Posted December 20, 201410 yr So I've had this problem for a while now and nobody's been able to fix it, including me, so I thought I'd take it here again. Below, you can see the methods in an item that will fire a projectile when right clicked. The problem is when I was switching the player specific values for the gun, so it would work on servers, the value "clipCount" will be set to the correct amount and then subsequently be set to 0 after each reload. I checked the value while the reload loop was running; it would get set to 1, 2, 3, 4, etc without any zeros in the middle, but after the maximum value was reached and exited the reload loop the value would be set to 0. Help? @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { FalloutPlayer props = FalloutPlayer.get(player); float actualDamage = damage * ((50 + (props.getSkillValue("guns") * .5F)) / 100); if (player.capabilities.isCreativeMode && !world.isRemote) { if (itemStack.stackTagCompound.getInteger("currentShotTime") >= shotTime * 20.0) { world.spawnEntityInWorld(new EntityBullet(world, player, actualDamage, spread)); world.playSoundAtEntity(player, fireSound, 1.0F, 1); itemStack.stackTagCompound.setInteger("currentShotTime", 0); } } else if (itemStack.stackTagCompound.getInteger("clipCount") > 0 && itemStack.stackTagCompound.getInteger("currentShotTime") >= shotTime * 20.0 && !world.isRemote && itemStack.stackTagCompound.getInteger("currentReloadTime") > (35 * reloadTime)) { if (!Fallout.isReloading) { world.spawnEntityInWorld(new EntityBullet(world, player, actualDamage, spread)); world.playSoundAtEntity(player, fireSound, 1.0F, 1); itemStack.stackTagCompound.setInteger("currentShotTime", 0); itemStack.stackTagCompound.setInteger("clipCount", itemStack.stackTagCompound.getInteger("clipCount") - 1); } } return itemStack; } @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int metadata, boolean bool) { if (itemStack.stackTagCompound == null) { itemStack.stackTagCompound = new NBTTagCompound(); itemStack.stackTagCompound.setInteger("clipCount", 0); itemStack.stackTagCompound.setInteger("currentReloadTime", 0); itemStack.stackTagCompound.setInteger("currentShotTime", 0); } if (itemStack.stackTagCompound != null) { itemStack.stackTagCompound.setInteger("currentShotTime", itemStack.stackTagCompound.getInteger("currentShotTime") + 1); itemStack.stackTagCompound.setInteger("currentReloadTime", itemStack.stackTagCompound.getInteger("currentReloadTime") + 1); if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; FalloutPlayer extPlayer = FalloutPlayer.get(player); if (itemStack.stackTagCompound.getInteger("clipCount") < clipSize && Fallout.isReloading && player.inventory.hasItem(ammoType)) { player.playSound(reloadSound, 1.0F, 1); for (int i = 0; i < clipSize; i++) { if (player.inventory.hasItem(ammoType) && itemStack.stackTagCompound.getInteger("clipCount") < clipSize) { int currentClip = itemStack.stackTagCompound.getInteger("clipCount"); player.inventory.consumeInventoryItem(ammoType); itemStack.stackTagCompound.setInteger("clipCount", currentClip + 1); System.out.println(itemStack.stackTagCompound.getInteger("clipCount")); } } System.out.println(itemStack.stackTagCompound.getInteger("clipCount")); itemStack.stackTagCompound.setInteger("currentReloadTime", 0); Fallout.isReloading = false; } } } }
December 21, 201410 yr Author So I tested each individual NBT data value and it seems that the values just don't store. Does anyone know what I'm doing wrong?
December 26, 201410 yr Author Any ideas anyone? -EDIT- I've been testing it more and the value doesn't always revert to zero, it reverts to what you originally set it to. The problem seems to come from the onItemRightClick method.
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.