mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
72 lines
2.2 KiB
Java
72 lines
2.2 KiB
Java
/**
|
|
* 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 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.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;
|
|
|
|
import javax.annotation.Nonnull;
|
|
import java.util.List;
|
|
|
|
public class ItemCraftPattern extends ItemMod {
|
|
|
|
public ItemCraftPattern() {
|
|
super(LibItemNames.CRAFT_PATTERN);
|
|
setHasSubtypes(true);
|
|
setMaxStackSize(1);
|
|
}
|
|
|
|
@Nonnull
|
|
@Override
|
|
public EnumActionResult onItemUse(ItemStack stack, 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 = stack.getItemDamage();
|
|
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 8);
|
|
return EnumActionResult.SUCCESS;
|
|
}
|
|
return EnumActionResult.PASS;
|
|
}
|
|
|
|
@Override
|
|
public void getSubItems(@Nonnull Item item, CreativeTabs tab, List<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);
|
|
}
|
|
|
|
}
|