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; }
@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 PlasmaBolt[] spawnProjectile( ItemStack weapon, EntityLivingBase shooter, Vec3 position, Vec3 dir, WeaponShot shot) { // PlasmaBolt fire = new PlasmaBolt(entityPlayer.worldObj, entityPlayer,position,dir, // getWeaponScaledDamage(weapon), 2, getAccuracy(weapon, zoomed), getRange(weapon), // WeaponHelper.getColor(weapon).getColor(), zoomed,seed); PlasmaBolt[] bolts = new PlasmaBolt[shot.getCount()]; for (int i = 0; i < shot.getCount(); i++) { WeaponShot newShot = new WeaponShot(shot); newShot.setSeed(shot.getSeed() + i); newShot.setDamage(shot.getDamage() / shot.getCount()); bolts[i] = new PlasmaBolt( shooter.worldObj, shooter, position, dir, newShot, getShotSpeed(weapon, shooter)); bolts[i].setWeapon(weapon); bolts[i].setRenderSize((getShotCount(weapon, shooter) / shot.getCount()) * 0.5f); bolts[i].setFireDamageMultiply(WeaponHelper.modifyStat(Reference.WS_FIRE_DAMAGE, weapon, 0)); bolts[i].setKnockBack(0.5f); shooter.worldObj.spawnEntityInWorld(bolts[i]); } return bolts; }
@Override public boolean onServerFire( ItemStack weapon, EntityLivingBase shooter, WeaponShot shot, Vec3 position, Vec3 dir, int delay) { DrainEnergy(weapon, getShootCooldown(weapon), false); int heatAdd = (getShotCount(weapon, shooter) - shot.getCount()) * 2; float newHeat = (getHeat(weapon) + heatAdd + 6) * 4.2f; setHeat(weapon, Math.max(newHeat, 0)); manageOverheat(weapon, shooter.worldObj, shooter); PlasmaBolt[] fires = spawnProjectile(weapon, shooter, position, dir, shot); for (PlasmaBolt bolt : fires) { bolt.simulateDelay(delay); } return true; }