More more more work
This commit is contained in:
parent
50710fa684
commit
7a133678da
100 changed files with 239 additions and 234 deletions
|
@ -1,28 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: JRoy <joshroy126@gmail.com>
|
||||
Date: Fri, 5 Jun 2020 18:24:06 -0400
|
||||
Subject: [PATCH] Add and implement PlayerRecipeBookClickEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index c03867ed9a66a408900cadf81b09704e415dfca6..00a8b49b4e3b443fed22761b57ebcfa64c8d46aa 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2997,9 +2997,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
this.player.resetLastActionTime();
|
||||
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu instanceof RecipeBookMenu) {
|
||||
- this.server.getRecipeManager().byKey(packet.getRecipe()).ifPresent((irecipe) -> {
|
||||
- ((RecipeBookMenu) this.player.containerMenu).handlePlacement(packet.isShiftDown(), irecipe, this.player);
|
||||
- });
|
||||
+ // Paper start - fire event for clicking recipes in the recipe book
|
||||
+ com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent event = new com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent(
|
||||
+ player.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(packet.getRecipe()), packet.isShiftDown());
|
||||
+ if (event.callEvent() && this.player.containerMenu instanceof RecipeBookMenu<?> recipeBookMenu) { // check if inventory changed during event handling
|
||||
+ this.server.getRecipeManager().byKey(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getRecipe())).ifPresent((irecipe) -> {
|
||||
+ recipeBookMenu.handlePlacement(event.isMakeAll(), irecipe, this.player);
|
||||
+ });
|
||||
+ } // Paper end
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Fri, 26 Jun 2020 22:35:08 -0700
|
||||
Subject: [PATCH] Hide sync chunk writes behind flag
|
||||
|
||||
Syncing writes on each write call has terrible performance
|
||||
on harddrives.
|
||||
|
||||
-DPaper.enable-sync-chunk-writes=true to enable
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
index cc92e2c5e6b62c6a67d0a6534b078e3a6029daf5..26345494ce190b5cd2ab58dd7d4b046796767b20 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
@@ -136,7 +136,7 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||
this.maxWorldSize = this.get("max-world-size", (integer) -> {
|
||||
return Mth.clamp(integer, (int) 1, 29999984);
|
||||
}, 29999984);
|
||||
- this.syncChunkWrites = this.get("sync-chunk-writes", true);
|
||||
+ this.syncChunkWrites = this.get("sync-chunk-writes", true) && Boolean.getBoolean("Paper.enable-sync-chunk-writes"); // Paper - hide behind flag
|
||||
this.enableJmxMonitoring = this.get("enable-jmx-monitoring", false);
|
||||
this.enableStatus = this.get("enable-status", true);
|
||||
this.hideOnlinePlayers = this.get("hide-online-players", false);
|
|
@ -1,79 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Sat, 16 May 2020 10:05:30 +0200
|
||||
Subject: [PATCH] Add permission for command blocks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
index af00442931f9f6cf878bd61137c2f29fc7c8d0b1..431ff490760f54be76847c7b370dbbb4b65de102 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
@@ -396,7 +396,7 @@ public class ServerPlayerGameMode {
|
||||
BlockEntity tileentity = this.level.getBlockEntity(pos);
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
- if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks()) {
|
||||
+ if (block instanceof GameMasterBlock && !this.player.canUseGameMasterBlocks() && !(block instanceof net.minecraft.world.level.block.CommandBlock && (this.player.isCreative() && this.player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission
|
||||
this.level.sendBlockUpdated(pos, iblockdata, iblockdata, 3);
|
||||
return false;
|
||||
} else if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) {
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 00a8b49b4e3b443fed22761b57ebcfa64c8d46aa..ffe92ac27172e9f00b7941a574d98475b4daff94 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -829,7 +829,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
if (!this.server.isCommandBlockEnabled()) {
|
||||
this.player.sendSystemMessage(Component.translatable("advMode.notEnabled"));
|
||||
- } else if (!this.player.canUseGameMasterBlocks()) {
|
||||
+ } else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission
|
||||
this.player.sendSystemMessage(Component.translatable("advMode.notAllowed"));
|
||||
} else {
|
||||
BaseCommandBlock commandblocklistenerabstract = null;
|
||||
@@ -896,7 +896,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
if (!this.server.isCommandBlockEnabled()) {
|
||||
this.player.sendSystemMessage(Component.translatable("advMode.notEnabled"));
|
||||
- } else if (!this.player.canUseGameMasterBlocks()) {
|
||||
+ } else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission
|
||||
this.player.sendSystemMessage(Component.translatable("advMode.notAllowed"));
|
||||
} else {
|
||||
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
index da504702bc9423774b35dff792d2dbe7fc270fe3..c0195f73cd2c8721e882c681eaead65471710081 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
|
||||
@@ -198,7 +198,7 @@ public abstract class BaseCommandBlock implements CommandSource {
|
||||
}
|
||||
|
||||
public InteractionResult usedBy(Player player) {
|
||||
- if (!player.canUseGameMasterBlocks()) {
|
||||
+ if (!player.canUseGameMasterBlocks() && (!player.isCreative() || !player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission
|
||||
return InteractionResult.PASS;
|
||||
} else {
|
||||
if (player.getCommandSenderWorld().isClientSide) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/CommandBlock.java b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||
index 061a56e3828767cd6576d5a9edde5f3498e609d0..2e7c03b00bc941b86df6a7f1b2b188c9f0aede22 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||
@@ -130,7 +130,7 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
BlockEntity tileentity = world.getBlockEntity(pos);
|
||||
|
||||
- if (tileentity instanceof CommandBlockEntity && player.canUseGameMasterBlocks()) {
|
||||
+ if (tileentity instanceof CommandBlockEntity && (player.canUseGameMasterBlocks() || (player.isCreative() && player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission
|
||||
player.openCommandBlock((CommandBlockEntity) tileentity);
|
||||
return InteractionResult.sidedSuccess(world.isClientSide);
|
||||
} else {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
||||
index 70d3949616c63038ad3e9bd1069db5ea2fb3f3b8..8e06bc11fb28baee3407bbfe9d7b3689d6f85ff2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
||||
@@ -16,6 +16,7 @@ public final class CraftDefaultPermissions {
|
||||
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".nbt.copy", "Gives the user the ability to copy NBT in creative", org.bukkit.permissions.PermissionDefault.TRUE, parent);
|
||||
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick", "Gives the user the ability to use the debug stick in creative", org.bukkit.permissions.PermissionDefault.OP, parent);
|
||||
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE/* , parent */); // Paper - should not have this parent, as it's not a "vanilla" utility
|
||||
+ DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".commandblock", "Gives the user the ability to use command blocks.", org.bukkit.permissions.PermissionDefault.OP, parent); // Paper
|
||||
// Spigot end
|
||||
parent.recalculatePermissibles();
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 10 May 2020 22:12:46 -0400
|
||||
Subject: [PATCH] Ensure Entity AABB's are never invalid
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 175f5400225584f1fedc940d967a3d6f8ede84c0..520b991a0a8adb91c933288faeba64c1798d8577 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -662,8 +662,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public void setPos(double x, double y, double z) {
|
||||
- this.setPosRaw(x, y, z);
|
||||
- this.setBoundingBox(this.makeBoundingBox());
|
||||
+ this.setPosRaw(x, y, z, true); // Paper - force bounding box update
|
||||
+ // this.setBoundingBox(this.makeBoundingBox()); // Paper - move into setPositionRaw
|
||||
}
|
||||
|
||||
protected AABB makeBoundingBox() {
|
||||
@@ -3873,6 +3873,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public final void setPosRaw(double x, double y, double z) {
|
||||
+ // Paper start
|
||||
+ this.setPosRaw(x, y, z, false);
|
||||
+ }
|
||||
+ public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
|
||||
+ // Paper end
|
||||
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
||||
this.position = new Vec3(x, y, z);
|
||||
int i = Mth.floor(x);
|
||||
@@ -3890,6 +3895,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
this.levelCallback.onMove();
|
||||
}
|
||||
|
||||
+ // Paper start - never allow AABB to become desynced from position
|
||||
+ // hanging has its own special logic
|
||||
+ if (!(this instanceof net.minecraft.world.entity.decoration.HangingEntity) && (forceBoundingBoxUpdate || this.position.x != x || this.position.y != y || this.position.z != z)) {
|
||||
+ this.setBoundingBox(this.makeBoundingBox());
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public void checkDespawn() {}
|
|
@ -1,118 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 28 Jun 2020 03:59:10 -0400
|
||||
Subject: [PATCH] Fix Per World Difficulty / Remembering Difficulty
|
||||
|
||||
Fixes per world difficulty with /difficulty command and also
|
||||
makes it so that the server keeps the last difficulty used instead
|
||||
of restoring the server.properties every single load.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 1774d6011ea165a36576f283de6531eed873ee4c..3496da11b02d823f6445b6b50d44ee2d2d7435af 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -789,7 +789,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
chunkproviderserver.getLightEngine().setTaskPerBatch(worldserver.paperConfig().misc.lightQueueSize); // Paper - increase light queue size
|
||||
// CraftBukkit start
|
||||
// this.updateMobSpawningFlags();
|
||||
- worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals());
|
||||
+ worldserver.setSpawnSettings(worldserver.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && ((DedicatedServer) this).settings.getProperties().spawnMonsters, this.isSpawningAnimals()); // Paper - per level difficulty (from setDifficulty(ServerLevel, Difficulty, boolean))
|
||||
|
||||
this.forceTicks = false;
|
||||
// CraftBukkit end
|
||||
@@ -1693,11 +1693,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
}
|
||||
|
||||
- public void setDifficulty(Difficulty difficulty, boolean forceUpdate) {
|
||||
- if (forceUpdate || !this.worldData.isDifficultyLocked()) {
|
||||
- this.worldData.setDifficulty(this.worldData.isHardcore() ? Difficulty.HARD : difficulty);
|
||||
- this.updateMobSpawningFlags();
|
||||
- this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate);
|
||||
+ // Paper start - remember per level difficulty
|
||||
+ public void setDifficulty(ServerLevel level, Difficulty difficulty, boolean forceUpdate) {
|
||||
+ PrimaryLevelData worldData = level.serverLevelData;
|
||||
+ if (forceUpdate || !worldData.isDifficultyLocked()) {
|
||||
+ worldData.setDifficulty(worldData.isHardcore() ? Difficulty.HARD : difficulty);
|
||||
+ level.setSpawnSettings(worldData.getDifficulty() != Difficulty.PEACEFUL && ((DedicatedServer) this).settings.getProperties().spawnMonsters, this.isSpawningAnimals());
|
||||
+ // this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate);
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1711,7 +1714,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
while (iterator.hasNext()) {
|
||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||
|
||||
- worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals());
|
||||
+ worldserver.setSpawnSettings(worldserver.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && ((DedicatedServer) this).settings.getProperties().spawnMonsters, this.isSpawningAnimals()); // Paper - per level difficulty (from setDifficulty(ServerLevel, Difficulty, boolean))
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/commands/DifficultyCommand.java b/src/main/java/net/minecraft/server/commands/DifficultyCommand.java
|
||||
index 4bb29f86538552bb62125cc61210fd77b1ec671d..817193ca5fc15134d2985187bc2226ccbb4f0108 100644
|
||||
--- a/src/main/java/net/minecraft/server/commands/DifficultyCommand.java
|
||||
+++ b/src/main/java/net/minecraft/server/commands/DifficultyCommand.java
|
||||
@@ -47,7 +47,7 @@ public class DifficultyCommand {
|
||||
if (worldServer.getDifficulty() == difficulty) { // CraftBukkit
|
||||
throw DifficultyCommand.ERROR_ALREADY_DIFFICULT.create(difficulty.getKey());
|
||||
} else {
|
||||
- worldServer.serverLevelData.setDifficulty(difficulty); // CraftBukkit
|
||||
+ minecraftserver.setDifficulty(worldServer, difficulty, true); // Paper - don't skip other difficulty-changing logic (fix upstream's fix)
|
||||
source.sendSuccess(Component.translatable("commands.difficulty.success", difficulty.getDisplayName()), true);
|
||||
return 0;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index a44a9b4b3c78395cdd1d859407a880cb54386d86..ae45abf66d2e7b24d316a5db3d00c0b52f402b7f 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -332,7 +332,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
|
||||
@Override
|
||||
public void forceDifficulty() {
|
||||
- this.setDifficulty(this.getProperties().difficulty, true);
|
||||
+ // this.setDifficulty(this.getProperties().difficulty, true); // Paper - Don't overwrite level.dat's difficulty, keep current
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 86574b86b02dc0b0814cc0d0540e82957f094025..7c014f288184328384a811ecbeef83406a780289 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1130,7 +1130,7 @@ public class ServerPlayer extends Player {
|
||||
this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
|
||||
|
||||
this.connection.send(new ClientboundRespawnPacket(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getLastDeathLocation()));
|
||||
- this.connection.send(new ClientboundChangeDifficultyPacket(this.level.getDifficulty(), this.level.getLevelData().isDifficultyLocked()));
|
||||
+ this.connection.send(new ClientboundChangeDifficultyPacket(worldserver.getDifficulty(), this.level.getLevelData().isDifficultyLocked())); // Paper - fix difficulty sync issue
|
||||
PlayerList playerlist = this.server.getPlayerList();
|
||||
|
||||
playerlist.sendPlayerPermissionLevel(this);
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index ffe92ac27172e9f00b7941a574d98475b4daff94..50226c6672ffb933fe7e22bf43641983eb6caa54 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -3258,7 +3258,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) {
|
||||
- this.server.setDifficulty(packet.getDifficulty(), false);
|
||||
+ // this.server.setDifficulty(packet.getDifficulty(), false); // Paper - don't allow clients to change this
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index e8f45ff744c9d297ea803392c988a86a8cbbe5fe..b4cc5f89b6694f1f3fc38d822a0f503c170d45c4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -949,8 +949,8 @@ public final class CraftServer implements Server {
|
||||
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
||||
for (ServerLevel world : this.console.getAllLevels()) {
|
||||
- world.serverLevelData.setDifficulty(config.difficulty);
|
||||
- world.setSpawnSettings(config.spawnMonsters, config.spawnAnimals);
|
||||
+ // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||
+ world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
||||
|
||||
for (SpawnCategory spawnCategory : SpawnCategory.values()) {
|
||||
if (CraftSpawnCategory.isValidForLimits(spawnCategory)) {
|
|
@ -1,92 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 28 Jun 2020 19:27:20 -0400
|
||||
Subject: [PATCH] Paper dumpitem command
|
||||
|
||||
Let's you quickly view the item in your hands NBT data
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
index 25f6d1c15cdfb4abdf1edd2ad9bbdc0e37b546f3..d2536f4ffae721f4df714b5345fa3329c3b8e3f5 100644
|
||||
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.papermc.paper.command;
|
||||
|
||||
import io.papermc.paper.command.subcommands.ChunkDebugCommand;
|
||||
+import io.papermc.paper.command.subcommands.DumpItemCommand;
|
||||
import io.papermc.paper.command.subcommands.EntityCommand;
|
||||
import io.papermc.paper.command.subcommands.FixLightCommand;
|
||||
import io.papermc.paper.command.subcommands.HeapDumpCommand;
|
||||
@@ -46,6 +47,7 @@ public final class PaperCommand extends Command {
|
||||
commands.put(Set.of("debug", "chunkinfo"), new ChunkDebugCommand());
|
||||
commands.put(Set.of("fixlight"), new FixLightCommand());
|
||||
commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
|
||||
+ commands.put(Set.of("dumpitem"), new DumpItemCommand());
|
||||
|
||||
return commands.entrySet().stream()
|
||||
.flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue())))
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java b/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..771503ff637fea10d4d8be0f37f3f146c41791d9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/subcommands/DumpItemCommand.java
|
||||
@@ -0,0 +1,59 @@
|
||||
+package io.papermc.paper.command.subcommands;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import io.papermc.paper.command.PaperSubcommand;
|
||||
+import java.util.Objects;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.event.ClickEvent;
|
||||
+import net.minecraft.core.Registry;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+import static net.kyori.adventure.text.Component.text;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.GRAY;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.YELLOW;
|
||||
+import static net.kyori.adventure.text.format.TextDecoration.ITALIC;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class DumpItemCommand implements PaperSubcommand {
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ this.doDumpItem(sender);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ private void doDumpItem(final CommandSender sender) {
|
||||
+ if (!(sender instanceof Player)) {
|
||||
+ sender.sendMessage("Only players can use this command");
|
||||
+ return;
|
||||
+ }
|
||||
+ final ItemStack itemStack = CraftItemStack.asNMSCopy(((CraftPlayer) sender).getItemInHand());
|
||||
+ final @Nullable CompoundTag tag = itemStack.getTag();
|
||||
+ final @Nullable Component nbtComponent = tag == null ? null : PaperAdventure.asAdventure(net.minecraft.nbt.NbtUtils.toPrettyComponent(tag));
|
||||
+ final String itemId = Objects.requireNonNull(((CraftWorld) ((CraftPlayer) sender).getWorld()).getHandle().registryAccess()
|
||||
+ .registryOrThrow(Registry.ITEM_REGISTRY).getKey(itemStack.getItem())).toString();
|
||||
+ final Component message = text()
|
||||
+ .append(text(itemId, YELLOW))
|
||||
+ .apply(b -> {
|
||||
+ if (nbtComponent != null) {
|
||||
+ b.append(nbtComponent);
|
||||
+ }
|
||||
+ })
|
||||
+ .build();
|
||||
+ Bukkit.getConsoleSender().sendMessage(message);
|
||||
+ sender.sendMessage(message);
|
||||
+ sender.sendMessage(text().content(" Click to copy item to clipboard")
|
||||
+ .color(GRAY)
|
||||
+ .decorate(ITALIC)
|
||||
+ .clickEvent(ClickEvent.copyToClipboard(tag == null ? itemId : (itemId + tag))));
|
||||
+ }
|
||||
+}
|
|
@ -1,22 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 28 Jun 2020 19:36:55 -0400
|
||||
Subject: [PATCH] Don't allow null UUID's for chat
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/ChatSender.java b/src/main/java/net/minecraft/network/chat/ChatSender.java
|
||||
index 1710d09d115a4adceeb56e07d68d8529eb099a26..8f5ccd61a37db718f527375387b421d438471b3c 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/ChatSender.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/ChatSender.java
|
||||
@@ -13,6 +13,11 @@ public record ChatSender(UUID uuid, Component name, @Nullable Component teamName
|
||||
public ChatSender(FriendlyByteBuf buf) {
|
||||
this(buf.readUUID(), buf.readComponent(), buf.readNullable(FriendlyByteBuf::readComponent));
|
||||
}
|
||||
+ // Paper start
|
||||
+ public ChatSender {
|
||||
+ com.google.common.base.Preconditions.checkNotNull(uuid, "uuid cannot be null");
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static ChatSender system(Component name) {
|
||||
return new ChatSender(Util.NIL_UUID, name);
|
|
@ -1,56 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 28 Jun 2020 19:08:41 -0400
|
||||
Subject: [PATCH] Improve Legacy Component serialization size
|
||||
|
||||
Don't constantly send format: false for all formatting options when parent already
|
||||
has it false
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
index 4fede2161792ba3e7cdf0cc5a1f533188becc6f7..0f70be614f8f5350ad558d0ae645cdf0027e1e76 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
@@ -47,6 +47,7 @@ public final class CraftChatMessage {
|
||||
// Separate pattern with no group 3, new lines are part of previous string
|
||||
private static final Pattern INCREMENTAL_PATTERN_KEEP_NEWLINES = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-orx])|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " ]|$))))", Pattern.CASE_INSENSITIVE);
|
||||
// ChatColor.b does not explicitly reset, its more of empty
|
||||
+ private static final Style EMPTY = Style.EMPTY.withItalic(false); // Paper - OBFHELPER
|
||||
private static final Style RESET = Style.EMPTY.withBold(false).withItalic(false).withUnderlined(false).withStrikethrough(false).withObfuscated(false);
|
||||
|
||||
private final List<Component> list = new ArrayList<Component>();
|
||||
@@ -68,6 +69,7 @@ public final class CraftChatMessage {
|
||||
Matcher matcher = (keepNewlines ? StringMessage.INCREMENTAL_PATTERN_KEEP_NEWLINES : StringMessage.INCREMENTAL_PATTERN).matcher(message);
|
||||
String match = null;
|
||||
boolean needsAdd = false;
|
||||
+ boolean hasReset = false; // Paper
|
||||
while (matcher.find()) {
|
||||
int groupId = 0;
|
||||
while ((match = matcher.group(++groupId)) == null) {
|
||||
@@ -113,7 +115,26 @@ public final class CraftChatMessage {
|
||||
throw new AssertionError("Unexpected message format");
|
||||
}
|
||||
} else { // Color resets formatting
|
||||
- this.modifier = StringMessage.RESET.withColor(format);
|
||||
+ // Paper start - improve legacy formatting
|
||||
+ Style previous = modifier;
|
||||
+ modifier = (!hasReset ? RESET : EMPTY).withColor(format);
|
||||
+ hasReset = true;
|
||||
+ if (previous.isBold()) {
|
||||
+ modifier = modifier.withBold(false);
|
||||
+ }
|
||||
+ if (previous.isItalic()) {
|
||||
+ modifier = modifier.withItalic(false);
|
||||
+ }
|
||||
+ if (previous.isObfuscated()) {
|
||||
+ modifier = modifier.withObfuscated(false);
|
||||
+ }
|
||||
+ if (previous.isStrikethrough()) {
|
||||
+ modifier = modifier.withStrikethrough(false);
|
||||
+ }
|
||||
+ if (previous.isUnderlined()) {
|
||||
+ modifier = modifier.withUnderlined(false);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
needsAdd = true;
|
||||
break;
|
|
@ -1,213 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 4 Jun 2020 02:24:49 -0400
|
||||
Subject: [PATCH] Optimize Bit Operations by inlining
|
||||
|
||||
Inline bit operations and reduce instruction count to make these hot
|
||||
operations faster
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
index f8361dcf9d0378497ec5a34ea53b4e0019700851..e68cd32a7db88f29d3224b0908119232ab3cf71a 100644
|
||||
--- a/src/main/java/net/minecraft/core/BlockPos.java
|
||||
+++ b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
@@ -30,15 +30,16 @@ public class BlockPos extends Vec3i {
|
||||
}).stable();
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final BlockPos ZERO = new BlockPos(0, 0, 0);
|
||||
- private static final int PACKED_X_LENGTH = 1 + Mth.log2(Mth.smallestEncompassingPowerOfTwo(30000000));
|
||||
- private static final int PACKED_Z_LENGTH = PACKED_X_LENGTH;
|
||||
- public static final int PACKED_Y_LENGTH = 64 - PACKED_X_LENGTH - PACKED_Z_LENGTH;
|
||||
- private static final long PACKED_X_MASK = (1L << PACKED_X_LENGTH) - 1L;
|
||||
- private static final long PACKED_Y_MASK = (1L << PACKED_Y_LENGTH) - 1L;
|
||||
- private static final long PACKED_Z_MASK = (1L << PACKED_Z_LENGTH) - 1L;
|
||||
- private static final int Y_OFFSET = 0;
|
||||
- private static final int Z_OFFSET = PACKED_Y_LENGTH;
|
||||
- private static final int X_OFFSET = PACKED_Y_LENGTH + PACKED_Z_LENGTH;
|
||||
+ // Paper start - static constants
|
||||
+ private static final int PACKED_X_LENGTH = 26;
|
||||
+ private static final int PACKED_Z_LENGTH = 26;
|
||||
+ public static final int PACKED_Y_LENGTH = 12;
|
||||
+ private static final long PACKED_X_MASK = 67108863;
|
||||
+ private static final long PACKED_Y_MASK = 4095;
|
||||
+ private static final long PACKED_Z_MASK = 67108863;
|
||||
+ private static final int Z_OFFSET = 12;
|
||||
+ private static final int X_OFFSET = 38;
|
||||
+ // Paper end
|
||||
|
||||
public BlockPos(int x, int y, int z) {
|
||||
super(x, y, z);
|
||||
@@ -60,28 +61,29 @@ public class BlockPos extends Vec3i {
|
||||
this(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
+ public static long getAdjacent(int baseX, int baseY, int baseZ, Direction enumdirection) { return asLong(baseX + enumdirection.getStepX(), baseY + enumdirection.getStepY(), baseZ + enumdirection.getStepZ()); } // Paper
|
||||
public static long offset(long value, Direction direction) {
|
||||
return offset(value, direction.getStepX(), direction.getStepY(), direction.getStepZ());
|
||||
}
|
||||
|
||||
public static long offset(long value, int x, int y, int z) {
|
||||
- return asLong(getX(value) + x, getY(value) + y, getZ(value) + z);
|
||||
+ return asLong((int) (value >> 38) + x, (int) ((value << 52) >> 52) + y, (int) ((value << 26) >> 38) + z); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static int getX(long packedPos) {
|
||||
- return (int)(packedPos << 64 - X_OFFSET - PACKED_X_LENGTH >> 64 - PACKED_X_LENGTH);
|
||||
+ return (int) (packedPos >> 38); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static int getY(long packedPos) {
|
||||
- return (int)(packedPos << 64 - PACKED_Y_LENGTH >> 64 - PACKED_Y_LENGTH);
|
||||
+ return (int) ((packedPos << 52) >> 52); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static int getZ(long packedPos) {
|
||||
- return (int)(packedPos << 64 - Z_OFFSET - PACKED_Z_LENGTH >> 64 - PACKED_Z_LENGTH);
|
||||
+ return (int) ((packedPos << 26) >> 38); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static BlockPos of(long packedPos) {
|
||||
- return new BlockPos(getX(packedPos), getY(packedPos), getZ(packedPos));
|
||||
+ return new BlockPos((int) (packedPos >> 38), (int) ((packedPos << 52) >> 52), (int) ((packedPos << 26) >> 38)); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public long asLong() {
|
||||
@@ -89,10 +91,7 @@ public class BlockPos extends Vec3i {
|
||||
}
|
||||
|
||||
public static long asLong(int x, int y, int z) {
|
||||
- long l = 0L;
|
||||
- l |= ((long)x & PACKED_X_MASK) << X_OFFSET;
|
||||
- l |= ((long)y & PACKED_Y_MASK) << 0;
|
||||
- return l | ((long)z & PACKED_Z_MASK) << Z_OFFSET;
|
||||
+ return (((long) x & (long) 67108863) << 38) | (((long) y & (long) 4095)) | (((long) z & (long) 67108863) << 12); // Paper - inline constants and simplify
|
||||
}
|
||||
|
||||
public static long getFlatIndex(long y) {
|
||||
diff --git a/src/main/java/net/minecraft/core/SectionPos.java b/src/main/java/net/minecraft/core/SectionPos.java
|
||||
index a481bd6328fe9e66f6911bf32ed11947c504c93c..a9d0d72aad7b1b708617a082c5efcd881a0f00d3 100644
|
||||
--- a/src/main/java/net/minecraft/core/SectionPos.java
|
||||
+++ b/src/main/java/net/minecraft/core/SectionPos.java
|
||||
@@ -38,7 +38,7 @@ public class SectionPos extends Vec3i {
|
||||
}
|
||||
|
||||
public static SectionPos of(BlockPos pos) {
|
||||
- return new SectionPos(blockToSectionCoord(pos.getX()), blockToSectionCoord(pos.getY()), blockToSectionCoord(pos.getZ()));
|
||||
+ return new SectionPos(pos.getX() >> 4, pos.getY() >> 4, pos.getZ() >> 4); // Paper
|
||||
}
|
||||
|
||||
public static SectionPos of(ChunkPos chunkPos, int y) {
|
||||
@@ -54,7 +54,7 @@ public class SectionPos extends Vec3i {
|
||||
}
|
||||
|
||||
public static SectionPos of(long packed) {
|
||||
- return new SectionPos(x(packed), y(packed), z(packed));
|
||||
+ return new SectionPos((int) (packed >> 42), (int) (packed << 44 >> 44), (int) (packed << 22 >> 42)); // Paper
|
||||
}
|
||||
|
||||
public static SectionPos bottomOf(ChunkAccess chunk) {
|
||||
@@ -65,8 +65,16 @@ public class SectionPos extends Vec3i {
|
||||
return offset(packed, direction.getStepX(), direction.getStepY(), direction.getStepZ());
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public static long getAdjacentFromBlockPos(int x, int y, int z, Direction enumdirection) {
|
||||
+ return (((long) ((x >> 4) + enumdirection.getStepX()) & 4194303L) << 42) | (((long) ((y >> 4) + enumdirection.getStepY()) & 1048575L)) | (((long) ((z >> 4) + enumdirection.getStepZ()) & 4194303L) << 20);
|
||||
+ }
|
||||
+ public static long getAdjacentFromSectionPos(int x, int y, int z, Direction enumdirection) {
|
||||
+ return (((long) (x + enumdirection.getStepX()) & 4194303L) << 42) | (((long) ((y) + enumdirection.getStepY()) & 1048575L)) | (((long) (z + enumdirection.getStepZ()) & 4194303L) << 20);
|
||||
+ }
|
||||
+ // Paper end
|
||||
public static long offset(long packed, int x, int y, int z) {
|
||||
- return asLong(x(packed) + x, y(packed) + y, z(packed) + z);
|
||||
+ return (((long) ((int) (packed >> 42) + x) & 4194303L) << 42) | (((long) ((int) (packed << 44 >> 44) + y) & 1048575L)) | (((long) ((int) (packed << 22 >> 42) + z) & 4194303L) << 20); // Simplify to reduce instruction count
|
||||
}
|
||||
|
||||
public static int posToSectionCoord(double coord) {
|
||||
@@ -86,10 +94,7 @@ public class SectionPos extends Vec3i {
|
||||
}
|
||||
|
||||
public static short sectionRelativePos(BlockPos pos) {
|
||||
- int i = sectionRelative(pos.getX());
|
||||
- int j = sectionRelative(pos.getY());
|
||||
- int k = sectionRelative(pos.getZ());
|
||||
- return (short)(i << 8 | k << 4 | j << 0);
|
||||
+ return (short) ((pos.getX() & 15) << 8 | (pos.getZ() & 15) << 4 | pos.getY() & 15); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static int sectionRelativeX(short packedLocalPos) {
|
||||
@@ -152,16 +157,16 @@ public class SectionPos extends Vec3i {
|
||||
return this.getZ();
|
||||
}
|
||||
|
||||
- public int minBlockX() {
|
||||
- return sectionToBlockCoord(this.x());
|
||||
+ public final int minBlockX() { // Paper - make final
|
||||
+ return this.getX() << 4; // Paper - inline
|
||||
}
|
||||
|
||||
- public int minBlockY() {
|
||||
- return sectionToBlockCoord(this.y());
|
||||
+ public final int minBlockY() { // Paper - make final
|
||||
+ return this.getY() << 4; // Paper - inline
|
||||
}
|
||||
|
||||
- public int minBlockZ() {
|
||||
- return sectionToBlockCoord(this.z());
|
||||
+ public int minBlockZ() { // Paper - make final
|
||||
+ return this.getZ() << 4; // Paper - inline
|
||||
}
|
||||
|
||||
public int maxBlockX() {
|
||||
@@ -177,7 +182,8 @@ public class SectionPos extends Vec3i {
|
||||
}
|
||||
|
||||
public static long blockToSection(long blockPos) {
|
||||
- return asLong(blockToSectionCoord(BlockPos.getX(blockPos)), blockToSectionCoord(BlockPos.getY(blockPos)), blockToSectionCoord(BlockPos.getZ(blockPos)));
|
||||
+ // b(a(BlockPosition.b(i)), a(BlockPosition.c(i)), a(BlockPosition.d(i)));
|
||||
+ return (((long) (int) (blockPos >> 42) & 4194303L) << 42) | (((long) (int) ((blockPos << 52) >> 56) & 1048575L)) | (((long) (int) ((blockPos << 26) >> 42) & 4194303L) << 20); // Simplify to reduce instruction count
|
||||
}
|
||||
|
||||
public static long getZeroNode(long pos) {
|
||||
@@ -201,15 +207,18 @@ public class SectionPos extends Vec3i {
|
||||
return asLong(blockToSectionCoord(pos.getX()), blockToSectionCoord(pos.getY()), blockToSectionCoord(pos.getZ()));
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public static long blockPosAsSectionLong(int i, int j, int k) {
|
||||
+ return (((long) (i >> 4) & 4194303L) << 42) | (((long) (j >> 4) & 1048575L)) | (((long) (k >> 4) & 4194303L) << 20);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public static long asLong(int x, int y, int z) {
|
||||
- long l = 0L;
|
||||
- l |= ((long)x & 4194303L) << 42;
|
||||
- l |= ((long)y & 1048575L) << 0;
|
||||
- return l | ((long)z & 4194303L) << 20;
|
||||
+ return (((long) x & 4194303L) << 42) | (((long) y & 1048575L)) | (((long) z & 4194303L) << 20); // Paper - Simplify to reduce instruction count
|
||||
}
|
||||
|
||||
public long asLong() {
|
||||
- return asLong(this.x(), this.y(), this.z());
|
||||
+ return (((long) getX() & 4194303L) << 42) | (((long) getY() & 1048575L)) | (((long) getZ() & 4194303L) << 20); // Paper - Simplify to reduce instruction count
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,16 +231,11 @@ public class SectionPos extends Vec3i {
|
||||
}
|
||||
|
||||
public static Stream<SectionPos> cube(SectionPos center, int radius) {
|
||||
- int i = center.x();
|
||||
- int j = center.y();
|
||||
- int k = center.z();
|
||||
- return betweenClosedStream(i - radius, j - radius, k - radius, i + radius, j + radius, k + radius);
|
||||
+ return betweenClosedStream(center.getX() - radius, center.getY() - radius, center.getZ() - radius, center.getX() + radius, center.getY() + radius, center.getZ() + radius); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static Stream<SectionPos> aroundChunk(ChunkPos center, int radius, int minY, int maxY) {
|
||||
- int i = center.x;
|
||||
- int j = center.z;
|
||||
- return betweenClosedStream(i - radius, minY, j - radius, i + radius, maxY - 1, j + radius);
|
||||
+ return betweenClosedStream(center.x - radius, 0, center.z - radius, center.x + radius, 15, center.z + radius); // Paper - simplify/inline
|
||||
}
|
||||
|
||||
public static Stream<SectionPos> betweenClosedStream(final int minX, final int minY, final int minZ, final int maxX, final int maxY, final int maxZ) {
|
|
@ -1,121 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 9 Jun 2020 03:33:03 -0400
|
||||
Subject: [PATCH] Add Plugin Tickets to API Chunk Methods
|
||||
|
||||
Like previous versions, plugins loading chunks kept them loaded until
|
||||
they garbage collected to avoid constant spamming of chunk loads
|
||||
|
||||
This adds tickets to a few more places so that they can be unloaded.
|
||||
|
||||
Additionally, this drops their ticket level to BORDER so they wont be ticking
|
||||
so they will just sit inactive instead.
|
||||
|
||||
Using .loadChunk to keep a chunk ticking was a horrible idea for upstream
|
||||
when we have TWO methods that are able to do that already in the API.
|
||||
|
||||
Also reduce their collection count down to a maximum of 1 second. Barely
|
||||
anyone knows what chunk-gc is in bukkit.yml as its less relevant now, and
|
||||
since this wasn't spigot behavior, this is safe to mostly ignore (unless someone
|
||||
wants it to collect even faster, they can restore that setting back to 1 instead of 20+)
|
||||
|
||||
Not adding it to .getType() though to keep behavior consistent with vanilla for performance reasons.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index b4cc5f89b6694f1f3fc38d822a0f503c170d45c4..2d7de60d7e663b91f0a72241f24913338bd725dd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -358,7 +358,7 @@ public final class CraftServer implements Server {
|
||||
this.overrideSpawnLimits();
|
||||
console.autosavePeriod = this.configuration.getInt("ticks-per.autosave");
|
||||
this.warningState = WarningState.value(this.configuration.getString("settings.deprecated-verbose"));
|
||||
- TicketType.PLUGIN.timeout = this.configuration.getInt("chunk-gc.period-in-ticks");
|
||||
+ TicketType.PLUGIN.timeout = Math.min(20, this.configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second
|
||||
this.minimumAPI = this.configuration.getString("settings.minimum-api");
|
||||
this.loadIcon();
|
||||
|
||||
@@ -929,7 +929,7 @@ public final class CraftServer implements Server {
|
||||
this.console.setMotd(config.motd);
|
||||
this.overrideSpawnLimits();
|
||||
this.warningState = WarningState.value(this.configuration.getString("settings.deprecated-verbose"));
|
||||
- TicketType.PLUGIN.timeout = this.configuration.getInt("chunk-gc.period-in-ticks");
|
||||
+ TicketType.PLUGIN.timeout = Math.min(20, configuration.getInt("chunk-gc.period-in-ticks")); // Paper - cap plugin loads to 1 second
|
||||
this.minimumAPI = this.configuration.getString("settings.minimum-api");
|
||||
this.printSaveWarning = false;
|
||||
console.autosavePeriod = this.configuration.getInt("ticks-per.autosave");
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 21927118d1762302dc560b385fd3a4322840031f..b234ba968e82ddf1e8f7c84d3a17659e3beda2b3 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -283,8 +283,21 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public Chunk getChunkAt(int x, int z) {
|
||||
- return this.world.getChunkSource().getChunk(x, z, true).bukkitChunk;
|
||||
+ // Paper start - add ticket to hold chunk for a little while longer if plugin accesses it
|
||||
+ net.minecraft.world.level.chunk.LevelChunk chunk = world.getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
||||
+ if (chunk == null) {
|
||||
+ addTicket(x, z);
|
||||
+ chunk = this.world.getChunkSource().getChunk(x, z, true);
|
||||
+ }
|
||||
+ return chunk.bukkitChunk;
|
||||
+ // Paper end
|
||||
+ }
|
||||
+
|
||||
+ // Paper start
|
||||
+ private void addTicket(int x, int z) {
|
||||
+ net.minecraft.server.MCUtil.MAIN_EXECUTOR.execute(() -> world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
@Override
|
||||
public Chunk getChunkAt(Block block) {
|
||||
@@ -351,7 +364,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
public boolean unloadChunkRequest(int x, int z) {
|
||||
org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
|
||||
if (this.isChunkLoaded(x, z)) {
|
||||
- this.world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 1, Unit.INSTANCE);
|
||||
+ this.world.getChunkSource().removeRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE); // Paper
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -434,9 +447,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
org.spigotmc.AsyncCatcher.catchOp("chunk load"); // Spigot
|
||||
// Paper start - Optimize this method
|
||||
ChunkPos chunkPos = new ChunkPos(x, z);
|
||||
+ ChunkAccess immediate = world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); // Paper
|
||||
+ if (immediate != null) return true; // Paper
|
||||
|
||||
if (!generate) {
|
||||
- ChunkAccess immediate = world.getChunkSource().getChunkAtImmediately(x, z);
|
||||
+
|
||||
+ //IChunkAccess immediate = world.getChunkProvider().getChunkAtImmediately(x, z); // Paper
|
||||
if (immediate == null) {
|
||||
immediate = world.getChunkSource().chunkMap.getUnloadingChunk(x, z);
|
||||
}
|
||||
@@ -444,7 +460,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
if (!(immediate instanceof ImposterProtoChunk) && !(immediate instanceof net.minecraft.world.level.chunk.LevelChunk)) {
|
||||
return false; // not full status
|
||||
}
|
||||
- world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE);
|
||||
+ world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 0, Unit.INSTANCE); // Paper
|
||||
world.getChunk(x, z); // make sure we're at ticket level 32 or lower
|
||||
return true;
|
||||
}
|
||||
@@ -470,7 +486,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
// we do this so we do not re-read the chunk data on disk
|
||||
}
|
||||
|
||||
- world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 1, Unit.INSTANCE);
|
||||
+ world.getChunkSource().addRegionTicket(TicketType.PLUGIN, chunkPos, 0, Unit.INSTANCE); // Paper
|
||||
world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true);
|
||||
return true;
|
||||
// Paper end
|
||||
@@ -2063,6 +2079,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
return this.world.getChunkSource().getChunkAtAsynchronously(x, z, gen, urgent).thenComposeAsync((either) -> {
|
||||
net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk) either.left().orElse(null);
|
||||
+ if (chunk != null) addTicket(x, z); // Paper
|
||||
return java.util.concurrent.CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
|
||||
}, net.minecraft.server.MinecraftServer.getServer());
|
||||
}
|
|
@ -1,376 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 9 Jun 2019 03:53:22 +0100
|
||||
Subject: [PATCH] incremental chunk and player saving
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 3496da11b02d823f6445b6b50d44ee2d2d7435af..2257a93b9f28a3b30f03ecb08e21346e0deeb8bf 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -852,7 +852,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
try {
|
||||
this.isSaving = true;
|
||||
- this.getPlayerList().saveAll();
|
||||
+ this.getPlayerList().saveAll(); // Diff on change
|
||||
flag3 = this.saveAllChunks(suppressLogs, flush, force);
|
||||
} finally {
|
||||
this.isSaving = false;
|
||||
@@ -1399,13 +1399,28 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
}
|
||||
|
||||
- if (this.autosavePeriod > 0 && this.tickCount % this.autosavePeriod == 0) { // CraftBukkit
|
||||
- MinecraftServer.LOGGER.debug("Autosave started");
|
||||
- this.profiler.push("save");
|
||||
- this.saveEverything(true, false, false);
|
||||
- this.profiler.pop();
|
||||
- MinecraftServer.LOGGER.debug("Autosave finished");
|
||||
+ // Paper start - incremental chunk and player saving
|
||||
+ int playerSaveInterval = io.papermc.paper.configuration.GlobalConfiguration.get().playerAutoSave.rate;
|
||||
+ if (playerSaveInterval < 0) {
|
||||
+ playerSaveInterval = autosavePeriod;
|
||||
}
|
||||
+ this.profiler.push("save");
|
||||
+ final boolean fullSave = autosavePeriod > 0 && this.tickCount % autosavePeriod == 0;
|
||||
+ try {
|
||||
+ this.isSaving = true;
|
||||
+ if (playerSaveInterval > 0) {
|
||||
+ this.playerList.saveAll(playerSaveInterval);
|
||||
+ }
|
||||
+ for (ServerLevel level : this.getAllLevels()) {
|
||||
+ if (level.paperConfig().chunks.autoSaveInterval.value() > 0) {
|
||||
+ level.saveIncrementally(fullSave);
|
||||
+ }
|
||||
+ }
|
||||
+ } finally {
|
||||
+ this.isSaving = false;
|
||||
+ }
|
||||
+ this.profiler.pop();
|
||||
+ // Paper end
|
||||
io.papermc.paper.util.CachedLists.reset(); // Paper
|
||||
// Paper start - move executeAll() into full server tick timing
|
||||
try (co.aikar.timings.Timing ignored = MinecraftTimings.processTasksTimer.startTiming()) {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
index 4e8a79f2d3b6f52c6284bc9b0ce2423dc43a154f..36a9d52d9af3bc398010c52dc16ab23e53f2702a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
@@ -92,6 +92,8 @@ public class ChunkHolder {
|
||||
this.playersInChunkTickRange = null;
|
||||
}
|
||||
// Paper end - optimise anyPlayerCloseEnoughForSpawning
|
||||
+ long lastAutoSaveTime; // Paper - incremental autosave
|
||||
+ long inactiveTimeStart; // Paper - incremental autosave
|
||||
|
||||
public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) {
|
||||
this.futures = new AtomicReferenceArray(ChunkHolder.CHUNK_STATUSES.size());
|
||||
@@ -502,7 +504,19 @@ public class ChunkHolder {
|
||||
boolean flag2 = playerchunk_state.isOrAfter(ChunkHolder.FullChunkStatus.BORDER);
|
||||
boolean flag3 = playerchunk_state1.isOrAfter(ChunkHolder.FullChunkStatus.BORDER);
|
||||
|
||||
+ boolean prevHasBeenLoaded = this.wasAccessibleSinceLastSave; // Paper
|
||||
this.wasAccessibleSinceLastSave |= flag3;
|
||||
+ // Paper start - incremental autosave
|
||||
+ if (this.wasAccessibleSinceLastSave & !prevHasBeenLoaded) {
|
||||
+ long timeSinceAutoSave = this.inactiveTimeStart - this.lastAutoSaveTime;
|
||||
+ if (timeSinceAutoSave < 0) {
|
||||
+ // safest bet is to assume autosave is needed here
|
||||
+ timeSinceAutoSave = this.chunkMap.level.paperConfig().chunks.autoSaveInterval.value();
|
||||
+ }
|
||||
+ this.lastAutoSaveTime = this.chunkMap.level.getGameTime() - timeSinceAutoSave;
|
||||
+ this.chunkMap.autoSaveQueue.add(this);
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (!flag2 && flag3) {
|
||||
int expectCreateCount = ++this.fullChunkCreateCount; // Paper
|
||||
this.fullChunkFuture = chunkStorage.prepareAccessibleChunk(this);
|
||||
@@ -633,9 +647,33 @@ public class ChunkHolder {
|
||||
}
|
||||
|
||||
public void refreshAccessibility() {
|
||||
+ boolean prev = this.wasAccessibleSinceLastSave; // Paper
|
||||
this.wasAccessibleSinceLastSave = ChunkHolder.getFullChunkStatus(this.ticketLevel).isOrAfter(ChunkHolder.FullChunkStatus.BORDER);
|
||||
+ // Paper start - incremental autosave
|
||||
+ if (prev != this.wasAccessibleSinceLastSave) {
|
||||
+ if (this.wasAccessibleSinceLastSave) {
|
||||
+ long timeSinceAutoSave = this.inactiveTimeStart - this.lastAutoSaveTime;
|
||||
+ if (timeSinceAutoSave < 0) {
|
||||
+ // safest bet is to assume autosave is needed here
|
||||
+ timeSinceAutoSave = this.chunkMap.level.paperConfig().chunks.autoSaveInterval.value();
|
||||
+ }
|
||||
+ this.lastAutoSaveTime = this.chunkMap.level.getGameTime() - timeSinceAutoSave;
|
||||
+ this.chunkMap.autoSaveQueue.add(this);
|
||||
+ } else {
|
||||
+ this.inactiveTimeStart = this.chunkMap.level.getGameTime();
|
||||
+ this.chunkMap.autoSaveQueue.remove(this);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
+ // Paper start - incremental autosave
|
||||
+ public boolean setHasBeenLoaded() {
|
||||
+ this.wasAccessibleSinceLastSave = getFullChunkStatus(this.ticketLevel).isOrAfter(ChunkHolder.FullChunkStatus.BORDER);
|
||||
+ return this.wasAccessibleSinceLastSave;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public void replaceProtoChunk(ImposterProtoChunk chunk) {
|
||||
for (int i = 0; i < this.futures.length(); ++i) {
|
||||
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completablefuture = (CompletableFuture) this.futures.get(i);
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 86cdc8951544c16f8dc5148bc2c7bf9bbf920c60..c468b012197b2c3444ad8bb0d8a9f41c7ab17b10 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -106,6 +106,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
|
||||
import net.minecraft.world.level.storage.DimensionDataStorage;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet; // Paper
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
import org.apache.commons.lang3.mutable.MutableObject;
|
||||
import org.slf4j.Logger;
|
||||
@@ -715,6 +716,64 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
}
|
||||
|
||||
+ // Paper start - incremental autosave
|
||||
+ final ObjectRBTreeSet<ChunkHolder> autoSaveQueue = new ObjectRBTreeSet<>((playerchunk1, playerchunk2) -> {
|
||||
+ int timeCompare = Long.compare(playerchunk1.lastAutoSaveTime, playerchunk2.lastAutoSaveTime);
|
||||
+ if (timeCompare != 0) {
|
||||
+ return timeCompare;
|
||||
+ }
|
||||
+
|
||||
+ return Long.compare(MCUtil.getCoordinateKey(playerchunk1.pos), MCUtil.getCoordinateKey(playerchunk2.pos));
|
||||
+ });
|
||||
+
|
||||
+ protected void saveIncrementally() {
|
||||
+ int savedThisTick = 0;
|
||||
+ // optimized since we search far less chunks to hit ones that need to be saved
|
||||
+ List<ChunkHolder> reschedule = new java.util.ArrayList<>(this.level.paperConfig().chunks.maxAutoSaveChunksPerTick);
|
||||
+ long currentTick = this.level.getGameTime();
|
||||
+ long maxSaveTime = currentTick - this.level.paperConfig().chunks.autoSaveInterval.value();
|
||||
+
|
||||
+ for (Iterator<ChunkHolder> iterator = this.autoSaveQueue.iterator(); iterator.hasNext();) {
|
||||
+ ChunkHolder playerchunk = iterator.next();
|
||||
+ if (playerchunk.lastAutoSaveTime > maxSaveTime) {
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ iterator.remove();
|
||||
+
|
||||
+ ChunkAccess ichunkaccess = playerchunk.getChunkToSave().getNow(null);
|
||||
+ if (ichunkaccess instanceof LevelChunk) {
|
||||
+ boolean shouldSave = ((LevelChunk)ichunkaccess).lastSaveTime <= maxSaveTime;
|
||||
+
|
||||
+ if (shouldSave && this.save(ichunkaccess) && this.level.entityManager.storeChunkSections(playerchunk.pos.toLong(), entity -> {})) {
|
||||
+ ++savedThisTick;
|
||||
+
|
||||
+ if (!playerchunk.setHasBeenLoaded()) {
|
||||
+ // do not fall through to reschedule logic
|
||||
+ playerchunk.inactiveTimeStart = currentTick;
|
||||
+ if (savedThisTick >= this.level.paperConfig().chunks.maxAutoSaveChunksPerTick) {
|
||||
+ break;
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ reschedule.add(playerchunk);
|
||||
+
|
||||
+ if (savedThisTick >= this.level.paperConfig().chunks.maxAutoSaveChunksPerTick) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0, len = reschedule.size(); i < len; ++i) {
|
||||
+ ChunkHolder playerchunk = reschedule.get(i);
|
||||
+ playerchunk.lastAutoSaveTime = this.level.getGameTime();
|
||||
+ this.autoSaveQueue.add(playerchunk);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
protected void saveAllChunks(boolean flush) {
|
||||
if (flush) {
|
||||
List<ChunkHolder> list = (List) this.visibleChunkMap.values().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList());
|
||||
@@ -799,13 +858,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
int l = 0;
|
||||
- ObjectIterator objectiterator = this.visibleChunkMap.values().iterator();
|
||||
-
|
||||
- while (l < 20 && shouldKeepTicking.getAsBoolean() && objectiterator.hasNext()) {
|
||||
- if (this.saveChunkIfNeeded((ChunkHolder) objectiterator.next())) {
|
||||
- ++l;
|
||||
- }
|
||||
- }
|
||||
+ // Paper - incremental chunk and player saving
|
||||
|
||||
}
|
||||
|
||||
@@ -843,6 +896,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
this.level.unload(chunk);
|
||||
}
|
||||
+ this.autoSaveQueue.remove(holder); // Paper
|
||||
|
||||
this.lightEngine.updateChunkStatus(ichunkaccess.getPos());
|
||||
this.lightEngine.tryScheduleUpdate();
|
||||
@@ -1263,6 +1317,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
asyncSaveData, chunk);
|
||||
|
||||
chunk.setUnsaved(false);
|
||||
+ chunk.setLastSaved(this.level.getGameTime()); // Paper - track last saved time
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@@ -1272,6 +1327,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
if (!chunk.isUnsaved()) {
|
||||
return false;
|
||||
} else {
|
||||
+ chunk.setLastSaved(this.level.getGameTime()); // Paper - track save time
|
||||
chunk.setUnsaved(false);
|
||||
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 1d9a0f6effa1654609f4d0752ec69eed6ab7134b..585892f19bc0aea89889a358c0407f2975b9efe5 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -814,6 +814,15 @@ public class ServerChunkCache extends ChunkSource {
|
||||
} // Paper - Timings
|
||||
}
|
||||
|
||||
+ // Paper start - duplicate save, but call incremental
|
||||
+ public void saveIncrementally() {
|
||||
+ this.runDistanceManagerUpdates();
|
||||
+ try (co.aikar.timings.Timing timed = level.timings.chunkSaveData.startTiming()) { // Paper - Timings
|
||||
+ this.chunkMap.saveIncrementally();
|
||||
+ } // Paper - Timings
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
// CraftBukkit start
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 443044aa09b80bdbbcd202b53d265c635b50015f..848690e6dfaec00ec9b8a8397d2a6d37f24c8d12 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1082,6 +1082,37 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
return !this.server.isUnderSpawnProtection(this, pos, player) && this.getWorldBorder().isWithinBounds(pos);
|
||||
}
|
||||
|
||||
+ // Paper start - derived from below
|
||||
+ public void saveIncrementally(boolean doFull) {
|
||||
+ ServerChunkCache chunkproviderserver = this.getChunkSource();
|
||||
+
|
||||
+ if (doFull) {
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld()));
|
||||
+ }
|
||||
+
|
||||
+ try (co.aikar.timings.Timing ignored = this.timings.worldSave.startTiming()) {
|
||||
+ if (doFull) {
|
||||
+ this.saveLevelData();
|
||||
+ }
|
||||
+
|
||||
+ this.timings.worldSaveChunks.startTiming(); // Paper
|
||||
+ if (!this.noSave()) chunkproviderserver.saveIncrementally();
|
||||
+ this.timings.worldSaveChunks.stopTiming(); // Paper
|
||||
+
|
||||
+ // Copied from save()
|
||||
+ // CraftBukkit start - moved from MinecraftServer.saveChunks
|
||||
+ if (doFull) { // Paper
|
||||
+ ServerLevel worldserver1 = this;
|
||||
+
|
||||
+ this.serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings());
|
||||
+ this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save());
|
||||
+ this.convertable.saveDataTag(this.server.registryHolder, this.serverLevelData, this.server.getPlayerList().getSingleplayerData());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public void save(@Nullable ProgressListener progressListener, boolean flush, boolean savingDisabled) {
|
||||
ServerChunkCache chunkproviderserver = this.getChunkSource();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 7c014f288184328384a811ecbeef83406a780289..fd46ec45d7f6b43cc02069ff3f2dbbdcf1e66d3c 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -178,6 +178,7 @@ import org.bukkit.inventory.MainHand;
|
||||
public class ServerPlayer extends Player {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
+ public long lastSave = MinecraftServer.currentTick; // Paper
|
||||
private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32;
|
||||
private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10;
|
||||
public ServerGamePacketListenerImpl connection;
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 4b9e030016bef762c01ace5181ade7d1480b8702..c1e62a0d1655993430da7e4cbd8075cd4239adb4 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -561,6 +561,7 @@ public abstract class PlayerList {
|
||||
protected void save(ServerPlayer player) {
|
||||
if (!player.getBukkitEntity().isPersistent()) return; // CraftBukkit
|
||||
if (!player.didPlayerJoinEvent) return; // Paper - If we never fired PJE, we disconnected during login. Data has not changed, and additionally, our saved vehicle is not loaded! If we save now, we will lose our vehicle (CraftBukkit bug)
|
||||
+ player.lastSave = MinecraftServer.currentTick; // Paper
|
||||
this.playerIo.save(player);
|
||||
ServerStatsCounter serverstatisticmanager = (ServerStatsCounter) player.getStats(); // CraftBukkit
|
||||
|
||||
@@ -1163,10 +1164,22 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public void saveAll() {
|
||||
+ // Paper start - incremental player saving
|
||||
+ this.saveAll(-1);
|
||||
+ }
|
||||
+
|
||||
+ public void saveAll(int interval) {
|
||||
net.minecraft.server.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main
|
||||
MinecraftTimings.savePlayers.startTiming(); // Paper
|
||||
+ int numSaved = 0;
|
||||
+ long now = MinecraftServer.currentTick;
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
- this.save(this.players.get(i));
|
||||
+ ServerPlayer entityplayer = this.players.get(i);
|
||||
+ if (interval == -1 || now - entityplayer.lastSave >= interval) {
|
||||
+ this.save(entityplayer);
|
||||
+ if (interval != -1 && ++numSaved <= io.papermc.paper.configuration.GlobalConfiguration.get().playerAutoSave.maxPerTick()) { break; }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
MinecraftTimings.savePlayers.stopTiming(); // Paper
|
||||
return null; }); // Paper - ensure main
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
index 8dd9879d52ba9bd816fcfa5413ef3bfc25d562c7..44e1fdbf6798034b9092fe151568ff392da8af08 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
@@ -457,6 +457,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
|
||||
public LevelHeightAccessor getHeightAccessorForGeneration() {
|
||||
return this;
|
||||
}
|
||||
+ public void setLastSaved(long ticks) {} // Paper
|
||||
|
||||
public static record TicksToSave(SerializableTickContainer<Block> blocks, SerializableTickContainer<Fluid> fluids) {
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index 291bcca206722c86bca6d13058d18c413c38d256..f8a3048fa80758d82f2e92d48bd3cd2c585ae6c2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -87,6 +87,12 @@ public class LevelChunk extends ChunkAccess {
|
||||
private final Int2ObjectMap<GameEventDispatcher> gameEventDispatcherSections;
|
||||
private final LevelChunkTicks<Block> blockTicks;
|
||||
private final LevelChunkTicks<Fluid> fluidTicks;
|
||||
+ // Paper start - track last save time
|
||||
+ public long lastSaveTime;
|
||||
+ public void setLastSaved(long ticks) {
|
||||
+ this.lastSaveTime = ticks;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public LevelChunk(Level world, ChunkPos pos) {
|
||||
this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null);
|
|
@ -1,297 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Mon, 27 Apr 2020 04:05:38 -0700
|
||||
Subject: [PATCH] Stop copy-on-write operations for updating light data
|
||||
|
||||
Causes huge memory allocations + gc issues
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java b/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java
|
||||
index 573cdb0897978eef8f5fc906ed4928293f4b2ab9..314b46f0becd088d26956b45981217b128d539cb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/lighting/BlockLightSectionStorage.java
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.world.level.chunk.LightChunkGetter;
|
||||
|
||||
public class BlockLightSectionStorage extends LayerLightSectionStorage<BlockLightSectionStorage.BlockDataLayerStorageMap> {
|
||||
protected BlockLightSectionStorage(LightChunkGetter chunkProvider) {
|
||||
- super(LightLayer.BLOCK, chunkProvider, new BlockLightSectionStorage.BlockDataLayerStorageMap(new Long2ObjectOpenHashMap<>()));
|
||||
+ super(LightLayer.BLOCK, chunkProvider, new BlockLightSectionStorage.BlockDataLayerStorageMap(new com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<>(), false)); // Paper - avoid copying light data
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -20,13 +20,13 @@ public class BlockLightSectionStorage extends LayerLightSectionStorage<BlockLigh
|
||||
}
|
||||
|
||||
protected static final class BlockDataLayerStorageMap extends DataLayerStorageMap<BlockLightSectionStorage.BlockDataLayerStorageMap> {
|
||||
- public BlockDataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays) {
|
||||
- super(arrays);
|
||||
+ public BlockDataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> long2objectopenhashmap, boolean isVisible) { // Paper - avoid copying light data
|
||||
+ super(long2objectopenhashmap, isVisible); // Paper - avoid copying light data
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockLightSectionStorage.BlockDataLayerStorageMap copy() {
|
||||
- return new BlockLightSectionStorage.BlockDataLayerStorageMap(this.map.clone());
|
||||
+ return new BlockDataLayerStorageMap(this.data, true); // Paper - avoid copying light data
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java b/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java
|
||||
index 67ff66e232592203cf8dad605ad01eabc4dded89..f357a3473682c2d37a20fb862522c67b9979402a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/lighting/DataLayerStorageMap.java
|
||||
@@ -9,10 +9,23 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> {
|
||||
private final long[] lastSectionKeys = new long[2];
|
||||
private final DataLayer[] lastSections = new DataLayer[2];
|
||||
private boolean cacheEnabled;
|
||||
- protected final Long2ObjectOpenHashMap<DataLayer> map;
|
||||
+ protected final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> data; // Paper - avoid copying light data
|
||||
+ protected final boolean isVisible; // Paper - avoid copying light data
|
||||
+ java.util.function.Function<Long, DataLayer> lookup; // Paper - faster branchless lookup
|
||||
|
||||
- protected DataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays) {
|
||||
- this.map = arrays;
|
||||
+ // Paper start - avoid copying light data
|
||||
+ protected DataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> data, boolean isVisible) {
|
||||
+ if (isVisible) {
|
||||
+ data.performUpdatesLockMap();
|
||||
+ }
|
||||
+ this.data = data;
|
||||
+ this.isVisible = isVisible;
|
||||
+ if (isVisible) {
|
||||
+ lookup = data::getVisibleAsync;
|
||||
+ } else {
|
||||
+ lookup = data::getUpdating;
|
||||
+ }
|
||||
+ // Paper end - avoid copying light data
|
||||
this.clearCache();
|
||||
this.cacheEnabled = true;
|
||||
}
|
||||
@@ -20,16 +33,17 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> {
|
||||
public abstract M copy();
|
||||
|
||||
public void copyDataLayer(long pos) {
|
||||
- this.map.put(pos, this.map.get(pos).copy());
|
||||
+ if (this.isVisible) { throw new IllegalStateException("writing to visible data"); } // Paper - avoid copying light data
|
||||
+ this.data.queueUpdate(pos, ((DataLayer) this.data.getUpdating(pos)).copy()); // Paper - avoid copying light data
|
||||
this.clearCache();
|
||||
}
|
||||
|
||||
public boolean hasLayer(long chunkPos) {
|
||||
- return this.map.containsKey(chunkPos);
|
||||
+ return lookup.apply(chunkPos) != null; // Paper - avoid copying light data
|
||||
}
|
||||
|
||||
@Nullable
|
||||
- public DataLayer getLayer(long chunkPos) {
|
||||
+ public final DataLayer getLayer(long chunkPos) { // Paper - final
|
||||
if (this.cacheEnabled) {
|
||||
for(int i = 0; i < 2; ++i) {
|
||||
if (chunkPos == this.lastSectionKeys[i]) {
|
||||
@@ -38,7 +52,7 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> {
|
||||
}
|
||||
}
|
||||
|
||||
- DataLayer dataLayer = this.map.get(chunkPos);
|
||||
+ DataLayer dataLayer = lookup.apply(chunkPos); // Paper - avoid copying light data
|
||||
if (dataLayer == null) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -58,11 +72,13 @@ public abstract class DataLayerStorageMap<M extends DataLayerStorageMap<M>> {
|
||||
|
||||
@Nullable
|
||||
public DataLayer removeLayer(long chunkPos) {
|
||||
- return this.map.remove(chunkPos);
|
||||
+ if (this.isVisible) { throw new IllegalStateException("writing to visible data"); } // Paper - avoid copying light data
|
||||
+ return (DataLayer) this.data.queueRemove(chunkPos); // Paper - avoid copying light data
|
||||
}
|
||||
|
||||
public void setLayer(long pos, DataLayer data) {
|
||||
- this.map.put(pos, data);
|
||||
+ if (this.isVisible) { throw new IllegalStateException("writing to visible data"); } // Paper - avoid copying light data
|
||||
+ this.data.queueUpdate(pos, data); // Paper - avoid copying light data
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java b/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java
|
||||
index c899674ee24167ee3abdf1588d7396df0ab4f0aa..85175b01b1623b3bc66c65805cec26eaead48265 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/lighting/LayerLightSectionStorage.java
|
||||
@@ -27,7 +27,7 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>>
|
||||
protected final LongSet dataSectionSet = new LongOpenHashSet();
|
||||
protected final LongSet toMarkNoData = new LongOpenHashSet();
|
||||
protected final LongSet toMarkData = new LongOpenHashSet();
|
||||
- protected volatile M visibleSectionData;
|
||||
+ protected volatile M e_visible; protected final Object visibleUpdateLock = new Object(); // Paper - diff on change, should be "visible" - force compile fail on usage change
|
||||
protected final M updatingSectionData;
|
||||
protected final LongSet changedSections = new LongOpenHashSet();
|
||||
protected final LongSet sectionsAffectedByLightUpdates = new LongOpenHashSet();
|
||||
@@ -42,8 +42,8 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>>
|
||||
this.layer = lightType;
|
||||
this.chunkSource = chunkProvider;
|
||||
this.updatingSectionData = lightData;
|
||||
- this.visibleSectionData = lightData.copy();
|
||||
- this.visibleSectionData.disableCache();
|
||||
+ this.e_visible = lightData.copy(); // Paper - avoid copying light dat
|
||||
+ this.e_visible.disableCache(); // Paper - avoid copying light dat
|
||||
}
|
||||
|
||||
protected boolean storingLightForSection(long sectionPos) {
|
||||
@@ -52,7 +52,15 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>>
|
||||
|
||||
@Nullable
|
||||
protected DataLayer getDataLayer(long sectionPos, boolean cached) {
|
||||
- return this.getDataLayer((M)(cached ? this.updatingSectionData : this.visibleSectionData), sectionPos);
|
||||
+ // Paper start - avoid copying light data
|
||||
+ if (cached) {
|
||||
+ return this.getDataLayer(this.updatingSectionData, sectionPos);
|
||||
+ } else {
|
||||
+ synchronized (this.visibleUpdateLock) {
|
||||
+ return this.getDataLayer(this.e_visible, sectionPos);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - avoid copying light data
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -342,9 +350,11 @@ public abstract class LayerLightSectionStorage<M extends DataLayerStorageMap<M>>
|
||||
|
||||
protected void swapSectionMap() {
|
||||
if (!this.changedSections.isEmpty()) {
|
||||
+ synchronized (this.visibleUpdateLock) { // Paper - avoid copying light data
|
||||
M dataLayerStorageMap = this.updatingSectionData.copy();
|
||||
dataLayerStorageMap.disableCache();
|
||||
- this.visibleSectionData = dataLayerStorageMap;
|
||||
+ this.e_visible = dataLayerStorageMap; // Paper - avoid copying light data
|
||||
+ } // Paper - avoid copying light data
|
||||
this.changedSections.clear();
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java b/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java
|
||||
index 59d2af9f883541518c203302257f03dbe957aa0b..e6c857c8b4e4e65e3cf6a75ce6d844ff61acb566 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/lighting/SkyLightSectionStorage.java
|
||||
@@ -21,7 +21,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
|
||||
private volatile boolean hasSourceInconsistencies;
|
||||
|
||||
protected SkyLightSectionStorage(LightChunkGetter chunkProvider) {
|
||||
- super(LightLayer.SKY, chunkProvider, new SkyLightSectionStorage.SkyDataLayerStorageMap(new Long2ObjectOpenHashMap<>(), new Long2IntOpenHashMap(), Integer.MAX_VALUE));
|
||||
+ super(LightLayer.SKY, chunkProvider, new SkyLightSectionStorage.SkyDataLayerStorageMap(new com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<>(), new com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int(), Integer.MAX_VALUE, false)); // Paper - avoid copying light data
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,8 +32,9 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
|
||||
protected int getLightValue(long blockPos, boolean cached) {
|
||||
long l = SectionPos.blockToSection(blockPos);
|
||||
int i = SectionPos.y(l);
|
||||
- SkyLightSectionStorage.SkyDataLayerStorageMap skyDataLayerStorageMap = cached ? this.updatingSectionData : this.visibleSectionData;
|
||||
- int j = skyDataLayerStorageMap.topSections.get(SectionPos.getZeroNode(l));
|
||||
+ synchronized (this.visibleUpdateLock) { // Paper - avoid copying light data
|
||||
+ SkyLightSectionStorage.SkyDataLayerStorageMap skyDataLayerStorageMap = (SkyLightSectionStorage.SkyDataLayerStorageMap) this.e_visible; // Paper - avoid copying light data - must be after lock acquire
|
||||
+ int j = skyDataLayerStorageMap.otherData.getVisibleAsync(SectionPos.getZeroNode(l)); // Paper - avoid copying light data
|
||||
if (j != skyDataLayerStorageMap.currentLowestY && i < j) {
|
||||
DataLayer dataLayer = this.getDataLayer(skyDataLayerStorageMap, l);
|
||||
if (dataLayer == null) {
|
||||
@@ -52,6 +53,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
|
||||
} else {
|
||||
return cached && !this.lightOnInSection(l) ? 0 : 15;
|
||||
}
|
||||
+ } // Paper - avoid copying light data
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,13 +61,13 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
|
||||
int i = SectionPos.y(sectionPos);
|
||||
if ((this.updatingSectionData).currentLowestY > i) {
|
||||
(this.updatingSectionData).currentLowestY = i;
|
||||
- (this.updatingSectionData).topSections.defaultReturnValue((this.updatingSectionData).currentLowestY);
|
||||
+ (this.updatingSectionData).otherData.queueDefaultReturnValue((this.updatingSectionData).currentLowestY); // Paper - avoid copying light data
|
||||
}
|
||||
|
||||
long l = SectionPos.getZeroNode(sectionPos);
|
||||
- int j = (this.updatingSectionData).topSections.get(l);
|
||||
+ int j = (this.updatingSectionData).otherData.getUpdating(l); // Paper - avoid copying light data
|
||||
if (j < i + 1) {
|
||||
- (this.updatingSectionData).topSections.put(l, i + 1);
|
||||
+ (this.updatingSectionData).otherData.queueUpdate(l, i + 1); // Paper - avoid copying light data
|
||||
if (this.columnsWithSkySources.contains(l)) {
|
||||
this.queueAddSource(sectionPos);
|
||||
if (j > (this.updatingSectionData).currentLowestY) {
|
||||
@@ -102,19 +104,19 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
|
||||
}
|
||||
|
||||
int i = SectionPos.y(sectionPos);
|
||||
- if ((this.updatingSectionData).topSections.get(l) == i + 1) {
|
||||
+ if ((this.updatingSectionData).otherData.getUpdating(l) == i + 1) { // Paper - avoid copying light data
|
||||
long m;
|
||||
for(m = sectionPos; !this.storingLightForSection(m) && this.hasSectionsBelow(i); m = SectionPos.offset(m, Direction.DOWN)) {
|
||||
--i;
|
||||
}
|
||||
|
||||
if (this.storingLightForSection(m)) {
|
||||
- (this.updatingSectionData).topSections.put(l, i + 1);
|
||||
+ (this.updatingSectionData).otherData.queueUpdate(l, i + 1); // Paper - avoid copying light data
|
||||
if (bl) {
|
||||
this.queueAddSource(m);
|
||||
}
|
||||
} else {
|
||||
- (this.updatingSectionData).topSections.remove(l);
|
||||
+ (this.updatingSectionData).otherData.queueRemove(l); // Paper - avoid copying light data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +130,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
|
||||
protected void enableLightSources(long columnPos, boolean enabled) {
|
||||
this.runAllUpdates();
|
||||
if (enabled && this.columnsWithSkySources.add(columnPos)) {
|
||||
- int i = (this.updatingSectionData).topSections.get(columnPos);
|
||||
+ int i = (this.updatingSectionData).otherData.getUpdating(columnPos); // Paper - avoid copying light data
|
||||
if (i != (this.updatingSectionData).currentLowestY) {
|
||||
long l = SectionPos.asLong(SectionPos.x(columnPos), i - 1, SectionPos.z(columnPos));
|
||||
this.queueAddSource(l);
|
||||
@@ -152,7 +154,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
|
||||
return dataLayer;
|
||||
} else {
|
||||
long l = SectionPos.offset(sectionPos, Direction.UP);
|
||||
- int i = (this.updatingSectionData).topSections.get(SectionPos.getZeroNode(sectionPos));
|
||||
+ int i = (this.updatingSectionData).otherData.getUpdating(SectionPos.getZeroNode(sectionPos)); // Paper - avoid copying light data
|
||||
if (i != (this.updatingSectionData).currentLowestY && SectionPos.y(l) < i) {
|
||||
DataLayer dataLayer2;
|
||||
while((dataLayer2 = this.getDataLayer(l, true)) == null) {
|
||||
@@ -275,7 +277,7 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
|
||||
|
||||
protected boolean isAboveData(long sectionPos) {
|
||||
long l = SectionPos.getZeroNode(sectionPos);
|
||||
- int i = (this.updatingSectionData).topSections.get(l);
|
||||
+ int i = (this.updatingSectionData).otherData.getUpdating(l); // Paper - avoid copying light data
|
||||
return i == (this.updatingSectionData).currentLowestY || SectionPos.y(sectionPos) >= i;
|
||||
}
|
||||
|
||||
@@ -286,18 +288,21 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage<SkyLightSec
|
||||
|
||||
protected static final class SkyDataLayerStorageMap extends DataLayerStorageMap<SkyLightSectionStorage.SkyDataLayerStorageMap> {
|
||||
int currentLowestY;
|
||||
- final Long2IntOpenHashMap topSections;
|
||||
-
|
||||
- public SkyDataLayerStorageMap(Long2ObjectOpenHashMap<DataLayer> arrays, Long2IntOpenHashMap columnToTopSection, int minSectionY) {
|
||||
- super(arrays);
|
||||
- this.topSections = columnToTopSection;
|
||||
- columnToTopSection.defaultReturnValue(minSectionY);
|
||||
+ private final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int otherData; // Paper - avoid copying light data
|
||||
+
|
||||
+ // Paper start - avoid copying light data
|
||||
+ public SkyDataLayerStorageMap(com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<DataLayer> arrays, com.destroystokyo.paper.util.map.QueuedChangesMapLong2Int columnToTopSection, int minSectionY, boolean isVisible) {
|
||||
+ super(arrays, isVisible);
|
||||
+ this.otherData = columnToTopSection;
|
||||
+ otherData.queueDefaultReturnValue(minSectionY);
|
||||
+ // Paper end
|
||||
this.currentLowestY = minSectionY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkyLightSectionStorage.SkyDataLayerStorageMap copy() {
|
||||
- return new SkyLightSectionStorage.SkyDataLayerStorageMap(this.map.clone(), this.topSections.clone(), this.currentLowestY);
|
||||
+ this.otherData.performUpdatesLockMap(); // Paper - avoid copying light data
|
||||
+ return new SkyLightSectionStorage.SkyDataLayerStorageMap(this.data, this.otherData, this.currentLowestY, true); // Paper - avoid copying light data
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 29 Jun 2020 03:26:17 -0400
|
||||
Subject: [PATCH] Support old UUID format for NBT
|
||||
|
||||
We have stored UUID in plenty of places that did not get DFU'd
|
||||
|
||||
So just look for old format and load it if it exists.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/CompoundTag.java b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||||
index 0778fdd4f47015787f7ffbfb39c31ec0e1c039bd..912fd5135e89348bdd3c0a8b6c07860ebc106df3 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/CompoundTag.java
|
||||
@@ -181,6 +181,12 @@ public class CompoundTag implements Tag {
|
||||
}
|
||||
|
||||
public void putUUID(String key, UUID value) {
|
||||
+ // Paper start - support old format
|
||||
+ if (this.contains(key + "Most", 99) && this.contains(key + "Least", 99)) {
|
||||
+ this.tags.remove(key + "Most");
|
||||
+ this.tags.remove(key + "Least");
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.tags.put(key, NbtUtils.createUUID(value));
|
||||
}
|
||||
|
||||
@@ -189,10 +195,20 @@ public class CompoundTag implements Tag {
|
||||
* You must use {@link #hasUUID(String)} before or else it <b>will</b> throw an NPE.
|
||||
*/
|
||||
public UUID getUUID(String key) {
|
||||
+ // Paper start - support old format
|
||||
+ if (!contains(key, 11) && this.contains(key + "Most", 99) && this.contains(key + "Least", 99)) {
|
||||
+ return new UUID(this.getLong(key + "Most"), this.getLong(key + "Least"));
|
||||
+ }
|
||||
+ // Paper end
|
||||
return NbtUtils.loadUUID(this.get(key));
|
||||
}
|
||||
|
||||
public boolean hasUUID(String key) {
|
||||
+ // Paper start - support old format
|
||||
+ if (this.contains(key + "Most", 99) && this.contains(key + "Least", 99)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
Tag tag = this.get(key);
|
||||
return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
index 2df77845b78b9d5fae0a36103d42c8202ee2af9e..73ee50e05a1c8d432d9967d4e879b5bb373740ad 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
@@ -74,6 +74,11 @@ public final class NbtUtils {
|
||||
if (nbt.contains("Name", 8)) {
|
||||
string = nbt.getString("Name");
|
||||
}
|
||||
+ // Paper start - support string UUID's
|
||||
+ if (nbt.contains("Id", 8)) {
|
||||
+ uUID = UUID.fromString(nbt.getString("Id"));
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
if (nbt.hasUUID("Id")) {
|
||||
uUID = nbt.getUUID("Id");
|
|
@ -1,47 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 1 Jul 2020 03:12:06 -0400
|
||||
Subject: [PATCH] Clean up duplicated GameProfile Properties
|
||||
|
||||
We had a bug where we accidently cloned properties resulting in skulls
|
||||
growing to large sizes and preventing login.
|
||||
|
||||
This now automatically cleans up the extra properties.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
index 73ee50e05a1c8d432d9967d4e879b5bb373740ad..5dda064813a0eb00438a7df909d51a4b2d48942e 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
@@ -92,7 +92,8 @@ public final class NbtUtils {
|
||||
for(String string2 : compoundTag.getAllKeys()) {
|
||||
ListTag listTag = compoundTag.getList(string2, 10);
|
||||
|
||||
- for(int i = 0; i < listTag.size(); ++i) {
|
||||
+ if (listTag.size() == 0) continue; // Paper - remove duplicate properties
|
||||
+ for (int i = listTag.size() - 1; i < listTag.size(); ++i) { // Paper - remove duplicate properties
|
||||
CompoundTag compoundTag2 = listTag.getCompound(i);
|
||||
String string3 = compoundTag2.getString("Value");
|
||||
if (compoundTag2.contains("Signature", 8)) {
|
||||
diff --git a/src/main/java/net/minecraft/world/item/PlayerHeadItem.java b/src/main/java/net/minecraft/world/item/PlayerHeadItem.java
|
||||
index 2fb1500e9d3202b6377bf4d8e50102a98f409148..72a0c7ad03b18c3156b4f3c7240f7551583f981c 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/PlayerHeadItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/PlayerHeadItem.java
|
||||
@@ -52,6 +52,18 @@ public class PlayerHeadItem extends StandingAndWallBlockItem {
|
||||
});
|
||||
// CraftBukkit start
|
||||
} else {
|
||||
+ // Paper start - clean up old duplicated properties
|
||||
+ CompoundTag properties = nbt.getCompound("SkullOwner").getCompound("Properties");
|
||||
+ for (String key : properties.getAllKeys()) {
|
||||
+ net.minecraft.nbt.ListTag values = properties.getList(key, 10);
|
||||
+ if (values.size() > 1) {
|
||||
+ net.minecraft.nbt.Tag texture = values.get(values.size() - 1);
|
||||
+ values = new net.minecraft.nbt.ListTag();
|
||||
+ values.add(texture);
|
||||
+ properties.put(key, values);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
net.minecraft.nbt.ListTag textures = nbt.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts
|
||||
for (int i = 0; i < textures.size(); i++) {
|
||||
if (textures.get(i) instanceof CompoundTag && !((CompoundTag) textures.get(i)).contains("Signature", 8) && ((CompoundTag) textures.get(i)).getString("Value").trim().isEmpty()) {
|
|
@ -1,44 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 1 Jul 2020 04:50:22 -0400
|
||||
Subject: [PATCH] Convert legacy attributes in Item Meta
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
||||
index 0520c45197629cbdc2777d9ae11eef572e793160..46c313d581b9af6aa0a48f97ae3cc800a88535f2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeMap.java
|
||||
@@ -11,6 +11,20 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
public class CraftAttributeMap implements Attributable {
|
||||
|
||||
private final AttributeMap handle;
|
||||
+ // Paper start - convert legacy attributes
|
||||
+ private static final com.google.common.collect.ImmutableMap<String, String> legacyNMS = com.google.common.collect.ImmutableMap.<String, String>builder().put("generic.maxHealth", "generic.max_health").put("Max Health", "generic.max_health").put("zombie.spawnReinforcements", "zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "zombie.spawn_reinforcements").put("horse.jumpStrength", "horse.jump_strength").put("Jump Strength", "horse.jump_strength").put("generic.followRange", "generic.follow_range").put("Follow Range", "generic.follow_range").put("generic.knockbackResistance", "generic.knockback_resistance").put("Knockback Resistance", "generic.knockback_resistance").put("generic.movementSpeed", "generic.movement_speed").put("Movement Speed", "generic.movement_speed").put("generic.flyingSpeed", "generic.flying_speed").put("Flying Speed", "generic.flying_speed").put("generic.attackDamage", "generic.attack_damage").put("generic.attackKnockback", "generic.attack_knockback").put("generic.attackSpeed", "generic.attack_speed").put("generic.armorToughness", "generic.armor_toughness").build();
|
||||
+
|
||||
+ public static String convertIfNeeded(String nms) {
|
||||
+ if (nms == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ nms = legacyNMS.getOrDefault(nms, nms);
|
||||
+ if (!nms.toLowerCase().equals(nms) || nms.indexOf(' ') != -1) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return nms;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public CraftAttributeMap(AttributeMap handle) {
|
||||
this.handle = handle;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 4304ee35a9bd912c2ae4058febf22f0eea25adbd..4a91da3561d16995e8cfe04ebbc104da009a2503 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -480,7 +480,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
|
||||
AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier);
|
||||
|
||||
- String attributeName = entry.getString(ATTRIBUTES_IDENTIFIER.NBT);
|
||||
+ String attributeName = CraftAttributeMap.convertIfNeeded(entry.getString(ATTRIBUTES_IDENTIFIER.NBT)); // Paper
|
||||
if (attributeName == null || attributeName.isEmpty()) {
|
||||
continue;
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: JRoy <joshroy126@gmail.com>
|
||||
Date: Mon, 29 Jun 2020 17:03:06 -0400
|
||||
Subject: [PATCH] Remove some streams from structures
|
||||
|
||||
This showed up a lot in the spark profiler, should have a low-medium performance improvement.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java b/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java
|
||||
index 89ec6902abaed56e57d3aa7e355a3db70baa02a0..0548be182bc342cc3855dcf7cc11519fc2805121 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java
|
||||
@@ -36,9 +36,10 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker {
|
||||
int j = chunkPos.getMinBlockZ();
|
||||
ObjectList<Beardifier.Rigid> objectList = new ObjectArrayList<>(10);
|
||||
ObjectList<JigsawJunction> objectList2 = new ObjectArrayList<>(32);
|
||||
- structureManager.startsForStructure(chunkPos, (structure) -> {
|
||||
+ // Paper start - replace for each
|
||||
+ for (net.minecraft.world.level.levelgen.structure.StructureStart structureStart : structureManager.startsForStructure(chunkPos, (structure) -> {
|
||||
return structure.terrainAdaptation() != TerrainAdjustment.NONE;
|
||||
- }).forEach((structureStart) -> {
|
||||
+ })) {
|
||||
TerrainAdjustment terrainAdjustment = structureStart.getStructure().terrainAdaptation();
|
||||
|
||||
for(StructurePiece structurePiece : structureStart.getPieces()) {
|
||||
@@ -63,7 +64,7 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker {
|
||||
}
|
||||
}
|
||||
|
||||
- });
|
||||
+ } // Paper
|
||||
return new Beardifier(objectList.iterator(), objectList2.iterator());
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: JRoy <joshroy126@gmail.com>
|
||||
Date: Wed, 1 Jul 2020 18:01:49 -0400
|
||||
Subject: [PATCH] Remove streams from classes related villager gossip
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
index 0de65462956fa734b6405614e047161696e596fb..aa277479f5552503a202a057b1a3ede379f2bbbf 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
@@ -58,8 +58,21 @@ public class GossipContainer {
|
||||
});
|
||||
}
|
||||
|
||||
+ // Paper start - Remove streams from reputation
|
||||
+ private List<GossipContainer.GossipEntry> decompress() {
|
||||
+ List<GossipContainer.GossipEntry> list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>();
|
||||
+ for (Map.Entry<UUID, GossipContainer.EntityGossips> entry : getReputations().entrySet()) {
|
||||
+ for (GossipContainer.GossipEntry cur : entry.getValue().decompress(entry.getKey())) {
|
||||
+ if (cur.weightedValue() != 0)
|
||||
+ list.add(cur);
|
||||
+ }
|
||||
+ }
|
||||
+ return list;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
private Collection<GossipContainer.GossipEntry> selectGossipsForTransfer(RandomSource random, int count) {
|
||||
- List<GossipContainer.GossipEntry> list = this.unpack().collect(Collectors.toList());
|
||||
+ List<GossipContainer.GossipEntry> list = this.decompress(); // Paper - Remove streams from reputation
|
||||
if (list.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
@@ -153,7 +166,7 @@ public class GossipContainer {
|
||||
}
|
||||
|
||||
public <T> Dynamic<T> store(DynamicOps<T> dynamicOps) {
|
||||
- return new Dynamic<>(dynamicOps, dynamicOps.createList(this.unpack().map((gossipEntry) -> {
|
||||
+ return new Dynamic<>(dynamicOps, dynamicOps.createList(this.decompress().stream().map((gossipEntry) -> {
|
||||
return gossipEntry.store(dynamicOps);
|
||||
}).map(Dynamic::getValue)));
|
||||
}
|
||||
@@ -179,11 +192,23 @@ public class GossipContainer {
|
||||
final Object2IntMap<GossipType> entries = new Object2IntOpenHashMap<>();
|
||||
|
||||
public int weightedValue(Predicate<GossipType> gossipTypeFilter) {
|
||||
- return this.entries.object2IntEntrySet().stream().filter((entry) -> {
|
||||
- return gossipTypeFilter.test(entry.getKey());
|
||||
- }).mapToInt((entry) -> {
|
||||
- return entry.getIntValue() * (entry.getKey()).weight;
|
||||
- }).sum();
|
||||
+ // Paper start - Remove streams from reputation
|
||||
+ int weight = 0;
|
||||
+ for (Object2IntMap.Entry<GossipType> entry : entries.object2IntEntrySet()) {
|
||||
+ if (gossipTypeFilter.test(entry.getKey())) {
|
||||
+ weight += entry.getIntValue() * entry.getKey().weight;
|
||||
+ }
|
||||
+ }
|
||||
+ return weight;
|
||||
+ }
|
||||
+
|
||||
+ public List<GossipContainer.GossipEntry> decompress(UUID uuid) {
|
||||
+ List<GossipContainer.GossipEntry> list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>();
|
||||
+ for (Object2IntMap.Entry<GossipType> entry : entries.object2IntEntrySet()) {
|
||||
+ list.add(new GossipContainer.GossipEntry(uuid, entry.getKey(), entry.getIntValue()));
|
||||
+ }
|
||||
+ return list;
|
||||
+ // Paper - end
|
||||
}
|
||||
|
||||
public Stream<GossipContainer.GossipEntry> unpack(UUID target) {
|
|
@ -1,83 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MiniDigger <admin@benndorf.dev>
|
||||
Date: Sat, 6 Jun 2020 18:13:42 +0200
|
||||
Subject: [PATCH] Support components in ItemMeta
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 4a91da3561d16995e8cfe04ebbc104da009a2503..c475ddea1c995df1dfcaf4f491f341761a5f8802 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -874,11 +874,23 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
return CraftChatMessage.fromJSONComponent(displayName);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public net.md_5.bungee.api.chat.BaseComponent[] getDisplayNameComponent() {
|
||||
+ return displayName == null ? new net.md_5.bungee.api.chat.BaseComponent[0] : net.md_5.bungee.chat.ComponentSerializer.parse(displayName);
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
public final void setDisplayName(String name) {
|
||||
this.displayName = CraftChatMessage.fromStringOrNullToJSON(name);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setDisplayNameComponent(net.md_5.bungee.api.chat.BaseComponent[] component) {
|
||||
+ this.displayName = net.md_5.bungee.chat.ComponentSerializer.toString(component);
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
public boolean hasDisplayName() {
|
||||
return this.displayName != null;
|
||||
@@ -1021,6 +1033,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
return this.lore == null ? null : new ArrayList<String>(Lists.transform(this.lore, CraftChatMessage::fromJSONComponent));
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public List<net.md_5.bungee.api.chat.BaseComponent[]> getLoreComponents() {
|
||||
+ return this.lore == null ? null : new ArrayList<>(this.lore.stream().map(entry ->
|
||||
+ net.md_5.bungee.chat.ComponentSerializer.parse(entry)
|
||||
+ ).collect(java.util.stream.Collectors.toList()));
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
public void setLore(List<String> lore) {
|
||||
if (lore == null || lore.isEmpty()) {
|
||||
@@ -1035,6 +1055,21 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setLoreComponents(List<net.md_5.bungee.api.chat.BaseComponent[]> lore) {
|
||||
+ if (lore == null) {
|
||||
+ this.lore = null;
|
||||
+ } else {
|
||||
+ if (this.lore == null) {
|
||||
+ safelyAdd(lore, this.lore = new ArrayList<>(lore.size()), false);
|
||||
+ } else {
|
||||
+ this.lore.clear();
|
||||
+ safelyAdd(lore, this.lore, false);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
public boolean hasCustomModelData() {
|
||||
return this.customModelData != null;
|
||||
@@ -1502,6 +1537,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
}
|
||||
|
||||
for (Object object : addFrom) {
|
||||
+ // Paper start - support components
|
||||
+ if(object instanceof net.md_5.bungee.api.chat.BaseComponent[]) {
|
||||
+ addTo.add(net.md_5.bungee.chat.ComponentSerializer.toString((net.md_5.bungee.api.chat.BaseComponent[]) object));
|
||||
+ } else
|
||||
+ // Paper end
|
||||
if (!(object instanceof String)) {
|
||||
if (object != null) {
|
||||
throw new IllegalArgumentException(addFrom + " cannot contain non-string " + object.getClass().getName());
|
|
@ -1,59 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 3 Jul 2020 15:03:33 -0700
|
||||
Subject: [PATCH] Improve EntityTargetLivingEntityEvent for 1.16 mobs
|
||||
|
||||
CraftBukkit has a bug in their implementation and is incorrectly handling forget
|
||||
Also adds more target reasons for why it forgot target.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java b/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
|
||||
index 44d3c9da39389b72bfc5ee39c1abb6baf9dccdb1..565691aaed71de3efe15dd751fbbbe7849ef56b7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
|
||||
@@ -56,15 +56,15 @@ public class StopAttackingIfTargetInvalid<E extends Mob> extends Behavior<E> {
|
||||
LivingEntity entityliving = this.getAttackTarget(entity);
|
||||
|
||||
if (!entity.canAttack(entityliving)) {
|
||||
- this.clearAttackTarget(entity);
|
||||
+ this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_INVALID); // Paper
|
||||
} else if (this.canGrowTiredOfTryingToReachTarget && StopAttackingIfTargetInvalid.isTiredOfTryingToReachTarget(entity)) {
|
||||
- this.clearAttackTarget(entity);
|
||||
+ this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // Paper
|
||||
} else if (this.isCurrentTargetDeadOrRemoved(entity)) {
|
||||
- this.clearAttackTarget(entity);
|
||||
+ this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_DIED); // Paper
|
||||
} else if (this.isCurrentTargetInDifferentLevel(entity)) {
|
||||
- this.clearAttackTarget(entity);
|
||||
+ this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_OTHER_LEVEL); // Paper
|
||||
} else if (this.stopAttackingWhen.test(this.getAttackTarget(entity))) {
|
||||
- this.clearAttackTarget(entity);
|
||||
+ this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_INVALID); // Paper
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,17 +88,20 @@ public class StopAttackingIfTargetInvalid<E extends Mob> extends Behavior<E> {
|
||||
return optional.isPresent() && !((LivingEntity) optional.get()).isAlive();
|
||||
}
|
||||
|
||||
- protected void clearAttackTarget(E entity) {
|
||||
+ protected void clearAttackTarget(E entity, EntityTargetEvent.TargetReason reason) {
|
||||
// CraftBukkit start
|
||||
- LivingEntity old = entity.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null);
|
||||
- EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(entity, null, (old != null && !old.isAlive()) ? EntityTargetEvent.TargetReason.TARGET_DIED : EntityTargetEvent.TargetReason.FORGOT_TARGET);
|
||||
+ // Paper start - fix this event
|
||||
+ // LivingEntity old = entity.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null);
|
||||
+ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(entity, null, reason);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
- if (event.getTarget() != null) {
|
||||
+ // comment out, bad logic - bad
|
||||
+ /*if (event.getTarget() != null) {
|
||||
entity.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, ((CraftLivingEntity) event.getTarget()).getHandle());
|
||||
return;
|
||||
- }
|
||||
+ }*/
|
||||
+ // Paper end
|
||||
// CraftBukkit end
|
||||
this.onTargetErased.accept(entity, this.getAttackTarget(entity));
|
||||
entity.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET);
|
|
@ -1,40 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Thu, 2 Jul 2020 18:11:43 -0500
|
||||
Subject: [PATCH] Add entity liquid API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 6029cb7d8801c471e596ba027b7e408a27c44db9..c0a2cffadb762240ef8fcdec1bd1e49edd3b5c61 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -1254,5 +1254,29 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getEntitySpawnReason() {
|
||||
return getHandle().spawnReason;
|
||||
}
|
||||
+
|
||||
+ public boolean isInRain() {
|
||||
+ return getHandle().isInRain();
|
||||
+ }
|
||||
+
|
||||
+ public boolean isInBubbleColumn() {
|
||||
+ return getHandle().isInBubbleColumn();
|
||||
+ }
|
||||
+
|
||||
+ public boolean isInWaterOrRain() {
|
||||
+ return getHandle().isInWaterOrRain();
|
||||
+ }
|
||||
+
|
||||
+ public boolean isInWaterOrBubbleColumn() {
|
||||
+ return getHandle().isInWaterOrBubble();
|
||||
+ }
|
||||
+
|
||||
+ public boolean isInWaterOrRainOrBubbleColumn() {
|
||||
+ return getHandle().isInWaterRainOrBubble();
|
||||
+ }
|
||||
+
|
||||
+ public boolean isInLava() {
|
||||
+ return getHandle().isInLava();
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Wed, 1 Jul 2020 11:57:40 -0500
|
||||
Subject: [PATCH] Update itemstack legacy name and lore
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index 5d7e07a9612dc8e62b5843b3c805f6423d5304f2..8400f6fc96efecf0ea77f2e163b589ec375272cd 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -166,6 +166,44 @@ public final class ItemStack {
|
||||
list.sort((java.util.Comparator<? super net.minecraft.nbt.Tag>) enchantSorter); // Paper
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
+
|
||||
+ private void processText() {
|
||||
+ CompoundTag display = getTagElement("display");
|
||||
+ if (display != null) {
|
||||
+ if (display.contains("Name", 8)) {
|
||||
+ String json = display.getString("Name");
|
||||
+ if (json != null && json.contains("\u00A7")) {
|
||||
+ try {
|
||||
+ display.put("Name", convert(json));
|
||||
+ } catch (com.google.gson.JsonParseException jsonparseexception) {
|
||||
+ display.remove("Name");
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (display.contains("Lore", 9)) {
|
||||
+ ListTag list = display.getList("Lore", 8);
|
||||
+ for (int index = 0; index < list.size(); index++) {
|
||||
+ String json = list.getString(index);
|
||||
+ if (json != null && json.contains("\u00A7")) { // Only try if it has legacy in the unparsed json
|
||||
+ try {
|
||||
+ list.set(index, convert(json));
|
||||
+ } catch (com.google.gson.JsonParseException e) {
|
||||
+ list.set(index, net.minecraft.nbt.StringTag.valueOf(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(net.minecraft.network.chat.Component.literal(""))));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private net.minecraft.nbt.StringTag convert(String json) {
|
||||
+ Component component = Component.Serializer.fromJson(json);
|
||||
+ if (component.getContents() instanceof net.minecraft.network.chat.contents.LiteralContents literalContents && literalContents.text().contains("\u00A7") && component.getSiblings().isEmpty()) {
|
||||
+ // Only convert if the root component is a single comp with legacy in it, don't convert already normal components
|
||||
+ component = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(literalContents.text())[0];
|
||||
+ }
|
||||
+ return net.minecraft.nbt.StringTag.valueOf(org.bukkit.craftbukkit.util.CraftChatMessage.toJSON(component));
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
public ItemStack(ItemLike item) {
|
||||
@@ -220,6 +258,7 @@ public final class ItemStack {
|
||||
this.tag = nbttagcompound.getCompound("tag").copy();
|
||||
// CraftBukkit end
|
||||
this.processEnchantOrder(this.tag); // Paper
|
||||
+ this.processText(); // Paper
|
||||
this.getItem().verifyTagAfterLoad(this.tag);
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Wyatt Childers <wchilders@nearce.com>
|
||||
Date: Fri, 3 Jul 2020 14:57:05 -0400
|
||||
Subject: [PATCH] Spawn player in correct world on login
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index c1e62a0d1655993430da7e4cbd8075cd4239adb4..0b301b1f164853bfd23300993288a2958824e287 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -199,7 +199,18 @@ public abstract class PlayerList {
|
||||
}String lastKnownName = s; // Paper
|
||||
// CraftBukkit end
|
||||
|
||||
- if (nbttagcompound != null) {
|
||||
+ // Paper start - move logic in Entity to here, to use bukkit supplied world UUID.
|
||||
+ if (nbttagcompound != null && nbttagcompound.contains("WorldUUIDMost") && nbttagcompound.contains("WorldUUIDLeast")) {
|
||||
+ UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast"));
|
||||
+ org.bukkit.World bWorld = org.bukkit.Bukkit.getServer().getWorld(uid);
|
||||
+ if (bWorld != null) {
|
||||
+ resourcekey = ((CraftWorld) bWorld).getHandle().dimension();
|
||||
+ } else {
|
||||
+ resourcekey = Level.OVERWORLD;
|
||||
+ }
|
||||
+ } else if (nbttagcompound != null) {
|
||||
+ // Vanilla migration support
|
||||
+ // Paper end
|
||||
DataResult<ResourceKey<Level>> dataresult = DimensionType.parseLegacy(new Dynamic(NbtOps.INSTANCE, nbttagcompound.get("Dimension"))); // CraftBukkit - decompile error
|
||||
Logger logger = PlayerList.LOGGER;
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 3 Jul 2020 11:58:56 -0500
|
||||
Subject: [PATCH] Add PrepareResultEvent
|
||||
|
||||
Adds a new event for all crafting stations that generate a result slot item
|
||||
|
||||
Anvil, Grindstone and Smithing now extend this event
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
||||
index eb22059fe008c3d3fc0364a7f85f91b4cca8b328..506d758efbf16da9467f120321d2359a8832e477 100644
|
||||
--- a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
||||
+++ b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
||||
@@ -316,6 +316,7 @@ public class AnvilMenu extends ItemCombinerMenu {
|
||||
}
|
||||
|
||||
this.createResult();
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
||||
}
|
||||
|
||||
public int getCost() {
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java b/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
||||
index fc2b400c58ddbd7b012707c61d9a37363d351251..4f5593d387545545e30475d3edaa92a4306ba96b 100644
|
||||
--- a/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
||||
+++ b/src/main/java/net/minecraft/world/inventory/CartographyTableMenu.java
|
||||
@@ -150,6 +150,7 @@ public class CartographyTableMenu extends AbstractContainerMenu {
|
||||
this.setupResultSlot(itemstack, itemstack1, itemstack2);
|
||||
}
|
||||
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
||||
}
|
||||
|
||||
private void setupResultSlot(ItemStack map, ItemStack item, ItemStack oldResult) {
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java b/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
|
||||
index aa0ba9c7dcb0ee81c9081031c447eeab61d92a10..7a0c38c743ef02f5b9c052f88c2d6429a53b8286 100644
|
||||
--- a/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
|
||||
+++ b/src/main/java/net/minecraft/world/inventory/GrindstoneMenu.java
|
||||
@@ -159,6 +159,7 @@ public class GrindstoneMenu extends AbstractContainerMenu {
|
||||
super.slotsChanged(inventory);
|
||||
if (inventory == this.repairSlots) {
|
||||
this.createResult();
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java b/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java
|
||||
index f5e52220abc5c678c090b32d83eb9644fa91ce9d..35575434f3c90f1bd23df6584ee8a5a991f93f9f 100644
|
||||
--- a/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java
|
||||
+++ b/src/main/java/net/minecraft/world/inventory/ItemCombinerMenu.java
|
||||
@@ -78,6 +78,7 @@ public abstract class ItemCombinerMenu extends AbstractContainerMenu {
|
||||
super.slotsChanged(inventory);
|
||||
if (inventory == this.inputSlots) {
|
||||
this.createResult();
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/LoomMenu.java b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
||||
index 3b3e7a89ce1fc719d241c7a3dc8c746191d91f85..9cbdcb87d76fa36887413754ef625a16624aadd7 100644
|
||||
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
||||
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
|
||||
@@ -243,7 +243,8 @@ public class LoomMenu extends AbstractContainerMenu {
|
||||
this.resultSlot.set(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
- this.broadcastChanges();
|
||||
+ // this.broadcastChanges(); // Paper - done below
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, 3); // Paper
|
||||
} else {
|
||||
this.resultSlot.set(ItemStack.EMPTY);
|
||||
this.selectablePatterns = List.of();
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java b/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
||||
index 92dd2ea23185bba311e184b2ac9744a423c102ea..71bb09e3d31f098503d0e1bdf073b60f07d76ed0 100644
|
||||
--- a/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
||||
+++ b/src/main/java/net/minecraft/world/inventory/SmithingMenu.java
|
||||
@@ -76,6 +76,7 @@ public class SmithingMenu extends ItemCombinerMenu {
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java
|
||||
index cdebd0cdf6eb901464cf4c16089b10ea0147b54d..b47dc7671fab2117b989d647d7e8e36d12af5f76 100644
|
||||
--- a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java
|
||||
+++ b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java
|
||||
@@ -176,6 +176,7 @@ public class StonecutterMenu extends AbstractContainerMenu {
|
||||
this.setupRecipeList(inventory, itemstack);
|
||||
}
|
||||
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(this, RESULT_SLOT); // Paper
|
||||
}
|
||||
|
||||
private void setupRecipeList(Container input, ItemStack stack) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index 9b94df9940040f51fdcc1af5c7da96117af9017e..c2eefe215f47e36cc2b8476750ae00ec88f826a6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -1594,19 +1594,44 @@ public class CraftEventFactory {
|
||||
return event;
|
||||
}
|
||||
|
||||
- public static PrepareAnvilEvent callPrepareAnvilEvent(InventoryView view, ItemStack item) {
|
||||
- PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item).clone());
|
||||
- event.getView().getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
+ // Paper start - disable this method, handled below
|
||||
+ public static void callPrepareAnvilEvent(InventoryView view, ItemStack item) { // Paper - verify nothing uses return - handled below in PrepareResult
|
||||
+ PrepareAnvilEvent event = new PrepareAnvilEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone
|
||||
+ //event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // disable event
|
||||
event.getInventory().setItem(2, event.getResult());
|
||||
- return event;
|
||||
+ //return event; // Paper
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
- public static PrepareSmithingEvent callPrepareSmithingEvent(InventoryView view, ItemStack item) {
|
||||
- PrepareSmithingEvent event = new PrepareSmithingEvent(view, CraftItemStack.asCraftMirror(item).clone());
|
||||
- event.getView().getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
+ // Paper start - disable this method, handled in callPrepareResultEvent
|
||||
+ public static void callPrepareSmithingEvent(InventoryView view, ItemStack item) { // Paper - verify nothing uses return - handled below in PrepareResult
|
||||
+ PrepareSmithingEvent event = new PrepareSmithingEvent(view, CraftItemStack.asCraftMirror(item)); // Paper - remove clone
|
||||
+ //event.getView().getPlayer().getServer().getPluginManager().callEvent(event); // Paper - disable event
|
||||
event.getInventory().setItem(2, event.getResult());
|
||||
- return event;
|
||||
+ //return event; // Paper
|
||||
}
|
||||
+ // Paper end
|
||||
+
|
||||
+ // Paper start - support specific overrides for prepare result
|
||||
+ public static void callPrepareResultEvent(AbstractContainerMenu container, int resultSlot) {
|
||||
+ com.destroystokyo.paper.event.inventory.PrepareResultEvent event;
|
||||
+ InventoryView view = container.getBukkitView();
|
||||
+ org.bukkit.inventory.ItemStack origItem = view.getTopInventory().getItem(resultSlot);
|
||||
+ CraftItemStack result = origItem != null ? CraftItemStack.asCraftCopy(origItem) : null;
|
||||
+ if (view.getTopInventory() instanceof org.bukkit.inventory.AnvilInventory) {
|
||||
+ event = new PrepareAnvilEvent(view, result);
|
||||
+ } else if (view.getTopInventory() instanceof org.bukkit.inventory.GrindstoneInventory) {
|
||||
+ event = new com.destroystokyo.paper.event.inventory.PrepareGrindstoneEvent(view, result);
|
||||
+ } else if (view.getTopInventory() instanceof org.bukkit.inventory.SmithingInventory) {
|
||||
+ event = new PrepareSmithingEvent(view, result);
|
||||
+ } else {
|
||||
+ event = new com.destroystokyo.paper.event.inventory.PrepareResultEvent(view, result);
|
||||
+ }
|
||||
+ event.callEvent();
|
||||
+ event.getInventory().setItem(resultSlot, event.getResult());
|
||||
+ container.broadcastChanges();;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
* Mob spawner event.
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 5 Jul 2020 14:59:31 -0400
|
||||
Subject: [PATCH] Don't check chunk for portal on world gen entity add
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index cf691b94b478dc058af706e1f2d13b51df231779..289073daacc2d477e965e668c6fb4041d27e3f8c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3410,7 +3410,7 @@ public abstract class LivingEntity extends Entity {
|
||||
Entity entity = this.getVehicle();
|
||||
|
||||
super.stopRiding(suppressCancellation); // Paper - suppress
|
||||
- if (entity != null && entity != this.getVehicle() && !this.level.isClientSide) {
|
||||
+ if (entity != null && entity != this.getVehicle() && !this.level.isClientSide && entity.valid) { // Paper - don't process on world gen
|
||||
this.dismountVehicle(entity);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,69 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Sun, 5 Jul 2020 22:38:18 -0400
|
||||
Subject: [PATCH] Optimize NetworkManager Exception Handling
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/ConnectionProtocol.java b/src/main/java/net/minecraft/network/ConnectionProtocol.java
|
||||
index d15ef330db69e0c948824d9bf112a26680c90b1b..25c98fa91260c5fe3bd42c0861e3834b4ec5dc5c 100644
|
||||
--- a/src/main/java/net/minecraft/network/ConnectionProtocol.java
|
||||
+++ b/src/main/java/net/minecraft/network/ConnectionProtocol.java
|
||||
@@ -299,6 +299,7 @@ public enum ConnectionProtocol {
|
||||
|
||||
@Nullable
|
||||
public Packet<?> createPacket(int id, FriendlyByteBuf buf) {
|
||||
+ if (id < 0 || id >= this.idToDeserializer.size()) return null; // Paper
|
||||
Function<FriendlyByteBuf, ? extends Packet<T>> function = this.idToDeserializer.get(id);
|
||||
return function != null ? function.apply(buf) : null;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/network/Varint21FrameDecoder.java b/src/main/java/net/minecraft/network/Varint21FrameDecoder.java
|
||||
index 99b581052f937b0f2d6b5d73de699008c1d51774..ed54479b14dcfc736ac90749106557f0ff537550 100644
|
||||
--- a/src/main/java/net/minecraft/network/Varint21FrameDecoder.java
|
||||
+++ b/src/main/java/net/minecraft/network/Varint21FrameDecoder.java
|
||||
@@ -8,8 +8,20 @@ import io.netty.handler.codec.CorruptedFrameException;
|
||||
import java.util.List;
|
||||
|
||||
public class Varint21FrameDecoder extends ByteToMessageDecoder {
|
||||
+ private final byte[] lenBuf = new byte[3]; // Paper
|
||||
+ @Override
|
||||
protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) {
|
||||
+ // Paper start - if channel is not active just discard the packet
|
||||
+ if (!channelHandlerContext.channel().isActive()) {
|
||||
+ byteBuf.skipBytes(byteBuf.readableBytes());
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
byteBuf.markReaderIndex();
|
||||
+ // Paper start - reuse temporary length buffer
|
||||
+ byte[] abyte = lenBuf;
|
||||
+ java.util.Arrays.fill(abyte, (byte) 0);
|
||||
+ // Paper end
|
||||
byte[] bs = new byte[3];
|
||||
|
||||
for(int i = 0; i < bs.length; ++i) {
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
||||
index 049e64c355d5f064009b1107ad15d28c44f999dd..a34f22cadc09e53ea4de787b04d050b99dddbcac 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
||||
@@ -30,11 +30,17 @@ public class PacketUtils {
|
||||
try (co.aikar.timings.Timing ignored = timing.startTiming()) { // Paper - timings
|
||||
packet.handle(listener);
|
||||
} catch (Exception exception) {
|
||||
- if (listener.shouldPropagateHandlingExceptions()) {
|
||||
- throw exception;
|
||||
+ net.minecraft.network.Connection networkmanager = listener.getConnection();
|
||||
+ if (networkmanager.getPlayer() != null) {
|
||||
+ LOGGER.error("Error whilst processing packet {} for {}[{}]", packet, networkmanager.getPlayer().getScoreboardName(), networkmanager.getRemoteAddress(), exception);
|
||||
+ } else {
|
||||
+ LOGGER.error("Error whilst processing packet {} for connection from {}", packet, networkmanager.getRemoteAddress(), exception);
|
||||
}
|
||||
-
|
||||
- PacketUtils.LOGGER.error("Failed to handle packet {}, suppressing error", packet, exception);
|
||||
+ net.minecraft.network.chat.Component error = net.minecraft.network.chat.Component.literal("Packet processing error");
|
||||
+ networkmanager.send(new net.minecraft.network.protocol.game.ClientboundDisconnectPacket(error), (future) -> {
|
||||
+ networkmanager.disconnect(error);
|
||||
+ });
|
||||
+ networkmanager.setReadOnly();
|
||||
}
|
||||
} else {
|
||||
PacketUtils.LOGGER.debug("Ignoring packet due to disconnection: {}", packet);
|
|
@ -1,54 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Wyatt Childers <wchilders@nearce.com>
|
||||
Date: Sat, 4 Jul 2020 23:07:43 -0400
|
||||
Subject: [PATCH] Optimize the advancement data player iteration to be O(N)
|
||||
rather than O(N^2)
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
index 4591364057110b8abe6cc669b76918096cb6b776..736e604205c0dcbe2cf1f1e0d507f53a9c0d941b 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
@@ -436,6 +436,16 @@ public class PlayerAdvancements {
|
||||
}
|
||||
|
||||
private void ensureVisibility(Advancement advancement) {
|
||||
+ // Paper start
|
||||
+ ensureVisibility(advancement, IterationEntryPoint.ROOT);
|
||||
+ }
|
||||
+ private enum IterationEntryPoint {
|
||||
+ ROOT,
|
||||
+ ITERATOR,
|
||||
+ PARENT_OF_ITERATOR
|
||||
+ }
|
||||
+ private void ensureVisibility(Advancement advancement, IterationEntryPoint entryPoint) {
|
||||
+ // Paper end
|
||||
boolean flag = this.shouldBeVisible(advancement);
|
||||
boolean flag1 = this.visible.contains(advancement);
|
||||
|
||||
@@ -451,15 +461,23 @@ public class PlayerAdvancements {
|
||||
}
|
||||
|
||||
if (flag != flag1 && advancement.getParent() != null) {
|
||||
- this.ensureVisibility(advancement.getParent());
|
||||
+ // Paper start - If we're not coming from an iterator consider this to be a root entry, otherwise
|
||||
+ // market that we're entering from the parent of an iterator.
|
||||
+ this.ensureVisibility(advancement.getParent(), entryPoint == IterationEntryPoint.ITERATOR ? IterationEntryPoint.PARENT_OF_ITERATOR : IterationEntryPoint.ROOT);
|
||||
}
|
||||
|
||||
+ // If this is true, we've went through a child iteration, entered the parent, processed the parent
|
||||
+ // and are about to reprocess the children. Stop processing here to prevent O(N^2) processing.
|
||||
+ if (entryPoint == IterationEntryPoint.PARENT_OF_ITERATOR) {
|
||||
+ return;
|
||||
+ } // Paper end
|
||||
+
|
||||
Iterator iterator = advancement.getChildren().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Advancement advancement1 = (Advancement) iterator.next();
|
||||
|
||||
- this.ensureVisibility(advancement1);
|
||||
+ this.ensureVisibility(advancement1, IterationEntryPoint.ITERATOR); // Paper - Mark this call as being from iteration
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Wed, 8 Jul 2020 11:24:30 -0500
|
||||
Subject: [PATCH] Fix arrows never despawning MC-125757
|
||||
|
||||
This forces the despawn counter to start ticking regardless of
|
||||
state after the arrow has been alive for 200 ticks (10 seconds)
|
||||
instead of getting stuck in a never despawn state (bubble columns,
|
||||
etc).
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
index 7f1f4813ac007fbf79e8ba254075c015fe15e3a1..f02fb03c63975e5c1ccdd848f5727559929cce00 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
@@ -199,6 +199,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||
|
||||
++this.inGroundTime;
|
||||
} else {
|
||||
+ if (tickCount > 200) this.tickDespawn(); // Paper - tick despawnCounter regardless after 10 seconds
|
||||
this.inGroundTime = 0;
|
||||
Vec3 vec3d2 = this.position();
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 11 Jul 2020 03:54:28 -0400
|
||||
Subject: [PATCH] Thread Safe Vanilla Command permission checking
|
||||
|
||||
Datapacks check this on load and are built concurrently. This was breaking them badly due
|
||||
to race conditions.
|
||||
|
||||
Plus, .canUse we want to be safe for async anyways.
|
||||
|
||||
diff --git a/src/main/java/com/mojang/brigadier/tree/CommandNode.java b/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
||||
index a4f97c1df86c574af9b9824a38034a3d76d6e357..d65defd5fc54086a969c568b93dfb05f40dd5a44 100644
|
||||
--- a/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
||||
+++ b/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
||||
@@ -74,10 +74,10 @@ public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
|
||||
public synchronized boolean canUse(final S source) {
|
||||
if (source instanceof CommandSourceStack) {
|
||||
try {
|
||||
- ((CommandSourceStack) source).currentCommand = this;
|
||||
+ ((CommandSourceStack) source).currentCommand.put(Thread.currentThread(), this); // Paper
|
||||
return this.requirement.test(source);
|
||||
} finally {
|
||||
- ((CommandSourceStack) source).currentCommand = null;
|
||||
+ ((CommandSourceStack) source).currentCommand.remove(Thread.currentThread()); // Paper
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java
|
||||
index 08cdd5807237c709accc989718178bc25428eb74..c948b9387e14d7f8bb2cd6236f513d57286d9301 100644
|
||||
--- a/src/main/java/net/minecraft/commands/CommandSourceStack.java
|
||||
+++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java
|
||||
@@ -55,7 +55,7 @@ public class CommandSourceStack implements SharedSuggestionProvider, com.destroy
|
||||
private final EntityAnchorArgument.Anchor anchor;
|
||||
private final Vec2 rotation;
|
||||
private final CommandSigningContext signingContext;
|
||||
- public volatile CommandNode currentCommand; // CraftBukkit
|
||||
+ public java.util.Map<Thread, CommandNode> currentCommand = new java.util.concurrent.ConcurrentHashMap<>(); // CraftBukkit // Paper
|
||||
|
||||
public CommandSourceStack(CommandSource output, Vec3 pos, Vec2 rot, ServerLevel world, int level, String name, Component displayName, MinecraftServer server, @Nullable Entity entity) {
|
||||
this(output, pos, rot, world, level, name, displayName, server, entity, false, (commandcontext, flag, j) -> {
|
||||
@@ -186,9 +186,11 @@ public class CommandSourceStack implements SharedSuggestionProvider, com.destroy
|
||||
@Override
|
||||
public boolean hasPermission(int level) {
|
||||
// CraftBukkit start
|
||||
- CommandNode currentCommand = this.currentCommand;
|
||||
+ // Paper start - fix concurrency issue
|
||||
+ CommandNode currentCommand = this.currentCommand.get(Thread.currentThread());
|
||||
if (currentCommand != null) {
|
||||
return this.hasPermission(level, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
|
||||
+ // Paper end
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: JRoy <joshroy126@gmail.com>
|
||||
Date: Wed, 15 Jul 2020 21:42:52 -0400
|
||||
Subject: [PATCH] Fix SPIGOT-5989
|
||||
|
||||
Before this fix, if a player was respawning to a respawn anchor and
|
||||
the respawn location was modified away from the anchor with the
|
||||
PlayerRespawnEvent, the anchor would still lose some charge.
|
||||
This fixes that by checking if the modified spawn location is
|
||||
still at a respawn anchor.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index ec48afe87b5d159b5bdbe035e214ea7c9024fadb..be7a25560cd5521ddfe4793c7e51b1036fc8a19c 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -835,6 +835,7 @@ public abstract class PlayerList {
|
||||
// Paper start
|
||||
boolean isBedSpawn = false;
|
||||
boolean isRespawn = false;
|
||||
+ boolean isLocAltered = false; // Paper - Fix SPIGOT-5989
|
||||
// Paper end
|
||||
|
||||
// CraftBukkit start - fire PlayerRespawnEvent
|
||||
@@ -845,7 +846,7 @@ public abstract class PlayerList {
|
||||
Optional optional;
|
||||
|
||||
if (blockposition != null) {
|
||||
- optional = net.minecraft.world.entity.player.Player.findRespawnPositionAndUseSpawnBlock(worldserver1, blockposition, f, flag1, flag);
|
||||
+ optional = net.minecraft.world.entity.player.Player.findRespawnPositionAndUseSpawnBlock(worldserver1, blockposition, f, flag1, true); // Paper - Fix SPIGOT-5989
|
||||
} else {
|
||||
optional = Optional.empty();
|
||||
}
|
||||
@@ -889,7 +890,12 @@ public abstract class PlayerList {
|
||||
}
|
||||
// Spigot End
|
||||
|
||||
- location = respawnEvent.getRespawnLocation();
|
||||
+ // Paper start - Fix SPIGOT-5989
|
||||
+ if (!location.equals(respawnEvent.getRespawnLocation()) ) {
|
||||
+ location = respawnEvent.getRespawnLocation();
|
||||
+ isLocAltered = true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (!flag) entityplayer.reset(); // SPIGOT-4785
|
||||
isRespawn = true; // Paper
|
||||
} else {
|
||||
@@ -927,8 +933,12 @@ public abstract class PlayerList {
|
||||
}
|
||||
// entityplayer1.initInventoryMenu();
|
||||
entityplayer1.setHealth(entityplayer1.getHealth());
|
||||
- if (flag2) {
|
||||
- entityplayer1.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver1.getRandom().nextLong()));
|
||||
+ // Paper start - Fix SPIGOT-5989
|
||||
+ if (flag2 && !isLocAltered) {
|
||||
+ BlockState data = worldserver1.getBlockState(blockposition);
|
||||
+ worldserver1.setBlock(blockposition, data.setValue(net.minecraft.world.level.block.RespawnAnchorBlock.CHARGE, data.getValue(net.minecraft.world.level.block.RespawnAnchorBlock.CHARGE) - 1), 3);
|
||||
+ entityplayer1.connection.send(new ClientboundSoundPacket(SoundEvents.RESPAWN_ANCHOR_DEPLETE, SoundSource.BLOCKS, (double) location.getX(), (double) location.getY(), (double) location.getZ(), 1.0F, 1.0F, worldserver1.getRandom().nextLong()));
|
||||
+ // Paper end
|
||||
}
|
||||
// Added from changeDimension
|
||||
this.sendAllPlayerInfo(entityplayer); // Update health, etc...
|
|
@ -1,50 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 10 Jul 2020 13:12:33 -0500
|
||||
Subject: [PATCH] Fix SPIGOT-5824 Bukkit world-container is not used
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||
index 8fda43173012ed3134ed1f114143ceaad66cae4a..3e1b589031d46126bdd6b6f63d7a133304fb9574 100644
|
||||
--- a/src/main/java/net/minecraft/server/Main.java
|
||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||
@@ -137,8 +137,17 @@ public class Main {
|
||||
return;
|
||||
}
|
||||
|
||||
- File file = (File) optionset.valueOf("universe"); // CraftBukkit
|
||||
- Services services = Services.create(new com.destroystokyo.paper.profile.PaperAuthenticationService(Proxy.NO_PROXY), file, optionset); // Paper
|
||||
+ // Paper start - fix SPIGOT-5824
|
||||
+ File file;
|
||||
+ File userCacheFile = new File(Services.USERID_CACHE_FILE);
|
||||
+ if (optionset.has("universe")) {
|
||||
+ file = (File) optionset.valueOf("universe"); // CraftBukkit
|
||||
+ userCacheFile = new File(file, Services.USERID_CACHE_FILE);
|
||||
+ } else {
|
||||
+ file = new File(bukkitConfiguration.getString("settings.world-container", "."));
|
||||
+ }
|
||||
+ // Paper end - fix SPIGOT-5824
|
||||
+ Services services = Services.create(new com.destroystokyo.paper.profile.PaperAuthenticationService(Proxy.NO_PROXY), file, userCacheFile, optionset); // Paper
|
||||
// CraftBukkit start
|
||||
String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath());
|
||||
diff --git a/src/main/java/net/minecraft/server/Services.java b/src/main/java/net/minecraft/server/Services.java
|
||||
index d7d65d0faefa5551480a4090de3a881828238ffd..ef6ff78af2ae747e939895b82ee9d11c75012dcd 100644
|
||||
--- a/src/main/java/net/minecraft/server/Services.java
|
||||
+++ b/src/main/java/net/minecraft/server/Services.java
|
||||
@@ -19,12 +19,12 @@ public record Services(MinecraftSessionService sessionService, SignatureValidato
|
||||
return java.util.Objects.requireNonNull(this.paperConfigurations);
|
||||
}
|
||||
// Paper end
|
||||
- private static final String USERID_CACHE_FILE = "usercache.json";
|
||||
+ public static final String USERID_CACHE_FILE = "usercache.json"; // Paper - private -> public
|
||||
|
||||
- public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, joptsimple.OptionSet optionSet) throws Exception { // Paper
|
||||
+ public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, File userCacheFile, joptsimple.OptionSet optionSet) throws Exception { // Paper
|
||||
MinecraftSessionService minecraftSessionService = authenticationService.createMinecraftSessionService();
|
||||
GameProfileRepository gameProfileRepository = authenticationService.createProfileRepository();
|
||||
- GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, new File(rootDirectory, "usercache.json"));
|
||||
+ GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, userCacheFile); // Paper
|
||||
SignatureValidator signatureValidator = SignatureValidator.from(authenticationService.getServicesKey());
|
||||
// Paper start
|
||||
final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath();
|
|
@ -1,18 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 10 Jul 2020 12:38:12 -0500
|
||||
Subject: [PATCH] Fix SPIGOT-5885 Unable to disable advancements
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||
index 3e1b589031d46126bdd6b6f63d7a133304fb9574..8bbc3a1e7f848047ff915d5bdf08d376e71c4025 100644
|
||||
--- a/src/main/java/net/minecraft/server/Main.java
|
||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||
@@ -137,6 +137,7 @@ public class Main {
|
||||
return;
|
||||
}
|
||||
|
||||
+ org.spigotmc.SpigotConfig.disabledAdvancements = spigotConfiguration.getStringList("advancements.disabled"); // Paper - fix SPIGOT-5885, must be set early in init
|
||||
// Paper start - fix SPIGOT-5824
|
||||
File file;
|
||||
File userCacheFile = new File(Services.USERID_CACHE_FILE);
|
|
@ -1,82 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Mon, 13 Jul 2020 06:22:54 -0700
|
||||
Subject: [PATCH] Fix AdvancementDataPlayer leak due from quitting early in
|
||||
login
|
||||
|
||||
Move the criterion storage to the AdvancementDataPlayer object
|
||||
itself, so the criterion object stores no references - and thus
|
||||
needs no cleanup.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java
|
||||
index 06fc39b19385d36fd0c5bb9a7042a238eb6e8a57..bb1f0e9dbcb792d015d1cb65664a96fdd3e0489e 100644
|
||||
--- a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java
|
||||
+++ b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java
|
||||
@@ -14,22 +14,24 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
|
||||
public abstract class SimpleCriterionTrigger<T extends AbstractCriterionTriggerInstance> implements CriterionTrigger<T> {
|
||||
- private final Map<PlayerAdvancements, Set<CriterionTrigger.Listener<T>>> players = Maps.newIdentityHashMap();
|
||||
+ //private final Map<PlayerAdvancements, Set<CriterionTrigger.Listener<T>>> players = Maps.newIdentityHashMap(); // Paper - moved into AdvancementDataPlayer to fix memory leak
|
||||
+
|
||||
+ public SimpleCriterionTrigger() {}
|
||||
|
||||
@Override
|
||||
public final void addPlayerListener(PlayerAdvancements manager, CriterionTrigger.Listener<T> conditions) {
|
||||
- this.players.computeIfAbsent(manager, (managerx) -> {
|
||||
+ manager.criterionData.computeIfAbsent(this, (managerx) -> { // Paper - fix AdvancementDataPlayer leak
|
||||
return Sets.newHashSet();
|
||||
}).add(conditions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void removePlayerListener(PlayerAdvancements manager, CriterionTrigger.Listener<T> conditions) {
|
||||
- Set<CriterionTrigger.Listener<T>> set = this.players.get(manager);
|
||||
+ Set<CriterionTrigger.Listener<T>> set = (Set) manager.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak
|
||||
if (set != null) {
|
||||
set.remove(conditions);
|
||||
if (set.isEmpty()) {
|
||||
- this.players.remove(manager);
|
||||
+ manager.criterionData.remove(this); // Paper - fix AdvancementDataPlayer leak
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +39,7 @@ public abstract class SimpleCriterionTrigger<T extends AbstractCriterionTriggerI
|
||||
|
||||
@Override
|
||||
public final void removePlayerListeners(PlayerAdvancements tracker) {
|
||||
- this.players.remove(tracker);
|
||||
+ tracker.criterionData.remove(this); // Paper - fix AdvancementDataPlayer leak
|
||||
}
|
||||
|
||||
protected abstract T createInstance(JsonObject obj, EntityPredicate.Composite playerPredicate, DeserializationContext predicateDeserializer);
|
||||
@@ -50,7 +52,7 @@ public abstract class SimpleCriterionTrigger<T extends AbstractCriterionTriggerI
|
||||
|
||||
protected void trigger(ServerPlayer player, Predicate<T> predicate) {
|
||||
PlayerAdvancements playerAdvancements = player.getAdvancements();
|
||||
- Set<CriterionTrigger.Listener<T>> set = this.players.get(playerAdvancements);
|
||||
+ Set<CriterionTrigger.Listener<T>> set = (Set) playerAdvancements.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak
|
||||
if (set != null && !set.isEmpty()) {
|
||||
LootContext lootContext = EntityPredicate.createContext(player, player);
|
||||
List<CriterionTrigger.Listener<T>> list = null;
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
index 736e604205c0dcbe2cf1f1e0d507f53a9c0d941b..a4f2eb219cc57303cc6642e6782700591e423cf4 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
@@ -39,6 +39,7 @@ import net.minecraft.advancements.Criterion;
|
||||
import net.minecraft.advancements.CriterionProgress;
|
||||
import net.minecraft.advancements.CriterionTrigger;
|
||||
import net.minecraft.advancements.CriterionTriggerInstance;
|
||||
+import net.minecraft.advancements.critereon.SimpleCriterionTrigger;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.ClientboundSelectAdvancementsTabPacket;
|
||||
@@ -69,6 +70,8 @@ public class PlayerAdvancements {
|
||||
private Advancement lastSelectedTab;
|
||||
private boolean isFirstPacket = true;
|
||||
|
||||
+ public final Map<SimpleCriterionTrigger, Set<CriterionTrigger.Listener>> criterionData = Maps.newIdentityHashMap(); // Paper - fix advancement data player leakage
|
||||
+
|
||||
public PlayerAdvancements(DataFixer dataFixer, PlayerList playerManager, ServerAdvancementManager advancementLoader, File advancementFile, ServerPlayer owner) {
|
||||
this.dataFixer = dataFixer;
|
||||
this.playerList = playerManager;
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 26 Jul 2020 12:11:39 +0100
|
||||
Subject: [PATCH] Add missing strikeLighting call to
|
||||
World#spigot()#strikeLightningEffect
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index af22fa8aa8ddef4d592564b14d0114cc6f903fca..566636192c8c5858999c80c31b068aeb5bace1e6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -2172,6 +2172,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
lightning.moveTo( loc.getX(), loc.getY(), loc.getZ() );
|
||||
lightning.visualOnly = true;
|
||||
lightning.isSilent = isSilent;
|
||||
+ world.strikeLightning( lightning );
|
||||
return (LightningStrike) lightning.getBukkitEntity();
|
||||
}
|
||||
};
|
|
@ -1,84 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Fri, 24 Jul 2020 15:56:05 -0700
|
||||
Subject: [PATCH] Fix some rails connecting improperly
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BaseRailBlock.java b/src/main/java/net/minecraft/world/level/block/BaseRailBlock.java
|
||||
index 9ae45eaf77ead0a6801046d8946d50eec24612fa..a3f877bf03f75cbfbd128c856322bcd427b95d21 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BaseRailBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BaseRailBlock.java
|
||||
@@ -65,6 +65,7 @@ public abstract class BaseRailBlock extends Block implements SimpleWaterloggedBl
|
||||
state = this.updateDir(world, pos, state, true);
|
||||
if (this.isStraight) {
|
||||
world.neighborChanged(state, pos, this, pos, notify);
|
||||
+ state = world.getBlockState(pos); // Paper - don't desync, update again
|
||||
}
|
||||
|
||||
return state;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java b/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java
|
||||
index fe9b6c89a1f0c98a9c73a409f2aca6a4a1c0f9e7..932a2c279f46c951182d2604b525b473b6945895 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java
|
||||
@@ -70,6 +70,7 @@ public class DetectorRailBlock extends BaseRailBlock {
|
||||
|
||||
private void checkPressed(Level world, BlockPos pos, BlockState state) {
|
||||
if (this.canSurvive(state, world, pos)) {
|
||||
+ if (state.getBlock() != this) { return; } // Paper - not our block, don't do anything
|
||||
boolean flag = (Boolean) state.getValue(DetectorRailBlock.POWERED);
|
||||
boolean flag1 = false;
|
||||
List<AbstractMinecart> list = this.getInteractingMinecartOfType(world, pos, AbstractMinecart.class, (entity) -> {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/RailState.java b/src/main/java/net/minecraft/world/level/block/RailState.java
|
||||
index 0cbfad97371b59de95963a09aa16f3dad7a37222..d873625c1b8439a727d39ce207b5e84a1d86e5eb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/RailState.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/RailState.java
|
||||
@@ -17,6 +17,12 @@ public class RailState {
|
||||
private final boolean isStraight;
|
||||
private final List<BlockPos> connections = Lists.newArrayList();
|
||||
|
||||
+ // Paper start - prevent desync
|
||||
+ public boolean isValid() {
|
||||
+ return this.level.getBlockState(this.pos).getBlock() == this.state.getBlock();
|
||||
+ }
|
||||
+ // Paper end - prevent desync
|
||||
+
|
||||
public RailState(Level world, BlockPos pos, BlockState state) {
|
||||
this.level = world;
|
||||
this.pos = pos;
|
||||
@@ -143,6 +149,11 @@ public class RailState {
|
||||
}
|
||||
|
||||
private void connectTo(RailState placementHelper) {
|
||||
+ // Paper start - prevent desync
|
||||
+ if (!this.isValid() || !placementHelper.isValid()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - prevent desync
|
||||
this.connections.add(placementHelper.pos);
|
||||
BlockPos blockPos = this.pos.north();
|
||||
BlockPos blockPos2 = this.pos.south();
|
||||
@@ -333,10 +344,15 @@ public class RailState {
|
||||
this.state = this.state.setValue(this.block.getShapeProperty(), railShape2);
|
||||
if (forceUpdate || this.level.getBlockState(this.pos) != this.state) {
|
||||
this.level.setBlock(this.pos, this.state, 3);
|
||||
+ // Paper start - prevent desync
|
||||
+ if (!this.isValid()) {
|
||||
+ return this;
|
||||
+ }
|
||||
+ // Paper end - prevent desync
|
||||
|
||||
for(int i = 0; i < this.connections.size(); ++i) {
|
||||
RailState railState = this.getRail(this.connections.get(i));
|
||||
- if (railState != null) {
|
||||
+ if (railState != null && railState.isValid()) { // Paper - prevent desync
|
||||
railState.removeSoftConnections();
|
||||
if (railState.canConnectTo(this)) {
|
||||
railState.connectTo(this);
|
||||
@@ -349,6 +365,6 @@ public class RailState {
|
||||
}
|
||||
|
||||
public BlockState getState() {
|
||||
- return this.state;
|
||||
+ return this.level.getBlockState(this.pos); // Paper - prevent desync
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: mbax <matt@phozop.net>
|
||||
Date: Mon, 17 Aug 2020 12:17:37 -0400
|
||||
Subject: [PATCH] Fix regex mistake in CB NBT int deserialization
|
||||
|
||||
The existing regex is too open and allows for the absence of any actual
|
||||
number data, detecting an NBT entry of just the letter "i" in upper or
|
||||
lower case. This causes a single-character NBT entry to be processed as
|
||||
an integer ending in "i", passing an empty String to to Integer.parseInt,
|
||||
triggering an exception in loading the item.
|
||||
|
||||
This commit forces numbers to be present prior to the ending "i"
|
||||
letter.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java
|
||||
index a7f4054002bd176fccf8357e9a23de66dd9e0dc5..207e4302161b3abe2ade56c9dc9c31820010fa42 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNBTTagConfigSerializer.java
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.nbt.TagParser;
|
||||
public class CraftNBTTagConfigSerializer {
|
||||
|
||||
private static final Pattern ARRAY = Pattern.compile("^\\[.*]");
|
||||
- private static final Pattern INTEGER = Pattern.compile("[-+]?(?:0|[1-9][0-9]*)?i", Pattern.CASE_INSENSITIVE);
|
||||
+ private static final Pattern INTEGER = Pattern.compile("[-+]?(?:0|[1-9][0-9]*)i", Pattern.CASE_INSENSITIVE); // Paper - fix regex
|
||||
private static final Pattern DOUBLE = Pattern.compile("[-+]?(?:[0-9]+[.]?|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?d", Pattern.CASE_INSENSITIVE);
|
||||
private static final TagParser MOJANGSON_PARSER = new TagParser(new StringReader(""));
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach@zachbr.io>
|
||||
Date: Tue, 23 Jul 2019 20:44:47 -0500
|
||||
Subject: [PATCH] Do not let the server load chunks from newer versions
|
||||
|
||||
If the server attempts to load a chunk generated by a newer version of
|
||||
the game, immediately stop the server to prevent data corruption.
|
||||
|
||||
You can override this functionality at your own peril.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
index f26a08f81495dde6205b34254d159b042e5a6ea9..12e3831324abdc1112cbe65cab0f0c75ce77a9ef 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
@@ -118,9 +118,22 @@ public class ChunkSerializer {
|
||||
return holder.protoChunk;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ private static final int CURRENT_DATA_VERSION = SharedConstants.getCurrentVersion().getDataVersion().getVersion();
|
||||
+ private static final boolean JUST_CORRUPT_IT = Boolean.getBoolean("Paper.ignoreWorldDataVersion");
|
||||
+ // Paper end
|
||||
public static InProgressChunkHolder loadChunk(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt, boolean distinguish) {
|
||||
java.util.ArrayDeque<Runnable> tasksToExecuteOnMain = new java.util.ArrayDeque<>();
|
||||
// Paper end
|
||||
+ // Paper start - Do NOT attempt to load chunks saved with newer versions
|
||||
+ if (nbt.contains("DataVersion", 99)) {
|
||||
+ int dataVersion = nbt.getInt("DataVersion");
|
||||
+ if (!JUST_CORRUPT_IT && dataVersion > CURRENT_DATA_VERSION) {
|
||||
+ new RuntimeException("Server attempted to load chunk saved with newer version of minecraft! " + dataVersion + " > " + CURRENT_DATA_VERSION).printStackTrace();
|
||||
+ System.exit(1);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - diff on change, see ChunkSerializer#getChunkCoordinate
|
||||
|
||||
if (!Objects.equals(chunkPos, chunkcoordintpair1)) {
|
|
@ -1,75 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: DigitalRegent <misterwener@gmail.com>
|
||||
Date: Sat, 11 Apr 2020 13:10:58 +0200
|
||||
Subject: [PATCH] Brand support
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 50226c6672ffb933fe7e22bf43641983eb6caa54..b924bf36e5a13d9fb7078e091e50c7e468bdd5b5 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -279,6 +279,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
|
||||
private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper
|
||||
|
||||
+ private String clientBrandName = null; // Paper - Brand name
|
||||
+
|
||||
public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) {
|
||||
this.lastChatTimeStamp = new AtomicReference(Instant.EPOCH);
|
||||
this.server = server;
|
||||
@@ -3213,6 +3215,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
private static final ResourceLocation CUSTOM_REGISTER = new ResourceLocation("register");
|
||||
private static final ResourceLocation CUSTOM_UNREGISTER = new ResourceLocation("unregister");
|
||||
|
||||
+ private static final ResourceLocation MINECRAFT_BRAND = new ResourceLocation("brand"); // Paper - Brand support
|
||||
+
|
||||
@Override
|
||||
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
@@ -3240,6 +3244,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
try {
|
||||
byte[] data = new byte[packet.data.readableBytes()];
|
||||
packet.data.readBytes(data);
|
||||
+ // Paper start - Brand support
|
||||
+ if (packet.identifier.equals(MINECRAFT_BRAND)) {
|
||||
+ try {
|
||||
+ this.clientBrandName = new net.minecraft.network.FriendlyByteBuf(io.netty.buffer.Unpooled.copiedBuffer(data)).readUtf(256);
|
||||
+ } catch (StringIndexOutOfBoundsException ex) {
|
||||
+ this.clientBrandName = "illegal";
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packet.identifier.toString(), data);
|
||||
} catch (Exception ex) {
|
||||
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
|
||||
@@ -3249,6 +3262,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
|
||||
}
|
||||
|
||||
+ // Paper start - brand support
|
||||
+ public String getClientBrandName() {
|
||||
+ return clientBrandName;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public final boolean isDisconnected() {
|
||||
return (!this.player.joining && !this.connection.isConnected()) || this.processedDisconnect; // Paper
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 1699ad9a3e0d03866a6a80a74a1a831f6d54d311..d06f6c9a7bfa7585d5dfb7da8654837605866a3e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2685,6 +2685,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
// Paper end
|
||||
};
|
||||
|
||||
+ // Paper start - brand support
|
||||
+ @Override
|
||||
+ public String getClientBrandName() {
|
||||
+ return getHandle().connection != null ? getHandle().connection.getClientBrandName() : null;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public Player.Spigot spigot()
|
||||
{
|
||||
return this.spigot;
|
|
@ -1,37 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Sat, 22 Aug 2020 23:59:30 +0200
|
||||
Subject: [PATCH] Add #setMaxPlayers API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index be7a25560cd5521ddfe4793c7e51b1036fc8a19c..869fa7c3913185c3537185426e75c076fbbdb7fe 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -146,7 +146,7 @@ public abstract class PlayerList {
|
||||
public final PlayerDataStorage playerIo;
|
||||
private boolean doWhiteList;
|
||||
private final RegistryAccess.Frozen registryHolder;
|
||||
- protected final int maxPlayers;
|
||||
+ protected int maxPlayers; public final void setMaxPlayers(int maxPlayers) { this.maxPlayers = maxPlayers; } // Paper - remove final and add setter
|
||||
private int viewDistance;
|
||||
private int simulationDistance;
|
||||
private boolean allowCheatsForAllPlayers;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 2d7de60d7e663b91f0a72241f24913338bd725dd..57c4871b977a31f55e5c39aba4159b39b1ac325d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -672,6 +672,13 @@ public final class CraftServer implements Server {
|
||||
return this.playerList.getMaxPlayers();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setMaxPlayers(int maxPlayers) {
|
||||
+ this.playerList.setMaxPlayers(maxPlayers);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
// NOTE: These are dependent on the corresponding call in MinecraftServer
|
||||
// so if that changes this will need to as well
|
||||
@Override
|
|
@ -1,21 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sun, 23 Aug 2020 19:36:22 +0200
|
||||
Subject: [PATCH] Add playPickupItemAnimation to LivingEntity
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 639d376bf382409410e26385134d36fd6e3b5f0c..537d1a6dcf8add34e8dac8aee2fa50c50ce7e5d0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -838,5 +838,10 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
((Mob) getHandle()).getJumpControl().jump();
|
||||
}
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public void playPickupItemAnimation(org.bukkit.entity.Item item, int quantity) {
|
||||
+ getHandle().take(((CraftItem) item).getHandle(), quantity);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Sun, 23 Aug 2020 19:01:04 +0200
|
||||
Subject: [PATCH] Don't require FACING data
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java
|
||||
index da6a145b06e217ff82b0a1b04410238dc50d4869..1e6ba6d9cceda1d4867b183c3dbc03d317ed287f 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java
|
||||
@@ -14,6 +14,7 @@ import org.bukkit.event.block.BlockDispenseEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class DefaultDispenseItemBehavior implements DispenseItemBehavior {
|
||||
+ private Direction enumdirection; // Paper
|
||||
|
||||
// CraftBukkit start
|
||||
private boolean dropper;
|
||||
@@ -27,15 +28,16 @@ public class DefaultDispenseItemBehavior implements DispenseItemBehavior {
|
||||
|
||||
@Override
|
||||
public final ItemStack dispense(BlockSource pointer, ItemStack stack) {
|
||||
+ enumdirection = pointer.getBlockState().getValue(DispenserBlock.FACING); // Paper - cache facing direction
|
||||
ItemStack itemstack1 = this.execute(pointer, stack);
|
||||
|
||||
this.playSound(pointer);
|
||||
- this.playAnimation(pointer, (Direction) pointer.getBlockState().getValue(DispenserBlock.FACING));
|
||||
+ this.playAnimation(pointer, enumdirection); // Paper - cache facing direction
|
||||
return itemstack1;
|
||||
}
|
||||
|
||||
protected ItemStack execute(BlockSource pointer, ItemStack stack) {
|
||||
- Direction enumdirection = (Direction) pointer.getBlockState().getValue(DispenserBlock.FACING);
|
||||
+ // Paper - cached enum direction
|
||||
Position iposition = DispenserBlock.getDispensePosition(pointer);
|
||||
ItemStack itemstack1 = stack.split(1);
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 22 Aug 2020 23:36:21 +0200
|
||||
Subject: [PATCH] Fix SpawnChangeEvent not firing for all use-cases
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 848690e6dfaec00ec9b8a8397d2a6d37f24c8d12..bb8d5868275407fe3c5eb29174bf1970cae498f9 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1850,6 +1850,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
//ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c()));
|
||||
|
||||
this.levelData.setSpawn(pos, angle);
|
||||
+ new org.bukkit.event.world.SpawnChangeEvent(getWorld(), MCUtil.toLocation(this, prevSpawn)).callEvent(); // Paper
|
||||
if (this.keepSpawnInMemory) {
|
||||
// if this keepSpawnInMemory is false a plugin has already removed our tickets, do not re-add
|
||||
this.removeTicketsForSpawn(this.paperConfig().spawn.keepSpawnLoadedRange * 16, prevSpawn);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 566636192c8c5858999c80c31b068aeb5bace1e6..a04ae390f2d054b2ad9fb91eca04955471247b5a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -264,11 +264,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
public boolean setSpawnLocation(int x, int y, int z, float angle) {
|
||||
try {
|
||||
Location previousLocation = this.getSpawnLocation();
|
||||
- world.levelData.setSpawn(new BlockPos(x, y, z), angle);
|
||||
+ world.setDefaultSpawnPos(new BlockPos(x, y, z), angle); // Paper - use WorldServer#setSpawn
|
||||
|
||||
+ // Paper start - move to nms.World
|
||||
// Notify anyone who's listening.
|
||||
- SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
|
||||
- this.server.getPluginManager().callEvent(event);
|
||||
+ // SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
|
||||
+ // server.getPluginManager().callEvent(event);
|
||||
+ // Paper end
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
|
@ -1,22 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 23 Aug 2020 16:32:11 +0200
|
||||
Subject: [PATCH] Add moon phase API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
index e395628ccf59c1b7a4efcabb3c38e8a879b95e38..ee5e59c37301d9a806e2f696d52d9d217b232833 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
@@ -932,4 +932,11 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
|
||||
throw new IllegalArgumentException("Cannot spawn an entity for " + clazz.getName());
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public io.papermc.paper.world.MoonPhase getMoonPhase() {
|
||||
+ return io.papermc.paper.world.MoonPhase.getPhase(this.getHandle().dayTime() / 24000L);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 29 May 2020 23:32:14 -0400
|
||||
Subject: [PATCH] Improve Chunk Status Transition Speed
|
||||
|
||||
When a chunk is loaded from disk that has already been generated,
|
||||
the server has to promote the chunk through the system to reach
|
||||
it's current desired status level.
|
||||
|
||||
This results in every single status transition going from the main thread
|
||||
to the world gen threads, only to discover it has no work it actually
|
||||
needs to do.... and then it returns back to main.
|
||||
|
||||
This back and forth costs a lot of time and can really delay chunk loads
|
||||
when the server is under high TPS due to their being a lot of time in
|
||||
between chunk load times, as well as hogs up the chunk threads from doing
|
||||
actual generation and light work.
|
||||
|
||||
Additionally, the whole task system uses a lot of CPU on the server threads anyways.
|
||||
|
||||
So by optimizing status transitions for status's that are already complete,
|
||||
we can run them to the desired level while on main thread (where it has
|
||||
to happen anyways) instead of ever jumping to world gen thread.
|
||||
|
||||
This will improve chunk loading effeciency to be reduced down to the following
|
||||
scenario / path:
|
||||
|
||||
1) MAIN: Chunk Requested, Load Request sent to ChunkTaskManager / IO Queue
|
||||
2) IO: Once position in queue comes, submit read IO data and schedule to chunk task thread
|
||||
3) CHUNK: Once IO is loaded and position in queue comes, deserialize the chunk data, process conversions, submit to main queue
|
||||
4) MAIN: next Chunk Task process (Mid Tick or End Of Tick), load chunk data into world (POI, main thread tasks)
|
||||
5) MAIN: process status transitions all the way to LIGHT, light schedules Threaded task
|
||||
6) SERVER: Light tasks register light enablement for chunk and any lighting needing to be done
|
||||
7) MAIN: Task returns to main, finish processing to FULL/TICKING status
|
||||
|
||||
Previously would have hopped to SERVER around 12+ times there extra.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
index ece4cd0de061969d4d2f07560e6cf38e631098b3..90f65fdcc4acf6762c67a5cb3023d2493f03144f 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
@@ -95,6 +95,13 @@ public class ChunkHolder {
|
||||
// Paper end - optimise anyPlayerCloseEnoughForSpawning
|
||||
long lastAutoSaveTime; // Paper - incremental autosave
|
||||
long inactiveTimeStart; // Paper - incremental autosave
|
||||
+ // Paper start - optimize chunk status progression without jumping through thread pool
|
||||
+ public boolean canAdvanceStatus() {
|
||||
+ ChunkStatus status = getChunkHolderStatus();
|
||||
+ ChunkAccess chunk = getAvailableChunkNow();
|
||||
+ return chunk != null && (status == null || chunk.getStatus().isOrAfter(getNextStatus(status)));
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public ChunkHolder(ChunkPos pos, int level, LevelHeightAccessor world, LevelLightEngine lightingProvider, ChunkHolder.LevelChangeListener levelUpdateListener, ChunkHolder.PlayerProvider playersWatchingChunkProvider) {
|
||||
this.futures = new AtomicReferenceArray(ChunkHolder.CHUNK_STATUSES.size());
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index b486b800399b53cb6d4912e16f2a14f1a3062759..13c4bfa296c854b5dbbffc495a029c6822131529 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -712,7 +712,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
return either.mapLeft((list) -> {
|
||||
return (LevelChunk) list.get(list.size() / 2);
|
||||
});
|
||||
- }, this.mainThreadExecutor);
|
||||
+ }, this.mainInvokingExecutor); // Paper
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1118,6 +1118,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
return "chunkGenerate " + requiredStatus.getName();
|
||||
});
|
||||
Executor executor = (runnable) -> {
|
||||
+ // Paper start - optimize chunk status progression without jumping through thread pool
|
||||
+ if (holder.canAdvanceStatus()) {
|
||||
+ this.mainInvokingExecutor.execute(runnable);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.worldgenMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable));
|
||||
};
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: commandblockguy <commandblockguy1@gmail.com>
|
||||
Date: Fri, 14 Aug 2020 14:44:14 -0500
|
||||
Subject: [PATCH] Prevent headless pistons from being created
|
||||
|
||||
Prevent headless pistons from being created by explosions or tree/mushroom growth.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index b18b0e1b5e059f08fd3117eaa0fb28a10fac6562..01477e7240f9e33d08d416a7d40ee10f3e5d4abf 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -187,6 +187,15 @@ public class Explosion {
|
||||
|
||||
if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockposition, iblockdata, f)) {
|
||||
set.add(blockposition);
|
||||
+ // Paper start - prevent headless pistons from forming
|
||||
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && iblockdata.getBlock() == Blocks.MOVING_PISTON) {
|
||||
+ BlockEntity extension = this.level.getBlockEntity(blockposition);
|
||||
+ if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) {
|
||||
+ net.minecraft.core.Direction direction = iblockdata.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING);
|
||||
+ set.add(blockposition.relative(direction.getOpposite()));
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
d4 += d0 * 0.30000001192092896D;
|
|
@ -1,28 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Eearslya Sleiarion <eearslya@gmail.com>
|
||||
Date: Sun, 23 Aug 2020 13:04:02 +0200
|
||||
Subject: [PATCH] Add BellRingEvent
|
||||
|
||||
Add a new event, BellRingEvent, to trigger whenever a player rings a
|
||||
village bell. Passes along the bell block and the player who rang it.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BellBlock.java b/src/main/java/net/minecraft/world/level/block/BellBlock.java
|
||||
index a4da6418c17e145333aa5efe427826ba53293e4d..14002e1f67e3dce421584c01e8f91769509638b7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BellBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BellBlock.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.world.level.block;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
+import net.minecraft.server.MCUtil;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.stats.Stats;
|
||||
@@ -131,6 +132,7 @@ public class BellBlock extends BaseEntityBlock {
|
||||
direction = world.getBlockState(pos).getValue(FACING);
|
||||
}
|
||||
|
||||
+ if (!new io.papermc.paper.event.block.BellRingEvent(world.getWorld().getBlockAt(MCUtil.toLocation(world, pos)), entity == null ? null : entity.getBukkitEntity()).callEvent()) return false; // Paper - BellRingEvent
|
||||
((BellBlockEntity)blockEntity).onHit(direction);
|
||||
world.playSound((Player)null, pos, SoundEvents.BELL_BLOCK, SoundSource.BLOCKS, 2.0F, 1.0F);
|
||||
world.gameEvent(entity, GameEvent.BLOCK_CHANGE, pos);
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 23 Aug 2020 15:47:34 +0200
|
||||
Subject: [PATCH] Add zombie targets turtle egg config
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
index 3c3095e7e684079bcba0ea5a6b44c8fe2a3f47c4..67fe3b79b6fe4064b26f87734174a394b9e2b3e3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
@@ -107,7 +107,7 @@ public class Zombie extends Monster {
|
||||
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
- this.goalSelector.addGoal(4, new Zombie.ZombieAttackTurtleEggGoal(this, 1.0D, 3));
|
||||
+ if (level.paperConfig().entities.behavior.zombiesTargetTurtleEggs) this.goalSelector.addGoal(4, new Zombie.ZombieAttackTurtleEggGoal(this, 1.0D, 3)); // Paper
|
||||
this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F));
|
||||
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
|
||||
this.addBehaviourGoals();
|
|
@ -1,36 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Wed, 19 Aug 2020 05:05:54 +0100
|
||||
Subject: [PATCH] Buffer joins to world
|
||||
|
||||
This patch buffers the number of logins which will attempt to join
|
||||
the world per tick, this attempts to reduce the impact that join floods
|
||||
has on the server
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
||||
index ed4587248fada36c4c206be1fa36fef42fc969e2..ddde8f9f53f352c806166354e6a445543ecc2fbf 100644
|
||||
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||
+++ b/src/main/java/net/minecraft/network/Connection.java
|
||||
@@ -387,10 +387,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper
|
||||
+ private static int joinAttemptsThisTick; // Paper
|
||||
+ private static int currTick; // Paper
|
||||
public void tick() {
|
||||
this.flushQueue();
|
||||
+ // Paper start
|
||||
+ if (currTick != net.minecraft.server.MinecraftServer.currentTick) {
|
||||
+ currTick = net.minecraft.server.MinecraftServer.currentTick;
|
||||
+ joinAttemptsThisTick = 0;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (this.packetListener instanceof ServerLoginPacketListenerImpl) {
|
||||
+ if ( ((ServerLoginPacketListenerImpl) this.packetListener).state != ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT // Paper
|
||||
+ || (joinAttemptsThisTick++ < MAX_PER_TICK)) { // Paper - limit the number of joins which can be processed each tick
|
||||
((ServerLoginPacketListenerImpl) this.packetListener).tick();
|
||||
+ } // Paper
|
||||
}
|
||||
|
||||
if (this.packetListener instanceof ServerGamePacketListenerImpl) {
|
File diff suppressed because it is too large
Load diff
|
@ -1,39 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: JRoy <joshroy126@gmail.com>
|
||||
Date: Thu, 27 Aug 2020 16:57:25 -0400
|
||||
Subject: [PATCH] Fix hex colors not working in some kick messages
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
index 43759cdf3da0796d7969c6504ac9a6986c0f0518..750fef0f5b908b776a7306e54653eba497b7c50b 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
@@ -75,12 +75,12 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (packet.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
|
||||
- MutableComponent ichatmutablecomponent;
|
||||
+ Component ichatmutablecomponent; // Paper - Fix hex colors not working in some kick messages
|
||||
|
||||
if (packet.getProtocolVersion() < 754) {
|
||||
- ichatmutablecomponent = Component.literal( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) ); // Spigot
|
||||
+ ichatmutablecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
|
||||
} else {
|
||||
- ichatmutablecomponent = Component.literal( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) ); // Spigot
|
||||
+ ichatmutablecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
|
||||
}
|
||||
|
||||
this.connection.send(new ClientboundLoginDisconnectPacket(ichatmutablecomponent));
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index e51c03e05c4407ad3a51e573a5e79b003f86d9f1..000ee7e12a1c756e065e99ebdbcf4a51047ec4d3 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -111,7 +111,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
|
||||
// CraftBukkit start
|
||||
@Deprecated
|
||||
public void disconnect(String s) {
|
||||
- this.disconnect(Component.literal(s));
|
||||
+ this.disconnect(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s, true)[0]); // Paper - Fix hex colors not working in some kick messages
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Fri, 21 Aug 2020 20:57:54 +0200
|
||||
Subject: [PATCH] PortalCreateEvent needs to know its entity
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index 8400f6fc96efecf0ea77f2e163b589ec375272cd..494a39cfafa5a632ccb61b196b0ec4e5772aa180 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -431,7 +431,7 @@ public final class ItemStack {
|
||||
net.minecraft.world.level.block.state.BlockState block = world.getBlockState(newblockposition);
|
||||
|
||||
if (!(block.getBlock() instanceof BaseEntityBlock)) { // Containers get placed automatically
|
||||
- block.getBlock().onPlace(block, world, newblockposition, oldBlock, true);
|
||||
+ block.getBlock().onPlace(block, world, newblockposition, oldBlock, true, itemactioncontext); // Paper - pass itemactioncontext
|
||||
}
|
||||
|
||||
world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
|
||||
index 378d4316a51d48cb84e2d8a553f7b28bae55630e..922b5b22a4ccfeead9d6d2b9a2a2b3cc8a1e6c55 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
|
||||
@@ -139,20 +139,23 @@ public abstract class BaseFireBlock extends Block {
|
||||
super.entityInside(state, world, pos, entity);
|
||||
}
|
||||
|
||||
+ // Paper start - ItemActionContext param
|
||||
+ @Override public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { this.onPlace(state, world, pos, oldState, notify, null); }
|
||||
@Override
|
||||
- public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
||||
- if (!oldState.is(state.getBlock())) {
|
||||
+ public void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, net.minecraft.world.item.context.UseOnContext itemActionContext) {
|
||||
+ // Paper end
|
||||
+ if (!iblockdata1.is(iblockdata.getBlock())) {
|
||||
if (BaseFireBlock.inPortalDimension(world)) {
|
||||
- Optional<PortalShape> optional = PortalShape.findEmptyPortalShape(world, pos, Direction.Axis.X);
|
||||
+ Optional<PortalShape> optional = PortalShape.findEmptyPortalShape(world, blockposition, Direction.Axis.X);
|
||||
|
||||
if (optional.isPresent()) {
|
||||
- ((PortalShape) optional.get()).createPortalBlocks();
|
||||
+ ((PortalShape) optional.get()).createPortalBlocks(itemActionContext); // Paper - pass ItemActionContext param
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
- if (!state.canSurvive(world, pos)) {
|
||||
- this.fireExtinguished(world, pos); // CraftBukkit - fuel block broke
|
||||
+ if (!iblockdata.canSurvive(world, blockposition)) {
|
||||
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java
|
||||
index 5ce5902b13ebb9438433d189f2c03677e4cb54b3..e34b8cff424ad58eee65a65fa510fa9908dbdf39 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/FireBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
+import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -356,9 +357,11 @@ public class FireBlock extends BaseFireBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
||||
- super.onPlace(state, world, pos, oldState, notify);
|
||||
- world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world.random));
|
||||
+ // Paper start - ItemActionContext param
|
||||
+ public void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, UseOnContext itemActionContext) {
|
||||
+ super.onPlace(iblockdata, world, blockposition, iblockdata1, flag, itemActionContext);
|
||||
+ // Paper end
|
||||
+ world.scheduleTick(blockposition, this, getFireTickDelay(world.random));
|
||||
}
|
||||
|
||||
private static int getFireTickDelay(RandomSource random) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
index 0ff34d2c569fbeae95509abed343b1e2f593378a..d75eb5eef83c9b0d247c7d8cb5021e931fe3ef4c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
@@ -34,6 +34,7 @@ import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
+import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.EmptyBlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -135,6 +136,12 @@ public abstract class BlockBehaviour {
|
||||
DebugPackets.sendNeighborsUpdatePacket(world, pos);
|
||||
}
|
||||
|
||||
+ // Paper start - add ItemActionContext param
|
||||
+ @Deprecated
|
||||
+ public void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, UseOnContext itemActionContext) {
|
||||
+ this.onPlace(iblockdata, world, blockposition, iblockdata1, flag);
|
||||
+ }
|
||||
+ // Paper end
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/portal/PortalShape.java b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
||||
index 768c39b265437641721d669d6aa85b3db49e5422..3414f3190e1a760c602613e82e551e797c3aa575 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/portal/PortalShape.java
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
+import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.NetherPortalBlock;
|
||||
@@ -184,7 +185,10 @@ public class PortalShape {
|
||||
}
|
||||
|
||||
// CraftBukkit start - return boolean
|
||||
- public boolean createPortalBlocks() {
|
||||
+ // Paper start - ItemActionContext param
|
||||
+ @Deprecated public boolean createPortalBlocks() { return this.createPortalBlocks(null); }
|
||||
+ public boolean createPortalBlocks(UseOnContext itemActionContext) {
|
||||
+ // Paper end
|
||||
org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld();
|
||||
|
||||
// Copy below for loop
|
||||
@@ -194,7 +198,7 @@ public class PortalShape {
|
||||
this.blocks.setBlock(blockposition, iblockdata, 18);
|
||||
});
|
||||
|
||||
- PortalCreateEvent event = new PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) this.blocks.getList(), bworld, null, PortalCreateEvent.CreateReason.FIRE);
|
||||
+ PortalCreateEvent event = new PortalCreateEvent((java.util.List<org.bukkit.block.BlockState>) (java.util.List) blocks.getList(), bworld, itemActionContext == null || itemActionContext.getPlayer() == null ? null : itemActionContext.getPlayer().getBukkitEntity(), PortalCreateEvent.CreateReason.FIRE); // Paper - pass entity param
|
||||
this.level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
|
||||
Date: Sun, 30 Aug 2020 15:30:29 +0800
|
||||
Subject: [PATCH] Fix CraftTeam null check
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
||||
index 18d5a26c34c848241c306241b3ad9825b5a0b9a9..60b1cffdccde4715832546d6edbf206fbab4e82f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
||||
@@ -261,7 +261,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
||||
|
||||
@Override
|
||||
public boolean hasEntry(String entry) throws IllegalArgumentException, IllegalStateException {
|
||||
- Validate.notNull("Entry cannot be null");
|
||||
+ Validate.notNull(entry, "Entry cannot be null"); // Paper
|
||||
|
||||
CraftScoreboard scoreboard = this.checkState();
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 23 Aug 2020 15:28:35 +0200
|
||||
Subject: [PATCH] Add more Evoker API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java
|
||||
index 91d07e6996e315734689ea25336992b0ed21cf25..7e861636710aa44ed36e7f20c6320dabb809c35d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
+import net.minecraft.world.entity.animal.Sheep;
|
||||
import net.minecraft.world.entity.monster.SpellcasterIllager;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -35,4 +36,17 @@ public class CraftEvoker extends CraftSpellcaster implements Evoker {
|
||||
public void setCurrentSpell(Evoker.Spell spell) {
|
||||
this.getHandle().setIsCastingSpell(spell == null ? SpellcasterIllager.IllagerSpell.NONE : SpellcasterIllager.IllagerSpell.byId(spell.ordinal()));
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public org.bukkit.entity.Sheep getWololoTarget() {
|
||||
+ Sheep sheep = getHandle().getWololoTarget();
|
||||
+ return sheep == null ? null : (org.bukkit.entity.Sheep) sheep.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setWololoTarget(org.bukkit.entity.Sheep sheep) {
|
||||
+ getHandle().setWololoTarget(sheep == null ? null : ((org.bukkit.craftbukkit.entity.CraftSheep) sheep).getHandle());
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,174 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Tue, 11 Aug 2020 19:16:09 +0200
|
||||
Subject: [PATCH] Add methods to get translation keys
|
||||
|
||||
Co-authored-by: MeFisto94 <MeFisto94@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index ea3358905dcd39a1a855d98570457c65dcd7513d..396fb96abed1e77893d8ee8a15cff18cad804475 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -668,5 +668,15 @@ public class CraftBlock implements Block {
|
||||
public org.bukkit.SoundGroup getBlockSoundGroup() {
|
||||
return org.bukkit.craftbukkit.CraftSoundGroup.getSoundGroup(this.getNMS().getSoundType());
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public String getTranslationKey() {
|
||||
+ return this.translationKey();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String translationKey() {
|
||||
+ return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
|
||||
index a859a675b4bc543e139358223cc92ad5eee3ddb5..31a22f26070059e5379730c1940ff1c5fb109be1 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
|
||||
@@ -194,6 +194,11 @@ public class CraftEnchantment extends Enchantment {
|
||||
public net.kyori.adventure.text.Component displayName(int level) {
|
||||
return io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().getFullname(level));
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public String translationKey() {
|
||||
+ return this.target.getDescriptionId();
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
public net.minecraft.world.item.enchantment.Enchantment getHandle() {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index 7d9a91b2afb6890a160c2cd1e1cf3f0fb6a10d92..c5d570131cd3c9b43ab7889454923c29078e0915 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -478,6 +478,30 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
Preconditions.checkArgument(dataVersion <= getDataVersion(), "Newer version! Server downgrades are not supported!");
|
||||
return compound;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public String getTranslationKey(Material mat) {
|
||||
+ if (mat.isBlock()) {
|
||||
+ return getBlock(mat).getDescriptionId();
|
||||
+ }
|
||||
+ return getItem(mat).getDescriptionId();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getTranslationKey(org.bukkit.block.Block block) {
|
||||
+ return ((org.bukkit.craftbukkit.block.CraftBlock)block).getNMS().getBlock().getDescriptionId();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getTranslationKey(org.bukkit.entity.EntityType type) {
|
||||
+ return net.minecraft.world.entity.EntityType.byString(type.getName()).map(net.minecraft.world.entity.EntityType::getDescriptionId).orElse(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getTranslationKey(org.bukkit.inventory.ItemStack itemStack) {
|
||||
+ net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
|
||||
+ return nmsItemStack.getItem().getDescriptionId(nmsItemStack);
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
|
||||
index fab3063fffa959ac7f0eb5937f2fae94d11b6591..9292a0119499d14c9ed170999ac3b8dfdd1f839a 100644
|
||||
--- a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
|
||||
+++ b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
|
||||
@@ -1,12 +1,29 @@
|
||||
package io.papermc.paper.world;
|
||||
|
||||
import com.destroystokyo.paper.ClientOption;
|
||||
+import net.minecraft.core.Registry;
|
||||
+import net.minecraft.core.RegistryAccess;
|
||||
+import net.minecraft.network.chat.contents.TranslatableContents;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.entity.player.ChatVisiblity;
|
||||
+import net.minecraft.world.item.CreativeModeTab;
|
||||
+import net.minecraft.world.level.GameType;
|
||||
+import net.minecraft.world.level.biome.Biome;
|
||||
import org.bukkit.Difficulty;
|
||||
+import org.bukkit.FireworkEffect;
|
||||
+import org.bukkit.GameMode;
|
||||
+import org.bukkit.GameRule;
|
||||
+import org.bukkit.attribute.Attribute;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftCreativeCategory;
|
||||
+import org.bukkit.inventory.CreativeCategory;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
-public class TranslationKeyTest {
|
||||
+import java.util.Map;
|
||||
+import java.util.Objects;
|
||||
+
|
||||
+public class TranslationKeyTest extends AbstractTestingBase {
|
||||
|
||||
@Test
|
||||
public void testChatVisibilityKeys() {
|
||||
@@ -15,4 +32,60 @@ public class TranslationKeyTest {
|
||||
Assert.assertEquals(chatVisibility + "'s translation key doesn't match", ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey());
|
||||
}
|
||||
}
|
||||
+
|
||||
+ @Test
|
||||
+ public void testDifficultyKeys() {
|
||||
+ for (Difficulty bukkitDifficulty : Difficulty.values()) {
|
||||
+ Assert.assertEquals(bukkitDifficulty + "'s translation key doesn't match", ((TranslatableContents) net.minecraft.world.Difficulty.byId(bukkitDifficulty.ordinal()).getDisplayName().getContents()).getKey(), bukkitDifficulty.translationKey());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testGameruleKeys() {
|
||||
+ for (GameRule<?> rule : GameRule.values()) {
|
||||
+ Assert.assertEquals(rule.getName() + "'s translation doesn't match", org.bukkit.craftbukkit.CraftWorld.getGameRulesNMS().get(rule.getName()).getDescriptionId(), rule.translationKey());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testAttributeKeys() {
|
||||
+ for (Attribute attribute : Attribute.values()) {
|
||||
+ Assert.assertEquals("translation key mismatch for " + attribute, org.bukkit.craftbukkit.attribute.CraftAttributeMap.toMinecraft(attribute).getDescriptionId(), attribute.translationKey());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testFireworkEffectType() {
|
||||
+ for (FireworkEffect.Type type : FireworkEffect.Type.values()) {
|
||||
+ Assert.assertEquals("translation key mismatch for " + type, net.minecraft.world.item.FireworkRocketItem.Shape.byId(org.bukkit.craftbukkit.inventory.CraftMetaFirework.getNBT(type)).getName(), org.bukkit.FireworkEffect.Type.NAMES.key(type));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testCreativeCategory() {
|
||||
+ for (CreativeModeTab tab : CreativeModeTab.TABS) {
|
||||
+ if (tab == CreativeModeTab.TAB_SEARCH || tab == CreativeModeTab.TAB_HOTBAR || tab == CreativeModeTab.TAB_INVENTORY) { // not implemented in the api
|
||||
+ continue;
|
||||
+ }
|
||||
+ CreativeCategory category = Objects.requireNonNull(CraftCreativeCategory.fromNMS(tab));
|
||||
+ Assert.assertEquals("translation key mismatch for " + category, ((TranslatableContents) tab.getDisplayName().getContents()).getKey(), category.translationKey());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testGameMode() {
|
||||
+ for (GameType nms : GameType.values()) {
|
||||
+ GameMode bukkit = GameMode.getByValue(nms.getId());
|
||||
+ Assert.assertNotNull(bukkit);
|
||||
+ Assert.assertEquals("translation key mismatch for " + bukkit, ((TranslatableContents) nms.getLongDisplayName().getContents()).getKey(), bukkit.translationKey());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testBiome() {
|
||||
+ for (Map.Entry<ResourceKey<Biome>, Biome> nms : RegistryAccess.builtinCopy().registry(Registry.BIOME_REGISTRY).get().entrySet()) {
|
||||
+ org.bukkit.block.Biome bukkit = org.bukkit.block.Biome.valueOf(nms.getKey().location().getPath().toUpperCase());
|
||||
+ Assert.assertEquals("translation key mismatch for " + bukkit, nms.getKey().location().toLanguageKey("biome"), bukkit.translationKey());
|
||||
+ }
|
||||
+ }
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: ysl3000 <yannicklamprecht@live.de>
|
||||
Date: Mon, 6 Jul 2020 22:18:04 +0200
|
||||
Subject: [PATCH] Create HoverEvent from ItemStack Entity
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
index f05923a6292f02a01791627abce2770daff24b6a..f3a6a4d97b5be2e75c438a6f7010a8f588afe86c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
@@ -405,5 +405,40 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
|
||||
return nms != null ? net.minecraft.locale.Language.getInstance().getOrDefault(nms.getItem().getDescriptionId(nms)) : null;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(ItemStack itemStack) {
|
||||
+ net.md_5.bungee.api.chat.ItemTag itemTag = net.md_5.bungee.api.chat.ItemTag.ofNbt(CraftItemStack.asNMSCopy(itemStack).getOrCreateTag().toString());
|
||||
+ return new net.md_5.bungee.api.chat.hover.content.Item(
|
||||
+ itemStack.getType().getKey().toString(),
|
||||
+ itemStack.getAmount(),
|
||||
+ itemTag);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(org.bukkit.entity.Entity entity) {
|
||||
+ return hoverContentOf(entity, org.apache.commons.lang3.StringUtils.isBlank(entity.getCustomName()) ? null : new net.md_5.bungee.api.chat.TextComponent(entity.getCustomName()));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(org.bukkit.entity.Entity entity, String customName) {
|
||||
+ return hoverContentOf(entity, org.apache.commons.lang3.StringUtils.isBlank(customName) ? null : new net.md_5.bungee.api.chat.TextComponent(customName));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(org.bukkit.entity.Entity entity, net.md_5.bungee.api.chat.BaseComponent customName) {
|
||||
+ return new net.md_5.bungee.api.chat.hover.content.Entity(
|
||||
+ entity.getType().getKey().toString(),
|
||||
+ entity.getUniqueId().toString(),
|
||||
+ customName);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(org.bukkit.entity.Entity entity, net.md_5.bungee.api.chat.BaseComponent[] customName) {
|
||||
+ return new net.md_5.bungee.api.chat.hover.content.Entity(
|
||||
+ entity.getType().getKey().toString(),
|
||||
+ entity.getUniqueId().toString(),
|
||||
+ new net.md_5.bungee.api.chat.TextComponent(customName));
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: miclebrick <miclebrick@outlook.com>
|
||||
Date: Thu, 6 Dec 2018 19:52:50 -0500
|
||||
Subject: [PATCH] Cache block data strings
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 2257a93b9f28a3b30f03ecb08e21346e0deeb8bf..ac65ff966b5ecd0960340c5a4063843e7c5582f3 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2015,6 +2015,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.getPlayerList().reloadResources();
|
||||
this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary());
|
||||
this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager);
|
||||
+ org.bukkit.craftbukkit.block.data.CraftBlockData.reloadCache(); // Paper - cache block data strings, they can be defined by datapacks so refresh it here
|
||||
}, this);
|
||||
|
||||
if (this.isSameThread()) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
index 514e1ab74cd24cfcf1dd031e69a8ebfaddf9d3dc..d02a5e383190fc4713141d953efc111bb2f7f89c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
@@ -506,9 +506,39 @@ public class CraftBlockData implements BlockData {
|
||||
Preconditions.checkState(CraftBlockData.MAP.put(nms, bukkit) == null, "Duplicate mapping %s->%s", nms, bukkit);
|
||||
}
|
||||
|
||||
+ // Paper start - cache block data strings
|
||||
+ private static Map<String, CraftBlockData> stringDataCache = new java.util.concurrent.ConcurrentHashMap<>();
|
||||
+
|
||||
+ static {
|
||||
+ // cache all of the default states at startup, will not cache ones with the custom states inside of the
|
||||
+ // brackets in a different order, though
|
||||
+ reloadCache();
|
||||
+ }
|
||||
+
|
||||
+ public static void reloadCache() {
|
||||
+ stringDataCache.clear();
|
||||
+ Block.BLOCK_STATE_REGISTRY.forEach(blockData -> stringDataCache.put(blockData.toString(), blockData.createCraftBlockData()));
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public static CraftBlockData newData(Material material, String data) {
|
||||
Preconditions.checkArgument(material == null || material.isBlock(), "Cannot get data for not block %s", material);
|
||||
|
||||
+ // Paper start - cache block data strings
|
||||
+ if (material != null) {
|
||||
+ Block block = CraftMagicNumbers.getBlock(material);
|
||||
+ if (block != null) {
|
||||
+ net.minecraft.resources.ResourceLocation key = Registry.BLOCK.getKey(block);
|
||||
+ data = data == null ? key.toString() : key + data;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ CraftBlockData cached = stringDataCache.computeIfAbsent(data, s -> createNewData(null, s));
|
||||
+ return (CraftBlockData) cached.clone();
|
||||
+ }
|
||||
+
|
||||
+ private static CraftBlockData createNewData(Material material, String data) {
|
||||
+ // Paper end - cache block data strings
|
||||
BlockState blockData;
|
||||
Block block = CraftMagicNumbers.getBlock(material);
|
||||
Map<Property<?>, Comparable<?>> parsed = null;
|
|
@ -1,83 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 25 Aug 2020 20:45:36 -0400
|
||||
Subject: [PATCH] Fix Entity Teleportation and cancel velocity if teleported
|
||||
|
||||
Uses correct setPositionRotation for Entity teleporting instead of setLocation
|
||||
as this is how Vanilla teleports entities.
|
||||
|
||||
Cancel any pending motion when teleported.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index b924bf36e5a13d9fb7078e091e50c7e468bdd5b5..b1281d1a0a51953703552e5855dd5a48de4e781e 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -721,7 +721,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
return;
|
||||
}
|
||||
|
||||
- this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
+ this.player.moveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); // Paper - use proper moveTo for teleportation
|
||||
this.lastGoodX = this.awaitingPositionFromClient.x;
|
||||
this.lastGoodY = this.awaitingPositionFromClient.y;
|
||||
this.lastGoodZ = this.awaitingPositionFromClient.z;
|
||||
@@ -1603,7 +1603,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
// CraftBukkit end
|
||||
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
- this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
+ this.player.moveTo(d0, d1, d2, f, f1); // Paper - use proper moveTo for teleportation
|
||||
this.player.connection.send(new ClientboundPlayerPositionPacket(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index bc3b174ceda5fb6dc6873429b8523ff85a1258a0..602525fdfe46fbe6e480a60f3382d04c344c7117 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -158,6 +158,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
|
||||
// CraftBukkit start
|
||||
private static final int CURRENT_LEVEL = 2;
|
||||
+ public boolean preserveMotion = true; // Paper - keep initial motion on first setPositionRotation
|
||||
static boolean isLevelAtLeast(CompoundTag tag, int level) {
|
||||
return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||
}
|
||||
@@ -1656,6 +1657,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public void moveTo(double x, double y, double z, float yaw, float pitch) {
|
||||
+ // Paper - cancel entity velocity if teleported
|
||||
+ if (!preserveMotion) {
|
||||
+ this.deltaMovement = Vec3.ZERO;
|
||||
+ } else {
|
||||
+ this.preserveMotion = false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.setPosRaw(x, y, z);
|
||||
this.setYRot(yaw);
|
||||
this.setXRot(pitch);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
index e3d8814cbad30da795632afddf8ebc87eff72106..ee619590aa49323059947fbaee9e88d61df99789 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
@@ -163,6 +163,7 @@ public abstract class BaseSpawner {
|
||||
return;
|
||||
}
|
||||
|
||||
+ entity.preserveMotion = true; // Paper - preserve entity motion from tag
|
||||
entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F);
|
||||
if (entity instanceof Mob) {
|
||||
Mob entityinsentient = (Mob) entity;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index c0a2cffadb762240ef8fcdec1bd1e49edd3b5c61..148cd01c88600042c557f21558acace8bfdfa1cf 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -590,7 +590,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
|
||||
// entity.setLocation() throws no event, and so cannot be cancelled
|
||||
- this.entity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
+ entity.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); // Paper - use proper moveTo, as per vanilla teleporting
|
||||
// SPIGOT-619: Force sync head rotation also
|
||||
this.entity.setYHeadRot(location.getYaw());
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: JRoy <joshroy126@gmail.com>
|
||||
Date: Wed, 26 Aug 2020 02:12:31 -0400
|
||||
Subject: [PATCH] Add additional open container api to HumanEntity
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
index 3a14cc3d0d692c8bbc90de1b1c5731158b1323e5..acf609e8d880156ba980b701816c475166c27bdb 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
@@ -459,6 +459,70 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
return this.getHandle().containerMenu.getBukkitView();
|
||||
}
|
||||
|
||||
+ // Paper start - Add additional containers
|
||||
+ @Override
|
||||
+ public InventoryView openAnvil(Location location, boolean force) {
|
||||
+ return openInventory(location, force, Material.ANVIL);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryView openCartographyTable(Location location, boolean force) {
|
||||
+ return openInventory(location, force, Material.CARTOGRAPHY_TABLE);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryView openGrindstone(Location location, boolean force) {
|
||||
+ return openInventory(location, force, Material.GRINDSTONE);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryView openLoom(Location location, boolean force) {
|
||||
+ return openInventory(location, force, Material.LOOM);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryView openSmithingTable(Location location, boolean force) {
|
||||
+ return openInventory(location, force, Material.SMITHING_TABLE);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryView openStonecutter(Location location, boolean force) {
|
||||
+ return openInventory(location, force, Material.STONECUTTER);
|
||||
+ }
|
||||
+
|
||||
+ private InventoryView openInventory(Location location, boolean force, Material material) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("open" + material);
|
||||
+ if (location == null) {
|
||||
+ location = getLocation();
|
||||
+ }
|
||||
+ if (!force) {
|
||||
+ Block block = location.getBlock();
|
||||
+ if (block.getType() != material) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ net.minecraft.world.level.block.Block block;
|
||||
+ if (material == Material.ANVIL) {
|
||||
+ block = Blocks.ANVIL;
|
||||
+ } else if (material == Material.CARTOGRAPHY_TABLE) {
|
||||
+ block = Blocks.CARTOGRAPHY_TABLE;
|
||||
+ } else if (material == Material.GRINDSTONE) {
|
||||
+ block = Blocks.GRINDSTONE;
|
||||
+ } else if (material == Material.LOOM) {
|
||||
+ block = Blocks.LOOM;
|
||||
+ } else if (material == Material.SMITHING_TABLE) {
|
||||
+ block = Blocks.SMITHING_TABLE;
|
||||
+ } else if (material == Material.STONECUTTER) {
|
||||
+ block = Blocks.STONECUTTER;
|
||||
+ } else {
|
||||
+ throw new IllegalArgumentException("Unsupported inventory type: " + material);
|
||||
+ }
|
||||
+ getHandle().openMenu(block.getMenuProvider(null, getHandle().level, new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
|
||||
+ getHandle().containerMenu.checkReachable = !force;
|
||||
+ return getHandle().containerMenu.getBukkitView();
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
// Paper start
|
|
@ -1,54 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 12 Sep 2020 17:21:38 -0400
|
||||
Subject: [PATCH] Cache DataFixerUpper Rewrite Rules on demand
|
||||
|
||||
Mojang precaches every single potential rewrite rule that could ever
|
||||
exist on server startup. This includes rules from all the way back to versions from 6+ years ago.
|
||||
|
||||
This is the source of why the server hogs every CPU core at 100% every start.
|
||||
|
||||
For anyone who hard resets for updates or has force upgraded their entire world, this
|
||||
results in completely wasted cpu cycles.
|
||||
|
||||
This massive CPU usage also delays server startup time.
|
||||
|
||||
We improve this by making "min version to precache" that defaults to a future version
|
||||
so that no rewrite rules are precached.
|
||||
|
||||
someone who expects to be converting a lot chunks could theoretically set
|
||||
-DPaper.minPrecachedDatafixVersion=<dataVersionConvertingFrom> as a startup
|
||||
parameter and only build from that point on.
|
||||
|
||||
However this will likely never be needed as the server will still run
|
||||
the same cache logic on demand when it's actually needed. The only
|
||||
cost would be some delay on the FIRST chunk conversion, but paper already
|
||||
runs chunk conversions on another thread so this will likely never be
|
||||
a concern for TPS.
|
||||
|
||||
This patch will significantly reduce CPU use on startup, reduce memory usage,
|
||||
and improve server startup time.
|
||||
|
||||
diff --git a/src/main/java/com/mojang/datafixers/DataFixerBuilder.java b/src/main/java/com/mojang/datafixers/DataFixerBuilder.java
|
||||
index d25f106ab64c90438f521a2c6fa944bdedc1969a..3d5e52d997a8e7d7f3b000e3737d30762aae2ca1 100644
|
||||
--- a/src/main/java/com/mojang/datafixers/DataFixerBuilder.java
|
||||
+++ b/src/main/java/com/mojang/datafixers/DataFixerBuilder.java
|
||||
@@ -28,8 +28,10 @@ public class DataFixerBuilder {
|
||||
private final Int2ObjectSortedMap<Schema> schemas = new Int2ObjectAVLTreeMap<>();
|
||||
private final List<DataFix> globalList = Lists.newArrayList();
|
||||
private final IntSortedSet fixerVersions = new IntAVLTreeSet();
|
||||
+ private final int minDataFixPrecacheVersion; // Paper
|
||||
|
||||
public DataFixerBuilder(final int dataVersion) {
|
||||
+ minDataFixPrecacheVersion = Integer.getInteger("Paper.minPrecachedDatafixVersion", dataVersion+1) * 10; // Paper - default to precache nothing - mojang stores versions * 10 to allow for 'sub versions'
|
||||
this.dataVersion = dataVersion;
|
||||
}
|
||||
|
||||
@@ -74,6 +76,7 @@ public class DataFixerBuilder {
|
||||
final IntBidirectionalIterator iterator = fixerUpper.fixerVersions().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final int versionKey = iterator.nextInt();
|
||||
+ if (versionKey < minDataFixPrecacheVersion) continue; // Paper
|
||||
final Schema schema = schemas.get(versionKey);
|
||||
for (final String typeName : schema.types()) {
|
||||
final CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
|
@ -1,43 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Thu, 17 Sep 2020 00:36:05 +0100
|
||||
Subject: [PATCH] Extend block drop capture to capture all items added to the
|
||||
world
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index bb8d5868275407fe3c5eb29174bf1970cae498f9..2ac0db36942ecb6dd073bc08f42fb3d1a6c12f6d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1287,6 +1287,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
// WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit
|
||||
return false;
|
||||
} else {
|
||||
+ // Paper start - capture all item additions to the world
|
||||
+ if (captureDrops != null && entity instanceof net.minecraft.world.entity.item.ItemEntity) {
|
||||
+ captureDrops.add((net.minecraft.world.entity.item.ItemEntity) entity);
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// SPIGOT-6415: Don't call spawn event when reason is null. For example when an entity teleports to a new world.
|
||||
if (spawnReason != null && !CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) {
|
||||
return false;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
index 431ff490760f54be76847c7b370dbbb4b65de102..1b45c1483a7ebad47162483b51036f9dfcdf62f6 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
@@ -428,10 +428,12 @@ public class ServerPlayerGameMode {
|
||||
// return true; // CraftBukkit
|
||||
}
|
||||
// CraftBukkit start
|
||||
+ java.util.List<net.minecraft.world.entity.item.ItemEntity> itemsToDrop = level.captureDrops; // Paper - store current list
|
||||
+ level.captureDrops = null; // Paper - Remove this earlier so that we can actually drop stuff
|
||||
if (event.isDropItems()) {
|
||||
- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, level.captureDrops);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - use stored ref
|
||||
}
|
||||
- level.captureDrops = null;
|
||||
+ //world.captureDrops = null; // Paper - move up
|
||||
|
||||
// Drop event experience
|
||||
if (flag && event != null) {
|
|
@ -1,18 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Sun, 27 Sep 2020 16:25:24 +0200
|
||||
Subject: [PATCH] Don't mark dirty in invalid locations (SPIGOT-6086)
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
index 90f65fdcc4acf6762c67a5cb3023d2493f03144f..96fb6e6ba3d1f9d5bd412f4f2bfb9450efa17948 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
@@ -245,6 +245,7 @@ public class ChunkHolder {
|
||||
}
|
||||
|
||||
public void blockChanged(BlockPos pos) {
|
||||
+ if (!pos.isInsideBuildHeightAndWorldBoundsHorizontal(levelHeightAccessor)) return; // Paper - SPIGOT-6086 for all invalid locations; avoid acquiring locks
|
||||
LevelChunk chunk = this.getTickingChunk();
|
||||
|
||||
if (chunk != null) {
|
|
@ -1,37 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MeFisto94 <MeFisto94@users.noreply.github.com>
|
||||
Date: Fri, 28 Aug 2020 01:41:26 +0200
|
||||
Subject: [PATCH] Expose the Entity Counter to allow plugins to use valid and
|
||||
non-conflicting Entity Ids
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 602525fdfe46fbe6e480a60f3382d04c344c7117..c2a17211cc216b9cf83ff393bf69ef49a3e778e8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4077,4 +4077,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
|
||||
void accept(Entity entity, double x, double y, double z);
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ public static int nextEntityId() {
|
||||
+ return ENTITY_COUNTER.incrementAndGet();
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index c5d570131cd3c9b43ab7889454923c29078e0915..7de4cf40d96caba35b43b6b4ac4daa1bf28ef27f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -502,6 +502,10 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
|
||||
return nmsItemStack.getItem().getDescriptionId(nmsItemStack);
|
||||
}
|
||||
+
|
||||
+ public int nextEntityId() {
|
||||
+ return net.minecraft.world.entity.Entity.nextEntityId();
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
|
@ -1,89 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Sat, 3 Oct 2020 04:15:09 -0400
|
||||
Subject: [PATCH] Lazily track plugin scoreboards by default
|
||||
|
||||
On servers with plugins that constantly churn through scoreboards, there is a risk of
|
||||
degraded GC performance due to the number of scoreboards held on by weak references.
|
||||
Most plugins don't even need the (vanilla) functionality that requires all plugin
|
||||
scoreboards to be tracked by the server. Instead, only track scoreboards when an
|
||||
objective is added with a non-dummy criteria.
|
||||
|
||||
This is a breaking change, however the change is a much more sensible default. In case
|
||||
this breaks your workflow you can always force all scoreboards to be tracked with
|
||||
settings.track-plugin-scoreboards in paper.yml.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
|
||||
index 9130c478b80fc50ef1fc4e27b1afa51e3f97d618..167376bcd547f55983ccbb0d46e571c45c7d1ed9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
|
||||
@@ -18,6 +18,7 @@ import org.bukkit.scoreboard.Team;
|
||||
|
||||
public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
|
||||
final Scoreboard board;
|
||||
+ boolean registeredGlobally = false; // Paper
|
||||
|
||||
CraftScoreboard(Scoreboard board) {
|
||||
this.board = board;
|
||||
@@ -44,6 +45,12 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
|
||||
Validate.isTrue(name.length() <= Short.MAX_VALUE, "The name '" + name + "' is longer than the limit of 32767 characters");
|
||||
Validate.isTrue(board.getObjective(name) == null, "An objective of name '" + name + "' already exists");
|
||||
CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria);
|
||||
+ // Paper start - the block comment from the old registerNewObjective didnt cause a conflict when rebasing, so this block wasn't added to the adventure registerNewObjective
|
||||
+ if (craftCriteria.criteria != net.minecraft.world.scores.criteria.ObjectiveCriteria.DUMMY && !registeredGlobally) {
|
||||
+ net.minecraft.server.MinecraftServer.getServer().server.getScoreboardManager().registerScoreboardForVanilla(this);
|
||||
+ registeredGlobally = true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
net.minecraft.world.scores.Objective objective = board.addObjective(name, craftCriteria.criteria, io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
|
||||
return new CraftObjective(this, objective);
|
||||
}
|
||||
@@ -68,6 +75,12 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
|
||||
net.minecraft.world.scores.Objective objective = this.board.addObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
|
||||
|
||||
CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria);
|
||||
+ // Paper start
|
||||
+ if (craftCriteria.criteria != net.minecraft.server.IScoreboardCriteria.DUMMY && !registeredGlobally) {
|
||||
+ net.minecraft.server.MinecraftServer.getServer().server.getScoreboardManager().registerScoreboardForVanilla(this);
|
||||
+ registeredGlobally = true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
|
||||
return new CraftObjective(this, objective);*/ // Paper
|
||||
return registerNewObjective(name, criteria, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(displayName), renderType); // Paper
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
|
||||
index ff090edcc85713083449cebb22bd1490123bc1ee..60d5564b5eb9f91db6b02bd4fb037a11fc6dfeb3 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
|
||||
@@ -30,6 +30,7 @@ public final class CraftScoreboardManager implements ScoreboardManager {
|
||||
|
||||
public CraftScoreboardManager(MinecraftServer minecraftserver, net.minecraft.world.scores.Scoreboard scoreboardServer) {
|
||||
this.mainScoreboard = new CraftScoreboard(scoreboardServer);
|
||||
+ mainScoreboard.registeredGlobally = true; // Paper
|
||||
this.server = minecraftserver;
|
||||
this.scoreboards.add(mainScoreboard);
|
||||
}
|
||||
@@ -43,10 +44,22 @@ public final class CraftScoreboardManager implements ScoreboardManager {
|
||||
public CraftScoreboard getNewScoreboard() {
|
||||
org.spigotmc.AsyncCatcher.catchOp("scoreboard creation"); // Spigot
|
||||
CraftScoreboard scoreboard = new CraftScoreboard(new ServerScoreboard(this.server));
|
||||
- this.scoreboards.add(scoreboard);
|
||||
+ // Paper start
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().scoreboards.trackPluginScoreboards) {
|
||||
+ scoreboard.registeredGlobally = true;
|
||||
+ scoreboards.add(scoreboard);
|
||||
+ }
|
||||
+ // Paper end
|
||||
return scoreboard;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public void registerScoreboardForVanilla(CraftScoreboard scoreboard) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("scoreboard registration");
|
||||
+ scoreboards.add(scoreboard);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
// CraftBukkit method
|
||||
public CraftScoreboard getPlayerBoard(CraftPlayer player) {
|
||||
CraftScoreboard board = this.playerBoards.get(player);
|
|
@ -1,42 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 3 Oct 2020 21:39:16 -0500
|
||||
Subject: [PATCH] Entity#isTicking
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index c2a17211cc216b9cf83ff393bf69ef49a3e778e8..c5cd18b02e5956fef6779b0b89d33b515bc9d13a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -59,6 +59,7 @@ import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MCUtil;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.TicketType;
|
||||
@@ -4082,5 +4083,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
public static int nextEntityId() {
|
||||
return ENTITY_COUNTER.incrementAndGet();
|
||||
}
|
||||
+
|
||||
+ public boolean isTicking() {
|
||||
+ return ((ServerChunkCache) level.getChunkSource()).isPositionTicking(this);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 148cd01c88600042c557f21558acace8bfdfa1cf..c39b683cbe83618daee0ca00d1107b115af6bf8f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -1278,5 +1278,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
public boolean isInLava() {
|
||||
return getHandle().isInLava();
|
||||
}
|
||||
+
|
||||
+ public boolean isTicking() {
|
||||
+ return getHandle().isTicking();
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 3 Oct 2020 22:00:27 -0500
|
||||
Subject: [PATCH] Fix deop kicking non-whitelisted player when white list is
|
||||
not enabled
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index ac65ff966b5ecd0960340c5a4063843e7c5582f3..115e598dcb075a8019b588b878e9d22994f0ce9f 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2081,13 +2081,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
if (this.isEnforceWhitelist()) {
|
||||
PlayerList playerlist = source.getServer().getPlayerList();
|
||||
UserWhiteList whitelist = playerlist.getWhiteList();
|
||||
+ if (!((DedicatedServer)getServer()).getProperties().whiteList.get()) return; // Paper - white list not enabled
|
||||
List<ServerPlayer> list = Lists.newArrayList(playerlist.getPlayers());
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
||||
|
||||
- if (!whitelist.isWhiteListed(entityplayer.getGameProfile())) {
|
||||
+ if (!whitelist.isWhiteListed(entityplayer.getGameProfile()) && !this.getPlayerList().isOp(entityplayer.getGameProfile())) { // Paper - Fix kicking ops when whitelist is reloaded (MC-171420)
|
||||
entityplayer.connection.disconnect(Component.translatable("multiplayer.disconnect.not_whitelisted"));
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 6 Jul 2020 18:36:41 -0400
|
||||
Subject: [PATCH] Fix Concurrency issue in ShufflingList
|
||||
|
||||
if multiple threads from worldgen sort at same time, it will crash.
|
||||
So make a copy of the list for sorting purposes.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
index c1f22c5e17418f91736237af1495a8a9910a61d5..5a5d454b5987bb01d03f91c15b7a6bff46f1de71 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
@@ -16,7 +16,7 @@ public class GateBehavior<E extends LivingEntity> extends Behavior<E> {
|
||||
private final Set<MemoryModuleType<?>> exitErasedMemories;
|
||||
private final GateBehavior.OrderPolicy orderPolicy;
|
||||
private final GateBehavior.RunningPolicy runningPolicy;
|
||||
- private final ShufflingList<Behavior<? super E>> behaviors = new ShufflingList<>();
|
||||
+ private final ShufflingList<Behavior<? super E>> behaviors = new ShufflingList<>(false); // Paper - don't use a clone
|
||||
|
||||
public GateBehavior(Map<MemoryModuleType<?>, MemoryStatus> requiredMemoryState, Set<MemoryModuleType<?>> memoriesToForgetWhenStopped, GateBehavior.OrderPolicy order, GateBehavior.RunningPolicy runMode, List<Pair<Behavior<? super E>, Integer>> tasks) {
|
||||
super(requiredMemoryState);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
|
||||
index 2af08836c60ddf0e1df7c53316eae6e329b5747f..090bba46b6ecd7d0e1415feb678b9b23264fe5e9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
|
||||
@@ -14,12 +14,25 @@ import net.minecraft.util.RandomSource;
|
||||
public class ShufflingList<U> {
|
||||
protected final List<ShufflingList.WeightedEntry<U>> entries;
|
||||
private final RandomSource random = RandomSource.create();
|
||||
+ private final boolean isUnsafe; // Paper
|
||||
|
||||
public ShufflingList() {
|
||||
+ // Paper start
|
||||
+ this(true);
|
||||
+ }
|
||||
+ public ShufflingList(boolean isUnsafe) {
|
||||
+ this.isUnsafe = isUnsafe;
|
||||
+ // Paper end
|
||||
this.entries = Lists.newArrayList();
|
||||
}
|
||||
|
||||
private ShufflingList(List<ShufflingList.WeightedEntry<U>> list) {
|
||||
+ // Paper start
|
||||
+ this(list, true);
|
||||
+ }
|
||||
+ private ShufflingList(List<ShufflingList.WeightedEntry<U>> list, boolean isUnsafe) {
|
||||
+ this.isUnsafe = isUnsafe;
|
||||
+ // Paper end
|
||||
this.entries = Lists.newArrayList(list);
|
||||
}
|
||||
|
||||
@@ -35,11 +48,12 @@ public class ShufflingList<U> {
|
||||
}
|
||||
|
||||
public ShufflingList<U> shuffle() {
|
||||
- this.entries.forEach((entry) -> {
|
||||
- entry.setRandom(this.random.nextFloat());
|
||||
- });
|
||||
- this.entries.sort(Comparator.comparingDouble(ShufflingList.WeightedEntry::getRandWeight));
|
||||
- return this;
|
||||
+ // Paper start - make concurrent safe, work off a clone of the list
|
||||
+ List<ShufflingList.WeightedEntry<U>> list = this.isUnsafe ? Lists.newArrayList(this.entries) : this.entries;
|
||||
+ list.forEach(entry -> entry.setRandom(this.random.nextFloat()));
|
||||
+ list.sort(Comparator.comparingDouble(ShufflingList.WeightedEntry::getRandWeight));
|
||||
+ return this.isUnsafe ? new ShufflingList<>(list, this.isUnsafe) : this;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public Stream<U> stream() {
|
|
@ -1,24 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 1 Jun 2016 23:29:17 -0400
|
||||
Subject: [PATCH] Reset Ender Crystals on Dragon Spawn
|
||||
|
||||
Crystals can end up in a bad state in certain conditions which causes
|
||||
an exception on the expected number of crystals going negative.
|
||||
|
||||
This ensures the crystals/pillars are in expected state when the dragon spawns.
|
||||
|
||||
See #3522
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
index 908cc3e2fc2cf4894a10081192a8b0d3c7e99932..f32906729baf83d8b53d64ab750cddcc413a2927 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
@@ -409,6 +409,7 @@ public class EndDragonFight {
|
||||
enderDragon.moveTo(0.0D, 128.0D, 0.0D, this.level.random.nextFloat() * 360.0F, 0.0F);
|
||||
this.level.addFreshEntity(enderDragon);
|
||||
this.dragonUUID = enderDragon.getUUID();
|
||||
+ this.resetSpikeCrystals(); // Paper
|
||||
return enderDragon;
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Sun, 17 May 2020 23:47:33 -0700
|
||||
Subject: [PATCH] Fix for large move vectors crashing server
|
||||
|
||||
Check movement distance also based on current position.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index b1281d1a0a51953703552e5855dd5a48de4e781e..f1a41a931b22f88f0dd530fb559b1c2ed839527a 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -536,9 +536,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
|
||||
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
|
||||
ServerLevel worldserver = this.player.getLevel();
|
||||
- double d0 = entity.getX();
|
||||
- double d1 = entity.getY();
|
||||
- double d2 = entity.getZ();
|
||||
+ double d0 = entity.getX();final double fromX = d0; // Paper - OBFHELPER
|
||||
+ double d1 = entity.getY();final double fromY = d1; // Paper - OBFHELPER
|
||||
+ double d2 = entity.getZ();final double fromZ = d2; // Paper - OBFHELPER
|
||||
double d3 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX()); final double toX = d3; // Paper - OBFHELPER
|
||||
double d4 = ServerGamePacketListenerImpl.clampVertical(packet.getY()); final double toY = d4; // Paper - OBFHELPER
|
||||
double d5 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ()); final double toZ = d5; // Paper - OBFHELPER
|
||||
@@ -548,8 +548,19 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
double d7 = d4 - this.vehicleFirstGoodY;
|
||||
double d8 = d5 - this.vehicleFirstGoodZ;
|
||||
double d9 = entity.getDeltaMovement().lengthSqr();
|
||||
- double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
-
|
||||
+ // Paper start - fix large move vectors killing the server
|
||||
+ double currDeltaX = toX - fromX;
|
||||
+ double currDeltaY = toY - fromY;
|
||||
+ double currDeltaZ = toZ - fromZ;
|
||||
+ double d10 = Math.max(d6 * d6 + d7 * d7 + d8 * d8, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1);
|
||||
+ // Paper end - fix large move vectors killing the server
|
||||
+
|
||||
+ // Paper start - fix large move vectors killing the server
|
||||
+ double otherFieldX = d3 - this.vehicleLastGoodX;
|
||||
+ double otherFieldY = d4 - this.vehicleLastGoodY - 1.0E-6D;
|
||||
+ double otherFieldZ = d5 - this.vehicleLastGoodZ;
|
||||
+ d10 = Math.max(d10, (otherFieldX * otherFieldX + otherFieldY * otherFieldY + otherFieldZ * otherFieldZ) - 1);
|
||||
+ // Paper end - fix large move vectors killing the server
|
||||
|
||||
// CraftBukkit start - handle custom speeds and skipped ticks
|
||||
this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick;
|
||||
@@ -595,9 +606,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
|
||||
boolean flag = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D));
|
||||
|
||||
- d6 = d3 - this.vehicleLastGoodX;
|
||||
- d7 = d4 - this.vehicleLastGoodY - 1.0E-6D;
|
||||
- d8 = d5 - this.vehicleLastGoodZ;
|
||||
+ d6 = d3 - this.vehicleLastGoodX; // Paper - diff on change, used for checking large move vectors above
|
||||
+ d7 = d4 - this.vehicleLastGoodY - 1.0E-6D; // Paper - diff on change, used for checking large move vectors above
|
||||
+ d8 = d5 - this.vehicleLastGoodZ; // Paper - diff on change, used for checking large move vectors above
|
||||
boolean flag1 = entity.verticalCollisionBelow;
|
||||
|
||||
entity.move(MoverType.PLAYER, new Vec3(d6, d7, d8));
|
||||
@@ -1283,7 +1294,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
double d8 = d1 - this.firstGoodY;
|
||||
double d9 = d2 - this.firstGoodZ;
|
||||
double d10 = this.player.getDeltaMovement().lengthSqr();
|
||||
- double d11 = d7 * d7 + d8 * d8 + d9 * d9;
|
||||
+ // Paper start - fix large move vectors killing the server
|
||||
+ double currDeltaX = toX - prevX;
|
||||
+ double currDeltaY = toY - prevY;
|
||||
+ double currDeltaZ = toZ - prevZ;
|
||||
+ double d11 = Math.max(d7 * d7 + d8 * d8 + d9 * d9, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1);
|
||||
+ // Paper end - fix large move vectors killing the server
|
||||
+ // Paper start - fix large move vectors killing the server
|
||||
+ double otherFieldX = d0 - this.lastGoodX;
|
||||
+ double otherFieldY = d1 - this.lastGoodY;
|
||||
+ double otherFieldZ = d2 - this.lastGoodZ;
|
||||
+ d11 = Math.max(d11, (otherFieldX * otherFieldX + otherFieldY * otherFieldY + otherFieldZ * otherFieldZ) - 1);
|
||||
+ // Paper end - fix large move vectors killing the server
|
||||
|
||||
if (this.player.isSleeping()) {
|
||||
if (d11 > 1.0D) {
|
||||
@@ -1335,9 +1357,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
|
||||
AABB axisalignedbb = this.player.getBoundingBox();
|
||||
|
||||
- d7 = d0 - this.lastGoodX;
|
||||
- d8 = d1 - this.lastGoodY;
|
||||
- d9 = d2 - this.lastGoodZ;
|
||||
+ d7 = d0 - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above
|
||||
+ d8 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above
|
||||
+ d9 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above
|
||||
boolean flag = d8 > 0.0D;
|
||||
|
||||
if (this.player.isOnGround() && !packet.isOnGround() && flag) {
|
|
@ -1,94 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Wed, 3 Jun 2020 11:37:13 -0700
|
||||
Subject: [PATCH] Optimise getType calls
|
||||
|
||||
Remove the map lookup for converting from Block->Bukkit Material
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockState.java b/src/main/java/net/minecraft/world/level/block/state/BlockState.java
|
||||
index 76133c77e8ebce7c9e5402e3e7cd50b30aa1c2e0..348a91a760bd728f8e732e1a35c86ab75d8fc0f1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/BlockState.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockState.java
|
||||
@@ -10,6 +10,17 @@ import net.minecraft.world.level.block.state.properties.Property;
|
||||
public class BlockState extends BlockBehaviour.BlockStateBase {
|
||||
public static final Codec<BlockState> CODEC = codec(Registry.BLOCK.byNameCodec(), Block::defaultBlockState).stable();
|
||||
|
||||
+ // Paper start - optimise getType calls
|
||||
+ org.bukkit.Material cachedMaterial;
|
||||
+
|
||||
+ public final org.bukkit.Material getBukkitMaterial() {
|
||||
+ if (this.cachedMaterial == null) {
|
||||
+ this.cachedMaterial = org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(this.getBlock());
|
||||
+ }
|
||||
+
|
||||
+ return this.cachedMaterial;
|
||||
+ }
|
||||
+ // Paper end - optimise getType calls
|
||||
public BlockState(Block block, ImmutableMap<Property<?>, Comparable<?>> propertyMap, MapCodec<BlockState> codec) {
|
||||
super(block, propertyMap, codec);
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java b/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java
|
||||
index 0511ac55c4e6d9736ec12e94c9899eb04d5cd2e3..75193684a71d694736087d1a368b8fb6a8c8363b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java
|
||||
@@ -84,7 +84,7 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
|
||||
public Material getBlockType(int x, int y, int z) {
|
||||
this.validateChunkCoordinates(x, y, z);
|
||||
|
||||
- return CraftMagicNumbers.getMaterial(this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBlock());
|
||||
+ return this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBukkitMaterial(); // Paper - optimise getType calls
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index 396fb96abed1e77893d8ee8a15cff18cad804475..2c1efaecf220588d8b74946194bf340871e57004 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -224,7 +224,7 @@ public class CraftBlock implements Block {
|
||||
|
||||
@Override
|
||||
public Material getType() {
|
||||
- return CraftMagicNumbers.getMaterial(this.world.getBlockState(position).getBlock());
|
||||
+ return this.world.getBlockState(this.position).getBukkitMaterial(); // Paper - optimise getType calls
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
index 0a755f38fae9dc84440f43113920c5b4c6d8218b..7b9e943b391c061782fccd2b8d705ceec8db50fe 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
@@ -166,7 +166,7 @@ public class CraftBlockState implements BlockState {
|
||||
|
||||
@Override
|
||||
public Material getType() {
|
||||
- return CraftMagicNumbers.getMaterial(this.data.getBlock());
|
||||
+ return this.data.getBukkitMaterial(); // Paper - optimise getType calls
|
||||
}
|
||||
|
||||
public void setFlag(int flag) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
index d02a5e383190fc4713141d953efc111bb2f7f89c..aae7f7ab4931db8f955c3055157fe01f99931ec7 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
||||
@@ -50,7 +50,7 @@ public class CraftBlockData implements BlockData {
|
||||
|
||||
@Override
|
||||
public Material getMaterial() {
|
||||
- return CraftMagicNumbers.getMaterial(this.state.getBlock());
|
||||
+ return this.state.getBukkitMaterial(); // Paper - optimise getType calls
|
||||
}
|
||||
|
||||
public BlockState getState() {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
||||
index ee88ff2ee86bbd3ccf3e4a0b2310f020f137ef4f..5e15feb408b8a05ec5ee393a604c8d39a91ff106 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java
|
||||
@@ -96,7 +96,7 @@ public final class CraftChunkData implements ChunkGenerator.ChunkData {
|
||||
|
||||
@Override
|
||||
public Material getType(int x, int y, int z) {
|
||||
- return CraftMagicNumbers.getMaterial(this.getTypeId(x, y, z).getBlock());
|
||||
+ return this.getTypeId(x, y, z).getBukkitMaterial(); // Paper - optimise getType calls
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,40 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Mon, 7 Oct 2019 00:15:37 -0500
|
||||
Subject: [PATCH] Villager#resetOffers
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
|
||||
index 9960862cb5302aa44776ac294e3b9e30105adb07..6717e3d116b7bff8ab4d7b45f8c4ec00939c9c73 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
|
||||
@@ -115,6 +115,13 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa
|
||||
return this.tradingPlayer != null;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public void resetOffers() {
|
||||
+ this.offers = new MerchantOffers();
|
||||
+ this.updateTrades();
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public MerchantOffers getOffers() {
|
||||
if (this.offers == null) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java
|
||||
index 1467232779541a9e38420caabf273662f380794c..762354681315e4c74e414bf7d677b5422385161e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractVillager.java
|
||||
@@ -70,4 +70,11 @@ public class CraftAbstractVillager extends CraftAgeable implements AbstractVilla
|
||||
public HumanEntity getTrader() {
|
||||
return this.getMerchant().getTrader();
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void resetOffers() {
|
||||
+ getHandle().resetOffers();
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Mon, 6 Jul 2020 20:46:50 -0700
|
||||
Subject: [PATCH] Improve inlinig for some hot IBlockData methods
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
index d75eb5eef83c9b0d247c7d8cb5021e931fe3ef4c..254ac28e692cf06c3286c8f4c6edb9de412851a2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
@@ -716,8 +716,14 @@ public abstract class BlockBehaviour {
|
||||
return this.shapeExceedsCube;
|
||||
}
|
||||
// Paper end
|
||||
+ // Paper start
|
||||
+ protected boolean isTicking;
|
||||
+ protected FluidState fluid;
|
||||
+ // Paper end
|
||||
|
||||
public void initCache() {
|
||||
+ this.fluid = this.getBlock().getFluidState(this.asState()); // Paper - moved from getFluid()
|
||||
+ this.isTicking = this.getBlock().isRandomlyTicking(this.asState()); // Paper - moved from isTicking()
|
||||
if (!this.getBlock().hasDynamicShape()) {
|
||||
this.cache = new BlockBehaviour.BlockStateBase.Cache(this.asState());
|
||||
}
|
||||
@@ -767,15 +773,15 @@ public abstract class BlockBehaviour {
|
||||
return this.shapeExceedsCube; // Paper - moved into shape cache init
|
||||
}
|
||||
|
||||
- public boolean useShapeForLightOcclusion() {
|
||||
+ public final boolean useShapeForLightOcclusion() { // Paper
|
||||
return this.useShapeForLightOcclusion;
|
||||
}
|
||||
|
||||
- public int getLightEmission() {
|
||||
+ public final int getLightEmission() { // Paper
|
||||
return this.lightEmission;
|
||||
}
|
||||
|
||||
- public boolean isAir() {
|
||||
+ public final boolean isAir() { // Paper
|
||||
return this.isAir;
|
||||
}
|
||||
|
||||
@@ -849,7 +855,7 @@ public abstract class BlockBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
- public boolean canOcclude() {
|
||||
+ public final boolean canOcclude() { // Paper
|
||||
return this.canOcclude;
|
||||
}
|
||||
|
||||
@@ -1047,12 +1053,12 @@ public abstract class BlockBehaviour {
|
||||
return this.getBlock() == block;
|
||||
}
|
||||
|
||||
- public FluidState getFluidState() {
|
||||
- return this.getBlock().getFluidState(this.asState());
|
||||
+ public final FluidState getFluidState() { // Paper
|
||||
+ return this.fluid; // Paper - moved into init
|
||||
}
|
||||
|
||||
- public boolean isRandomlyTicking() {
|
||||
- return this.getBlock().isRandomlyTicking(this.asState());
|
||||
+ public final boolean isRandomlyTicking() { // Paper
|
||||
+ return this.isTicking; // Paper - moved into init
|
||||
}
|
||||
|
||||
public long getSeed(BlockPos pos) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/FluidState.java b/src/main/java/net/minecraft/world/level/material/FluidState.java
|
||||
index d035eaccc09dfeaedf25579b850ccdaecba3f974..66f712657ae0c4166ecd198f41081d96843296c4 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/FluidState.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/FluidState.java
|
||||
@@ -26,8 +26,12 @@ public final class FluidState extends StateHolder<Fluid, FluidState> {
|
||||
public static final int AMOUNT_MAX = 9;
|
||||
public static final int AMOUNT_FULL = 8;
|
||||
|
||||
+ // Paper start
|
||||
+ protected final boolean isEmpty;
|
||||
+ // Paper end
|
||||
public FluidState(Fluid fluid, ImmutableMap<Property<?>, Comparable<?>> propertiesMap, MapCodec<FluidState> codec) {
|
||||
super(fluid, propertiesMap, codec);
|
||||
+ this.isEmpty = fluid.isEmpty(); // Paper - moved from isEmpty()
|
||||
}
|
||||
|
||||
public Fluid getType() {
|
||||
@@ -43,7 +47,7 @@ public final class FluidState extends StateHolder<Fluid, FluidState> {
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
- return this.getType().isEmpty();
|
||||
+ return this.isEmpty; // Paper - moved into constructor
|
||||
}
|
||||
|
||||
public float getHeight(BlockGetter world, BlockPos pos) {
|
|
@ -1,24 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Fri, 7 Aug 2020 04:27:56 -0700
|
||||
Subject: [PATCH] Retain block place order when capturing blockstates
|
||||
|
||||
Fixes twisted vines not connecting properly when grown via
|
||||
bonemeal by a player.
|
||||
|
||||
In general, look at making this logic more robust (i.e properly handling
|
||||
cases where a captured entry is overriden) - but for now this will do.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index d5e80a0d953e7792669f21011bc685adaec78464..d9a88b29cfefcdbce7bfc477b6c1af0e51079102 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -155,7 +155,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
public boolean captureBlockStates = false;
|
||||
public boolean captureTreeGeneration = false;
|
||||
public Map<BlockPos, org.bukkit.craftbukkit.block.CraftBlockState> capturedBlockStates = new java.util.LinkedHashMap<>(); // Paper
|
||||
- public Map<BlockPos, BlockEntity> capturedTileEntities = new HashMap<>();
|
||||
+ public Map<BlockPos, BlockEntity> capturedTileEntities = new java.util.LinkedHashMap<>(); // Paper
|
||||
public List<ItemEntity> captureDrops;
|
||||
public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<SpawnCategory> ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>();
|
||||
// Paper start
|
|
@ -1,28 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Sat, 25 Apr 2020 17:10:55 -0700
|
||||
Subject: [PATCH] Reduce blockpos allocation from pathfinding
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||
index c48e097464977dbec22d1370c3393ba1fe105137..ede91a2fbe67480d2b6bcdeb776f87da0b69bdae 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||
@@ -495,7 +495,7 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
||||
return BlockPathTypes.DANGER_FIRE;
|
||||
}
|
||||
|
||||
- if (world.getFluidState(pos).is(FluidTags.WATER)) {
|
||||
+ if (blockState.getFluidState().is(FluidTags.WATER)) {
|
||||
return BlockPathTypes.WATER_BORDER;
|
||||
}
|
||||
} // Paper
|
||||
@@ -526,7 +526,7 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
||||
} else if (blockState.is(Blocks.COCOA)) {
|
||||
return BlockPathTypes.COCOA;
|
||||
} else {
|
||||
- FluidState fluidState = world.getFluidState(pos);
|
||||
+ FluidState fluidState = blockState.getFluidState(); // Paper - remove another get type call
|
||||
if (fluidState.is(FluidTags.LAVA)) {
|
||||
return BlockPathTypes.LAVA;
|
||||
} else if (isBurningBlock(blockState)) {
|
|
@ -1,24 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 3 Oct 2020 20:32:25 -0500
|
||||
Subject: [PATCH] Fix item locations dropped from campfires
|
||||
|
||||
Fixes #4259 by not flooring the blockposition among other weirdness
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
|
||||
index 0cebba557f0ba312e7911e61cb21485c81436720..003a66064c666db974c2b36f6579a87e1ad28685 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/CampfireBlockEntity.java
|
||||
@@ -78,7 +78,11 @@ public class CampfireBlockEntity extends BlockEntity implements Clearable {
|
||||
result = blockCookEvent.getResult();
|
||||
itemstack1 = CraftItemStack.asNMSCopy(result);
|
||||
// CraftBukkit end
|
||||
- Containers.dropItemStack(world, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), itemstack1);
|
||||
+ // Paper start
|
||||
+ net.minecraft.world.entity.item.ItemEntity droppedItem = new net.minecraft.world.entity.item.ItemEntity(world, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, itemstack1.split(world.random.nextInt(21) + 10));
|
||||
+ droppedItem.setDeltaMovement(world.random.nextGaussian() * 0.05D, world.random.nextGaussian() * 0.05D + 0.2D, world.random.nextGaussian() * 0.05D);
|
||||
+ world.addFreshEntity(droppedItem);
|
||||
+ // Paper end
|
||||
campfire.items.set(i, ItemStack.EMPTY);
|
||||
world.sendBlockUpdated(pos, state, state, 3);
|
||||
world.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(state));
|
|
@ -1,31 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Trigary <trigary0@gmail.com>
|
||||
Date: Tue, 14 Apr 2020 12:05:22 +0200
|
||||
Subject: [PATCH] Player elytra boost API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index d06f6c9a7bfa7585d5dfb7da8654837605866a3e..c94a7ccb3d5420dc0c8493d5cb0381a47ea8f9a0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -592,6 +592,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
throw new RuntimeException("Unknown settings type");
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.entity.Firework boostElytra(ItemStack firework) {
|
||||
+ Validate.isTrue(isGliding(), "Player must be gliding");
|
||||
+ Validate.isTrue(firework != null, "firework == null");
|
||||
+ Validate.isTrue(firework.getType() == Material.FIREWORK_ROCKET, "Firework must be Material.FIREWORK_ROCKET");
|
||||
+
|
||||
+ net.minecraft.world.item.ItemStack item = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(firework);
|
||||
+ net.minecraft.world.level.Level world = ((CraftWorld) getWorld()).getHandle();
|
||||
+ net.minecraft.world.entity.projectile.FireworkRocketEntity entity = new net.minecraft.world.entity.projectile.FireworkRocketEntity(world, item, getHandle());
|
||||
+ return world.addFreshEntity(entity)
|
||||
+ ? (org.bukkit.entity.Firework) entity.getBukkitEntity()
|
||||
+ : null;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
|
@ -1,39 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: giacomo <32515303+giacomozama@users.noreply.github.com>
|
||||
Date: Sat, 10 Oct 2020 12:15:33 +0200
|
||||
Subject: [PATCH] Fixed TileEntityBell memory leak
|
||||
|
||||
TileEntityBell has a list of entities (entitiesAtRing) that was not being cleared at the right time, causing leaks whenever a bell would be rung near a crowd of entities.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
|
||||
index 4353ad2f67556feaa0fdd34e8e907b17ab697565..feaad48e9bbc1e658324ef9e1e7e73aca0b3bf48 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
|
||||
@@ -61,6 +61,11 @@ public class BellBlockEntity extends BlockEntity {
|
||||
|
||||
if (blockEntity.ticks >= 50) {
|
||||
blockEntity.shaking = false;
|
||||
+ // Paper start
|
||||
+ if (!blockEntity.resonating) {
|
||||
+ blockEntity.nearbyEntities.clear();
|
||||
+ }
|
||||
+ // Paper end
|
||||
blockEntity.ticks = 0;
|
||||
}
|
||||
|
||||
@@ -74,6 +79,7 @@ public class BellBlockEntity extends BlockEntity {
|
||||
++blockEntity.resonationTicks;
|
||||
} else {
|
||||
bellEffect.run(world, pos, blockEntity.nearbyEntities);
|
||||
+ blockEntity.nearbyEntities.clear(); // Paper
|
||||
blockEntity.resonating = false;
|
||||
}
|
||||
}
|
||||
@@ -116,6 +122,7 @@ public class BellBlockEntity extends BlockEntity {
|
||||
}
|
||||
}
|
||||
|
||||
+ this.nearbyEntities.removeIf(e -> !e.isAlive()); // Paper
|
||||
}
|
||||
|
||||
private static boolean areRaidersNearby(BlockPos pos, List<LivingEntity> hearingEntities) {
|
|
@ -1,46 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Toon Schoenmakers <nighteyes1993@gmail.com>
|
||||
Date: Fri, 23 Oct 2020 15:01:44 +0200
|
||||
Subject: [PATCH] Avoid error bubbling up when item stack is empty in fishing
|
||||
loot
|
||||
|
||||
This can realistically only happen if there's custom loot active on fishing
|
||||
which can return 0 items. This would disconnect the player who's fishing.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
index 11ac510ad4095438d4904d521bfb18aa5f743faf..f5886a88fd98ede5e85a91eccccb05ac33eb40e2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
@@ -494,9 +494,15 @@ public class FishingHook extends Projectile {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
ItemStack itemstack1 = (ItemStack) iterator.next();
|
||||
- ItemEntity entityitem = new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), itemstack1);
|
||||
+ // Paper start, new EntityItem would throw if for whatever reason (mostly shitty datapacks) the itemstack1 turns out to be empty
|
||||
+ // if the item stack is empty we instead just have our entityitem as null
|
||||
+ ItemEntity entityitem = null;
|
||||
+ if (!itemstack1.isEmpty()) {
|
||||
+ entityitem = new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), itemstack1);
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit start
|
||||
- PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), entityitem.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
|
||||
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), entityitem != null ? entityitem.getBukkitEntity() : null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH); // Paper - entityitem may be null
|
||||
playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1);
|
||||
this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent);
|
||||
|
||||
@@ -509,8 +515,12 @@ public class FishingHook extends Projectile {
|
||||
double d2 = entityhuman.getZ() - this.getZ();
|
||||
double d3 = 0.1D;
|
||||
|
||||
- entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
|
||||
- this.level.addFreshEntity(entityitem);
|
||||
+ // Paper start, entity item can be null, so we need to check against this
|
||||
+ if (entityitem != null) {
|
||||
+ entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
|
||||
+ this.level.addFreshEntity(entityitem);
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
|
||||
if (playerFishEvent.getExpToDrop() > 0) {
|
||||
entityhuman.level.addFreshEntity(new ExperienceOrb(entityhuman.level, entityhuman.getX(), entityhuman.getY() + 0.5D, entityhuman.getZ() + 0.5D, playerFishEvent.getExpToDrop(), org.bukkit.entity.ExperienceOrb.SpawnReason.FISHING, this.getPlayerOwner(), this)); // Paper
|
|
@ -1,39 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: oxygencraft <21054297+oxygencraft@users.noreply.github.com>
|
||||
Date: Sun, 25 Oct 2020 18:34:50 +1100
|
||||
Subject: [PATCH] Add getOfflinePlayerIfCached(String)
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 57c4871b977a31f55e5c39aba4159b39b1ac325d..da3ca296a4bcc0c6d303df9de5370a89a5ae0d67 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1801,6 +1801,28 @@ public final class CraftServer implements Server {
|
||||
return result;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ @Nullable
|
||||
+ public OfflinePlayer getOfflinePlayerIfCached(String name) {
|
||||
+ Validate.notNull(name, "Name cannot be null");
|
||||
+ Validate.notEmpty(name, "Name cannot be empty");
|
||||
+
|
||||
+ OfflinePlayer result = getPlayerExact(name);
|
||||
+ if (result == null) {
|
||||
+ GameProfile profile = console.getProfileCache().getProfileIfCached(name);
|
||||
+
|
||||
+ if (profile != null) {
|
||||
+ result = getOfflinePlayer(profile);
|
||||
+ }
|
||||
+ } else {
|
||||
+ offlinePlayers.remove(result.getUniqueId());
|
||||
+ }
|
||||
+
|
||||
+ return result;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public OfflinePlayer getOfflinePlayer(UUID id) {
|
||||
Validate.notNull(id, "UUID cannot be null");
|
|
@ -1,154 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Mon, 9 Nov 2020 20:44:51 +0100
|
||||
Subject: [PATCH] Add ignore discounts API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
index 39fc94b1e1555fd6706391223dd2783139b16016..1d2b7950e3c498945a2ff85fda0e3bb30acd22cb 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -489,6 +489,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
|
||||
+ if (merchantrecipe.ignoreDiscounts) continue; // Paper
|
||||
|
||||
merchantrecipe.addToSpecialPriceDiff(-Mth.floor((float) i * merchantrecipe.getPriceMultiplier()));
|
||||
}
|
||||
@@ -501,6 +502,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
MerchantOffer merchantrecipe1 = (MerchantOffer) iterator1.next();
|
||||
+ if (merchantrecipe1.ignoreDiscounts) continue; // Paper
|
||||
double d0 = 0.3D + 0.0625D * (double) j;
|
||||
int k = (int) Math.floor(d0 * (double) merchantrecipe1.getBaseCostA().getCount());
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
||||
index 8b46e494ecd0cce5ab0b2bf8e50cf50dc7e2a7e5..8a9a701baabdaf066cd9b28c05430f673fcafb4e 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/trading/MerchantOffer.java
|
||||
@@ -19,6 +19,7 @@ public class MerchantOffer {
|
||||
public int demand;
|
||||
public float priceMultiplier;
|
||||
public int xp;
|
||||
+ public boolean ignoreDiscounts; // Paper
|
||||
// CraftBukkit start
|
||||
private CraftMerchantRecipe bukkitHandle;
|
||||
|
||||
@@ -31,7 +32,15 @@ public class MerchantOffer {
|
||||
}
|
||||
|
||||
public MerchantOffer(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, int demand, CraftMerchantRecipe bukkit) {
|
||||
- this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, demand);
|
||||
+ // Paper start - add ignoreDiscounts param
|
||||
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, demand, false, bukkit);
|
||||
+ }
|
||||
+ public MerchantOffer(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, boolean ignoreDiscounts, CraftMerchantRecipe bukkit) {
|
||||
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, 0, ignoreDiscounts, bukkit);
|
||||
+ }
|
||||
+ public MerchantOffer(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, int demand, boolean ignoreDiscounts, CraftMerchantRecipe bukkit) {
|
||||
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, demand, ignoreDiscounts);
|
||||
+ // Paper end
|
||||
this.bukkitHandle = bukkit;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -63,6 +72,7 @@ public class MerchantOffer {
|
||||
|
||||
this.specialPriceDiff = nbt.getInt("specialPrice");
|
||||
this.demand = nbt.getInt("demand");
|
||||
+ this.ignoreDiscounts = nbt.getBoolean("Paper.IgnoreDiscounts"); // Paper
|
||||
}
|
||||
|
||||
public MerchantOffer(ItemStack buyItem, ItemStack sellItem, int maxUses, int merchantExperience, float priceMultiplier) {
|
||||
@@ -74,10 +84,19 @@ public class MerchantOffer {
|
||||
}
|
||||
|
||||
public MerchantOffer(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier) {
|
||||
- this(firstBuyItem, secondBuyItem, sellItem, uses, maxUses, merchantExperience, priceMultiplier, 0);
|
||||
+ // Paper start - add ignoreDiscounts param
|
||||
+ this(firstBuyItem, secondBuyItem, sellItem, uses, maxUses, merchantExperience, priceMultiplier, false);
|
||||
+ }
|
||||
+ public MerchantOffer(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier, boolean ignoreDiscounts) {
|
||||
+ this(firstBuyItem, secondBuyItem, sellItem, uses, maxUses, merchantExperience, priceMultiplier, 0, ignoreDiscounts);
|
||||
}
|
||||
|
||||
public MerchantOffer(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier, int demandBonus) {
|
||||
+ this(firstBuyItem, secondBuyItem, sellItem, uses, maxUses, merchantExperience, priceMultiplier, demandBonus, false);
|
||||
+ }
|
||||
+ public MerchantOffer(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier, int demandBonus, boolean ignoreDiscounts) {
|
||||
+ this.ignoreDiscounts = ignoreDiscounts;
|
||||
+ // Paper end
|
||||
this.rewardExp = true;
|
||||
this.xp = 1;
|
||||
this.baseCostA = firstBuyItem;
|
||||
@@ -193,6 +212,7 @@ public class MerchantOffer {
|
||||
nbttagcompound.putFloat("priceMultiplier", this.priceMultiplier);
|
||||
nbttagcompound.putInt("specialPrice", this.specialPriceDiff);
|
||||
nbttagcompound.putInt("demand", this.demand);
|
||||
+ nbttagcompound.putBoolean("Paper.IgnoreDiscounts", this.ignoreDiscounts); // Paper
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
|
||||
index 07462b77107541aed2e29d04da33831ac113b450..0f038f6152c90e707cb633dffcab0a1c5b99d260 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantRecipe.java
|
||||
@@ -18,11 +18,19 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
||||
}
|
||||
|
||||
public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier) {
|
||||
- this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0);
|
||||
+ // Paper start - add ignoreDiscounts param
|
||||
+ this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0, false);
|
||||
+ }
|
||||
+ public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier, boolean ignoreDiscounts) {
|
||||
+ this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0, ignoreDiscounts);
|
||||
}
|
||||
|
||||
public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier, int demand, int specialPrice) {
|
||||
- super(result, uses, maxUses, experienceReward, experience, priceMultiplier, demand, specialPrice);
|
||||
+ this(result, uses, maxUses, experienceReward, experience, priceMultiplier, demand, specialPrice, false);
|
||||
+ }
|
||||
+ public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier, int demand, int specialPrice, boolean ignoreDiscounts) {
|
||||
+ super(result, uses, maxUses, experienceReward, experience, priceMultiplier, demand, specialPrice, ignoreDiscounts);
|
||||
+ // Paper end
|
||||
this.handle = new net.minecraft.world.item.trading.MerchantOffer(
|
||||
net.minecraft.world.item.ItemStack.EMPTY,
|
||||
net.minecraft.world.item.ItemStack.EMPTY,
|
||||
@@ -32,6 +40,7 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
||||
experience,
|
||||
priceMultiplier,
|
||||
demand,
|
||||
+ ignoreDiscounts, // Paper - add ignoreDiscounts param
|
||||
this
|
||||
);
|
||||
this.setSpecialPrice(specialPrice);
|
||||
@@ -108,6 +117,18 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
||||
handle.priceMultiplier = priceMultiplier;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean shouldIgnoreDiscounts() {
|
||||
+ return this.handle.ignoreDiscounts;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setIgnoreDiscounts(boolean ignoreDiscounts) {
|
||||
+ this.handle.ignoreDiscounts = ignoreDiscounts;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public net.minecraft.world.item.trading.MerchantOffer toMinecraft() {
|
||||
List<ItemStack> ingredients = getIngredients();
|
||||
Preconditions.checkState(!ingredients.isEmpty(), "No offered ingredients");
|
||||
@@ -122,7 +143,7 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
||||
if (recipe instanceof CraftMerchantRecipe) {
|
||||
return (CraftMerchantRecipe) recipe;
|
||||
} else {
|
||||
- CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward(), recipe.getVillagerExperience(), recipe.getPriceMultiplier());
|
||||
+ CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward(), recipe.getVillagerExperience(), recipe.getPriceMultiplier(), recipe.shouldIgnoreDiscounts()); // Paper - shouldIgnoreDiscounts
|
||||
craft.setIngredients(recipe.getIngredients());
|
||||
|
||||
return craft;
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Wed, 30 Sep 2020 22:49:14 +0200
|
||||
Subject: [PATCH] Toggle for removing existing dragon
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
index f32906729baf83d8b53d64ab750cddcc413a2927..3e1e8b42f963fab17e416760b93e7c1c0a9a7f45 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
@@ -217,7 +217,7 @@ public class EndDragonFight {
|
||||
this.dragonUUID = enderDragon.getUUID();
|
||||
LOGGER.info("Found that there's a dragon still alive ({})", (Object)enderDragon);
|
||||
this.dragonKilled = false;
|
||||
- if (!bl) {
|
||||
+ if (!bl && this.level.paperConfig().entities.behavior.shouldRemoveDragon) {
|
||||
LOGGER.info("But we didn't have a portal, let's remove it.");
|
||||
enderDragon.discard();
|
||||
this.dragonUUID = null;
|
|
@ -1,35 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Sat, 31 Oct 2020 11:49:01 -0700
|
||||
Subject: [PATCH] Fix client lag on advancement loading
|
||||
|
||||
When new advancements are added via the UnsafeValues#loadAdvancement
|
||||
API, it triggers a full datapack reload when this is not necessary. The
|
||||
advancement is already loaded directly into the advancement registry,
|
||||
and the point of saving the advancement to the Bukkit datapack seems to
|
||||
be for persistence. By removing the call to reload datapacks when an
|
||||
advancement is loaded, the client no longer completely freezes up when
|
||||
adding a new advancement.
|
||||
To ensure the client still receives the updated advancement data, we
|
||||
manually reload the advancement data for all players, which
|
||||
normally takes place as a part of the datapack reloading.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index 7de4cf40d96caba35b43b6b4ac4daa1bf28ef27f..4192a6eff940bfe7823f100d4156f5c4d82d994c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -340,7 +340,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Error saving advancement " + key, ex);
|
||||
}
|
||||
|
||||
- MinecraftServer.getServer().getPlayerList().reloadResources();
|
||||
+ // Paper start
|
||||
+ //MinecraftServer.getServer().getPlayerList().reload();
|
||||
+ MinecraftServer.getServer().getPlayerList().getPlayers().forEach(player -> {
|
||||
+ player.getAdvancements().reload(MinecraftServer.getServer().getAdvancements());
|
||||
+ player.getAdvancements().flushDirty(player);
|
||||
+ });
|
||||
+ // Paper end
|
||||
|
||||
return bukkit;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alfie Smith <alfie@alfiesmith.net>
|
||||
Date: Sat, 7 Nov 2020 01:20:33 +0000
|
||||
Subject: [PATCH] Item no age & no player pickup
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
index 30c954efba587d69ff55df509339f03e7d5a476e..1d90219c3a0e86786a9497d4c078c2d4077ab6cd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
@@ -10,6 +10,12 @@ import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CraftItem extends CraftEntity implements Item {
|
||||
+
|
||||
+ // Paper start
|
||||
+ private final static int NO_AGE_TIME = (int) Short.MIN_VALUE;
|
||||
+ private final static int NO_PICKUP_TIME = (int) Short.MAX_VALUE;
|
||||
+ // Paper end
|
||||
+
|
||||
private final ItemEntity item;
|
||||
|
||||
public CraftItem(CraftServer server, Entity entity, ItemEntity item) {
|
||||
@@ -76,6 +82,26 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
public void setCanMobPickup(boolean canMobPickup) {
|
||||
item.canMobPickup = canMobPickup;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean canPlayerPickup() {
|
||||
+ return item.pickupDelay != NO_PICKUP_TIME;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCanPlayerPickup(boolean canPlayerPickup) {
|
||||
+ item.pickupDelay = canPlayerPickup ? 0 : NO_PICKUP_TIME;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean willAge() {
|
||||
+ return item.age != NO_AGE_TIME;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setWillAge(boolean willAge) {
|
||||
+ item.age = willAge ? 0 : NO_AGE_TIME;
|
||||
+ }
|
||||
// Paper End
|
||||
|
||||
@Override
|
|
@ -1,135 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 4 Aug 2020 22:24:15 +0200
|
||||
Subject: [PATCH] Optimize Pathfinder - Remove Streams / Optimized collections
|
||||
|
||||
1.17 Update: Please do this k thx bb
|
||||
I utilized the IDE to convert streams to non streams code, so shouldn't
|
||||
be any risk of behavior change. Only did minor optimization of the
|
||||
generated code set to remove unnecessary things.
|
||||
|
||||
I expect us to just drop this patch on next major update and re-apply
|
||||
it with the IDE again and re-apply the collections optimization.
|
||||
|
||||
Optimize collection by creating a list instead of a set of the key and value.
|
||||
|
||||
This lets us get faster foreach iteration, as well as avoids map lookups on
|
||||
the values when needed.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
index 300c812d513e0b948a7e79c0ed241f514c7a09fc..d23481453717f715124156b5d83f6448f720d049 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
|
||||
@@ -38,9 +38,12 @@ public class PathFinder {
|
||||
if (node == null) {
|
||||
return null;
|
||||
} else {
|
||||
- Map<Target, BlockPos> map = positions.stream().collect(Collectors.toMap((pos) -> {
|
||||
- return this.nodeEvaluator.getGoal((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
|
||||
- }, Function.identity()));
|
||||
+ // Paper start - remove streams - and optimize collection
|
||||
+ List<Map.Entry<Target, BlockPos>> map = Lists.newArrayList();
|
||||
+ for (BlockPos pos : positions) {
|
||||
+ map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getGoal(pos.getX(), pos.getY(), pos.getZ()), pos));
|
||||
+ }
|
||||
+ // Paper end
|
||||
Path path = this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier);
|
||||
this.nodeEvaluator.done();
|
||||
return path;
|
||||
@@ -48,18 +51,19 @@ public class PathFinder {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
- private Path findPath(ProfilerFiller profiler, Node startNode, Map<Target, BlockPos> positions, float followRange, int distance, float rangeMultiplier) {
|
||||
+ // Paper start - optimize collection
|
||||
+ private Path findPath(ProfilerFiller profiler, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
|
||||
profiler.push("find_path");
|
||||
profiler.markForCharting(MetricCategory.PATH_FINDING);
|
||||
- Set<Target> set = positions.keySet();
|
||||
+ // Set<Target> set = positions.keySet();
|
||||
startNode.g = 0.0F;
|
||||
- startNode.h = this.getBestH(startNode, set);
|
||||
+ startNode.h = this.getBestH(startNode, positions); // Paper - optimize collection
|
||||
startNode.f = startNode.h;
|
||||
this.openSet.clear();
|
||||
this.openSet.insert(startNode);
|
||||
- Set<Node> set2 = ImmutableSet.of();
|
||||
+ // Set<Node> set2 = ImmutableSet.of(); // Paper - unused - diff on change
|
||||
int i = 0;
|
||||
- Set<Target> set3 = Sets.newHashSetWithExpectedSize(set.size());
|
||||
+ List<Map.Entry<Target, BlockPos>> entryList = Lists.newArrayListWithExpectedSize(positions.size()); // Paper - optimize collection
|
||||
int j = (int)((float)this.maxVisitedNodes * rangeMultiplier);
|
||||
|
||||
while(!this.openSet.isEmpty()) {
|
||||
@@ -71,14 +75,18 @@ public class PathFinder {
|
||||
Node node = this.openSet.pop();
|
||||
node.closed = true;
|
||||
|
||||
- for(Target target : set) {
|
||||
+ // Paper start - optimize collection
|
||||
+ for(int i1 = 0; i1 < positions.size(); i1++) {
|
||||
+ final Map.Entry<Target, BlockPos> entry = positions.get(i1);
|
||||
+ Target target = entry.getKey();
|
||||
if (node.distanceManhattan(target) <= (float)distance) {
|
||||
target.setReached();
|
||||
- set3.add(target);
|
||||
+ entryList.add(entry);
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
||||
- if (!set3.isEmpty()) {
|
||||
+ if (!entryList.isEmpty()) { // Paper - rename variable
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -93,7 +101,7 @@ public class PathFinder {
|
||||
if (node2.walkedDistance < followRange && (!node2.inOpenSet() || g < node2.g)) {
|
||||
node2.cameFrom = node;
|
||||
node2.g = g;
|
||||
- node2.h = this.getBestH(node2, set) * 1.5F;
|
||||
+ node2.h = this.getBestH(node2, positions) * 1.5F; // Paper - list instead of set
|
||||
if (node2.inOpenSet()) {
|
||||
this.openSet.changeCost(node2, node2.g + node2.h);
|
||||
} else {
|
||||
@@ -105,23 +113,31 @@ public class PathFinder {
|
||||
}
|
||||
}
|
||||
|
||||
- Optional<Path> optional = !set3.isEmpty() ? set3.stream().map((node) -> {
|
||||
- return this.reconstructPath(node.getBestNode(), positions.get(node), true);
|
||||
- }).min(Comparator.comparingInt(Path::getNodeCount)) : set.stream().map((target) -> {
|
||||
- return this.reconstructPath(target.getBestNode(), positions.get(target), false);
|
||||
- }).min(Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount));
|
||||
- profiler.pop();
|
||||
- return !optional.isPresent() ? null : optional.get();
|
||||
+ // Paper start - remove streams - and optimize collection
|
||||
+ Path best = null;
|
||||
+ boolean entryListIsEmpty = entryList.isEmpty();
|
||||
+ Comparator<Path> comparator = entryListIsEmpty ? Comparator.comparingInt(Path::getNodeCount)
|
||||
+ : Comparator.comparingDouble(Path::getDistToTarget).thenComparingInt(Path::getNodeCount);
|
||||
+ for (Map.Entry<Target, BlockPos> entry : entryListIsEmpty ? positions : entryList) {
|
||||
+ Path path = this.reconstructPath(entry.getKey().getBestNode(), entry.getValue(), !entryListIsEmpty);
|
||||
+ if (best == null || comparator.compare(path, best) < 0)
|
||||
+ best = path;
|
||||
+ }
|
||||
+ return best;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
protected float distance(Node a, Node b) {
|
||||
return a.distanceTo(b);
|
||||
}
|
||||
|
||||
- private float getBestH(Node node, Set<Target> targets) {
|
||||
+ private float getBestH(Node node, List<Map.Entry<Target, BlockPos>> targets) { // Paper - optimize collection - Set<Target> -> List<Map.Entry<Target, BlockPos>>
|
||||
float f = Float.MAX_VALUE;
|
||||
|
||||
- for(Target target : targets) {
|
||||
+ // Paper start - optimize collection
|
||||
+ for (int i = 0, targetsSize = targets.size(); i < targetsSize; i++) {
|
||||
+ final Target target = targets.get(i).getKey();
|
||||
+ // Paper end
|
||||
float g = node.distanceTo(target);
|
||||
target.updateBest(g, node);
|
||||
f = Math.min(g, f);
|
|
@ -1,131 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 24 Jun 2020 12:39:08 -0600
|
||||
Subject: [PATCH] Beacon API - custom effect ranges
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
index 349b89dd4d34b92d1077ddadb30c36642fd85622..812d21393ed2ed0623b7445585f1b0b3dcefb55d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
@@ -76,6 +76,26 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
return (BeaconBlockEntity.hasSecondaryEffect(this.levels, this.primaryPower, this.secondaryPower)) ? CraftPotionUtil.toBukkit(new MobEffectInstance(this.secondaryPower, BeaconBlockEntity.getLevel(this.levels), BeaconBlockEntity.getAmplification(this.levels, this.primaryPower, this.secondaryPower), true, true)) : null;
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Paper start - add field/methods for custom range
|
||||
+ private final String PAPER_RANGE_TAG = "Paper.Range";
|
||||
+ private double effectRange = -1;
|
||||
+
|
||||
+ public double getEffectRange() {
|
||||
+ if (this.effectRange < 0) {
|
||||
+ return this.levels * 10 + 10;
|
||||
+ } else {
|
||||
+ return effectRange;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void setEffectRange(double range) {
|
||||
+ this.effectRange = range;
|
||||
+ }
|
||||
+
|
||||
+ public void resetEffectRange() {
|
||||
+ this.effectRange = -1;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public BeaconBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityType.BEACON, pos, state);
|
||||
@@ -186,7 +206,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
}
|
||||
|
||||
if (blockEntity.levels > 0 && !blockEntity.beamSections.isEmpty()) {
|
||||
- BeaconBlockEntity.applyEffects(world, pos, blockEntity.levels, blockEntity.primaryPower, blockEntity.secondaryPower);
|
||||
+ BeaconBlockEntity.applyEffects(world, pos, blockEntity.levels, blockEntity.primaryPower, blockEntity.secondaryPower, blockEntity); // Paper
|
||||
BeaconBlockEntity.playSound(world, pos, SoundEvents.BEACON_AMBIENT);
|
||||
}
|
||||
}
|
||||
@@ -272,8 +292,13 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
}
|
||||
|
||||
public static List getHumansInRange(Level world, BlockPos blockposition, int i) {
|
||||
+ // Paper start
|
||||
+ return BeaconBlockEntity.getHumansInRange(world, blockposition, i, null);
|
||||
+ }
|
||||
+ public static List getHumansInRange(Level world, BlockPos blockposition, int i, @Nullable BeaconBlockEntity blockEntity) {
|
||||
+ // Paper end
|
||||
{
|
||||
- double d0 = (double) (i * 10 + 10);
|
||||
+ double d0 = blockEntity != null ? blockEntity.getEffectRange() : (i * 10 + 10);// Paper - custom beacon ranges
|
||||
|
||||
AABB axisalignedbb = (new AABB(blockposition)).inflate(d0).expandTowards(0.0D, (double) world.getHeight(), 0.0D);
|
||||
List<Player> list = world.getEntitiesOfClass(Player.class, axisalignedbb);
|
||||
@@ -314,12 +339,17 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
}
|
||||
|
||||
private static void applyEffects(Level world, BlockPos pos, int beaconLevel, @Nullable MobEffect primaryEffect, @Nullable MobEffect secondaryEffect) {
|
||||
+ // Paper start
|
||||
+ BeaconBlockEntity.applyEffects(world, pos, beaconLevel, primaryEffect, secondaryEffect, null);
|
||||
+ }
|
||||
+ private static void applyEffects(Level world, BlockPos pos, int beaconLevel, @Nullable MobEffect primaryEffect, @Nullable MobEffect secondaryEffect, @Nullable BeaconBlockEntity blockEntity) {
|
||||
+ // Paper end
|
||||
if (!world.isClientSide && primaryEffect != null) {
|
||||
double d0 = (double) (beaconLevel * 10 + 10);
|
||||
byte b0 = BeaconBlockEntity.getAmplification(beaconLevel, primaryEffect, secondaryEffect);
|
||||
|
||||
int j = BeaconBlockEntity.getLevel(beaconLevel);
|
||||
- List list = BeaconBlockEntity.getHumansInRange(world, pos, beaconLevel);
|
||||
+ List list = BeaconBlockEntity.getHumansInRange(world, pos, beaconLevel, blockEntity); // Paper
|
||||
|
||||
BeaconBlockEntity.applyEffect(list, primaryEffect, j, b0, true, pos); // Paper - BeaconEffectEvent
|
||||
|
||||
@@ -369,6 +399,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
}
|
||||
|
||||
this.lockKey = LockCode.fromTag(nbt);
|
||||
+ this.effectRange = nbt.contains(PAPER_RANGE_TAG, 6) ? nbt.getDouble(PAPER_RANGE_TAG) : -1; // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -382,6 +413,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
}
|
||||
|
||||
this.lockKey.addToTag(nbt);
|
||||
+ nbt.putDouble(PAPER_RANGE_TAG, this.effectRange); // Paper
|
||||
}
|
||||
|
||||
public void setCustomName(@Nullable Component customName) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
||||
index c186a44b927188ed222f8b2f8f76aaef35d9c654..c47e613cae3d9252a8364ccc4d717e410bb0fc0c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeacon.java
|
||||
@@ -29,7 +29,7 @@ public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implem
|
||||
if (tileEntity instanceof BeaconBlockEntity) {
|
||||
BeaconBlockEntity beacon = (BeaconBlockEntity) tileEntity;
|
||||
|
||||
- Collection<Player> nms = BeaconBlockEntity.getHumansInRange(beacon.getLevel(), beacon.getBlockPos(), beacon.levels);
|
||||
+ Collection<Player> nms = BeaconBlockEntity.getHumansInRange(beacon.getLevel(), beacon.getBlockPos(), beacon.levels, beacon); // Paper
|
||||
Collection<LivingEntity> bukkit = new ArrayList<LivingEntity>(nms.size());
|
||||
|
||||
for (Player human : nms) {
|
||||
@@ -106,4 +106,21 @@ public class CraftBeacon extends CraftBlockEntityState<BeaconBlockEntity> implem
|
||||
public void setLock(String key) {
|
||||
this.getSnapshot().lockKey = (key == null) ? LockCode.NO_LOCK : new LockCode(key);
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public double getEffectRange() {
|
||||
+ return this.getSnapshot().getEffectRange();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setEffectRange(double range) {
|
||||
+ this.getSnapshot().setEffectRange(range);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void resetEffectRange() {
|
||||
+ this.getSnapshot().resetEffectRange();
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Sat, 14 Nov 2020 16:19:52 +0100
|
||||
Subject: [PATCH] Add API for quit reason
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
||||
index ddde8f9f53f352c806166354e6a445543ecc2fbf..91556b52edaa1d5c4dc73a825c77b9a66b002c61 100644
|
||||
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||
+++ b/src/main/java/net/minecraft/network/Connection.java
|
||||
@@ -151,12 +151,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
|
||||
this.handlingFault = true;
|
||||
if (this.channel.isOpen()) {
|
||||
+ net.minecraft.server.level.ServerPlayer player = this.getPlayer(); // Paper
|
||||
if (throwable instanceof TimeoutException) {
|
||||
Connection.LOGGER.debug("Timeout", throwable);
|
||||
+ if (player != null) player.quitReason = org.bukkit.event.player.PlayerQuitEvent.QuitReason.TIMED_OUT; // Paper
|
||||
this.disconnect(Component.translatable("disconnect.timeout"));
|
||||
} else {
|
||||
MutableComponent ichatmutablecomponent = Component.translatable("disconnect.genericReason", "Internal Exception: " + throwable);
|
||||
|
||||
+ if (player != null) player.quitReason = org.bukkit.event.player.PlayerQuitEvent.QuitReason.ERRONEOUS_STATE; // Paper
|
||||
if (flag) {
|
||||
Connection.LOGGER.debug("Failed to sent packet", throwable);
|
||||
ConnectionProtocol enumprotocol = this.getCurrentProtocol();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 059e4f221f4e509bbdf2b5034890af49f5415d5b..c9bb90854af9881f044c1968d116368957cc1d7d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -265,6 +265,7 @@ public class ServerPlayer extends Player {
|
||||
|
||||
public double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks
|
||||
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
|
||||
+ public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event
|
||||
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, @Nullable ProfilePublicKey publicKey) {
|
||||
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile, publicKey);
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index f1a41a931b22f88f0dd530fb559b1c2ed839527a..2687823d07df2c4b57cb684000621c69c1cfd10d 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -469,6 +469,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
final Component ichatbasecomponent = PaperAdventure.asVanilla(event.reason()); // Paper - Adventure
|
||||
// CraftBukkit end
|
||||
|
||||
+ this.player.quitReason = org.bukkit.event.player.PlayerQuitEvent.QuitReason.KICKED; // Paper
|
||||
this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), (future) -> {
|
||||
this.connection.disconnect(ichatbasecomponent);
|
||||
});
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 869fa7c3913185c3537185426e75c076fbbdb7fe..0dad9a0c98cc128d990d9bd2357895d9a07a0ac7 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -600,7 +600,7 @@ public abstract class PlayerList {
|
||||
entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper
|
||||
}
|
||||
|
||||
- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName())));
|
||||
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName())), entityplayer.quitReason); // Paper - quit reason
|
||||
if (entityplayer.didPlayerJoinEvent) this.cserver.getPluginManager().callEvent(playerQuitEvent); // Paper - if we disconnected before join ever fired, don't fire quit
|
||||
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Thu, 20 Aug 2020 11:20:12 -0700
|
||||
Subject: [PATCH] Add Wandering Trader spawn rate config options
|
||||
|
||||
Adds config options for modifying the spawn rates of Wandering Traders.
|
||||
These values are all easy to understand and configure after a quick read of this
|
||||
page on the Minecraft wiki: https://minecraft.gamepedia.com/Wandering_Trader#Spawning
|
||||
Usages of the vanilla WanderingTraderSpawnDelay and WanderingTraderSpawnChance values
|
||||
in IWorldServerData are removed as they were only used in certain places, with hardcoded
|
||||
values used in other places.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
|
||||
index 0130c5e7e1b42024f88c6d7dadd246b7744d7f91..fcde09e155727fe0b8b6acc79700fe4122fd22f0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
|
||||
@@ -43,43 +43,53 @@ public class WanderingTraderSpawner implements CustomSpawner {
|
||||
|
||||
public WanderingTraderSpawner(ServerLevelData properties) {
|
||||
this.serverLevelData = properties;
|
||||
- this.tickDelay = 1200;
|
||||
- this.spawnDelay = properties.getWanderingTraderSpawnDelay();
|
||||
- this.spawnChance = properties.getWanderingTraderSpawnChance();
|
||||
- if (this.spawnDelay == 0 && this.spawnChance == 0) {
|
||||
- this.spawnDelay = 24000;
|
||||
- properties.setWanderingTraderSpawnDelay(this.spawnDelay);
|
||||
- this.spawnChance = 25;
|
||||
- properties.setWanderingTraderSpawnChance(this.spawnChance);
|
||||
- }
|
||||
+ // Paper start
|
||||
+ this.tickDelay = Integer.MIN_VALUE;
|
||||
+ //this.spawnDelay = properties.getWanderingTraderSpawnDelay(); // Paper - This value is read from the world file only for the first spawn, after which vanilla uses a hardcoded value
|
||||
+ //this.spawnChance = properties.getWanderingTraderSpawnChance(); // Paper - This value is read from the world file only for the first spawn, after which vanilla uses a hardcoded value
|
||||
+ //if (this.spawnDelay == 0 && this.spawnChance == 0) {
|
||||
+ // this.spawnDelay = 24000;
|
||||
+ // properties.setWanderingTraderSpawnDelay(this.spawnDelay);
|
||||
+ // this.spawnChance = 25;
|
||||
+ // properties.setWanderingTraderSpawnChance(this.spawnChance);
|
||||
+ //}
|
||||
+ // Paper end
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tick(ServerLevel world, boolean spawnMonsters, boolean spawnAnimals) {
|
||||
+ // Paper start
|
||||
+ if (this.tickDelay == Integer.MIN_VALUE) {
|
||||
+ this.tickDelay = world.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength;
|
||||
+ this.spawnDelay = world.paperConfig().entities.spawning.wanderingTrader.spawnDayLength;
|
||||
+ this.spawnChance = world.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin;
|
||||
+ }
|
||||
if (!world.getGameRules().getBoolean(GameRules.RULE_DO_TRADER_SPAWNING)) {
|
||||
return 0;
|
||||
- } else if (--this.tickDelay > 0) {
|
||||
+ } else if (this.tickDelay - 1 > 0) {
|
||||
+ this.tickDelay = this.tickDelay - 1;
|
||||
return 0;
|
||||
} else {
|
||||
- this.tickDelay = 1200;
|
||||
- this.spawnDelay -= 1200;
|
||||
- this.serverLevelData.setWanderingTraderSpawnDelay(this.spawnDelay);
|
||||
+ this.tickDelay = world.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength;
|
||||
+ this.spawnDelay = this.spawnDelay - world.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength;
|
||||
+ //this.serverLevelData.setWanderingTraderSpawnDelay(this.spawnDelay); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways
|
||||
if (this.spawnDelay > 0) {
|
||||
return 0;
|
||||
} else {
|
||||
- this.spawnDelay = 24000;
|
||||
+ this.spawnDelay = world.paperConfig().entities.spawning.wanderingTrader.spawnDayLength;
|
||||
if (!world.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
|
||||
return 0;
|
||||
} else {
|
||||
int i = this.spawnChance;
|
||||
|
||||
- this.spawnChance = Mth.clamp(this.spawnChance + 25, (int) 25, (int) 75);
|
||||
- this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance);
|
||||
+ this.spawnChance = Mth.clamp(i + world.paperConfig().entities.spawning.wanderingTrader.spawnChanceFailureIncrement, world.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin, world.paperConfig().entities.spawning.wanderingTrader.spawnChanceMax);
|
||||
+ //this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways
|
||||
if (this.random.nextInt(100) > i) {
|
||||
return 0;
|
||||
} else if (this.spawn(world)) {
|
||||
- this.spawnChance = 25;
|
||||
+ this.spawnChance = world.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin;
|
||||
+ // Paper end
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
|
||||
Date: Tue, 17 Nov 2020 19:13:09 +0200
|
||||
Subject: [PATCH] Expose world spawn angle
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 0dad9a0c98cc128d990d9bd2357895d9a07a0ac7..75c713f7afd8c4fd5fffada7397b102751eb6423 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -878,7 +878,7 @@ public abstract class PlayerList {
|
||||
if (location == null) {
|
||||
worldserver1 = this.server.getLevel(Level.OVERWORLD);
|
||||
blockposition = entityplayer1.getSpawnPoint(worldserver1);
|
||||
- location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
|
||||
+ location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F), worldserver1.levelData.getSpawnAngle(), 0.0F); // Paper - use world spawn angle
|
||||
}
|
||||
|
||||
Player respawnPlayer = entityplayer1.getBukkitEntity();
|
|
@ -1,38 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ineusia <ineusia@yahoo.com>
|
||||
Date: Mon, 26 Oct 2020 11:48:06 -0500
|
||||
Subject: [PATCH] Add Destroy Speed API
|
||||
|
||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index 2c1efaecf220588d8b74946194bf340871e57004..653dcec33f83ab490af424faa6ede7df07d41742 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -678,5 +678,26 @@ public class CraftBlock implements Block {
|
||||
public String translationKey() {
|
||||
return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this);
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public float getDestroySpeed(ItemStack itemStack, boolean considerEnchants) {
|
||||
+ net.minecraft.world.item.ItemStack nmsItemStack;
|
||||
+ if (itemStack instanceof CraftItemStack) {
|
||||
+ nmsItemStack = ((CraftItemStack) itemStack).handle;
|
||||
+ if (nmsItemStack == null) {
|
||||
+ nmsItemStack = net.minecraft.world.item.ItemStack.EMPTY;
|
||||
+ }
|
||||
+ } else {
|
||||
+ nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
|
||||
+ }
|
||||
+ float speed = nmsItemStack.getDestroySpeed(this.getNMS().getBlock().defaultBlockState());
|
||||
+ if (speed > 1.0F && considerEnchants) {
|
||||
+ int enchantLevel = net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.BLOCK_EFFICIENCY, nmsItemStack);
|
||||
+ if (enchantLevel > 0) {
|
||||
+ speed += enchantLevel * enchantLevel + 1;
|
||||
+ }
|
||||
+ }
|
||||
+ return speed;
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Esophose <esophose@gmail.com>
|
||||
Date: Sat, 3 Oct 2020 18:57:47 -0600
|
||||
Subject: [PATCH] Fix Player spawnParticle x/y/z precision loss
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index c94a7ccb3d5420dc0c8493d5cb0381a47ea8f9a0..39e0f1398e6f09ce7b0a4f1c9b677dca10a32c3f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2261,7 +2261,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (data != null && !particle.getDataType().isInstance(data)) {
|
||||
throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());
|
||||
}
|
||||
- ClientboundLevelParticlesPacket packetplayoutworldparticles = new ClientboundLevelParticlesPacket(CraftParticle.toNMS(particle, data), true, (float) x, (float) y, (float) z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count);
|
||||
+ ClientboundLevelParticlesPacket packetplayoutworldparticles = new ClientboundLevelParticlesPacket(CraftParticle.toNMS(particle, data), true, x, y, z, (float) offsetX, (float) offsetY, (float) offsetZ, (float) extra, count); // Paper - Fix x/y/z coordinate precision loss
|
||||
this.getHandle().connection.send(packetplayoutworldparticles);
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Anrza <andrzejrzeczycki314@gmail.com>
|
||||
Date: Wed, 15 Jul 2020 12:08:49 +0200
|
||||
Subject: [PATCH] Add LivingEntity#clearActiveItem
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 537d1a6dcf8add34e8dac8aee2fa50c50ce7e5d0..24ffc967391c9ba175f41396a90007ecdc32f55c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -805,6 +805,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
return getHandle().getUseItem().asBukkitMirror();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void clearActiveItem() {
|
||||
+ getHandle().stopUsingItem();
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public int getItemUseRemainingTime() {
|
||||
return getHandle().getUseItemRemainingTicks();
|
|
@ -1,27 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Nassim Jahnke <jahnke.nassim@gmail.com>
|
||||
Date: Tue, 25 Aug 2020 13:48:33 +0200
|
||||
Subject: [PATCH] Add PlayerItemCooldownEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java b/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
|
||||
index 47283d2a49209839002212e663a503a82ea86587..ce026600b3b5c846d991a0dfe599708caf2a2962 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ServerItemCooldowns.java
|
||||
@@ -10,6 +10,16 @@ public class ServerItemCooldowns extends ItemCooldowns {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void addCooldown(Item item, int duration) {
|
||||
+ io.papermc.paper.event.player.PlayerItemCooldownEvent event = new io.papermc.paper.event.player.PlayerItemCooldownEvent(this.player.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), duration);
|
||||
+ if (event.callEvent()) {
|
||||
+ super.addCooldown(item, event.getCooldown());
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
protected void onCooldownStarted(Item item, int duration) {
|
||||
super.onCooldownStarted(item, duration);
|
|
@ -1,63 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: SuperCoder7979 <25208576+SuperCoder7979@users.noreply.github.com>
|
||||
Date: Tue, 3 Nov 2020 23:48:05 -0600
|
||||
Subject: [PATCH] Significantly improve performance of the end generation
|
||||
|
||||
This patch implements a noise cache for the end which significantly reduces the computation time of generation. This results in about a 3x improvement.
|
||||
|
||||
Original code by SuperCoder7979 and Gegy in Lithium, licensed under LGPL-3.0 (Source: https://github.com/jellysquid3/lithium-fabric)
|
||||
|
||||
Co-authored-by: Gegy <gegy1000@gmail.com>
|
||||
Co-authored-by: Dylan Xaldin <Puremin0rez515@gmail.com>
|
||||
Co-authored-by: pop4959 <pop4959@gmail.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java b/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
index 6825feea42667a0f14c4c730e5f1ac970c654c56..1d00c019eb976de22be6e5e1f3632ca0c00d77ea 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
@@ -489,6 +489,16 @@ public final class DensityFunctions {
|
||||
public static final KeyDispatchDataCodec<DensityFunctions.EndIslandDensityFunction> CODEC = KeyDispatchDataCodec.of(MapCodec.unit(new DensityFunctions.EndIslandDensityFunction(0L)));
|
||||
private static final float ISLAND_THRESHOLD = -0.9F;
|
||||
private final SimplexNoise islandNoise;
|
||||
+ // Paper start
|
||||
+ private static final class NoiseCache {
|
||||
+ public long[] keys = new long[8192];
|
||||
+ public float[] values = new float[8192];
|
||||
+ public NoiseCache() {
|
||||
+ java.util.Arrays.fill(keys, Long.MIN_VALUE);
|
||||
+ }
|
||||
+ }
|
||||
+ private static final ThreadLocal<java.util.Map<SimplexNoise, NoiseCache>> noiseCache = ThreadLocal.withInitial(java.util.WeakHashMap::new);
|
||||
+ // Paper end
|
||||
|
||||
public EndIslandDensityFunction(long seed) {
|
||||
RandomSource randomSource = new LegacyRandomSource(seed);
|
||||
@@ -504,12 +514,26 @@ public final class DensityFunctions {
|
||||
float f = 100.0F - Mth.sqrt((long) i * (long) i + (long) j * (long) j) * 8.0F; // Paper - cast ints to long to avoid integer overflow
|
||||
f = Mth.clamp(f, -100.0F, 80.0F);
|
||||
|
||||
+ NoiseCache cache = noiseCache.get().computeIfAbsent(simplexNoise, noiseKey -> new NoiseCache()); // Paper
|
||||
for(int o = -12; o <= 12; ++o) {
|
||||
for(int p = -12; p <= 12; ++p) {
|
||||
long q = (long)(k + o);
|
||||
long r = (long)(l + p);
|
||||
- if (q * q + r * r > 4096L && simplexNoise.getValue((double)q, (double)r) < (double)-0.9F) {
|
||||
- float g = (Mth.abs((float)q) * 3439.0F + Mth.abs((float)r) * 147.0F) % 13.0F + 9.0F;
|
||||
+ // Paper start - Significantly improve end generation performance by using a noise cache
|
||||
+ long key = net.minecraft.world.level.ChunkPos.asLong((int) q, (int) r);
|
||||
+ int index = (int) it.unimi.dsi.fastutil.HashCommon.mix(key) & 8191;
|
||||
+ float g = Float.MIN_VALUE;
|
||||
+ if (cache.keys[index] == key) {
|
||||
+ g = cache.values[index];
|
||||
+ } else {
|
||||
+ if (q * q + r * r > 4096L && simplexNoise.getValue((double)q, (double)r) < (double)-0.9F) {
|
||||
+ g = (Mth.abs((float) q) * 3439.0F + Mth.abs((float) r) * 147.0F) % 13.0F + 9.0F;
|
||||
+ }
|
||||
+ cache.keys[index] = key;
|
||||
+ cache.values[index] = g;
|
||||
+ }
|
||||
+ if (g != Float.MIN_VALUE) {
|
||||
+ // Paper end
|
||||
float h = (float)(m - o * 2);
|
||||
float s = (float)(n - p * 2);
|
||||
float t = 100.0F - Mth.sqrt(h * h + s * s) * g;
|
|
@ -1,49 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Nassim Jahnke <jahnke.nassim@gmail.com>
|
||||
Date: Sun, 26 Jul 2020 14:44:09 +0200
|
||||
Subject: [PATCH] More lightning API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java
|
||||
index f7991ff14ef9cda0327b8621bf615b49cffd7ac5..e515e819774bfb31ec03f05a5502921e66f2b0e2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java
|
||||
@@ -45,4 +45,38 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike
|
||||
return this.spigot;
|
||||
}
|
||||
// Spigot end
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public int getFlashCount() {
|
||||
+ return getHandle().flashes;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setFlashCount(int flashes) {
|
||||
+ com.google.common.base.Preconditions.checkArgument(flashes >= 0, "Flashes has to be a positive number!");
|
||||
+ getHandle().flashes = flashes;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getLifeTicks() {
|
||||
+ return getHandle().life;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLifeTicks(int lifeTicks) {
|
||||
+ getHandle().life = lifeTicks;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @org.jetbrains.annotations.Nullable org.bukkit.entity.Entity getCausingEntity() {
|
||||
+ final var cause = this.getHandle().getCause();
|
||||
+ return cause == null ? null : cause.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCausingPlayer(@org.jetbrains.annotations.Nullable org.bukkit.entity.Player causingPlayer) {
|
||||
+ this.getHandle().setCause(causingPlayer == null ? null : ((CraftPlayer) causingPlayer).getHandle());
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sun, 23 Aug 2020 20:59:00 +0200
|
||||
Subject: [PATCH] Climbing should not bypass cramming gamerule
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index c5cd18b02e5956fef6779b0b89d33b515bc9d13a..933b49da673c07e45f6cb5727598df492cf1a958 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -1837,6 +1837,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public boolean isPushable() {
|
||||
+ // Paper start
|
||||
+ return isCollidable(false);
|
||||
+ }
|
||||
+
|
||||
+ public boolean isCollidable(boolean ignoreClimbing) {
|
||||
+ // Paper end
|
||||
return false;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/EntitySelector.java b/src/main/java/net/minecraft/world/entity/EntitySelector.java
|
||||
index 22f36cd3df49160f1b6668befdd05c2268edaa49..e39965c2e50bc8ee424ea07819346e0611398e28 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntitySelector.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java
|
||||
@@ -45,11 +45,17 @@ public final class EntitySelector {
|
||||
}
|
||||
|
||||
public static Predicate<Entity> pushableBy(Entity entity) {
|
||||
+ // Paper start - ignoreClimbing param
|
||||
+ return pushable(entity, false);
|
||||
+ }
|
||||
+
|
||||
+ public static Predicate<Entity> pushable(Entity entity, boolean ignoreClimbing) {
|
||||
+ // Paper end
|
||||
Team scoreboardteambase = entity.getTeam();
|
||||
Team.CollisionRule scoreboardteambase_enumteampush = scoreboardteambase == null ? Team.CollisionRule.ALWAYS : scoreboardteambase.getCollisionRule();
|
||||
|
||||
return (Predicate) (scoreboardteambase_enumteampush == Team.CollisionRule.NEVER ? Predicates.alwaysFalse() : EntitySelector.NO_SPECTATORS.and((entity1) -> {
|
||||
- if (!entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API
|
||||
+ if (!entity1.isCollidable(ignoreClimbing) || !entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API // Paper - isCollidable
|
||||
return false;
|
||||
} else if (entity.level.isClientSide && (!(entity1 instanceof Player) || !((Player) entity1).isLocalPlayer())) {
|
||||
return false;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 289073daacc2d477e965e668c6fb4041d27e3f8c..9310770edd38107211dafb94529d0edc73889e85 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3332,7 +3332,7 @@ public abstract class LivingEntity extends Entity {
|
||||
return;
|
||||
}
|
||||
// Paper end - don't run getEntities if we're not going to use its result
|
||||
- List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushableBy(this));
|
||||
+ List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushable(this, level.paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - fix climbing bypassing cramming rule
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
// Paper - move up
|
||||
@@ -3495,9 +3495,16 @@ public abstract class LivingEntity extends Entity {
|
||||
return !this.isRemoved() && this.collides; // CraftBukkit
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
@Override
|
||||
public boolean isPushable() {
|
||||
- return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit
|
||||
+ return this.isCollidable(level.paperConfig().collisions.fixClimbingBypassingCrammingRule);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCollidable(boolean ignoreClimbing) {
|
||||
+ return this.isAlive() && !this.isSpectator() && (ignoreClimbing || !this.onClimbable()) && this.collides; // CraftBukkit
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
// CraftBukkit start - collidable API
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
index e9f6e31cd557410a4ad4ced7086c4a846f13a4f6..50d4595b81f24949011c7565c5e3fc8c26c86019 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
@@ -82,7 +82,7 @@ public class Bat extends AmbientCreature {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean isPushable() {
|
||||
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
|
||||
return false;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Parrot.java b/src/main/java/net/minecraft/world/entity/animal/Parrot.java
|
||||
index 90b98b823855037ce6efab1f478d875f225f65ed..a2977596c672a5a435f56bb20fbfb7b59882dda6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Parrot.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Parrot.java
|
||||
@@ -382,8 +382,8 @@ public class Parrot extends ShoulderRidingEntity implements FlyingAnimal {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean isPushable() {
|
||||
- return super.isPushable(); // CraftBukkit - collidable API
|
||||
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
|
||||
+ return super.isCollidable(ignoreClimbing); // CraftBukkit - collidable API // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
index 119ee27ceb873c67d1d0904da903401e216eb450..04a119e6641898454253e2478bc1b4dff181b5ee 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
@@ -243,7 +243,7 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean isPushable() {
|
||||
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
|
||||
return !this.isVehicle();
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
||||
index 808e564789d826c1778c053ab91038e3d4d81b7f..150afceb491cfd254c0f1b84800e6df14cf26676 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
||||
@@ -342,7 +342,7 @@ public class ArmorStand extends LivingEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean isPushable() {
|
||||
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
|
||||
return false;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
index 7d60f56b2e8206e8e546abdd06ea74a2ead6e75d..4984b2b3294e425247b595bcf36812728fb4cd16 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
@@ -147,7 +147,7 @@ public abstract class AbstractMinecart extends Entity {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean isPushable() {
|
||||
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
|
||||
return true;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
index 5d927b6331f3d5cb7dd34be3e7ea4443f52f9ead..8471c34d02ba5819580754f98ce8cc0b50a0b328 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
@@ -157,7 +157,7 @@ public class Boat extends Entity {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean isPushable() {
|
||||
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Mon, 16 Nov 2020 12:01:52 -0800
|
||||
Subject: [PATCH] Added missing default perms for commands
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java
|
||||
index ca30f9c590f792caa8f1b76d7219e9121d932673..0467419fc8a06c241a46216c8f8c32abeb9fbc26 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java
|
||||
@@ -25,12 +25,67 @@ public final class CommandPermissions {
|
||||
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "list", "Allows the user to list all online players", PermissionDefault.OP, commands);
|
||||
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "gamemode", "Allows the user to change the gamemode of another player", PermissionDefault.OP, commands);
|
||||
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "xp", "Allows the user to give themselves or others arbitrary values of experience", PermissionDefault.OP, commands);
|
||||
- DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "toggledownfall", "Allows the user to toggle rain on/off for a given world", PermissionDefault.OP, commands);
|
||||
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "defaultgamemode", "Allows the user to change the default gamemode of the server", PermissionDefault.OP, commands);
|
||||
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "seed", "Allows the user to view the seed of the world", PermissionDefault.OP, commands);
|
||||
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "effect", "Allows the user to add/remove effects on players", PermissionDefault.OP, commands);
|
||||
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "selector", "Allows the use of selectors", PermissionDefault.OP, commands);
|
||||
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "trigger", "Allows the use of the trigger command", PermissionDefault.TRUE, commands);
|
||||
+ // Paper start
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "attribute", "Allows the user to query, add, remove or set an entity attribute", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "advancement", "Allows the user to give, remove, or check player advancements", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "ban", "Allows the user to add players to the ban list", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "ban-ip", "Allows the user to add ip address to the ban list", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "banlist", "Allows the user to display the ban list", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "bossbar", "Allows the user to create and modify bossbars", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "clear", "Allows the user to clear items from player inventory", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "clone", "Allows the user to copy blocks from one place to another", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "data", "Allows the user to get, merge, modify, and remove block entity and entity NBT data", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "datapack", "Allows the user to control loaded data packs", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "debug", "Allows the user to start or stop a debugging session", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "deop", "Allows the user to revoke operator status from a player", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "difficulty", "Allows the user to set the difficulty level", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "enchant", "Allows the user to enchant a player item", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "execute", "Allows the user to execute another command", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "fill", "Allows the user to fill a region with a specific block", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "forceload", "Allows the user to force chunks to be constantly loaded or not", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "function", "Allows the user to run a function", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "gamerule", "Allows a user to set or query a game rule value", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "jfr", "Allows a user to use the vanilla Java FlightRecorder profiling system", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "locate", "Allows the user to locate the closest structure", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "loot", "Allows the user to drop items from an inventory slot onto the ground", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "op", "Allows the user to grant operator status to a player", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "pardon", "Allows the user to remove entries from the player ban list", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "pardon-ip", "Allows the user to remove entries from the ip address ban list", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "particle", "Allows the user to create particles", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "perf", "Allows the user to start/stop the vanilla performance metrics capture", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "playsound", "Allows the user to play a sound", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "recipe", "Allows the user to give or take recipes", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "reload", "Allows the user to reload loot tables, advancements, and functions from disk", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "item", "Allows the user to replace items in inventories", PermissionDefault.OP, commands); // Remove in 1.17 (replaced by /item)
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "save-all", "Allows the user to save the server to disk", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "save-off", "Allows the user disable automatic server saves", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "save-on", "Allows the user enable automatic server saves", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "schedule", "Allows the user to delay the execution of a function", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "scoreboard", "Allows the user manage scoreboard objectives and players", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "setblock", "Allows the user to change a block to another block", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "setidletimeout", "Allows the user to set the time before idle players are kicked", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "setworldspawn", "Allows the user to set the world spawn", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "spawnpoint", "Allows the user to set the spawn point for a player", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "spectate", "Allows the user to make one player in spectator mode spectate an entity", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "spreadplayers", "Allows the user to teleport entities to random locations", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "stopsound", "Allows the user to stop a sound", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "summon", "Allows the user to summon an entity", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "tag", "Allows the user to control entity tags", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "team", "Allows the user to control teams", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "teammsg", "Allows the user to specify the message to send to team", PermissionDefault.TRUE, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "tellraw", "Allows the user to display a JSON message to players", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "time", "Allows the user to change or query the world's game time", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "title", "Allows the user to manage screen titles", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "weather", "Allows the user to set the weather", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "whitelist", "Allows the user to manage the server whitelist", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "worldborder", "Allows the user to manage the world border", PermissionDefault.OP, commands);
|
||||
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "place", "Allows the user to place features and structures", PermissionDefault.OP, commands);
|
||||
+ // Paper end
|
||||
|
||||
DefaultPermissions.registerPermission("minecraft.admin.command_feedback", "Receive command broadcasts when sendCommandFeedback is true", PermissionDefault.OP, commands);
|
||||
|
||||
diff --git a/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java b/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..da2eb57ea64403657744ea00eff40243ef51df58
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java
|
||||
@@ -0,0 +1,86 @@
|
||||
+package io.papermc.paper.permissions;
|
||||
+
|
||||
+import com.mojang.brigadier.tree.CommandNode;
|
||||
+import com.mojang.brigadier.tree.RootCommandNode;
|
||||
+import net.minecraft.commands.CommandBuildContext;
|
||||
+import net.minecraft.commands.CommandSourceStack;
|
||||
+import net.minecraft.commands.Commands;
|
||||
+import net.minecraft.core.RegistryAccess;
|
||||
+import net.minecraft.server.Bootstrap;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
|
||||
+import org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions;
|
||||
+import org.bukkit.permissions.Permission;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
+import org.junit.AfterClass;
|
||||
+import org.junit.BeforeClass;
|
||||
+import org.junit.Test;
|
||||
+
|
||||
+import java.io.PrintStream;
|
||||
+import java.util.HashSet;
|
||||
+import java.util.LinkedHashSet;
|
||||
+import java.util.List;
|
||||
+import java.util.Set;
|
||||
+import java.util.TreeSet;
|
||||
+
|
||||
+import static org.junit.Assert.assertTrue;
|
||||
+
|
||||
+public class MinecraftCommandPermissionsTest extends AbstractTestingBase {
|
||||
+
|
||||
+ private static PrintStream old;
|
||||
+ @BeforeClass
|
||||
+ public static void before() {
|
||||
+ old = System.out;
|
||||
+ System.setOut(Bootstrap.STDOUT);
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void test() {
|
||||
+ CraftDefaultPermissions.registerCorePermissions();
|
||||
+ Set<String> perms = collectMinecraftCommandPerms();
|
||||
+
|
||||
+ Commands commands = new Commands(Commands.CommandSelection.DEDICATED, new CommandBuildContext(RegistryAccess.BUILTIN.get()));
|
||||
+ RootCommandNode<CommandSourceStack> root = commands.getDispatcher().getRoot();
|
||||
+ Set<String> missing = new LinkedHashSet<>();
|
||||
+ Set<String> foundPerms = new HashSet<>();
|
||||
+ for (CommandNode<CommandSourceStack> child : root.getChildren()) {
|
||||
+ final String vanillaPerm = VanillaCommandWrapper.getPermission(child);
|
||||
+ if (!perms.contains(vanillaPerm)) {
|
||||
+ missing.add("Missing permission for " + child.getName() + " (" + vanillaPerm + ") command");
|
||||
+ } else {
|
||||
+ foundPerms.add(vanillaPerm);
|
||||
+ }
|
||||
+ }
|
||||
+ assertTrue("Commands missing permissions: \n" + String.join("\n", missing), missing.isEmpty());
|
||||
+ perms.removeAll(foundPerms);
|
||||
+ assertTrue("Extra permissions not associated with a command: \n" + String.join("\n", perms), perms.isEmpty());
|
||||
+ }
|
||||
+
|
||||
+ private static final List<String> TO_SKIP = List.of(
|
||||
+ "minecraft.command.selector"
|
||||
+ );
|
||||
+
|
||||
+ private static Set<String> collectMinecraftCommandPerms() {
|
||||
+ Set<String> perms = new TreeSet<>();
|
||||
+ for (Permission perm : Bukkit.getPluginManager().getPermissions()) {
|
||||
+ if (perm.getName().startsWith("minecraft.command.")) {
|
||||
+ if (TO_SKIP.contains(perm.getName())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (perm.getName().endsWith(".xp")) {
|
||||
+ perms.add("minecraft.command.experience"); // for the "experience" command, craftbukkit perm is "minecraft.command.xp"
|
||||
+ continue;
|
||||
+ }
|
||||
+ perms.add(perm.getName());
|
||||
+ }
|
||||
+ }
|
||||
+ return perms;
|
||||
+ }
|
||||
+
|
||||
+ @AfterClass
|
||||
+ public static void after() {
|
||||
+ if (old != null) {
|
||||
+ System.setOut(old);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
index 946497353a64421592d2bae012c9a3cb874dd5b8..2ddceb709291d3bd713621ffa4020c02ec26bb21 100644
|
||||
--- a/src/test/java/org/bukkit/support/DummyServer.java
|
||||
+++ b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
@@ -106,7 +106,21 @@ public final class DummyServer implements InvocationHandler {
|
||||
}
|
||||
}
|
||||
);
|
||||
- Bukkit.setServer(Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(new DummyServer()));
|
||||
+ // Paper start - modeled off of TestServer in the API tests module
|
||||
+ methods.put(
|
||||
+ Server.class.getMethod("getPluginManager"),
|
||||
+ new MethodHandler() {
|
||||
+ @Override
|
||||
+ public Object handle(DummyServer server, Object[] args) {
|
||||
+ return server.pluginManager;
|
||||
+ }
|
||||
+ }
|
||||
+ );
|
||||
+ DummyServer server = new DummyServer();
|
||||
+ Server instance = Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(server);
|
||||
+ Bukkit.setServer(instance);
|
||||
+ server.pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance));
|
||||
+ // Paper end
|
||||
} catch (Throwable t) {
|
||||
throw new Error(t);
|
||||
}
|
||||
@@ -116,6 +130,7 @@ public final class DummyServer implements InvocationHandler {
|
||||
|
||||
private DummyServer() {};
|
||||
|
||||
+ private org.bukkit.plugin.PluginManager pluginManager; // Paper
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) {
|
||||
MethodHandler handler = DummyServer.methods.get(method);
|
|
@ -1,70 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: JRoy <joshroy126@gmail.com>
|
||||
Date: Thu, 27 Aug 2020 15:02:48 -0400
|
||||
Subject: [PATCH] Add PlayerShearBlockEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
|
||||
index 8dff119fa83e44d71b10bb3ea6e5f4e886a48c9c..1aaab26c59bb9255955aff34ea1d057b88152768 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
|
||||
@@ -113,7 +113,7 @@ public class BeehiveBlock extends BaseEntityBlock {
|
||||
}
|
||||
|
||||
public static void dropHoneycomb(Level world, BlockPos pos) {
|
||||
- popResource(world, pos, new ItemStack(Items.HONEYCOMB, 3));
|
||||
+ popResource(world, pos, new ItemStack(Items.HONEYCOMB, 3)); // Paper - conflict on change, item needs to be set below
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,8 +126,19 @@ public class BeehiveBlock extends BaseEntityBlock {
|
||||
Item item = itemstack.getItem();
|
||||
|
||||
if (itemstack.is(Items.SHEARS)) {
|
||||
+ // Paper start - Add PlayerShearBlockEvent
|
||||
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), net.minecraft.server.MCUtil.toBukkitBlock(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (hand == InteractionHand.OFF_HAND ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND), new java.util.ArrayList<>());
|
||||
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.HONEYCOMB, 3)));
|
||||
+ if (!event.callEvent()) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.NEUTRAL, 1.0F, 1.0F);
|
||||
- BeehiveBlock.dropHoneycomb(world, pos);
|
||||
+ // Paper start - Add PlayerShearBlockEvent
|
||||
+ for (org.bukkit.inventory.ItemStack itemDrop : event.getDrops()) {
|
||||
+ popResource(world, pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(itemDrop));
|
||||
+ }
|
||||
+ // Paper end
|
||||
itemstack.hurtAndBreak(1, player, (entityhuman1) -> {
|
||||
entityhuman1.broadcastBreakEvent(hand);
|
||||
});
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
|
||||
index 0e8cbe7a465edc31b78b7e47a928435f9c2b6bd9..f998598a34315389dd74b82e4b9c8448f0aae253 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
|
||||
@@ -27,13 +27,24 @@ public class PumpkinBlock extends StemGrownBlock {
|
||||
ItemStack itemStack = player.getItemInHand(hand);
|
||||
if (itemStack.is(Items.SHEARS)) {
|
||||
if (!world.isClientSide) {
|
||||
+ // Paper start - Add PlayerShearBlockEvent
|
||||
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), net.minecraft.server.MCUtil.toBukkitBlock(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (hand == InteractionHand.OFF_HAND ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND), new java.util.ArrayList<>());
|
||||
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.PUMPKIN_SEEDS, 4)));
|
||||
+ if (!event.callEvent()) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
Direction direction = hit.getDirection();
|
||||
Direction direction2 = direction.getAxis() == Direction.Axis.Y ? player.getDirection().getOpposite() : direction;
|
||||
world.playSound((Player)null, pos, SoundEvents.PUMPKIN_CARVE, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
world.setBlock(pos, Blocks.CARVED_PUMPKIN.defaultBlockState().setValue(CarvedPumpkinBlock.FACING, direction2), 11);
|
||||
- ItemEntity itemEntity = new ItemEntity(world, (double)pos.getX() + 0.5D + (double)direction2.getStepX() * 0.65D, (double)pos.getY() + 0.1D, (double)pos.getZ() + 0.5D + (double)direction2.getStepZ() * 0.65D, new ItemStack(Items.PUMPKIN_SEEDS, 4));
|
||||
+ // Paper start - Add PlayerShearBlockEvent
|
||||
+ for (org.bukkit.inventory.ItemStack item : event.getDrops()) {
|
||||
+ ItemEntity itemEntity = new ItemEntity(world, (double) pos.getX() + 0.5D + (double) direction2.getStepX() * 0.65D, (double) pos.getY() + 0.1D, (double) pos.getZ() + 0.5D + (double) direction2.getStepZ() * 0.65D, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item));
|
||||
+ // Paper end
|
||||
itemEntity.setDeltaMovement(0.05D * (double)direction2.getStepX() + world.random.nextDouble() * 0.02D, 0.05D, 0.05D * (double)direction2.getStepZ() + world.random.nextDouble() * 0.02D);
|
||||
world.addFreshEntity(itemEntity);
|
||||
+ } // Paper - Add PlayerShearBlockEvent
|
||||
itemStack.hurtAndBreak(1, player, (playerx) -> {
|
||||
playerx.broadcastBreakEvent(hand);
|
||||
});
|
|
@ -1,29 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <blake.galbreath@gmail.com>
|
||||
Date: Tue, 8 Dec 2020 20:14:20 -0600
|
||||
Subject: [PATCH] Fix curing zombie villager discount exploit
|
||||
|
||||
This fixes the exploit used to gain absurd trading discounts with infecting
|
||||
and curing a villager on repeat by simply resetting the relevant part of
|
||||
the reputation when it is cured.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
index 1d2b7950e3c498945a2ff85fda0e3bb30acd22cb..10b45ec24a5a0867106d1694312385ad1e267f43 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -976,6 +976,15 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
@Override
|
||||
public void onReputationEventFrom(ReputationEventType interaction, Entity entity) {
|
||||
if (interaction == ReputationEventType.ZOMBIE_VILLAGER_CURED) {
|
||||
+ // Paper start - fix MC-181190
|
||||
+ if (level.paperConfig().fixes.fixCuringZombieVillagerDiscountExploit) {
|
||||
+ final GossipContainer.EntityGossips playerReputation = this.getGossips().getReputations().get(entity.getUUID());
|
||||
+ if (playerReputation != null) {
|
||||
+ playerReputation.remove(GossipType.MAJOR_POSITIVE);
|
||||
+ playerReputation.remove(GossipType.MINOR_POSITIVE);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.gossips.add(entity.getUUID(), GossipType.MAJOR_POSITIVE, 20);
|
||||
this.gossips.add(entity.getUUID(), GossipType.MINOR_POSITIVE, 25);
|
||||
} else if (interaction == ReputationEventType.TRADE) {
|
|
@ -1,41 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sat, 12 Dec 2020 23:45:28 +0000
|
||||
Subject: [PATCH] Limit recipe packets
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 2687823d07df2c4b57cb684000621c69c1cfd10d..8254c6d3bcff79c9a718c89f8c04c2c2db035a8f 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -248,6 +248,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
// CraftBukkit start - multithreaded fields
|
||||
private final AtomicInteger chatSpamTickCount = new AtomicInteger();
|
||||
private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits
|
||||
+ private final java.util.concurrent.atomic.AtomicInteger recipeSpamPackets = new java.util.concurrent.atomic.AtomicInteger(); // Paper - auto recipe limit
|
||||
// CraftBukkit end
|
||||
private int dropSpamTickCount;
|
||||
private double firstGoodX;
|
||||
@@ -400,6 +401,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
// CraftBukkit start
|
||||
for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !this.chatSpamTickCount.compareAndSet(spam, spam - 1); ) ;
|
||||
if (tabSpamLimiter.get() > 0) tabSpamLimiter.getAndDecrement(); // Paper - split to seperate variable
|
||||
+ if (recipeSpamPackets.get() > 0) recipeSpamPackets.getAndDecrement(); // Paper
|
||||
/* Use thread-safe field access instead
|
||||
if (this.chatSpamTickCount > 0) {
|
||||
--this.chatSpamTickCount;
|
||||
@@ -3019,6 +3021,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
|
||||
@Override
|
||||
public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) {
|
||||
+ // Paper start
|
||||
+ if (!org.bukkit.Bukkit.isPrimaryThread()) {
|
||||
+ if (recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) {
|
||||
+ server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam", new Object[0]))); // Paper
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
this.player.resetLastActionTime();
|
||||
if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu instanceof RecipeBookMenu) {
|
Loading…
Add table
Add a link
Reference in a new issue