Skip to content

Commit

Permalink
Change the accuraccy stuff to not call clientside methods serverside >_>
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Nov 6, 2014
1 parent 936e048 commit 253dde7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/main/java/tconstruct/library/weaponry/AmmoWeapon.java
Expand Up @@ -67,6 +67,7 @@ public float getWindupProgress(ItemStack itemStack, int timeInUse)
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!
Expand All @@ -80,11 +81,11 @@ public float getWindupProgress(ItemStack itemStack, EntityPlayer player)
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
Expand All @@ -96,16 +97,16 @@ public String[] getTraits() {
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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/library/weaponry/IAccuracy.java
Expand Up @@ -6,5 +6,5 @@
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);
}
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/weaponry/weapons/Shuriken.java
Expand Up @@ -119,7 +119,7 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla
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));
Expand Down

0 comments on commit 253dde7

Please sign in to comment.