@Override public void onPlayerStoppedUsing( ItemStack weapon, World world, EntityPlayer entityPlayer, int time) { if (world.isRemote) { int maxCount = getShotCount(weapon, entityPlayer); int timeElapsed = (getMaxItemUseDuration(weapon) - time); int count = Math.max(1, (int) ((1f - (timeElapsed / (float) MAX_CHARGE_TIME)) * maxCount)); float shotPercent = count / (float) getShotCount(weapon, entityPlayer); ItemRenderPlasmaShotgun.RECOIL_AMOUNT = 15 + (maxCount - count) * 2 + getAccuracy(weapon, entityPlayer, isWeaponZoomed(entityPlayer, weapon)) * 2; ItemRenderPlasmaShotgun.RECOIL_TIME = 1 + (maxCount - count) * 0.03f; Minecraft.getMinecraft().renderViewEntity.hurtTime = 15 + (maxCount - count); Minecraft.getMinecraft().renderViewEntity.maxHurtTime = 30 + (maxCount - count); Vec3 dir = entityPlayer.getLook(1); Vec3 pos = getFirePosition(entityPlayer, dir, Mouse.isButtonDown(1)); WeaponShot shot = createShot(weapon, entityPlayer, Mouse.isButtonDown(1)); shot.setCount(count); shot.setAccuracy(shot.getAccuracy() * shotPercent); shot.setRange(shot.getRange() + (int) (shot.getRange() * (1 - shotPercent))); onClientShot(weapon, entityPlayer, pos, dir, shot); MatterOverdrive.packetPipeline.sendToServer( new PacketFirePlasmaShot(entityPlayer.getEntityId(), pos, dir, shot)); addShootDelay(weapon); stopChargingSound(); entityPlayer.clearItemInUse(); } }
public WeaponShot createShot(ItemStack weapon, EntityLivingBase shooter, boolean zoomed) { WeaponShot shot = new WeaponShot( itemRand.nextInt(), getWeaponScaledDamage(weapon, shooter), getAccuracy(weapon, shooter, zoomed), WeaponHelper.getColor(weapon), getRange(weapon)); shot.setCount(getShotCount(weapon, shooter)); return shot; }