forked from vadis365/PrimalTech
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
254 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package primal_tech.blocks; | ||
|
||
import java.util.Random; | ||
|
||
import net.minecraft.block.BlockBed; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.BlockRenderLayer; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.IBlockAccess; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
import primal_tech.PrimalTech; | ||
|
||
public class BlockLeafBed extends BlockBed { | ||
|
||
public BlockLeafBed() { | ||
super(); | ||
disableStats(); | ||
} | ||
|
||
@Override | ||
public boolean isBed(IBlockState state, IBlockAccess world, BlockPos pos, Entity player) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) { | ||
if (state.getValue(PART) == BlockBed.EnumPartType.FOOT) | ||
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, 0); | ||
} | ||
|
||
@Override | ||
public Item getItemDropped(IBlockState state, Random rand, int fortune) { | ||
return state.getValue(PART) == BlockBed.EnumPartType.HEAD ? null : PrimalTech.LEAF_BED_ITEM; | ||
} | ||
|
||
@SideOnly(Side.CLIENT) | ||
@Override | ||
public BlockRenderLayer getBlockLayer() { | ||
return BlockRenderLayer.CUTOUT; | ||
} | ||
|
||
@Override | ||
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { | ||
return new ItemStack(PrimalTech.LEAF_BED_ITEM); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package primal_tech.items; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockBed; | ||
import net.minecraft.block.SoundType; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.EnumActionResult; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.util.SoundCategory; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraft.world.World; | ||
import primal_tech.PrimalTech; | ||
|
||
public class ItemLeafBed extends Item { | ||
|
||
public ItemLeafBed() { | ||
setCreativeTab(PrimalTech.TAB); | ||
} | ||
|
||
@Override | ||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { | ||
if (world.isRemote) | ||
return EnumActionResult.SUCCESS; | ||
else if (facing != EnumFacing.UP) | ||
return EnumActionResult.FAIL; | ||
else { | ||
IBlockState iblockstate = world.getBlockState(pos); | ||
Block block = iblockstate.getBlock(); | ||
boolean flag = block.isReplaceable(world, pos); | ||
|
||
if (!flag) | ||
pos = pos.up(); | ||
|
||
int i = MathHelper.floor((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; | ||
EnumFacing enumfacing = EnumFacing.getHorizontal(i); | ||
BlockPos blockpos = pos.offset(enumfacing); | ||
ItemStack itemstack = player.getHeldItem(hand); | ||
|
||
if (player.canPlayerEdit(pos, facing, itemstack) && player.canPlayerEdit(blockpos, facing, itemstack)) { | ||
IBlockState iblockstate1 = world.getBlockState(blockpos); | ||
boolean flag1 = iblockstate1.getBlock().isReplaceable(world, blockpos); | ||
boolean flag2 = flag || world.isAirBlock(pos); | ||
boolean flag3 = flag1 || world.isAirBlock(blockpos); | ||
|
||
if (flag2 && flag3 && world.getBlockState(pos.down()).isFullyOpaque()&& world.getBlockState(blockpos.down()).isFullyOpaque()) { | ||
IBlockState iblockstate2 = PrimalTech.LEAF_BED.getDefaultState().withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)).withProperty(BlockBed.FACING, enumfacing).withProperty(BlockBed.PART, BlockBed.EnumPartType.FOOT); | ||
world.setBlockState(pos, iblockstate2, 10); | ||
world.setBlockState(blockpos, iblockstate2.withProperty(BlockBed.PART, BlockBed.EnumPartType.HEAD), 10); | ||
world.notifyNeighborsRespectDebug(pos, block, false); | ||
world.notifyNeighborsRespectDebug(blockpos, iblockstate1.getBlock(), false); | ||
SoundType soundtype = iblockstate2.getBlock().getSoundType(iblockstate2, world, pos, player); | ||
world.playSound((EntityPlayer) null, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); | ||
itemstack.shrink(1); | ||
return EnumActionResult.SUCCESS; | ||
} else | ||
return EnumActionResult.FAIL; | ||
} else | ||
return EnumActionResult.FAIL; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/resources/assets/primal_tech/blockstates/leaf_bed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"variants": { | ||
"facing=north,part=foot": { "model": "primal_tech:leaf_bed", "y": 180 }, | ||
"facing=east,part=foot": { "model": "primal_tech:leaf_bed", "y": 270 }, | ||
"facing=south,part=foot": { "model": "primal_tech:leaf_bed" }, | ||
"facing=west,part=foot": { "model": "primal_tech:leaf_bed", "y": 90 }, | ||
"facing=north,part=head": { "model": "primal_tech:leaf_bed" }, | ||
"facing=east,part=head": { "model": "primal_tech:leaf_bed", "y": 90 }, | ||
"facing=south,part=head": { "model": "primal_tech:leaf_bed", "y": 180 }, | ||
"facing=west,part=head": { "model": "primal_tech:leaf_bed", "y": 270 } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
src/main/resources/assets/primal_tech/models/block/leaf_bed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"parent": "block/cube_all", | ||
"textures": { | ||
"0": "primal_tech:blocks/bed_leaves", | ||
"1": "blocks/hay_block_top", | ||
"2": "blocks/hay_block_side", | ||
"3": "blocks/planks_oak", | ||
"particle": "primal_tech:blocks/bed_leaves" | ||
}, | ||
"elements": [ | ||
{ | ||
"name": "leaves", | ||
"from": [ 1.0, 6.0, 1.0 ], | ||
"to": [ 15.0, 8.0, 16.0 ], | ||
"faces": { | ||
"east": { "texture": "#0", "uv": [ 1.0, 0.0, 16.0, 2.0 ] }, | ||
"west": { "texture": "#0", "uv": [ 1.0, 0.0, 16.0, 2.0 ] }, | ||
"up": { "texture": "#0", "uv": [ 1.0, 1.0, 15.0, 15.0 ] } | ||
} | ||
}, | ||
{ | ||
"name": "base", | ||
"from": [ 0.0, 0.0, 1.0 ], | ||
"to": [ 16.0, 6.0, 16.0 ], | ||
"faces": { | ||
"east": { "texture": "#1", "uv": [ 0.0, 0.0, 15.0, 6.0 ] }, | ||
"west": { "texture": "#1", "uv": [ 1.0, 0.0, 16.0, 6.0 ] }, | ||
"up": { "texture": "#2", "uv": [ 0.0, 0.0, 16.0, 15.0 ], "rotation": 90 }, | ||
"down": { "texture": "#2", "uv": [ 0.0, 0.0, 16.0, 15.0 ], "rotation": 90 } | ||
} | ||
}, | ||
{ | ||
"name": "head_1", | ||
"from": [ 0.0, 0.0, 0.0 ], | ||
"to": [ 2.0, 8.0, 1.0 ], | ||
"faces": { | ||
"north": { "texture": "#3", "uv": [ 0.0, 0.0, 2.0, 8.0 ] }, | ||
"east": { "texture": "#3", "uv": [ 0.0, 0.0, 1.0, 8.0 ] }, | ||
"south": { "texture": "#3", "uv": [ 0.0, 0.0, 2.0, 8.0 ] }, | ||
"west": { "texture": "#3", "uv": [ 0.0, 0.0, 1.0, 8.0 ] }, | ||
"up": { "texture": "#3", "uv": [ 0.0, 0.0, 2.0, 1.0 ] }, | ||
"down": { "texture": "#3", "uv": [ 0.0, 0.0, 2.0, 1.0 ] } | ||
} | ||
}, | ||
{ | ||
"name": "head_2", | ||
"from": [ 2.0, 0.0, 0.0 ], | ||
"to": [ 6.0, 9.0, 1.0 ], | ||
"faces": { | ||
"north": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 9.0 ] }, | ||
"east": { "texture": "#3", "uv": [ 0.0, 0.0, 1.0, 9.0 ] }, | ||
"south": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 9.0 ] }, | ||
"west": { "texture": "#3", "uv": [ 0.0, 0.0, 1.0, 9.0 ] }, | ||
"up": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 1.0 ] }, | ||
"down": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 1.0 ] } | ||
} | ||
}, | ||
{ | ||
"name": "head_3", | ||
"from": [ 6.0, 0.0, 0.0 ], | ||
"to": [ 10.0, 10.0, 1.0 ], | ||
"faces": { | ||
"north": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 10.0 ] }, | ||
"east": { "texture": "#3", "uv": [ 0.0, 0.0, 1.0, 10.0 ] }, | ||
"south": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 10.0 ] }, | ||
"west": { "texture": "#3", "uv": [ 0.0, 0.0, -1.0, 9.0 ] }, | ||
"up": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 1.0 ] }, | ||
"down": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 1.0 ] } | ||
} | ||
}, | ||
{ | ||
"name": "head_4", | ||
"from": [ 10.0, 0.0, 0.0 ], | ||
"to": [ 14.0, 9.0, 1.0 ], | ||
"faces": { | ||
"north": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 9.0 ] }, | ||
"east": { "texture": "#3", "uv": [ 0.0, 0.0, 1.0, 9.0 ] }, | ||
"south": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 9.0 ] }, | ||
"west": { "texture": "#3", "uv": [ 0.0, 0.0, 1.0, 9.0 ] }, | ||
"up": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 1.0 ] }, | ||
"down": { "texture": "#3", "uv": [ 0.0, 0.0, 4.0, 1.0 ] } | ||
} | ||
}, | ||
{ | ||
"name": "head_5", | ||
"from": [ 14.0, 0.0, 0.0 ], | ||
"to": [ 16.0, 8.0, 1.0 ], | ||
"faces": { | ||
"north": { "texture": "#3", "uv": [ 0.0, 0.0, 2.0, 8.0 ] }, | ||
"east": { "texture": "#3", "uv": [ 0.0, 0.0, 1.0, 8.0 ] }, | ||
"south": { "texture": "#3", "uv": [ 0.0, 0.0, 2.0, 8.0 ] }, | ||
"west": { "texture": "#3", "uv": [ 0.0, 0.0, 1.0, 8.0 ] }, | ||
"up": { "texture": "#3", "uv": [ 0.0, 0.0, 2.0, 1.0 ] }, | ||
"down": { "texture": "#3", "uv": [ 0.0, 0.0, 2.0, 1.0 ] } | ||
} | ||
} | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/primal_tech/models/item/leaf_bed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "primal_tech:items/leaf_bed" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters