package com.projectreddog.machinemod.block; import javax.annotation.Nullable; import com.projectreddog.machinemod.creativetab.CreativeTabMachineMod; import com.projectreddog.machinemod.init.ModBlocks; import com.projectreddog.machinemod.reference.Reference; import com.projectreddog.machinemod.tileentities.TileEntityWellHead; import net.minecraft.block.BlockContainer; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockMachineModWellHead extends BlockContainer { // public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); protected BlockMachineModWellHead(Material material) { super(material); // TODO Find bounds fix // this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.5F, 1.0F); // can override later ;) this.setCreativeTab(CreativeTabMachineMod.MACHINEMOD_BLOCKS_TAB); // this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); // 1.8 this.setUnlocalizedName(Reference.MOD_ID.toLowerCase() + ":" + Reference.MODBLOCK_MACHINE_WELL_HEAD); // this.setBlockTextureName(Reference.MODBLOCK_MACHINE_BLASTED_STONE); // this.setHardness(15f);// not sure on the hardness this.setSoundType(SoundType.STONE); this.setHardness(1.5f); } @Override public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { if (worldIn.getBlockState(pos.down()).getBlock() == ModBlocks.machinedrilledstone) { EnumFacing ef = (EnumFacing) worldIn.getBlockState(pos.down()).getValue(BlockMachineDrilledStone.FACING); if (ef == EnumFacing.DOWN || ef == EnumFacing.UP) { return true; } } return false; } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, net.minecraft.entity.player.EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity te = worldIn.getTileEntity(pos); if (te != null && !playerIn.isSneaking()) { // playerIn.openGui(MachineMod.instance, Reference.GUI_DISTILLER, worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } else { return false; } }; public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { // only place on drilled stone vertical worldIn.setBlockState(pos, state, 2); if (stack.hasDisplayName()) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityFurnace) { ((TileEntityFurnace) tileentity).setCustomInventoryName(stack.getDisplayName()); } } } public BlockMachineModWellHead() { // Generic constructor (set to rock by default) this(Material.IRON); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { // NEED TO return the TE here return new TileEntityWellHead(); } @Override public EnumBlockRenderType getRenderType(IBlockState state) { // 3 for normal block 2 for TESR 1 liquid -1 nothing ( like air) // return 3; return EnumBlockRenderType.MODEL; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof IInventory) { InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory) tileentity); worldIn.updateComparatorOutputLevel(pos, this); } super.breakBlock(worldIn, pos, state); } }