equivalent-exchange-3/src/main/java/com/pahimar/ee3/block/BlockAlchemicalChest.java

96 lines
2.7 KiB
Java

package com.pahimar.ee3.block;
import com.pahimar.ee3.EquivalentExchange3;
import com.pahimar.ee3.lib.GuiIds;
import com.pahimar.ee3.lib.RenderIds;
import com.pahimar.ee3.lib.Strings;
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
/**
* Equivalent-Exchange-3
* <p/>
* BlockAlchemicalChest
*
* @author pahimar
*/
public class BlockAlchemicalChest extends BlockEE implements ITileEntityProvider
{
public BlockAlchemicalChest(int id)
{
super(id, Material.wood);
this.setHardness(2.5F);
this.setUnlocalizedName(Strings.ALCHEMICAL_CHEST_NAME);
this.setCreativeTab(EquivalentExchange3.tabsEE3);
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileAlchemicalChest();
}
@Override
public TileEntity createTileEntity(World world, int metaData)
{
return new TileAlchemicalChest(metaData);
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public int getRenderType()
{
return RenderIds.alchemicalChestRender;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
if (player.isSneaking() || world.isBlockSolidOnSide(x, y + 1, z, ForgeDirection.DOWN))
{
return true;
}
else
{
if (!world.isRemote)
{
if (world.getBlockTileEntity(x, y, z) instanceof TileAlchemicalChest)
{
if (world.getBlockMetadata(x, y, z) == 0)
{
player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST_SMALL, world, x, y, z);
}
else if (world.getBlockMetadata(x, y, z) == 1)
{
player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST_MEDIUM, world, x, y, z);
}
else if (world.getBlockMetadata(x, y, z) == 2)
{
player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST_LARGE, world, x, y, z);
}
}
}
return true;
}
}
}