2013-05-23 21:07:28 -07:00
|
|
|
package magicbees.block;
|
|
|
|
|
|
2015-01-08 21:48:13 -08:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2014-04-08 12:39:01 -07:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-05-23 21:07:28 -07:00
|
|
|
import magicbees.block.types.HiveType;
|
2015-01-10 14:01:51 -08:00
|
|
|
import magicbees.main.Config;
|
2013-05-23 21:07:28 -07:00
|
|
|
import net.minecraft.block.Block;
|
2014-04-08 12:39:01 -07:00
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
2013-05-23 21:07:28 -07:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
2014-04-08 12:39:01 -07:00
|
|
|
import net.minecraft.entity.Entity;
|
2013-05-23 21:07:28 -07:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-04-08 12:39:01 -07:00
|
|
|
import net.minecraft.util.IIcon;
|
2013-05-23 21:07:28 -07:00
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
|
import net.minecraft.world.World;
|
2015-01-08 21:48:13 -08:00
|
|
|
import forestry.api.core.Tabs;
|
2013-05-23 21:07:28 -07:00
|
|
|
|
|
|
|
|
public class BlockHive extends Block
|
2015-01-08 21:48:13 -08:00
|
|
|
{
|
2014-04-08 12:39:01 -07:00
|
|
|
public BlockHive()
|
2013-05-23 21:07:28 -07:00
|
|
|
{
|
2014-04-08 12:39:01 -07:00
|
|
|
super(new MaterialHive());
|
|
|
|
|
this.setLightLevel(0.8f);
|
2013-05-23 21:07:28 -07:00
|
|
|
setHardness(1f);
|
|
|
|
|
setCreativeTab(Tabs.tabApiculture);
|
2014-04-08 12:39:01 -07:00
|
|
|
setBlockName("hive");
|
2013-05-23 21:07:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-04-08 12:39:01 -07:00
|
|
|
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity)
|
2013-05-23 21:07:28 -07:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-01-08 21:48:13 -08:00
|
|
|
public int damageDropped(int meta)
|
2013-05-23 21:07:28 -07:00
|
|
|
{
|
|
|
|
|
return meta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
|
|
|
|
{
|
|
|
|
|
int meta = world.getBlockMetadata(x, y, z);
|
|
|
|
|
if (meta < 0 || meta > HiveType.values().length)
|
|
|
|
|
{
|
|
|
|
|
meta = 0;
|
|
|
|
|
}
|
|
|
|
|
return HiveType.getHiveFromMeta(meta).getLightValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
@Override
|
2014-04-08 12:39:01 -07:00
|
|
|
public void getSubBlocks(Item item, CreativeTabs tab, List itemsList)
|
2013-05-23 21:07:28 -07:00
|
|
|
{
|
|
|
|
|
for (HiveType type : HiveType.values())
|
|
|
|
|
{
|
2015-01-10 14:02:45 -08:00
|
|
|
if (type.show || Config.forestryDebugEnabled)
|
2013-05-23 21:07:28 -07:00
|
|
|
{
|
|
|
|
|
itemsList.add(new ItemStack(this, 1, type.ordinal()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-04-08 12:39:01 -07:00
|
|
|
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
|
|
|
|
{
|
2013-05-29 11:15:25 -07:00
|
|
|
return HiveType.getHiveFromMeta(metadata).getDrops(world, x, y, z, fortune);
|
2013-05-23 21:07:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2014-04-08 12:39:01 -07:00
|
|
|
public void registerBlockIcons(IIconRegister register)
|
2013-05-23 21:07:28 -07:00
|
|
|
{
|
|
|
|
|
HiveType.registerIcons(register);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2014-04-08 12:39:01 -07:00
|
|
|
public IIcon getIcon(int side, int meta)
|
2013-05-23 21:07:28 -07:00
|
|
|
{
|
|
|
|
|
if (meta < 0 || meta > HiveType.values().length)
|
|
|
|
|
{
|
|
|
|
|
meta = 0;
|
|
|
|
|
}
|
|
|
|
|
return HiveType.getHiveFromMeta(meta).getIconForSide(side);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
|
|
|
|
{
|
2014-04-08 12:39:01 -07:00
|
|
|
Block block = world.getBlock(x, y, z);
|
2013-05-23 21:07:28 -07:00
|
|
|
|
2015-01-08 21:48:13 -08:00
|
|
|
if (block.isAir(world, x, y, z))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2014-04-08 12:39:01 -07:00
|
|
|
|
2015-01-08 21:48:13 -08:00
|
|
|
Item item = Item.getItemFromBlock(block);
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ItemStack(item, 1, getDamageValue(world, x, y, z) & 7);
|
2013-05-23 21:07:28 -07:00
|
|
|
}
|
|
|
|
|
}
|