From 253dde7cce277144c1a3576375d27af9dbd303ec Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 6 Nov 2014 23:06:09 +0100 Subject: [PATCH] Change the accuraccy stuff to not call clientside methods serverside >_> --- .../java/tconstruct/library/weaponry/AmmoWeapon.java | 11 ++++++----- .../java/tconstruct/library/weaponry/IAccuracy.java | 2 +- .../java/tconstruct/weaponry/weapons/Shuriken.java | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java b/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java index b540e760..026749be 100644 --- a/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java +++ b/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java @@ -67,6 +67,7 @@ public abstract class AmmoWeapon extends AmmoItem implements IAccuracy, IWindup public float minAccuracy(ItemStack itemStack) { return 0.5f; } public float maxAccuracy(ItemStack itemStack) { return 0.5f; } + @SideOnly(Side.CLIENT) public float getWindupProgress(ItemStack itemStack, EntityPlayer player) { // what are you doing! @@ -80,11 +81,11 @@ public abstract class AmmoWeapon extends AmmoItem implements IAccuracy, IWindup return getWindupProgress(itemStack, getMaxItemUseDuration(itemStack) - player.getItemInUseCount()); } - public float getAccuracy(ItemStack itemStack, EntityPlayer player) + public float getAccuracy(ItemStack itemStack, int time) { float dif = minAccuracy(itemStack) - maxAccuracy(itemStack); - return minAccuracy(itemStack) - dif * getWindupProgress(itemStack, player); + return minAccuracy(itemStack) - dif * getWindupProgress(itemStack, time); } @Override @@ -96,16 +97,16 @@ public abstract class AmmoWeapon extends AmmoItem implements IAccuracy, IWindup public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int durationLeft) { int time = this.getMaxItemUseDuration(stack) - durationLeft; if(getWindupProgress(stack, time) >= getMinWindupProgress(stack)) - launchProjectile(stack, world, player); + launchProjectile(stack, world, player, time); } - protected void launchProjectile(ItemStack stack, World world, EntityPlayer player) { + protected void launchProjectile(ItemStack stack, World world, EntityPlayer player, int time) { // spawn projectile on server if(!world.isRemote) { ItemStack reference = stack.copy(); reference.stackSize = 1; reference.getTagCompound().getCompoundTag("InfiTool").setInteger("Ammo", 1); - Entity projectile = createProjectile(reference, world, player, getAccuracy(stack, player)); + Entity projectile = createProjectile(reference, world, player, getAccuracy(stack, time)); world.spawnEntityInWorld(projectile); } diff --git a/src/main/java/tconstruct/library/weaponry/IAccuracy.java b/src/main/java/tconstruct/library/weaponry/IAccuracy.java index 07bae711..764ce990 100644 --- a/src/main/java/tconstruct/library/weaponry/IAccuracy.java +++ b/src/main/java/tconstruct/library/weaponry/IAccuracy.java @@ -6,5 +6,5 @@ import net.minecraft.item.ItemStack; public interface IAccuracy { public float minAccuracy(ItemStack itemStack); public float maxAccuracy(ItemStack itemStack); - public float getAccuracy(ItemStack itemStack, EntityPlayer player); + public float getAccuracy(ItemStack itemStack, int time); } diff --git a/src/main/java/tconstruct/weaponry/weapons/Shuriken.java b/src/main/java/tconstruct/weaponry/weapons/Shuriken.java index 09124a75..d0bf8328 100644 --- a/src/main/java/tconstruct/weaponry/weapons/Shuriken.java +++ b/src/main/java/tconstruct/weaponry/weapons/Shuriken.java @@ -119,7 +119,7 @@ public class Shuriken extends AmmoWeapon { if(getAmmoCount(stack) <= 0) return stack; - launchProjectile(stack, world, player); + launchProjectile(stack, world, player, 1); // this is only used for the animation player.setItemInUse(stack, this.getMaxItemUseDuration(stack));