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(); diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java index 169cfb58..137ede95 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java @@ -36,6 +36,9 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { this.input.add(new PositionedStack(meteor.focusStack, 74, 4)); int row = 0; int col = 0; + + float totalMeteorWeight = meteor.getTotalMeteorWeight(); + for (MeteorParadigmComponent component : meteor.componentList) { ItemStack stack = component.getValidBlockParadigm(); List tooltips = new ArrayList<>(); @@ -43,7 +46,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 +174,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); } 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..3e51f5e4 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(); @@ -37,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) { @@ -56,16 +70,13 @@ public class MeteorParadigm } int newRadius = radius; - int chance = maxChance; if (hasOrbisTerrae) { newRadius += 2; - chance += 200; } else if (hasTerrae) { newRadius += 1; - chance += 100; } world.createExplosion(null, x, y, z, newRadius * 4, AlchemicalWizardry.doMeteorsDestroyBlocks); @@ -75,6 +86,8 @@ public class MeteorParadigm float obsidChance = hasTennebrae ? 1 : 0; float totalChance = iceChance + soulChance + obsidChance; + + int totalMeteorWeight = getTotalMeteorWeight(); for (int i = -newRadius; i <= newRadius; i++) { @@ -92,7 +105,8 @@ public class MeteorParadigm continue; } - int randNum = world.rand.nextInt(chance); + int randNum = world.rand.nextInt(totalMeteorWeight); + boolean hasPlacedBlock = false; for (MeteorParadigmComponent mpc : componentList)