From c72e20a7ef5c8afd36f3579717f99e8b4c426e96 Mon Sep 17 00:00:00 2001 From: ScriptedPiky <41557212+ScriptedPiky@users.noreply.github.com> Date: Wed, 30 Mar 2022 12:53:57 -0700 Subject: [PATCH 1/7] Set "weight" to 0 for testing What will happen if the weight is 0? Time to find out! --- .../common/summoning/meteor/MeteorParadigm.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java index 31526973..0312ad96 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java @@ -61,11 +61,11 @@ public class MeteorParadigm if (hasOrbisTerrae) { newRadius += 2; - chance += 200; + chance += 0; } else if (hasTerrae) { newRadius += 1; - chance += 100; + chance += 0; } world.createExplosion(null, x, y, z, newRadius * 4, AlchemicalWizardry.doMeteorsDestroyBlocks); From 366a22908f8e3a805cfd8524737d72fcb0c7d078 Mon Sep 17 00:00:00 2001 From: ScriptedPiky <41557212+ScriptedPiky@users.noreply.github.com> Date: Wed, 30 Mar 2022 13:11:45 -0700 Subject: [PATCH 2/7] Experimental Additions Based on what BigFluf (211200168656240642) on Discord stated: "If this works you should be able to change the weights in the configs to any number you like, and it'll just use those as relative chances and never add any 'filler' blocks like the stone So for example if you have a meteor with just Black Granite with weight 1 and Iron Ore with weight 1, both would have 50% chance Or you could put both at 1 million and it'd still be the same Just make sure the new meteor GUI is changed in the same way if possible, otherwise the ore chances will be inaccurate" --- .../common/summoning/meteor/MeteorParadigm.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java index 0312ad96..3d26812a 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java @@ -76,6 +76,8 @@ public class MeteorParadigm float totalChance = iceChance + soulChance + obsidChance; + int randNum = world.rand.nextInt(totalMeteorWeight); + for (int i = -newRadius; i <= newRadius; i++) { for (int j = -newRadius; j <= newRadius; j++) @@ -92,7 +94,7 @@ public class MeteorParadigm continue; } - int randNum = world.rand.nextInt(chance); + int randNum = world.rand.nextInt(totalMeteorWeight); boolean hasPlacedBlock = false; for (MeteorParadigmComponent mpc : componentList) From 801a8548f23e24997a23845ad4af45b5d31bae9c Mon Sep 17 00:00:00 2001 From: Bigfluf <34474265+Bigfluf@users.noreply.github.com> Date: Thu, 31 Mar 2022 01:38:14 +0200 Subject: [PATCH 3/7] Update MeteorParadigm.java Removed hardcoded maxChance and chance at fixed 1000 total weight, instead using dynamically calculated total weight of all the blocks in the meteor --- .../summoning/meteor/MeteorParadigm.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java index 3d26812a..f649b4bf 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java @@ -16,7 +16,6 @@ public class MeteorParadigm public ItemStack focusStack; public int radius; public int cost; - public static int maxChance = 1000; public static Random rand = new Random(); @@ -56,16 +55,13 @@ public class MeteorParadigm } int newRadius = radius; - int chance = maxChance; if (hasOrbisTerrae) { newRadius += 2; - chance += 0; } else if (hasTerrae) { newRadius += 1; - chance += 0; } world.createExplosion(null, x, y, z, newRadius * 4, AlchemicalWizardry.doMeteorsDestroyBlocks); @@ -75,9 +71,18 @@ public class MeteorParadigm float obsidChance = hasTennebrae ? 1 : 0; float totalChance = iceChance + soulChance + obsidChance; - - int randNum = world.rand.nextInt(totalMeteorWeight); + int totalMeteorWeight = 0; + for (MeteorParadigmComponent mpc : componentList) + { + if (mpc == null || !mpc.isValidBlockParadigm()) + { + continue; + } + + totalMeteorWeight += mpc.getChance(); + } + for (int i = -newRadius; i <= newRadius; i++) { for (int j = -newRadius; j <= newRadius; j++) @@ -95,6 +100,7 @@ public class MeteorParadigm } int randNum = world.rand.nextInt(totalMeteorWeight); + boolean hasPlacedBlock = false; for (MeteorParadigmComponent mpc : componentList) From d8b0fa1cc97aafca9bc190ca4a6f343d9b788b39 Mon Sep 17 00:00:00 2001 From: Bigfluf <34474265+Bigfluf@users.noreply.github.com> Date: Thu, 31 Mar 2022 01:41:00 +0200 Subject: [PATCH 4/7] Update NEIMeteorRecipeHandler.java --- .../client/nei/NEIMeteorRecipeHandler.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java index 169cfb58..acaeacd8 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java @@ -36,6 +36,16 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { this.input.add(new PositionedStack(meteor.focusStack, 74, 4)); int row = 0; int col = 0; + + float totalMeteorWeight = 0.0f; + for (MeteorParadigmComponent component : meteor.componentList) { + ItemStack stack = component.getValidBlockParadigm(); + if (stack == null) { + continue; + } + totalMeteorWeight += component.getChance(); + } + for (MeteorParadigmComponent component : meteor.componentList) { ItemStack stack = component.getValidBlockParadigm(); List tooltips = new ArrayList<>(); @@ -43,7 +53,7 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { stack = new ItemStack(Blocks.fire); tooltips.add(String.format("no entries found for oredict \"%s\"", component.getOreDictName())); } - tooltips.add(I18n.format("nei.recipe.meteor.chance", getFormattedChance(component.getChance()))); + tooltips.add(I18n.format("nei.recipe.meteor.chance", getFormattedChance(component.getChance() / totalMeteorWeight))); this.outputs.add(new TooltipStack(stack, 3 + 18 * col, 37 + 18 * row, tooltips)); col++; if (col > 8) { @@ -171,9 +181,9 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { .collect(Collectors.toList()); } - private String getFormattedChance(int chance) { - float percentage = (float) chance / 10; - boolean isInteger = Float.compare(percentage, (float) (chance / 10)) == 0; + private String getFormattedChance(float chance) { + float percentage = chance * 100.0f; + boolean isInteger = percentage - (int) percentage <= 0.01; if (isInteger) return String.format("%,d", (int) percentage); else return String.format("%,.1f", percentage); } From 5c930a479f4f32b482a26476af82d2234ad959c8 Mon Sep 17 00:00:00 2001 From: Bigfluf <34474265+Bigfluf@users.noreply.github.com> Date: Thu, 31 Mar 2022 01:43:41 +0200 Subject: [PATCH 5/7] Update BloodMagicConfiguration.java --- .../WayofTime/alchemicalWizardry/BloodMagicConfiguration.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java b/src/main/java/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java index fa110fc7..ba732f06 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java +++ b/src/main/java/WayofTime/alchemicalWizardry/BloodMagicConfiguration.java @@ -101,7 +101,6 @@ public class BloodMagicConfiguration AlchemicalWizardry.customPotionDemonCloakID = config.get("Potion ID", "DemonCloak", 115).getInt(); AlchemicalWizardry.customPotionAmphibianID = config.get("Potion ID", "Amphibian", 116).getInt(); - MeteorParadigm.maxChance = config.get("meteor", "maxChance", 1000).getInt(); AlchemicalWizardry.doMeteorsDestroyBlocks = config.get("meteor", "doMeteorsDestroyBlocks", true).getBoolean(true); AlchemicalWizardry.allowedCrushedOresArray = config.get("oreCrushing", "allowedOres", new String[]{"iron", "gold", "copper", "tin", "lead", "silver", "osmium"}).getStringList(); From 00f9fa1add03ff8890c4f94abd41b9a4d2fdf48f Mon Sep 17 00:00:00 2001 From: Bigfluf <34474265+Bigfluf@users.noreply.github.com> Date: Fri, 8 Apr 2022 12:01:27 +0200 Subject: [PATCH 6/7] Added getTotalMeteorWeight function Moved loop to calculate total weight to it's own function, used in NEI tab as well --- .../summoning/meteor/MeteorParadigm.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java index f649b4bf..3e51f5e4 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/summoning/meteor/MeteorParadigm.java @@ -36,6 +36,21 @@ public class MeteorParadigm componentList.add(mpc); } } + + public int getTotalMeteorWeight() + { + int totalMeteorWeight = 0; + for (MeteorParadigmComponent mpc : componentList) + { + if (mpc == null || !mpc.isValidBlockParadigm()) + { + continue; + } + + totalMeteorWeight += mpc.getChance(); + } + return totalMeteorWeight; + } public void createMeteorImpact(World world, int x, int y, int z, boolean[] flags) { @@ -72,16 +87,7 @@ public class MeteorParadigm float totalChance = iceChance + soulChance + obsidChance; - int totalMeteorWeight = 0; - for (MeteorParadigmComponent mpc : componentList) - { - if (mpc == null || !mpc.isValidBlockParadigm()) - { - continue; - } - - totalMeteorWeight += mpc.getChance(); - } + int totalMeteorWeight = getTotalMeteorWeight(); for (int i = -newRadius; i <= newRadius; i++) { From 1593b5482bd0579b2f3d5d86f86a8ff62c7350f7 Mon Sep 17 00:00:00 2001 From: Bigfluf <34474265+Bigfluf@users.noreply.github.com> Date: Fri, 8 Apr 2022 12:03:48 +0200 Subject: [PATCH 7/7] Using getTotalMeteorWeight function Changed copy-pasted weight calculation code to function call for getTotalMeteorWeight --- .../client/nei/NEIMeteorRecipeHandler.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java index acaeacd8..137ede95 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java @@ -37,14 +37,7 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { int row = 0; int col = 0; - float totalMeteorWeight = 0.0f; - for (MeteorParadigmComponent component : meteor.componentList) { - ItemStack stack = component.getValidBlockParadigm(); - if (stack == null) { - continue; - } - totalMeteorWeight += component.getChance(); - } + float totalMeteorWeight = meteor.getTotalMeteorWeight(); for (MeteorParadigmComponent component : meteor.componentList) { ItemStack stack = component.getValidBlockParadigm();