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); | |
} |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
because mob loot pools have very little variance in weight, it does not impact them much unless mojang adds a higher weight item to pool:
300 witches no luck
69 redstone, 78 sugar, 88 gunpowder, 69 eyes, 69 bottles, 138 sticks, 67 glowstone
300 witches 10 luck
72 redstone, 77 sugar, 57 gunpowder, 68 eyes, 85 bottles, 132 sticks, 68 glowstone
results from chests was greatly seen.
1 book out of 30 and 1 chest with 2 diamonds out of 30 with no luck
4 chest with diamonds (1 had like 6), 4 with books out of 30 with 10 luck