From 3d6c2aa67e38de5b5011357df7f01784536f08c8 Mon Sep 17 00:00:00 2001 From: George Paton Date: Thu, 1 Feb 2024 21:56:04 +1100 Subject: [PATCH] Fix reload animation getting stuck if you run out of ammo before filling the weapon Fix ALT_CYCLE support, will fall back to CYCLE if no ALT_CYCLE animation is defined --- .../hbm/handler/guncfg/Gun12GaugeFactory.java | 1 - src/main/java/com/hbm/items/ModItems.java | 2 +- .../com/hbm/items/weapon/ItemCryoCannon.java | 26 +-- .../com/hbm/items/weapon/ItemGunBase.java | 21 +- .../hbm/items/weapon/ItemGunChemthrower.java | 10 +- .../com/hbm/items/weapon/ItemGunVortex.java | 215 ------------------ .../weapon/gununified/ItemEnergyGunBase.java | 16 +- .../com/hbm/packet/GunAnimationPacket.java | 5 + 8 files changed, 34 insertions(+), 262 deletions(-) delete mode 100644 src/main/java/com/hbm/items/weapon/ItemGunVortex.java diff --git a/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java index 26e2a5264..ea2f4b24a 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java @@ -16,7 +16,6 @@ import com.hbm.particle.SpentCasing; import com.hbm.particle.SpentCasing.CasingType; import com.hbm.potion.HbmPotion; import com.hbm.render.anim.BusAnimation; -import com.hbm.render.anim.BusAnimationKeyframe; import com.hbm.render.anim.BusAnimationSequence; import com.hbm.render.anim.BusAnimationSequence.Dimension; import com.hbm.render.anim.HbmAnimations.AnimType; diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index 0c07cb805..0b2168673 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -4257,7 +4257,7 @@ public class ModItems { gun_twigun = new GunEuthanasia().setUnlocalizedName("gun_twigun").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_twigun"); gun_defabricator_ammo = new Item().setUnlocalizedName("gun_defabricator_ammo").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_defabricator_ammo"); gun_defabricator = new GunDefabricator().setUnlocalizedName("gun_defabricator").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_defabricator"); - gun_vortex = new ItemGunVortex(Gun556mmFactory.getEuphieConfig()).setUnlocalizedName("gun_vortex").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_vortex"); + gun_vortex = new ItemGunBase(Gun556mmFactory.getEuphieConfig()).setUnlocalizedName("gun_vortex").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_vortex"); gun_super_shotgun = new ItemCustomLore().setUnlocalizedName("gun_super_shotgun").setMaxStackSize(1).setFull3D().setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_super_shotgun"); gun_moist_nugget = new ItemNugget(3, false).setUnlocalizedName("gun_moist_nugget").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_moist_nugget"); gun_dampfmaschine = new GunDampfmaschine().setUnlocalizedName("gun_dampfmaschine").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_dampfmaschine"); diff --git a/src/main/java/com/hbm/items/weapon/ItemCryoCannon.java b/src/main/java/com/hbm/items/weapon/ItemCryoCannon.java index 6e9bf1de7..6a69055ab 100644 --- a/src/main/java/com/hbm/items/weapon/ItemCryoCannon.java +++ b/src/main/java/com/hbm/items/weapon/ItemCryoCannon.java @@ -26,12 +26,12 @@ public class ItemCryoCannon extends ItemGunBase { @Override protected void fire(ItemStack stack, World world, EntityPlayer player) { - if(this.getPressure(stack) >= 1000) return; - if(this.getTurbine(stack) < 100) return; + if(getPressure(stack) >= 1000) return; + if(getTurbine(stack) < 100) return; BulletConfiguration config = null; - if(mainConfig.reloadType == mainConfig.RELOAD_NONE) { + if(mainConfig.reloadType == GunConfiguration.RELOAD_NONE) { config = getBeltCfg(player, stack, true); } else { config = BulletConfigSyncingUtil.pullConfig(mainConfig.config.get(getMagType(stack))); @@ -50,6 +50,9 @@ public class ItemCryoCannon extends ItemGunBase { for(int i = 0; i < bullets; i++) { spawnProjectile(world, player, stack, BulletConfigSyncingUtil.getKey(config)); } + + if(player instanceof EntityPlayerMP) + PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); useUpAmmo(player, stack, true); player.inventoryContainer.detectAndSendChanges(); @@ -66,26 +69,23 @@ public class ItemCryoCannon extends ItemGunBase { @Override protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) { - EntityChemical chem = new EntityChemical(world, player); chem.setFluid(Fluids.OXYGEN); world.spawnEntityInWorld(chem); - int pressure = this.getPressure(stack); + int pressure = getPressure(stack); pressure += 5; pressure = MathHelper.clamp_int(pressure, 0, 1000); - this.setPressure(stack, pressure); - - if(player instanceof EntityPlayerMP) PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); + setPressure(stack, pressure); } @Override protected void updateServer(ItemStack stack, World world, EntityPlayer player, int slot, boolean isCurrentItem) { - int turbine = this.getTurbine(stack); - int pressure = this.getPressure(stack); + int turbine = getTurbine(stack); + int pressure = getPressure(stack); - if(this.getIsMouseDown(stack)) { + if(getIsMouseDown(stack)) { turbine += 10; } else { turbine -= 5; @@ -94,8 +94,8 @@ public class ItemCryoCannon extends ItemGunBase { turbine = MathHelper.clamp_int(turbine, 0, 100); pressure = MathHelper.clamp_int(pressure, 0, 1000); - this.setTurbine(stack, turbine); - this.setPressure(stack, pressure); + setTurbine(stack, turbine); + setPressure(stack, pressure); super.updateServer(stack, world, player, slot, isCurrentItem); } diff --git a/src/main/java/com/hbm/items/weapon/ItemGunBase.java b/src/main/java/com/hbm/items/weapon/ItemGunBase.java index bf24aa672..6b5af4a37 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunBase.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunBase.java @@ -241,6 +241,9 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu for(int i = 0; i < bullets; i++) { spawnProjectile(world, player, stack, BulletConfigSyncingUtil.getKey(config)); } + + if(player instanceof EntityPlayerMP) + PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); useUpAmmo(player, stack, true); player.inventoryContainer.detectAndSendChanges(); @@ -276,6 +279,9 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu for(int i = 0; i < bullets; i++) { spawnProjectile(world, player, stack, BulletConfigSyncingUtil.getKey(config)); } + + if(player instanceof EntityPlayerMP) + PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.ALT_CYCLE.ordinal()), (EntityPlayerMP) player); useUpAmmo(player, stack, false); player.inventoryContainer.detectAndSendChanges(); @@ -291,13 +297,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu //spawns the actual projectile, can be overridden to change projectile entity protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) { - EntityBulletBaseNT bullet = new EntityBulletBaseNT(world, config, player); world.spawnEntityInWorld(bullet); - - if(player instanceof EntityPlayerMP) - PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); - } //called on click (server side, called by mouse packet) for semi-automatics and specific events @@ -314,10 +315,6 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu fire(stack, world, player); setDelay(stack, mainConfig.rateOfFire); } - - //setMag(stack, getMag(stack) - 1); - //useUpAmmo(player, stack, main); - //player.inventoryContainer.detectAndSendChanges(); } if(!main && altConfig != null && tryShoot(stack, world, player, main)) { @@ -328,9 +325,6 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu altFire(stack, world, player); setDelay(stack, altConfig.rateOfFire); } - - //useUpAmmo(player, stack, main); - //player.inventoryContainer.detectAndSendChanges(); } } @@ -378,7 +372,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.RELOAD_END.ordinal()), (EntityPlayerMP) player); } else { resetReloadCycle(player, stack); - PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.RELOAD_CYCLE.ordinal()), (EntityPlayerMP) player); + AnimType animType = availableFills <= 1 ? AnimType.RELOAD_END : AnimType.RELOAD_CYCLE; + PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(animType.ordinal()), (EntityPlayerMP) player); } if(hasLoaded && mainConfig.reloadSoundEnd) diff --git a/src/main/java/com/hbm/items/weapon/ItemGunChemthrower.java b/src/main/java/com/hbm/items/weapon/ItemGunChemthrower.java index 80910ce01..028ea8769 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunChemthrower.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunChemthrower.java @@ -48,13 +48,14 @@ public class ItemGunChemthrower extends ItemGunBase implements IFillableItem { spawnProjectile(world, player, stack, 0); } + if(player instanceof EntityPlayerMP) + PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); + useUpAmmo(player, stack, true); player.inventoryContainer.detectAndSendChanges(); int wear = (int) Math.ceil(10 / (1F + EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, stack))); setItemWear(stack, getItemWear(stack) + wear); - - //world.playSoundAtEntity(player, mainConfig.firingSound, 1.0F, mainConfig.firingPitch); } @Override @@ -86,15 +87,10 @@ public class ItemGunChemthrower extends ItemGunBase implements IFillableItem { @Override protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) { - //spawn fluid projectile - EntityChemical chem = new EntityChemical(world, player); chem.setFluid(this.getFluidType(stack)); world.spawnEntityInWorld(chem); - - if(player instanceof EntityPlayerMP) - PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); } @Override diff --git a/src/main/java/com/hbm/items/weapon/ItemGunVortex.java b/src/main/java/com/hbm/items/weapon/ItemGunVortex.java deleted file mode 100644 index fb8422d72..000000000 --- a/src/main/java/com/hbm/items/weapon/ItemGunVortex.java +++ /dev/null @@ -1,215 +0,0 @@ -package com.hbm.items.weapon; - -import com.hbm.handler.GunConfiguration; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class ItemGunVortex extends ItemGunBase { - - @SideOnly(Side.CLIENT) - private long lastFireTime; - - public ItemGunVortex(GunConfiguration config) { - super(config); - } - - /*@Override - protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) { - //EntityBeamVortex beam = new EntityBeamVortex(world, player); - //world.spawnEntity(beam); - //100 blocks is its current max range, but I'm sure that could be increased if necessary. - List entsOnBeam = Library.rayTraceEntitiesOnLine(player, 100, 1).getRight(); - - for(Entity e : entsOnBeam){ - - if(!(e instanceof EntityLivingBase)) - continue; - - float dmg = 30; - EntityDamageUtil.attackEntityFromIgnoreIFrame(e, ModDamageSource.radiation, dmg); - } - - if(this.mainConfig.animations.containsKey(AnimType.CYCLE) && player instanceof EntityPlayerMP) - PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); - PacketDispatcher.wrapper.sendToAllAround(new GunFXPacket(player, FXType.FIRE), new TargetPoint(world.provider.dimensionId, player.posX, player.posY, player.posZ, 1)); - } - - //This method should also solve the supershotgun issue where it doesn't fire some of the time (maybe?) - @Override - @SideOnly(Side.CLIENT) - public void onFireClient(ItemStack stack, EntityPlayer player, boolean shouldDoThirdPerson) { - //If I'm going to do more particle systems like this maybe I should write some kind of abstraction around it to make it less messy. - NBTTagCompound tag = new NBTTagCompound(); - Vec3d pos = null; - if(stack == player.getHeldItemMainhand()){ - pos = new Vec3d(-0.16, -0.20, 1).rotatePitch(-(float) Math.toRadians(player.rotationPitch)).rotateYaw(-(float) Math.toRadians(player.rotationYawHead)); - } else { - pos = new Vec3d(0.16, -0.20, 1).rotatePitch(-(float) Math.toRadians(player.rotationPitch)).rotateYaw(-(float) Math.toRadians(player.rotationYawHead)); - } - pos = pos.add(player.getPositionEyes(1F)); - Vec3d view = BobMathUtil.getVectorFromAngle(BobMathUtil.getEulerAngles(player.getLookVec()).addVector(0, 3, 0)); - Vec3d hitPos = null; - Vec3d hitNormal = null; - RayTraceResult r = Library.rayTraceIncludeEntities(player, 100, MainRegistry.proxy.partialTicks()); - if(r == null || r.typeOfHit == Type.MISS){ - hitPos = player.getLook(MainRegistry.proxy.partialTicks()).scale(100).add(pos); - } else { - hitPos = r.hitVec; - hitNormal = new Vec3d(r.sideHit.getFrontOffsetX(), r.sideHit.getFrontOffsetY(), r.sideHit.getFrontOffsetZ()); - } - - tag.setString("type", "spark"); - tag.setString("mode", "coneBurst"); - tag.setDouble("posX", pos.x-player.motionX); - tag.setDouble("posY", pos.y-player.motionY); - tag.setDouble("posZ", pos.z-player.motionZ); - tag.setDouble("dirX", view.x); - tag.setDouble("dirY", view.y); - tag.setDouble("dirZ", view.z); - tag.setFloat("r", 0.2F); - tag.setFloat("g", 0.8F); - tag.setFloat("b", 0.9F); - tag.setFloat("a", 1.5F); - tag.setInteger("lifetime", 1); - tag.setFloat("width", 0.01F); - tag.setFloat("length", 2F); - tag.setFloat("gravity", 0); - tag.setFloat("angle", 15F); - tag.setInteger("count", 12); - MainRegistry.proxy.effectNT(tag); - - ParticleVortexBeam beam = new ParticleVortexBeam(player.world, pos.x, pos.y, pos.z, hitPos.x, hitPos.y, hitPos.z, shouldDoThirdPerson); - beam.color(0.5F, 0.8F, 0.9F, 2.0F); - beam.width(0.125F); - Minecraft.getMinecraft().effectRenderer.addEffect(beam); - - ParticleVortexFireFlash flash = new ParticleVortexFireFlash(player.world, pos.x, pos.y, pos.z, hitPos.x, hitPos.y, hitPos.z); - flash.color(0.5F, 0.8F, 0.9F, 1F); - flash.width(0.5F); - Minecraft.getMinecraft().effectRenderer.addEffect(flash); - - Vec3 line = hitPos.subtract(pos); - int circleParticles = (int) line.lengthVector(); - for(int i = 0; i < circleParticles; i ++){ - Vec3 circlePos = line.scale(i/(float)circleParticles).add(pos); - ParticleVortexCircle c = new ParticleVortexCircle(player.worldObj, circlePos.x, circlePos.y, circlePos.z, 0.5F+player.worldObj.rand.nextFloat()*0.3F); - c.color(0.5F, 0.8F, 0.9F, 0.15F); - c.lifetime((int) (15+(i/(float)circleParticles)*10)); - Minecraft.getMinecraft().effectRenderer.addEffect(c); - } - - int extraParticles = (int) line.lengthVector(); - for(int i = 0; i < extraParticles; i ++){ - Vec3d circlePos = line.scale((i/(float)circleParticles)*0.25).add(pos); - float randX = (float) (player.worldObj.rand.nextGaussian()-0.5) * 0.01F; - float randY = (float) (player.worldObj.rand.nextGaussian()-0.5) * 0.01F; - float randZ = (float) (player.worldObj.rand.nextGaussian()-0.5) * 0.01F; - ParticleVortexParticle c = new ParticleVortexParticle(player.worldObj, circlePos.x+randX, circlePos.y+randY, circlePos.z+randZ, 0.5F); - c.color(0.5F, 0.8F, 0.9F, 0.15F); - c.lifetime(30); - Minecraft.getMinecraft().effectRenderer.addEffect(c); - } - - ParticleVortexGlow glow = new ParticleVortexGlow(player.worldObj, pos.x, pos.y, pos.z, 2F); - glow.color(0.3F, 0.7F, 1F, 0.5F); - glow.lifetime(15); - Minecraft.getMinecraft().effectRenderer.addEffect(glow); - - if(hitNormal != null){ - Vec3d sparkAxis = line.normalize().scale(0.25); - switch(r.sideHit.getAxis()){ - case X: - sparkAxis = new Vec3d(-sparkAxis.x, sparkAxis.y, sparkAxis.z); - break; - case Y: - sparkAxis = new Vec3d(sparkAxis.x, -sparkAxis.y, sparkAxis.z); - break; - case Z: - sparkAxis = new Vec3d(sparkAxis.x, sparkAxis.y, -sparkAxis.z); - break; - } - tag = new NBTTagCompound(); - tag.setString("type", "spark"); - tag.setString("mode", "coneBurst"); - tag.setDouble("posX", hitPos.x); - tag.setDouble("posY", hitPos.y); - tag.setDouble("posZ", hitPos.z); - tag.setDouble("dirX", sparkAxis.x); - tag.setDouble("dirY", sparkAxis.y+0.1); - tag.setDouble("dirZ", sparkAxis.z); - tag.setFloat("r", 0.2F); - tag.setFloat("g", 0.8F); - tag.setFloat("b", 0.9F); - tag.setFloat("a", 1.5F); - tag.setInteger("lifetime", 20); - tag.setInteger("randLifetime", 30); - tag.setFloat("width", 0.015F); - tag.setFloat("length", 0.5F); - tag.setFloat("gravity", 0.05F); - tag.setFloat("angle", 70F); - tag.setInteger("count", 15); - tag.setFloat("randomVelocity", 0.1F); - MainRegistry.proxy.effectNT(tag); - - ParticleVortexHit hit = new ParticleVortexHit(player.world, hitPos.x, hitPos.y, hitPos.z, 2.5F+player.world.rand.nextFloat()*0.5F, 90); - hit.color(0.4F, 0.8F, 1F, 0.25F); - hit.lifetime(20); - ParticleVortexHit hit2 = new ParticleVortexHit(player.world, hitPos.x, hitPos.y, hitPos.z, 2.5F+player.world.rand.nextFloat()*0.5F, -90); - hit2.color(0.4F, 0.8F, 1F, 0.25F); - hit2.lifetime(20); - Minecraft.getMinecraft().effectRenderer.addEffect(hit); - Minecraft.getMinecraft().effectRenderer.addEffect(hit2); - } - - MainRegistry.proxy.setRecoil(3); - lastFireTime = System.currentTimeMillis(); - } - - @Override - @SideOnly(Side.CLIENT) - public boolean hasCustomHudElement() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public void renderHud(ScaledResolution res, GuiIngame gui, ItemStack stack, float partialTicks) { - float x = res.getScaledWidth()/2; - float y = res.getScaledHeight()/2; - - Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.vortex_hud_reticle); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); - GL11.glColor4f(0.4F, 0.9F, 0.9F, 1.0F); - GL11.glEnable(GL11.GL_BLEND); - GlStateManager.tryBlendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO); - RenderHelper.drawGuiRect(x - 11F, y - 11F, 0, 0, 22, 22, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.vortex_hud_circle); - - //Running off of system time gives less wonky results than relying on server updating the nbt tag. - long time = System.currentTimeMillis(); - - //float cooldown = (this.mainConfig.rateOfFire-getDelay(stack)+partialTicks)/(float)this.mainConfig.rateOfFire; - //Adding 0.05 so it doesn't start at nothing makes it look better in my opinion. - //It's 55 instead of 50 (50 ms in one tick) because xon lets you fire slightly before the cooldown is over. This extends the cooldown slightly beyond the real one. - float cooldown = MathHelper.clamp((time-lastFireTime)/(float)(mainConfig.rateOfFire*55), 0, 1)+0.05F; - final int SUBDIVISIONS = 64; - Tessellator tes = Tessellator.instance; - tes.startDrawing(GL11.GL_TRIANGLE_FAN); - - tes.setColorRGBA_F(0.4F, 0.9F, 0.9F, 0.4F); - tes.addVertexWithUV(x, y, 0, 0.5, 0.5); - - for(int i = 0; i < SUBDIVISIONS+1; i ++){ - //Should be quite fast because MathHelper uses a sin table... right? - float ratio = i/(float)SUBDIVISIONS; - float x2 = MathHelper.sin((float) (ratio*Math.PI*2+0.5*Math.PI)); - float y2 = MathHelper.cos((float) (ratio*Math.PI*2+0.5*Math.PI)); - float alphaMult = 1-ratio < cooldown ? 1 : 0; - buf.pos(x+x2*11, y+y2*11, 0).tex(BobMathUtil.remap01(x2, -1, 1), BobMathUtil.remap01(y2, -1, 1)).color(0.4F, 0.9F, 0.9F, 0.4F*alphaMult).endVertex(); - } - tes.draw(); - - GlStateManager.tryBlendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); - GlStateManager.disableBlend(); - }*/ -} diff --git a/src/main/java/com/hbm/items/weapon/gununified/ItemEnergyGunBase.java b/src/main/java/com/hbm/items/weapon/gununified/ItemEnergyGunBase.java index e137eda14..b5e040bb3 100644 --- a/src/main/java/com/hbm/items/weapon/gununified/ItemEnergyGunBase.java +++ b/src/main/java/com/hbm/items/weapon/gununified/ItemEnergyGunBase.java @@ -5,7 +5,6 @@ import java.util.List; import org.lwjgl.input.Mouse; import com.hbm.config.GeneralConfig; -import com.hbm.entity.projectile.EntityBulletBaseNT; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; import com.hbm.handler.GunConfiguration; @@ -131,6 +130,9 @@ public class ItemEnergyGunBase extends ItemGunBase implements IBatteryItem { for(int i = 0; i < bullets; i++) { spawnProjectile(world, player, stack, BulletConfigSyncingUtil.getKey(config)); } + + if(player instanceof EntityPlayerMP) + PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); setCharge(stack, getCharge(stack) - config.dischargePerShot);; } @@ -138,19 +140,9 @@ public class ItemEnergyGunBase extends ItemGunBase implements IBatteryItem { world.playSoundAtEntity(player, mainConfig.firingSound, 1.0F, mainConfig.firingPitch); } - protected void spawnProjectile(World world, EntityPlayer player, ItemStack stack, int config) { - - EntityBulletBaseNT bullet = new EntityBulletBaseNT(world, config, player); - world.spawnEntityInWorld(bullet); - - if(this.mainConfig.animations.containsKey(AnimType.CYCLE) && player instanceof EntityPlayerMP) - PacketDispatcher.wrapper.sendTo(new GunAnimationPacket(AnimType.CYCLE.ordinal()), (EntityPlayerMP) player); - - } - public void startAction(ItemStack stack, World world, EntityPlayer player, boolean main) { - if(mainConfig.firingMode == mainConfig.FIRE_MANUAL && main && tryShoot(stack, world, player, main)) { + if(mainConfig.firingMode == GunConfiguration.FIRE_MANUAL && main && tryShoot(stack, world, player, main)) { fire(stack, world, player); setDelay(stack, mainConfig.rateOfFire); diff --git a/src/main/java/com/hbm/packet/GunAnimationPacket.java b/src/main/java/com/hbm/packet/GunAnimationPacket.java index 1fb244f01..1699d1d9e 100644 --- a/src/main/java/com/hbm/packet/GunAnimationPacket.java +++ b/src/main/java/com/hbm/packet/GunAnimationPacket.java @@ -66,6 +66,11 @@ public class GunAnimationPacket implements IMessage { if(animation == null && type == AnimType.RELOAD_EMPTY) { animation = base.getAnimation(stack, AnimType.RELOAD); } + + // Fallback to regular CYCLE if no ALT_CYCLE exists + if(animation == null && type == AnimType.ALT_CYCLE) { + animation = base.getAnimation(stack, AnimType.CYCLE); + } if(animation != null) { boolean isReloadAnimation = type == AnimType.RELOAD || type == AnimType.RELOAD_CYCLE || type == AnimType.RELOAD_EMPTY;