Workbench block

This commit is contained in:
Emmanuel BENOîT 2016-07-13 12:39:40 +02:00
parent afe308f2ba
commit ac0c7be5f0
8 changed files with 116 additions and 1 deletions

Binary file not shown.

View file

@ -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( );
}

View file

@ -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( ) );

View file

@ -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 );
}
}

View file

@ -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 }
}
}

View file

@ -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"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "mmm:block/tech/base/workbench"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B