diff --git a/src/main/java/com/hbm/handler/BulletConfiguration.java b/src/main/java/com/hbm/handler/BulletConfiguration.java index 2118dab84..71c208daa 100644 --- a/src/main/java/com/hbm/handler/BulletConfiguration.java +++ b/src/main/java/com/hbm/handler/BulletConfiguration.java @@ -187,10 +187,15 @@ public class BulletConfiguration implements Cloneable { this.vPFX = "greendust"; if(this.spentCasing != null) { - this.spentCasing = this.spentCasing.clone(); int[] colors = this.spentCasing.getColors(); - colors[colors.length - 1] = 0x659750; // <- standard chlorophyte coloring in last place - //this.spentCasing.setColor(colors); //it's a reference type, dummy + this.spentCasing = this.spentCasing.clone(); + + if(colors != null && colors.length > 0) { + int[] colorClone = new int[colors.length]; + for(int i = 0; i < colors.length; i++) colorClone[i] = colors[i]; + colorClone[colorClone.length - 1] = 0x659750; // <- standard chlorophyte coloring in last place + this.spentCasing.setColor(colorClone).register(this.spentCasing.getName() + "Cl"); + } } return this; diff --git a/src/main/java/com/hbm/handler/CasingEjector.java b/src/main/java/com/hbm/handler/CasingEjector.java index b62dc986c..46e5cbd67 100644 --- a/src/main/java/com/hbm/handler/CasingEjector.java +++ b/src/main/java/com/hbm/handler/CasingEjector.java @@ -41,11 +41,19 @@ public class CasingEjector implements Cloneable { mappings.put(id, this); } + public CasingEjector setOffset(double x, double y, double z) { + return setOffset(Vec3.createVectorHelper(x, y, z)); + } + public CasingEjector setOffset(Vec3 vec) { this.posOffset = vec; return this; } + public CasingEjector setMotion(double x, double y, double z) { + return setMotion(Vec3.createVectorHelper(x, y, z)); + } + public CasingEjector setMotion(Vec3 vec) { this.initialMotion = vec; return this; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java index 7b1cca443..7fa8c658f 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java @@ -1,16 +1,27 @@ package com.hbm.handler.guncfg; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.CasingEjector; import com.hbm.handler.GunConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.items.ItemAmmoEnums.Ammo50AE; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasing; +import com.hbm.particle.SpentCasing.CasingType; import com.hbm.render.util.RenderScreenOverlay.Crosshair; public class Gun50AEFactory { + private static final CasingEjector EJECTOR_PISTOL; + private static final SpentCasing CASING50AE; + + static { + EJECTOR_PISTOL = new CasingEjector().setMotion(-0.3, 0.7, 0).setOffset(-0.5, 0, 0.5).setAngleRange(0.01F, 0.03F); + CASING50AE = new SpentCasing(CasingType.STRAIGHT).setScale(1.5F).setBounceMotion(0.01F, 0.03F).setColor(SpentCasing.COLOR_CASE_BRASS); + } + public static GunConfiguration getBaseConfig() { GunConfiguration config = new GunConfiguration(); @@ -44,6 +55,8 @@ public class Gun50AEFactory { config.hasSights = true; config.config = HbmCollection.fiftyAE; + config.ejector = EJECTOR_PISTOL; + return config; } @@ -57,6 +70,8 @@ public class Gun50AEFactory { bullet.dmgMin = 28; bullet.dmgMax = 32; + bullet.spentCasing = CASING50AE.clone().register("50AEStock"); + return bullet; } @@ -71,6 +86,8 @@ public class Gun50AEFactory { bullet.leadChance = 10; bullet.wear = 15; + bullet.spentCasing = CASING50AE.clone().register("50AEAP"); + return bullet; } @@ -85,6 +102,8 @@ public class Gun50AEFactory { bullet.leadChance = 50; bullet.wear = 25; + bullet.spentCasing = CASING50AE.clone().register("50AEDU"); + return bullet; } @@ -99,6 +118,8 @@ public class Gun50AEFactory { bullet.leadChance = 100; bullet.wear = 25; + bullet.spentCasing = CASING50AE.clone().register("50AEStar"); + return bullet; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java index ae12c9ba3..f12d5ad6f 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import com.hbm.entity.projectile.EntityBulletBase; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.CasingEjector; import com.hbm.handler.GunConfiguration; import com.hbm.interfaces.IBulletHitBehavior; import com.hbm.interfaces.IBulletImpactBehavior; @@ -16,6 +17,8 @@ import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; +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; @@ -34,6 +37,18 @@ import net.minecraft.potion.PotionEffect; public class Gun50BMGFactory { + private static final CasingEjector EJECTOR_BMG; + private static final CasingEjector EJECTOR_SNIPER; + private static final SpentCasing CASING50BMG; + private static final SpentCasing CASINGLUNA; + + static { + EJECTOR_BMG = new CasingEjector().setMotion(-0.35, 0.9, 0).setOffset(-0.45, -0.2, 0.35).setAngleRange(0.01F, 0.05F); + EJECTOR_SNIPER = new CasingEjector().setMotion(-2, 0.15, 0).setOffset(-0.45, -0.2, 0.35).setAngleRange(0.02F, 0.05F); + CASING50BMG = new SpentCasing(CasingType.BOTTLENECK).setScale(3F).setBounceMotion(0.01F, 0.05F).setColor(SpentCasing.COLOR_CASE_BRASS); + CASINGLUNA = new SpentCasing(CasingType.BOTTLENECK).setScale(4F).setBounceMotion(0.02F, 0.05F).setColor(SpentCasing.COLOR_CASE_BRASS); + } + public static GunConfiguration getCalamityConfig() { GunConfiguration config = new GunConfiguration(); @@ -72,6 +87,8 @@ public class Gun50BMGFactory { config.config = HbmCollection.fiftyBMG; + config.ejector = EJECTOR_BMG; + return config; } @@ -98,6 +115,8 @@ public class Gun50BMGFactory { config.config = HbmCollection.fiftyBMG; + config.ejector = EJECTOR_BMG; + return config; } @@ -117,6 +136,8 @@ public class Gun50BMGFactory { bullet.blockDamage = true; bullet.bImpact = (projectile, x, y, z) -> projectile.worldObj.newExplosion(projectile, x, y, z, 5.0F, true, false); + + bullet.spentCasing = CASINGLUNA.clone().register("LunaStock"); return bullet; } @@ -128,6 +149,8 @@ public class Gun50BMGFactory { bullet.ammo.meta = 1; bullet.incendiary = 50; + + bullet.spentCasing = CASINGLUNA.clone().register("LunaInc"); return bullet; } @@ -140,6 +163,8 @@ public class Gun50BMGFactory { bullet.ammo.meta = 2; bullet.explosive = 25; bullet.bImpact = (projectile, x, y, z) -> projectile.worldObj.newExplosion(projectile, x, y, z, 25.0F, true, false); + + bullet.spentCasing = CASINGLUNA.clone().register("LunaExp"); return bullet; } @@ -179,6 +204,8 @@ public class Gun50BMGFactory { config.config.add(BulletConfigSyncingUtil.CHL_BMG50); config.config.add(BulletConfigSyncingUtil.BMG50_SLEEK); + config.ejector = EJECTOR_BMG; + return config; } @@ -192,6 +219,8 @@ public class Gun50BMGFactory { bullet.dmgMin = 30; bullet.dmgMax = 36; + bullet.spentCasing = CASING50BMG.clone().register("50BMGStock"); + return bullet; } @@ -206,6 +235,8 @@ public class Gun50BMGFactory { bullet.wear = 15; bullet.incendiary = 5; + bullet.spentCasing = CASING50BMG.clone().register("50BMGInc"); + return bullet; } @@ -241,6 +272,8 @@ public class Gun50BMGFactory { } }; + bullet.spentCasing = CASING50BMG.clone().register("50BMGPhos"); + return bullet; } @@ -255,6 +288,8 @@ public class Gun50BMGFactory { bullet.wear = 25; bullet.explosive = 1; + bullet.spentCasing = CASING50BMG.clone().register("50BMGExp"); + return bullet; } @@ -269,6 +304,8 @@ public class Gun50BMGFactory { bullet.wear = 15; bullet.leadChance = 10; + bullet.spentCasing = CASING50BMG.clone().register("50BMGAP"); + return bullet; } @@ -283,6 +320,8 @@ public class Gun50BMGFactory { bullet.wear = 25; bullet.leadChance = 50; + bullet.spentCasing = CASING50BMG.clone().register("50BMGDU"); + return bullet; } @@ -297,6 +336,8 @@ public class Gun50BMGFactory { bullet.wear = 25; bullet.leadChance = 100; + bullet.spentCasing = CASING50BMG.clone().register("50BMGStar"); + return bullet; } @@ -347,6 +388,8 @@ public class Gun50BMGFactory { } }; + bullet.spentCasing = CASING50BMG.clone().register("50BMGIF"); + return bullet; } @@ -360,6 +403,8 @@ public class Gun50BMGFactory { bullet.dmgMax = 54; bullet.style = bullet.STYLE_FLECHETTE; + bullet.spentCasing = CASING50BMG.clone().register("50BMGFlech"); + return bullet; } @@ -387,6 +432,8 @@ public class Gun50BMGFactory { } }; + bullet.spentCasing = CASING50BMG.clone().register("50BMGAM"); + return bullet; } @@ -414,6 +461,8 @@ public class Gun50BMGFactory { } }; + bullet.spentCasing = CASING50BMG.clone().register("50BMGPO"); + return bullet; } } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java index fc5be0d11..e315fc20b 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import com.hbm.entity.projectile.EntityBulletBase; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.CasingEjector; import com.hbm.handler.GunConfiguration; import com.hbm.interfaces.IBulletHitBehavior; import com.hbm.interfaces.IBulletImpactBehavior; @@ -15,6 +16,8 @@ import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; +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; @@ -28,6 +31,14 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; public class Gun556mmFactory { + + private static final CasingEjector EJECTOR_RIFLE; + private static final SpentCasing CASING556; + + static { + EJECTOR_RIFLE = new CasingEjector().setMotion(-0.35, 0.6, 0).setOffset(-0.35, 0, 0.35).setAngleRange(0.01F, 0.03F); + CASING556 = new SpentCasing(CasingType.BOTTLENECK).setScale(1.25F).setBounceMotion(0.01F, 0.03F).setColor(SpentCasing.COLOR_CASE_BRASS); + } public static GunConfiguration getEuphieConfig() { @@ -54,7 +65,8 @@ public class Gun556mmFactory { config.comment.add("Why is this gun so sticky?"); - config.config = HbmCollection.NATO; + config.config = new ArrayList(); + config.config.add(BulletConfigSyncingUtil.R556_GOLD); return config; } @@ -95,6 +107,8 @@ public class Gun556mmFactory { config.config = HbmCollection.NATOFlechette; + config.ejector = EJECTOR_RIFLE; + return config; } @@ -132,6 +146,8 @@ public class Gun556mmFactory { bullet.dmgMin = 16; bullet.dmgMax = 20; + bullet.spentCasing = CASING556.clone().register("556Stock"); + return bullet; } @@ -144,6 +160,8 @@ public class Gun556mmFactory { bullet.dmgMax = 320; bullet.spread = 0.0F; + bullet.spentCasing = null; + return bullet; } @@ -176,6 +194,8 @@ public class Gun556mmFactory { } }; + bullet.spentCasing = CASING556.clone().register("556Phos"); + return bullet; } @@ -189,6 +209,8 @@ public class Gun556mmFactory { bullet.wear = 15; bullet.leadChance = 10; + bullet.spentCasing = CASING556.clone().register("556AP"); + return bullet; } @@ -202,6 +224,8 @@ public class Gun556mmFactory { bullet.wear = 25; bullet.leadChance = 50; + bullet.spentCasing = CASING556.clone().register("556DU"); + return bullet; } @@ -215,6 +239,8 @@ public class Gun556mmFactory { bullet.wear = 25; bullet.leadChance = 100; + bullet.spentCasing = CASING556.clone().register("556Star"); + return bullet; } @@ -264,6 +290,8 @@ public class Gun556mmFactory { } }; + bullet.spentCasing = CASING556.clone().register("556IF"); + return bullet; } @@ -274,6 +302,8 @@ public class Gun556mmFactory { bullet.ammo = new ComparableStack(ModItems.ammo_556.stackFromEnum(Ammo556mm.TRACER)); bullet.vPFX = "reddust"; + bullet.spentCasing = CASING556.clone().register("556Trac"); + return bullet; } @@ -290,6 +320,8 @@ public class Gun556mmFactory { bullet.style = BulletConfiguration.STYLE_FLECHETTE; bullet.doesPenetrate = false; + bullet.spentCasing = CASING556.clone().register("556Flec"); + return bullet; } @@ -300,6 +332,8 @@ public class Gun556mmFactory { bullet.ammo = new ComparableStack(ModItems.ammo_556.stackFromEnum(Ammo556mm.FLECHETTE_INCENDIARY)); bullet.incendiary = 5; + bullet.spentCasing = CASING556.clone().register("556FlecInc"); + return bullet; } @@ -330,6 +364,8 @@ public class Gun556mmFactory { } }; + bullet.spentCasing = CASING556.clone().register("556FlecPhos"); + return bullet; } @@ -344,6 +380,8 @@ public class Gun556mmFactory { bullet.leadChance = 50; bullet.doesPenetrate = true; + bullet.spentCasing = CASING556.clone().register("556FlecDU"); + return bullet; } @@ -393,6 +431,8 @@ public class Gun556mmFactory { } }; + bullet.spentCasing = CASING556.clone().register("556FlecIF"); + return bullet; } diff --git a/src/main/java/com/hbm/lib/HbmCollection.java b/src/main/java/com/hbm/lib/HbmCollection.java index d9f39c595..3f665ea71 100644 --- a/src/main/java/com/hbm/lib/HbmCollection.java +++ b/src/main/java/com/hbm/lib/HbmCollection.java @@ -48,7 +48,7 @@ public class HbmCollection { /** .50 BROWNING MACHINE GUN (FLECHETTE) **/ public static final List fiftyBMGFlechette = ImmutableList.of(BulletConfigSyncingUtil.BMG50_FLECHETTE_AM, BulletConfigSyncingUtil.BMG50_FLECHETTE_NORMAL, BulletConfigSyncingUtil.BMG50_FLECHETTE_PO); /** 5.56MMx45 NATO (BASIC) **/ - public static final List NATO = ImmutableList.of(BulletConfigSyncingUtil.R556_NORMAL, BulletConfigSyncingUtil.R556_GOLD, BulletConfigSyncingUtil.R556_TRACER, BulletConfigSyncingUtil.R556_PHOSPHORUS, BulletConfigSyncingUtil.R556_AP, BulletConfigSyncingUtil.R556_DU, BulletConfigSyncingUtil.R556_STAR, BulletConfigSyncingUtil.CHL_R556, BulletConfigSyncingUtil.R556_SLEEK, BulletConfigSyncingUtil.R556_K); + public static final List NATO = ImmutableList.of(BulletConfigSyncingUtil.R556_NORMAL, BulletConfigSyncingUtil.R556_TRACER, BulletConfigSyncingUtil.R556_PHOSPHORUS, BulletConfigSyncingUtil.R556_AP, BulletConfigSyncingUtil.R556_DU, BulletConfigSyncingUtil.R556_STAR, BulletConfigSyncingUtil.CHL_R556, BulletConfigSyncingUtil.R556_SLEEK, BulletConfigSyncingUtil.R556_K); /** 5.56MMx45 NATO (FLECHETTE) **/ public static final List NATOFlechette = ImmutableList.of(BulletConfigSyncingUtil.R556_FLECHETTE, BulletConfigSyncingUtil.R556_FLECHETTE_INCENDIARY, BulletConfigSyncingUtil.R556_FLECHETTE_PHOSPHORUS, BulletConfigSyncingUtil.R556_FLECHETTE_DU, BulletConfigSyncingUtil.CHL_R556_FLECHETTE, BulletConfigSyncingUtil.R556_FLECHETTE_SLEEK, BulletConfigSyncingUtil.R556_K); /** 7.62x51mm NATO **/