From 754f88a42f4528dacea7344c36ce541e7cb1b43d Mon Sep 17 00:00:00 2001 From: UFFR Date: Tue, 20 Dec 2022 00:04:58 -0500 Subject: [PATCH] Fixes and tinkering Fixed offset rotation sorta, now casing align with the ejection port for the most part. Turrets still need work in this regard. Fixed some texture asset names. FBI shotgunners make spent casings, but they are jank since NPC rotations don't match with their rendered rotation for some reason (ie NPC is facing player when rendered visually, but the actual entity isn't). --- .../java/com/hbm/entity/mob/EntityFBI.java | 15 ++++ .../hbm/handler/guncfg/Gun12GaugeFactory.java | 49 ++++++----- .../hbm/handler/guncfg/Gun20GaugeFactory.java | 28 +++---- .../hbm/handler/guncfg/Gun22LRFactory.java | 3 +- .../handler/guncfg/Gun357MagnumFactory.java | 2 +- .../handler/guncfg/Gun44MagnumFactory.java | 2 +- .../hbm/handler/guncfg/Gun45ACPFactory.java | 6 +- .../hbm/handler/guncfg/Gun4GaugeFactory.java | 4 +- .../hbm/handler/guncfg/Gun50AEFactory.java | 4 +- .../hbm/handler/guncfg/Gun50BMGFactory.java | 12 ++- .../hbm/handler/guncfg/Gun556mmFactory.java | 4 +- .../hbm/handler/guncfg/Gun762mmFactory.java | 1 + .../com/hbm/handler/guncfg/Gun9mmFactory.java | 6 +- .../hbm/handler/guncfg/GunCannonFactory.java | 8 +- .../com/hbm/handler/guncfg/GunDGKFactory.java | 4 +- .../hbm/handler/guncfg/GunOSIPRFactory.java | 2 +- .../com/hbm/items/weapon/ItemAmmoArty.java | 52 +++++++----- .../com/hbm/particle/ParticleSpentCasing.java | 79 +++++++++++------- .../com/hbm/particle/SpentCasingConfig.java | 52 ++++++++---- .../particle/SpentCasingConfigBuilder.java | 1 + .../turret/TileEntityTurretArty.java | 3 + .../turret/TileEntityTurretBaseNT.java | 2 +- src/main/java/com/hbm/util/BobMathUtil.java | 8 +- ...{ammo_4gauge.png => ammo_4gauge.stock.png} | Bin .../{gun_pm_ammo.png => ammo_556.gold.png} | Bin ...arty.classic.png => ammo_arty_classic.png} | Bin .../{ammo_arty.he.png => ammo_arty_he.png} | Bin ....mini_nuke.png => ammo_arty_mini_nuke.png} | Bin ...ulti.png => ammo_arty_mini_nuke_multi.png} | Bin ...{ammo_arty.nuke.png => ammo_arty_nuke.png} | Bin ...hosphorus.png => ammo_arty_phosphorus.png} | Bin ...lti.png => ammo_arty_phosphorus_multi.png} | Bin 32 files changed, 224 insertions(+), 123 deletions(-) rename src/main/resources/assets/hbm/textures/items/{ammo_4gauge.png => ammo_4gauge.stock.png} (100%) rename src/main/resources/assets/hbm/textures/items/{gun_pm_ammo.png => ammo_556.gold.png} (100%) rename src/main/resources/assets/hbm/textures/items/{ammo_arty.classic.png => ammo_arty_classic.png} (100%) rename src/main/resources/assets/hbm/textures/items/{ammo_arty.he.png => ammo_arty_he.png} (100%) rename src/main/resources/assets/hbm/textures/items/{ammo_arty.mini_nuke.png => ammo_arty_mini_nuke.png} (100%) rename src/main/resources/assets/hbm/textures/items/{ammo_arty.mini_nuke_multi.png => ammo_arty_mini_nuke_multi.png} (100%) rename src/main/resources/assets/hbm/textures/items/{ammo_arty.nuke.png => ammo_arty_nuke.png} (100%) rename src/main/resources/assets/hbm/textures/items/{ammo_arty.phosphorus.png => ammo_arty_phosphorus.png} (100%) rename src/main/resources/assets/hbm/textures/items/{ammo_arty.phosphorus_multi.png => ammo_arty_phosphorus_multi.png} (100%) diff --git a/src/main/java/com/hbm/entity/mob/EntityFBI.java b/src/main/java/com/hbm/entity/mob/EntityFBI.java index fbbd5e6e6..7696f0097 100644 --- a/src/main/java/com/hbm/entity/mob/EntityFBI.java +++ b/src/main/java/com/hbm/entity/mob/EntityFBI.java @@ -9,7 +9,9 @@ import com.hbm.config.MobConfig; import com.hbm.entity.mob.ai.EntityAIBreaking; import com.hbm.entity.mob.ai.EntityAI_MLPF; import com.hbm.entity.projectile.EntityBullet; +import com.hbm.handler.guncfg.Gun4GaugeFactory; import com.hbm.items.ModItems; +import com.hbm.main.MainRegistry; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; @@ -32,6 +34,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; @@ -145,6 +148,18 @@ public class EntityFBI extends EntityMob implements IRangedAttackMob { this.worldObj.spawnEntityInWorld(bullet); } this.playSound("hbm:weapon.shotgunShoot", 1.0F, 1.0F); + + // Casing stuff, not doing it in a method or anything because I'm gonna do that with the SNPC class. + final NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "casing"); + data.setDouble("posX", posX); + data.setDouble("posY", posY + getEyeHeight()); + data.setDouble("posZ", posZ); + data.setFloat("pitch", (float) Math.toRadians(rotationPitch)); + data.setFloat("yaw", (float) Math.toRadians(rotationYaw)); + data.setBoolean("crouched", isSneaking()); + data.setString("name", "4g"); + MainRegistry.proxy.effectNT(data); } } } diff --git a/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java index a22c378fb..a9ee91341 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun12GaugeFactory.java @@ -25,28 +25,33 @@ 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(); + static final SpentCasingConfig CASING_SPAS, CASING_SPAS_ALT, CASING_BENELLI, CASING_UBOINIK, CASING_SSG; + + static + { + final SpentCasingConfigBuilder CASING_12G_BUILDER = new SpentCasingConfigBuilder("", CasingType.SHOTGUN, false) + .setScaleX(1.5f).setScaleY(1.5f).setScaleZ(1.5f); + CASING_SPAS = CASING_12G_BUILDER.setRegistryName("spas12").setInitialMotion(Vec3.createVectorHelper(-0.4, 0.1, 0)) + .setPosOffset(new EasyLocation(-0.35, 0, 0.5)).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, 0)) + .build(); + + CASING_UBOINIK = CASING_12G_BUILDER.setRegistryName("uboinik").setOverrideColor(true) + .setBlueOverride(255).setPosOffset(new EasyLocation(-0.35, -0.3, 0.5)) + .build(); + + CASING_SSG = CASING_12G_BUILDER.setRegistryName("ssg").setBlueOverride(0).setRedOverride(255).setCasingAmount(2) + .setPosOffset(new EasyLocation(0.8, 0, 0)).setInitialMotion(Vec3.createVectorHelper(0.2, 0, -0.2)) + .setPitchFactor(0.05f).setYawFactor(0.02f) + .build(); + } public static GunConfiguration getSpas12Config() { diff --git a/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java index 135254b75..d809071e8 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun20GaugeFactory.java @@ -4,7 +4,6 @@ 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; @@ -29,8 +28,8 @@ 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) + .setPosOffset(new EasyLocation(-0.55, 0, 0.5)) + .setInitialMotion(Vec3.createVectorHelper(-0.4, 0.95, 0)).setPitchFactor(0.05f).setYawFactor(0.01f) .setSmokeChance(0) .build(); @@ -215,17 +214,18 @@ public class Gun20GaugeFactory { ) ); - config.config = new ArrayList(); - config.config.add(BulletConfigSyncingUtil.G20_SLUG_FIRE); - config.config.add(BulletConfigSyncingUtil.G20_NORMAL_FIRE); - config.config.add(BulletConfigSyncingUtil.G20_FLECHETTE_FIRE); - config.config.add(BulletConfigSyncingUtil.G20_FIRE); - config.config.add(BulletConfigSyncingUtil.G20_SHRAPNEL); - config.config.add(BulletConfigSyncingUtil.G20_EXPLOSIVE_FIRE); - config.config.add(BulletConfigSyncingUtil.G20_CAUSTIC_FIRE); - config.config.add(BulletConfigSyncingUtil.G20_SHOCK_FIRE); - config.config.add(BulletConfigSyncingUtil.G20_WITHER_FIRE); - config.config.add(BulletConfigSyncingUtil.G20_SLEEK); +// config.config = new ArrayList(); +// config.config.add(BulletConfigSyncingUtil.G20_SLUG_FIRE); +// config.config.add(BulletConfigSyncingUtil.G20_NORMAL_FIRE); +// config.config.add(BulletConfigSyncingUtil.G20_FLECHETTE_FIRE); +// config.config.add(BulletConfigSyncingUtil.G20_FIRE); +// config.config.add(BulletConfigSyncingUtil.G20_SHRAPNEL); +// config.config.add(BulletConfigSyncingUtil.G20_EXPLOSIVE_FIRE); +// config.config.add(BulletConfigSyncingUtil.G20_CAUSTIC_FIRE); +// config.config.add(BulletConfigSyncingUtil.G20_SHOCK_FIRE); +// config.config.add(BulletConfigSyncingUtil.G20_WITHER_FIRE); +// config.config.add(BulletConfigSyncingUtil.G20_SLEEK); + config.config = HbmCollection.twentyGauge; config.casingConfig = Optional.of(CASING_20G_LEVER); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java index 57787fc5a..e5ecf60e4 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun22LRFactory.java @@ -21,7 +21,8 @@ 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)) + .setInitialMotion(Vec3.createVectorHelper(-0.4, 0.1, 0)).setPitchFactor(0.03f).setYawFactor(0.01f) + .setPosOffset(new EasyLocation(-0.35, -0.2, 0.35)) .build(); public static GunConfiguration getUziConfig() { diff --git a/src/main/java/com/hbm/handler/guncfg/Gun357MagnumFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun357MagnumFactory.java index 9ddc7721f..588d951b3 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun357MagnumFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun357MagnumFactory.java @@ -22,7 +22,7 @@ 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); + .setCasingAmount(6).setYawFactor(0.05f).setPosOffset(new EasyLocation(0, -0.15, 0)).setSmokeChance(6).setAfterReload(true); static final SpentCasingConfig CASING_357 = CASING_357_BUILDER.build(), diff --git a/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java index 4c184270b..ad8f4f2d1 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun44MagnumFactory.java @@ -30,7 +30,7 @@ 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) + .setCasingAmount(6).setYawFactor(0.05f).setPosOffset(new EasyLocation(0, -0.15, 0)).setSmokeChance(6) .setAfterReload(true).setScaleX(1.25f).build(); public static GunConfiguration getBaseConfig() { diff --git a/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java index ffe301bef..9d0bf6d82 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun45ACPFactory.java @@ -25,13 +25,13 @@ 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); + .setSmokeChance(8).setInitialMotion(Vec3.createVectorHelper(0.3, 0.75, 0)).setPitchFactor(0.03f).setYawFactor(0.01f) + .setPosOffset(new EasyLocation(-0.3, -0.25, 0.6)).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)) + .setInitialMotion(Vec3.createVectorHelper(0.3, 0.9, 0)) .build(); public static GunConfiguration getThompsonConfig() { diff --git a/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java index 9b2a769ed..9c88012e9 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java @@ -42,8 +42,8 @@ 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) + .setSmokeChance(0).setPosOffset(new EasyLocation(-0.5, 0, 0.5)) + .setInitialMotion(Vec3.createVectorHelper(-0.4, 0.4, 0)).setPitchFactor(0.03f).setYawFactor(0.01f) .setScaleX(2.5f).setScaleY(2.5f).setScaleZ(2.5f).build(); private static GunConfiguration getShotgunConfig() { diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java index c13ebb40e..ddbdff3fd 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50AEFactory.java @@ -19,8 +19,8 @@ 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(); + .setSmokeChance(4).setInitialMotion(Vec3.createVectorHelper(-0.3, 0.7, 0)).setPitchFactor(0.03f).setYawFactor(0.01f) + .setPosOffset(new EasyLocation(-0.5, 0, 0.5)).setScaleZ(1.5f).build(); public static GunConfiguration getBaseConfig() { diff --git a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java index cb87223f4..0a0d0e758 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun50BMGFactory.java @@ -37,13 +37,13 @@ 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) + .setSmokeChance(0).setInitialMotion(Vec3.createVectorHelper(-0.35, 0.9, 0)).setScaleX(3).setScaleY(3).setScaleZ(3) + .setPosOffset(new EasyLocation(-0.45, -0.2, 0.35)).setPitchFactor(0.05f).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) + .setScaleX(4).setScaleY(4).setScaleZ(4).setSmokeChance(0).setInitialMotion(Vec3.createVectorHelper(-2, 0.15, 0)) + .setPosOffset(new EasyLocation(-0.45, -0.2, 0.35)).setRedOverride(11).setGreenOverride(97).setBlueOverride(109) .setYawFactor(0.02f) .build(); @@ -85,6 +85,8 @@ public class Gun50BMGFactory { config.config = HbmCollection.fiftyBMG; + config.casingConfig = Optional.of(CONFIG_50BMG); + return config; } @@ -111,6 +113,8 @@ public class Gun50BMGFactory { config.config = HbmCollection.fiftyBMG; + 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 12265a75d..874d451c5 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun556mmFactory.java @@ -32,8 +32,8 @@ 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) + .setSmokeChance(4).setInitialMotion(Vec3.createVectorHelper(-0.35, 0.6, 0)).setPitchFactor(0.03f).setYawFactor(0.01f) + .setPosOffset(new EasyLocation(-0.35, 0, 0.35)).setScaleZ(1.5f) .build(); public static GunConfiguration getEuphieConfig() { diff --git a/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java index a9d3dce92..6591e9a72 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun762mmFactory.java @@ -18,6 +18,7 @@ import net.minecraft.potion.PotionEffect; public class Gun762mmFactory { + // TODO Confirm static final SpentCasingConfig CASING_762_NATO = Gun556mmFactory.CONFIG_556.toBuilder("762NATO").setSmokeChance(2).setScaleX(2) .setScaleZ(2.5f).build(); diff --git a/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java index fff5dc221..08a4f6024 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun9mmFactory.java @@ -3,6 +3,7 @@ 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; @@ -17,9 +18,12 @@ 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 Gun9mmFactory { - static final SpentCasingConfig CASING_9 = Gun45ACPFactory.CASING_45.toBuilder("9") + static final SpentCasingConfig CASING_9 = Gun45ACPFactory.CASING_45_UAC.toBuilder("9") + .setInitialMotion(Vec3.createVectorHelper(-0.3, 0.6, 0)).setPosOffset(new EasyLocation(-0.35, -0.2, 0.55)) .setScaleX(1).setScaleY(1).setScaleZ(0.6f).build(); public static GunConfiguration getMP40Config() { diff --git a/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java b/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java index bbf7f64da..ad62fdf50 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java @@ -16,13 +16,13 @@ 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); + .setInitialMotion(Vec3.createVectorHelper(0, 0.2, -1)).setPosOffset(new EasyLocation(0, 1.75, -1.5)).setSmokeChance(0) + .setScaleX(10).setScaleY(10).setScaleZ(10).setPitchFactor(0.15f).setYawFactor(0.015f); 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) + CASING_16IN = CASING_CANNON_BUILDER.setRegistryName("16inch").setInitialMotion(Vec3.createVectorHelper(0, 2, -1.75)) + .setScaleX(20).setScaleY(20).setScaleZ(25).setCasingType(CasingType.BRASS_STRAIGHT_WALL) .build(); static final int stockPen = 10000; diff --git a/src/main/java/com/hbm/handler/guncfg/GunDGKFactory.java b/src/main/java/com/hbm/handler/guncfg/GunDGKFactory.java index 931578c99..db11ee141 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunDGKFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunDGKFactory.java @@ -1,5 +1,6 @@ package com.hbm.handler.guncfg; +import com.hbm.calc.EasyLocation; import com.hbm.handler.BulletConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.items.ModItems; @@ -10,7 +11,8 @@ 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) + .setInitialMotion(Vec3.createVectorHelper(0.8, 1, 0)).setPosOffset(new EasyLocation(0.15, 1.5, -1.5)) + .setOverrideColor(false).setPitchFactor(0.1f).setYawFactor(0.08f) .build(); public static BulletConfiguration getDGKConfig() { diff --git a/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java b/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java index 5c1b849ae..0829183a2 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunOSIPRFactory.java @@ -34,7 +34,7 @@ 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(); + .setAfterReload(true).setPosOffset(new EasyLocation(-0.4, 0, 0)).build(); public static GunConfiguration getOSIPRConfig() { diff --git a/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java b/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java index 803b44ed5..463207c36 100644 --- a/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java +++ b/src/main/java/com/hbm/items/weapon/ItemAmmoArty.java @@ -41,17 +41,17 @@ import net.minecraft.util.Vec3; public class ItemAmmoArty extends Item { - public static ArtilleryShell[] itemTypes = new ArtilleryShell[ /* >>> */ 8 /* <<< */ ]; - public static ArtilleryShell[] shellTypes = new ArtilleryShell[ /* >>> */ 8 /* <<< */ ]; + public static final ArtilleryShell[] itemTypes = new ArtilleryShell[ /* >>> */ 8 /* <<< */ ]; + public static final ArtilleryShell[] shellTypes = new ArtilleryShell[ /* >>> */ 8 /* <<< */ ]; /* item types */ - public final int NORMAL = 0; - public final int CLASSIC = 1; - public final int EXPLOSIVE = 2; - public final int MINI_NUKE = 3; - public final int NUKE = 4; - public final int PHOSPHORUS = 5; - public final int MINI_NUKE_MULTI = 6; - public final int PHOSPHORUS_MULTI = 7; + public static final int NORMAL = 0; + public static final int CLASSIC = 1; + public static final int EXPLOSIVE = 2; + public static final int MINI_NUKE = 3; + public static final int NUKE = 4; + public static final int PHOSPHORUS = 5; + public static final int MINI_NUKE_MULTI = 6; + public static final int PHOSPHORUS_MULTI = 7; /* non-item shell types */ public ItemAmmoArty() { @@ -118,11 +118,13 @@ public class ItemAmmoArty extends Item { list.add(r + "(that is the best skull and crossbones"); list.add(r + "minecraft's unicode has to offer)"); break; + default: break; } } private IIcon[] icons = new IIcon[itemTypes.length]; + @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister reg) { @@ -204,12 +206,16 @@ public class ItemAmmoArty extends Item { private void init() { /* STANDARD SHELLS */ - this.shellTypes[NORMAL] = this.itemTypes[NORMAL] = new ArtilleryShell("ammo_arty") { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 10F, 3F, false); }}; - this.shellTypes[CLASSIC] = this.itemTypes[CLASSIC] = new ArtilleryShell("ammo_arty_classic") { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 15F, 5F, false); }}; - this.shellTypes[EXPLOSIVE] = this.itemTypes[EXPLOSIVE] = new ArtilleryShell("ammo_arty_he") { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 15F, 3F, true); }}; + ItemAmmoArty.shellTypes[NORMAL] = ItemAmmoArty.itemTypes[NORMAL] = new ArtilleryShell("ammo_arty") { @Override + public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 10F, 3F, false); }}; + ItemAmmoArty.shellTypes[CLASSIC] = ItemAmmoArty.itemTypes[CLASSIC] = new ArtilleryShell("ammo_arty_classic") { @Override + public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 15F, 5F, false); }}; + ItemAmmoArty.shellTypes[EXPLOSIVE] = ItemAmmoArty.itemTypes[EXPLOSIVE] = new ArtilleryShell("ammo_arty_he") { @Override + public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 15F, 3F, true); }}; /* MINI NUKE */ - this.shellTypes[MINI_NUKE] = this.itemTypes[MINI_NUKE] = new ArtilleryShell("ammo_arty_mini_nuke") { + ItemAmmoArty.shellTypes[MINI_NUKE] = ItemAmmoArty.itemTypes[MINI_NUKE] = new ArtilleryShell("ammo_arty_mini_nuke") { + @Override public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { shell.killAndClear(); Vec3 vec = Vec3.createVectorHelper(shell.motionX, shell.motionY, shell.motionZ).normalize(); @@ -218,7 +224,8 @@ public class ItemAmmoArty extends Item { }; /* FULL NUKE */ - this.shellTypes[NUKE] = this.itemTypes[NUKE] = new ArtilleryShell("ammo_arty_nuke") { + ItemAmmoArty.shellTypes[NUKE] = ItemAmmoArty.itemTypes[NUKE] = new ArtilleryShell("ammo_arty_nuke") { + @Override public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { shell.worldObj.spawnEntityInWorld(EntityNukeExplosionMK4.statFac(shell.worldObj, BombConfig.missileRadius, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord)); EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(shell.worldObj, 1000, BombConfig.missileRadius * 0.005F); @@ -231,7 +238,8 @@ public class ItemAmmoArty extends Item { }; /* PHOSPHORUS */ - this.shellTypes[PHOSPHORUS] = this.itemTypes[PHOSPHORUS] = new ArtilleryShell("ammo_arty_phosphorus") { + ItemAmmoArty.shellTypes[PHOSPHORUS] = ItemAmmoArty.itemTypes[PHOSPHORUS] = new ArtilleryShell("ammo_arty_phosphorus") { + @Override public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 10F, 3F, false); shell.worldObj.playSoundEffect(shell.posX, shell.posY, shell.posZ, "hbm:weapon.explosionMedium", 20.0F, 0.9F + shell.worldObj.rand.nextFloat() * 0.2F); @@ -260,12 +268,16 @@ public class ItemAmmoArty extends Item { }; /* CLUSTER SHELLS */ - this.shellTypes[PHOSPHORUS_MULTI] = this.itemTypes[PHOSPHORUS_MULTI] = new ArtilleryShell("ammo_arty_phosphorus_multi") { - public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { ItemAmmoArty.this.shellTypes[PHOSPHORUS].onImpact(shell, mop); } + ItemAmmoArty.shellTypes[PHOSPHORUS_MULTI] = ItemAmmoArty.itemTypes[PHOSPHORUS_MULTI] = new ArtilleryShell("ammo_arty_phosphorus_multi") { + @Override + public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { ItemAmmoArty.shellTypes[PHOSPHORUS].onImpact(shell, mop); } + @Override public void onUpdate(EntityArtilleryShell shell) { standardCluster(shell, PHOSPHORUS, 10, 300, 5); } }; - this.shellTypes[MINI_NUKE_MULTI] = this.itemTypes[MINI_NUKE_MULTI] = new ArtilleryShell("ammo_arty_mini_nuke_multi") { - public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { ItemAmmoArty.this.shellTypes[MINI_NUKE].onImpact(shell, mop); } + ItemAmmoArty.shellTypes[MINI_NUKE_MULTI] = ItemAmmoArty.itemTypes[MINI_NUKE_MULTI] = new ArtilleryShell("ammo_arty_mini_nuke_multi") { + @Override + public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { ItemAmmoArty.shellTypes[MINI_NUKE].onImpact(shell, mop); } + @Override public void onUpdate(EntityArtilleryShell shell) { standardCluster(shell, MINI_NUKE, 5, 300, 5); } }; } diff --git a/src/main/java/com/hbm/particle/ParticleSpentCasing.java b/src/main/java/com/hbm/particle/ParticleSpentCasing.java index e3f16c893..ae401cb95 100644 --- a/src/main/java/com/hbm/particle/ParticleSpentCasing.java +++ b/src/main/java/com/hbm/particle/ParticleSpentCasing.java @@ -20,7 +20,7 @@ import net.minecraft.world.World; @SideOnly(Side.CLIENT) public class ParticleSpentCasing extends EntityFX { - private static final float dScale = 0.05f, smokeOffset = 0.025f, gravity = -0.5f; + private static final float dScale = 0.05f, smokeJitter = 0.025f; private static final byte smokeAccel = 1; private final List> smokeNodes = new ArrayList>(); @@ -34,16 +34,22 @@ public class ParticleSpentCasing extends EntityFX 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); + super(world, x, y, z, 0, 0, 0); this.textureManager = textureManager; this.momentumPitch = momentumPitch; this.momentumYaw = momentumYaw; this.config = config; - particleMaxAge = 120; + particleMaxAge = 240; smoke = config.getSmokeChance() == 0 ? true : config.getSmokeChance() < 0 ? false : rand.nextInt(config.getSmokeChance()) == 0; + + motionX = mx; + motionY = my; + motionZ = mz; + + particleGravity = 8f; } @Override @@ -62,16 +68,13 @@ public class ParticleSpentCasing extends EntityFX else if (onGroundPreviously && !onGround) onGroundPreviously = false; - if (!config.getBounceSound().isEmpty()) - { - if (!onGroundPreviously && onGround) - worldObj.playSoundEffect(posX, posY, posZ, config.getBounceSound(), 1, 1); - } + if (!onGroundPreviously && onGround) + tryPlayBounceSound(); - if (particleAge > 90 && !smokeNodes.isEmpty()) + if (particleAge > 120 && !smokeNodes.isEmpty()) smokeNodes.clear(); - if (smoke && particleAge <= 90) + if (smoke && particleAge <= 120) { final double side = (rotationYaw - prevRotationYaw) * 0.1D; final Vec3 prev = Vec3.createVectorHelper(motionX, -motionY, motionZ); @@ -81,23 +84,25 @@ public class ParticleSpentCasing extends EntityFX { final EasyLocation node = pair.getKey(); - node.posX += prev.xCoord * smokeAccel + rand.nextGaussian() * smokeOffset + side; + node.posX += prev.xCoord * smokeAccel + rand.nextGaussian() * smokeJitter + side; node.posY += prev.yCoord + 1.5; - node.posZ += prev.zCoord * smokeAccel + rand.nextGaussian() * smokeOffset; + node.posZ += prev.zCoord * smokeAccel + rand.nextGaussian() * smokeJitter; } - final double alpha = (particleAge / 20d); - - smokeNodes.add(new Pair(EasyLocation.getZeroLocation(), alpha)); + if (particleAge < 60) + { + final double alpha = (particleAge / 20d); + smokeNodes.add(new Pair(EasyLocation.getZeroLocation(), alpha)); + } } prevRotationPitch = rotationPitch; prevRotationYaw = rotationYaw; - if (motionY > gravity && !onGround) - motionY += gravity; - if (motionY < -0.75) - motionY = -0.75; +// if (motionY > gravity && !onGround) +// motionY += gravity; +// if (motionY < -0.75) +// motionY = -0.75; if (onGround) rotationPitch = 0; @@ -128,17 +133,13 @@ public class ParticleSpentCasing extends EntityFX 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); + + GL11.glScalef(config.getScaleX(), config.getScaleY(), config.getScaleZ()); + if (config.doesOverrideColor()) - GL11.glColor3f(config.getRedOverride(), config.getBlueOverride(), config.getGreenOverride()); + GL11.glColor3b((byte) config.getRedOverride(), (byte) config.getGreenOverride(), (byte) config.getBlueOverride()); if (!smokeNodes.isEmpty()) { @@ -149,7 +150,7 @@ public class ParticleSpentCasing extends EntityFX { 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()); + final float nodeAlpha = node.getValue().floatValue(), pastAlpha = past.getValue().floatValue(), scale = config.getScaleX(); tessellator.setColorRGBA_F(1F, 1F, 1F, nodeAlpha); tessellator.addVertex(nodeLoc.posX(), nodeLoc.posY(), nodeLoc.posZ()); @@ -183,4 +184,26 @@ public class ParticleSpentCasing extends EntityFX GL11.glShadeModel(GL11.GL_FLAT); GL11.glPopMatrix(); } + + private void tryPlayBounceSound() + { + if (!config.getBounceSound().isEmpty()) + worldObj.playSoundEffect(posX, posY, posZ, config.getBounceSound(), 1, 1); + } + +// private static float[] getOffset(float time) +// { +// final float sinVal1 = (float) ((Math.sin(time * 0.15) + Math.sin(time * 0.25 - 10) + Math.sin(time * 0.1 + 10)) / 3f), +// sinVal2 = (float) ((Math.sin(time * 0.1) + Math.sin(time * 0.05 + 20) + Math.sin(time * 0.13 + 20)) / 3f); +// +// return new float[] {BobMathUtil.remap(BobMathUtil.smoothStep(sinVal1, -1, 1), 0, 1, -2, 1.5F), BobMathUtil.remap(sinVal2, -1, 1, -0.03F, 0.05F)}; +// } +// +// private static float[] getJitter(float time) +// { +// final float sinVal1 = (float) ((Math.sin(time * 0.8) + Math.sin(time * 0.6 - 10) + Math.sin(time * 0.9 + 10)) / 3f), +// sinVal2 = (float) ((Math.sin(time * 0.3) + Math.sin(time * 0.2 + 20) + Math.sin(time * 0.1 + 20)) / 3f); +// +// return new float[] {BobMathUtil.remap(sinVal1, -1, 1, -3, 3), BobMathUtil.remap(sinVal2, -1, 1, -1F, 1F)}; +// } } diff --git a/src/main/java/com/hbm/particle/SpentCasingConfig.java b/src/main/java/com/hbm/particle/SpentCasingConfig.java index e0edaddfc..8fd314de4 100644 --- a/src/main/java/com/hbm/particle/SpentCasingConfig.java +++ b/src/main/java/com/hbm/particle/SpentCasingConfig.java @@ -99,39 +99,63 @@ public class SpentCasingConfig 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); + pitch + (float) RANDOM.nextGaussian() * getPitchFactor(), yaw + (float) RANDOM.nextGaussian() * getPitchFactor(), + getPitchFactor(), getPitchFactor()); final ParticleSpentCasing casing = new ParticleSpentCasing(textureManager, world, x, - y, z, 0, 0, 0, + y, z, rotatedMotionVec.xCoord, rotatedMotionVec.yCoord, rotatedMotionVec.zCoord, // 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); + offsetCasing(casing, getPosOffset(), pitch, yaw, crouched); casing.rotationPitch = (float) Math.toDegrees(pitch); casing.rotationYaw = (float) Math.toDegrees(yaw); if (overrideColor) - casing.setRBGColorF(redOverride, blueOverride, greenOverride); + casing.setRBGColorF(redOverride / 255f, blueOverride / 255f, greenOverride / 255f); Minecraft.getMinecraft().effectRenderer.addEffect(casing); } - private static void offsetCasing(ParticleSpentCasing casing, ILocationProvider offset, float yaw, boolean crouched) + // Rotate a position + private static void offsetCasing(ParticleSpentCasing casing, ILocationProvider offset, float pitch, float yaw, boolean crouched) { - casing.posX -= Math.cos(yaw) * offset.posX() + (crouched ? 0.16 : -0.05); - casing.posY -= offset.posY(); - casing.posZ -= Math.sin(yaw) * offset.posZ(); +// // x-axis offset, 0 if crouched to center +// final double oX = crouched ? 0 : offset.posX(); +// // Trigonometric operations, saved for convenience +// final double sinP = Math.sin(pitch), cosP = Math.cos(pitch), sinY = Math.sin(yaw), cosY = Math.cos(yaw); +// // New offsets +// final double newX = oX * cosY - offset.posZ() * sinY, +// newY = offset.posY() * cosP - sinP * (oX * sinY + offset.posZ() * cosY), +// newZ = offset.posZ() * sinP + cosP * (oX * sinY + offset.posZ() * cosY); +// +// // Apply +// casing.setPosition(casing.posX + newX, casing.posY + newY, casing.posZ + newZ); + + // x-axis offset, 0 if crouched to center + final float oX = (float) (crouched ? 0 : offset.posX()); + // Create rotation matrices for pitch and yaw + final Matrix4f pitchMatrix = new Matrix4f(), yawMatrix = new Matrix4f(); + + pitchMatrix.rotate(pitch, new Vector3f(1, 0, 0)); // modify axis of rotation + yawMatrix.rotate(-yaw, new Vector3f(0, 1, 0)); + + // Multiply matrices to get combined rotation matrix + final Matrix4f rotMatrix = Matrix4f.mul(yawMatrix, pitchMatrix, null); + // Create vector representing the offset and apply rotation + final Vector4f offsetVector = new Vector4f(oX, (float) offset.posY(), (float) offset.posZ(), 1); // set fourth coordinate to 1 + Matrix4f.transform(rotMatrix, offsetVector, offsetVector); + final Vector3f result = new Vector3f(); // create result vector + result.set(offsetVector.x, offsetVector.y, offsetVector.z); // set result vector using transformed coordinates + // Apply rotation + casing.setPosition(casing.posX + result.x, casing.posY + result.y, casing.posZ + result.z); } +// Rotate a vector private static Vec3 rotateVector(Vec3 vector, float pitch, float yaw, float pitchFactor, float yawFactor) { + // Apply randomness to vector vector.xCoord += RANDOM.nextGaussian() * yawFactor; vector.yCoord += RANDOM.nextGaussian() * pitchFactor; vector.zCoord += RANDOM.nextGaussian() * yawFactor; diff --git a/src/main/java/com/hbm/particle/SpentCasingConfigBuilder.java b/src/main/java/com/hbm/particle/SpentCasingConfigBuilder.java index a3f7368f3..9dc24c102 100644 --- a/src/main/java/com/hbm/particle/SpentCasingConfigBuilder.java +++ b/src/main/java/com/hbm/particle/SpentCasingConfigBuilder.java @@ -40,6 +40,7 @@ public class SpentCasingConfigBuilder implements Cloneable 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; + // TODO Setting to disregard crouch effect and/or another offset specifically for crouching which can be set to null to use the default one /** * Constructor with fields for the required bare minimum parameters.
* All parameters may overridden using setters at any time at your discretion, however. diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java index 026b21408..1d6dae6b5 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretArty.java @@ -204,6 +204,8 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen proj.setWhistle(true); worldObj.spawnEntityInWorld(proj); + + spawnCasing(); } @Override @@ -374,6 +376,7 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen data.setFloat("size", 0F); data.setByte("count", (byte)5); 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 == MODE_MANUAL && !this.targetQueue.isEmpty()) { diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java index c53c9b283..6545cbce1 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java @@ -849,7 +849,7 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple final NBTTagCompound data = new NBTTagCompound(); data.setString("type", "casing"); data.setDouble("posX", xCoord); - data.setDouble("posY", yCoord + 0.5); + data.setDouble("posY", yCoord + 1); data.setDouble("posZ", zCoord); data.setFloat("pitch", (float) rotationPitch); data.setFloat("yaw", (float) rotationYaw); diff --git a/src/main/java/com/hbm/util/BobMathUtil.java b/src/main/java/com/hbm/util/BobMathUtil.java index 065142b57..51325f3b0 100644 --- a/src/main/java/com/hbm/util/BobMathUtil.java +++ b/src/main/java/com/hbm/util/BobMathUtil.java @@ -81,6 +81,12 @@ public class BobMathUtil { return MathHelper.clamp_float((num - min1) / (max1 - min1), 0, 1); } + public static float smoothStep(float f, float lower, float upper) + { + final float t = MathHelper.clamp_float((f - lower) / (upper - lower), 0, 1); + return t * t * (3f - 2f * t); + } + public static ForgeDirection[] getShuffledDirs() { ForgeDirection[] dirs = new ForgeDirection[6]; @@ -94,7 +100,7 @@ public class BobMathUtil { return dirs; } - public static String toPercentage(float amount, float total) { + public static String toPercentage(double amount, double total) { return NumberFormat.getPercentInstance().format(amount / total); } diff --git a/src/main/resources/assets/hbm/textures/items/ammo_4gauge.png b/src/main/resources/assets/hbm/textures/items/ammo_4gauge.stock.png similarity index 100% rename from src/main/resources/assets/hbm/textures/items/ammo_4gauge.png rename to src/main/resources/assets/hbm/textures/items/ammo_4gauge.stock.png diff --git a/src/main/resources/assets/hbm/textures/items/gun_pm_ammo.png b/src/main/resources/assets/hbm/textures/items/ammo_556.gold.png similarity index 100% rename from src/main/resources/assets/hbm/textures/items/gun_pm_ammo.png rename to src/main/resources/assets/hbm/textures/items/ammo_556.gold.png diff --git a/src/main/resources/assets/hbm/textures/items/ammo_arty.classic.png b/src/main/resources/assets/hbm/textures/items/ammo_arty_classic.png similarity index 100% rename from src/main/resources/assets/hbm/textures/items/ammo_arty.classic.png rename to src/main/resources/assets/hbm/textures/items/ammo_arty_classic.png diff --git a/src/main/resources/assets/hbm/textures/items/ammo_arty.he.png b/src/main/resources/assets/hbm/textures/items/ammo_arty_he.png similarity index 100% rename from src/main/resources/assets/hbm/textures/items/ammo_arty.he.png rename to src/main/resources/assets/hbm/textures/items/ammo_arty_he.png diff --git a/src/main/resources/assets/hbm/textures/items/ammo_arty.mini_nuke.png b/src/main/resources/assets/hbm/textures/items/ammo_arty_mini_nuke.png similarity index 100% rename from src/main/resources/assets/hbm/textures/items/ammo_arty.mini_nuke.png rename to src/main/resources/assets/hbm/textures/items/ammo_arty_mini_nuke.png diff --git a/src/main/resources/assets/hbm/textures/items/ammo_arty.mini_nuke_multi.png b/src/main/resources/assets/hbm/textures/items/ammo_arty_mini_nuke_multi.png similarity index 100% rename from src/main/resources/assets/hbm/textures/items/ammo_arty.mini_nuke_multi.png rename to src/main/resources/assets/hbm/textures/items/ammo_arty_mini_nuke_multi.png diff --git a/src/main/resources/assets/hbm/textures/items/ammo_arty.nuke.png b/src/main/resources/assets/hbm/textures/items/ammo_arty_nuke.png similarity index 100% rename from src/main/resources/assets/hbm/textures/items/ammo_arty.nuke.png rename to src/main/resources/assets/hbm/textures/items/ammo_arty_nuke.png diff --git a/src/main/resources/assets/hbm/textures/items/ammo_arty.phosphorus.png b/src/main/resources/assets/hbm/textures/items/ammo_arty_phosphorus.png similarity index 100% rename from src/main/resources/assets/hbm/textures/items/ammo_arty.phosphorus.png rename to src/main/resources/assets/hbm/textures/items/ammo_arty_phosphorus.png diff --git a/src/main/resources/assets/hbm/textures/items/ammo_arty.phosphorus_multi.png b/src/main/resources/assets/hbm/textures/items/ammo_arty_phosphorus_multi.png similarity index 100% rename from src/main/resources/assets/hbm/textures/items/ammo_arty.phosphorus_multi.png rename to src/main/resources/assets/hbm/textures/items/ammo_arty_phosphorus_multi.png