diff --git a/src/main/java/com/hbm/config/MobConfig.java b/src/main/java/com/hbm/config/MobConfig.java index 171f56935..4828ae781 100644 --- a/src/main/java/com/hbm/config/MobConfig.java +++ b/src/main/java/com/hbm/config/MobConfig.java @@ -27,6 +27,7 @@ public class MobConfig { public static boolean enableDucks = true; public static boolean enableMobGear = true; + public static boolean enableMobWeapons = true; public static boolean enableHives = true; public static int hiveSpawn = 256; @@ -94,6 +95,7 @@ public class MobConfig { enableDucks = CommonConfig.createConfigBool(config, CATEGORY, "12.D00_enableDucks", "Whether pressing O should allow the player to duck", true); enableMobGear = CommonConfig.createConfigBool(config, CATEGORY, "12.D01_enableMobGear", "Whether zombies and skeletons should have additional gear when spawning", true); + enableMobWeapons = CommonConfig.createConfigBool(config, CATEGORY, "12.D02_enableMobWeapons", "Whether skeletons should have bows replaced with guns when spawning at higher soot levels", true); enableHives = CommonConfig.createConfigBool(config, CATEGORY, "12.G00_enableHives", "Whether glyphid hives should spawn", true); hiveSpawn = CommonConfig.createConfigInt(config, CATEGORY, "12.G01_hiveSpawn", "The average amount of chunks per hive", 256); diff --git a/src/main/java/com/hbm/entity/mob/ai/EntityAIFireGun.java b/src/main/java/com/hbm/entity/mob/ai/EntityAIFireGun.java new file mode 100644 index 000000000..9670d65a7 --- /dev/null +++ b/src/main/java/com/hbm/entity/mob/ai/EntityAIFireGun.java @@ -0,0 +1,136 @@ +package com.hbm.entity.mob.ai; + +import com.hbm.handler.HbmKeybinds.EnumKeybind; +import com.hbm.items.weapon.sedna.GunConfig; +import com.hbm.items.weapon.sedna.ItemGunBaseNT; +import com.hbm.items.weapon.sedna.Receiver; +import com.hbm.items.weapon.sedna.ItemGunBaseNT.GunState; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.item.ItemStack; + +public class EntityAIFireGun extends EntityAIBase { + + private final EntityLiving host; + + private double attackMoveSpeed = 1.0D; // how fast we move while in this state + private double maxRange = 20; // how far our target can be before we stop shooting + private int burstTime = 10; // maximum number of ticks in a burst (for automatic weapons) + private int minWait = 10; // minimum number of ticks to wait between bursts/shots + private int maxWait = 40; // maximum number of ticks to wait between bursts/shots + private float inaccuracy = 30; // how many degrees of inaccuracy does the AI have + + // state timers + private int attackTimer = 0; + private FireState state = FireState.IDLE; + private int stateTimer = 0; + + private static enum FireState { + IDLE, + WAIT, + FIRING, + RELOADING, + } + + public EntityAIFireGun(EntityLiving host) { + this.host = host; + } + + @Override + public boolean shouldExecute() { + return host.getAttackTarget() != null && getYerGun() != null; + } + + @Override + public void updateTask() { + EntityLivingBase target = host.getAttackTarget(); + ItemStack stack = host.getHeldItem(); + ItemGunBaseNT gun = getYerGun(); + + gun.onUpdate(stack, host.worldObj, host, 0, true); + + double distanceToTargetSquared = host.getDistanceSq(target.posX, target.posY, target.posZ); + boolean canSeeTarget = host.getEntitySenses().canSee(target); + + if(canSeeTarget) { + attackTimer++; + } else { + attackTimer = 0; + } + + if(distanceToTargetSquared < maxRange * maxRange && attackTimer > 20) { + host.getNavigator().clearPathEntity(); + } else { + host.getNavigator().tryMoveToEntityLiving(target, attackMoveSpeed); + } + + host.getLookHelper().setLookPositionWithEntity(target, 30.0F, 30.0F); + + stateTimer--; + if(stateTimer < 0) { + stateTimer = 0; + + if(state == FireState.WAIT) { + updateState(FireState.IDLE, 0, gun, stack); + } else if(state != FireState.IDLE) { + updateState(FireState.WAIT, host.worldObj.rand.nextInt(maxWait - minWait) + minWait, gun, stack); + } + } else if(state == FireState.FIRING) { + // Keep the trigger held throughout the duration of firing + updateKeybind(gun, stack, EnumKeybind.GUN_PRIMARY); + } + + if(canSeeTarget && distanceToTargetSquared < maxRange * maxRange) { + if(state == FireState.IDLE) { + GunConfig config = gun.getConfig(stack, 0); + Receiver rec = config.getReceivers(stack)[0]; + if(rec.getMagazine(stack).getAmount(stack) <= 0) { + updateState(FireState.RELOADING, 20, gun, stack); + } else if(ItemGunBaseNT.getState(stack, 0) == GunState.IDLE) { + updateState(FireState.FIRING, host.worldObj.rand.nextInt(burstTime), gun, stack); + } + } + } + } + + private void updateState(FireState toState, int time, ItemGunBaseNT gun, ItemStack stack) { + state = toState; + stateTimer = time; + + switch(state) { + case FIRING: updateKeybind(gun, stack, EnumKeybind.GUN_PRIMARY); + case RELOADING: updateKeybind(gun, stack, EnumKeybind.RELOAD); + default: clearKeybinds(gun, stack); break; + } + } + + private void clearKeybinds(ItemGunBaseNT gun, ItemStack stack) { + updateKeybind(gun, stack, null); + } + + private void updateKeybind(ItemGunBaseNT gun, ItemStack stack, EnumKeybind bind) { + // Turn body to face firing direction, since the gun is attached to that, not the head + // Also apply accuracy debuff just before firing + if(bind != null && bind != EnumKeybind.RELOAD) { + host.rotationYawHead += (host.worldObj.rand.nextFloat() - 0.5F) * inaccuracy; + host.rotationPitch += (host.worldObj.rand.nextFloat() - 0.5F) * inaccuracy; + host.rotationYaw = host.rotationYawHead; + } + + gun.handleKeybind(host, null, stack, EnumKeybind.GUN_PRIMARY, bind == EnumKeybind.GUN_PRIMARY); + gun.handleKeybind(host, null, stack, EnumKeybind.GUN_SECONDARY, bind == EnumKeybind.GUN_SECONDARY); + gun.handleKeybind(host, null, stack, EnumKeybind.GUN_TERTIARY, bind == EnumKeybind.GUN_TERTIARY); + gun.handleKeybind(host, null, stack, EnumKeybind.RELOAD, bind == EnumKeybind.RELOAD); + } + + public ItemGunBaseNT getYerGun() { + ItemStack stack = host.getHeldItem(); + + if(stack == null || !(stack.getItem() instanceof ItemGunBaseNT)) return null; + + return (ItemGunBaseNT) stack.getItem(); + } + +} diff --git a/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java b/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java index 0028748f3..4ff316aa0 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java +++ b/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java @@ -23,8 +23,10 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -62,7 +64,7 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei public static final String KEY_LOCKONTARGET = "lockontarget"; public static final String KEY_LOCKEDON = "lockedon"; - public static ConcurrentHashMap loopedSounds = new ConcurrentHashMap(); + public static ConcurrentHashMap loopedSounds = new ConcurrentHashMap(); public static float prevAimingProgress; public static float aimingProgress; @@ -98,12 +100,15 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei @Override public void handleKeybind(EntityPlayer player, ItemStack stack, EnumKeybind keybind, boolean newState) { - + handleKeybind(player, player.inventory, stack, keybind, newState); + } + + public void handleKeybind(EntityLivingBase entity, IInventory inventory, ItemStack stack, EnumKeybind keybind, boolean newState) { int configs = this.configs_DNA.length; for(int i = 0; i < configs; i++) { GunConfig config = getConfig(stack, i); - LambdaContext ctx = new LambdaContext(config, player, i); + LambdaContext ctx = new LambdaContext(config, entity, inventory, i); if(keybind == EnumKeybind.GUN_PRIMARY && newState && !getPrimary(stack, i)) { if(config.getPressPrimary(stack) != null) config.getPressPrimary(stack).accept(stack, ctx); this.setPrimary(stack, i, newState); continue; } if(keybind == EnumKeybind.GUN_PRIMARY && !newState && getPrimary(stack, i)) { if(config.getReleasePrimary(stack) != null) config.getReleasePrimary(stack).accept(stack, ctx); this.setPrimary(stack, i, newState); continue; } @@ -132,14 +137,14 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isHeld) { - if(!(entity instanceof EntityPlayer)) return; + if(!(entity instanceof EntityLivingBase)) return; EntityPlayer player = entity instanceof EntityPlayer ? (EntityPlayer) entity : null; int confNo = this.configs_DNA.length; GunConfig[] configs = new GunConfig[confNo]; LambdaContext[] ctx = new LambdaContext[confNo]; for(int i = 0; i < confNo; i++) { configs[i] = this.getConfig(stack, i); - ctx[i] = new LambdaContext(configs[i], player, i); + ctx[i] = new LambdaContext(configs[i], (EntityLivingBase) entity, player != null ? player.inventory : null, i); } if(world.isRemote) { @@ -271,14 +276,21 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei /** Wrapper for extra context used in most Consumer lambdas which are part of the guncfg */ public static class LambdaContext { public final GunConfig config; - public final EntityPlayer player; + public final EntityLivingBase entity; + public final IInventory inventory; public final int configIndex; - public LambdaContext(GunConfig config, EntityPlayer player, int configIndex) { + public LambdaContext(GunConfig config, EntityLivingBase player, IInventory inventory, int configIndex) { this.config = config; - this.player = player; + this.entity = player; + this.inventory = inventory; this.configIndex = configIndex; } + + public EntityPlayer getPlayer() { + if(!(entity instanceof EntityPlayer)) return null; + return (EntityPlayer) entity; + } } @Override diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/GunStateDecider.java b/src/main/java/com/hbm/items/weapon/sedna/factory/GunStateDecider.java index fb08efac8..a7678a22f 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/GunStateDecider.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/GunStateDecider.java @@ -11,6 +11,7 @@ import com.hbm.items.weapon.sedna.ItemGunBaseNT.GunState; import com.hbm.items.weapon.sedna.ItemGunBaseNT.LambdaContext; import com.hbm.render.anim.HbmAnimations.AnimType; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -55,22 +56,23 @@ public class GunStateDecider { if(lastState == GunState.RELOADING) { - EntityPlayer player = ctx.player; + EntityLivingBase entity = ctx.entity; + EntityPlayer player = ctx.getPlayer(); GunConfig cfg = ctx.config; Receiver rec = cfg.getReceivers(stack)[recIndex]; IMagazine mag = rec.getMagazine(stack); - mag.reloadAction(stack, player); + mag.reloadAction(stack, ctx.inventory); //if after reloading the gun can still reload, assume a tube mag and resume reloading - if(mag.canReload(stack, player)) { + if(mag.canReload(stack, ctx.inventory)) { ItemGunBaseNT.setState(stack, gunIndex, GunState.RELOADING); ItemGunBaseNT.setTimer(stack, gunIndex, rec.getReloadCycleDuration(stack)); ItemGunBaseNT.playAnimation(player, stack, AnimType.RELOAD_CYCLE, gunIndex); //if no more reloading can be done, go idle } else { - if(getStandardJamChance(stack, cfg, gunIndex) > player.getRNG().nextFloat()) { + if(getStandardJamChance(stack, cfg, gunIndex) > entity.getRNG().nextFloat()) { ItemGunBaseNT.setState(stack, gunIndex, GunState.JAMMED); ItemGunBaseNT.setTimer(stack, gunIndex, rec.getJamDuration(stack)); ItemGunBaseNT.playAnimation(player, stack, AnimType.JAMMED, gunIndex); @@ -97,7 +99,7 @@ public class GunStateDecider { if(lastState == GunState.COOLDOWN) { - EntityPlayer player = ctx.player; + EntityLivingBase entity = ctx.entity; GunConfig cfg = ctx.config; Receiver rec = cfg.getReceivers(stack)[recIndex]; @@ -109,7 +111,7 @@ public class GunStateDecider { ItemGunBaseNT.setState(stack, gunIndex, GunState.COOLDOWN); ItemGunBaseNT.setTimer(stack, gunIndex, rec.getDelayAfterFire(stack)); - if(rec.getFireSound(stack) != null) player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, rec.getFireSound(stack), rec.getFireVolume(stack), rec.getFirePitch(stack)); + if(rec.getFireSound(stack) != null) entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, rec.getFireSound(stack), rec.getFireVolume(stack), rec.getFirePitch(stack)); int remaining = rec.getRoundsPerCycle(stack) - 1; for(int i = 0; i < remaining; i++) if(rec.getCanFire(stack).apply(stack, ctx)) rec.getOnFire(stack).accept(stack, ctx); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java index 1c84b95bc..e3da6fdbe 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java @@ -22,6 +22,7 @@ import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationSequence; import com.hbm.render.anim.HbmAnimations.AnimType; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; @@ -40,7 +41,7 @@ public class Lego { * If IDLE and the mag of receiver 0 can be loaded, set state to RELOADING. Used by keybinds. */ public static BiConsumer LAMBDA_STANDARD_RELOAD = (stack, ctx) -> { - EntityPlayer player = ctx.player; + EntityPlayer player = ctx.getPlayer(); Receiver rec = ctx.config.getReceivers(stack)[0]; GunState state = ItemGunBaseNT.getState(stack, ctx.configIndex); @@ -49,7 +50,7 @@ public class Lego { ItemGunBaseNT.setIsAiming(stack, false); IMagazine mag = rec.getMagazine(stack); - if(mag.canReload(stack, ctx.player)) { + if(mag.canReload(stack, ctx.inventory)) { int loaded = mag.getAmount(stack); mag.setAmountBeforeReload(stack, loaded); ItemGunBaseNT.setState(stack, ctx.configIndex, GunState.RELOADING); @@ -64,7 +65,8 @@ public class Lego { /** If IDLE and ammo is loaded, fire and set to JUST_FIRED. */ public static BiConsumer LAMBDA_STANDARD_CLICK_PRIMARY = (stack, ctx) -> { - EntityPlayer player = ctx.player; + EntityLivingBase entity = ctx.entity; + EntityPlayer player = ctx.getPlayer(); Receiver rec = ctx.config.getReceivers(stack)[0]; int index = ctx.configIndex; GunState state = ItemGunBaseNT.getState(stack, index); @@ -75,7 +77,7 @@ public class Lego { rec.getOnFire(stack).accept(stack, ctx); if(rec.getFireSound(stack) != null) - player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, rec.getFireSound(stack), rec.getFireVolume(stack), rec.getFirePitch(stack)); + entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, rec.getFireSound(stack), rec.getFireVolume(stack), rec.getFirePitch(stack)); int remaining = rec.getRoundsPerCycle(stack) - 1; for(int i = 0; i < remaining; i++) if(rec.getCanFire(stack).apply(stack, ctx)) rec.getOnFire(stack).accept(stack, ctx); @@ -96,7 +98,7 @@ public class Lego { /** If IDLE, switch mode between 0 and 1. */ public static BiConsumer LAMBDA_STANDARD_CLICK_SECONDARY = (stack, ctx) -> { - EntityPlayer player = ctx.player; + EntityLivingBase entity = ctx.entity; int index = ctx.configIndex; GunState state = ItemGunBaseNT.getState(stack, index); @@ -104,9 +106,9 @@ public class Lego { int mode = ItemGunBaseNT.getMode(stack, 0); ItemGunBaseNT.setMode(stack, index, 1 - mode); if(mode == 0) - player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:weapon.switchmode1", 1F, 1F); + entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "hbm:weapon.switchmode1", 1F, 1F); else - player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hbm:weapon.switchmode2", 1F, 1F); + entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "hbm:weapon.switchmode2", 1F, 1F); } }; @@ -118,10 +120,10 @@ public class Lego { /** Default smoke. */ public static BiConsumer LAMBDA_STANDARD_SMOKE = (stack, ctx) -> { - handleStandardSmoke(ctx.player, stack, 2000, 0.025D, 1.15D, ctx.configIndex); + handleStandardSmoke(ctx.entity, stack, 2000, 0.025D, 1.15D, ctx.configIndex); }; - public static void handleStandardSmoke(EntityPlayer player, ItemStack stack, int smokeDuration, double alphaDecay, double widthGrowth, int index) { + public static void handleStandardSmoke(EntityLivingBase entity, ItemStack stack, int smokeDuration, double alphaDecay, double widthGrowth, int index) { ItemGunBaseNT gun = (ItemGunBaseNT) stack.getItem(); long lastShot = gun.lastShot[index]; List smokeNodes = gun.getConfig(stack, index).smokeNodes; @@ -130,16 +132,16 @@ public class Lego { if(!smoking && !smokeNodes.isEmpty()) smokeNodes.clear(); if(smoking) { - Vec3 prev = Vec3.createVectorHelper(-player.motionX, -player.motionY, -player.motionZ); - prev.rotateAroundY((float) (player.rotationYaw * Math.PI / 180D)); + Vec3 prev = Vec3.createVectorHelper(-entity.motionX, -entity.motionY, -entity.motionZ); + prev.rotateAroundY((float) (entity.rotationYaw * Math.PI / 180D)); double accel = 15D; - double side = (player.rotationYaw - player.prevRotationYawHead) * 0.1D; + double side = (entity.rotationYaw - entity.prevRotationYawHead) * 0.1D; double waggle = 0.025D; for(SmokeNode node : smokeNodes) { - node.forward += -prev.zCoord * accel + player.worldObj.rand.nextGaussian() * waggle; + node.forward += -prev.zCoord * accel + entity.worldObj.rand.nextGaussian() * waggle; node.lift += prev.yCoord + 1.5D; - node.side += prev.xCoord * accel + player.worldObj.rand.nextGaussian() * waggle + side; + node.side += prev.xCoord * accel + entity.worldObj.rand.nextGaussian() * waggle + side; if(node.alpha > 0) node.alpha -= alphaDecay; node.width *= widthGrowth; } @@ -178,7 +180,8 @@ public class Lego { }; public static void doStandardFire(ItemStack stack, LambdaContext ctx, AnimType anim) { - EntityPlayer player = ctx.player; + EntityLivingBase entity = ctx.entity; + EntityPlayer player = ctx.getPlayer(); int index = ctx.configIndex; if(anim != null) ItemGunBaseNT.playAnimation(player, stack, anim, ctx.configIndex); @@ -197,14 +200,14 @@ public class Lego { sideOffset = -0.1875D;*/ int projectiles = config.projectilesMin; - if(config.projectilesMax > config.projectilesMin) projectiles += player.getRNG().nextInt(config.projectilesMax - config.projectilesMin + 1); + if(config.projectilesMax > config.projectilesMin) projectiles += entity.getRNG().nextInt(config.projectilesMax - config.projectilesMin + 1); for(int i = 0; i < projectiles; i++) { float damage = primary.getBaseDamage(stack) * getStandardWearDamage(stack, ctx.config, index); float spread = primary.getGunSpread(stack) * aim + getStandardWearSpread(stack, ctx.config, index) * 0.125F; - EntityBulletBaseMK4 mk4 = new EntityBulletBaseMK4(player, config, damage, spread, sideOffset, heightOffset, forwardOffset); - if(ItemGunBaseNT.getIsLockedOn(stack)) mk4.lockonTarget = player.worldObj.getEntityByID(ItemGunBaseNT.getLockonTarget(stack)); - player.worldObj.spawnEntityInWorld(mk4); + EntityBulletBaseMK4 mk4 = new EntityBulletBaseMK4(entity, config, damage, spread, sideOffset, heightOffset, forwardOffset); + if(ItemGunBaseNT.getIsLockedOn(stack)) mk4.lockonTarget = entity.worldObj.getEntityByID(ItemGunBaseNT.getLockonTarget(stack)); + entity.worldObj.spawnEntityInWorld(mk4); } mag.setAmount(stack, mag.getAmount(stack) - 1); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java index 09519cf63..ea79e62cd 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java @@ -14,7 +14,7 @@ import com.hbm.particle.helper.CasingCreator; import com.hbm.render.anim.HbmAnimations.AnimType; import com.hbm.sound.AudioWrapper; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; /** Orchestras are server-side components that run along client-side animations. @@ -23,331 +23,331 @@ import net.minecraft.item.ItemStack; public class Orchestras { public static BiConsumer DEBUG_ORCHESTRA = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); if(type == AnimType.RELOAD) { - if(timer == 3) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); - if(timer == 10) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 1F); - if(timer == 34) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); - if(timer == 40) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 3) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 10) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 1F); + if(timer == 34) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 40) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); if(timer == 16) { Receiver rec = ctx.config.getReceivers(stack)[0]; IMagazine mag = rec.getMagazine(stack); SpentCasing casing = mag.getCasing(stack); - if(casing != null) for(int i = 0; i < mag.getCapacity(stack); i++) CasingCreator.composeEffect(player.worldObj, player, 0.25, -0.125, -0.125, -0.05, 0, 0, 0.01, casing.getName()); + if(casing != null) for(int i = 0; i < mag.getCapacity(stack); i++) CasingCreator.composeEffect(entity.worldObj, entity, 0.25, -0.125, -0.125, -0.05, 0, 0, 0.01, casing.getName()); } } if(type == AnimType.CYCLE) { - if(timer == 11) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 11) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); } if(type == AnimType.CYCLE_DRY) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 11) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 11) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); } if(type == AnimType.INSPECT) { - if(timer == 3) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); - if(timer == 16) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 3) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 16) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } }; public static BiConsumer ORCHESTRA_PEPPERBOX = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); if(type == AnimType.RELOAD) { - if(timer == 24) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); - if(timer == 55) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverSpin", 1F, 1F); + if(timer == 24) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 55) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverSpin", 1F, 1F); } if(type == AnimType.CYCLE) { - if(timer == 21) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.6F); + if(timer == 21) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.6F); } if(type == AnimType.CYCLE_DRY) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 0.8F); - if(timer == 11) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.6F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 0.8F); + if(timer == 11) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.6F); } if(type == AnimType.INSPECT) { - if(timer == 3) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverSpin", 1F, 1F); + if(timer == 3) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverSpin", 1F, 1F); } if(type == AnimType.JAMMED) { - if(timer == 28) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 0.75F); - if(timer == 45) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 0.6F); + if(timer == 28) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 0.75F); + if(timer == 45) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 0.6F); } }; public static BiConsumer ORCHESTRA_ATLAS = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); if(type == AnimType.RELOAD) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 1F); - if(timer == 36) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); - if(timer == 44) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 1F); + if(timer == 36) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 44) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } if(type == AnimType.CYCLE) { - if(timer == 14) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.9F); + if(timer == 14) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.9F); } if(type == AnimType.CYCLE_DRY) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 14) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.9F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 14) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.9F); } if(type == AnimType.INSPECT) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 1F); - if(timer == 24) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 1F); + if(timer == 24) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } if(type == AnimType.JAMMED) { - if(timer == 12) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 1F); - if(timer == 34) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 12) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 1F); + if(timer == 34) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } }; public static BiConsumer ORCHESTRA_DANI = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); if(type == AnimType.RELOAD) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 1F); - if(timer == 36) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); - if(timer == 44) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 1F); + if(timer == 36) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 44) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } if(type == AnimType.CYCLE) { - if(timer == 9) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.9F); + if(timer == 9) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.9F); } if(type == AnimType.CYCLE_DRY) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 9) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.9F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 9) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.9F); } if(type == AnimType.INSPECT) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 1F); - if(timer == 24) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 1F); + if(timer == 24) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } if(type == AnimType.JAMMED) { - if(timer == 12) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 1F); - if(timer == 34) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 12) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 1F); + if(timer == 34) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } }; public static BiConsumer ORCHESTRA_HENRY = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); if(type == AnimType.RELOAD) { - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 1F); - if(timer == 16) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 1F); + if(timer == 16) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); } if(type == AnimType.RELOAD_CYCLE) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); } if(type == AnimType.RELOAD_END) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 0.9F); - if(timer == 12 && ctx.config.getReceivers(stack)[0].getMagazine(stack).getAmountBeforeReload(stack) <= 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 1F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 0.9F); + if(timer == 12 && ctx.config.getReceivers(stack)[0].getMagazine(stack).getAmountBeforeReload(stack) <= 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 1F); } if(type == AnimType.JAMMED) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 0.9F); - if(timer == 12) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 1F); - if(timer == 36) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 1F); - if(timer == 44) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 1F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 0.9F); + if(timer == 12) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 1F); + if(timer == 36) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 1F); + if(timer == 44) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 1F); } if(type == AnimType.CYCLE) { if(timer == 14) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.5, -0.125, aiming ? -0.125 : -0.375D, 0, 0.12, -0.12, 0.01, casing.getName(), true, 60, 0.5D, 20); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.5, -0.125, aiming ? -0.125 : -0.375D, 0, 0.12, -0.12, 0.01, casing.getName(), true, 60, 0.5D, 20); } - if(timer == 12) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 1F); + if(timer == 12) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 1F); } if(type == AnimType.CYCLE_DRY) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 12) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 12) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 1F); } }; public static BiConsumer ORCHESTRA_GREASEGUN = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); if(type == AnimType.EQUIP) { - if(timer == 5) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.openLatch", 1F, 1F); + if(timer == 5) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.openLatch", 1F, 1F); } if(type == AnimType.CYCLE) { if(timer == 2) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.55, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, 0.18, -0.12, 0.01, casing.getName()); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.55, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, 0.18, -0.12, 0.01, casing.getName()); } } if(type == AnimType.CYCLE_DRY) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 0.8F); - if(timer == 11) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 0.8F); + if(timer == 11) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.8F); } if(type == AnimType.RELOAD) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 24) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); - if(timer == 36) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 24) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 36) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.8F); } if(type == AnimType.INSPECT) { - if(timer == 5) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.8F); - if(timer == 26) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1.25F); + if(timer == 5) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.8F); + if(timer == 26) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1.25F); } if(type == AnimType.JAMMED) { - if(timer == 11) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); - if(timer == 26) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 11) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 26) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.8F); } }; public static BiConsumer ORCHESTRA_MARESLEG = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); if(type == AnimType.RELOAD) { - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.8F); - if(timer == 16) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.shotgunReload", 1F, 1F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.8F); + if(timer == 16) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.shotgunReload", 1F, 1F); } if(type == AnimType.RELOAD_CYCLE) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.shotgunReload", 1F, 1F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.shotgunReload", 1F, 1F); } if(type == AnimType.RELOAD_END) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.7F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.7F); } if(type == AnimType.JAMMED) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.7F); - if(timer == 17) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 0.8F); - if(timer == 29) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 0.8F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.7F); + if(timer == 17) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 0.8F); + if(timer == 29) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 0.8F); } if(type == AnimType.CYCLE) { if(timer == 14) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.3125, -0.125, aiming ? -0.125 : -0.375D, 0, 0.18, -0.12, 0.01, casing.getName(), true, 60, 0.5D, 20); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.3125, -0.125, aiming ? -0.125 : -0.375D, 0, 0.18, -0.12, 0.01, casing.getName(), true, 60, 0.5D, 20); } - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 0.8F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 0.8F); } if(type == AnimType.CYCLE_DRY) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 0.8F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 0.8F); } }; public static BiConsumer ORCHESTRA_MARESLEG_AKIMBO = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); if(type == AnimType.RELOAD) { - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.8F); - if(timer == 16) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.shotgunReload", 1F, 1F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.8F); + if(timer == 16) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.shotgunReload", 1F, 1F); } if(type == AnimType.RELOAD_CYCLE) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.shotgunReload", 1F, 1F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.shotgunReload", 1F, 1F); } if(type == AnimType.RELOAD_END) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.7F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.7F); } if(type == AnimType.JAMMED) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.7F); - if(timer == 17) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 0.8F); - if(timer == 29) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 0.8F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.7F); + if(timer == 17) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 0.8F); + if(timer == 29) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 0.8F); } if(type == AnimType.CYCLE) { if(timer == 14) { int offset = ctx.configIndex == 0 ? -1 : 1; SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.3125, -0.125, aiming ? -0.125 * offset : -0.375D * offset, 0, -0.08, 0, 0.01, casing.getName(), true, 60, 0.5D, 20); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.3125, -0.125, aiming ? -0.125 * offset : -0.375D * offset, 0, -0.08, 0, 0.01, casing.getName(), true, 60, 0.5D, 20); } - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 0.8F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 0.8F); } if(type == AnimType.CYCLE_DRY) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.leverCock", 1F, 0.8F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.leverCock", 1F, 0.8F); } }; public static BiConsumer ORCHESTRA_FLAREGUN = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); if(type == AnimType.RELOAD) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 0.8F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 0.8F); if(timer == 4) { IMagazine mag = ctx.config.getReceivers(stack)[0].getMagazine(stack); if(mag.getAmountAfterReload(stack) > 0) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.625, -0.125, aiming ? -0.125 : -0.375D, -0.12, 0.18, 0, 0.01, casing.getName(), true, 60, 0.5D, 20); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.625, -0.125, aiming ? -0.125 : -0.375D, -0.12, 0.18, 0, 0.01, casing.getName(), true, 60, 0.5D, 20); mag.setAmountBeforeReload(stack, 0); } } - if(timer == 16) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.insertCanister", 1F, 1F); - if(timer == 24) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 16) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.insertCanister", 1F, 1F); + if(timer == 24) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); } if(type == AnimType.JAMMED) { - if(timer == 10) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 0.8F); - if(timer == 29) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 10) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 0.8F); + if(timer == 29) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); } if(type == AnimType.CYCLE) { - if(timer == 12) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 12) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); } if(type == AnimType.CYCLE_DRY) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 12) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 12) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); } }; public static BiConsumer ORCHESTRA_NOPIP = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); if(type == AnimType.RELOAD) { - if(timer == 3) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); - if(timer == 10) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallRemove", 1F, 1F); - if(timer == 34) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); - if(timer == 40) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 3) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 10) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallRemove", 1F, 1F); + if(timer == 34) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 40) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); if(timer == 16) { Receiver rec = ctx.config.getReceivers(stack)[0]; IMagazine mag = rec.getMagazine(stack); SpentCasing casing = mag.getCasing(stack); - if(casing != null) for(int i = 0; i < mag.getCapacity(stack); i++) CasingCreator.composeEffect(player.worldObj, player, 0.25, -0.125, -0.125, -0.05, 0, 0, 0.01, casing.getName()); + if(casing != null) for(int i = 0; i < mag.getCapacity(stack); i++) CasingCreator.composeEffect(entity.worldObj, entity, 0.25, -0.125, -0.125, -0.05, 0, 0, 0.01, casing.getName()); } } if(type == AnimType.CYCLE) { - if(timer == 11) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 11) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); } if(type == AnimType.CYCLE_DRY) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 11) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 11) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); } if(type == AnimType.INSPECT) { - if(timer == 3) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); - if(timer == 16) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 3) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 16) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } }; public static BiConsumer ORCHESTRA_CARBIBE = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -355,33 +355,33 @@ public class Orchestras { if(type == AnimType.CYCLE) { if(timer == 2) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.3125, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, 0.18, -0.06, 0.01, casing.getName(), true, 60, 0.5D, 20); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.3125, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, 0.18, -0.06, 0.01, casing.getName(), true, 60, 0.5D, 20); } } if(type == AnimType.CYCLE_DRY) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.8F); } if(type == AnimType.RELOAD) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 26) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 26) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); } if(type == AnimType.RELOAD_END) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.8F); } if(type == AnimType.JAMMED) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); - if(timer == 31) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 31) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.8F); } if(type == AnimType.INSPECT) { - if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); - if(timer == 30) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 0.9F); + if(timer == 6) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 30) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.9F); } }; public static BiConsumer ORCHESTRA_AM180 = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -390,100 +390,100 @@ public class Orchestras { if(type == AnimType.CYCLE) { if(timer == 0) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.4375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, -0.06, 0, 0.01, casing.getName()); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.4375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, -0.06, 0, 0.01, casing.getName()); } } if(type == AnimType.CYCLE_DRY) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.9F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 6) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.9F); } if(type == AnimType.RELOAD) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 20) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.impact", 0.25F, 1F); - if(timer == 32) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); - if(timer == 40) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.9F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 20) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.impact", 0.25F, 1F); + if(timer == 32) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 40) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.9F); } if(type == AnimType.JAMMED) { - if(timer == 15) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 15) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.8F); } if(type == AnimType.INSPECT) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 35) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 35) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); } } else { if(type == AnimType.CYCLE) { if(timer == 0) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.4375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, -0.06, 0, 0.01, casing.getName()); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.4375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, -0.06, 0, 0.01, casing.getName()); } } if(type == AnimType.CYCLE_DRY) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.9F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 6) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.9F); } if(type == AnimType.RELOAD) { - if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 26) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.impact", 0.25F, 1F); - if(timer == 48) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); - if(timer == 54) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.9F); + if(timer == 6) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 26) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.impact", 0.25F, 1F); + if(timer == 48) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 54) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.9F); } if(type == AnimType.JAMMED) { - if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 0.8F); - if(timer == 20) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 1.0F); + if(timer == 6) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 0.8F); + if(timer == 20) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 1.0F); } if(type == AnimType.INSPECT) { - if(timer == 6) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 53) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 6) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 53) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); } } }; public static BiConsumer ORCHESTRA_LIBERATOR = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); if(type == AnimType.RELOAD) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.75F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.75F); if(timer == 4) { IMagazine mag = ctx.config.getReceivers(stack)[0].getMagazine(stack); int toEject = mag.getAmountAfterReload(stack) - mag.getAmount(stack); SpentCasing casing = mag.getCasing(stack); - if(casing != null) for(int i = 0; i < toEject; i++) CasingCreator.composeEffect(player.worldObj, player, 0.625, -0.1875, -0.375D, -0.12, 0.18, 0, 0.01, casing.getName(), true, 60, 0.5D, 20); + if(casing != null) for(int i = 0; i < toEject; i++) CasingCreator.composeEffect(entity.worldObj, entity, 0.625, -0.1875, -0.375D, -0.12, 0.18, 0, 0.01, casing.getName(), true, 60, 0.5D, 20); } - if(timer == 15) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 15) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); } if(type == AnimType.RELOAD_CYCLE) { - if(timer == 5) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magSmallInsert", 1F, 1F); + if(timer == 5) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magSmallInsert", 1F, 1F); } if(type == AnimType.RELOAD_END) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 0.9F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.9F); } if(type == AnimType.JAMMED) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 0.9F); - if(timer == 12) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.75F); - if(timer == 26) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 0.9F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.9F); + if(timer == 12) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.75F); + if(timer == 26) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.9F); } if(type == AnimType.CYCLE_DRY) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); } if(type == AnimType.INSPECT) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 0.75F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 0.75F); IMagazine mag = ctx.config.getReceivers(stack)[0].getMagazine(stack); int toEject = mag.getAmountAfterReload(stack) - mag.getAmount(stack); if(timer == 4 && toEject > 0) { SpentCasing casing = mag.getCasing(stack); - if(casing != null) for(int i = 0; i < toEject; i++) CasingCreator.composeEffect(player.worldObj, player, 0.625, -0.1875, -0.375D, -0.12, 0.18, 0, 0.01, casing.getName(), true, 60, 0.5D, 20); + if(casing != null) for(int i = 0; i < toEject; i++) CasingCreator.composeEffect(entity.worldObj, entity, 0.625, -0.1875, -0.375D, -0.12, 0.18, 0, 0.01, casing.getName(), true, 60, 0.5D, 20); mag.setAmountAfterReload(stack, 0); } - if(timer == 20) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 0.9F); + if(timer == 20) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.9F); } }; public static BiConsumer ORCHESTRA_CONGOLAKE = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -492,37 +492,37 @@ public class Orchestras { if(timer == 15) { IMagazine mag = ctx.config.getReceivers(stack)[0].getMagazine(stack); SpentCasing casing = mag.getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.625, aiming ? -0.0625 : -0.25, aiming ? 0 : -0.375D, 0, 0.18, 0.12, 0.01, casing.getName(), true, 60, 0.5D, 20); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.625, aiming ? -0.0625 : -0.25, aiming ? 0 : -0.375D, 0, 0.18, 0.12, 0.01, casing.getName(), true, 60, 0.5D, 20); } } if(type == AnimType.RELOAD || type == AnimType.RELOAD_CYCLE) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.glReload", 1F, 1F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.glReload", 1F, 1F); } if(type == AnimType.INSPECT) { - if(timer == 9) player.worldObj.playSoundAtEntity(player, "hbm:weapon.glOpen", 1F, 1F); - if(timer == 27) player.worldObj.playSoundAtEntity(player, "hbm:weapon.glClose", 1F, 1F); + if(timer == 9) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.glOpen", 1F, 1F); + if(timer == 27) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.glClose", 1F, 1F); } }; public static BiConsumer ORCHESTRA_FLAMER = (stack, ctx) -> { - EntityPlayer player = ctx.player; + EntityLivingBase entity = ctx.entity; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); - if(type == AnimType.CYCLE && player.worldObj.isRemote) { - AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(player); + if(type == AnimType.CYCLE && entity.worldObj.isRemote) { + AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(entity); if(timer < 5) { //start sound if(runningAudio == null || !runningAudio.isPlaying()) { - AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.flameLoop", (float) player.posX, (float) player.posY, (float) player.posZ, 1F, 15F, 1F, 10); - ItemGunBaseNT.loopedSounds.put(player, audio); + AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.flameLoop", (float) entity.posX, (float) entity.posY, (float) entity.posZ, 1F, 15F, 1F, 10); + ItemGunBaseNT.loopedSounds.put(entity, audio); audio.startSound(); } //keepalive if(runningAudio != null && runningAudio.isPlaying()) { runningAudio.keepAlive(); - runningAudio.updatePosition((float) player.posX, (float) player.posY, (float) player.posZ); + runningAudio.updatePosition((float) entity.posX, (float) entity.posY, (float) entity.posZ); } } else { //stop sound due to timeout @@ -530,102 +530,102 @@ public class Orchestras { } } //stop sound due to state change - if(type != AnimType.CYCLE && player.worldObj.isRemote) { - AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(player); + if(type != AnimType.CYCLE && entity.worldObj.isRemote) { + AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(entity); if(runningAudio != null && runningAudio.isPlaying()) runningAudio.stopSound(); } - if(player.worldObj.isRemote) return; + if(entity.worldObj.isRemote) return; if(type == AnimType.RELOAD) { - if(timer == 15) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.openLatch", 1F, 1F); - if(timer == 35) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.impact", 0.5F, 1F); - if(timer == 60) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 0.75F); - if(timer == 70) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.insertCanister", 1F, 1F); - if(timer == 85) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pressureValve", 1F, 1F); + if(timer == 15) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.openLatch", 1F, 1F); + if(timer == 35) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.impact", 0.5F, 1F); + if(timer == 60) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.75F); + if(timer == 70) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.insertCanister", 1F, 1F); + if(timer == 85) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pressureValve", 1F, 1F); } }; public static BiConsumer ORCHESTRA_LAG = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); }; public static BiConsumer ORCHESTRA_UZI = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); if(type == AnimType.EQUIP) { - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.openLatch", 1F, 1.25F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.openLatch", 1F, 1.25F); } if(type == AnimType.CYCLE) { if(timer == 1) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, 0.18, -0.12, 0.01, casing.getName()); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, 0.18, -0.12, 0.01, casing.getName()); } } if(type == AnimType.CYCLE_DRY) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 1F); - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 1F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 1F); } if(type == AnimType.RELOAD) { - if(timer == 4) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 26) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); - if(timer == 36) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 1F); + if(timer == 4) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 26) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 36) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 1F); } if(type == AnimType.JAMMED) { - if(timer == 17) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 1F); - if(timer == 31) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.pistolCock", 1F, 1F); + if(timer == 17) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 1F); + if(timer == 31) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pistolCock", 1F, 1F); } }; public static BiConsumer ORCHESTRA_SPAS = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); if(type == AnimType.CYCLE || type == AnimType.ALT_CYCLE) { - if(timer == 8) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.shotgunCock", 1F, 1F); + if(timer == 8) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.shotgunCock", 1F, 1F); if(timer == 10) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, 0.18, -0.12, 0.01, casing.getName()); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.375, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, 0.18, -0.12, 0.01, casing.getName()); } } if(type == AnimType.RELOAD) { IMagazine mag = ctx.config.getReceivers(stack)[0].getMagazine(stack); if(mag.getAmount(stack) == 0) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverCock", 1F, 1F); - if(timer == 7) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverCock", 1F, 1F); + if(timer == 7) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } - if(timer == 5) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.shotgunReload", 1F, 1F); + if(timer == 5) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.shotgunReload", 1F, 1F); } if(type == AnimType.RELOAD_CYCLE) { - if(timer == 5) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.shotgunReload", 1F, 1F); + if(timer == 5) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.shotgunReload", 1F, 1F); } }; public static BiConsumer ORCHESTRA_PANERSCHRECK = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); if(type == AnimType.RELOAD) { - if(timer == 30) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.insertCanister", 1F, 1F); + if(timer == 30) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.insertCanister", 1F, 1F); } }; public static BiConsumer ORCHESTRA_G3 = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -633,51 +633,51 @@ public class Orchestras { if(type == AnimType.CYCLE) { if(timer == 0) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.5, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, 0.18, -0.12, 0.01, casing.getName()); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.5, aiming ? 0 : -0.125, aiming ? 0 : -0.25D, 0, 0.18, -0.12, 0.01, casing.getName()); } } if(type == AnimType.CYCLE_DRY) { - if(timer == 0) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.dryFireClick", 1F, 0.8F); - if(timer == 5) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 0.9F); - if(timer == 9) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 0.8F); + if(timer == 5) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.9F); + if(timer == 9) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } if(type == AnimType.RELOAD) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 4) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 0.9F); - if(timer == 32) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); - if(timer == 36) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 4) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.9F); + if(timer == 32) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 36) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } if(type == AnimType.INSPECT) { - if(timer == 2) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 28) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); + if(timer == 28) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); } if(type == AnimType.JAMMED) { - if(timer == 16) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 0.9F); - if(timer == 20) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); - if(timer == 24) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 0.9F); - if(timer == 28) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 16) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.9F); + if(timer == 20) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); + if(timer == 24) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 0.9F); + if(timer == 28) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.revolverClose", 1F, 1F); } }; public static BiConsumer ORCHESTRA_STINGER = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); - AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(player); + AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(entity); if(ItemGunStinger.getLockonProgress(stack) > 0 && !ItemGunStinger.getIsLockedOn(stack)) { //start sound if(runningAudio == null || !runningAudio.isPlaying()) { - AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.lockon", (float) player.posX, (float) player.posY, (float) player.posZ, 1F, 15F, 1F, 10); - ItemGunBaseNT.loopedSounds.put(player, audio); + AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.lockon", (float) entity.posX, (float) entity.posY, (float) entity.posZ, 1F, 15F, 1F, 10); + ItemGunBaseNT.loopedSounds.put(entity, audio); audio.startSound(); } //keepalive if(runningAudio != null && runningAudio.isPlaying()) { runningAudio.keepAlive(); - runningAudio.updatePosition((float) player.posX, (float) player.posY, (float) player.posZ); + runningAudio.updatePosition((float) entity.posX, (float) entity.posY, (float) entity.posZ); } } else { //stop sound due to timeout @@ -685,29 +685,29 @@ public class Orchestras { } if(type == AnimType.RELOAD) { - if(timer == 30) player.worldObj.playSoundAtEntity(player, "hbm:weapon.reload.insertCanister", 1F, 1F); + if(timer == 30) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.insertCanister", 1F, 1F); } }; public static BiConsumer ORCHESTRA_CHEMTHROWER = (stack, ctx) -> { - EntityPlayer player = ctx.player; + EntityLivingBase entity = ctx.entity; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); - if(type == AnimType.CYCLE && player.worldObj.isRemote) { - AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(player); + if(type == AnimType.CYCLE && entity.worldObj.isRemote) { + AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(entity); if(timer < 5) { //start sound if(runningAudio == null || !runningAudio.isPlaying()) { - AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.flameLoop", (float) player.posX, (float) player.posY, (float) player.posZ, 1F, 15F, 1F, 10); - ItemGunBaseNT.loopedSounds.put(player, audio); + AudioWrapper audio = MainRegistry.proxy.getLoopedSound("hbm:weapon.fire.flameLoop", (float) entity.posX, (float) entity.posY, (float) entity.posZ, 1F, 15F, 1F, 10); + ItemGunBaseNT.loopedSounds.put(entity, audio); audio.startSound(); } //keepalive if(runningAudio != null && runningAudio.isPlaying()) { runningAudio.keepAlive(); - runningAudio.updatePosition((float) player.posX, (float) player.posY, (float) player.posZ); + runningAudio.updatePosition((float) entity.posX, (float) entity.posY, (float) entity.posZ); } } else { //stop sound due to timeout @@ -715,15 +715,15 @@ public class Orchestras { } } //stop sound due to state change - if(type != AnimType.CYCLE && player.worldObj.isRemote) { - AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(player); + if(type != AnimType.CYCLE && entity.worldObj.isRemote) { + AudioWrapper runningAudio = ItemGunBaseNT.loopedSounds.get(entity); if(runningAudio != null && runningAudio.isPlaying()) runningAudio.stopSound(); } }; public static BiConsumer ORCHESTRA_M2 = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); boolean aiming = ItemGunBaseNT.getIsAiming(stack); @@ -731,14 +731,14 @@ public class Orchestras { if(type == AnimType.CYCLE) { if(timer == 0) { SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack); - if(casing != null) CasingCreator.composeEffect(player.worldObj, player, 0.375, aiming ? 0 : -0.125, aiming ? 0 : -0.3125D, 0, 0.06, -0.18, 0.01, casing.getName()); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.375, aiming ? 0 : -0.125, aiming ? 0 : -0.3125D, 0, 0.06, -0.18, 0.01, casing.getName()); } } }; public static BiConsumer ORCHESTRA_SHREDDER = (stack, ctx) -> { - EntityPlayer player = ctx.player; - if(player.worldObj.isRemote) return; + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); }; diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java index 6f7431e32..621b5a214 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java @@ -23,6 +23,7 @@ import com.hbm.render.anim.BusAnimationSequence; import com.hbm.render.anim.BusAnimationKeyframe.IType; import com.hbm.render.anim.HbmAnimations.AnimType; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -108,7 +109,8 @@ public class XFactory12ga { } //TODO: make generic code for this crap public static BiConsumer LAMBDA_SPAS_SECONDARY = (stack, ctx) -> { - EntityPlayer player = ctx.player; + EntityLivingBase entity = ctx.entity; + EntityPlayer player = ctx.getPlayer(); Receiver rec = ctx.config.getReceivers(stack)[0]; int index = ctx.configIndex; GunState state = ItemGunBaseNT.getState(stack, index); @@ -123,7 +125,7 @@ public class XFactory12ga { timeFired++; } } - if(rec.getFireSound(stack) != null) player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, rec.getFireSound(stack), rec.getFireVolume(stack), rec.getFirePitch(stack) * (timeFired > 1 ? 0.9F : 1F)); + if(rec.getFireSound(stack) != null) entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, rec.getFireSound(stack), rec.getFireVolume(stack), rec.getFirePitch(stack) * (timeFired > 1 ? 0.9F : 1F)); ItemGunBaseNT.setState(stack, index, GunState.COOLDOWN); ItemGunBaseNT.setTimer(stack, index, 10); } else { diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory22lr.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory22lr.java index 6cc0636d4..ed9510c0f 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory22lr.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory22lr.java @@ -55,7 +55,7 @@ public class XFactory22lr { } public static BiConsumer LAMBDA_SMOKE = (stack, ctx) -> { - Lego.handleStandardSmoke(ctx.player, stack, 3000, 0.05D, 1.1D, 0); + Lego.handleStandardSmoke(ctx.entity, stack, 3000, 0.05D, 1.1D, 0); }; @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_AM180_ANIMS = (stack, type) -> { diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory40mm.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory40mm.java index c28335378..60b5caf87 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory40mm.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory40mm.java @@ -63,7 +63,7 @@ public class XFactory40mm { } public static BiConsumer LAMBDA_SMOKE = (stack, ctx) -> { - Lego.handleStandardSmoke(ctx.player, stack, 1500, 0.025D, 1.05D, 0); + Lego.handleStandardSmoke(ctx.entity, stack, 1500, 0.025D, 1.05D, 0); }; @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_FLAREGUN_ANIMS = (stack, type) -> { diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory50.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory50.java index fa9425c42..fda9f09fd 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory50.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory50.java @@ -56,7 +56,7 @@ public class XFactory50 { } public static BiConsumer LAMBDA_SMOKE = (stack, ctx) -> { - Lego.handleStandardSmoke(ctx.player, stack, 2000, 0.05D, 1.1D, 0); + Lego.handleStandardSmoke(ctx.entity, stack, 2000, 0.05D, 1.1D, 0); }; @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_M2_ANIMS = (stack, type) -> { diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory556mm.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory556mm.java index dabbbeb20..e97b3e3c5 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory556mm.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory556mm.java @@ -53,7 +53,7 @@ public class XFactory556mm { } public static BiConsumer LAMBDA_SMOKE = (stack, ctx) -> { - Lego.handleStandardSmoke(ctx.player, stack, 1500, 0.075D, 1.1D, 0); + Lego.handleStandardSmoke(ctx.entity, stack, 1500, 0.075D, 1.1D, 0); }; @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_G3_ANIMS = (stack, type) -> { diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory762mm.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory762mm.java index 6b6db1504..6f88a140e 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory762mm.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory762mm.java @@ -56,7 +56,7 @@ public class XFactory762mm { } public static BiConsumer LAMBDA_SMOKE = (stack, ctx) -> { - Lego.handleStandardSmoke(ctx.player, stack, 1500, 0.075D, 1.1D, 0); + Lego.handleStandardSmoke(ctx.entity, stack, 1500, 0.075D, 1.1D, 0); }; @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_CARBINE_ANIMS = (stack, type) -> { diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory9mm.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory9mm.java index f534cdecb..c604050c5 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory9mm.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory9mm.java @@ -75,7 +75,7 @@ public class XFactory9mm { } public static BiConsumer LAMBDA_SMOKE = (stack, ctx) -> { - Lego.handleStandardSmoke(ctx.player, stack, 2000, 0.05D, 1.1D, 0); + Lego.handleStandardSmoke(ctx.entity, stack, 2000, 0.05D, 1.1D, 0); }; @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_GREASEGUN_ANIMS = (stack, type) -> { diff --git a/src/main/java/com/hbm/items/weapon/sedna/impl/ItemGunChemthrower.java b/src/main/java/com/hbm/items/weapon/sedna/impl/ItemGunChemthrower.java index 4d21faecf..1b883686f 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/impl/ItemGunChemthrower.java +++ b/src/main/java/com/hbm/items/weapon/sedna/impl/ItemGunChemthrower.java @@ -14,6 +14,7 @@ import com.hbm.items.weapon.sedna.mags.MagazineFluid; import com.hbm.render.anim.HbmAnimations.AnimType; import api.hbm.fluid.IFillableItem; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.Vec3; @@ -77,7 +78,8 @@ public class ItemGunChemthrower extends ItemGunBaseNT implements IFillableItem { public static BiFunction LAMBDA_CAN_FIRE = (stack, ctx) -> { return ctx.config.getReceivers(stack)[0].getMagazine(stack).getAmount(stack) >= CONSUMPTION; }; public static BiConsumer LAMBDA_FIRE = (stack, ctx) -> { - EntityPlayer player = ctx.player; + EntityLivingBase entity = ctx.entity; + EntityPlayer player = ctx.getPlayer(); int index = ctx.configIndex; ItemGunBaseNT.playAnimation(player, stack, AnimType.CYCLE, ctx.configIndex); @@ -89,9 +91,9 @@ public class ItemGunChemthrower extends ItemGunBaseNT implements IFillableItem { double heightOffset = offset.yCoord; double sideOffset = offset.zCoord; - EntityChemical chem = new EntityChemical(player.worldObj, player, sideOffset, heightOffset, forwardOffset); + EntityChemical chem = new EntityChemical(entity.worldObj, entity, sideOffset, heightOffset, forwardOffset); chem.setFluid((FluidType) mag.getType(stack)); - player.worldObj.spawnEntityInWorld(chem); + entity.worldObj.spawnEntityInWorld(chem); mag.setAmount(stack, mag.getAmount(stack) - CONSUMPTION); ItemGunBaseNT.setWear(stack, index, Math.min(ItemGunBaseNT.getWear(stack, index) + 1F, ctx.config.getDurability(stack))); diff --git a/src/main/java/com/hbm/items/weapon/sedna/mags/IMagazine.java b/src/main/java/com/hbm/items/weapon/sedna/mags/IMagazine.java index f36e9767f..11dbf6166 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/mags/IMagazine.java +++ b/src/main/java/com/hbm/items/weapon/sedna/mags/IMagazine.java @@ -2,7 +2,7 @@ package com.hbm.items.weapon.sedna.mags; import com.hbm.particle.SpentCasing; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; /** @@ -23,10 +23,10 @@ public interface IMagazine { public int getAmount(ItemStack stack); /** Sets the mag's ammo level */ public void setAmount(ItemStack stack, int amount); - /** If a reload can even be initiated, i.e. the player even has bullets to load */ - public boolean canReload(ItemStack stack, EntityPlayer player); - /** The action done at the end of one reload cycle, either loading one shell or replacing the whole mag */ - public void reloadAction(ItemStack stack, EntityPlayer player); + /** If a reload can even be initiated, i.e. the player even has bullets to load, inventory can be null */ + public boolean canReload(ItemStack stack, IInventory inventory); + /** The action done at the end of one reload cycle, either loading one shell or replacing the whole mag, inventory can be null */ + public void reloadAction(ItemStack stack, IInventory inventory); /** The stack that should be displayed for the ammo HUD */ public ItemStack getIconForHUD(ItemStack stack); /** It explains itself */ diff --git a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFluid.java b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFluid.java index 44f83d895..977abb51e 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFluid.java +++ b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFluid.java @@ -6,7 +6,9 @@ import com.hbm.items.ModItems; import com.hbm.items.weapon.sedna.ItemGunBaseNT; import com.hbm.particle.SpentCasing; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; public class MagazineFluid implements IMagazine { @@ -45,8 +47,8 @@ public class MagazineFluid implements IMagazine { @Override public int getAmount(ItemStack stack) { return getMagCount(stack, index); } @Override public void setAmount(ItemStack stack, int amount) { setMagCount(stack, index, amount); } - @Override public boolean canReload(ItemStack stack, EntityPlayer player) { return false; } - @Override public void reloadAction(ItemStack stack, EntityPlayer player) { } + @Override public boolean canReload(ItemStack stack, IInventory inventory) { return false; } + @Override public void reloadAction(ItemStack stack, IInventory inventory) { } @Override public SpentCasing getCasing(ItemStack stack) { return null; } @Override public ItemStack getIconForHUD(ItemStack stack) { return new ItemStack(ModItems.fluid_icon, 1, this.getMagType(stack, index)); } diff --git a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFullReload.java b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFullReload.java index a8dedc7dc..7377c3693 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFullReload.java +++ b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineFullReload.java @@ -2,7 +2,7 @@ package com.hbm.items.weapon.sedna.mags; import com.hbm.items.weapon.sedna.BulletConfig; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; /** Uses individual bullets which are loaded all at once */ @@ -14,11 +14,14 @@ public class MagazineFullReload extends MagazineSingleTypeBase { /** Returns true if the player has the same ammo if partially loaded, or any valid ammo if not */ @Override - public boolean canReload(ItemStack stack, EntityPlayer player) { + public boolean canReload(ItemStack stack, IInventory inventory) { if(this.getAmount(stack) >= this.getCapacity(stack)) return false; + + if(inventory == null) return true; - for(ItemStack slot : player.inventory.mainInventory) { + for(int i = 0; i < inventory.getSizeInventory(); i++) { + ItemStack slot = inventory.getStackInSlot(i); if(slot != null) { if(this.getAmount(stack) == 0) { @@ -38,10 +41,18 @@ public class MagazineFullReload extends MagazineSingleTypeBase { /** Reloads all rounds at once. If the mag is empty, the mag's type will change to the first valid ammo type */ @Override - public void reloadAction(ItemStack stack, EntityPlayer player) { + public void reloadAction(ItemStack stack, IInventory inventory) { + + if(inventory == null) { + BulletConfig config = this.getType(stack); + if(config == null) { config = this.acceptedBullets.get(0); this.setType(stack, config); } //fixing broken NBT + + this.setAmount(stack, this.capacity); + return; + } - for(int i = 0; i < player.inventory.mainInventory.length; i++) { - ItemStack slot = player.inventory.mainInventory[i]; + for(int i = 0; i < inventory.getSizeInventory(); i++) { + ItemStack slot = inventory.getStackInSlot(i); if(slot != null) { @@ -54,7 +65,7 @@ public class MagazineFullReload extends MagazineSingleTypeBase { int wantsToLoad = (int) Math.ceil((double) this.getCapacity(stack) / (double) config.ammoReloadCount); int toLoad = Math.min(wantsToLoad, slot.stackSize); this.setAmount(stack, Math.min(toLoad * config.ammoReloadCount, this.capacity)); - player.inventory.decrStackSize(i, toLoad); + inventory.decrStackSize(i, toLoad); break; } } @@ -68,7 +79,7 @@ public class MagazineFullReload extends MagazineSingleTypeBase { int wantsToLoad = (int) Math.ceil((double) this.getCapacity(stack) / (double) config.ammoReloadCount) - (alreadyLoaded / config.ammoReloadCount); int toLoad = Math.min(wantsToLoad, slot.stackSize); this.setAmount(stack, Math.min((toLoad * config.ammoReloadCount) + alreadyLoaded, this.capacity)); - player.inventory.decrStackSize(i, toLoad); + inventory.decrStackSize(i, toLoad); } } } diff --git a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineSingleReload.java b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineSingleReload.java index c44175632..14c7da9ad 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineSingleReload.java +++ b/src/main/java/com/hbm/items/weapon/sedna/mags/MagazineSingleReload.java @@ -2,7 +2,7 @@ package com.hbm.items.weapon.sedna.mags; import com.hbm.items.weapon.sedna.BulletConfig; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; /** Uses individual bullets which are loaded one by one */ @@ -14,11 +14,14 @@ public class MagazineSingleReload extends MagazineSingleTypeBase { /** Returns true if the player has the same ammo if partially loaded, or any valid ammo if not */ @Override - public boolean canReload(ItemStack stack, EntityPlayer player) { + public boolean canReload(ItemStack stack, IInventory inventory) { if(this.getAmount(stack) >= this.getCapacity(stack)) return false; + + if(inventory == null) return true; - for(ItemStack slot : player.inventory.mainInventory) { + for(int i = 0; i < inventory.getSizeInventory(); i++) { + ItemStack slot = inventory.getStackInSlot(i); if(slot != null) { if(this.getAmount(stack) == 0) { @@ -38,10 +41,18 @@ public class MagazineSingleReload extends MagazineSingleTypeBase { /** Reloads all rounds at once. If the mag is empty, the mag's type will change to the first valid ammo type */ @Override - public void reloadAction(ItemStack stack, EntityPlayer player) { + public void reloadAction(ItemStack stack, IInventory inventory) { + + if(inventory == null) { + BulletConfig config = this.getType(stack); + if(config == null) { config = this.acceptedBullets.get(0); this.setType(stack, config); } //fixing broken + + this.setAmount(stack, this.getAmount(stack) + 1); + return; + } - for(int i = 0; i < player.inventory.mainInventory.length; i++) { - ItemStack slot = player.inventory.mainInventory[i]; + for(int i = 0; i < inventory.getSizeInventory(); i++) { + ItemStack slot = inventory.getStackInSlot(i); if(slot != null) { @@ -52,7 +63,7 @@ public class MagazineSingleReload extends MagazineSingleTypeBase { if(config.ammo.matchesRecipe(slot, true)) { this.setType(stack, config); this.setAmount(stack, 1); - player.inventory.decrStackSize(i, 1); + inventory.decrStackSize(i, 1); return; } } @@ -64,7 +75,7 @@ public class MagazineSingleReload extends MagazineSingleTypeBase { if(config.ammo.matchesRecipe(slot, true)) { int alreadyLoaded = this.getAmount(stack); this.setAmount(stack, alreadyLoaded + 1); - player.inventory.decrStackSize(i, 1); + inventory.decrStackSize(i, 1); return; } } diff --git a/src/main/java/com/hbm/main/ModEventHandler.java b/src/main/java/com/hbm/main/ModEventHandler.java index 143ac44e1..e69a50c59 100644 --- a/src/main/java/com/hbm/main/ModEventHandler.java +++ b/src/main/java/com/hbm/main/ModEventHandler.java @@ -24,6 +24,7 @@ import com.hbm.entity.mob.EntityCyberCrab; import com.hbm.entity.mob.EntityDuck; import com.hbm.entity.mob.EntityCreeperNuclear; import com.hbm.entity.mob.EntityQuackos; +import com.hbm.entity.mob.ai.EntityAIFireGun; import com.hbm.entity.mob.EntityCreeperTainted; import com.hbm.entity.projectile.EntityBulletBaseNT; import com.hbm.entity.projectile.EntityBurningFOEQ; @@ -53,6 +54,7 @@ import com.hbm.items.armor.ItemModShackles; import com.hbm.items.food.ItemConserve.EnumFoodType; import com.hbm.items.tool.ItemGuideBook.BookType; import com.hbm.items.weapon.ItemGunBase; +import com.hbm.items.weapon.sedna.ItemGunBaseNT; import com.hbm.lib.HbmCollection; import com.hbm.lib.ModDamageSource; import com.hbm.lib.RefStrings; @@ -64,14 +66,7 @@ import com.hbm.saveddata.AuxSavedData; import com.hbm.tileentity.machine.TileEntityMachineRadarNT; import com.hbm.tileentity.network.RTTYSystem; import com.hbm.tileentity.network.RequestNetwork; -import com.hbm.util.AchievementHandler; -import com.hbm.util.ArmorRegistry; -import com.hbm.util.ArmorUtil; -import com.hbm.util.ContaminationUtil; -import com.hbm.util.EnchantmentUtil; -import com.hbm.util.EnumUtil; -import com.hbm.util.InventoryUtil; -import com.hbm.util.ShadyUtil; +import com.hbm.util.*; import com.hbm.util.ArmorRegistry.HazardClass; import com.hbm.world.generator.TimedGenerator; @@ -88,8 +83,10 @@ import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAITasks; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.monster.EntityCaveSpider; @@ -115,13 +112,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntitySign; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.EntityDamageSource; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.FoodStats; -import net.minecraft.util.MathHelper; -import net.minecraft.util.Vec3; +import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.ForgeDirection; @@ -422,6 +413,62 @@ public class ModEventHandler { } if(rand.nextInt(64) == 0) entity.setCurrentItemOrArmor(3, new ItemStack(ModItems.steel_plate, 1, world.rand.nextInt(ModItems.steel_plate.getMaxDamage()))); + + float soot = PollutionHandler.getPollution(entity.worldObj, MathHelper.floor_double(event.x), MathHelper.floor_double(event.y), MathHelper.floor_double(event.z), PollutionType.SOOT); + ItemStack bowReplacement = getSkelegun(soot, entity.worldObj.rand); + if(bowReplacement != null) { + entity.setCurrentItemOrArmor(0, bowReplacement); + addFireTask((EntityLiving) entity); + } + } + } + + private static ItemStack getSkelegun(float soot, Random rand) { + if(!MobConfig.enableMobWeapons) return null; + if(rand.nextDouble() > Math.log(soot) * 0.25) return null; + + ArrayList pool = new ArrayList(); + pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_light_revolver), 12)); + pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_heavy_revolver), 8)); + + if(soot > 2) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_pepperbox), 10)); + if(soot > 2) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_henry), 8)); + if(soot > 2) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_greasegun), 6)); + + if(soot > 4) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_maresleg), 4)); + if(soot > 4) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_uzi), 6)); + + if(soot > 8) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_spas12), 3)); + if(soot > 8) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_am180), 4)); + + if(soot > 12) pool.add(new WeightedRandomObject(new ItemStack(ModItems.gun_congolake), 1)); + + WeightedRandomObject selected = (WeightedRandomObject) WeightedRandom.getRandomItem(rand, pool); + + return selected.asStack(); + } + + // these fucking tasks keep stacking on top of themselves + private static void addFireTask(EntityLiving entity) { + entity.setEquipmentDropChance(0, 0); // Prevent dropping guns + + for(Object entry : entity.tasks.taskEntries) { + EntityAITasks.EntityAITaskEntry task = (EntityAITasks.EntityAITaskEntry) entry; + if(task.action instanceof EntityAIFireGun) return; + } + + entity.tasks.addTask(3, new EntityAIFireGun(entity)); + } + + @SubscribeEvent + public void addAITasks(EntityJoinWorldEvent event) { + if(event.world.isRemote || !(event.entity instanceof EntityLiving)) return; + + EntityLiving living = (EntityLiving) event.entity; + ItemStack held = living.getHeldItem(); + + if(held != null && held.getItem() instanceof ItemGunBaseNT) { + addFireTask(living); } } diff --git a/src/main/java/com/hbm/packet/toclient/GunAnimationPacket.java b/src/main/java/com/hbm/packet/toclient/GunAnimationPacket.java index 0b3c5e5e8..922d19200 100644 --- a/src/main/java/com/hbm/packet/toclient/GunAnimationPacket.java +++ b/src/main/java/com/hbm/packet/toclient/GunAnimationPacket.java @@ -125,7 +125,7 @@ public class GunAnimationPacket implements IMessage { if(receiverIndex >= 0 && receiverIndex < receivers.length) { Receiver rec = receivers[receiverIndex]; BiConsumer onRecoil= rec.getRecoil(stack); - if(onRecoil != null) onRecoil.accept(stack, new LambdaContext(config, player, receiverIndex)); + if(onRecoil != null) onRecoil.accept(stack, new LambdaContext(config, player, player.inventory, receiverIndex)); } } diff --git a/src/main/java/com/hbm/particle/helper/CasingCreator.java b/src/main/java/com/hbm/particle/helper/CasingCreator.java index 522ab322e..161bcb8d7 100644 --- a/src/main/java/com/hbm/particle/helper/CasingCreator.java +++ b/src/main/java/com/hbm/particle/helper/CasingCreator.java @@ -9,6 +9,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; @@ -17,11 +18,11 @@ import net.minecraft.world.World; public class CasingCreator implements IParticleCreator { /** Casing without smoke */ - public static void composeEffect(World world, EntityPlayer player, double frontOffset, double heightOffset, double sideOffset, double frontMotion, double heightMotion, double sideMotion, double motionVariance, String casing) { + public static void composeEffect(World world, EntityLivingBase player, double frontOffset, double heightOffset, double sideOffset, double frontMotion, double heightMotion, double sideMotion, double motionVariance, String casing) { composeEffect(world, player, frontOffset, heightOffset, sideOffset, frontMotion, heightMotion, sideMotion, motionVariance, casing, false, 0, 0, 0); } - public static void composeEffect(World world, EntityPlayer player, double frontOffset, double heightOffset, double sideOffset, double frontMotion, double heightMotion, double sideMotion, double motionVariance, String casing, boolean smoking, int smokeLife, double smokeLift, int nodeLife) { + public static void composeEffect(World world, EntityLivingBase player, double frontOffset, double heightOffset, double sideOffset, double frontMotion, double heightMotion, double sideMotion, double motionVariance, String casing, boolean smoking, int smokeLife, double smokeLift, int nodeLife) { if(player.isSneaking()) heightOffset -= 0.075F;