Update loot table and other patches

Dieser Commit ist enthalten in:
Jason Penilla 2023-12-05 14:20:44 -07:00
Ursprung 2a9a9c4cf0
Commit fad3fa9bde
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0E75A301420E48F8
5 geänderte Dateien mit 90 neuen und 72 gelöschten Zeilen

Datei anzeigen

@ -503,11 +503,72 @@ index 0000000000000000000000000000000000000000..9cfa5d36a6991067a3866e0d437749fa
+ return tileEntityLootable.getLevel();
+ }
+}
diff --git a/src/main/java/net/minecraft/world/RandomizableContainer.java b/src/main/java/net/minecraft/world/RandomizableContainer.java
index 22eba5982dd258e2f58a7a70fd25900364cc9448..0c80f97e74ee04e7eab24e35c752ded5586bed07 100644
--- a/src/main/java/net/minecraft/world/RandomizableContainer.java
+++ b/src/main/java/net/minecraft/world/RandomizableContainer.java
@@ -49,17 +49,29 @@ public interface RandomizableContainer extends Container {
}
+ // Paper start
+ private static net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity blockEntity(final RandomizableContainer container) {
+ return (net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) container;
+ }
default boolean tryLoadLootTable(CompoundTag nbt) {
+ final net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity entity = blockEntity(this);
+ entity.lootableData.loadNbt(nbt);
if (nbt.contains("LootTable", 8)) {
this.setLootTable(new ResourceLocation(nbt.getString("LootTable")));
+ try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(entity.lootTable); } catch (IllegalArgumentException ex) { entity.lootTable = null; } // Paper - validate
this.setLootTableSeed(nbt.getLong("LootTableSeed"));
- return true;
+ return false; // Paper - always load the items, table may still remain
+ // Paper end
} else {
return false;
}
}
default boolean trySaveLootTable(CompoundTag nbt) {
+ // Paper start
+ final net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity entity = blockEntity(this);
+ entity.lootableData.saveNbt(nbt);
+ // Paper end
ResourceLocation resourceLocation = this.getLootTable();
if (resourceLocation == null) {
return false;
@@ -70,21 +82,22 @@ public interface RandomizableContainer extends Container {
nbt.putLong("LootTableSeed", l);
}
- return true;
+ return false; // Paper - always save the items, table may still remain
}
}
default void unpackLootTable(@Nullable Player player) {
+ final net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity entity = blockEntity(this); // Paper
Level level = this.getLevel();
BlockPos blockPos = this.getBlockPos();
ResourceLocation resourceLocation = this.getLootTable();
- if (resourceLocation != null && level != null && level.getServer() != null) {
+ if (entity.lootableData.shouldReplenish(player) && level != null) { // Paper
LootTable lootTable = level.getServer().getLootData().getLootTable(resourceLocation);
if (player instanceof ServerPlayer) {
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, resourceLocation);
}
- this.setLootTable((ResourceLocation)null);
+ entity.lootableData.processRefill(player); // Paper
LootParams.Builder builder = (new LootParams.Builder((ServerLevel)level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockPos));
if (player != null) {
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 6b577914e6b7603f3cef4c4698d5f81b7ebff19c..c85833a54c79b9a6eb18bc22dae67a92dbbad724 100644
index cc762d3eb68d2f8bf9529ecf07adfc343953c7a2..1b7b3114cd6ced0587a0e7e4a4c94584c72ed17f 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -235,6 +235,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -236,6 +236,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
// Paper end
@ -516,7 +577,7 @@ index 6b577914e6b7603f3cef4c4698d5f81b7ebff19c..c85833a54c79b9a6eb18bc22dae67a92
public CraftEntity getBukkitEntity() {
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
index 442736878291fbdc62572b2c83f384413408326f..00187fbbeddfc17e1b6887f8bf0f50da23938470 100644
index 364cfa220b5c7c5351f1eb909066bef933da2c08..6d23c39e4eadf23616080d6d08672e13b5d3c37d 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
@@ -32,6 +32,20 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
@ -556,10 +617,10 @@ index 442736878291fbdc62572b2c83f384413408326f..00187fbbeddfc17e1b6887f8bf0f50da
}
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java
index 11d9d4861aee68cd97d36ee2ff7597b7a6c81294..d70c1206df96b03c031399049a65e6a765d80347 100644
index 7bfdffc9b3c637bd6ac8ac3eb10961abdc5b1a7a..bc3fe45d12ffc2069a03d1587b7623d31130565a 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java
@@ -65,12 +65,14 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain
@@ -66,12 +66,14 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain
@Override
protected void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(nbt);
@ -574,7 +635,7 @@ index 11d9d4861aee68cd97d36ee2ff7597b7a6c81294..d70c1206df96b03c031399049a65e6a7
this.readChestVehicleSaveData(nbt);
}
@@ -245,6 +247,20 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain
@@ -246,6 +248,20 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain
this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of((Entity) player));
}
@ -654,10 +715,10 @@ index e0fbacd574e0c83c2e1d164ded8e9ccf4af30480..7529751afa2932fd16bc4591189b0358
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
index 111494c30a2b7d8464237a92cf5c98f7f4cca19d..e11618247ad889fa8fadbb2c7addd0de94caf249 100644
index aa4181e59f88be04a3605352fa5ceb3e04149dd3..a7c9301cfb3e15ebea9b3ca23ce97a936f0e351c 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
@@ -29,6 +29,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
@@ -17,6 +17,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
@Nullable
public ResourceLocation lootTable;
public long lootTableSeed;
@ -665,49 +726,6 @@ index 111494c30a2b7d8464237a92cf5c98f7f4cca19d..e11618247ad889fa8fadbb2c7addd0de
protected RandomizableContainerBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
@@ -43,16 +44,19 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
}
protected boolean tryLoadLootTable(CompoundTag nbt) {
+ this.lootableData.loadNbt(nbt); // Paper
if (nbt.contains("LootTable", 8)) {
this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
+ try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate
this.lootTableSeed = nbt.getLong("LootTableSeed");
- return true;
+ return false; // Paper - always load the items, table may still remain
} else {
return false;
}
}
protected boolean trySaveLootTable(CompoundTag nbt) {
+ this.lootableData.saveNbt(nbt); // Paper
if (this.lootTable == null) {
return false;
} else {
@@ -61,18 +65,18 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
nbt.putLong("LootTableSeed", this.lootTableSeed);
}
- return true;
+ return false; // Paper - always save the items, table may still remain
}
}
public void unpackLootTable(@Nullable Player player) {
- if (this.lootTable != null && this.level.getServer() != null) {
+ if (this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper
LootTable lootTable = this.level.getServer().getLootData().getLootTable(this.lootTable);
if (player instanceof ServerPlayer) {
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, this.lootTable);
}
- this.lootTable = null;
+ this.lootableData.processRefill(player); // Paper
LootParams.Builder builder = (new LootParams.Builder((ServerLevel)this.level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition));
if (player != null) {
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java
index 86076a9d2a3b1044c96518cbaeee66d60a8a22c6..c268513bc5719d80e1c3d73de53b85ec7f852fa9 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Async GameProfileCache saving
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 937de8ff1f8c25861ae09af197d75577088b70fe..2bb21a86f49ec996b7beeb65dd0ec8e2e5634053 100644
index ee751fb9580064682e650cf1c959a0e159a89bf2..e1849b879334bc9d17e6efeff061e1db6ab4ec7b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -914,7 +914,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -960,7 +960,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
} catch (java.lang.InterruptedException ignored) {} // Paper
if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) {
MinecraftServer.LOGGER.info("Saving usercache.json");
@ -18,7 +18,7 @@ index 937de8ff1f8c25861ae09af197d75577088b70fe..2bb21a86f49ec996b7beeb65dd0ec8e2
// Spigot end
io.papermc.paper.chunk.system.io.RegionFileIOThread.close(true); // Paper // Paper - rewrite chunk system
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index dbe57c172ed57694912ef940024f8f33577e92bd..1989bbc4bcceb86ab49786b0c93ff48f3836e904 100644
index a267ab0b217573373d7b6a1f48cadab0f431da40..772d7c1e398538b8bbbd70aedaba05199d11b358 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -242,7 +242,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@ -31,10 +31,10 @@ index dbe57c172ed57694912ef940024f8f33577e92bd..1989bbc4bcceb86ab49786b0c93ff48f
if (!OldUsersConverter.serverReadyAfterUserconversion(this)) {
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
index 7170f8cfd733708089495b51647659237bd10385..322e07adc556ee8131d40d89856574b185ee4c94 100644
index d5e83f14bb7809c8bb3c2bffe436fd7284896aff..ee43e87fca2a8ac3f63bc2f8ffcf15be373195e9 100644
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
@@ -115,7 +115,7 @@ public class GameProfileCache {
@@ -118,7 +118,7 @@ public class GameProfileCache {
GameProfileCache.GameProfileInfo usercache_usercacheentry = new GameProfileCache.GameProfileInfo(profile, date);
this.safeAdd(usercache_usercacheentry);
@ -43,7 +43,7 @@ index 7170f8cfd733708089495b51647659237bd10385..322e07adc556ee8131d40d89856574b1
}
private long getNextOperation() {
@@ -148,7 +148,7 @@ public class GameProfileCache {
@@ -151,7 +151,7 @@ public class GameProfileCache {
}
if (flag && !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) { // Spigot - skip saving if disabled
@ -52,7 +52,7 @@ index 7170f8cfd733708089495b51647659237bd10385..322e07adc556ee8131d40d89856574b1
}
return optional;
@@ -260,7 +260,7 @@ public class GameProfileCache {
@@ -263,7 +263,7 @@ public class GameProfileCache {
return arraylist;
}
@ -61,7 +61,7 @@ index 7170f8cfd733708089495b51647659237bd10385..322e07adc556ee8131d40d89856574b1
JsonArray jsonarray = new JsonArray();
DateFormat dateformat = GameProfileCache.createDateFormat();
@@ -268,6 +268,7 @@ public class GameProfileCache {
@@ -271,6 +271,7 @@ public class GameProfileCache {
jsonarray.add(GameProfileCache.writeGameProfile(usercache_usercacheentry, dateformat));
});
String s = this.gson.toJson(jsonarray);
@ -69,7 +69,7 @@ index 7170f8cfd733708089495b51647659237bd10385..322e07adc556ee8131d40d89856574b1
try {
BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8);
@@ -292,6 +293,14 @@ public class GameProfileCache {
@@ -295,6 +296,14 @@ public class GameProfileCache {
} catch (IOException ioexception) {
;
}

Datei anzeigen

@ -18,10 +18,10 @@ index fb16216b54eea81fceaf3edafa69b554ad01c807..90d2fa5b90d64ddb28075a50f4478b46
public ServerEntity(ServerLevel worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<ServerPlayerConnection> trackedPlayers) {
this.trackedPlayers = trackedPlayers;
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index 89fd5d6b373d2705dccc2f22663048f4c2aaa60f..57f9bf73ee14bc8811d0192543caf2b02e890ee0 100644
index 5c3b86e2301079e775971aa4da6a8f2dc6a40d1f..d9ed22e9853eebdf6c517b41787a27a1a56a0871 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -98,6 +98,27 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -106,6 +106,27 @@ public class PrimedTnt extends Entity implements TraceableEntity {
}
}
@ -49,9 +49,9 @@ index 89fd5d6b373d2705dccc2f22663048f4c2aaa60f..57f9bf73ee14bc8811d0192543caf2b0
}
private void explode() {
@@ -147,4 +168,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
public int getFuse() {
return (Integer) this.entityData.get(PrimedTnt.DATA_FUSE_ID);
@@ -179,4 +200,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
public BlockState getBlockState() {
return (BlockState) this.entityData.get(PrimedTnt.DATA_BLOCK_STATE_ID);
}
+
+ // Paper start - Optional prevent TNT from moving in water

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Faster redstone torch rapid clock removal
Only resize the the redstone torch list once, since resizing arrays / lists is costly
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index d9a03a3d262fee9f93b1ccf3a08ec0b77efa1c33..555e7efacd6cc37c6cf959e2931069be5c85fe8f 100644
index 9bb380e7c8973b4728b5d4aad663af9e477dda0c..48d3da58820c1d9259bc023ddd74e9632b3f62d1 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -173,6 +173,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -176,6 +176,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
private org.spigotmc.TickLimiter tileLimiter;
private int tileTickPosition;
public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
@ -18,19 +18,19 @@ index d9a03a3d262fee9f93b1ccf3a08ec0b77efa1c33..555e7efacd6cc37c6cf959e2931069be
public CraftWorld getWorld() {
return this.world;
diff --git a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
index a6e61112f5a30a0001071cd931ea658384338eef..c91535f6c0bbc870fad7e04b9d341783cfcbbd63 100644
index 68da47c3ec59518a4bbeb03c196ef0e7c6b5d049..6c49962e8f9e2a5fca50b33f3e3fff76fa36f907 100644
--- a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
@@ -22,7 +22,7 @@ import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
public class RedstoneTorchBlock extends TorchBlock {
@@ -24,7 +24,7 @@ public class RedstoneTorchBlock extends BaseTorchBlock {
public static final MapCodec<RedstoneTorchBlock> CODEC = simpleCodec(RedstoneTorchBlock::new);
public static final BooleanProperty LIT = BlockStateProperties.LIT;
- private static final Map<BlockGetter, List<RedstoneTorchBlock.Toggle>> RECENT_TOGGLES = new WeakHashMap();
+ // Paper - Move the mapped list to World
public static final int RECENT_TOGGLE_TIMER = 60;
public static final int MAX_RECENT_TOGGLES = 8;
public static final int RESTART_DELAY = 160;
@@ -73,11 +73,15 @@ public class RedstoneTorchBlock extends TorchBlock {
@@ -80,11 +80,15 @@ public class RedstoneTorchBlock extends BaseTorchBlock {
@Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
boolean flag = this.hasNeighborSignal(world, pos, state);
@ -50,7 +50,7 @@ index a6e61112f5a30a0001071cd931ea658384338eef..c91535f6c0bbc870fad7e04b9d341783
// CraftBukkit start
org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager();
@@ -153,9 +157,12 @@ public class RedstoneTorchBlock extends TorchBlock {
@@ -160,9 +164,12 @@ public class RedstoneTorchBlock extends BaseTorchBlock {
}
private static boolean isToggledTooFrequently(Level world, BlockPos pos, boolean addNew) {