From 273018a5c745ad37b962c2a596dc28f6cb0c5274 Mon Sep 17 00:00:00 2001 From: George Paton Date: Thu, 1 Feb 2024 12:07:04 +1100 Subject: [PATCH] Add correct shell colouring to KS23 --- .../hbm/handler/BulletConfigSyncingUtil.java | 2 +- .../java/com/hbm/handler/CasingEjector.java | 2 +- .../hbm/handler/guncfg/Gun4GaugeFactory.java | 2 ++ .../com/hbm/items/weapon/ItemGunBase.java | 21 +++++++++---------- .../item/weapon/ItemRenderWeaponKS23.java | 13 ++++++++---- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java b/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java index 3c2c2e7a3..29aaf510e 100644 --- a/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java +++ b/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java @@ -9,7 +9,7 @@ import com.hbm.items.ModItems; public class BulletConfigSyncingUtil { - private static HashMap configSet = new HashMap(); + private static HashMap configSet = new HashMap(); static int i = 0; diff --git a/src/main/java/com/hbm/handler/CasingEjector.java b/src/main/java/com/hbm/handler/CasingEjector.java index 94dd08a92..eda29d1a0 100644 --- a/src/main/java/com/hbm/handler/CasingEjector.java +++ b/src/main/java/com/hbm/handler/CasingEjector.java @@ -23,7 +23,7 @@ import net.minecraft.world.World; */ public class CasingEjector implements Cloneable { - public static HashMap mappings = new HashMap(); + public static HashMap mappings = new HashMap(); public static final Random rand = new Random(); private int id; diff --git a/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java b/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java index 8dfdc1d18..de94a6be9 100644 --- a/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/Gun4GaugeFactory.java @@ -81,6 +81,8 @@ public class Gun4GaugeFactory { config.firingSound = "hbm:weapon.revolverShootAlt"; config.firingPitch = 0.65F; + config.ejector = EJECTOR_SHOTGUN.clone().setDelay(10); + config.name = "ks23"; config.manufacturer = EnumGunManufacturer.TULSKY; diff --git a/src/main/java/com/hbm/items/weapon/ItemGunBase.java b/src/main/java/com/hbm/items/weapon/ItemGunBase.java index 406e65a81..bf24aa672 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunBase.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunBase.java @@ -115,7 +115,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu endActionClient(stack, world, entity, false); } - if(mainConfig.reloadType != mainConfig.RELOAD_NONE || (altConfig != null && altConfig.reloadType != 0)) { + if(mainConfig.reloadType != GunConfiguration.RELOAD_NONE || (altConfig != null && altConfig.reloadType != 0)) { if(GameSettings.isKeyDown(HbmKeybinds.reloadKey) && Minecraft.getMinecraft().currentScreen == null && (getMag(stack) < mainConfig.ammoCap || hasInfinity(stack, mainConfig))) { PacketDispatcher.wrapper.sendToServer(new GunButtonPacket(true, (byte) 2)); @@ -184,7 +184,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu protected boolean tryShoot(ItemStack stack, World world, EntityPlayer player, boolean main) { //cancel reload when trying to shoot if it's a single reload weapon and at least one round is loaded - if(getIsReloading(stack) && mainConfig.reloadType == mainConfig.RELOAD_SINGLE && this.getMag(stack) > 0) { + if(getIsReloading(stack) && mainConfig.reloadType == GunConfiguration.RELOAD_SINGLE && getMag(stack) > 0) { setReloadCycle(stack, 0); setIsReloading(stack, false); } @@ -208,7 +208,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu if(!main) config = altConfig; - if(config.reloadType == mainConfig.RELOAD_NONE) { + if(config.reloadType == GunConfiguration.RELOAD_NONE) { return getBeltSize(player, getBeltType(player, stack, main)) > 0; } else { @@ -222,7 +222,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu BulletConfiguration config = null; - if(mainConfig.reloadType == mainConfig.RELOAD_NONE) { + if(mainConfig.reloadType == GunConfiguration.RELOAD_NONE) { config = getBeltCfg(player, stack, true); } else { config = BulletConfigSyncingUtil.pullConfig(mainConfig.config.get(getMagType(stack))); @@ -261,13 +261,13 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu if(altConfig == null) return; - BulletConfiguration config = altConfig.reloadType == altConfig.RELOAD_NONE ? getBeltCfg(player, stack, false) : BulletConfigSyncingUtil.pullConfig(altConfig.config.get(getMagType(stack))); + BulletConfiguration config = altConfig.reloadType == GunConfiguration.RELOAD_NONE ? getBeltCfg(player, stack, false) : BulletConfigSyncingUtil.pullConfig(altConfig.config.get(getMagType(stack))); int bullets = config.bulletsMin; for(int k = 0; k < altConfig.roundsPerCycle; k++) { - if(altConfig.reloadType != altConfig.RELOAD_NONE && !hasAmmo(stack, player, true)) + if(altConfig.reloadType != GunConfiguration.RELOAD_NONE && !hasAmmo(stack, player, true)) break; if(config.bulletsMax > config.bulletsMin) @@ -355,9 +355,6 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu BulletConfiguration prevCfg = BulletConfigSyncingUtil.pullConfig(mainConfig.config.get(getMagType(stack))); - if(getMag(stack) == 0) - resetAmmoType(stack, world, player); - BulletConfiguration cfg = BulletConfigSyncingUtil.pullConfig(mainConfig.config.get(getMagType(stack))); ComparableStack ammo = (ComparableStack) cfg.ammo.copy(); @@ -403,6 +400,9 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu //initiates a reload public void startReloadAction(ItemStack stack, World world, EntityPlayer player) { + + if(getMag(stack) == 0) + resetAmmoType(stack, world, player); if(player.isSneaking() && hasInfinity(stack, mainConfig)) { @@ -494,8 +494,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD, IEqu addAdditionalInformation(stack, list); } - protected void addAdditionalInformation(ItemStack stack, List list) - { + protected void addAdditionalInformation(ItemStack stack, List list) { final BulletConfiguration bulletConfig = BulletConfigSyncingUtil.pullConfig(mainConfig.config.get(getMagType(stack))); list.add(I18nUtil.resolveKey(HbmCollection.gunDamage, bulletConfig.dmgMin, bulletConfig.dmgMax)); if(bulletConfig.bulletsMax != 1) diff --git a/src/main/java/com/hbm/render/item/weapon/ItemRenderWeaponKS23.java b/src/main/java/com/hbm/render/item/weapon/ItemRenderWeaponKS23.java index 9ede89c08..4160ee3f9 100644 --- a/src/main/java/com/hbm/render/item/weapon/ItemRenderWeaponKS23.java +++ b/src/main/java/com/hbm/render/item/weapon/ItemRenderWeaponKS23.java @@ -4,8 +4,10 @@ import java.awt.Color; import org.lwjgl.opengl.GL11; +import com.hbm.handler.BulletConfigSyncingUtil; +import com.hbm.handler.BulletConfiguration; +import com.hbm.items.weapon.ItemGunBase; import com.hbm.main.ResourceManager; -import com.hbm.particle.SpentCasing; import com.hbm.render.anim.HbmAnimations; import net.minecraft.client.Minecraft; @@ -83,12 +85,15 @@ public class ItemRenderWeaponKS23 implements IItemRenderer { HbmAnimations.applyRelevantTransformation("Shell"); - // TODO: Fetch the correct colors to render on the shells - Color shellColor = new Color(SpentCasing.COLOR_CASE_4GA); + ItemGunBase gun = (ItemGunBase)item.getItem(); + BulletConfiguration bullet = BulletConfigSyncingUtil.pullConfig(gun.mainConfig.config.get(ItemGunBase.getMagType(item))); + int[] colors = bullet.spentCasing.getColors(); + + Color shellColor = new Color(colors[1]); GL11.glColor3f(shellColor.getRed() / 255F, shellColor.getGreen() / 255F, shellColor.getBlue() / 255F); ResourceManager.ks23.renderPart("Shell"); - Color shellForeColor = new Color(0xFFD800); + Color shellForeColor = new Color(colors[0]); GL11.glColor3f(shellForeColor.getRed() / 255F, shellForeColor.getGreen() / 255F, shellForeColor.getBlue() / 255F); ResourceManager.ks23.renderPart("ShellFore");