Files
MagicBees/src/main/java/magicbees/block/BlockHive.java
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
2.9 KiB
Java
Raw Normal View History

2013-05-23 21:07:28 -07:00
package magicbees.block;
2022-10-12 21:09:45 +02:00
import java.util.ArrayList;
import java.util.List;
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;
import net.minecraft.client.renderer.texture.IIconRegister;
2013-05-23 21:07:28 -07:00
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
2013-05-23 21:07:28 -07:00
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
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;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2022-10-12 21:09:45 +02:00
import forestry.api.core.Tabs;
2022-10-12 21:09:45 +02:00
public class BlockHive extends Block {
2022-10-12 21:09:45 +02:00
public BlockHive() {
super(new MaterialHive());
this.setLightLevel(0.8f);
setHardness(1f);
setCreativeTab(Tabs.tabApiculture);
setBlockName("hive");
}
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
return false;
}
@Override
public int damageDropped(int meta) {
return meta;
}
2013-05-23 21:07:28 -07:00
2022-10-12 21:09:45 +02:00
@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();
}
2013-05-23 21:07:28 -07:00
2022-10-12 21:09:45 +02:00
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List itemsList) {
// Java bitches about raw types & types not being checked. Sorry, but the API sucks.
for (HiveType type : HiveType.values()) {
if (type.show || Config.forestryDebugEnabled) {
itemsList.add(new ItemStack(this, 1, type.ordinal()));
}
}
}
2013-05-23 21:07:28 -07:00
2022-10-12 21:09:45 +02:00
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return HiveType.getHiveFromMeta(metadata).getDrops(world, x, y, z, fortune);
}
2013-05-23 21:07:28 -07:00
2022-10-12 21:09:45 +02:00
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
HiveType.registerIcons(register);
}
2013-05-23 21:07:28 -07:00
2022-10-12 21:09:45 +02:00
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
if (meta < 0 || meta > HiveType.values().length) {
meta = 0;
}
return HiveType.getHiveFromMeta(meta).getIconForSide(side);
}
2013-05-23 21:07:28 -07:00
2022-10-12 21:09:45 +02:00
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
2013-05-23 21:07:28 -07:00
2022-10-12 21:09:45 +02:00
if (block.isAir(world, x, y, z)) {
return null;
}
2022-10-12 21:09:45 +02:00
Item item = Item.getItemFromBlock(block);
if (item == null) {
return null;
}
2022-10-12 21:09:45 +02:00
return new ItemStack(item, 1, getDamageValue(world, x, y, z) & 7);
}
2013-05-23 21:07:28 -07:00
}