@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/level/storage/loot/LootDataType.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/LootDataType.java
|
||||
@@ -16,6 +16,11 @@
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemConditions;
|
||||
@@ -15,6 +15,11 @@
|
||||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -9,10 +9,10 @@
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record LootDataType<T>(ResourceKey<IRegistry<T>> registryKey, Codec<T> codec, String directory, LootDataType.a<T> validator) {
|
||||
public record LootDataType<T>(ResourceKey<IRegistry<T>> registryKey, Codec<T> codec, LootDataType.a<T> validator) {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -49,6 +54,7 @@
|
||||
@@ -48,6 +53,7 @@
|
||||
private static LootDataType.a<LootTable> createLootTableValidator() {
|
||||
return (lootcollector, resourcekey, loottable) -> {
|
||||
loottable.validate(lootcollector.setParams(loottable.getParamSet()).enterElement("{" + String.valueOf(resourcekey.registry()) + "/" + String.valueOf(resourcekey.location()) + "}", resourcekey));
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
LootTable(LootContextParameterSet lootcontextparameterset, Optional<MinecraftKey> optional, List<LootSelector> list, List<LootItemFunction> list1) {
|
||||
this.paramSet = lootcontextparameterset;
|
||||
@@ -153,9 +161,22 @@
|
||||
@@ -157,9 +165,22 @@
|
||||
}
|
||||
|
||||
public void fill(IInventory iinventory, LootParams lootparams, long i) {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
--- a/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/functions/LootEnchantFunction.java
|
||||
@@ -57,8 +57,13 @@
|
||||
|
||||
if (entity instanceof EntityLiving) {
|
||||
int i = EnchantmentManager.getMobLooting((EntityLiving) entity);
|
||||
+ // CraftBukkit start - use lootingModifier if set by plugin
|
||||
+ if (loottableinfo.hasParam(LootContextParameters.LOOTING_MOD)) {
|
||||
+ i = loottableinfo.getParamOrNull(LootContextParameters.LOOTING_MOD);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
- if (i == 0) {
|
||||
+ if (i <= 0) { // CraftBukkit - account for possible negative looting values from Bukkit
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
--- a/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/parameters/LootContextParameters.java
|
||||
@@ -21,6 +21,7 @@
|
||||
public static final LootContextParameter<TileEntity> BLOCK_ENTITY = create("block_entity");
|
||||
public static final LootContextParameter<ItemStack> TOOL = create("tool");
|
||||
public static final LootContextParameter<Float> EXPLOSION_RADIUS = create("explosion_radius");
|
||||
+ public static final LootContextParameter<Integer> LOOTING_MOD = new LootContextParameter<>(new MinecraftKey("bukkit:looting_mod")); // CraftBukkit
|
||||
|
||||
public LootContextParameters() {}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
--- a/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.java
|
||||
@@ -35,6 +35,11 @@
|
||||
if (entity instanceof EntityLiving) {
|
||||
i = EnchantmentManager.getMobLooting((EntityLiving) entity);
|
||||
}
|
||||
+ // CraftBukkit start - only use lootingModifier if set by Bukkit
|
||||
+ if (loottableinfo.hasParam(LootContextParameters.LOOTING_MOD)) {
|
||||
+ i = loottableinfo.getParamOrNull(LootContextParameters.LOOTING_MOD);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
return loottableinfo.getRandom().nextFloat() < this.percent + (float) i * this.lootingMultiplier;
|
||||
}
|
||||
Reference in New Issue
Block a user