Make Tadpole apply

This commit is contained in:
Nassim Jahnke 2024-12-13 18:55:47 +01:00
parent b97663fdf9
commit e20952c643
No known key found for this signature in database
GPG key ID: EF6771C01F6EF02F
2 changed files with 22 additions and 15 deletions

View file

@ -18,17 +18,17 @@
}
}
@@ -122,12 +_,14 @@
public void addAdditionalSaveData(CompoundTag tag) {
super.addAdditionalSaveData(tag);
tag.putInt("Age", this.age);
+ tag.putBoolean("AgeLocked", this.ageLocked); // Paper
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("Age", this.age);
+ compound.putBoolean("AgeLocked", this.ageLocked); // Paper
}
@Override
public void readAdditionalSaveData(CompoundTag tag) {
super.readAdditionalSaveData(tag);
this.setAge(tag.getInt("Age"));
+ this.ageLocked = tag.getBoolean("AgeLocked"); // Paper
public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
this.setAge(compound.getInt("Age"));
+ this.ageLocked = compound.getBoolean("AgeLocked"); // Paper
}
@Nullable

View file

@ -1,10 +1,21 @@
--- a/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java
+++ b/net/minecraft/world/level/storage/loot/entries/LootPoolSingletonContainer.java
@@ -126,9 +126,35 @@
@@ -32,6 +_,10 @@
);
}
};
+ // Paper start - Configurable LootPool luck formula
+ private Float lastLuck;
+ private int lastWeight;
+ // Paper end - Configurable LootPool luck formula
protected LootPoolSingletonContainer(int weight, int quality, List<LootItemCondition> conditions, List<LootItemFunction> functions) {
super(conditions);
@@ -126,7 +_,31 @@
protected abstract class EntryBase implements LootPoolEntry {
@Override
public int getWeight(float luck) {
- return Math.max(Mth.floor((float)LootPoolSingletonContainer.this.weight + (float)LootPoolSingletonContainer.this.quality * luck), 0);
- return Math.max(Mth.floor(LootPoolSingletonContainer.this.weight + LootPoolSingletonContainer.this.quality * luck), 0);
+ // Paper start - Configurable LootPool luck formula
+ // SEE: https://luckformula.emc.gs for details and data
+ if (LootPoolSingletonContainer.this.lastLuck != null && LootPoolSingletonContainer.this.lastLuck == luck) {
@ -29,11 +40,7 @@
+ LootPoolSingletonContainer.this.lastLuck = luck;
+ LootPoolSingletonContainer.this.lastWeight = (int) Math.max(Math.floor(baseWeight), 0);
+ return lastWeight;
+ // Paper end - Configurable LootPool luck formula
}
}
+ private Float lastLuck = null;
+ private int lastWeight = 0;
+ // Paper end - Configurable LootPool luck formula
@FunctionalInterface
protected interface EntryConstructor {