mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-16 10:44:53 +00:00
165 lines
5.1 KiB
Java
165 lines
5.1 KiB
Java
package binnie.extratrees.block;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockWoodSlab;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
|
|
import binnie.core.block.BlockMetadata;
|
|
import binnie.core.block.IBlockMetadata;
|
|
import binnie.core.block.TileEntityMetadata;
|
|
import binnie.core.util.I18N;
|
|
import binnie.extratrees.ExtraTrees;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import forestry.api.core.Tabs;
|
|
|
|
public class BlockETSlab extends BlockWoodSlab implements IBlockMetadata {
|
|
|
|
public BlockETSlab(boolean isDouble) {
|
|
super(isDouble);
|
|
setCreativeTab(Tabs.tabArboriculture);
|
|
setHardness(2.0f);
|
|
setResistance(5.0f);
|
|
setStepSound(Block.soundTypeWood);
|
|
|
|
if (!field_150004_a) {
|
|
useNeighborBrightness = true;
|
|
}
|
|
|
|
setLightOpacity(0);
|
|
setBlockName("slabs");
|
|
}
|
|
|
|
@Override
|
|
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int blockMeta, int fortune) {
|
|
ArrayList<ItemStack> drops = new ArrayList<>(
|
|
BlockMetadata.getBlockDropped((IBlockMetadata) ExtraTrees.blockSlab, world, x, y, z, blockMeta));
|
|
if (field_150004_a) {
|
|
drops.addAll(
|
|
BlockMetadata.getBlockDropped((IBlockMetadata) ExtraTrees.blockSlab, world, x, y, z, blockMeta));
|
|
}
|
|
return drops;
|
|
}
|
|
|
|
@Override
|
|
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
|
return BlockMetadata.breakBlock(this, player, world, x, y, z);
|
|
}
|
|
|
|
@Override
|
|
public TileEntity createNewTileEntity(World world, int meta) {
|
|
return new TileEntityMetadata();
|
|
}
|
|
|
|
@Override
|
|
public boolean hasTileEntity(int meta) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventType) {
|
|
super.onBlockEventReceived(world, x, y, z, eventId, eventType);
|
|
TileEntity tileentity = world.getTileEntity(x, y, z);
|
|
return tileentity != null && tileentity.receiveClientEvent(eventId, eventType);
|
|
}
|
|
|
|
@Override
|
|
public int getPlacedMeta(ItemStack itemStack, World world, int x, int y, int z, ForgeDirection direction) {
|
|
return TileEntityMetadata.getItemDamage(itemStack);
|
|
}
|
|
|
|
@Override
|
|
public int getDroppedMeta(int blockMeta, int tileMeta) {
|
|
return tileMeta;
|
|
}
|
|
|
|
@Override
|
|
public String getBlockName(ItemStack itemStack) {
|
|
int meta = TileEntityMetadata.getItemDamage(itemStack);
|
|
return I18N.localise("extratrees.block.woodslab.name", PlankType.ExtraTreePlanks.VALUES[meta].getName());
|
|
}
|
|
|
|
@Override
|
|
public void addBlockTooltip(ItemStack itemStack, List<String> tooltip) {
|
|
// ignored
|
|
}
|
|
|
|
@Override
|
|
public void dropAsStack(World world, int x, int y, int z, ItemStack itemStack) {
|
|
dropBlockAsItem(world, x, y, z, itemStack);
|
|
}
|
|
|
|
@Override
|
|
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
|
|
if (field_150004_a) {
|
|
return;
|
|
}
|
|
for (int i = 0; i < PlankType.ExtraTreePlanks.VALUES.length; ++i) {
|
|
list.add(TileEntityMetadata.getItemStack(this, i));
|
|
}
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
|
TileEntityMetadata tile = TileEntityMetadata.getTile(world, x, y, z);
|
|
if (tile != null) {
|
|
return getIcon(side, tile.getTileMetadata());
|
|
}
|
|
return super.getIcon(world, x, y, z, side);
|
|
}
|
|
|
|
@Override
|
|
public IIcon getIcon(int side, int meta) {
|
|
return PlankType.ExtraTreePlanks.VALUES[meta].getIcon();
|
|
}
|
|
|
|
@Override
|
|
public void breakBlock(World world, int x, int y, int z, Block block, int side) {
|
|
super.breakBlock(world, x, y, z, block, side);
|
|
world.removeTileEntity(x, y, z);
|
|
}
|
|
|
|
@Override
|
|
public boolean isOpaqueCube() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean isWood(IBlockAccess world, int x, int y, int z) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
|
return 20;
|
|
}
|
|
|
|
@Override
|
|
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
|
return 5;
|
|
}
|
|
|
|
@Override
|
|
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
|
|
return BlockMetadata.getPickBlock(world, x, y, z);
|
|
}
|
|
}
|