diff --git a/src/main/java/api/hbm/fluidmk2/package-info.java b/src/main/java/api/hbm/fluidmk2/package-info.java index b948336d8..fae3f6c16 100644 --- a/src/main/java/api/hbm/fluidmk2/package-info.java +++ b/src/main/java/api/hbm/fluidmk2/package-info.java @@ -1,10 +1,3 @@ -/** - * - */ -/** - * @author hbm - * - */ package api.hbm.fluidmk2; /* @@ -13,4 +6,19 @@ It's rather shrimple: the shiny new energy system using universal nodespace, but Has a few extra bits and pieces for handling, but the concept is basically the same. Sounds good? +*/ + +/* + +Quick explanation for implementing new fluids via addon: +Fluids are subject to /ntmreload so they get wiped and rebuilt using the init function in Fluids, which means that if fluids +are simply added externally during startup, they are removed permanently until the game restarts. Same concept as with recipes, really. +To fix this we need to make sure that externally registered fluids are re-registered during reload, for that purpose we have +IFluidRegisterListener, a simple interface with a small method that runs whenever the fluid list is reloaded. IFluidRegisterListeners +need to be registered with CompatExternal.registerFluidRegisterListener to be used, make sure to do this during PreInit. +Inside the IFluidRegisterListener, fluids can be added using CompatFluidRegistry.registerFluid, which will generate a Fluid instance +using the supplied arguments and automatically register it. Do note that like with custom fluids, fluids need numeric IDs assigned manually. +To prevent collisions with stock fluids when NTM updates, make sure to choose a high starting ID (e.g. 10,000). +The fluid created by registerFluid can have traits added to them, just like how NTM does it with its stock fluids. + */ \ No newline at end of file diff --git a/src/main/java/com/hbm/inventory/fluid/FluidType.java b/src/main/java/com/hbm/inventory/fluid/FluidType.java index 4cecc13a5..f983c90ed 100644 --- a/src/main/java/com/hbm/inventory/fluid/FluidType.java +++ b/src/main/java/com/hbm/inventory/fluid/FluidType.java @@ -109,6 +109,7 @@ public class FluidType { this.id = id; Fluids.register(this, id); + Fluids.foreignFluids.add(this); } public FluidType setTemp(int temperature) { diff --git a/src/main/java/com/hbm/inventory/fluid/Fluids.java b/src/main/java/com/hbm/inventory/fluid/Fluids.java index 1a0b5dcd2..cadd39969 100644 --- a/src/main/java/com/hbm/inventory/fluid/Fluids.java +++ b/src/main/java/com/hbm/inventory/fluid/Fluids.java @@ -197,6 +197,7 @@ public class Fluids { public static final HashBiMap renameMapping = HashBiMap.create(); public static List customFluids = new ArrayList(); + public static List foreignFluids = new ArrayList(); private static final HashMap idMapping = new HashMap(); private static final HashMap nameMapping = new HashMap(); @@ -593,8 +594,6 @@ public class Fluids { // LEGACY ACID = PEROXIDE; - - for(IFluidRegisterListener listener : additionalListeners) listener.onFluidsLoad(); for(FluidType custom : customFluids) metaOrder.add(custom); @@ -877,10 +876,12 @@ public class Fluids { ex.printStackTrace(); } } + public static void reloadFluids(){ File folder = MainRegistry.configHbmDir; File customTypes = new File(folder.getAbsolutePath() + File.separatorChar + "hbmFluidTypes.json"); if(!customTypes.exists()) initDefaultFluids(customTypes); + for(FluidType type : customFluids){ idMapping.remove(type.getID()); registerOrder.remove(type); @@ -888,6 +889,15 @@ public class Fluids { metaOrder.remove(type); } customFluids.clear(); + + for(FluidType type : foreignFluids){ + idMapping.remove(type.getID()); + registerOrder.remove(type); + nameMapping.remove(type.getName()); + metaOrder.remove(type); + } + foreignFluids.clear(); + readCustomFluids(customTypes); for(FluidType custom : customFluids) metaOrder.add(custom); File config = new File(MainRegistry.configHbmDir.getAbsolutePath() + File.separatorChar + "hbmFluidTraits.json"); @@ -898,6 +908,8 @@ public class Fluids { } else { readTraits(config); } + + for(IFluidRegisterListener listener : additionalListeners) listener.onFluidsLoad(); } private static void registerCalculatedFuel(FluidType type, double base, double combustMult, FuelGrade grade) { diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java index b8bbe7266..dddfbeda4 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java @@ -933,23 +933,24 @@ public class Orchestras { if(entity.worldObj.isRemote) return; AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); + boolean aiming = ItemGunBaseNT.getIsAiming(stack); if(type == AnimType.CYCLE) { if(timer == 0 && ctx.config.getReceivers(stack)[0].getMagazine(stack).getType(stack, null) == XFactory12ga.g12_equestrian_bj) { ItemGunBaseNT.setTimer(stack, 0, 20); } + + if(timer == 2) { + SpentCasing casing = ctx.config.getReceivers(stack)[0].getMagazine(stack).getCasing(stack, ctx.inventory); + if(casing != null) CasingCreator.composeEffect(entity.worldObj, entity, 0.375, -0.125, aiming ? -0.125 : -0.25D, 0, 0.18, -0.12, 0.01, -10F + (float)entity.getRNG().nextGaussian() * 2.5F, (float)entity.getRNG().nextGaussian() * -20F + 15F, casing.getName(), false, 60, 0.5D, 20); + } } if(type == AnimType.CYCLE_DRY) { if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); } if(type == AnimType.RELOAD) { - if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 32) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); - } - if(type == AnimType.INSPECT) { - if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magRemove", 1F, 1F); - if(timer == 28) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.magInsert", 1F, 1F); + if(timer == 55) ctx.config.getReceivers(stack)[0].getMagazine(stack).reloadAction(stack, ctx.inventory); } }; diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java index 24df3eeff..abd376759 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory12ga.java @@ -375,9 +375,9 @@ public class XFactory12ga { ).setUnlocalizedName("gun_autoshotgun_shredder"); ModItems.gun_autoshotgun_sexy = new ItemGunBaseNT(WeaponQuality.LEGENDARY, new GunConfig() - .dura(5_000).draw(10).inspect(33).reloadSequential(true).crosshair(Crosshair.L_CIRCLE).smoke(Lego.LAMBDA_STANDARD_SMOKE) + .dura(5_000).draw(20).inspect(33).reloadSequential(true).crosshair(Crosshair.L_CIRCLE).smoke(Lego.LAMBDA_STANDARD_SMOKE) .rec(new Receiver(0) - .dmg(64F).delay(4).auto(true).dryfireAfterAuto(true).reload(44).jam(19).sound("hbm:weapon.fire.shotgunAuto", 1.0F, 1.0F) + .dmg(64F).delay(4).auto(true).dryfireAfterAuto(true).reload(110).jam(19).sound("hbm:weapon.fire.shotgunAuto", 1.0F, 1.0F) .mag(new MagazineFullReload(0, 100).addConfigs(g12_equestrian_bj, g12_bp, g12_bp_magnum, g12_bp_slug, g12, g12_slug, g12_flechette, g12_magnum, g12_explosive, g12_phosphorus)) .offset(0.75, -0.125, -0.25) .setupStandardFire().recoil(LAMBDA_RECOIL_SEXY)) @@ -653,17 +653,25 @@ public class XFactory12ga { @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_SEXY_ANIMS = (stack, type) -> { switch(type) { - case CYCLE: return new BusAnimation() + case EQUIP: return new BusAnimation() + .addBus("EQUIP", new BusAnimationSequence().addPos(45, 0, 0, 0).addPos(0, 0, 0, 1000, IType.SIN_DOWN)); + case CYCLE: + int amount = ((ItemGunBaseNT) stack.getItem()).getConfig(stack, 0).getReceivers(stack)[0].getMagazine(stack).getAmount(stack, null); + return new BusAnimation() .addBus("RECOIL", new BusAnimationSequence().hold(50).addPos(0, 0, -0.25, 50, IType.SIN_DOWN).addPos(0, 0, 0, 100, IType.SIN_FULL)) .addBus("BARREL", new BusAnimationSequence().addPos(0, 0, -1, 50, IType.SIN_DOWN).addPos(0, 0, 0, 150)) .addBus("CYCLE", new BusAnimationSequence().addPos(1, 0, 0, 150)) - .addBus("HOOD", new BusAnimationSequence().hold(50).addPos(3, 0, 0, 50, IType.SIN_DOWN).addPos(0, 0, 0, 50, IType.SIN_UP)); + .addBus("HOOD", new BusAnimationSequence().hold(50).addPos(3, 0, 0, 50, IType.SIN_DOWN).addPos(0, 0, 0, 50, IType.SIN_UP)) + .addBus("SHELLS", new BusAnimationSequence().setPos(amount - 1, 0, 0)); case CYCLE_DRY: return new BusAnimation() .addBus("CYCLE", new BusAnimationSequence().addPos(0, 0, 18, 50)); case RELOAD: return new BusAnimation() - .addBus("LEVER", new BusAnimationSequence().addPos(0, 0, 1, 150).hold(2750).addPos(0, 0, 0, 150)) - .addBus("HOOD", new BusAnimationSequence().hold(250).addPos(60, 0, 0, 500, IType.SIN_FULL).hold(1500).addPos(0, 0, 0, 500, IType.SIN_FULL)) - .addBus("BELT", new BusAnimationSequence().setPos(1, 0, 0).hold(750).addPos(0, 0, 0, 500, IType.SIN_FULL).hold(500).addPos(1, 0, 0, 500, IType.SIN_FULL)); + .addBus("LOWER", new BusAnimationSequence().addPos(15, 0, 0, 500, IType.SIN_FULL).hold(2750).addPos(12, 0, 0, 100, IType.SIN_DOWN).addPos(15, 0, 0, 100, IType.SIN_FULL).hold(1050).addPos(18, 0, 0, 100, IType.SIN_DOWN).addPos(15, 0, 0, 100, IType.SIN_FULL).hold(300).addPos(0, 0, 0, 500, IType.SIN_FULL)) + .addBus("LEVER", new BusAnimationSequence().addPos(0, 0, 1, 150).hold(4700).addPos(0, 0, 0, 150)) + .addBus("HOOD", new BusAnimationSequence().hold(250).addPos(60, 0, 0, 500, IType.SIN_FULL).hold(3250).addPos(0, 0, 0, 500, IType.SIN_UP)) + .addBus("BELT", new BusAnimationSequence().setPos(1, 0, 0).hold(750).addPos(0, 0, 0, 500, IType.SIN_UP).hold(2000).addPos(1, 0, 0, 500, IType.SIN_UP)) + .addBus("MAG", new BusAnimationSequence().hold(1500).addPos(0, -1, 0, 250, IType.SIN_UP).addPos(2, -1, 0, 500, IType.SIN_UP).addPos(7, 1, 0, 250, IType.SIN_UP).addPos(15, 2, 0, 250).setPos(0, -2, 0).addPos(0, 0, 0, 500, IType.SIN_UP)) + .addBus("MAGROT", new BusAnimationSequence().hold(2250).addPos(0, 0, -180, 500, IType.SIN_FULL).setPos(0, 0, 0)); } return null; diff --git a/src/main/java/com/hbm/main/MainRegistry.java b/src/main/java/com/hbm/main/MainRegistry.java index ab9f2f995..0826c53bd 100644 --- a/src/main/java/com/hbm/main/MainRegistry.java +++ b/src/main/java/com/hbm/main/MainRegistry.java @@ -899,10 +899,14 @@ public class MainRegistry { Compat.handleRailcraftNonsense(); SuicideThreadDump.register(); CommandReloadClient.register(); + + // to make sure that foreign registered fluids are accounted for, + // even when the reload listener is registered too late due to load order + Fluids.reloadFluids(); //ExplosionTests.runTest(); } - + @EventHandler public void preInit(FMLPreInitializationEvent event) { if(logger == null) diff --git a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderSexy.java b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderSexy.java index 901d129fd..c237a95e4 100644 --- a/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderSexy.java +++ b/src/main/java/com/hbm/render/item/weapon/sedna/ItemRenderSexy.java @@ -48,18 +48,27 @@ public class ItemRenderSexy extends ItemRenderWeaponBase { boolean doesCycle = HbmAnimations.getRelevantAnim(0) != null && HbmAnimations.getRelevantAnim(0).animation.getBus("CYCLE") != null; boolean reloading = HbmAnimations.getRelevantAnim(0) != null && HbmAnimations.getRelevantAnim(0).animation.getBus("BELT") != null; + boolean useShellCount = HbmAnimations.getRelevantAnim(0) != null && HbmAnimations.getRelevantAnim(0).animation.getBus("SHELLS") != null; double[] equip = HbmAnimations.getRelevantTransformation("EQUIP"); + double[] lower = HbmAnimations.getRelevantTransformation("LOWER"); double[] recoil = HbmAnimations.getRelevantTransformation("RECOIL"); double[] cycle = HbmAnimations.getRelevantTransformation("CYCLE"); double[] barrel = HbmAnimations.getRelevantTransformation("BARREL"); double[] hood = HbmAnimations.getRelevantTransformation("HOOD"); double[] lever = HbmAnimations.getRelevantTransformation("LEVER"); double[] belt = HbmAnimations.getRelevantTransformation("BELT"); + double[] mag = HbmAnimations.getRelevantTransformation("MAG"); + double[] magRot = HbmAnimations.getRelevantTransformation("MAGROT"); + double[] shellCount = HbmAnimations.getRelevantTransformation("SHELLS"); GL11.glTranslated(0, -1, -8); GL11.glRotated(equip[0], 1, 0, 0); GL11.glTranslated(0, 1, 8); + GL11.glTranslated(0, 0, -6); + GL11.glRotated(lower[0], 1, 0, 0); + GL11.glTranslated(0, 0, 6); + GL11.glTranslated(0, 0, recoil[2]); GL11.glShadeModel(GL11.GL_SMOOTH); @@ -72,9 +81,9 @@ public class ItemRenderSexy extends ItemRenderWeaponBase { GL11.glPopMatrix(); GL11.glPushMatrix(); - GL11.glTranslated(0, 0, 0.375); - //GL11.glScaled(1, 1, 0.75); GL11.glTranslated(0, 0, -0.375); + GL11.glScaled(1, 1, 1 + 0.457247371D * barrel[2]); + GL11.glTranslated(0, 0, 0.375); ResourceManager.sexy.renderPart("RecoilSpring"); GL11.glPopMatrix(); @@ -99,6 +108,11 @@ public class ItemRenderSexy extends ItemRenderWeaponBase { ResourceManager.sexy.renderPart("LockSpring"); GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(mag[0], mag[1], mag[2]); + GL11.glTranslated(0, -1, 0); + GL11.glRotated(magRot[2], 0, 0, 1); + GL11.glTranslated(0, 1, 0); ResourceManager.sexy.renderPart("Magazine"); double p = 0.0625D; @@ -129,15 +143,15 @@ public class ItemRenderSexy extends ItemRenderWeaponBase { y += vec.yCoord; } + int shellAmount = useShellCount ? (int) shellCount[0] : gun.getConfig(stack, 0).getReceivers(stack)[0].getMagazine(stack).getAmount(stack, null); + // draw belt, interp used for cycling (shells will transform towards the position/rotation of the next shell) for(int i = 0; i < shells.length - 1; i++) { double[] prevShell = shells[i]; double[] nextShell = shells[i + 1]; - renderShell( - BobMathUtil.interp(prevShell[0], nextShell[0], cycleProgress), - BobMathUtil.interp(prevShell[1], nextShell[1], cycleProgress), - BobMathUtil.interp(prevShell[2], nextShell[2], cycleProgress), true); + renderShell(prevShell[0], nextShell[0], prevShell[1], nextShell[1], prevShell[2], nextShell[2], shells.length - i < shellAmount + 2, cycleProgress); } + GL11.glPopMatrix(); GL11.glShadeModel(GL11.GL_FLAT); }