Posted August 31, 201411 yr i have this growth amulet it has an max damge but i want to use the meta data for an ative and an non aactive version. mayby nbt or something i have no clue public class ItemAmuletGrowth extends ItemBaubles { public ItemAmuletGrowth(){ this.setUnlocalizedName("ItemAmuletGrowth"); setMaxDamage(1001); this.canRepair = true; } private int tickDelay = 100; @Override public BaubleType getBaubleType(ItemStack arg0) { return BaubleType.AMULET; } @Override public void onWornTick(ItemStack stack, EntityLivingBase entity) { { World par2World = entity.worldObj; if (!(entity instanceof EntityPlayer)) { return; } EntityPlayer par3EntityPlayer = (EntityPlayer) entity; if (stack.stackTagCompound == null) { stack.setTagCompound(new NBTTagCompound()); } { if (par2World.getWorldTime() % tickDelay == stack.stackTagCompound.getInteger("worldTimeDelay") && entity instanceof EntityPlayer) { } int range = 5; int verticalRange = 2; int posX = (int) Math.round(entity.posX - 0.5f); int posY = (int) entity.posY; int posZ = (int) Math.round(entity.posZ - 0.5f); for (int ix = posX - range; ix <= posX + range; ix++) { for (int iz = posZ - range; iz <= posZ + range; iz++) { for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) { Block block = par2World.getBlock(ix, iy, iz); if (block instanceof IPlantable) { if (par2World.rand.nextInt(20) == 0) { block.updateTick(par2World, ix, iy, iz, par2World.rand); if (par2World.rand.nextInt(100) == 0){ stack.damageItem(1, par3EntityPlayer); } } } } } } } return; } } } [code/]
August 31, 201411 yr I would use the normal item damage for the damage and the state of on and off with NBT Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
August 31, 201411 yr Author I would use the normal item damage for the damage and the state of on and off with NBT well i got it working with on item right click but i want to do it with an key bind but i cant figure it out it got this @SubscribeEvent public void onKey(KeyInputEvent evt) { boolean toggle = keyToggle.isPressed(); ItemStack stack = new ItemStack (BaubleliciousItems.ItemAmuletGrowth); if (toggle) { if (mc.inGameHasFocus) { if (stack.stackTagCompound == null) { stack.setTagCompound(new NBTTagCompound()); } NBTTagCompound tag = stack.stackTagCompound; tag.setBoolean("isActive", (tag.getBoolean("isActive"))); if (tag.getBoolean("isActive")) { System.out.print("yay"); // tag.setBoolean("isActive",true); } else { System.out.print("nah"); // tag.setBoolean("isActive",false); } } return; } } } [code/]
August 31, 201411 yr Author First of all: You're just creating a new ItemStack and then don't do anything with that. This will not do anything at all. Then: KeyHandlers are client-only. For things like this you'll need to send a packet when the key is pressed and then do the actions on the server. ok Thanks i will take a look at it
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.