mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 19:59:55 +00:00
Change the accuraccy stuff to not call clientside methods serverside >_>
This commit is contained in:
1 parent
936e0483da
commit
253dde7cce
3 files changed
+8
-7
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user