Posted December 10, 20168 yr In 1.10 I stored item information in the onItemUse function to nbt to save the progress of a certain action. @NotNull @Override public EnumActionResult onItemUse( final ItemStack stack, final EntityPlayer playerIn, final World worldIn, final BlockPos pos, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } final NBTTagCompound compound = stack.getTagCompound(); if (!compound.hasKey("pos1")) { BlockPosUtil.writeToNBT(compound, "pos1", pos); if (worldIn.isRemote) { LanguageHandler.sendPlayerLocalizedMessage(playerIn, "item.scepterSteel.point"); } return EnumActionResult.SUCCESS; } else if (!compound.hasKey("pos2")) { @NotNull final BlockPos pos1 = BlockPosUtil.readFromNBT(compound, "pos1"); @NotNull final BlockPos pos2 = pos; if (pos2.distanceSq(pos1) > 0) { BlockPosUtil.writeToNBT(compound, "pos2", pos2); if (worldIn.isRemote) { LanguageHandler.sendPlayerLocalizedMessage(playerIn, "item.scepterSteel.point2"); } return EnumActionResult.SUCCESS; } if (worldIn.isRemote) { LanguageHandler.sendPlayerLocalizedMessage(playerIn, "item.scepterSteel.samePoint"); } return EnumActionResult.FAIL; } else { @NotNull final BlockPos pos1 = BlockPosUtil.readFromNBT(compound, "pos1"); @NotNull final BlockPos pos2 = BlockPosUtil.readFromNBT(compound, "pos2"); if (!worldIn.isRemote) { saveStructure(worldIn, pos1, pos2, playerIn); } compound.removeTag("pos1"); compound.removeTag("pos2"); return EnumActionResult.SUCCESS; } } In 1.10 though, the onItemUse does not offer the itemStack and the position variable at the same time. I tried this but it won't work: @NotNull @Override public EnumActionResult onItemUse( final EntityPlayer playerIn, final World worldIn, final BlockPos pos, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { ItemStack stack = playerIn.getActiveItemStack(); if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } final NBTTagCompound compound = stack.getTagCompound(); if (!compound.hasKey("pos1")) { BlockPosUtil.writeToNBT(compound, "pos1", pos); if (worldIn.isRemote) { LanguageHandler.sendPlayerLocalizedMessage(playerIn, "item.scepterSteel.point"); } return EnumActionResult.SUCCESS; } else if (!compound.hasKey("pos2")) { @NotNull final BlockPos pos1 = BlockPosUtil.readFromNBT(compound, "pos1"); @NotNull final BlockPos pos2 = pos; if (pos2.distanceSq(pos1) > 0) { BlockPosUtil.writeToNBT(compound, "pos2", pos2); if (worldIn.isRemote) { LanguageHandler.sendPlayerLocalizedMessage(playerIn, "item.scepterSteel.point2"); } return EnumActionResult.SUCCESS; } if (worldIn.isRemote) { LanguageHandler.sendPlayerLocalizedMessage(playerIn, "item.scepterSteel.samePoint"); } return EnumActionResult.FAIL; } else { @NotNull final BlockPos pos1 = BlockPosUtil.readFromNBT(compound, "pos1"); @NotNull final BlockPos pos2 = BlockPosUtil.readFromNBT(compound, "pos2"); if (!worldIn.isRemote) { saveStructure(worldIn, pos1, pos2, playerIn); } compound.removeTag("pos1"); compound.removeTag("pos2"); return EnumActionResult.SUCCESS; } } What can I do to make it work again?
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.