mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-13 16:54:21 +00:00
Meteor weight changes (#21)
* Set "weight" to 0 for testing What will happen if the weight is 0? Time to find out! * 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" * 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 * Update NEIMeteorRecipeHandler.java * Update BloodMagicConfiguration.java * Added getTotalMeteorWeight function Moved loop to calculate total weight to it's own function, used in NEI tab as well * Using getTotalMeteorWeight function Changed copy-pasted weight calculation code to function call for getTotalMeteorWeight Co-authored-by: ScriptedPiky <41557212+ScriptedPiky@users.noreply.github.com>
This commit is contained in:
1 parent
79cab43a65
commit
595bd797fd
3 files changed
+26
-10
No files matched your search
@@ -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();
|
||||
|
||||
|
||||
@@ -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<String> 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);
|
||||
}
|
||||
|
||||
+19
-5
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user