Improved LootEntry#getEffectiveWeight - Makes Luck apply a modifier to weight so all loot pools get impact from luck, not just quality. Code licensed MIT - Mojang can use as WTFPL/no restrictions - please pull this into Minecraft Mojang!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Refactor how Loot bonus applies - | |
// V PCT = Vanilla Percent Chance, M PCT = Modified Percent Chance | |
/* base in these tables does not include vanilla quality modifer in this table, but does in code | |
BASE IMPACTED REDUCED V PCT M PCT PCT CHANGE | |
ITEM 1 400 12 388 26.67 27.75 1.087 | |
ITEM 2 100 0 100 6.67 7.15 0.486 | |
ITEM 3 1000 90 910 66.67 65.09 -1.574 | |
TOTAL 1500 1398 | |
LUCK (*10) 100 | |
BASE IMPACTED REDUCED V PCT M PCT PCT CHANGE | |
ITEM 1 4000 1560 3220 31.74 39.03 7.284 | |
ITEM 2 100 0 100 0.79 1.21 0.418 | |
ITEM 3 8500 7140 4930 67.46 59.76 -7.703 | |
TOTAL 12600 8250 | |
LUCK (*10) 50 | |
*/ | |
public int getEffectiveWeight(float luck) | |
{ | |
// This is vanilla | |
float qualityModifer = (float) this.getQuality() * luck; | |
// Random boost to avoid losing precision in the final int cast on return | |
final int weightBoost = 100; | |
// This is vanilla * our weight boost | |
double baseWeight = (this.getWeight() + qualityModifer) * weightBoost; | |
// If we have vanilla 1, bump that down to 0 so nothing is is impacted | |
// vanilla 3 = 300, 200 basis = impact 2% | |
// =($B2*(($B2-100)/100/100)) | |
double impacted = baseWeight * ((baseWeight - weightBoost) / weightBoost / 100); | |
// =($B$7/100) | |
float luckModifier = Math.min(100, luck * 10) / 100; | |
// =B2 - (C2 *($B$7/100)) | |
double reduced = Math.ceil(baseWeight - (impacted * luckModifier)); | |
return (int) Math.max(0, reduced); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
luck 3 30 chests, 7 diamond chest, 1 book (book is rarer)
luck 6, 30 chests, 8 diamonds, no books
luck 6, 30 chests, 4 diamonds, no books
showing good degrees of randomness
Note there are other 'rare' items in the pool that are generating I havent even been counting