Skip to content

Commit

Permalink
leaf bed
Browse files Browse the repository at this point in the history
  • Loading branch information
vadis365 committed Jul 29, 2017
1 parent 1218314 commit c5c77d2
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "0.1.28"
version = "0.1.29"
group= "somepeople" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "PrimalTech"
sourceCompatibility = targetCompatibility = "1.8"
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/primal_tech/PrimalTech.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import primal_tech.blocks.BlockFibreTorch;
import primal_tech.blocks.BlockFibreTorchLit;
import primal_tech.blocks.BlockFlint;
import primal_tech.blocks.BlockLeafBed;
import primal_tech.blocks.BlockStickBundle;
import primal_tech.blocks.BlockStoneAnvil;
import primal_tech.blocks.BlockStoneGrill;
Expand All @@ -62,13 +63,14 @@
import primal_tech.items.ItemClub;
import primal_tech.items.ItemFireSticks;
import primal_tech.items.ItemFluidBladder;
import primal_tech.items.ItemLeafBed;
import primal_tech.items.ItemMaterials;
import primal_tech.network.FireSticksMessage;
import primal_tech.network.FireSticksPacketHandler;
import primal_tech.proxy.CommonProxy;
import primal_tech.recipes.ModRecipes;

@Mod(modid = "primal_tech", name = "primal_tech", version = "0.1.28", guiFactory = "primal_tech.configs.ConfigGuiFactory", dependencies = "after:*")
@Mod(modid = "primal_tech", name = "primal_tech", version = "0.1.29", guiFactory = "primal_tech.configs.ConfigGuiFactory", dependencies = "after:*")

public class PrimalTech {

Expand All @@ -80,8 +82,9 @@ public class PrimalTech {

public static Item FIRE_STICKS, BONE_PICKAXE, BONE_AXE, BONE_SHOVEL, BONE_SWORD, BONE_SHEARS, BONE_KNIFE, FLUID_BLADDER,
BONE_SHARD, FLINT_BLOCK_ITEM, CHARCOAL_BLOCK_ITEM, CLAY_KILN_ITEM, STICK_BUNDLE_ITEM, FIBRE_TORCH_ITEM, WOODEN_HOPPER_ITEM, CHARCOAL_HOPPER_ITEM, STONE_ANVIL_ITEM,
FIBRE_TORCH_ITEM_LIT, PLANT_FIBRES, TWINE, WORK_STUMP_ITEM, ROCK, WOOD_CLUB, BONE_CLUB, STONE_CLUB, STONE_GRILL_ITEM, WORK_STUMP_II_ITEM, WATER_SAW_ITEM, FLINT_SAW_BLADE, STONE_MALLET;
public static Block CLAY_KILN, FLINT_BLOCK, STICK_BUNDLE, FIBRE_TORCH, FIBRE_TORCH_LIT, CHARCOAL_BLOCK, WORK_STUMP, STONE_GRILL, WOODEN_HOPPER, WORK_STUMP_II, CHARCOAL_HOPPER, WATER_SAW, STONE_ANVIL;
FIBRE_TORCH_ITEM_LIT, PLANT_FIBRES, TWINE, WORK_STUMP_ITEM, ROCK, WOOD_CLUB, BONE_CLUB, STONE_CLUB, STONE_GRILL_ITEM, WORK_STUMP_II_ITEM, WATER_SAW_ITEM,
FLINT_SAW_BLADE, STONE_MALLET, LEAF_BED_ITEM;
public static Block CLAY_KILN, FLINT_BLOCK, STICK_BUNDLE, FIBRE_TORCH, FIBRE_TORCH_LIT, CHARCOAL_BLOCK, WORK_STUMP, STONE_GRILL, WOODEN_HOPPER, WORK_STUMP_II, CHARCOAL_HOPPER, WATER_SAW, STONE_ANVIL, LEAF_BED;
public static ToolMaterial TOOL_BONE = EnumHelper.addToolMaterial("BONE_TOOLS", 1, 100, 5.0F, 0.0F, 15);
public static ToolMaterial TOOL_BONE_KNIFE = EnumHelper.addToolMaterial("BONE_KNIFE", 0, 10, 2.0F, 0.0F, 0);
public static SoundEvent BREAKING_STUFF;
Expand Down Expand Up @@ -189,6 +192,11 @@ public void addInformation(ItemStack stack, EntityPlayer player, List list, bool
GameRegistry.register(STONE_MALLET.setRegistryName("primal_tech", "stone_mallet").setUnlocalizedName("primal_tech.stone_mallet"));

//Blocks and Item Blocks
LEAF_BED = new BlockLeafBed();
LEAF_BED_ITEM = new ItemLeafBed();
GameRegistry.register(LEAF_BED.setRegistryName("primal_tech", "leaf_bed").setUnlocalizedName("primal_tech.leaf_bed"));
GameRegistry.register(LEAF_BED_ITEM.setRegistryName(LEAF_BED.getRegistryName()).setUnlocalizedName("primal_tech.leaf_bed"));

CLAY_KILN = new BlockClayKiln();
CLAY_KILN_ITEM = new ItemBlock(CLAY_KILN);
GameRegistry.register(CLAY_KILN.setRegistryName("primal_tech", "clay_kiln").setUnlocalizedName("primal_tech.clay_kiln"));
Expand Down
53 changes: 53 additions & 0 deletions src/main/java/primal_tech/blocks/BlockLeafBed.java
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);
}

}

66 changes: 66 additions & 0 deletions src/main/java/primal_tech/items/ItemLeafBed.java
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;
}
}
}
5 changes: 4 additions & 1 deletion src/main/java/primal_tech/proxy/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import primal_tech.PrimalTech;
import primal_tech.blocks.BlockLeafBed;
import primal_tech.blocks.BlockWoodenHopper;
import primal_tech.client.render.TileEntityKilnRenderer;
import primal_tech.client.render.TileEntityStoneAnvilRenderer;
Expand Down Expand Up @@ -60,7 +61,9 @@ public void registerRenderers() {
ModelLoader.setCustomModelResourceLocation(PrimalTech.FLUID_BLADDER, 1, new ModelResourceLocation("primal_tech:fluid_bladder_filled", "inventory"));
ModelLoader.setCustomModelResourceLocation(PrimalTech.STONE_ANVIL_ITEM, 0, new ModelResourceLocation("primal_tech:stone_anvil", "inventory"));
ModelLoader.setCustomModelResourceLocation(PrimalTech.STONE_MALLET, 0, new ModelResourceLocation("primal_tech:stone_mallet", "inventory"));

ModelLoader.setCustomModelResourceLocation(PrimalTech.LEAF_BED_ITEM, 0, new ModelResourceLocation("primal_tech:leaf_bed", "inventory"));
ModelLoader.setCustomStateMapper((PrimalTech.LEAF_BED), (new StateMap.Builder()).ignore(new IProperty[] {BlockLeafBed.OCCUPIED}).build());

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityKiln.class, new TileEntityKilnRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWorkStump.class, new TileEntityWorkStumpRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWorkStumpUpgraded.class, new TileEntityWorkStumpUpgradedRenderer());
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/assets/primal_tech/blockstates/leaf_bed.json
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 }
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/primal_tech/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tile.primal_tech.wooden_hopper.name=Wopper Mk2 :P
tile.primal_tech.charcoal_hopper.name=Flame Grilled Wopper
tile.primal_tech.water_saw.name=Water Powered Saw
tile.primal_tech.stone_anvil.name=Stone Anvil
tile.primal_tech.leaf_bed.name=Bed of Straw and Leaves

#Items
item.primal_tech.fire_sticks.name=Whittled Fire Sticks
Expand All @@ -31,6 +32,7 @@ item.primal_tech.bone_club.name=Bone Club
item.primal_tech.flint_edged_disc.name=Water Powered Saw Blade
item.primal_tech.fluid_bladder.name=Fluid Bladder
item.primal_tech.stone_mallet.name=Stone Mallet
item.primal_tech.leaf_bed.name=Bed of Straw and Leaves

#Creative Tab
itemGroup.primal_tech=Primal Tech
Expand Down
98 changes: 98 additions & 0 deletions src/main/resources/assets/primal_tech/models/block/leaf_bed.json
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 ] }
}
}
]
}
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.
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"modid": "primal_tech",
"name": "primal_tech",
"description": "Primal Technology.",
"version": "0.1.28",
"version": "0.1.29",
"url": "",
"updateUrl": "",
"authorList": [
Expand Down

0 comments on commit c5c77d2

Please sign in to comment.