mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Inline imports in loottable patch
This commit is contained in:
parent
bee1482bcb
commit
80729ab0fd
1 changed files with 10 additions and 36 deletions
|
@ -657,33 +657,7 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableCo
|
|||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
@@ -0,0 +0,0 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
+import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.ContainerHelper;
|
||||
import net.minecraft.world.RandomizableContainer;
|
||||
@@ -0,0 +0,0 @@ import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
+import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
+import net.minecraft.world.level.storage.loot.LootParams;
|
||||
+import net.minecraft.world.level.storage.loot.LootTable;
|
||||
+import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
+import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
+import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public abstract class RandomizableContainerBlockEntity extends BaseContainerBlockEntity implements RandomizableContainer {
|
||||
@@ -0,0 +0,0 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
@Nullable
|
||||
public ResourceLocation lootTable;
|
||||
public long lootTableSeed;
|
||||
|
@ -697,7 +671,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean tryLoadLootTable(final CompoundTag nbt) {
|
||||
+ public boolean tryLoadLootTable(final net.minecraft.nbt.CompoundTag nbt) {
|
||||
+ // Copied from super with changes, always check the original method
|
||||
+ this.lootableData.loadNbt(nbt); // Paper
|
||||
+ if (nbt.contains("LootTable", 8)) {
|
||||
|
@ -711,7 +685,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean trySaveLootTable(final CompoundTag nbt) {
|
||||
+ public boolean trySaveLootTable(final net.minecraft.nbt.CompoundTag nbt) {
|
||||
+ this.lootableData.saveNbt(nbt);
|
||||
+ RandomizableContainer.super.trySaveLootTable(nbt);
|
||||
+ return false;
|
||||
|
@ -720,22 +694,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ @Override
|
||||
+ public void unpackLootTable(@org.jetbrains.annotations.Nullable final Player player) {
|
||||
+ // Copied from super with changes, always check the original method
|
||||
+ Level level = this.getLevel();
|
||||
+ net.minecraft.world.level.Level level = this.getLevel();
|
||||
+ BlockPos blockPos = this.getBlockPos();
|
||||
+ ResourceLocation resourceLocation = this.getLootTable();
|
||||
+ if (this.lootableData.shouldReplenish(player) && level != null) { // Paper
|
||||
+ LootTable lootTable = level.getServer().getLootData().getLootTable(resourceLocation);
|
||||
+ if (player instanceof ServerPlayer) {
|
||||
+ CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, resourceLocation);
|
||||
+ net.minecraft.world.level.storage.loot.LootTable lootTable = level.getServer().getLootData().getLootTable(resourceLocation);
|
||||
+ if (player instanceof net.minecraft.server.level.ServerPlayer) {
|
||||
+ net.minecraft.advancements.CriteriaTriggers.GENERATE_LOOT.trigger((net.minecraft.server.level.ServerPlayer)player, resourceLocation);
|
||||
+ }
|
||||
+
|
||||
+ this.lootableData.processRefill(player); // Paper
|
||||
+ LootParams.Builder builder = (new LootParams.Builder((ServerLevel)level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockPos));
|
||||
+ net.minecraft.world.level.storage.loot.LootParams.Builder builder = (new net.minecraft.world.level.storage.loot.LootParams.Builder((net.minecraft.server.level.ServerLevel)level)).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.ORIGIN, net.minecraft.world.phys.Vec3.atCenterOf(blockPos));
|
||||
+ if (player != null) {
|
||||
+ builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
|
||||
+ builder.withLuck(player.getLuck()).withParameter(net.minecraft.world.level.storage.loot.parameters.LootContextParams.THIS_ENTITY, player);
|
||||
+ }
|
||||
+
|
||||
+ lootTable.fill(this, builder.create(LootContextParamSets.CHEST), this.getLootTableSeed());
|
||||
+ lootTable.fill(this, builder.create(net.minecraft.world.level.storage.loot.parameters.LootContextParamSets.CHEST), this.getLootTableSeed());
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
|
|
Loading…
Reference in a new issue