13
0
geforkt von Mirrors/Paper

remove already applied

net/minecraft/world/level/storage/loot
Dieser Commit ist enthalten in:
Owen1212055 2024-12-14 17:29:33 -05:00
Ursprung d096e6baaf
Commit f2f3b06179
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 2133292072886A30
2 geänderte Dateien mit 0 neuen und 107 gelöschten Zeilen

Datei anzeigen

@ -1,22 +0,0 @@
--- a/net/minecraft/world/level/storage/loot/LootDataType.java
+++ b/net/minecraft/world/level/storage/loot/LootDataType.java
@@ -9,6 +9,11 @@
import net.minecraft.world.level.storage.loot.functions.LootItemFunctions;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
+// CraftBukkit start
+import org.bukkit.craftbukkit.CraftLootTable;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+// CraftBukkit end
+
public record LootDataType<T>(ResourceKey<Registry<T>> registryKey, Codec<T> codec, LootDataType.Validator<T> validator) {
public static final LootDataType<LootItemCondition> PREDICATE = new LootDataType<>(Registries.PREDICATE, LootItemCondition.DIRECT_CODEC, createSimpleValidator());
@@ -32,6 +37,7 @@
private static LootDataType.Validator<LootTable> createLootTableValidator() {
return (lootcollector, resourcekey, loottable) -> {
loottable.validate(lootcollector.setContextKeySet(loottable.getParamSet()).enterElement("{" + String.valueOf(resourcekey.registry()) + "/" + String.valueOf(resourcekey.location()) + "}", resourcekey));
+ loottable.craftLootTable = new CraftLootTable(CraftNamespacedKey.fromMinecraft(resourcekey.location()), loottable); // CraftBukkit
};
}

Datei anzeigen

@ -1,85 +0,0 @@
--- a/net/minecraft/world/level/storage/loot/LootTable.java
+++ b/net/minecraft/world/level/storage/loot/LootTable.java
@@ -31,6 +31,13 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import org.slf4j.Logger;
+// CraftBukkit start
+import org.bukkit.craftbukkit.CraftLootTable;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.world.LootGenerateEvent;
+// CraftBukkit end
+
public class LootTable {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -54,6 +61,7 @@
private final List<LootPool> pools;
private final List<LootItemFunction> functions;
private final BiFunction<ItemStack, LootContext, ItemStack> compositeFunction;
+ public CraftLootTable craftLootTable; // CraftBukkit
LootTable(ContextKeySet type, Optional<ResourceLocation> randomSequenceId, List<LootPool> pools, List<LootItemFunction> functions) {
this.paramSet = type;
@@ -64,9 +72,10 @@
}
public static Consumer<ItemStack> createStackSplitter(ServerLevel world, Consumer<ItemStack> consumer) {
+ boolean skipSplitter = world != null && !world.paperConfig().fixes.splitOverstackedLoot; // Paper - preserve overstacked items
return (itemstack) -> {
if (itemstack.isItemEnabled(world.enabledFeatures())) {
- if (itemstack.getCount() < itemstack.getMaxStackSize()) {
+ if (skipSplitter || itemstack.getCount() < itemstack.getMaxStackSize()) { // Paper - preserve overstacked items
consumer.accept(itemstack);
} else {
int i = itemstack.getCount();
@@ -157,10 +166,23 @@
}
public void fill(Container inventory, LootParams parameters, long seed) {
- LootContext loottableinfo = (new LootContext.Builder(parameters)).withOptionalRandomSeed(seed).create(this.randomSequence);
+ // CraftBukkit start
+ this.fillInventory(inventory, parameters, seed, false);
+ }
+
+ public void fillInventory(Container iinventory, LootParams lootparams, long i, boolean plugin) {
+ // CraftBukkit end
+ LootContext loottableinfo = (new LootContext.Builder(lootparams)).withOptionalRandomSeed(i).create(this.randomSequence);
ObjectArrayList<ItemStack> objectarraylist = this.getRandomItems(loottableinfo);
RandomSource randomsource = loottableinfo.getRandom();
- List<Integer> list = this.getAvailableSlots(inventory, randomsource);
+ // CraftBukkit start
+ LootGenerateEvent event = CraftEventFactory.callLootGenerateEvent(iinventory, this, loottableinfo, objectarraylist, plugin);
+ if (event.isCancelled()) {
+ return;
+ }
+ objectarraylist = event.getLoot().stream().map(CraftItemStack::asNMSCopy).collect(ObjectArrayList.toList());
+ // CraftBukkit end
+ List<Integer> list = this.getAvailableSlots(iinventory, randomsource);
this.shuffleAndSplitItems(objectarraylist, list.size(), randomsource);
ObjectListIterator objectlistiterator = objectarraylist.iterator();
@@ -174,9 +196,9 @@
}
if (itemstack.isEmpty()) {
- inventory.setItem((Integer) list.remove(list.size() - 1), ItemStack.EMPTY);
+ iinventory.setItem((Integer) list.remove(list.size() - 1), ItemStack.EMPTY);
} else {
- inventory.setItem((Integer) list.remove(list.size() - 1), itemstack);
+ iinventory.setItem((Integer) list.remove(list.size() - 1), itemstack);
}
}
@@ -238,8 +260,8 @@
public static class Builder implements FunctionUserBuilder<LootTable.Builder> {
- private final Builder<LootPool> pools = ImmutableList.builder();
- private final Builder<LootItemFunction> functions = ImmutableList.builder();
+ private final ImmutableList.Builder<LootPool> pools = ImmutableList.builder();
+ private final ImmutableList.Builder<LootItemFunction> functions = ImmutableList.builder();
private ContextKeySet paramSet;
private Optional<ResourceLocation> randomSequence;