/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jan 28, 2015, 2:59:06 PM (GMT)]
*/
package vazkii.botania.common.item;
import java.util.List;
import javax.annotation.Nonnull;
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.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.client.core.handler.ModelHandler;
import vazkii.botania.common.block.tile.TileCraftCrate;
import vazkii.botania.common.lib.LibItemNames;
public class ItemCraftPattern extends ItemMod {
public ItemCraftPattern() {
super(LibItemNames.CRAFT_PATTERN);
setHasSubtypes(true);
setMaxStackSize(1);
}
@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer p, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile instanceof TileCraftCrate) {
TileCraftCrate crate = (TileCraftCrate) tile;
crate.pattern = p.getHeldItem(hand).getItemDamage();
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 8);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> list) {
for(int i = 0; i < TileCraftCrate.PATTERNS.length; i++)
list.add(new ItemStack(item, 1, i));
}
@Nonnull
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage();
}
@SideOnly(Side.CLIENT)
@Override
public void registerModels() {
ModelHandler.registerItemAppendMeta(this, 9, LibItemNames.CRAFT_PATTERN);
}
}