From ac0c7be5f0d14106fe3edc641bfe5e1f5bd1c253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Wed, 13 Jul 2016 12:39:40 +0200 Subject: [PATCH] Workbench block --- graphics/workbench-front.xcf | Bin 0 -> 2528 bytes src/java/mmm/tech/base/TBMachines.java | 3 + .../tech/base/alloy_furnace/TBAFBlock.java | 1 - .../mmm/tech/base/workbench/TBWorkbench.java | 89 ++++++++++++++++++ .../mmm/blockstates/tech/base/workbench.json | 8 ++ .../mmm/models/block/tech/base/workbench.json | 13 +++ .../mmm/models/item/tech/base/workbench.json | 3 + .../textures/blocks/tech/base/workbench.png | Bin 0 -> 411 bytes 8 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 graphics/workbench-front.xcf create mode 100644 src/java/mmm/tech/base/workbench/TBWorkbench.java create mode 100644 src/resources/assets/mmm/blockstates/tech/base/workbench.json create mode 100644 src/resources/assets/mmm/models/block/tech/base/workbench.json create mode 100644 src/resources/assets/mmm/models/item/tech/base/workbench.json create mode 100644 src/resources/assets/mmm/textures/blocks/tech/base/workbench.png diff --git a/graphics/workbench-front.xcf b/graphics/workbench-front.xcf new file mode 100644 index 0000000000000000000000000000000000000000..a7fcab1619fa98c8a520b61e66912038194ae42f GIT binary patch literal 2528 zcmd5;O=#mr6rLG7wYyE}Hu2UZtg&HJJ4;cMpk4%Z4{1+LbQ2}0pkifhcW7b<$xGJI zvOVZ79R)oIiopk8b=0}n_S}z<8Vr>K}tp3Xf%w;vsK&td{c~jl&y5@IY7;OpxJ)y z-3mfq*+;E?-s{%3vRGgo-e*j0(#swn)Oc_I$F`05ey3x%2X7KY^xLMHEUt6ut08<^bOsLzSe}tazfnfP>L5iu4?(e5MOaxy8`rvp3 zlIb7J>5FsvhjaQzpd)WK3ZP{8?A7P8O+whWsh*_{zRb95V?A6aD*+3xrSSW`P>NVY zSEf;DhhcqhuO5U!7_F>CLGViuekMh*5k)KHHTjbyC5JiJYsVYX@tV(kTAKQv;dwPl zsyUwH`K6NYID3xwY|V!a-!IKjiz-vE%R5h3cgiL+>EhJX6?~N<;`YnIpx?96{t#-9ZI_PRAE}b%3$@Sveb<&d#r1b2 z{#7Sm&OJZ+Y@B!l?6lr0W3O@7yqEJ&BVN8t*J3hoJCd&N+K&% zfwQQmb=5RgXkbM)RYDZ(Y*W>leyQLZ8=9I-y;96NuI0SU6e^$9Wd$}(*;D|oQ~g|^ zfkicSU8O2jF3?@q>%h)bs$U2?Syp6aK{=5Xfa}05BCD#bn}n!J9b!!dgQ5zwERutK zfCiFN&=L-4PB;bw>jJCW%4f!>nRKX literal 0 HcmV?d00001 diff --git a/src/java/mmm/tech/base/TBMachines.java b/src/java/mmm/tech/base/TBMachines.java index 551559d..e1eee4f 100644 --- a/src/java/mmm/tech/base/TBMachines.java +++ b/src/java/mmm/tech/base/TBMachines.java @@ -2,17 +2,20 @@ package mmm.tech.base; import mmm.tech.base.alloy_furnace.TBAlloyFurnace; +import mmm.tech.base.workbench.TBWorkbench; public class TBMachines { public final TBAlloyFurnace ALLOY_FURNACE; + public final TBWorkbench WORKBENCH; public TBMachines( ) { this.ALLOY_FURNACE = new TBAlloyFurnace( ); + this.WORKBENCH = new TBWorkbench( ); } diff --git a/src/java/mmm/tech/base/alloy_furnace/TBAFBlock.java b/src/java/mmm/tech/base/alloy_furnace/TBAFBlock.java index fe199c7..bdb3650 100644 --- a/src/java/mmm/tech/base/alloy_furnace/TBAFBlock.java +++ b/src/java/mmm/tech/base/alloy_furnace/TBAFBlock.java @@ -319,7 +319,6 @@ public class TBAFBlock TBAFBlock.FACING , placer.getHorizontalFacing( ).getOpposite( ) ) , 2 ); if ( stack.hasDisplayName( ) ) { - System.err.println( "HAZ A NAME!" ); final TileEntity tileentity = worldIn.getTileEntity( pos ); if ( tileentity instanceof TBAFTileEntity ) { ( (TBAFTileEntity) tileentity ).setCustomName( stack.getDisplayName( ) ); diff --git a/src/java/mmm/tech/base/workbench/TBWorkbench.java b/src/java/mmm/tech/base/workbench/TBWorkbench.java new file mode 100644 index 0000000..5b70ccc --- /dev/null +++ b/src/java/mmm/tech/base/workbench/TBWorkbench.java @@ -0,0 +1,89 @@ +package mmm.tech.base.workbench; + + +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; +import mmm.tech.base.alloy_furnace.TBAFBlock; +import net.minecraft.block.Block; +import net.minecraft.block.BlockHorizontal; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.block.properties.PropertyDirection; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.registry.GameRegistry; + + + +public class TBWorkbench + extends Block + implements I_RecipeRegistrar +{ + public static final PropertyDirection FACING = BlockHorizontal.FACING; + + + public TBWorkbench( ) + { + super( Material.WOOD ); + + this.setCreativeTab( CreativeTabs.DECORATIONS ); + this.setHardness( 2.5f ); + this.setSoundType( SoundType.WOOD ); + this.setHarvestLevel( "axe" , 0 ); + + this.setDefaultState( this.blockState.getBaseState( ) // + .withProperty( TBWorkbench.FACING , EnumFacing.NORTH ) ); + + CRegistry.setIdentifiers( this , "tech" , "base" , "workbench" ); + CRegistry.addBlock( this ); + } + + + @Override + public void registerRecipes( ) + { + GameRegistry.addShapelessRecipe( new ItemStack( this ) , // + Blocks.CRAFTING_TABLE , // + Blocks.CHEST , // + Items.BOOK ); + } + + + @Override + protected BlockStateContainer createBlockState( ) + { + return new BlockStateContainer( this , TBWorkbench.FACING ); + } + + + @Override + public IBlockState getStateFromMeta( final int meta ) + { + return this.getDefaultState( ) // + .withProperty( TBWorkbench.FACING , EnumFacing.getHorizontal( meta ) ); + } + + + @Override + public int getMetaFromState( final IBlockState state ) + { + return state.getValue( TBWorkbench.FACING ).getHorizontalIndex( ); + } + + + @Override + public void onBlockPlacedBy( final World worldIn , final BlockPos pos , final IBlockState state , + final EntityLivingBase placer , final ItemStack stack ) + { + worldIn.setBlockState( pos , state.withProperty( // + TBAFBlock.FACING , placer.getHorizontalFacing( ).getOpposite( ) ) , 2 ); + } +} diff --git a/src/resources/assets/mmm/blockstates/tech/base/workbench.json b/src/resources/assets/mmm/blockstates/tech/base/workbench.json new file mode 100644 index 0000000..d83f06f --- /dev/null +++ b/src/resources/assets/mmm/blockstates/tech/base/workbench.json @@ -0,0 +1,8 @@ +{ + "variants": { + "facing=north": { "model": "mmm:tech/base/workbench" } , + "facing=east": { "model": "mmm:tech/base/workbench" , "y": 90 } , + "facing=south": { "model": "mmm:tech/base/workbench" , "y": 180 } , + "facing=west": { "model": "mmm:tech/base/workbench" , "y": 270 } + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/block/tech/base/workbench.json b/src/resources/assets/mmm/models/block/tech/base/workbench.json new file mode 100644 index 0000000..e0c5c6f --- /dev/null +++ b/src/resources/assets/mmm/models/block/tech/base/workbench.json @@ -0,0 +1,13 @@ +{ + "parent": "minecraft:block/cube", + "textures": + { + "particle": "mmm:blocks/tech/base/workbench", + "down": "minecraft:blocks/planks_oak", + "up": "minecraft:blocks/crafting_table_top", + "north": "mmm:blocks/tech/base/workbench", + "west": "minecraft:blocks/crafting_table_front", + "east": "minecraft:blocks/crafting_table_side", + "south": "minecraft:blocks/crafting_table_side" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/tech/base/workbench.json b/src/resources/assets/mmm/models/item/tech/base/workbench.json new file mode 100644 index 0000000..88d6c91 --- /dev/null +++ b/src/resources/assets/mmm/models/item/tech/base/workbench.json @@ -0,0 +1,3 @@ +{ + "parent": "mmm:block/tech/base/workbench" +} \ No newline at end of file diff --git a/src/resources/assets/mmm/textures/blocks/tech/base/workbench.png b/src/resources/assets/mmm/textures/blocks/tech/base/workbench.png new file mode 100644 index 0000000000000000000000000000000000000000..d74f94892e52c54f6ea78b1e44763b607ecc295a GIT binary patch literal 411 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkET0>Ux0bwWwcYmjxe3!o**cjr`K^2R-Dwf!`Ngg%v7udJ z_q85}o7X27R%cceill~3@;G=uee?3y4}S2!v`u1e++=@;?@eu4n*C|5HF7r?RD$jZ zttboA%NGx4^t~Jrd;P5>(^LV$AHQm@z5iJ$t+BvJ*&&QG^DhI_PbF4{cB9Ih45llz zzB%}|OjVe=KyF3nk1pE_A6|&Igs^T?YFux**0%L~I+ww+_v`k)5y+UbSWdu)b5iUq z=C2O6r$r9T+gEKRKC9WIaecn&-qXJx+`r#^BmP+w&*SrJG|E6>?CI*~vd$@?2>{&o BqtE~V literal 0 HcmV?d00001