diff --git a/src/main/java/com/hbm/calc/EasyLocation.java b/src/main/java/com/hbm/calc/EasyLocation.java index c22e6b484..6f0d31d38 100644 --- a/src/main/java/com/hbm/calc/EasyLocation.java +++ b/src/main/java/com/hbm/calc/EasyLocation.java @@ -6,18 +6,21 @@ import java.util.Optional; import javax.annotation.CheckForNull; +import com.hbm.interfaces.IByteSerializable; import com.hbm.interfaces.ILocationProvider; +import com.hbm.interfaces.INBTSerializable; import com.hbm.main.DeserializationException; import api.hbm.serialization.ISerializable; import api.hbm.serialization.SerializationRegistry; import io.netty.buffer.ByteBuf; import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Vec3; import net.minecraft.world.World; -public class EasyLocation implements Cloneable, Comparable, ISerializable, ILocationProvider +public class EasyLocation implements Cloneable, Comparable, ISerializable, IByteSerializable, INBTSerializable, ILocationProvider { /** * @@ -31,13 +34,26 @@ public class EasyLocation implements Cloneable, Comparable, ISeria { SerializationRegistry.register(EasyLocation.class, EasyLocation::new); } + + /** + * Returns a new {@code EasyLocation} object with all coordinates set to 0. + * @return A unique {@code EasyLocation} object at position (0, 0, 0). + */ + public static EasyLocation getZeroLocation() + { + return ZERO_LOCATION.clone(); + } + public EasyLocation(ILocationProvider locationProvider) { posX = locationProvider.posX(); posY = locationProvider.posY(); posZ = locationProvider.posZ(); if (locationProvider.hasWorld()) + { world = Optional.of(locationProvider.getWorld()); + dimID = locationProvider.getWorld().provider.dimensionId; + } } public EasyLocation(double x, double y, double z) { @@ -272,7 +288,7 @@ public class EasyLocation implements Cloneable, Comparable, ISeria final double myDist = ILocationProvider.distance(this, ZERO_LOCATION); if (testDist == myDist) return 0; - return myDist < testDist ? 1 : -1; + return myDist > testDist ? 1 : -1; } @Override @@ -310,4 +326,44 @@ public class EasyLocation implements Cloneable, Comparable, ISeria { return world.get(); } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + nbt.setDouble("posX", posX); + nbt.setDouble("posY", posY); + nbt.setDouble("posZ", posZ); + nbt.setInteger("dimID", dimID); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + posX = nbt.getDouble("posX"); + posY = nbt.getDouble("posY"); + posZ = nbt.getDouble("posZ"); + dimID = nbt.getInteger("dimID"); + } + + @Override + public void writeToBytes(ByteBuf buf) + { + buf.writeBytes(serialize()); + } + + @Override + public void readFromBytes(byte[] bytes) throws DeserializationException + { + try + { + final ByteBuf buf = allocCopy.apply(bytes); + posX = buf.readDouble(); + posY = buf.readDouble(); + posZ = buf.readDouble(); + dimID = buf.readInt(); + } catch (Exception e) + { + throw new DeserializationException(e); + } + } } \ No newline at end of file diff --git a/src/main/java/com/hbm/entity/projectile/EntityCombineBallNT.java b/src/main/java/com/hbm/entity/projectile/EntityCombineBallNT.java index aa85c6fa6..cebd81411 100644 --- a/src/main/java/com/hbm/entity/projectile/EntityCombineBallNT.java +++ b/src/main/java/com/hbm/entity/projectile/EntityCombineBallNT.java @@ -11,7 +11,7 @@ public class EntityCombineBallNT extends EntityBulletBase super(world, config, shooter); overrideDamage = 1000; } - + @Override public void setDead() { diff --git a/src/main/java/com/hbm/handler/BulletConfiguration.java b/src/main/java/com/hbm/handler/BulletConfiguration.java index 72037b14f..7acc16ac6 100644 --- a/src/main/java/com/hbm/handler/BulletConfiguration.java +++ b/src/main/java/com/hbm/handler/BulletConfiguration.java @@ -88,7 +88,7 @@ public class BulletConfiguration implements Cloneable { /**The function that handles lost penetration over distance**/ @Nonnull public Optional modFunction = Optional.of(DEFAULT_FUNCTION); - + //whether or not the bullet should penetrate mobs public boolean doesPenetrate; //whether or not the bullet should phase through blocks diff --git a/src/main/java/com/hbm/handler/GunConfiguration.java b/src/main/java/com/hbm/handler/GunConfiguration.java index 0ea58fb3e..e41d7a1fe 100644 --- a/src/main/java/com/hbm/handler/GunConfiguration.java +++ b/src/main/java/com/hbm/handler/GunConfiguration.java @@ -6,6 +6,8 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import javax.annotation.Nonnull; + import com.hbm.lib.HbmCollection.EnumGunManufacturer; import com.hbm.main.MainRegistry; import com.hbm.particle.SpentCasingConfig; @@ -94,8 +96,9 @@ public class GunConfiguration implements Cloneable { public Crosshair crosshair; /**Controller for spent casings. If {@code Optional.empty()} it will not eject casings.**/ + @Nonnull public Optional casingConfig = Optional.empty(); - + public static final int MODE_NORMAL = 0; public static final int MODE_RELEASE = 1; public static final int MODE_BOTH = 1; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java index 8a4e8424a..a22c378fb 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java @@ -1,11 +1,17 @@ package com.hbm.handler.guncfg; +import java.util.Optional; + +import com.hbm.calc.EasyLocation; import com.hbm.handler.BulletConfiguration; import com.hbm.handler.GunConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfig.CasingType; +import com.hbm.particle.SpentCasingConfigBuilder; import com.hbm.potion.HbmPotion; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationKeyframe; @@ -15,9 +21,33 @@ import com.hbm.render.util.RenderScreenOverlay.Crosshair; import net.minecraft.entity.EntityLivingBase; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.Vec3; public class Gun12GaugeFactory { + private static final SpentCasingConfigBuilder CASING_12G_BUILDER = new SpentCasingConfigBuilder("", CasingType.SHOTGUN, false) + .setScaleX(1.5f).setScaleY(1.5f).setScaleZ(1.5f); + static final SpentCasingConfig + CASING_SPAS = CASING_12G_BUILDER.setRegistryName("spas12").setPosOffset(new EasyLocation(1.5, 0, 0)) + .setInitialMotion(Vec3.createVectorHelper(-0.3, 0.75, 0)).setPitchFactor(0.03f).setYawFactor(0.01f) + .setSmokeChance(0).setDelay(10) + .build(), + + CASING_SPAS_ALT = CASING_12G_BUILDER.setRegistryName("spas12alt").setCasingAmount(2) + .build(), + + CASING_BENELLI = CASING_12G_BUILDER.setRegistryName("benelli").setCasingAmount(1).setDelay(0) + .setInitialMotion(Vec3.createVectorHelper(-0.3, 1.1, 0)) + .build(), + + CASING_UBOINIK = CASING_12G_BUILDER.setRegistryName("uboinik").setOverrideColor(true) + .setBlueOverride(255) + .build(), + + CASING_SSG = CASING_12G_BUILDER.setRegistryName("ssg").setBlueOverride(0).setRedOverride(255).setCasingAmount(2) + .setPosOffset(new EasyLocation(-2, 0, 0)).setInitialMotion(Vec3.createVectorHelper(0.2, 0, -0.2)) + .build(); + public static GunConfiguration getSpas12Config() { GunConfiguration config = new GunConfiguration(); @@ -59,6 +89,8 @@ public class Gun12GaugeFactory { ) ); + config.casingConfig = Optional.of(CASING_SPAS); + return config; } @@ -78,6 +110,8 @@ public class Gun12GaugeFactory { config.config = HbmCollection.twelveGauge; + + config.casingConfig = Optional.of(CASING_SPAS_ALT); return config; } @@ -105,6 +139,8 @@ public class Gun12GaugeFactory { config.config = HbmCollection.twelveGauge; + config.casingConfig = Optional.of(CASING_UBOINIK); + return config; } @@ -156,6 +192,8 @@ public class Gun12GaugeFactory { config.config = HbmCollection.twelveGauge; + config.casingConfig = Optional.of(CASING_SSG); + return config; } @@ -230,6 +268,8 @@ public class Gun12GaugeFactory { config.advFuncLore.add("user to quickly exchange the various assembly groups (barrel, buttstock, forend, etc.) without the use"); config.advFuncLore.add("of additional tools."); + config.casingConfig = Optional.of(CASING_BENELLI); + return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java index 719c35a09..135254b75 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java @@ -1,7 +1,9 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; +import com.hbm.calc.EasyLocation; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; import com.hbm.handler.GunConfiguration; @@ -9,6 +11,9 @@ import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfig.CasingType; +import com.hbm.particle.SpentCasingConfigBuilder; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationKeyframe; import com.hbm.render.anim.BusAnimationSequence; @@ -17,9 +22,18 @@ import com.hbm.render.util.RenderScreenOverlay.Crosshair; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.Vec3; public class Gun20GaugeFactory { + private static final SpentCasingConfigBuilder CASING_20G_BUILDER = new SpentCasingConfigBuilder("20g_lever", CasingType.SHOTGUN, false); + static final SpentCasingConfig + CASING_20G_LEVER = CASING_20G_BUILDER + .setPosOffset(new EasyLocation(1.5, 0, 0)) + .setInitialMotion(Vec3.createVectorHelper(-0.1, 0.95, 0)).setPitchFactor(0.05f).setYawFactor(0.01f) + .setSmokeChance(0) + .build(); + public static GunConfiguration getShotgunConfig() { GunConfiguration config = new GunConfiguration(); @@ -53,6 +67,8 @@ public class Gun20GaugeFactory { config.config = HbmCollection.twentyGauge; + config.casingConfig = Optional.of(CASING_20G_LEVER); + return config; } @@ -69,6 +85,8 @@ public class Gun20GaugeFactory { config.manufacturer = EnumGunManufacturer.WINCHESTER; config.config = HbmCollection.twentyGauge; + + config.casingConfig = Optional.of(CASING_20G_LEVER); return config; } @@ -86,6 +104,8 @@ public class Gun20GaugeFactory { config.manufacturer = EnumGunManufacturer.WINCHESTER; config.config = HbmCollection.twentyGauge; + + config.casingConfig = Optional.of(CASING_20G_LEVER); return config; } @@ -121,6 +141,8 @@ public class Gun20GaugeFactory { ); config.config = HbmCollection.twentyGauge; + + config.casingConfig = Optional.of(CASING_20G_LEVER); return config; } @@ -157,6 +179,8 @@ public class Gun20GaugeFactory { config.config = HbmCollection.twentyGauge; + + config.casingConfig = Optional.of(CASING_20G_LEVER); return config; } @@ -202,6 +226,8 @@ public class Gun20GaugeFactory { config.config.add(BulletConfigSyncingUtil.G20_SHOCK_FIRE); config.config.add(BulletConfigSyncingUtil.G20_WITHER_FIRE); config.config.add(BulletConfigSyncingUtil.G20_SLEEK); + + config.casingConfig = Optional.of(CASING_20G_LEVER); return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java index 83f7e660a..57787fc5a 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java @@ -1,17 +1,29 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; +import com.hbm.calc.EasyLocation; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; import com.hbm.handler.GunConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfig.CasingType; +import com.hbm.particle.SpentCasingConfigBuilder; import com.hbm.render.util.RenderScreenOverlay.Crosshair; +import net.minecraft.util.Vec3; + public class Gun22LRFactory { + static final SpentCasingConfig CASING_22LR = new SpentCasingConfigBuilder("22lr", CasingType.BRASS_STRAIGHT_WALL, false) + .setSmokeChance(20).setScaleX(0.4f).setScaleY(0.4f).setScaleZ(0.4f) + .setInitialMotion(Vec3.createVectorHelper(-0.3, 1, 0)).setPitchFactor(0.03f).setYawFactor(0.01f).setPosOffset(new EasyLocation(1.5, 0, 0)) + .build(); + public static GunConfiguration getUziConfig() { GunConfiguration config = new GunConfiguration(); @@ -54,6 +66,8 @@ public class Gun22LRFactory { config.advFuncLore.add("to be moved far back into the receiver and the magazine to be housed in the pistol grip, allowing for a heavier,"); config.advFuncLore.add("slower-firing bolt in a shorter, better-balanced weapon."); + config.casingConfig = Optional.of(CASING_22LR); + return config; } @@ -70,6 +84,8 @@ public class Gun22LRFactory { config.config.add(BulletConfigSyncingUtil.LR22_NORMAL_FIRE); config.config.add(BulletConfigSyncingUtil.LR22_AP_FIRE); config.config.add(BulletConfigSyncingUtil.CHL_LR22_FIRE); + + config.casingConfig = Optional.of(CASING_22LR); return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun357MagnumFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun357MagnumFactory.java index 3817e3ee1..9ddc7721f 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun357MagnumFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun357MagnumFactory.java @@ -1,7 +1,9 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; +import com.hbm.calc.EasyLocation; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; import com.hbm.handler.GunConfiguration; @@ -9,6 +11,9 @@ import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection.EnumGunManufacturer; import com.hbm.lib.ModDamageSource; +import com.hbm.particle.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfigBuilder; +import com.hbm.particle.SpentCasingConfig.CasingType; import com.hbm.potion.HbmPotion; import com.hbm.render.util.RenderScreenOverlay.Crosshair; @@ -16,6 +21,15 @@ import net.minecraft.potion.PotionEffect; public class Gun357MagnumFactory { + private static final SpentCasingConfigBuilder CASING_357_BUILDER = new SpentCasingConfigBuilder("357", CasingType.BRASS_STRAIGHT_WALL, false) + .setCasingAmount(6).setYawFactor(0.05f).setPosOffset(new EasyLocation(0, -0.1, 0)).setSmokeChance(6).setAfterReload(true); + static final SpentCasingConfig + CASING_357 = CASING_357_BUILDER.build(), + + CASING_357_SA = CASING_357_BUILDER.setRegistryName("357Schrabidium").setSmokeChance(0).setOverrideColor(true) + .setRedOverride(2).setGreenOverride(207).setBlueOverride(207) + .build(); + public static GunConfiguration getBaseConfig() { GunConfiguration config = new GunConfiguration(); @@ -34,6 +48,8 @@ public class Gun357MagnumFactory { config.firingSound = "hbm:weapon.revolverShoot"; config.reloadSoundEnd = false; + config.casingConfig = Optional.of(CASING_357); + return config; } @@ -149,6 +165,8 @@ public class Gun357MagnumFactory { config.config = new ArrayList(); config.config.add(BulletConfigSyncingUtil.SCHRABIDIUM_REVOLVER); config.config.add(BulletConfigSyncingUtil.DESH_REVOLVER); + + config.casingConfig = Optional.of(CASING_357_SA); return config; } @@ -184,6 +202,8 @@ public class Gun357MagnumFactory { config.config = new ArrayList(); config.config.add(BulletConfigSyncingUtil.NIGHT2_REVOLVER); + config.casingConfig = Optional.of(Gun20GaugeFactory.CASING_20G_LEVER); + return config; } @@ -210,7 +230,7 @@ public class Gun357MagnumFactory { public static GunConfiguration getColtPythonConfig() { - GunConfiguration config = getBaseConfig().clone(); + GunConfiguration config = getBaseConfig(); config.durability = 8000; config.name = "cPython"; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java index 796f3f011..4c184270b 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java @@ -1,7 +1,9 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; +import com.hbm.calc.EasyLocation; import com.hbm.entity.particle.EntityBSmokeFX; import com.hbm.entity.projectile.EntityBoxcar; import com.hbm.entity.projectile.EntityBuilding; @@ -15,6 +17,9 @@ 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.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfigBuilder; +import com.hbm.particle.SpentCasingConfig.CasingType; import com.hbm.potion.HbmPotion; import com.hbm.render.util.RenderScreenOverlay.Crosshair; @@ -24,6 +29,10 @@ import net.minecraft.potion.PotionEffect; public class Gun44MagnumFactory { + static final SpentCasingConfig CASING_44 = new SpentCasingConfigBuilder("44Magnum", CasingType.BRASS_STRAIGHT_WALL, false) + .setCasingAmount(6).setYawFactor(0.05f).setPosOffset(new EasyLocation(0, -0.1, 0)).setSmokeChance(6) + .setAfterReload(true).setScaleX(1.25f).build(); + public static GunConfiguration getBaseConfig() { GunConfiguration config = new GunConfiguration(); @@ -44,6 +53,8 @@ public class Gun44MagnumFactory { config.config.addAll(HbmCollection.fourtyFourMagBasic); + config.casingConfig = Optional.of(CASING_44); + return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java index 71e657cf4..ffe301bef 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java @@ -1,22 +1,39 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; +import com.hbm.calc.EasyLocation; import com.hbm.handler.BulletConfiguration; import com.hbm.handler.GunConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfig.CasingType; +import com.hbm.particle.SpentCasingConfigBuilder; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationKeyframe; import com.hbm.render.anim.BusAnimationSequence; import com.hbm.render.anim.HbmAnimations.AnimType; import com.hbm.render.util.RenderScreenOverlay.Crosshair; +import net.minecraft.util.Vec3; + public class Gun45ACPFactory { + private static final SpentCasingConfigBuilder CASING_45_BUILDER = new SpentCasingConfigBuilder("45acp", CasingType.BRASS_STRAIGHT_WALL, false) + .setSmokeChance(8).setInitialMotion(Vec3.createVectorHelper(-0.3, 0.75, 0)).setPitchFactor(0.03f).setYawFactor(0.01f) + .setPosOffset(new EasyLocation(1.5, 0, 0)).setScaleZ(0.75f); + static final SpentCasingConfig + CASING_45 = CASING_45_BUILDER.build(), + + CASING_45_UAC = CASING_45_BUILDER.setRegistryName("45acp_UAC_Pistol") + .setInitialMotion(Vec3.createVectorHelper(0.3, 0.9, 0)).setPosOffset(new EasyLocation(1.5, -1, 0)) + .build(); + public static GunConfiguration getThompsonConfig() { GunConfiguration config = new GunConfiguration(); @@ -48,6 +65,8 @@ public class Gun45ACPFactory config.advLore.add("Thompson in 1918. It was originally designed to break the stalemate of trench warfare of World"); config.advLore.add("War I, but was not finished until after the war ended."); + config.casingConfig = Optional.of(CASING_45); + return config; } @@ -85,6 +104,8 @@ public class Gun45ACPFactory .addKeyframe(new BusAnimationKeyframe(15, 0, 0, 10)) .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 40)))); + config.casingConfig = Optional.of(CASING_45_UAC); + return config; } @@ -114,6 +135,8 @@ public class Gun45ACPFactory config.config.addAll(HbmCollection.fourtyFiveACP); + config.casingConfig = Optional.of(CASING_45); + return config; } public static BulletConfiguration get45AutoConfig() diff --git a/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java index ba7568da4..9b2a769ed 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java @@ -2,7 +2,9 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import com.hbm.calc.EasyLocation; import com.hbm.entity.projectile.EntityBulletBase; import com.hbm.explosion.ExplosionLarge; import com.hbm.explosion.ExplosionNT; @@ -18,6 +20,9 @@ import com.hbm.lib.HbmCollection.EnumGunManufacturer; import com.hbm.lib.ModDamageSource; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; +import com.hbm.particle.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfig.CasingType; +import com.hbm.particle.SpentCasingConfigBuilder; import com.hbm.potion.HbmPotion; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationKeyframe; @@ -31,10 +36,16 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.Vec3; import net.minecraftforge.common.IExtendedEntityProperties; public class Gun4GaugeFactory { + static final SpentCasingConfig CASING_4G = new SpentCasingConfigBuilder("4g", CasingType.SHOTGUN, false) + .setSmokeChance(0).setPosOffset(new EasyLocation(1.5, 0, 0)) + .setInitialMotion(Vec3.createVectorHelper(-0.3, 0.75, 0)).setPitchFactor(0.03f).setYawFactor(0.01f) + .setScaleX(2.5f).setScaleY(2.5f).setScaleZ(2.5f).build(); + private static GunConfiguration getShotgunConfig() { GunConfiguration config = new GunConfiguration(); @@ -52,6 +63,8 @@ public class Gun4GaugeFactory { config.crosshair = Crosshair.L_CIRCLE; config.reloadSound = GunConfiguration.RSOUND_SHOTGUN; + config.casingConfig = Optional.of(CASING_4G); + return config; } @@ -123,7 +136,6 @@ public class Gun4GaugeFactory { return config; } static byte i = 0; - static final BulletConfiguration stock = get4GaugeConfig(); public static BulletConfiguration get4GaugeConfig() { BulletConfiguration bullet = BulletConfigFactory.standardBuckshotConfig(); @@ -339,7 +351,7 @@ public class Gun4GaugeFactory { public static BulletConfiguration get4GaugeClawConfig() { - BulletConfiguration bullet = stock.clone(); + BulletConfiguration bullet = BulletConfigFactory.standardBuckshotConfig(); bullet.ammo = new ComparableStack(ModItems.ammo_4gauge, 1, i++); bullet.dmgMin = 6; @@ -373,7 +385,7 @@ public class Gun4GaugeFactory { public static BulletConfiguration get4GaugeVampireConfig() { - BulletConfiguration bullet = stock.clone(); + BulletConfiguration bullet = BulletConfigFactory.standardBuckshotConfig(); bullet.ammo = new ComparableStack(ModItems.ammo_4gauge, 1, i++); bullet.dmgMin = 5; @@ -407,7 +419,7 @@ public class Gun4GaugeFactory { public static BulletConfiguration get4GaugeVoidConfig() { - BulletConfiguration bullet = stock.clone(); + BulletConfiguration bullet = BulletConfigFactory.standardBuckshotConfig(); bullet.ammo = new ComparableStack(ModItems.ammo_4gauge, 1, i++); bullet.dmgMin = 6; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java index 4f5783430..c13ebb40e 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java @@ -1,15 +1,27 @@ package com.hbm.handler.guncfg; +import java.util.Optional; + +import com.hbm.calc.EasyLocation; import com.hbm.handler.BulletConfiguration; import com.hbm.handler.GunConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfig.CasingType; +import com.hbm.particle.SpentCasingConfigBuilder; import com.hbm.render.util.RenderScreenOverlay.Crosshair; +import net.minecraft.util.Vec3; + public class Gun50AEFactory { + static final SpentCasingConfig CASING_50AE = new SpentCasingConfigBuilder("50ae", CasingType.BRASS_STRAIGHT_WALL, false) + .setSmokeChance(4).setInitialMotion(Vec3.createVectorHelper(-0.3, 0.9, 0)).setPitchFactor(0.03f).setYawFactor(0.01f) + .setPosOffset(new EasyLocation(1.5, 0, 0)).setScaleZ(1.5f).build(); + public static GunConfiguration getBaseConfig() { GunConfiguration config = new GunConfiguration(); @@ -28,6 +40,8 @@ public class Gun50AEFactory { config.firingSound = "hbm:weapon.deagleShoot"; config.reloadSoundEnd = false; + config.casingConfig = Optional.of(CASING_50AE); + return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java index 9d0ac4458..cb87223f4 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java @@ -1,7 +1,9 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; +import com.hbm.calc.EasyLocation; import com.hbm.entity.projectile.EntityBulletBase; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; @@ -12,6 +14,9 @@ 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.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfig.CasingType; +import com.hbm.particle.SpentCasingConfigBuilder; import com.hbm.potion.HbmPotion; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationKeyframe; @@ -26,9 +31,22 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.Vec3; public class Gun50BMGFactory { + public static final SpentCasingConfig + CONFIG_50BMG = new SpentCasingConfigBuilder("50bmg", CasingType.BRASS_BOTTLENECK, false) + .setSmokeChance(0).setInitialMotion(Vec3.createVectorHelper(-0.4, 1, 0)).setScaleX(3).setScaleY(3).setScaleZ(3) + .setPosOffset(new EasyLocation(0.2, 0.2, -0.08)).setPitchFactor(0.1f).setYawFactor(0.01f) + .build(), + + CONFIG_LUNA = new SpentCasingConfigBuilder("luna", CasingType.BRASS_BOTTLENECK, true) + .setScaleX(4).setScaleY(4).setScaleZ(4).setSmokeChance(0).setInitialMotion(Vec3.createVectorHelper(-2, 0, 0)) + .setPosOffset(new EasyLocation(0.5, 0.2, 0.08)).setRedOverride(11).setGreenOverride(97).setBlueOverride(109) + .setYawFactor(0.02f) + .build(); + public static GunConfiguration getCalamityConfig() { GunConfiguration config = new GunConfiguration(); @@ -141,6 +159,8 @@ public class Gun50BMGFactory { // .addKeyframe(new BusAnimationKeyframe(-20, -2, 0.75, 400))//Just plop that thing in there // .addKeyframe(new BusAnimationKeyframe(20, -2, 0.75, 75))));//Wait for the slide to close + config.casingConfig = Optional.of(CONFIG_LUNA); + return config; } @@ -155,6 +175,7 @@ public class Gun50BMGFactory { bullet.dmgMin = 450F; bullet.penetration = 10000; bullet.penetrationModifier = 1; + bullet.headshotMult = 2.5f; bullet.wear = 2000; bullet.velocity = 100; bullet.doesPenetrate = true; @@ -219,6 +240,8 @@ public class Gun50BMGFactory { config.config.addAll(HbmCollection.fiftyBMG); config.config.addAll(HbmCollection.fiftyBMGFlechette); + config.casingConfig = Optional.of(CONFIG_50BMG); + return config; } @@ -257,6 +280,8 @@ public class Gun50BMGFactory { config.advFuncLore.add("gun on aircraft before and during World War II, as on the early versions of the Curtiss P-40 fighter."); config.advFuncLore.add("The M2 is a scaled-up version of John Browning's M1917 .30 caliber machine gun. "); + config.casingConfig = Optional.of(CONFIG_50BMG); + return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java index cc9f467ad..12265a75d 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java @@ -1,7 +1,9 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; +import com.hbm.calc.EasyLocation; import com.hbm.entity.projectile.EntityBulletBase; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; @@ -12,6 +14,9 @@ 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.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfig.CasingType; +import com.hbm.particle.SpentCasingConfigBuilder; import com.hbm.potion.HbmPotion; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationKeyframe; @@ -22,9 +27,15 @@ import com.hbm.render.util.RenderScreenOverlay.Crosshair; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.Vec3; public class Gun556mmFactory { + static final SpentCasingConfig CONFIG_556 = new SpentCasingConfigBuilder("556", CasingType.BRASS_BOTTLENECK, false) + .setSmokeChance(4).setInitialMotion(Vec3.createVectorHelper(-0.3, 1, 0)).setPitchFactor(0.03f).setYawFactor(0.01f) + .setPosOffset(new EasyLocation(1.5, 0, 0)).setScaleZ(1.5f) + .build(); + public static GunConfiguration getEuphieConfig() { GunConfiguration config = new GunConfiguration(); @@ -61,6 +72,8 @@ public class Gun556mmFactory { config.config.add(BulletConfigSyncingUtil.CHL_R556); config.config.add(BulletConfigSyncingUtil.R556_SLEEK); config.config.add(BulletConfigSyncingUtil.R556_K); + + config.casingConfig = Optional.of(CONFIG_556); return config; } @@ -101,6 +114,8 @@ public class Gun556mmFactory { config.config = new ArrayList(); config.config.addAll(HbmCollection.NATOFlechette); + + config.casingConfig = Optional.of(CONFIG_556); return config; } @@ -127,6 +142,8 @@ public class Gun556mmFactory { config.config = new ArrayList(); config.config.addAll(HbmCollection.grenade); + config.casingConfig = Optional.of(GunGrenadeFactory.CASING_40); + return config; } @@ -160,6 +177,8 @@ public class Gun556mmFactory { .addKeyframe(new BusAnimationKeyframe(-0.35, 0, 0, 30)) .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 30)))); + config.casingConfig = Optional.of(CONFIG_556); + return config; } @@ -191,10 +210,13 @@ public class Gun556mmFactory { .addKeyframe(new BusAnimationKeyframe(-0.35, 0, 0, 30)) .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 30)))); + config.casingConfig = Optional.of(CONFIG_556); + return config; } static final float inaccuracy = 1.15F; + public static BulletConfiguration get556Config() { BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig(); @@ -216,7 +238,7 @@ public class Gun556mmFactory { bullet.dmgMin = 250; bullet.dmgMax = 320; bullet.spread = 0.0F; - + return bullet; } @@ -244,7 +266,7 @@ public class Gun556mmFactory { PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, projectile.posX, projectile.posY, projectile.posZ), new TargetPoint(projectile.dimension, projectile.posX, projectile.posY, projectile.posZ, 50)); }; - + return bullet; } @@ -258,7 +280,7 @@ public class Gun556mmFactory { bullet.penetration *= 1.5; bullet.wear = 15; bullet.leadChance = 10; - + return bullet; } @@ -272,7 +294,7 @@ public class Gun556mmFactory { bullet.penetration *= 2; bullet.wear = 25; bullet.leadChance = 50; - + return bullet; } @@ -286,7 +308,7 @@ public class Gun556mmFactory { bullet.penetration *= 2.5; bullet.wear = 25; bullet.leadChance = 100; - + return bullet; } @@ -327,7 +349,7 @@ public class Gun556mmFactory { meteor.shooter = projectile.shooter; projectile.worldObj.spawnEntityInWorld(meteor); }; - + return bullet; } @@ -354,7 +376,7 @@ public class Gun556mmFactory { bullet.wear = 15; bullet.style = BulletConfiguration.STYLE_FLECHETTE; bullet.doesPenetrate = false; - + return bullet; } @@ -364,7 +386,7 @@ public class Gun556mmFactory { bullet.ammo = new ComparableStack(ModItems.ammo_556, 1, 9); bullet.incendiary = 5; - + return bullet; } @@ -390,7 +412,7 @@ public class Gun556mmFactory { PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, projectile.posX, projectile.posY, projectile.posZ), new TargetPoint(projectile.dimension, projectile.posX, projectile.posY, projectile.posZ, 50)); }; - + return bullet; } @@ -405,7 +427,7 @@ public class Gun556mmFactory { bullet.wear = 25; bullet.leadChance = 50; bullet.doesPenetrate = true; - + return bullet; } @@ -446,7 +468,7 @@ public class Gun556mmFactory { meteor.shooter = projectile.shooter; projectile.worldObj.spawnEntityInWorld(meteor); }; - + return bullet; } @@ -459,7 +481,7 @@ public class Gun556mmFactory { bullet.dmgMax = 0; bullet.penetration = 0; bullet.maxAge = 0; - + return bullet; } } \ No newline at end of file diff --git a/src/main/java/com/hbm/handler/guncfg/Gun5mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun5mmFactory.java index c5a0b866b..7d162bcd2 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun5mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun5mmFactory.java @@ -1,6 +1,7 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; @@ -9,10 +10,14 @@ import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasingConfig; import com.hbm.render.util.RenderScreenOverlay.Crosshair; public class Gun5mmFactory { + public static final SpentCasingConfig CASING_5MM = Gun22LRFactory.CASING_22LR.toBuilder("5mm").setCasingAmount(5).build(), + CASING_5MM_TURRET = CASING_5MM.toBuilder("5mmTurret").setCasingAmount(1).build(); + public static GunConfiguration getMinigunConfig() { GunConfiguration config = new GunConfiguration(); @@ -32,6 +37,8 @@ public class Gun5mmFactory { config.config = HbmCollection.fiveMM; + config.casingConfig = Optional.of(CASING_5MM); + return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java index 50e370d68..a9d3dce92 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java @@ -1,6 +1,7 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; import com.hbm.handler.BulletConfiguration; import com.hbm.handler.GunConfiguration; @@ -8,6 +9,7 @@ import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasingConfig; import com.hbm.potion.HbmPotion; import com.hbm.render.util.RenderScreenOverlay.Crosshair; @@ -16,6 +18,9 @@ import net.minecraft.potion.PotionEffect; public class Gun762mmFactory { + static final SpentCasingConfig CASING_762_NATO = Gun556mmFactory.CONFIG_556.toBuilder("762NATO").setSmokeChance(2).setScaleX(2) + .setScaleZ(2.5f).build(); + public static GunConfiguration getUACDMRConfig() { final GunConfiguration config = new GunConfiguration(); @@ -42,6 +47,8 @@ public class Gun762mmFactory config.config.addAll(HbmCollection.threeZeroEight); + config.casingConfig = Optional.of(CASING_762_NATO); + return config; } @@ -118,6 +125,8 @@ public class Gun762mmFactory config.advFuncLore.add("extra ammunition, and reloads and spots targets for the gunner. The ammunition bearer carries additional ammunition"); config.advFuncLore.add("and the tripod with associated traversing and elevation mechanism, if issued, and fetches more ammunition as needed"); config.advFuncLore.add("during firing."); + + config.casingConfig = Optional.of(CASING_762_NATO); return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java index 0d2c60532..fff5dc221 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java @@ -1,6 +1,7 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; @@ -9,6 +10,7 @@ import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasingConfig; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationKeyframe; import com.hbm.render.anim.BusAnimationSequence; @@ -17,6 +19,9 @@ import com.hbm.render.util.RenderScreenOverlay.Crosshair; public class Gun9mmFactory { + static final SpentCasingConfig CASING_9 = Gun45ACPFactory.CASING_45.toBuilder("9") + .setScaleX(1).setScaleY(1).setScaleZ(0.6f).build(); + public static GunConfiguration getMP40Config() { GunConfiguration config = new GunConfiguration(); @@ -46,6 +51,8 @@ public class Gun9mmFactory { config.config.add(BulletConfigSyncingUtil.CHL_P9); config.config.add(BulletConfigSyncingUtil.P9_ROCKET); + config.casingConfig = Optional.of(CASING_9); + return config; } @@ -77,6 +84,8 @@ public class Gun9mmFactory { config.config.add(BulletConfigSyncingUtil.P9_DU); config.config.add(BulletConfigSyncingUtil.CHL_P9); config.config.add(BulletConfigSyncingUtil.P9_ROCKET); + + config.casingConfig = Optional.of(CASING_9); return config; } @@ -110,6 +119,8 @@ public class Gun9mmFactory { .addBus("RECOIL", new BusAnimationSequence() .addKeyframe(new BusAnimationKeyframe(0, 0, -0.1, 30)) .addKeyframe(new BusAnimationKeyframe(0, 0, 0, 30)))); + + config.casingConfig = Optional.of(CASING_9); return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java b/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java index 0e667779f..bbf7f64da 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java @@ -1,13 +1,30 @@ package com.hbm.handler.guncfg; +import com.hbm.calc.EasyLocation; import com.hbm.config.BombConfig; import com.hbm.entity.effect.EntityNukeCloudSmall; import com.hbm.entity.logic.EntityNukeExplosionMK4; import com.hbm.handler.BulletConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; +import com.hbm.particle.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfigBuilder; +import com.hbm.particle.SpentCasingConfig.CasingType; + +import net.minecraft.util.Vec3; public class GunCannonFactory { + + private static final SpentCasingConfigBuilder CASING_CANNON_BUILDER = new SpentCasingConfigBuilder("240", CasingType.BRASS_BOTTLENECK, false) + .setInitialMotion(Vec3.createVectorHelper(0, 0.2, -1)).setPosOffset(new EasyLocation(0, 1.75, 0)).setSmokeChance(0) + .setScaleX(10).setScaleY(10).setScaleZ(10); + public static final SpentCasingConfig + CASING_240 = CASING_CANNON_BUILDER.build(), + + CASING_16IN = CASING_CANNON_BUILDER.setRegistryName("16inch").setInitialMotion(Vec3.createVectorHelper(0, 1, -1.75)) + .setScaleX(20).setScaleY(20).setScaleZ(25) + .build(); + static final int stockPen = 10000; static byte i = 0; public static BulletConfiguration getShellConfig() { @@ -17,8 +34,8 @@ public class GunCannonFactory { bullet.ammo = new ComparableStack(ModItems.ammo_shell, 1, i++); bullet.dmgMin = 225; bullet.dmgMax = 235; - bullet.penetration = stockPen; - bullet.explosive = 40F; + bullet.penetration = 40; + bullet.explosive = 20F; bullet.blockDamage = false; return bullet; @@ -31,8 +48,8 @@ public class GunCannonFactory { bullet.ammo = new ComparableStack(ModItems.ammo_shell, 1, i++); bullet.dmgMin = 235; bullet.dmgMax = 245; - bullet.penetration = stockPen; - bullet.explosive = 40F; + bullet.penetration = 50; + bullet.explosive = 25F; bullet.blockDamage = true; return bullet; diff --git a/src/main/java/com/hbm/handler/guncfg/GunDGKFactory.java b/src/main/java/com/hbm/handler/guncfg/GunDGKFactory.java index aa61cff4e..931578c99 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunDGKFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunDGKFactory.java @@ -3,9 +3,16 @@ package com.hbm.handler.guncfg; import com.hbm.handler.BulletConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; +import com.hbm.particle.SpentCasingConfig; + +import net.minecraft.util.Vec3; public class GunDGKFactory { + public static final SpentCasingConfig CASING_DGK = Gun50BMGFactory.CONFIG_LUNA.toBuilder("dgk") + .setInitialMotion(Vec3.createVectorHelper(1, 1, 0)).setPosOffset(null).setOverrideColor(false) + .build(); + public static BulletConfiguration getDGKConfig() { BulletConfiguration bullet = BulletConfigFactory.standardBulletConfig(); diff --git a/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java b/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java index e8bd2a05c..e49d86fc9 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunGrenadeFactory.java @@ -1,6 +1,7 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Optional; import com.hbm.config.BombConfig; import com.hbm.entity.effect.EntityCloudTom; @@ -11,10 +12,17 @@ import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfigBuilder; +import com.hbm.particle.SpentCasingConfig.CasingType; import com.hbm.render.util.RenderScreenOverlay.Crosshair; public class GunGrenadeFactory { + static final SpentCasingConfig CASING_40 = new SpentCasingConfigBuilder("40", CasingType.BRASS_STRAIGHT_WALL, false) + .setSmokeChance(0).setScaleX(4).setAfterReload(true).setPitchFactor(0.02f).setYawFactor(0.03f) + .build(); + public static GunConfiguration getHK69Config() { GunConfiguration config = new GunConfiguration(); @@ -40,6 +48,8 @@ public class GunGrenadeFactory { config.config = new ArrayList(); config.config.addAll(HbmCollection.grenade); config.durability = 300; + + config.casingConfig = Optional.of(GunGrenadeFactory.CASING_40); return config; } diff --git a/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java b/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java index e662b397d..5c1b849ae 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java @@ -1,24 +1,41 @@ package com.hbm.handler.guncfg; import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; import com.hbm.blocks.generic.RedBarrel; +import com.hbm.calc.EasyLocation; +import com.hbm.entity.projectile.EntityBulletBase; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; import com.hbm.handler.GunConfiguration; +import com.hbm.interfaces.ILocationProvider; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.lib.HbmCollection.EnumGunManufacturer; +import com.hbm.particle.SpentCasingConfig; +import com.hbm.particle.SpentCasingConfigBuilder; +import com.hbm.particle.SpentCasingConfig.CasingType; +import com.hbm.lib.Library; import com.hbm.lib.ModDamageSource; import com.hbm.potion.HbmPotion; import com.hbm.render.util.RenderScreenOverlay.Crosshair; import net.minecraft.block.Block; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; public class GunOSIPRFactory { + static final SpentCasingConfig CASING_AR2 = new SpentCasingConfigBuilder("ar2", CasingType.AR2, false) + .setSmokeChance(0).setInitialMotion(Vec3.createVectorHelper(-0.15, 0.2, 0)).setPitchFactor(0.02f) + .setAfterReload(true).setPosOffset(new EasyLocation(3.5, 0, 0)).build(); + public static GunConfiguration getOSIPRConfig() { GunConfiguration config = new GunConfiguration(); @@ -44,6 +61,8 @@ public class GunOSIPRFactory { config.config = new ArrayList(); config.config.add(BulletConfigSyncingUtil.SPECIAL_OSIPR); + config.casingConfig = Optional.of(CASING_AR2); + return config; } @@ -151,37 +170,41 @@ public class GunOSIPRFactory { return bullet; } -// private static void tryRedirectBall(EntityBulletBase ball, EntityLivingBase lastHit) -// { -// if (!ball.worldObj.isRemote) -// { -// final ILocationProvider ballLoc = ILocationProvider.wrap(ball, false), targetLoc; -// final Vec3 newVector; -// final List entities = ball.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(ball.posX - 10, ball.posY - 10, ball.posZ - 10, ball.posX + 10, ball.posY + 10, ball.posZ + 10)); -// entities.remove(ball); -// entities.remove(ball.shooter); -// entities.remove(lastHit); -// entities.removeIf(e -> Library.isObstructed(ball.worldObj, ballLoc, ILocationProvider.wrap(e, false))); -// if (entities.isEmpty()) -// return; -// -// entities.sort(Comparator.comparing(e -> ILocationProvider.distance(ILocationProvider.wrap(e, false), ballLoc))); -// -// targetLoc = ILocationProvider.wrap(entities.get(0), false); -// newVector = ILocationProvider.makeVector(ballLoc, targetLoc).normalize(); -// -// System.out.println(ballLoc); -// System.out.println(targetLoc); -// System.out.println(newVector); -// System.out.println(Vec3.createVectorHelper(ball.motionX, ball.motionY, ball.motionZ)); -// -// final double total = ball.motionX + ball.motionY + ball.motionZ; -// -// ball.motionX = newVector.xCoord * total; -// ball.motionY = newVector.yCoord * total; -// ball.motionZ = newVector.zCoord * total; -// -// System.out.println(Vec3.createVectorHelper(ball.motionX, ball.motionY, ball.motionZ)); -// } -// } -} \ No newline at end of file + private static void tryRedirectBall(EntityBulletBase ball, EntityLivingBase lastHit) + { + if (!ball.worldObj.isRemote) + { + final ILocationProvider ballLoc = ILocationProvider.wrap(ball, false), targetLoc; + final Vec3 newVector; + final List entities = ball.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(ball.posX - 10, ball.posY - 10, ball.posZ - 10, ball.posX + 10, ball.posY + 10, ball.posZ + 10)); + entities.remove(ball); + entities.remove(ball.shooter); + entities.remove(lastHit); + entities.removeIf(e -> Library.isObstructed(ball.worldObj, ballLoc, ILocationProvider.wrap(e, false))); + if (entities.isEmpty()) + return; + + entities.sort(Comparator.comparing(e -> ILocationProvider.distance(ILocationProvider.wrap(e, false), ballLoc))); + + targetLoc = ILocationProvider.wrap(entities.get(0), false); + + System.out.println(ballLoc); + System.out.println(targetLoc); + System.out.println(Vec3.createVectorHelper(ball.motionX, ball.motionY, ball.motionZ)); + + final double oldMagnitude = Math.sqrt(ball.motionX * ball.motionX + ball.motionY * ball.motionY + ball.motionZ * ball.motionZ), newMagnitude; + newVector = Vec3.createVectorHelper( + targetLoc.posX() - ball.motionX, + targetLoc.posY() - ball.motionY, + targetLoc.posZ() - ball.motionZ + ); + newMagnitude = Math.sqrt(newVector.xCoord * newVector.xCoord + newVector.yCoord * newVector.yCoord + newVector.zCoord * newVector.zCoord); + + ball.motionX = newVector.xCoord * oldMagnitude / newMagnitude; + ball.motionY = newVector.yCoord * oldMagnitude / newMagnitude; + ball.motionZ = newVector.zCoord * oldMagnitude / newMagnitude; + + System.out.println(Vec3.createVectorHelper(ball.motionX, ball.motionY, ball.motionZ)); + } + } +} diff --git a/src/main/java/com/hbm/interfaces/IByteSerializable.java b/src/main/java/com/hbm/interfaces/IByteSerializable.java new file mode 100644 index 000000000..d23d7552b --- /dev/null +++ b/src/main/java/com/hbm/interfaces/IByteSerializable.java @@ -0,0 +1,19 @@ +package com.hbm.interfaces; + +import com.hbm.main.DeserializationException; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +public interface IByteSerializable +{ + public void writeToBytes(ByteBuf buf); + public void readFromBytes(byte[] bytes) throws DeserializationException; + + public default byte[] writeToBytes() + { + final ByteBuf buf = Unpooled.buffer(); + writeToBytes(buf); + return buf.array(); + } +} diff --git a/src/main/java/com/hbm/interfaces/INBTSerializable.java b/src/main/java/com/hbm/interfaces/INBTSerializable.java new file mode 100644 index 000000000..8dc9b42f7 --- /dev/null +++ b/src/main/java/com/hbm/interfaces/INBTSerializable.java @@ -0,0 +1,16 @@ +package com.hbm.interfaces; + +import net.minecraft.nbt.NBTTagCompound; + +public interface INBTSerializable +{ + public void writeToNBT(NBTTagCompound nbt); + public void readFromNBT(NBTTagCompound nbt); + + public default NBTTagCompound writeToNBT() + { + final NBTTagCompound nbt = new NBTTagCompound(); + writeToNBT(nbt); + return nbt; + } +} diff --git a/src/main/java/com/hbm/items/tool/ItemWandD.java b/src/main/java/com/hbm/items/tool/ItemWandD.java index 69fdac079..b0b95df35 100644 --- a/src/main/java/com/hbm/items/tool/ItemWandD.java +++ b/src/main/java/com/hbm/items/tool/ItemWandD.java @@ -2,26 +2,17 @@ package com.hbm.items.tool; import java.util.List; -import com.hbm.blocks.ModBlocks; -import com.hbm.entity.effect.EntityNukeTorex; -import com.hbm.entity.mob.siege.EntitySiegeTunneler; -import com.hbm.items.ModItems; -import com.hbm.items.special.ItemKitCustom; import com.hbm.lib.Library; import com.hbm.world.feature.OilSpot; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class ItemWandD extends Item { - + @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { diff --git a/src/main/java/com/hbm/items/weapon/ItemGunBase.java b/src/main/java/com/hbm/items/weapon/ItemGunBase.java index 58186803b..f07cfac11 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunBase.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunBase.java @@ -16,10 +16,12 @@ import com.hbm.interfaces.IItemHUD; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.IEquipReceiver; import com.hbm.lib.HbmCollection; +import com.hbm.main.MainRegistry; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.GunAnimationPacket; import com.hbm.packet.GunButtonPacket; import com.hbm.packet.PacketDispatcher; +import com.hbm.particle.SpentCasingConfig; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.HbmAnimations.AnimType; import com.hbm.render.util.RenderScreenOverlay; @@ -208,6 +210,9 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu } world.playSoundAtEntity(player, mainConfig.firingSound, 1.0F, mainConfig.firingPitch); + + if (mainConfig.casingConfig.isPresent() && !mainConfig.casingConfig.get().isAfterReload()) + spawnCasing(player, mainConfig.casingConfig.get(), stack); if(player.getDisplayName().equals("Vic4Games")) { NBTTagCompound nbt = new NBTTagCompound(); @@ -245,6 +250,9 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu } world.playSoundAtEntity(player, altConfig.firingSound, 1.0F, altConfig.firingPitch); + + if (altConfig.casingConfig.isPresent() && !altConfig.casingConfig.get().isAfterReload()) + spawnCasing(player, altConfig.casingConfig.get(), stack); } //spawns the actual projectile, can be overridden to change projectile entity @@ -438,6 +446,10 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu if(hasLoaded && mainConfig.reloadSoundEnd) world.playSoundAtEntity(player, mainConfig.reloadSound, 1.0F, 1.0F); + + if (mainConfig.casingConfig.isPresent() && mainConfig.casingConfig.get().isAfterReload()) + spawnCasing(player, mainConfig.casingConfig.get(), stack); + InventoryUtil.doesPlayerHaveAStack(player, ammo, true, false); } else { setReloadCycle(stack, getReloadCycle(stack) - 1); @@ -579,6 +591,8 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu list.add("Is Reloading: " + getIsReloading(stack)); list.add("Reload Cycle: " + getReloadCycle(stack)); list.add("RoF Cooldown: " + getDelay(stack)); +// list.add("Casing Spawning: " + stack.stackTagCompound.getBoolean("casingReady")); +// list.add("Casing Cooldown: " + stack.stackTagCompound.getByte("casingDelay")); } if (!mainConfig.advLore.isEmpty() || !mainConfig.advFuncLore.isEmpty()) list.add(""); @@ -844,10 +858,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu event.setCanceled(true); - if(!(gcfg.hasSights && player.isSneaking())) - RenderScreenOverlay.renderCustomCrosshairs(event.resolution, Minecraft.getMinecraft().ingameGUI, ((IHoldableWeapon)player.getHeldItem().getItem()).getCrosshair()); - else - RenderScreenOverlay.renderCustomCrosshairs(event.resolution, Minecraft.getMinecraft().ingameGUI, Crosshair.NONE); + RenderScreenOverlay.renderCustomCrosshairs(event.resolution, Minecraft.getMinecraft().ingameGUI, (gcfg.hasSights && player.isSneaking()) ? Crosshair.NONE : ((IHoldableWeapon)player.getHeldItem().getItem()).getCrosshair()); } } @@ -863,4 +874,19 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu if (!mainConfig.equipSound.isEmpty() && !player.worldObj.isRemote) player.worldObj.playSoundAtEntity(player, mainConfig.equipSound, 1, 1); } + + // TODO Do something to handle delays + protected static void spawnCasing(Entity entity, SpentCasingConfig config, ItemStack stack) + { + final NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "casing"); + data.setDouble("posX", entity.posX); + data.setDouble("posY", entity.posY + entity.getEyeHeight()); + data.setDouble("posZ", entity.posZ); + data.setFloat("pitch", (float) Math.toRadians(entity.rotationPitch)); + data.setFloat("yaw", (float) Math.toRadians(entity.rotationYaw)); + data.setBoolean("crouched", entity.isSneaking()); + data.setString("name", config.getRegistryName()); + MainRegistry.proxy.effectNT(data); + } } diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 1218e4ea7..98bead3d9 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -103,7 +103,6 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.ReflectionHelper; public class ClientProxy extends ServerProxy { - public RenderInfoSystem theInfoSystem = new RenderInfoSystem(); @Override @@ -528,6 +527,8 @@ public class ClientProxy extends ServerProxy { MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.steel_wall), new ItemRenderDecoBlock()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.steel_corner), new ItemRenderDecoBlock()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.steel_roof), new ItemRenderDecoBlock()); + + MinecraftForgeClient.registerItemRenderer(ModItems.wand_d, new RenderCasingTest()); } @Override @@ -1174,6 +1175,8 @@ public class ClientProxy extends ServerProxy { ReflectionHelper.setPrivateValue(EntityFX.class, fx, 10 + rand.nextInt(20), "particleMaxAge", "field_70547_e"); break; } + default: + break; } if(fx != null) { @@ -1813,6 +1816,13 @@ public class ClientProxy extends ServerProxy { Minecraft.getMinecraft().effectRenderer.addEffect(text); break; } + case "casing": + final SpentCasingConfig casingConfig = SpentCasingConfig.get(data.getString("name")); + for (int i = 0; i < casingConfig.getCasingAmount(); i++) + casingConfig.spawnCasing(man, world, x, y, z, data.getFloat("pitch"), data.getFloat("yaw"), data.getBoolean("crouched")); + break; + default: + break; } } diff --git a/src/main/java/com/hbm/main/ResourceManager.java b/src/main/java/com/hbm/main/ResourceManager.java index 6edfe9257..faa98d485 100644 --- a/src/main/java/com/hbm/main/ResourceManager.java +++ b/src/main/java/com/hbm/main/ResourceManager.java @@ -989,6 +989,9 @@ public class ResourceManager { public static final IModelCustom cart = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/vehicles/cart.obj")); public static final IModelCustom cart_destroyer = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/vehicles/cart_destroyer.obj")); public static final IModelCustom cart_powder = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/vehicles/cart_powder.obj")); + + //Casings + public static final IModelCustom casings = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/effect/casings.obj")); ////Texture Entities @@ -1261,6 +1264,9 @@ public class ResourceManager { public static final ResourceLocation cart_semtex_side = new ResourceLocation(RefStrings.MODID, "textures/blocks/semtex_side.png"); public static final ResourceLocation cart_semtex_top = new ResourceLocation(RefStrings.MODID, "textures/blocks/semtex_bottom.png"); + //Casings + public static final ResourceLocation casings_tex = new ResourceLocation(RefStrings.MODID, "textures/particle/casing_tex.png"); + //ISBRHs public static final IModelCustom scaffold = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/scaffold.obj")); public static final IModelCustom taperecorder = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/blocks/taperecorder.obj")); diff --git a/src/main/java/com/hbm/particle/ParticleSpentCasing.java b/src/main/java/com/hbm/particle/ParticleSpentCasing.java index 254f44a2d..e3f16c893 100644 --- a/src/main/java/com/hbm/particle/ParticleSpentCasing.java +++ b/src/main/java/com/hbm/particle/ParticleSpentCasing.java @@ -1,37 +1,49 @@ package com.hbm.particle; +import java.util.ArrayList; +import java.util.List; + import org.lwjgl.opengl.GL11; -import com.hbm.lib.RefStrings; -import com.hbm.particle.SpentCasingConfig.CasingType; +import com.hbm.calc.EasyLocation; +import com.hbm.main.ResourceManager; +import com.hbm.util.Tuple.Pair; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; import net.minecraft.world.World; @SideOnly(Side.CLIENT) public class ParticleSpentCasing extends EntityFX { - private static final ResourceLocation TEXTURE_BRASS = new ResourceLocation(RefStrings.MODID, "textures/particle/casing_brass.png"), - TEXTURE_SHOTGUN = new ResourceLocation(RefStrings.MODID, "textures/particle/casing_shotgun.png"), - TEXTURE_AR2 = new ResourceLocation(RefStrings.MODID, "textures/particle/casing_ar2.png"); + private static final float dScale = 0.05f, smokeOffset = 0.025f, gravity = -0.5f; + private static final byte smokeAccel = 1; + + private final List> smokeNodes = new ArrayList>(); private final TextureManager textureManager; private final float momentumPitch, momentumYaw; - private final CasingType casingType; - public ParticleSpentCasing(TextureManager textureManager, World world, double x, double y, double z, double mx, double my, double mz, CasingType casingType, float momentumPitch, float momentumYaw) + private final SpentCasingConfig config; + private final boolean smoke; + + private boolean onGroundPreviously = false; + public ParticleSpentCasing(TextureManager textureManager, World world, double x, double y, double z, double mx, double my, double mz, float momentumPitch, float momentumYaw, SpentCasingConfig config) { super(world, x, y, z, mx, my, mz); - particleMaxAge = 120; this.textureManager = textureManager; - this.casingType = casingType; this.momentumPitch = momentumPitch; this.momentumYaw = momentumYaw; + this.config = config; + + particleMaxAge = 120; + smoke = config.getSmokeChance() == 0 ? true + : config.getSmokeChance() < 0 ? false + : rand.nextInt(config.getSmokeChance()) == 0; } @Override @@ -43,13 +55,53 @@ public class ParticleSpentCasing extends EntityFX @Override public void onUpdate() { - // TODO Auto-generated method stub super.onUpdate(); + if (!onGroundPreviously && onGround) + onGroundPreviously = true; + else if (onGroundPreviously && !onGround) + onGroundPreviously = false; + + if (!config.getBounceSound().isEmpty()) + { + if (!onGroundPreviously && onGround) + worldObj.playSoundEffect(posX, posY, posZ, config.getBounceSound(), 1, 1); + } + + if (particleAge > 90 && !smokeNodes.isEmpty()) + smokeNodes.clear(); + + if (smoke && particleAge <= 90) + { + final double side = (rotationYaw - prevRotationYaw) * 0.1D; + final Vec3 prev = Vec3.createVectorHelper(motionX, -motionY, motionZ); + prev.rotateAroundY((float) Math.toRadians(rotationYaw)); + + for (Pair pair : smokeNodes) + { + final EasyLocation node = pair.getKey(); + + node.posX += prev.xCoord * smokeAccel + rand.nextGaussian() * smokeOffset + side; + node.posY += prev.yCoord + 1.5; + node.posZ += prev.zCoord * smokeAccel + rand.nextGaussian() * smokeOffset; + } + + final double alpha = (particleAge / 20d); + + smokeNodes.add(new Pair(EasyLocation.getZeroLocation(), alpha)); + } + prevRotationPitch = rotationPitch; prevRotationYaw = rotationYaw; - if (!onGround) + if (motionY > gravity && !onGround) + motionY += gravity; + if (motionY < -0.75) + motionY = -0.75; + + if (onGround) + rotationPitch = 0; + else { rotationPitch += momentumPitch; rotationYaw += momentumYaw; @@ -62,36 +114,73 @@ public class ParticleSpentCasing extends EntityFX float tx, float tz ) { - // TODO Auto-generated method stub - super.renderParticle(tessellator, interp, x, y, z, tx, tz); - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - final ResourceLocation texture; - switch (casingType) + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glShadeModel(GL11.GL_SMOOTH); + + textureManager.bindTexture(ResourceManager.casings_tex); + + GL11.glTranslated( + prevPosX + (posX - prevPosX) * interp - interpPosX, + prevPosY + (posY - prevPosY) * interp - interpPosY, + prevPosZ + (posZ - prevPosZ) * interp - interpPosZ); + + GL11.glScalef(dScale, dScale, dScale); + + GL11.glScalef(config.getScaleX(), config.getScaleY(), config.getScaleZ()); + +// GL11.glRotatef(prevRotationYaw + (rotationYaw - prevRotationYaw), +// 0.0F, 1.0F, 0.0F); +// GL11.glRotatef(prevRotationPitch + (rotationPitch - prevRotationPitch), +// 0.0F, 0.0F, 1.0F); + + GL11.glRotatef(180 - rotationYaw, 0, 1, 0); + GL11.glRotatef(-rotationPitch, 1, 0, 0); + if (config.doesOverrideColor()) + GL11.glColor3f(config.getRedOverride(), config.getBlueOverride(), config.getGreenOverride()); + + if (!smokeNodes.isEmpty()) { - case AR2: texture = TEXTURE_AR2; break; - case BRASS: texture = TEXTURE_BRASS; break; - case SHOTGUN: texture = TEXTURE_SHOTGUN; break; - default: throw new IllegalStateException("CasingType [" + casingType + "] is not recognized, cannot render spent casing!"); + tessellator.startDrawingQuads(); + tessellator.setNormal(0F, 1F, 0F); + + for (int i = 0; i < smokeNodes.size() - 1; i++) + { + final Pair node = smokeNodes.get(i), past = smokeNodes.get(i + 1); + final EasyLocation nodeLoc = node.getKey(), pastLoc = past.getKey(); + final float nodeAlpha = node.getValue().floatValue(), pastAlpha = past.getValue().floatValue(), scale = Math.max(config.getScaleX(), config.getScaleY()); + + tessellator.setColorRGBA_F(1F, 1F, 1F, nodeAlpha); + tessellator.addVertex(nodeLoc.posX(), nodeLoc.posY(), nodeLoc.posZ()); + tessellator.setColorRGBA_F(1F, 1F, 1F, 0F); + tessellator.addVertex(nodeLoc.posX() + scale, nodeLoc.posY(), nodeLoc.posZ()); + tessellator.setColorRGBA_F(1F, 1F, 1F, 0F); + tessellator.addVertex(pastLoc.posX() + scale, pastLoc.posY(), pastLoc.posZ()); + tessellator.setColorRGBA_F(1F, 1F, 1F, pastAlpha); + tessellator.addVertex(pastLoc.posX(), pastLoc.posY(), pastLoc.posZ()); + + tessellator.setColorRGBA_F(1F, 1F, 1F, nodeAlpha); + tessellator.addVertex(nodeLoc.posX(), nodeLoc.posY(), nodeLoc.posZ()); + tessellator.setColorRGBA_F(1F, 1F, 1F, 0F); + tessellator.addVertex(nodeLoc.posX() - scale, nodeLoc.posY(), nodeLoc.posZ()); + tessellator.setColorRGBA_F(1F, 1F, 1F, 0F); + tessellator.addVertex(pastLoc.posX() - scale, pastLoc.posY(), pastLoc.posZ()); + tessellator.setColorRGBA_F(1F, 1F, 1F, pastAlpha); + tessellator.addVertex(pastLoc.posX(), pastLoc.posY(), pastLoc.posZ()); + } + + GL11.glAlphaFunc(GL11.GL_GREATER, 0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.1F); } - textureManager.bindTexture(texture); - - final float scale = particleScale * 0.1f, - xInterp = (float) (prevPosX + (posX - prevPosX) * interp - interpPosX), - yInterp = (float) (prevPosY + (posY - prevPosY) * interp - interpPosY), - zInterp = (float) (prevPosZ + (posZ - prevPosZ) * interp - interpPosZ); - - tessellator.startDrawingQuads(); - tessellator.setNormal(0, 1, 0); - tessellator.setBrightness(240); - tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); - tessellator.addVertexWithUV(xInterp - x * scale - tx * scale, yInterp - y, zInterp - z * scale - tz * scale, 0, 0); - tessellator.addVertexWithUV(xInterp - x * scale + tx * scale, yInterp + y, zInterp - z * scale + tz * scale, 0, 1); - tessellator.addVertexWithUV(xInterp + x * scale + tx * scale, yInterp + y, zInterp + z * scale + tz * scale, 1, 1); - tessellator.addVertexWithUV(xInterp + x * scale - tx * scale, yInterp - y, zInterp + z * scale - tz * scale, 1, 0); - tessellator.draw(); + ResourceManager.casings.renderPart(config.getCasingType().objName); + GL11.glShadeModel(GL11.GL_FLAT); GL11.glPopMatrix(); } } diff --git a/src/main/java/com/hbm/particle/SpentCasingConfig.java b/src/main/java/com/hbm/particle/SpentCasingConfig.java index 3bf9e031b..e0edaddfc 100644 --- a/src/main/java/com/hbm/particle/SpentCasingConfig.java +++ b/src/main/java/com/hbm/particle/SpentCasingConfig.java @@ -1,28 +1,55 @@ package com.hbm.particle; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; +import java.util.Random; -public class SpentCasingConfig implements Cloneable +import org.lwjgl.util.vector.Matrix4f; +import org.lwjgl.util.vector.Vector3f; +import org.lwjgl.util.vector.Vector4f; + +import com.google.common.annotations.Beta; +import com.google.common.collect.ImmutableMap; +import com.hbm.interfaces.ILocationProvider; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +@Beta +public class SpentCasingConfig { - + private static final Map CONFIG_MAP = new HashMap(); + private static final Random RANDOM = new Random(); public enum CasingType { - /**The typical ejected type. Most pistols, rifles, and even cannons will likely use it.**/ - BRASS, + /**The typical handgun ejected type. Most pistol and some cannon rounds will likely use it.**/ + BRASS_STRAIGHT_WALL("Brass_Straight_Casing"), + /**The typical rife ejected type. Most rifle round and sometimes cannon rounds use it. Only use if the bottleneck shape is noticeable.**/ + BRASS_BOTTLENECK("Brass_Bottleneck_Casing.002"), /**Shotgun shells.**/ - SHOTGUN, + SHOTGUN("Shotgun_Shell_Cylinder.002"), /**AR2 pulse rifle plugs.**/ - AR2; + AR2("AR2_Cylinder.001"); + public final String objName; + private CasingType(String objName) + { + this.objName = objName; + } } + /**Unique name used for map lookup.**/ + private final String registryName; /**Change position of the ejecting shell.**/ - private final double offsetX, offsetY, offsetZ; + private final ILocationProvider posOffset; /**Set initial motion after ejecting.**/ - private final double motionX, motionY, motionZ; - /**Rescale the sprite to match the approximate scale of the rounds.**/ - private final float stretchX, stretchY; + private final Vec3 initialMotion; /**Multipliers for random pitch and yaw.**/ private final float pitchFactor, yawFactor; + /**Rescale the sprite to match the approximate scale of the rounds.**/ + private final float scaleX, scaleY, scaleZ; /**Overrides for the sprite colors.**/ private final int redOverride, greenOverride, blueOverride; /**Whether or not to override the default sprite color scheme.**/ @@ -30,25 +57,31 @@ public class SpentCasingConfig implements Cloneable /**The type of casing.**/ private final CasingType casingType; /**Amount of casings to spawn per event. Default 1.**/ - private final int casingAmount; + private final byte casingAmount; /**If the casing(s) should be spawned after reloading, instead of after firing.**/ private final boolean afterReload; + /**Sound effect for bouncing. Make empty string to have no sound.**/ + private final String bounceSound; + /**Delay before casings are actually spawned**/ + private final byte delay; + /**Chance for the casing to emit smoke. 0 for 100% chance and -1 for it to never make smoke.**/ + private final byte smokeChance; + public SpentCasingConfig( - double offsetX, double offsetY, double offsetZ, double motionX, double motionY, double motionZ, - float stretchX, float stretchY, float pitchFactor, float yawFactor, int redOverride, int greenOverride, - int blueOverride, boolean overrideColor, CasingType casingType, int casingAmount, boolean afterReload + String registryName, ILocationProvider posOffset, Vec3 initialMotion, float pitchFactor, float yawFactor, + float scaleX, float scaleY, float scaleZ, int redOverride, int greenOverride, int blueOverride, + boolean overrideColor, CasingType casingType, byte casingAmount, boolean afterReload, String bounceSound, + byte delay, byte smokeChance ) { - this.offsetX = offsetX; - this.offsetY = offsetY; - this.offsetZ = offsetZ; - this.motionX = motionX; - this.motionY = motionY; - this.motionZ = motionZ; - this.stretchX = stretchX; - this.stretchY = stretchY; + this.registryName = registryName; + this.posOffset = posOffset; + this.initialMotion = initialMotion; this.pitchFactor = pitchFactor; this.yawFactor = yawFactor; + this.scaleX = scaleX; + this.scaleY = scaleY; + this.scaleZ = scaleZ; this.redOverride = redOverride; this.greenOverride = greenOverride; this.blueOverride = blueOverride; @@ -56,52 +89,88 @@ public class SpentCasingConfig implements Cloneable this.casingType = casingType; this.casingAmount = casingAmount; this.afterReload = afterReload; - } - - /** - * Apply these settings to an initialized casing entity - * @param entity The entity to apply the settings defined by this object - */ - public void applyToEntity(ParticleSpentCasing entity) - { - entity.setPosition((entity.posX - Math.cos(entity.rotationYaw / 180 * Math.PI)) + offsetX, - (entity.posY - 0.1) + offsetY, - (entity.posZ - Math.sin(entity.rotationYaw / 180 * Math.PI) + offsetZ)); + this.bounceSound = bounceSound; + this.delay = delay; + this.smokeChance = smokeChance; - entity.setRBGColorF((float) redOverride / 255, (float) greenOverride / 255, (float) blueOverride / 255); + CONFIG_MAP.put(registryName, this); + } + + public void spawnCasing(TextureManager textureManager, World world, double x, double y, double z, float pitch, float yaw, boolean crouched) + { + final Vec3 rotatedMotionVec = rotateVector(getInitialMotion(), + pitch + (float) (RANDOM.nextGaussian() * pitchFactor * 0.5), + yaw + (float) (RANDOM.nextGaussian() * yawFactor * 0.5), + pitchFactor, yawFactor); + + final ParticleSpentCasing casing = new ParticleSpentCasing(textureManager, world, x, + y, z, 0, 0, 0, +// 0, 0, + (float) (getPitchFactor() * RANDOM.nextGaussian()), (float) (getYawFactor() * RANDOM.nextGaussian()), + this); + + casing.motionX = rotatedMotionVec.xCoord; + casing.motionY = rotatedMotionVec.yCoord; + casing.motionZ = rotatedMotionVec.zCoord; + + offsetCasing(casing, getPosOffset(), yaw, crouched); + + casing.rotationPitch = (float) Math.toDegrees(pitch); + casing.rotationYaw = (float) Math.toDegrees(yaw); + + if (overrideColor) + casing.setRBGColorF(redOverride, blueOverride, greenOverride); + Minecraft.getMinecraft().effectRenderer.addEffect(casing); } - public double getOffsetX() + private static void offsetCasing(ParticleSpentCasing casing, ILocationProvider offset, float yaw, boolean crouched) { - return offsetX; + casing.posX -= Math.cos(yaw) * offset.posX() + (crouched ? 0.16 : -0.05); + casing.posY -= offset.posY(); + casing.posZ -= Math.sin(yaw) * offset.posZ(); } - public double getOffsetY() + + private static Vec3 rotateVector(Vec3 vector, float pitch, float yaw, float pitchFactor, float yawFactor) { - return offsetY; + vector.xCoord += RANDOM.nextGaussian() * yawFactor; + vector.yCoord += RANDOM.nextGaussian() * pitchFactor; + vector.zCoord += RANDOM.nextGaussian() * yawFactor; + + final Matrix4f pitchMatrix = new Matrix4f(), yawMatrix = new Matrix4f(); + + pitchMatrix.setIdentity(); + pitchMatrix.rotate(-pitch, new Vector3f(1, 0, 0)); + + yawMatrix.setIdentity(); + yawMatrix.rotate(-yaw, new Vector3f(0, 1, 0)); + + final Vector4f vector4f = new Vector4f((float) vector.xCoord, (float) vector.yCoord, (float) vector.zCoord, 1); + + Matrix4f.transform(pitchMatrix, vector4f, vector4f); + Matrix4f.transform(yawMatrix, vector4f, vector4f); + + return Vec3.createVectorHelper(vector4f.x, vector4f.y, vector4f.z); } - public double getOffsetZ() + + public ILocationProvider getPosOffset() { - return offsetZ; + return posOffset; } - public double getMotionX() + public Vec3 getInitialMotion() { - return motionX; + return Vec3.createVectorHelper(initialMotion.xCoord, initialMotion.yCoord, initialMotion.zCoord); } - public double getMotionY() + public float getScaleX() { - return motionY; + return scaleX; } - public double getMotionZ() + public float getScaleY() { - return motionZ; + return scaleY; } - public float getStretchX() + public float getScaleZ() { - return stretchX; - } - public float getStretchY() - { - return stretchY; + return scaleZ; } public float getPitchFactor() { @@ -123,7 +192,7 @@ public class SpentCasingConfig implements Cloneable { return blueOverride; } - public boolean isOverrideColor() + public boolean doesOverrideColor() { return overrideColor; } @@ -131,7 +200,7 @@ public class SpentCasingConfig implements Cloneable { return casingType; } - public int getCasingAmount() + public byte getCasingAmount() { return casingAmount; } @@ -139,11 +208,44 @@ public class SpentCasingConfig implements Cloneable { return afterReload; } + public String getRegistryName() + { + return registryName; + } + public String getBounceSound() + { + return bounceSound; + } + public byte getDelay() + { + return delay; + } + public byte getSmokeChance() + { + return smokeChance; + } + + /** + * Convert to a new builder for modification. + * @param newName The new registry name. + * @return A new builder with all the settings inherited from this config, except for registry name. + */ + public SpentCasingConfigBuilder toBuilder(String newName) + { + final SpentCasingConfigBuilder builder = new SpentCasingConfigBuilder(newName, casingType, overrideColor); + builder.setAfterReload(afterReload).setBlueOverride(blueOverride).setBounceSound(bounceSound).setCasingAmount(casingAmount) + .setDelay(delay).setGreenOverride(greenOverride).setInitialMotion(getInitialMotion()).setPitchFactor(pitchFactor) + .setPosOffset(getPosOffset()).setRedOverride(redOverride).setScaleX(scaleX).setScaleY(scaleY).setScaleZ(scaleZ) + .setSmokeChance(smokeChance).setYawFactor(yawFactor); + return builder; + } + @Override public int hashCode() { - return Objects.hash(afterReload, blueOverride, casingAmount, casingType, greenOverride, motionX, motionY, motionZ, - offsetX, offsetY, offsetZ, overrideColor, pitchFactor, redOverride, stretchX, stretchY, yawFactor); + return Objects.hash(afterReload, blueOverride, bounceSound, casingAmount, casingType, delay, greenOverride, + initialMotion.xCoord, initialMotion.yCoord, initialMotion.zCoord, overrideColor, pitchFactor, + posOffset, redOverride, registryName, scaleX, scaleY, scaleZ, smokeChance, yawFactor); } @Override public boolean equals(Object obj) @@ -154,47 +256,50 @@ public class SpentCasingConfig implements Cloneable return false; final SpentCasingConfig other = (SpentCasingConfig) obj; return afterReload == other.afterReload && blueOverride == other.blueOverride - && casingAmount == other.casingAmount && casingType == other.casingType - && greenOverride == other.greenOverride - && Double.doubleToLongBits(motionX) == Double.doubleToLongBits(other.motionX) - && Double.doubleToLongBits(motionY) == Double.doubleToLongBits(other.motionY) - && Double.doubleToLongBits(motionZ) == Double.doubleToLongBits(other.motionZ) - && Double.doubleToLongBits(offsetX) == Double.doubleToLongBits(other.offsetX) - && Double.doubleToLongBits(offsetY) == Double.doubleToLongBits(other.offsetY) - && Double.doubleToLongBits(offsetZ) == Double.doubleToLongBits(other.offsetZ) + && Objects.equals(bounceSound, other.bounceSound) && casingAmount == other.casingAmount + && casingType == other.casingType && delay == other.delay && greenOverride == other.greenOverride + && Double.doubleToLongBits(initialMotion.xCoord) == Double.doubleToLongBits(other.initialMotion.xCoord) + && Double.doubleToLongBits(initialMotion.yCoord) == Double.doubleToLongBits(other.initialMotion.yCoord) + && Double.doubleToLongBits(initialMotion.zCoord) == Double.doubleToLongBits(other.initialMotion.zCoord) && overrideColor == other.overrideColor && Float.floatToIntBits(pitchFactor) == Float.floatToIntBits(other.pitchFactor) - && redOverride == other.redOverride - && Float.floatToIntBits(stretchX) == Float.floatToIntBits(other.stretchX) - && Float.floatToIntBits(stretchY) == Float.floatToIntBits(other.stretchY) + && Objects.equals(posOffset, other.posOffset) && redOverride == other.redOverride + && Objects.equals(registryName, other.registryName) + && Float.floatToIntBits(scaleX) == Float.floatToIntBits(other.scaleX) + && Float.floatToIntBits(scaleY) == Float.floatToIntBits(other.scaleY) + && Float.floatToIntBits(scaleZ) == Float.floatToIntBits(other.scaleZ) + && smokeChance == other.smokeChance && Float.floatToIntBits(yawFactor) == Float.floatToIntBits(other.yawFactor); } @Override public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("SpentCasingConfig [offsetX=").append(offsetX).append(", offsetY=").append(offsetY) - .append(", offsetZ=").append(offsetZ).append(", motionX=").append(motionX).append(", motionY=") - .append(motionY).append(", motionZ=").append(motionZ).append(", stretchX=").append(stretchX) - .append(", stretchY=").append(stretchY).append(", pitchFactor=").append(pitchFactor) - .append(", yawFactor=").append(yawFactor).append(", redOverride=").append(redOverride) + builder.append("SpentCasingConfig [registryName=").append(registryName).append(", posOffset=").append(posOffset) + .append(", initialMotion=").append(initialMotion).append(", pitchFactor=").append(pitchFactor) + .append(", yawFactor=").append(yawFactor).append(", scaleX=").append(scaleX).append(", scaleY=") + .append(scaleY).append(", scaleZ=").append(scaleZ).append(", redOverride=").append(redOverride) .append(", greenOverride=").append(greenOverride).append(", blueOverride=").append(blueOverride) .append(", overrideColor=").append(overrideColor).append(", casingType=").append(casingType) .append(", casingAmount=").append(casingAmount).append(", afterReload=").append(afterReload) - .append(']'); + .append(", bounceSound=").append(bounceSound).append(", delay=").append(delay).append(", smokeChance=") + .append(smokeChance).append("]"); return builder.toString(); } - @Override - public SpentCasingConfig clone() + + public static boolean containsKey(String key) { - try - { - return (SpentCasingConfig) super.clone(); - } catch (CloneNotSupportedException e) - { - e.printStackTrace(); - return new SpentCasingConfig(offsetX, offsetY, offsetZ, motionX, motionY, motionZ, stretchX, stretchY, pitchFactor, yawFactor, redOverride, greenOverride, blueOverride, overrideColor, casingType, casingAmount, afterReload); - } + return CONFIG_MAP.containsKey(key); } + public static SpentCasingConfig get(String key) + { + return CONFIG_MAP.get(key); + } + + public static Map getConfigMap() + { + return ImmutableMap.copyOf(CONFIG_MAP); + } + } diff --git a/src/main/java/com/hbm/particle/SpentCasingConfigBuilder.java b/src/main/java/com/hbm/particle/SpentCasingConfigBuilder.java index 13e975773..a3f7368f3 100644 --- a/src/main/java/com/hbm/particle/SpentCasingConfigBuilder.java +++ b/src/main/java/com/hbm/particle/SpentCasingConfigBuilder.java @@ -2,121 +2,135 @@ package com.hbm.particle; import java.util.Objects; +import com.google.common.annotations.Beta; +import com.hbm.calc.EasyLocation; +import com.hbm.interfaces.ILocationProvider; +import com.hbm.main.MainRegistry; import com.hbm.particle.SpentCasingConfig.CasingType; import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +@Beta public class SpentCasingConfigBuilder implements Cloneable { + /**Unique name used for map lookup.**/ + private String registryName; /**Change position of the ejecting shell.**/ - private double offsetX, offsetY, offsetZ; + private ILocationProvider posOffset = EasyLocation.getZeroLocation(); /**Set initial motion after ejecting.**/ - private double motionX, motionY, motionZ; - /**Rescale the sprite to match the approximate scale of the rounds.**/ - private float stretchX, stretchY; + private Vec3 initialMotion = Vec3.createVectorHelper(0, 0, 0); /**Multipliers for random pitch and yaw.**/ - private float pitchFactor = 1, yawFactor = 1; + private float pitchFactor, yawFactor; + /**Rescale the sprite to match the approximate scale of the rounds.**/ + private float scaleX = 1, scaleY = 1, scaleZ = 1; /**Overrides for the sprite colors.**/ private int redOverride, greenOverride, blueOverride; /**Whether or not to override the default sprite color scheme.**/ private boolean overrideColor; /**The type of casing.**/ - private CasingType casingType; + private CasingType casingType = CasingType.BRASS_STRAIGHT_WALL; /**Amount of casings to spawn per event. Default 1.**/ - private int casingAmount = 1; + private byte casingAmount = 1; /**If the casing(s) should be spawned after reloading, instead of after firing.**/ private boolean afterReload; - public SpentCasingConfigBuilder(CasingType casingType, boolean overrideColor) + /**Sound effect for bouncing. Make empty string to have no sound.**/ + private String bounceSound = ""; + /**Delay before casings are actually spawned**/ + private byte delay; + /**Chance for the casing to emit smoke. 0 for 100% chance and -1 for it to never make smoke.**/ + private byte smokeChance = -1; + /** + * Constructor with fields for the required bare minimum parameters.
+ * All parameters may overridden using setters at any time at your discretion, however. + * @param registryName The unique name for map lookup. Null not permitted, becomes empty string. + * @param casingType Type of casing model to use. Null not permitted, defaults to straight wall type. + * @param overrideColor Whether or not the config will override the model texture's color. + */ + public SpentCasingConfigBuilder(String registryName, CasingType casingType, boolean overrideColor) { - this.casingType = casingType; + this.registryName = registryName == null ? "" : registryName; + this.casingType = casingType == null ? CasingType.BRASS_STRAIGHT_WALL : casingType; this.overrideColor = overrideColor; } - public double getOffsetX() + public ILocationProvider getPosOffset() { - return offsetX; + return posOffset; } - - public SpentCasingConfigBuilder setOffsetX(double offsetX) + + /** + * Set the relative x, y, z coordinate offset on spawn. + * @param posOffset Any ILocationProvider that serves as the offset. Null becomes a zero location. + * @return Itself for chaining. + */ + public SpentCasingConfigBuilder setPosOffset(ILocationProvider posOffset) { - this.offsetX = offsetX; + this.posOffset = posOffset == null ? EasyLocation.getZeroLocation() : posOffset; return this; } - public double getOffsetY() + public Vec3 getInitialMotion() { - return offsetY; + return initialMotion; + } + + /** + * Sets the casing's initial relative x, y, z motion on spawn. + * @param initialMotion Vector representing the initial motion. Null becomes a zero vector. + * @return Itself for chaining. + */ + public SpentCasingConfigBuilder setInitialMotion(Vec3 initialMotion) + { + this.initialMotion = initialMotion == null ? Vec3.createVectorHelper(0, 0, 0) : initialMotion; + return this; + } + + public double getScaleX() + { + return scaleX; } - public SpentCasingConfigBuilder setOffsetY(double offsetY) + /** + * Scale of the model on its x-axis. + * @param scaleX The scale/stretch factor of the model on the x-axis. + * @return Itself for chaining. + */ + public SpentCasingConfigBuilder setScaleX(float scaleX) { - this.offsetY = offsetY; + this.scaleX = scaleX; return this; } - public double getOffsetZ() + public double getScaleY() { - return offsetZ; + return scaleY; } - public SpentCasingConfigBuilder setOffsetZ(double offsetZ) + /** + * Scale of the model on its y-axis. + * @param scaleY The scale/stretch factor of the model on the y-axis. + * @return Itself for chaining. + */ + public SpentCasingConfigBuilder setScaleY(float scaleY) { - this.offsetZ = offsetZ; + this.scaleY = scaleY; return this; } - - public double getMotionX() + + public float getScaleZ() { - return motionX; + return scaleZ; } - - public SpentCasingConfigBuilder setMotionX(double motionX) + + /** + * Scale of the model on its z-axis. + * @param scaleZ The scale/stretch of the model on the z-axis. + * @return Itself for chaining. + */ + public SpentCasingConfigBuilder setScaleZ(float scaleZ) { - this.motionX = motionX; - return this; - } - - public double getMotionY() - { - return motionY; - } - - public SpentCasingConfigBuilder setMotionY(double motionY) - { - this.motionY = motionY; - return this; - } - - public double getMotionZ() - { - return motionZ; - } - - public SpentCasingConfigBuilder setMotionZ(double motionZ) - { - this.motionZ = motionZ; - return this; - } - - public double getStretchX() - { - return stretchX; - } - - public SpentCasingConfigBuilder setStretchX(float stretchX) - { - this.stretchX = stretchX; - return this; - } - - public double getStretchY() - { - return stretchY; - } - - public SpentCasingConfigBuilder setStretchY(float stretchY) - { - this.stretchY = stretchY; + this.scaleZ = scaleZ; return this; } @@ -125,6 +139,11 @@ public class SpentCasingConfigBuilder implements Cloneable return pitchFactor; } + /** + * Multiplier for random pitch-related motion. Recommended to keep in the thousanths (0.00X), as even with the hundreths (0.0X) the pitch can get crazy at times. + * @param pitchFactor The multiplier. + * @return Itself for chaining. + */ public SpentCasingConfigBuilder setPitchFactor(float pitchFactor) { this.pitchFactor = pitchFactor; @@ -136,6 +155,11 @@ public class SpentCasingConfigBuilder implements Cloneable return yawFactor; } + /** + * Multiplier for random yaw-related motion. Recommended to keep in the thousanths (0.00X), as even with the hundreths (0.0X) the yaw can get crazy at times. + * @param yawFactor The multiplier. + * @return Itself for chaining. + */ public SpentCasingConfigBuilder setYawFactor(float yawFactor) { this.yawFactor = yawFactor; @@ -147,6 +171,11 @@ public class SpentCasingConfigBuilder implements Cloneable return redOverride; } + /** + * Red color override. Clamped between 0-255, but I don't know how it actually works on the receiving end, so feel free to change. + * @param redOverride Red color override. + * @return Itself for chaining. + */ public SpentCasingConfigBuilder setRedOverride(int redOverride) { this.redOverride = MathHelper.clamp_int(redOverride, 0, 255); @@ -158,6 +187,11 @@ public class SpentCasingConfigBuilder implements Cloneable return greenOverride; } + /** + * Green color override. Clamped between 0-255, but I don't know how it actually works on the receiving end, so feel free to change. + * @param greenOverride Green color override. + * @return Itself for chaining. + */ public SpentCasingConfigBuilder setGreenOverride(int greenOverride) { this.greenOverride = MathHelper.clamp_int(greenOverride, 0, 255); @@ -169,17 +203,27 @@ public class SpentCasingConfigBuilder implements Cloneable return blueOverride; } + /** + * Blue color override. Clamped between 0-255, but I don't know how it actually works on the receiving end, so feel free to change. + * @param blueOverride Blue color override. + * @return Itself for chaining. + */ public SpentCasingConfigBuilder setBlueOverride(int blueOverride) { this.blueOverride = MathHelper.clamp_int(blueOverride, 0, 255); return this; } - public boolean isOverrideColor() + public boolean doesOverrideColor() { return overrideColor; } + /** + * Sets whether or not the config will override color. If false, the integer overrides will be ignored. + * @param overrideColor True, to use the integer color overrides, false to ignore them. + * @return Itself for chaining. + */ public SpentCasingConfigBuilder setOverrideColor(boolean overrideColor) { this.overrideColor = overrideColor; @@ -191,20 +235,30 @@ public class SpentCasingConfigBuilder implements Cloneable return casingType; } + /** + * Sets the model the casing will use. + * @param casingType One of the 4 casing model types. Null is not permitted, will have no effect. + * @return Itself for chaining. + */ public SpentCasingConfigBuilder setCasingType(CasingType casingType) { - this.casingType = casingType; + this.casingType = casingType == null ? this.casingType : casingType; return this; } - public int getCasingAmount() + public byte getCasingAmount() { return casingAmount; } + /** + * Sets the amount of casings to spawn. Default is 1. + * @param casingAmount Amount of casings to spawn. Clamped to a positive byte (0 - 127). + * @return Itself for chaining. + */ public SpentCasingConfigBuilder setCasingAmount(int casingAmount) { - this.casingAmount = casingAmount; + this.casingAmount = (byte) MathHelper.clamp_int(casingAmount, 0, 127); return this; } @@ -213,23 +267,102 @@ public class SpentCasingConfigBuilder implements Cloneable return afterReload; } + /** + * Sets whether or not the casing will be spawned after reloading is done or after firing. + * @param afterReload If true, casings will be spawned when reloading, false, they will be spawned after firing. + * @return Itself for chaining. + */ public SpentCasingConfigBuilder setAfterReload(boolean afterReload) { this.afterReload = afterReload; return this; } + public String getRegistryName() + { + return registryName; + } + + /** + * Resets the unique name for the config used in map lookup.
+ * As the real class is self-registering, make sure to set this in reused builders. + * @param registryName The registry name to use. Null is not permitted, becomes an empty string. + * @return Itself for chaining. + */ + public SpentCasingConfigBuilder setRegistryName(String registryName) + { + this.registryName = registryName == null ? "" : registryName; + return this; + } + + public String getBounceSound() + { + return bounceSound; + } + + /** + * The sound used when bouncing. If empty, no sound will be made. + * @param bounceSound The sound path. Null is not permitted, becomes an empty string. + * @return Itself for chaining. + */ + public SpentCasingConfigBuilder setBounceSound(String bounceSound) + { + this.bounceSound = bounceSound == null ? "" : bounceSound; + return this; + } + + public byte getDelay() + { + return delay; + } + + /** + * The delay in ticks before spawning. + * @param delay Tick spawn delay. Must be nonnegative, otherwise 0. + * @return Itself for chaining. + */ + public SpentCasingConfigBuilder setDelay(int delay) + { + this.delay = (byte) (delay < 0 ? 0 : delay); + return this; + } + + public byte getSmokeChance() + { + return smokeChance; + } + + /** + * Chance for the casing to emit smoke. 0 for 100% chance and -1 for it to never make smoke. + * @param smokeChance Chance to emit smoke. Clamped to a byte. + * @return Itself for chaining. + */ + public SpentCasingConfigBuilder setSmokeChance(int smokeChance) + { + this.smokeChance = (byte) smokeChance; + return this; + } + + /** + * Constructs the true immutable config with all settings loaded from this builder.
+ * This builder may be reused as all non-immutable and primitive fields are copied before being passed to the constructor.
+ * The config's constructor is self-registering. + * @return The finished config with its settings specified by this builder. + */ public SpentCasingConfig build() { - return new SpentCasingConfig(offsetX, offsetY, offsetZ, motionX, motionY, motionZ, stretchX, stretchY, pitchFactor, yawFactor, redOverride, greenOverride, blueOverride, overrideColor, casingType, casingAmount, afterReload); + return new SpentCasingConfig(registryName, new EasyLocation(posOffset), + Vec3.createVectorHelper(initialMotion.xCoord, initialMotion.yCoord, initialMotion.zCoord), pitchFactor, + yawFactor, scaleX, scaleY, scaleZ, redOverride, greenOverride, blueOverride, overrideColor, casingType, + casingAmount, afterReload, bounceSound, delay, smokeChance); } @Override public int hashCode() { - return Objects.hash(afterReload, blueOverride, casingAmount, casingType, greenOverride, motionX, motionY, - motionZ, offsetX, offsetY, offsetZ, overrideColor, pitchFactor, redOverride, stretchX, stretchY, - yawFactor); + return Objects.hash(afterReload, blueOverride, bounceSound, casingAmount, casingType, delay, greenOverride, + initialMotion.xCoord, initialMotion.yCoord, initialMotion.zCoord, overrideColor, pitchFactor, + posOffset, redOverride, registryName, scaleX, scaleY, scaleZ, smokeChance, yawFactor); } @Override @@ -241,19 +374,19 @@ public class SpentCasingConfigBuilder implements Cloneable return false; final SpentCasingConfigBuilder other = (SpentCasingConfigBuilder) obj; return afterReload == other.afterReload && blueOverride == other.blueOverride - && casingAmount == other.casingAmount && casingType == other.casingType - && greenOverride == other.greenOverride - && Double.doubleToLongBits(motionX) == Double.doubleToLongBits(other.motionX) - && Double.doubleToLongBits(motionY) == Double.doubleToLongBits(other.motionY) - && Double.doubleToLongBits(motionZ) == Double.doubleToLongBits(other.motionZ) - && Double.doubleToLongBits(offsetX) == Double.doubleToLongBits(other.offsetX) - && Double.doubleToLongBits(offsetY) == Double.doubleToLongBits(other.offsetY) - && Double.doubleToLongBits(offsetZ) == Double.doubleToLongBits(other.offsetZ) + && Objects.equals(bounceSound, other.bounceSound) && casingAmount == other.casingAmount + && casingType == other.casingType && delay == other.delay && greenOverride == other.greenOverride + && Double.doubleToLongBits(initialMotion.xCoord) == Double.doubleToLongBits(other.initialMotion.xCoord) + && Double.doubleToLongBits(initialMotion.yCoord) == Double.doubleToLongBits(other.initialMotion.yCoord) + && Double.doubleToLongBits(initialMotion.zCoord) == Double.doubleToLongBits(other.initialMotion.zCoord) && overrideColor == other.overrideColor && Float.floatToIntBits(pitchFactor) == Float.floatToIntBits(other.pitchFactor) - && redOverride == other.redOverride - && Float.floatToIntBits(stretchX) == Float.floatToIntBits(other.stretchX) - && Float.floatToIntBits(stretchY) == Float.floatToIntBits(other.stretchY) + && Objects.equals(posOffset, other.posOffset) && redOverride == other.redOverride + && Objects.equals(registryName, other.registryName) + && Float.floatToIntBits(scaleX) == Float.floatToIntBits(other.scaleX) + && Float.floatToIntBits(scaleY) == Float.floatToIntBits(other.scaleY) + && Float.floatToIntBits(scaleZ) == Float.floatToIntBits(other.scaleZ) + && smokeChance == other.smokeChance && Float.floatToIntBits(yawFactor) == Float.floatToIntBits(other.yawFactor); } @@ -261,15 +394,15 @@ public class SpentCasingConfigBuilder implements Cloneable public String toString() { final StringBuilder builder = new StringBuilder(); - builder.append("SpentCasingConfigBuilder [offsetX=").append(offsetX).append(", offsetY=").append(offsetY) - .append(", offsetZ=").append(offsetZ).append(", motionX=").append(motionX).append(", motionY=") - .append(motionY).append(", motionZ=").append(motionZ).append(", stretchX=").append(stretchX) - .append(", stretchY=").append(stretchY).append(", pitchFactor=").append(pitchFactor) - .append(", yawFactor=").append(yawFactor).append(", redOverride=").append(redOverride) - .append(", greenOverride=").append(greenOverride).append(", blueOverride=").append(blueOverride) - .append(", overrideColor=").append(overrideColor).append(", casingType=").append(casingType) - .append(", casingAmount=").append(casingAmount).append(", afterReload=").append(afterReload) - .append(']'); + builder.append("SpentCasingConfigBuilder [registryName=").append(registryName).append(", posOffset=") + .append(posOffset).append(", initialMotion=").append(initialMotion).append(", pitchFactor=") + .append(pitchFactor).append(", yawFactor=").append(yawFactor).append(", scaleX=").append(scaleX) + .append(", scaleY=").append(scaleY).append(", scaleZ=").append(scaleZ).append(", redOverride=") + .append(redOverride).append(", greenOverride=").append(greenOverride).append(", blueOverride=") + .append(blueOverride).append(", overrideColor=").append(overrideColor).append(", casingType=") + .append(casingType).append(", casingAmount=").append(casingAmount).append(", afterReload=") + .append(afterReload).append(", bounceSound=").append(bounceSound).append(", delay=").append(delay) + .append(", smokeChance=").append(smokeChance).append(']'); return builder.toString(); } @@ -281,12 +414,8 @@ public class SpentCasingConfigBuilder implements Cloneable return (SpentCasingConfigBuilder) super.clone(); } catch (CloneNotSupportedException e) { - e.printStackTrace(); - return new SpentCasingConfigBuilder(casingType, overrideColor).setBlueOverride(blueOverride) - .setCasingAmount(casingAmount).setGreenOverride(greenOverride).setMotionX(motionX) - .setMotionY(motionY).setMotionZ(motionZ).setOffsetX(offsetX).setOffsetY(offsetY) - .setOffsetZ(offsetZ).setPitchFactor(pitchFactor).setRedOverride(redOverride) - .setStretchX(stretchX).setStretchY(stretchY).setYawFactor(yawFactor); + MainRegistry.logger.catching(e); + return new SpentCasingConfigBuilder(registryName, casingType, overrideColor); } } diff --git a/src/main/java/com/hbm/render/entity/effect/RenderCasingTest.java b/src/main/java/com/hbm/render/entity/effect/RenderCasingTest.java new file mode 100644 index 000000000..381d1834a --- /dev/null +++ b/src/main/java/com/hbm/render/entity/effect/RenderCasingTest.java @@ -0,0 +1,56 @@ +package com.hbm.render.entity.effect; + +import org.lwjgl.opengl.GL11; + +import com.hbm.main.ResourceManager; +import com.hbm.particle.SpentCasingConfig.CasingType; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; + +public class RenderCasingTest implements IItemRenderer +{ + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) + { + return true; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) + { + return false; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) + { + final EntityPlayer player = Minecraft.getMinecraft().thePlayer; + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glShadeModel(GL11.GL_SMOOTH); + + Minecraft.getMinecraft().getTextureManager().bindTexture(ResourceManager.casings_tex); + +// GL11.glTranslated( +// player.prevPosX + (player.posX - player.prevPosX), +// player.prevPosY + (player.posY - player.prevPosY), +// player.prevPosZ + (player.posZ - player.prevPosZ)); + +// GL11.glRotatef(player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw), +// 0.0F, 1.0F, 0.0F); +// GL11.glRotatef(player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch), +// 0.0F, 0.0F, 1.0F); + + GL11.glRotatef(180 - player.rotationYaw, 0, 1, 0); + GL11.glRotatef(-player.rotationPitch, 1, 0, 0); + + ResourceManager.casings.renderPart(CasingType.BRASS_BOTTLENECK.objName); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glPopMatrix(); + } + +} diff --git a/src/main/java/com/hbm/render/item/weapon/ItemRenderBenelli.java b/src/main/java/com/hbm/render/item/weapon/ItemRenderBenelli.java index 90ba0e4b4..06a0986d9 100644 --- a/src/main/java/com/hbm/render/item/weapon/ItemRenderBenelli.java +++ b/src/main/java/com/hbm/render/item/weapon/ItemRenderBenelli.java @@ -39,7 +39,7 @@ public class ItemRenderBenelli implements IItemRenderer static final String frontGrip = "Pump_Cylinder.003"; static final String slide = "Cylinder"; static final String barrelAndTube = "Body_Cube.002"; - static final String shell = "Shell_Cylinder.002"; +// static final String shell = "Shell_Cylinder.002"; @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { @@ -55,7 +55,7 @@ public class ItemRenderBenelli implements IItemRenderer final double scale3 = 0.52D; double[] recoil = HbmAnimations.getRelevantTransformation("RECOIL"); - double[] eject = HbmAnimations.getRelevantTransformation("EJECT"); +// double[] eject = HbmAnimations.getRelevantTransformation("EJECT"); // double[] reload = HbmAnimations.getRelevantTransformation("RELOAD"); double[] feedNew = HbmAnimations.getRelevantTransformation("PUMP"); switch (type) @@ -82,7 +82,7 @@ public class ItemRenderBenelli implements IItemRenderer // GL11.glTranslated(reload[2] / 2, 0, 0); // GL11.glRotated(reload[0], 1, 0, 0); // GL11.glRotated(reload[1], 0, 0, 1); - ResourceManager.benelli.renderAllExcept(shell, slide); + ResourceManager.benelli.renderAll(); // Pump new round if empty if (magSize == 0) GL11.glTranslated(feedNew[0], feedNew[1], feedNew[2]); @@ -90,8 +90,8 @@ public class ItemRenderBenelli implements IItemRenderer GL11.glPopMatrix(); // Eject spent shell GL11.glPushMatrix(); - GL11.glTranslated(eject[0], eject[1], eject[2]); - ResourceManager.benelli.renderPart(shell); +// GL11.glTranslated(eject[0], eject[1], eject[2]); +// ResourceManager.benelli.renderPart(shell); GL11.glPopMatrix(); break; case EQUIPPED:// In hand from other's POV @@ -104,8 +104,8 @@ public class ItemRenderBenelli implements IItemRenderer GL11.glScaled(scale2 - scale2 * 2, scale2, scale2); GL11.glPushMatrix(); - GL11.glTranslated(eject[0], eject[1], eject[2]); - ResourceManager.benelli.renderPart(shell); +// GL11.glTranslated(eject[0], eject[1], eject[2]); +// ResourceManager.benelli.renderPart(shell); GL11.glPopMatrix(); break; case ENTITY:// Dropped entity diff --git a/src/main/java/com/hbm/render/item/weapon/ItemRenderLunaticSniper.java b/src/main/java/com/hbm/render/item/weapon/ItemRenderLunaticSniper.java index 097bb0cd0..1c788e292 100644 --- a/src/main/java/com/hbm/render/item/weapon/ItemRenderLunaticSniper.java +++ b/src/main/java/com/hbm/render/item/weapon/ItemRenderLunaticSniper.java @@ -49,7 +49,7 @@ public class ItemRenderLunaticSniper implements IItemRenderer { GL11.glPushMatrix(); double[] recoil = HbmAnimations.getRelevantTransformation("RECOIL"); - double[] eject = HbmAnimations.getRelevantTransformation("EJECT"); +// double[] eject = HbmAnimations.getRelevantTransformation("EJECT"); double[] tilt = HbmAnimations.getRelevantTransformation("TILT"); // double[] insert = HbmAnimations.getRelevantTransformation("INSERT_ROUND"); Minecraft.getMinecraft().renderEngine.bindTexture(ResourceManager.lunatic_sniper_tex); @@ -93,7 +93,7 @@ public class ItemRenderLunaticSniper implements IItemRenderer // Eject casing GL11.glPushMatrix(); GL11.glTranslated(0, 2, 0);//FIXME Where on earth is it?! - ResourceManager.lunatic_sniper.renderPart(spentShell); +// ResourceManager.lunatic_sniper.renderPart(spentShell); GL11.glPopMatrix(); break; case EQUIPPED:// In hand from other's POV @@ -103,8 +103,8 @@ public class ItemRenderLunaticSniper implements IItemRenderer GL11.glTranslatef(0F, -0.25F, -0.76F); GL11.glScalef(scale2 - scale2 * 2, scale2, scale2); GL11.glPushMatrix(); - GL11.glTranslated(eject[0] / 2, 0, -5); - ResourceManager.lunatic_sniper.renderPart(spentShell); +// GL11.glTranslated(eject[0] / 2, 0, -5); +// ResourceManager.lunatic_sniper.renderPart(spentShell); GL11.glPopMatrix(); break; case ENTITY:// Dropped item diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java index cfc551c83..026b21408 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java @@ -5,6 +5,7 @@ import java.util.List; import com.hbm.blocks.BlockDummyable; import com.hbm.entity.projectile.EntityArtilleryShell; +import com.hbm.handler.guncfg.GunCannonFactory; import com.hbm.inventory.container.ContainerTurretBase; import com.hbm.inventory.gui.GUITurretArty; import com.hbm.items.ModItems; @@ -12,6 +13,7 @@ import com.hbm.lib.Library; import com.hbm.main.MainRegistry; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; +import com.hbm.particle.SpentCasingConfig; import com.hbm.tileentity.IGUIProvider; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; @@ -45,7 +47,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen if(ammoStacks != null) return ammoStacks; - ammoStacks = new ArrayList(); + ammoStacks = new ArrayList<>(); List list = new ArrayList(); ModItems.ammo_arty.getSubItems(ModItems.ammo_arty, MainRegistry.weaponTab, list); @@ -56,7 +58,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen @Override protected List getAmmoList() { - return new ArrayList(); + return new ArrayList<>(); } @Override @@ -86,12 +88,12 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen @Override public double getDecetorRange() { - return this.mode == this.MODE_CANNON ? 250D : 3000D; + return this.mode == MODE_CANNON ? 250D : 3000D; } @Override public double getDecetorGrace() { - return this.mode == this.MODE_CANNON ? 32D : 250D; + return this.mode == MODE_CANNON ? 32D : 250D; } @Override @@ -121,7 +123,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen @Override public boolean doLOSCheck() { - return this.mode == this.MODE_CANNON; + return this.mode == MODE_CANNON; } @Override @@ -198,12 +200,13 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen proj.setTarget((int) tPos.xCoord, (int) tPos.yCoord, (int) tPos.zCoord); proj.setType(type); - if(this.mode != this.MODE_CANNON) + if(this.mode != MODE_CANNON) proj.setWhistle(true); worldObj.spawnEntityInWorld(proj); } + @Override protected void updateConnections() { ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite(); ForgeDirection rot = dir.getRotation(ForgeDirection.UP); @@ -239,7 +242,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen } } - if(this.mode == this.MODE_MANUAL) { + if(this.mode == MODE_MANUAL) { if(!this.targetQueue.isEmpty()) { this.tPos = this.targetQueue.get(0); } @@ -264,7 +267,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen } } - if(target != null && this.mode != this.MODE_MANUAL) { + if(target != null && this.mode != MODE_MANUAL) { if(!this.entityInLOS(this.target)) { this.target = null; } @@ -275,7 +278,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen if(target != null) { this.tPos = this.getEntityPos(target); } else { - if(this.mode != this.MODE_MANUAL) { + if(this.mode != MODE_MANUAL) { this.tPos = null; } } @@ -307,7 +310,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen if(searchTimer <= 0) { searchTimer = this.getDecetorInterval(); - if(this.target == null && this.mode != this.MODE_MANUAL) + if(this.target == null && this.mode != MODE_MANUAL) this.seekNewTarget(); } } else { @@ -373,7 +376,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.xCoord + vec.xCoord, pos.yCoord + vec.yCoord, pos.zCoord + vec.zCoord), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 150)); } - if(this.mode == this.MODE_MANUAL && !this.targetQueue.isEmpty()) { + if(this.mode == MODE_MANUAL && !this.targetQueue.isEmpty()) { this.targetQueue.remove(0); this.tPos = null; } @@ -436,4 +439,16 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUITurretArty(player.inventory, this); } + + @Override + public boolean usesCasings() + { + return true; + } + + @Override + public SpentCasingConfig getCasingConfig() + { + return GunCannonFactory.CASING_16IN; + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseArtillery.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseArtillery.java index 35d211872..9b2eeaefb 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseArtillery.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseArtillery.java @@ -8,7 +8,7 @@ import net.minecraft.util.Vec3; public abstract class TileEntityTurretBaseArtillery extends TileEntityTurretBaseNT { - protected List targetQueue = new ArrayList(); + protected List targetQueue = new ArrayList<>(); public void enqueueTarget(double x, double y, double z) { diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java index bff77dba0..c53c9b283 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java @@ -17,6 +17,8 @@ import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemTurretBiometry; import com.hbm.lib.Library; +import com.hbm.main.MainRegistry; +import com.hbm.particle.SpentCasingConfig; import com.hbm.tileentity.TileEntityMachineBase; import api.hbm.energy.IEnergyUser; @@ -90,6 +92,8 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple //tally marks! public int stattrak; + // Not saved because client side only + public byte casingDelay; /** * X @@ -226,6 +230,14 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple else this.lastRotationYaw -= Math.PI * 2; } + + if (usesCasings() && getCasingConfig().getDelay() > 0) + { + if (casingDelay > 0) + casingDelay--; + else + spawnCasing(); + } } } @@ -297,6 +309,8 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple } public abstract void updateFiringTick(); + public abstract boolean usesCasings(); + public abstract SpentCasingConfig getCasingConfig(); public BulletConfiguration getFirstConfigLoaded() { @@ -338,6 +352,14 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple proj.setThrowableHeading(vec.xCoord, vec.yCoord, vec.zCoord, bullet.velocity, bullet.spread); worldObj.spawnEntityInWorld(proj); + + if (usesCasings()) + { + if (getCasingConfig().getDelay() == 0) + spawnCasing(); + else + casingDelay = getCasingConfig().getDelay(); + } } public void conusmeAmmo(ComparableStack ammo) { @@ -821,4 +843,18 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple public void closeInventory() { this.worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "hbm:block.closeC", 1.0F, 1.0F); } + + protected void spawnCasing() + { + final NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "casing"); + data.setDouble("posX", xCoord); + data.setDouble("posY", yCoord + 0.5); + data.setDouble("posZ", zCoord); + data.setFloat("pitch", (float) rotationPitch); + data.setFloat("yaw", (float) rotationYaw); + data.setBoolean("crouched", false); + data.setString("name", getCasingConfig().getRegistryName()); + MainRegistry.proxy.effectNT(data); + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBrandon.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBrandon.java index d0598c8d5..4857d820a 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBrandon.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBrandon.java @@ -2,6 +2,8 @@ package com.hbm.tileentity.turret; import java.util.List; +import com.hbm.particle.SpentCasingConfig; + public class TileEntityTurretBrandon extends TileEntityTurretBaseNT { @Override @@ -28,4 +30,16 @@ public class TileEntityTurretBrandon extends TileEntityTurretBaseNT { return null; } + @Override + public boolean usesCasings() + { + return false; + } + + @Override + public SpentCasingConfig getCasingConfig() + { + return null; + } + } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretChekhov.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretChekhov.java index 80f5da180..05e23d4cf 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretChekhov.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretChekhov.java @@ -3,10 +3,12 @@ package com.hbm.tileentity.turret; import java.util.ArrayList; import java.util.List; -import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.guncfg.Gun50BMGFactory; +import com.hbm.lib.HbmCollection; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; +import com.hbm.particle.SpentCasingConfig; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.nbt.NBTTagCompound; @@ -14,21 +16,22 @@ import net.minecraft.util.Vec3; public class TileEntityTurretChekhov extends TileEntityTurretBaseNT { - static List configs = new ArrayList(); + static List configs = new ArrayList<>(); //because cramming it into the ArrayList's constructor with nested curly brackets and all that turned out to be not as pretty //also having a floaty `static` like this looks fun //idk if it's just me though static { - configs.add(BulletConfigSyncingUtil.BMG50_NORMAL); - configs.add(BulletConfigSyncingUtil.BMG50_INCENDIARY); - configs.add(BulletConfigSyncingUtil.BMG50_EXPLOSIVE); - configs.add(BulletConfigSyncingUtil.BMG50_AP); - configs.add(BulletConfigSyncingUtil.BMG50_DU); - configs.add(BulletConfigSyncingUtil.BMG50_STAR); - configs.add(BulletConfigSyncingUtil.BMG50_PHOSPHORUS); - configs.add(BulletConfigSyncingUtil.BMG50_SLEEK); - configs.add(BulletConfigSyncingUtil.CHL_BMG50); +// configs.add(BulletConfigSyncingUtil.BMG50_NORMAL); +// configs.add(BulletConfigSyncingUtil.BMG50_INCENDIARY); +// configs.add(BulletConfigSyncingUtil.BMG50_EXPLOSIVE); +// configs.add(BulletConfigSyncingUtil.BMG50_AP); +// configs.add(BulletConfigSyncingUtil.BMG50_DU); +// configs.add(BulletConfigSyncingUtil.BMG50_STAR); +// configs.add(BulletConfigSyncingUtil.BMG50_PHOSPHORUS); +// configs.add(BulletConfigSyncingUtil.BMG50_SLEEK); +// configs.add(BulletConfigSyncingUtil.CHL_BMG50); + configs.addAll(HbmCollection.fiftyBMG); } @Override @@ -142,4 +145,16 @@ public class TileEntityTurretChekhov extends TileEntityTurretBaseNT { manual = true; } + + @Override + public boolean usesCasings() + { + return true; + } + + @Override + public SpentCasingConfig getCasingConfig() + { + return Gun50BMGFactory.CONFIG_50BMG; + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretFriendly.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretFriendly.java index cadfc4c94..081cb1383 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretFriendly.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretFriendly.java @@ -4,10 +4,12 @@ import java.util.ArrayList; import java.util.List; import com.hbm.handler.BulletConfigSyncingUtil; +import com.hbm.handler.guncfg.Gun5mmFactory; +import com.hbm.particle.SpentCasingConfig; public class TileEntityTurretFriendly extends TileEntityTurretChekhov { - static List configs = new ArrayList(); + static List configs = new ArrayList<>(); static { configs.add(BulletConfigSyncingUtil.R5_NORMAL); @@ -31,4 +33,10 @@ public class TileEntityTurretFriendly extends TileEntityTurretChekhov { public int getDelay() { return 5; } + + @Override + public SpentCasingConfig getCasingConfig() + { + return Gun5mmFactory.CASING_5MM_TURRET; + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretFritz.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretFritz.java index f571c4c03..cd41c778d 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretFritz.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretFritz.java @@ -13,6 +13,7 @@ import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.items.ModItems; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; +import com.hbm.particle.SpentCasingConfig; import api.hbm.fluid.IFluidStandardReceiver; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; @@ -212,4 +213,16 @@ public class TileEntityTurretFritz extends TileEntityTurretBaseNT implements IFl public FluidTank[] getAllTanks() { return new FluidTank[] { tank }; } + + @Override + public boolean usesCasings() + { + return false; + } + + @Override + public SpentCasingConfig getCasingConfig() + { + return null; + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretHIMARS.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretHIMARS.java index 1bb2d49c9..9e052854d 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretHIMARS.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretHIMARS.java @@ -8,6 +8,7 @@ import com.hbm.inventory.gui.GUITurretHIMARS; import com.hbm.items.ModItems; import com.hbm.lib.Library; import com.hbm.main.MainRegistry; +import com.hbm.particle.SpentCasingConfig; import com.hbm.tileentity.IGUIProvider; import cpw.mods.fml.relauncher.Side; @@ -257,4 +258,16 @@ public class TileEntityTurretHIMARS extends TileEntityTurretBaseArtillery implem public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUITurretHIMARS(player.inventory, this); } + + @Override + public boolean usesCasings() + { + return false; + } + + @Override + public SpentCasingConfig getCasingConfig() + { + return null; + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretHoward.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretHoward.java index 94df68742..d9ab5ab64 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretHoward.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretHoward.java @@ -6,9 +6,11 @@ import java.util.List; import com.hbm.config.WeaponConfig; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.guncfg.GunDGKFactory; import com.hbm.lib.ModDamageSource; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; +import com.hbm.particle.SpentCasingConfig; import com.hbm.util.EntityDamageUtil; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; @@ -17,7 +19,7 @@ import net.minecraft.util.Vec3; public class TileEntityTurretHoward extends TileEntityTurretBaseNT { - static List configs = new ArrayList(); + static List configs = new ArrayList<>(); static { configs.add(BulletConfigSyncingUtil.DGK_NORMAL); @@ -159,6 +161,8 @@ public class TileEntityTurretHoward extends TileEntityTurretBaseNT { data.setByte("count", (byte)1); PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.xCoord + vec.xCoord + hOff.xCoord, pos.yCoord + vec.yCoord + hOff.yCoord, pos.zCoord + vec.zCoord + hOff.zCoord), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50)); } + + spawnCasing(); } } } @@ -174,4 +178,16 @@ public class TileEntityTurretHoward extends TileEntityTurretBaseNT { super.writeToNBT(nbt); nbt.setInteger("loaded", loaded); } + + @Override + public boolean usesCasings() + { + return true; + } + + @Override + public SpentCasingConfig getCasingConfig() + { + return GunDGKFactory.CASING_DGK; + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretJeremy.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretJeremy.java index 5e022996d..930e1be42 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretJeremy.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretJeremy.java @@ -4,9 +4,11 @@ import java.util.ArrayList; import java.util.List; import com.hbm.handler.BulletConfiguration; +import com.hbm.handler.guncfg.GunCannonFactory; import com.hbm.lib.HbmCollection; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; +import com.hbm.particle.SpentCasingConfig; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.nbt.NBTTagCompound; @@ -98,4 +100,16 @@ public class TileEntityTurretJeremy extends TileEntityTurretBaseNT { } } } + + @Override + public boolean usesCasings() + { + return true; + } + + @Override + public SpentCasingConfig getCasingConfig() + { + return GunCannonFactory.CASING_240; + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretMaxwell.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretMaxwell.java index 413a166ad..8a9175b0a 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretMaxwell.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretMaxwell.java @@ -7,6 +7,7 @@ import com.hbm.items.ModItems; import com.hbm.lib.ModDamageSource; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; +import com.hbm.particle.SpentCasingConfig; import com.hbm.potion.HbmPotion; import com.hbm.util.EntityDamageUtil; @@ -39,7 +40,7 @@ public class TileEntityTurretMaxwell extends TileEntityTurretBaseNT { if(ammoStacks != null) return ammoStacks; - ammoStacks = new ArrayList(); + ammoStacks = new ArrayList<>(); ammoStacks.add(new ItemStack(ModItems.upgrade_speed_1)); ammoStacks.add(new ItemStack(ModItems.upgrade_speed_2)); @@ -232,4 +233,16 @@ public class TileEntityTurretMaxwell extends TileEntityTurretBaseNT { else super.networkUnpack(nbt); } + + @Override + public boolean usesCasings() + { + return false; + } + + @Override + public SpentCasingConfig getCasingConfig() + { + return null; + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretRichard.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretRichard.java index 2750202d5..8cae81356 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretRichard.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretRichard.java @@ -7,6 +7,7 @@ import com.hbm.entity.projectile.EntityBulletBase; import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.handler.BulletConfiguration; import com.hbm.items.ItemAmmoEnums.AmmoRocket; +import com.hbm.particle.SpentCasingConfig; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; @@ -163,4 +164,16 @@ public class TileEntityTurretRichard extends TileEntityTurretBaseNT { super.writeToNBT(nbt); nbt.setInteger("loaded", this.loaded); } + + @Override + public boolean usesCasings() + { + return false; + } + + @Override + public SpentCasingConfig getCasingConfig() + { + return null; + } } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretTauon.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretTauon.java index d3d8d7f27..798f79653 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretTauon.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretTauon.java @@ -8,6 +8,7 @@ import com.hbm.handler.BulletConfiguration; import com.hbm.lib.ModDamageSource; import com.hbm.packet.AuxParticlePacketNT; import com.hbm.packet.PacketDispatcher; +import com.hbm.particle.SpentCasingConfig; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.nbt.NBTTagCompound; @@ -15,7 +16,7 @@ import net.minecraft.util.Vec3; public class TileEntityTurretTauon extends TileEntityTurretBaseNT { - static List configs = new ArrayList(); + static List configs = new ArrayList<>(); static { configs.add(BulletConfigSyncingUtil.SPECIAL_GAUSS); @@ -149,4 +150,16 @@ public class TileEntityTurretTauon extends TileEntityTurretBaseNT { else super.networkUnpack(nbt); } + + @Override + public boolean usesCasings() + { + return false; + } + + @Override + public SpentCasingConfig getCasingConfig() + { + return null; + } } diff --git a/src/main/java/com/hbm/util/Quaternion.java b/src/main/java/com/hbm/util/Quaternion.java new file mode 100644 index 000000000..21aa12ed9 --- /dev/null +++ b/src/main/java/com/hbm/util/Quaternion.java @@ -0,0 +1,302 @@ +package com.hbm.util; + +import java.io.Serializable; +import java.util.Objects; + +import com.hbm.interfaces.IByteSerializable; +import com.hbm.interfaces.INBTSerializable; +import com.hbm.main.DeserializationException; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Vec3; + +/** + * Credits to Apache for the basic structure. + * @author UFFR + * + */ +public class Quaternion implements Serializable, Cloneable, IByteSerializable, INBTSerializable +{ + /** + * + */ + private static final long serialVersionUID = -403051011515625947L; + private double w, x, y, z; + + public Quaternion(double pitch, double yaw) + { + final double rPitch = Math.toRadians(pitch), + rYaw = Math.toRadians(yaw), + + cp = Math.cos(rPitch * 0.5), + sp = Math.sin(rPitch * 0.5), + cy = Math.cos(rYaw * 0.5), + sy = Math.sin(rYaw * 0.5); + + w = cy * sp; + x = sy * cp; + y = sy * cp; + z = cy * cp; + } + + public Quaternion(double roll, double pitch, double yaw) + { + final double rRoll = Math.toRadians(roll), + rPitch = Math.toRadians(pitch), + rYaw = Math.toRadians(yaw), + + cr = Math.cos(rRoll * 0.5), + sr = Math.sin(rRoll * 0.5), + cp = Math.cos(rPitch * 0.5), + sp = Math.sin(rPitch * 0.5), + cy = Math.cos(rYaw * 0.5), + sy = Math.sin(rYaw * 0.5); + + w = cr * cp * cy + sr * sp * sy; + x = sr * cp * cy - cr * sp * sy; + y = cr * sp * cy + sr * cp * sy; + z = cr * cp * sy - sr * sp * cy; + + } + + public Quaternion(double w, double x, double y, double z) + { + this.w = w; + this.x = x; + this.y = y; + this.z = z; + } + + public Quaternion(double w, Vec3 vec3) + { + this.w = w; + + x = vec3.xCoord; + y = vec3.yCoord; + z = vec3.zCoord; + } + + public Quaternion(Vec3 vec3) + { + this(0, vec3); + } + + public Quaternion(double w, double[] vector) + { + if (vector.length != 3) + throw new IllegalArgumentException("Vector argument must only have 3 values!"); + + this.w = w; + + x = vector[0]; + y = vector[1]; + z = vector[2]; + } + + public Quaternion(double[] vector) + { + this(0, vector); + } + + public Quaternion getConjugate() + { + return new Quaternion(w, -x, -y, -z); + } + + public Quaternion add(Quaternion q) + { + return add(this, q); + } + + public Quaternion subtract(Quaternion q) + { + return subtract(this, q); + } + + public Quaternion multiply(Quaternion q) + { + return multiply(this, q); + } + + public Quaternion dotProduct(Quaternion q) + { + return dotProduct(this, q); + } + + public double getNorm() + { + return Math.sqrt(w * w + x * x + y * y + z * z); + } + + public Quaternion normalize() + { + final double norm = getNorm(); + if (norm < Double.MIN_NORMAL) + throw new ArithmeticException("Quaternion norm zero!"); + + return new Quaternion( + w / norm, + x / norm, + y / norm, + z / norm); + } + + public double getPitch() + { + return Math.atan2(2 * (y * z + w * x), w * w - x * x - y * y + z * z); + } + + public double getYaw() + { + return Math.asin(-2 * (x * z - w * y)); + } + + public double getRoll() + { + return Math.atan2(2 * (x * y + w * z), w * w + x * x - y * y - z * z); + } + + public static Quaternion add(Quaternion q1, Quaternion q2) + { + return new Quaternion(q1.w + q2.w, q1.x + q2.x, q1.y + q2.y, q1.z + q2.z); + } + + public static Quaternion subtract(Quaternion q1, Quaternion q2) + { + return new Quaternion(q1.w - q2.w, q1.x - q2.x, q1.y - q2.y, q1.z - q2.z); + } + + public static Quaternion multiply(Quaternion q1, Quaternion q2) + { + return new Quaternion( + q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z, + q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y, + q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z * q2.x, + q1.w * q2.z + q1.x * q2.y - q1.y * q2.x + q1.z * q2.w + ); + } + + public static Quaternion dotProduct(Quaternion q1, Quaternion q2) + { + return new Quaternion(q1.w * q2.w, q1.x * q2.x, q1.y * q2.y, q1.z * q2.z); + } + + public static Vec3 rotate(Quaternion q, Vec3 vec3) + { + return q.multiply(new Quaternion(vec3)).multiply(q.getConjugate()).getVector(); + } + + public static Vec3 rotate(Quaternion q, Vec3 vec3, Vec3 origin) + { + return q.multiply(new Quaternion(vec3.subtract(origin))).multiply(q.getConjugate()).getVector().addVector(origin.xCoord, origin.yCoord, origin.zCoord); + } + + public double getW() + { + return w; + } + + public double getX() + { + return x; + } + + public double getY() + { + return y; + } + + public double getZ() + { + return z; + } + + public Vec3 getVector() + { + return Vec3.createVectorHelper(x, y, z); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + nbt.setDouble("w", w); + nbt.setDouble("x", x); + nbt.setDouble("y", y); + nbt.setDouble("z", z); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + w = nbt.getDouble("w"); + x = nbt.getDouble("x"); + y = nbt.getDouble("y"); + z = nbt.getDouble("z"); + } + + @Override + public void writeToBytes(ByteBuf buf) + { + buf.writeDouble(w).writeDouble(x).writeDouble(y).writeDouble(z); + } + + @Override + public void readFromBytes(byte[] bytes) throws DeserializationException + { + try + { + final ByteBuf buf = Unpooled.copiedBuffer(bytes); + w = buf.readDouble(); + x = buf.readDouble(); + y = buf.readDouble(); + z = buf.readDouble(); + } catch (Exception e) + { + throw new DeserializationException(e); + } + } + + @Override + public int hashCode() + { + return Objects.hash(w, x, y, z); + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (!(obj instanceof Quaternion)) + return false; + final Quaternion other = (Quaternion) obj; + return Double.doubleToLongBits(w) == Double.doubleToLongBits(other.w) + && Double.doubleToLongBits(x) == Double.doubleToLongBits(other.x) + && Double.doubleToLongBits(y) == Double.doubleToLongBits(other.y) + && Double.doubleToLongBits(z) == Double.doubleToLongBits(other.z); + } + + @Override + public String toString() + { + final StringBuilder builder = new StringBuilder(); + builder.append("Quaternion [w=").append(w).append(", x=").append(x).append(", y=").append(y).append(", z=") + .append(z).append(']'); + return builder.toString(); + } + + @Override + public Quaternion clone() + { + try + { + return (Quaternion) super.clone(); + } catch (CloneNotSupportedException e) + { + return new Quaternion(w, x, y, z); + } + } + +} diff --git a/src/main/resources/assets/hbm/models/effect/casings.mtl b/src/main/resources/assets/hbm/models/effect/casings.mtl new file mode 100644 index 000000000..9870c10af --- /dev/null +++ b/src/main/resources/assets/hbm/models/effect/casings.mtl @@ -0,0 +1,13 @@ +# Blender MTL File: 'casings.blend' +# Material Count: 1 + +newmtl None +Ns 500.000001 +Ka 1.000000 1.000000 1.000000 +Kd 0.800000 0.800000 0.800000 +Ks 0.800000 0.800000 0.800000 +Ke 0.000000 0.000000 0.000000 +Ni 1.450000 +d 1.000000 +illum 2 +map_Kd /home/justin/eclipse-workspace/Hbm-s-Nuclear-Tech-GIT/src/main/resources/assets/hbm/textures/particle/casing_tex.png diff --git a/src/main/resources/assets/hbm/models/effect/casings.obj b/src/main/resources/assets/hbm/models/effect/casings.obj new file mode 100644 index 000000000..aafd7bc83 --- /dev/null +++ b/src/main/resources/assets/hbm/models/effect/casings.obj @@ -0,0 +1,965 @@ +# Blender v3.0.1 OBJ File: 'casings.blend' +# www.blender.org +mtllib casings.mtl +o AR2_Cylinder.001 +v 0.000000 0.360000 -1.200000 +v 0.000000 0.360000 -0.400000 +v 0.254558 0.254558 -1.200000 +v 0.254558 0.254558 -0.400000 +v 0.360000 0.000000 -1.200000 +v 0.360000 -0.000000 -0.400000 +v 0.254558 -0.254558 -1.200000 +v 0.254558 -0.254558 -0.400000 +v -0.000000 -0.360000 -1.200000 +v -0.000000 -0.360000 -0.400000 +v -0.254558 -0.254558 -1.200000 +v -0.254558 -0.254559 -0.400000 +v -0.360000 0.000000 -1.200000 +v -0.360000 -0.000000 -0.400000 +v -0.254559 0.254558 -1.200000 +v -0.254559 0.254558 -0.400000 +v 0.000000 0.600000 -0.400000 +v 0.000000 0.600000 0.000000 +v 0.424264 0.424264 -0.400000 +v 0.424264 0.424264 0.000000 +v 0.600000 -0.000000 -0.400000 +v 0.600000 -0.000000 0.000000 +v 0.424264 -0.424264 -0.400000 +v 0.424264 -0.424264 0.000000 +v -0.000000 -0.600000 -0.400000 +v -0.000000 -0.600000 0.000000 +v -0.424264 -0.424264 -0.400000 +v -0.424264 -0.424264 0.000000 +v -0.600000 0.000000 -0.400000 +v -0.600000 0.000000 0.000000 +v -0.424264 0.424264 -0.400000 +v -0.424264 0.424264 0.000000 +vt 0.162500 0.566875 +vt 0.146875 0.504375 +vt 0.162500 0.504375 +vt 0.146875 0.566875 +vt 0.131250 0.504375 +vt 0.131250 0.566875 +vt 0.115625 0.504375 +vt 0.115625 0.566875 +vt 0.100000 0.504375 +vt 0.100000 0.566875 +vt 0.084375 0.504375 +vt 0.084375 0.566875 +vt 0.068750 0.504375 +vt 0.101250 0.599125 +vt 0.002250 0.500125 +vt 0.101250 0.401125 +vt 0.068750 0.566875 +vt 0.053125 0.504375 +vt 0.053125 0.566875 +vt 0.037500 0.504375 +vt 0.171253 0.570129 +vt 0.171253 0.430121 +vt 0.031246 0.430122 +vt 0.162500 0.566875 +vt 0.146875 0.504375 +vt 0.162500 0.504375 +vt 0.146875 0.566875 +vt 0.131250 0.504375 +vt 0.131250 0.566875 +vt 0.115625 0.504375 +vt 0.115625 0.566875 +vt 0.100000 0.504375 +vt 0.100000 0.566875 +vt 0.084375 0.504375 +vt 0.084375 0.566875 +vt 0.068750 0.504375 +vt 0.171253 0.430121 +vt 0.200250 0.500125 +vt 0.002250 0.500125 +vt 0.068750 0.566875 +vt 0.053125 0.504375 +vt 0.053125 0.566875 +vt 0.037500 0.504375 +vt 0.171253 0.430121 +vt 0.031246 0.430122 +vt 0.031246 0.570129 +vt 0.200250 0.500125 +vt 0.171253 0.570129 +vt 0.031246 0.570129 +vt 0.031246 0.430122 +vt 0.171253 0.430121 +vt 0.037500 0.566875 +vt 0.031246 0.570129 +vt 0.101250 0.599125 +vt 0.200250 0.500125 +vt 0.101250 0.401125 +vt 0.002250 0.500125 +vt 0.171253 0.570129 +vt 0.101250 0.599125 +vt 0.031246 0.570129 +vt 0.031246 0.430122 +vt 0.101250 0.401125 +vt 0.037500 0.566875 +vt 0.101250 0.599125 +vt 0.171253 0.570129 +vt 0.200250 0.500125 +vt 0.101250 0.401125 +vt 0.002250 0.500125 +vn 0.3827 0.9239 0.0000 +vn 0.9239 0.3827 0.0000 +vn 0.9239 -0.3827 -0.0000 +vn 0.3827 -0.9239 -0.0000 +vn -0.3827 -0.9239 0.0000 +vn -0.9239 -0.3827 -0.0000 +vn 0.0000 -0.0000 1.0000 +vn -0.9239 0.3827 0.0000 +vn -0.3827 0.9239 0.0000 +vn -0.0000 0.0000 -1.0000 +usemtl None +s off +f 2/1/1 3/2/1 1/3/1 +f 4/4/2 5/5/2 3/2/2 +f 6/6/3 7/7/3 5/5/3 +f 8/8/4 9/9/4 7/7/4 +f 10/10/5 11/11/5 9/9/5 +f 12/12/6 13/13/6 11/11/6 +f 2/14/7 14/15/7 10/16/7 +f 14/17/8 15/18/8 13/13/8 +f 16/19/9 1/20/9 15/18/9 +f 3/21/10 7/22/10 11/23/10 +f 18/24/1 19/25/1 17/26/1 +f 20/27/2 21/28/2 19/25/2 +f 22/29/3 23/30/3 21/28/3 +f 24/31/4 25/32/4 23/30/4 +f 26/33/5 27/34/5 25/32/5 +f 28/35/6 29/36/6 27/34/6 +f 24/37/7 22/38/7 30/39/7 +f 30/40/8 31/41/8 29/36/8 +f 32/42/9 17/43/9 31/41/9 +f 23/44/10 27/45/10 31/46/10 +f 2/1/1 4/4/1 3/2/1 +f 4/4/2 6/6/2 5/5/2 +f 6/6/3 8/8/3 7/7/3 +f 8/8/4 10/10/4 9/9/4 +f 10/10/5 12/12/5 11/11/5 +f 12/12/6 14/17/6 13/13/6 +f 6/47/7 4/48/7 2/14/7 +f 2/14/7 16/49/7 14/15/7 +f 14/15/7 12/50/7 10/16/7 +f 10/16/7 8/51/7 6/47/7 +f 6/47/7 2/14/7 10/16/7 +f 14/17/8 16/19/8 15/18/8 +f 16/19/9 2/52/9 1/20/9 +f 15/53/10 1/54/10 3/21/10 +f 3/21/10 5/55/10 7/22/10 +f 7/22/10 9/56/10 11/23/10 +f 11/23/10 13/57/10 15/53/10 +f 15/53/10 3/21/10 11/23/10 +f 18/24/1 20/27/1 19/25/1 +f 20/27/2 22/29/2 21/28/2 +f 22/29/3 24/31/3 23/30/3 +f 24/31/4 26/33/4 25/32/4 +f 26/33/5 28/35/5 27/34/5 +f 28/35/6 30/40/6 29/36/6 +f 22/38/7 20/58/7 18/59/7 +f 18/59/7 32/60/7 22/38/7 +f 32/60/7 30/39/7 22/38/7 +f 30/39/7 28/61/7 26/62/7 +f 26/62/7 24/37/7 30/39/7 +f 30/40/8 32/42/8 31/41/8 +f 32/42/9 18/63/9 17/43/9 +f 31/46/10 17/64/10 19/65/10 +f 19/65/10 21/66/10 23/44/10 +f 23/44/10 25/67/10 27/45/10 +f 27/45/10 29/68/10 31/46/10 +f 31/46/10 19/65/10 23/44/10 +o Shotgun_Shell_Cylinder.002 +v -0.317579 0.317579 1.112764 +v 0.000000 0.449124 -1.223040 +v -0.317579 0.317579 -1.223040 +v 0.449124 -0.000000 1.112764 +v 0.317579 -0.317578 -1.223040 +v 0.449124 -0.000000 -1.223040 +v 0.317579 -0.317578 1.112764 +v 0.000000 -0.449123 -1.223040 +v 0.000000 -0.449124 1.112764 +v -0.317579 -0.317578 -1.223040 +v -0.317579 -0.317578 1.112764 +v -0.449124 -0.000000 -1.223040 +v -0.449124 -0.000000 1.112764 +v 0.000000 0.449124 1.112764 +v 0.317579 0.317579 -1.223040 +v 0.317579 0.317579 1.112764 +v 0.353356 0.353357 1.148335 +v 0.499721 -0.000000 1.148335 +v 0.353356 -0.353356 1.148335 +v 0.000000 -0.499721 1.148335 +v -0.353356 -0.353356 1.148335 +v -0.499721 -0.000000 1.148335 +v -0.353356 0.353357 1.148335 +v 0.000000 0.499721 1.148335 +vt 0.468081 0.764346 +vt 0.489255 0.933910 +vt 0.468081 0.933910 +vt 0.395789 0.764346 +vt 0.416963 0.933910 +vt 0.395789 0.933910 +vt 0.293553 0.764346 +vt 0.323497 0.933910 +vt 0.293553 0.933910 +vt 0.323497 0.764346 +vt 0.344671 0.933910 +vt 0.416963 0.764346 +vt 0.438137 0.933910 +vt 0.416963 0.933910 +vt 0.438137 0.764346 +vt 0.344671 0.764346 +vt 0.365845 0.933910 +vt 0.344671 0.933910 +vt 0.365845 0.764346 +vt 0.175844 0.775274 +vt 0.144213 0.779346 +vt 0.145900 0.775274 +vt 0.120654 0.755786 +vt 0.124726 0.754100 +vt 0.124726 0.724156 +vt 0.120654 0.722469 +vt 0.145900 0.702982 +vt 0.144213 0.698910 +vt 0.177531 0.698910 +vt 0.175844 0.702982 +vt 0.201090 0.722469 +vt 0.197018 0.724155 +vt 0.197018 0.754100 +vt 0.201090 0.755787 +vt 0.177531 0.779346 +vt 0.489255 0.764346 +vt 0.416963 0.764346 +vt 0.344671 0.764346 +vt 0.960365 0.912783 +vt 0.858129 0.955131 +vt 0.815781 0.852895 +vt 0.067942 0.886801 +vt 0.086790 0.867953 +vt 0.113444 0.867953 +vt 0.918017 0.810547 +vt 0.960365 0.852895 +vt 0.918017 0.955131 +vt 0.815781 0.912784 +vt 0.858128 0.810547 +vt 0.132291 0.886801 +vt 0.132291 0.913455 +vt 0.113444 0.932302 +vt 0.086790 0.932302 +vt 0.067942 0.913455 +vn -0.3827 0.9239 0.0000 +vn 0.9239 -0.3827 -0.0000 +vn 0.3827 -0.9239 -0.0000 +vn -0.3827 -0.9239 -0.0000 +vn -0.9239 -0.3827 -0.0000 +vn -0.9239 0.3827 0.0000 +vn 0.3827 0.9239 0.0000 +vn 0.9239 0.3827 0.0000 +vn 0.2317 0.5595 -0.7958 +vn 0.5595 0.2317 -0.7958 +vn 0.5595 -0.2317 -0.7958 +vn 0.2317 -0.5595 -0.7958 +vn -0.2317 -0.5595 -0.7958 +vn -0.5595 -0.2317 -0.7958 +vn -0.5595 0.2317 -0.7958 +vn -0.2317 0.5595 -0.7958 +vn -0.0000 0.0000 -1.0000 +vn 0.0000 0.0000 1.0000 +usemtl None +s 1 +f 33/69/11 34/70/11 35/71/11 +f 36/72/12 37/73/12 38/74/12 +f 39/75/13 40/76/13 37/77/13 +f 41/78/14 42/79/14 40/76/14 +f 43/80/15 44/81/15 42/82/15 +f 45/83/16 35/71/16 44/81/16 +f 46/84/17 47/85/17 34/86/17 +f 48/87/18 38/74/18 47/85/18 +f 46/88/19 49/89/19 48/90/19 +f 48/90/20 50/91/20 36/92/20 +f 39/93/21 50/91/21 51/94/21 +f 41/95/22 51/94/22 52/96/22 +f 41/95/23 53/97/23 43/98/23 +f 43/98/24 54/99/24 45/100/24 +f 33/101/25 54/99/25 55/102/25 +f 46/88/26 55/102/26 56/103/26 +f 33/69/11 46/104/11 34/70/11 +f 36/72/12 39/105/12 37/73/12 +f 39/75/13 41/78/13 40/76/13 +f 41/78/14 43/106/14 42/79/14 +f 43/80/15 45/83/15 44/81/15 +f 45/83/16 33/69/16 35/71/16 +f 46/84/17 48/87/17 47/85/17 +f 48/87/18 36/72/18 38/74/18 +f 34/107/27 38/108/27 40/109/27 +f 46/88/19 56/103/19 49/89/19 +f 48/90/20 49/89/20 50/91/20 +f 39/93/21 36/92/21 50/91/21 +f 41/95/22 39/93/22 51/94/22 +f 41/95/23 52/96/23 53/97/23 +f 43/98/24 53/97/24 54/99/24 +f 33/101/25 45/100/25 54/99/25 +f 46/88/26 33/101/26 55/102/26 +f 53/110/28 52/111/28 51/112/28 +f 44/113/27 35/114/27 34/107/27 +f 34/107/27 47/115/27 38/108/27 +f 38/108/27 37/116/27 40/109/27 +f 40/109/27 42/117/27 44/113/27 +f 44/113/27 34/107/27 40/109/27 +f 51/112/28 50/118/28 49/119/28 +f 49/119/28 56/120/28 51/112/28 +f 56/120/28 55/121/28 51/112/28 +f 55/121/28 54/122/28 51/112/28 +f 54/122/28 53/110/28 51/112/28 +o Brass_Straight_Casing +v 0.300002 -0.000003 0.685047 +v 0.185616 0.185613 0.685047 +v -0.000000 -0.262503 0.735047 +v 0.300002 -0.000001 0.785047 +v -0.212132 -0.212133 0.685047 +v -0.185614 -0.185617 0.685047 +v -0.212132 0.212131 0.685047 +v -0.000000 0.262499 0.685047 +v -0.000000 0.299999 0.685047 +v 0.212132 0.212131 0.685047 +v 0.212132 -0.212133 0.685047 +v 0.185616 -0.185617 0.685047 +v 0.300002 -0.000003 0.735047 +v -0.000000 0.299999 0.735047 +v -0.212132 0.212131 0.735047 +v -0.185614 0.185613 0.735047 +v -0.185614 -0.185617 0.735047 +v 0.185616 -0.185617 0.735047 +v 0.185616 0.185613 0.735047 +v 0.212132 -0.212133 0.785047 +v -0.300000 -0.000001 0.785047 +v -0.212132 0.212131 0.785047 +v -0.212132 -0.212133 0.785047 +v -0.212132 -0.212133 -0.814953 +v 0.300002 -0.000003 -0.814953 +v 0.212132 0.212131 -0.814953 +v -0.000000 0.299999 -0.814953 +v 0.212132 -0.212133 -0.814953 +v -0.000000 -0.300001 -0.814953 +v -0.000000 -0.300001 0.685047 +v -0.300000 -0.000003 -0.814953 +v -0.300000 -0.000003 0.685047 +v -0.212132 0.212131 -0.814953 +v -0.212132 -0.212133 0.735047 +v -0.000000 -0.300001 0.785047 +v 0.212132 -0.212133 0.735047 +v 0.212132 0.212131 0.785047 +v 0.212132 0.212131 0.735047 +v -0.000000 0.299999 0.785047 +v -0.300000 -0.000003 0.735047 +v -0.000000 -0.300001 0.735047 +v -0.000000 -0.262503 0.685047 +v 0.262502 -0.000003 0.735047 +v 0.262502 -0.000003 0.685047 +v -0.000000 0.262499 0.735047 +v -0.185614 0.185613 0.685047 +v -0.262500 -0.000003 0.735047 +v -0.262500 -0.000003 0.685047 +vt 0.555701 0.706657 +vt 0.559782 0.681299 +vt 0.559782 0.704967 +vt 0.374299 0.628133 +vt 0.353483 0.613088 +vt 0.355173 0.609007 +vt 0.621002 0.706657 +vt 0.600185 0.721702 +vt 0.616920 0.704966 +vt 0.601875 0.660482 +vt 0.576517 0.664564 +vt 0.574827 0.660482 +vt 0.555701 0.679609 +vt 0.574827 0.725783 +vt 0.576518 0.721702 +vt 0.616920 0.681299 +vt 0.621002 0.679609 +vt 0.601876 0.725783 +vt 0.600185 0.664564 +vt 0.328125 0.609007 +vt 0.313080 0.629823 +vt 0.308998 0.628133 +vt 0.308998 0.655181 +vt 0.329815 0.670226 +vt 0.328124 0.674308 +vt 0.355173 0.674308 +vt 0.353482 0.670226 +vt 0.370218 0.653491 +vt 0.370218 0.629824 +vt 0.329815 0.613088 +vt 0.313080 0.653491 +vt 0.374299 0.655181 +vt 0.555701 0.614308 +vt 0.378998 0.641356 +vt 0.378998 0.614308 +vt 0.378998 0.725783 +vt 0.555701 0.752832 +vt 0.378998 0.752832 +vt 0.555701 0.725783 +vt 0.378998 0.706657 +vt 0.555701 0.706657 +vt 0.555701 0.660482 +vt 0.378998 0.660482 +vt 0.378998 0.679609 +vt 0.555701 0.660482 +vt 0.555701 0.679609 +vt 0.555701 0.706657 +vt 0.378998 0.706657 +vt 0.555701 0.799007 +vt 0.378998 0.771958 +vt 0.555701 0.771958 +vt 0.834098 0.918854 +vt 0.872350 0.826504 +vt 0.964699 0.864757 +vt 0.555701 0.641356 +vt 0.378998 0.660482 +vt 0.378998 0.799007 +vt 0.964699 0.918854 +vt 0.926447 0.957106 +vt 0.872350 0.957106 +vt 0.834098 0.864757 +vt 0.926448 0.826504 +vt 0.078463 0.847672 +vt 0.152342 0.878274 +vt 0.121740 0.952153 +vt 0.578726 0.628418 +vt 0.559600 0.622528 +vt 0.578726 0.622528 +vt 0.559600 0.622528 +vt 0.578726 0.616637 +vt 0.578726 0.622528 +vt 0.605775 0.628418 +vt 0.586649 0.634308 +vt 0.586649 0.628418 +vt 0.605775 0.616637 +vt 0.578726 0.610747 +vt 0.605775 0.610747 +vt 0.605775 0.628418 +vt 0.605775 0.622528 +vt 0.605775 0.616637 +vt 0.605775 0.622528 +vt 0.559600 0.634308 +vt 0.559600 0.628418 +vt 0.578726 0.616637 +vt 0.559600 0.610747 +vt 0.572436 0.725783 +vt 0.596104 0.731673 +vt 0.572436 0.731673 +vt 0.600003 0.604857 +vt 0.616739 0.610747 +vt 0.600003 0.610747 +vt 0.555701 0.725783 +vt 0.555701 0.731673 +vt 0.583268 0.610747 +vt 0.559600 0.604857 +vt 0.583268 0.604857 +vt 0.600003 0.610747 +vt 0.600003 0.604857 +vt 0.622437 0.634308 +vt 0.646104 0.640198 +vt 0.622437 0.640198 +vt 0.605701 0.634308 +vt 0.605701 0.640198 +vt 0.616739 0.604857 +vt 0.640406 0.610747 +vt 0.559600 0.628418 +vt 0.559600 0.616637 +vt 0.605775 0.634308 +vt 0.559600 0.616637 +vt 0.596104 0.725783 +vt 0.559600 0.610747 +vt 0.646104 0.634308 +vt 0.640406 0.604857 +vt 0.078463 0.952153 +vt 0.047861 0.921551 +vt 0.047861 0.878274 +vt 0.121740 0.847672 +vt 0.152342 0.921551 +vn 0.0000 0.0000 1.0000 +vn 0.0000 0.0000 -1.0000 +vn -0.9239 -0.3827 -0.0000 +vn -0.3827 0.9239 0.0000 +vn -0.9239 0.3827 0.0000 +vn -0.3827 -0.9239 -0.0000 +vn 0.9239 -0.3827 -0.0000 +vn 0.3827 -0.9239 -0.0000 +vn 0.9239 0.3827 0.0000 +vn 0.3827 0.9239 0.0000 +vn 0.5490 -0.5490 0.6303 +vn 0.5490 0.5490 0.6303 +vn -0.5490 0.5490 0.6303 +vn -0.7071 -0.7071 0.0000 +vn -0.0000 -0.7764 0.6303 +vn -0.5490 -0.5490 0.6303 +vn 1.0000 -0.0000 -0.0000 +vn 0.7071 -0.7071 0.0000 +vn 0.0000 1.0000 0.0000 +vn 0.7071 0.7071 -0.0000 +vn 0.0000 0.7764 0.6303 +vn -1.0000 -0.0000 -0.0000 +vn -0.7764 0.0000 0.6303 +vn 0.0000 -1.0000 0.0000 +vn 0.7764 0.0000 0.6303 +vn -0.7071 0.7071 -0.0000 +usemtl None +s off +f 57/123/29 58/124/29 100/125/29 +f 90/126/30 59/127/30 97/128/30 +f 61/129/29 98/130/29 62/131/29 +f 63/132/29 64/133/29 65/134/29 +f 66/135/29 64/133/29 58/124/29 +f 67/136/29 100/125/29 68/137/29 +f 61/129/29 104/138/29 88/139/29 +f 67/136/29 98/130/29 86/140/29 +f 88/139/29 102/141/29 63/132/29 +f 92/142/30 99/143/30 69/144/30 +f 94/145/30 101/146/30 70/147/30 +f 71/148/30 101/146/30 72/149/30 +f 90/126/30 103/150/30 73/151/30 +f 92/142/30 59/127/30 74/152/30 +f 69/144/30 75/153/30 94/145/30 +f 96/154/30 72/149/30 103/150/30 +f 57/123/29 66/135/29 58/124/29 +f 90/126/30 73/151/30 59/127/30 +f 61/129/29 86/140/29 98/130/29 +f 63/132/29 102/141/29 64/133/29 +f 66/135/29 65/134/29 64/133/29 +f 67/136/29 57/123/29 100/125/29 +f 61/129/29 62/131/29 104/138/29 +f 67/136/29 68/137/29 98/130/29 +f 88/139/29 104/138/29 102/141/29 +f 92/142/30 74/152/30 99/143/30 +f 94/145/30 75/153/30 101/146/30 +f 71/148/30 70/147/30 101/146/30 +f 90/126/30 96/154/30 103/150/30 +f 92/142/30 97/128/30 59/127/30 +f 69/144/30 99/143/30 75/153/30 +f 96/154/30 71/148/30 72/149/30 +f 87/155/31 61/156/31 88/157/31 +f 89/158/32 65/159/32 83/160/32 +f 63/161/33 87/162/33 88/163/33 +f 61/156/34 85/164/34 86/165/34 +f 84/166/35 57/167/35 67/168/35 +f 84/166/36 86/169/36 85/170/36 +f 57/171/37 82/172/37 66/173/37 +f 83/160/38 66/173/38 82/172/38 +f 89/174/30 82/175/30 84/176/30 +f 87/155/31 80/177/31 61/156/31 +f 89/158/32 63/161/32 65/159/32 +f 63/161/33 89/158/33 87/162/33 +f 61/156/34 80/177/34 85/164/34 +f 84/166/35 81/178/35 57/167/35 +f 84/166/36 67/168/36 86/169/36 +f 57/171/37 81/179/37 82/172/37 +f 83/160/38 65/159/38 66/173/38 +f 84/176/30 85/180/30 80/181/30 +f 80/181/30 87/182/30 89/174/30 +f 89/174/30 83/183/30 82/175/30 +f 82/175/30 81/184/30 84/176/30 +f 84/176/30 80/181/30 89/174/30 +s 1 +f 76/185/39 93/186/40 78/187/41 +f 90/188/42 91/189/43 79/190/44 +f 69/191/45 76/192/39 92/193/46 +f 70/194/47 93/195/40 94/196/48 +f 70/197/47 78/198/41 95/199/49 +f 96/200/50 79/190/44 77/201/51 +f 92/193/46 91/202/43 97/203/52 +f 94/196/48 60/204/53 69/205/45 +f 71/206/54 77/207/51 78/198/41 +f 74/208/46 98/209/52 68/210/46 +f 59/211/52 62/212/42 98/213/52 +f 99/214/45 68/210/46 100/215/45 +f 75/216/48 100/217/45 58/218/48 +f 101/219/47 58/218/48 64/220/47 +f 72/221/54 64/222/47 102/223/54 +f 103/224/50 102/223/54 104/225/50 +f 73/226/42 104/227/50 62/212/42 +f 90/188/42 97/228/52 91/189/43 +f 69/191/45 60/229/53 76/192/39 +f 70/194/47 95/230/49 93/195/40 +f 70/197/47 71/206/54 78/198/41 +f 96/200/50 90/188/42 79/190/44 +f 92/193/46 76/192/39 91/202/43 +f 94/196/48 93/195/40 60/204/53 +f 71/206/54 96/231/50 77/207/51 +f 74/208/46 59/232/52 98/209/52 +f 59/211/52 73/226/42 62/212/42 +f 99/214/45 74/208/46 68/210/46 +f 75/216/48 99/233/45 100/217/45 +f 101/219/47 75/216/48 58/218/48 +f 72/221/54 101/234/47 64/222/47 +f 103/224/50 72/221/54 102/223/54 +f 73/226/42 103/235/50 104/227/50 +f 78/187/41 77/236/51 79/237/44 +f 79/237/44 91/238/43 76/185/39 +f 76/185/39 60/239/53 93/186/40 +f 93/186/40 95/240/49 78/187/41 +f 78/187/41 79/237/44 76/185/39 +o Brass_Bottleneck_Casing.002 +v 0.300002 -0.000003 0.685047 +v 0.185616 0.185613 0.685047 +v -0.000000 -0.262503 0.735047 +v 0.300002 -0.000001 0.785047 +v -0.212132 -0.212133 0.685047 +v -0.185614 -0.185617 0.685047 +v -0.212132 0.212131 0.685047 +v -0.000000 0.262499 0.685047 +v -0.000000 0.299999 0.685047 +v 0.212132 0.212131 0.685047 +v 0.212132 -0.212133 0.685047 +v 0.185616 -0.185617 0.685047 +v 0.300002 -0.000003 0.735047 +v -0.000000 0.299999 0.735047 +v -0.212132 0.212131 0.735047 +v -0.185614 0.185613 0.735047 +v -0.185614 -0.185617 0.735047 +v 0.185616 -0.185617 0.735047 +v 0.185616 0.185613 0.735047 +v 0.212132 -0.212133 0.785047 +v -0.300000 -0.000001 0.785047 +v -0.212132 0.212131 0.785047 +v -0.212132 -0.212133 0.785047 +v -0.000000 -0.300001 0.685047 +v -0.300000 -0.000003 0.685047 +v -0.212132 -0.212133 0.735047 +v -0.000000 -0.300001 0.785047 +v 0.212132 -0.212133 0.735047 +v 0.212132 0.212131 0.785047 +v 0.212132 0.212131 0.735047 +v -0.000000 0.299999 0.785047 +v -0.300000 -0.000003 0.735047 +v -0.000000 -0.300001 0.735047 +v -0.000000 -0.262503 0.685047 +v 0.262502 -0.000003 0.735047 +v 0.262502 -0.000003 0.685047 +v -0.000000 0.262499 0.735047 +v -0.185614 0.185613 0.685047 +v -0.262500 -0.000003 0.735047 +v -0.262500 -0.000003 0.685047 +v -0.135596 -0.135597 -0.764953 +v -0.212132 -0.212133 -0.414953 +v 0.191762 -0.000003 -0.764953 +v 0.300002 -0.000003 -0.414953 +v 0.212132 0.212131 -0.414953 +v 0.135595 0.135594 -0.764953 +v -0.000000 0.299999 -0.414953 +v -0.000000 0.191760 -0.764953 +v 0.135596 -0.135596 -0.764953 +v 0.212132 -0.212133 -0.414953 +v -0.000000 -0.191762 -0.764953 +v -0.000000 -0.300001 -0.414953 +v -0.191761 -0.000003 -0.764953 +v -0.300000 -0.000003 -0.414953 +v -0.212132 0.212131 -0.414953 +v -0.135595 0.135594 -0.764953 +v -0.000000 -0.191762 -1.014953 +v 0.135596 -0.135596 -1.014953 +v -0.135595 0.135594 -1.014953 +v -0.191761 -0.000003 -1.014953 +v -0.000000 0.191760 -1.014953 +v 0.135595 0.135594 -1.014953 +v -0.135596 -0.135597 -1.014953 +v 0.191762 -0.000003 -1.014953 +vt 0.630972 0.689316 +vt 0.635004 0.664263 +vt 0.635004 0.687646 +vt 0.760004 0.662592 +vt 0.739438 0.647728 +vt 0.741108 0.643696 +vt 0.695488 0.689316 +vt 0.674922 0.704180 +vt 0.691456 0.687645 +vt 0.676592 0.643696 +vt 0.651539 0.647728 +vt 0.649868 0.643696 +vt 0.630972 0.662592 +vt 0.649869 0.708212 +vt 0.651539 0.704180 +vt 0.691456 0.664263 +vt 0.695488 0.662592 +vt 0.676592 0.708212 +vt 0.674922 0.647728 +vt 0.714385 0.643696 +vt 0.699521 0.664262 +vt 0.695488 0.662592 +vt 0.695488 0.689316 +vt 0.716055 0.704180 +vt 0.714385 0.708212 +vt 0.741108 0.708212 +vt 0.739438 0.704180 +vt 0.755972 0.687645 +vt 0.755972 0.664262 +vt 0.716055 0.647728 +vt 0.699521 0.687645 +vt 0.760005 0.689316 +vt 0.565094 0.763968 +vt 0.437169 0.737244 +vt 0.565094 0.737244 +vt 0.395530 0.665471 +vt 0.366932 0.677549 +vt 0.366456 0.665471 +vt 0.436423 0.653832 +vt 0.565094 0.672728 +vt 0.437169 0.672728 +vt 0.436423 0.718348 +vt 0.565094 0.699452 +vt 0.564349 0.718348 +vt 0.436423 0.718348 +vt 0.565094 0.627109 +vt 0.436423 0.608212 +vt 0.564349 0.608212 +vt 0.436423 0.782864 +vt 0.564348 0.782864 +vt 0.437168 0.627109 +vt 0.565094 0.653832 +vt 0.437168 0.653832 +vt 0.396006 0.677549 +vt 0.396006 0.631929 +vt 0.395530 0.619851 +vt 0.396006 0.649011 +vt 0.395530 0.729986 +vt 0.396006 0.742065 +vt 0.437169 0.699452 +vt 0.396006 0.694631 +vt 0.396006 0.759147 +vt 0.437169 0.763968 +vt 0.818608 0.930835 +vt 0.866923 0.814195 +vt 0.983563 0.862509 +vt 0.366456 0.729986 +vt 0.395530 0.706709 +vt 0.366932 0.694631 +vt 0.395530 0.771225 +vt 0.366932 0.759147 +vt 0.366932 0.742065 +vt 0.366932 0.631929 +vt 0.366456 0.619851 +vt 0.564349 0.653832 +vt 0.564349 0.718348 +vt 0.983563 0.930836 +vt 0.935248 0.979150 +vt 0.866923 0.979150 +vt 0.818608 0.862509 +vt 0.935250 0.814194 +vt 0.366456 0.706709 +vt 0.366456 0.771225 +vt 0.366932 0.649011 +vt 0.078761 0.848420 +vt 0.151753 0.878654 +vt 0.121519 0.951645 +vt 0.714385 0.637881 +vt 0.741108 0.643696 +vt 0.714385 0.643696 +vt 0.585352 0.637881 +vt 0.566456 0.642951 +vt 0.566456 0.637136 +vt 0.630972 0.637136 +vt 0.612076 0.643696 +vt 0.612076 0.637881 +vt 0.760099 0.660723 +vt 0.786724 0.666973 +vt 0.760004 0.666537 +vt 0.695488 0.637136 +vt 0.695488 0.642951 +vt 0.760004 0.637136 +vt 0.741108 0.637881 +vt 0.585352 0.643696 +vt 0.786819 0.661159 +vt 0.805630 0.666537 +vt 0.816456 0.643044 +vt 0.799922 0.637881 +vt 0.816456 0.637229 +vt 0.799922 0.643696 +vt 0.776539 0.637881 +vt 0.655571 0.643696 +vt 0.639037 0.637229 +vt 0.655571 0.637881 +vt 0.678954 0.643696 +vt 0.678954 0.637881 +vt 0.695488 0.643044 +vt 0.695488 0.637229 +vt 0.783384 0.660723 +vt 0.760099 0.654527 +vt 0.783479 0.654909 +vt 0.799927 0.660341 +vt 0.800022 0.654527 +vt 0.776539 0.643696 +vt 0.760004 0.637229 +vt 0.630972 0.642951 +vt 0.760004 0.642951 +vt 0.805725 0.660723 +vt 0.639037 0.643044 +vt 0.760004 0.660341 +vt 0.760004 0.643044 +vt 0.078761 0.951645 +vt 0.048527 0.921411 +vt 0.048527 0.878654 +vt 0.121519 0.848420 +vt 0.151753 0.921411 +vn 0.0000 0.0000 1.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.9239 0.3827 0.0000 +vn 0.3827 -0.9239 0.0000 +vn -0.9239 -0.3827 -0.0000 +vn 0.3827 0.9239 0.0000 +vn -0.9239 0.3827 0.0000 +vn 0.9239 -0.3827 -0.0000 +vn -0.3827 0.9239 0.0000 +vn 0.3680 -0.8883 -0.2747 +vn -0.8883 0.3680 -0.2747 +vn -0.3680 0.8883 -0.2747 +vn 0.3680 0.8883 -0.2747 +vn -0.3680 -0.8883 -0.2747 +vn 0.8883 -0.3680 -0.2747 +vn -0.8883 -0.3680 -0.2747 +vn 0.8883 0.3680 -0.2747 +vn -0.3827 -0.9239 -0.0000 +vn 0.5490 -0.5490 0.6303 +vn 0.5490 0.5490 0.6303 +vn -0.5490 0.5490 0.6303 +vn -0.7071 -0.7071 0.0000 +vn -0.0000 -0.7764 0.6303 +vn -0.5490 -0.5490 0.6303 +vn 1.0000 -0.0000 -0.0000 +vn 0.7071 -0.7071 0.0000 +vn 0.0000 1.0000 0.0000 +vn 0.7071 0.7071 -0.0000 +vn 0.0000 0.7764 0.6303 +vn -1.0000 -0.0000 -0.0000 +vn -0.7764 0.0000 0.6303 +vn 0.0000 -1.0000 0.0000 +vn 0.7764 0.0000 0.6303 +vn -0.7071 0.7071 -0.0000 +usemtl None +s off +f 105/241/55 106/242/55 140/243/55 +f 130/244/56 107/245/56 137/246/56 +f 109/247/55 138/248/55 110/249/55 +f 111/250/55 112/251/55 113/252/55 +f 114/253/55 112/251/55 106/242/55 +f 115/254/55 140/243/55 116/255/55 +f 109/247/55 144/256/55 129/257/55 +f 115/254/55 138/248/55 128/258/55 +f 129/257/55 142/259/55 111/250/55 +f 132/260/56 139/261/56 117/262/56 +f 134/263/56 141/264/56 118/265/56 +f 119/266/56 141/264/56 120/267/56 +f 130/244/56 143/268/56 121/269/56 +f 132/260/56 107/245/56 122/270/56 +f 117/262/56 123/271/56 134/263/56 +f 136/272/56 120/267/56 143/268/56 +f 105/273/57 149/274/57 114/275/57 +f 105/241/55 114/253/55 106/242/55 +f 130/244/56 121/269/56 107/245/56 +f 109/247/55 128/258/55 138/248/55 +f 111/250/55 142/259/55 112/251/55 +f 114/253/55 113/252/55 112/251/55 +f 115/254/55 105/241/55 140/243/55 +f 109/247/55 110/249/55 144/256/55 +f 115/254/55 116/255/55 138/248/55 +f 129/257/55 144/256/55 142/259/55 +f 132/260/56 122/270/56 139/261/56 +f 134/263/56 123/271/56 141/264/56 +f 119/266/56 118/265/56 141/264/56 +f 130/244/56 136/272/56 143/268/56 +f 132/260/56 137/246/56 107/245/56 +f 117/262/56 139/261/56 123/271/56 +f 136/272/56 119/266/56 120/267/56 +f 153/276/58 161/277/58 162/278/58 +f 154/279/58 128/280/58 156/281/58 +f 158/282/59 109/283/59 129/284/59 +f 151/285/60 114/275/60 149/274/60 +f 111/286/61 158/287/61 129/288/61 +f 154/289/62 105/273/62 115/290/62 +f 159/291/63 113/292/63 151/293/63 +f 154/279/64 155/294/64 153/276/64 +f 158/287/65 160/295/65 157/296/65 +f 160/295/66 151/293/66 152/297/66 +f 152/298/67 149/274/67 150/299/67 +f 155/294/68 146/300/68 145/301/68 +f 154/289/69 147/302/69 148/303/69 +f 158/282/70 145/301/70 146/300/70 +f 147/302/71 149/274/71 148/303/71 +f 109/283/72 156/281/72 128/280/72 +f 163/304/56 166/305/56 162/306/56 +f 150/299/60 165/307/60 152/298/60 +f 157/308/59 167/309/59 145/301/59 +f 153/310/62 168/311/62 147/302/62 +f 145/301/72 161/277/72 155/294/72 +f 150/299/57 168/311/57 166/312/57 +f 152/297/63 163/313/63 160/295/63 +f 160/295/61 164/314/61 157/296/61 +f 105/273/57 148/303/57 149/274/57 +f 153/276/58 155/294/58 161/277/58 +f 154/279/58 115/315/58 128/280/58 +f 158/282/59 146/300/59 109/283/59 +f 151/285/60 113/316/60 114/275/60 +f 111/286/61 159/291/61 158/287/61 +f 154/289/62 148/303/62 105/273/62 +f 159/291/63 111/286/63 113/292/63 +f 154/279/64 156/281/64 155/294/64 +f 158/287/65 159/291/65 160/295/65 +f 160/295/66 159/291/66 151/293/66 +f 152/298/67 151/285/67 149/274/67 +f 155/294/68 156/281/68 146/300/68 +f 154/289/69 153/310/69 147/302/69 +f 158/282/70 157/308/70 145/301/70 +f 147/302/71 150/299/71 149/274/71 +f 109/283/72 146/300/72 156/281/72 +f 162/306/56 161/317/56 163/304/56 +f 161/317/56 167/318/56 163/304/56 +f 167/318/56 164/319/56 163/304/56 +f 163/304/56 165/320/56 166/305/56 +f 166/305/56 168/321/56 162/306/56 +f 150/299/60 166/312/60 165/307/60 +f 157/308/59 164/322/59 167/309/59 +f 153/310/62 162/323/62 168/311/62 +f 145/301/72 167/309/72 161/277/72 +f 150/299/57 147/302/57 168/311/57 +f 152/297/63 165/324/63 163/313/63 +f 160/295/61 163/313/61 164/314/61 +s 1 +f 124/325/73 133/326/74 126/327/75 +f 130/328/76 131/329/77 127/330/78 +f 117/331/79 124/332/73 132/333/80 +f 118/334/81 133/335/74 134/336/82 +f 118/337/81 126/338/75 135/339/83 +f 136/340/84 127/330/78 125/341/85 +f 132/342/80 131/329/77 137/343/86 +f 134/336/82 108/344/87 117/331/79 +f 119/345/88 125/346/85 126/338/75 +f 122/347/80 138/348/86 116/349/80 +f 107/350/86 110/351/76 138/348/86 +f 139/352/79 116/353/80 140/354/79 +f 123/355/82 140/354/79 106/356/82 +f 141/357/81 106/356/82 112/358/81 +f 120/359/88 112/360/81 142/361/88 +f 143/362/84 142/361/88 144/363/84 +f 121/364/76 144/365/84 110/351/76 +f 130/328/76 137/343/86 131/329/77 +f 117/331/79 108/344/87 124/332/73 +f 118/334/81 135/366/83 133/335/74 +f 118/337/81 119/345/88 126/338/75 +f 136/340/84 130/328/76 127/330/78 +f 132/342/80 124/367/73 131/329/77 +f 134/336/82 133/335/74 108/344/87 +f 119/345/88 136/368/84 125/346/85 +f 122/347/80 107/350/86 138/348/86 +f 107/350/86 121/364/76 110/351/76 +f 139/352/79 122/369/80 116/353/80 +f 123/355/82 139/352/79 140/354/79 +f 141/357/81 123/355/82 106/356/82 +f 120/359/88 141/370/81 112/360/81 +f 143/362/84 120/359/88 142/361/88 +f 121/364/76 143/371/84 144/365/84 +f 126/327/75 125/372/85 127/373/78 +f 127/373/78 131/374/77 124/325/73 +f 124/325/73 108/375/87 133/326/74 +f 133/326/74 135/376/83 126/327/75 +f 126/327/75 127/373/78 124/325/73 diff --git a/src/main/resources/assets/hbm/textures/particle/casing_ar2.png b/src/main/resources/assets/hbm/textures/particle/casing_ar2.png new file mode 100644 index 000000000..6186525b2 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/particle/casing_ar2.png differ diff --git a/src/main/resources/assets/hbm/textures/particle/casing_tex.png b/src/main/resources/assets/hbm/textures/particle/casing_tex.png new file mode 100644 index 000000000..e9ddbafa5 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/particle/casing_tex.png differ