Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.looke81.biowarfare.blocks;
- import java.util.Random;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockContainer;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.properties.IProperty;
- import net.minecraft.block.properties.PropertyDirection;
- import net.minecraft.block.state.BlockState;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.tileentity.TileEntityFurnace;
- import net.minecraft.util.BlockPos;
- import net.minecraft.util.ChatComponentTranslation;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.util.EnumWorldBlockLayer;
- import net.minecraft.util.MathHelper;
- import net.minecraft.world.World;
- import net.minecraftforge.fml.common.network.internal.FMLNetworkHandler;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- import com.looke81.biowarfare.BioWarfare;
- import com.looke81.biowarfare.Reference;
- import com.looke81.biowarfare.container.ContainerMicrobeExtractor;
- import com.looke81.biowarfare.init.BioWarfareBlocks;
- import com.looke81.biowarfare.tileentity.TileEntityMicrobeExtractor;
- public class MicrobeExtractor extends BlockContainer {
- public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
- private final boolean isActive;
- private static boolean keepInventory;
- public MicrobeExtractor(boolean isActive) {
- super(Material.iron);
- this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
- this.isActive = isActive;
- this.setHardness(5.0F);
- }
- public static void setState(World worldIn, BlockPos pos, Block setter)
- {
- IBlockState iblockstate = worldIn.getBlockState(pos);
- TileEntity tileentity = worldIn.getTileEntity(pos);
- keepInventory = true;
- worldIn.setBlockState(pos, setter.getDefaultState().withProperty(MicrobeExtractor.FACING, iblockstate.getValue(MicrobeExtractor.FACING)), 3);
- worldIn.setBlockState(pos, setter.getDefaultState().withProperty(MicrobeExtractor.FACING, iblockstate.getValue(MicrobeExtractor.FACING)), 3);
- keepInventory = false;
- if (tileentity != null)
- {
- tileentity.validate();
- worldIn.setTileEntity(pos, tileentity);
- }
- worldIn.markBlockForUpdate(pos);
- }
- @Override
- @SideOnly(Side.CLIENT)
- public IBlockState getStateForEntityRender(IBlockState state) {
- return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
- }
- @Override
- public IBlockState getStateFromMeta(int meta) {
- EnumFacing enumFacing = EnumFacing.getFront(meta);
- if (enumFacing.getAxis() == EnumFacing.Axis.Y) {
- enumFacing = EnumFacing.NORTH;
- }
- return this.getDefaultState().withProperty(FACING, enumFacing);
- }
- @Override
- public int getMetaFromState(IBlockState state) {
- return ((EnumFacing) state.getValue(FACING)).getIndex();
- }
- @Override
- protected BlockState createBlockState() {
- return new BlockState(this, new IProperty[] { FACING });
- }
- @Override
- public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
- return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
- }
- public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
- if (!world.isRemote) {
- FMLNetworkHandler.openGui(player, BioWarfare.instance, 0, world, pos.getX(), pos.getY(), pos.getZ());
- }
- return true;
- }
- public int getRenderType() {
- return 3;
- }
- public Item getItemDropped(int i, Random random, int j) {
- return Item.getItemFromBlock(BioWarfareBlocks.block_MicrobeExtractorIdle);
- }
- public Item getItem(World world, int x, int y, int z) {
- return Item.getItemFromBlock(BioWarfareBlocks.block_MicrobeExtractorIdle);
- }
- @Override
- public TileEntity createNewTileEntity(World worldIn, int meta) {
- return new TileEntityMicrobeExtractor();
- }
Advertisement
Add Comment
Please, Sign In to add comment