Fix a bunch of vanilla bugs

https://bugs.mojang.com/browse/MC-253721
  wrong msg for opping multiple players

https://bugs.mojang.com/browse/MC-248588
  respect mob griefing gamerule for draining water cauldrons

https://bugs.mojang.com/browse/MC-244739
  play goat eating sound for last item in stack

https://bugs.mojang.com/browse/MC-243057
  ignore furnace fuel slot in recipe book click

https://bugs.mojang.com/browse/MC-147659
  Some witch huts spawn the incorrect cat
  Note: Marked as Won't Fix, makes 0 sense

https://bugs.mojang.com/browse/MC-179072
  Creepers do not defuse when switching from Survival to Creative/Spectator

https://bugs.mojang.com/browse/MC-259571
  Fix changeGameModeForPlayer to use gameModeForPlayer

https://bugs.mojang.com/browse/MC-262422
  Fix lightning being able to hit spectators

https://bugs.mojang.com/browse/MC-263999
  Fix mobs breaking doors not spawning block break particles

https://bugs.mojang.com/browse/MC-210802
  Fixes sheep eating blocks outside of ticking range

https://bugs.mojang.com/browse/MC-123848
  Fixes item frames dropping items above when pointing down

https://bugs.mojang.com/browse/MC-174630
  Fix secondary beacon effect remaining after switching effect

https://bugs.mojang.com/browse/MC-153086
  Fix the beacon deactivation sound always playing when broken

https://bugs.mojang.com/browse/MC-200092
  Fix yaw being ignored for a player's first spawn pos

https://bugs.mojang.com/browse/MC-158900
  Fix error when joining after tempban expired

https://bugs.mojang.com/browse/MC-99075
  Fix inventory desync within spawn protected area

https://bugs.mojang.com/browse/MC-273635
  Fix TrialSpawner forgets assigned mob when placed by player

== AT ==
public net/minecraft/world/entity/Mob leashInfoTag
public net/minecraft/server/level/ChunkMap anyPlayerCloseEnoughForSpawning(Lnet/minecraft/world/level/ChunkPos;)Z

Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
This commit is contained in:
Jake Potrebic
2022-07-11 11:56:41 -07:00
parent 492ebf1459
commit 0b9ef3701e
20 changed files with 256 additions and 83 deletions

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/server/commands/DeOpCommands.java
+++ b/net/minecraft/server/commands/DeOpCommands.java
@@ -35,7 +35,7 @@
if (playerList.isOp(gameProfile)) {
playerList.deop(gameProfile);
i++;
- source.sendSuccess(() -> Component.translatable("commands.deop.success", targets.iterator().next().getName()), true);
+ source.sendSuccess(() -> Component.translatable("commands.deop.success", gameProfile.getName()), true); // Paper - fixes MC-253721
}
}

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/server/commands/OpCommand.java
+++ b/net/minecraft/server/commands/OpCommand.java
@@ -46,7 +46,7 @@
if (!playerList.isOp(gameProfile)) {
playerList.op(gameProfile);
i++;
- source.sendSuccess(() -> Component.translatable("commands.op.success", targets.iterator().next().getName()), true);
+ source.sendSuccess(() -> Component.translatable("commands.op.success", gameProfile.getName()), true); // Paper - fixes MC-253721
}
}

View File

@@ -61,7 +61,7 @@
private int lastSpawnChunkRadius;
final EntityTickList entityTickList = new EntityTickList();
public final PersistentEntitySectionManager<Entity> entityManager;
@@ -214,53 +226,203 @@
@@ -214,54 +226,204 @@
private final boolean tickTime;
private final RandomSequences randomSequences;
@@ -136,7 +136,7 @@
+
+ int minChunkX = minBlockX >> 4;
+ int minChunkZ = minBlockZ >> 4;
+
+ int maxChunkX = maxBlockX >> 4;
+ int maxChunkZ = maxBlockZ >> 4;
+
@@ -227,7 +227,7 @@
+ boolean flag2 = minecraftserver.forceSynchronousWrites();
+ DataFixer datafixer = minecraftserver.getFixerUpper();
+ EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver);
+
this.entityManager = new PersistentEntitySectionManager<>(Entity.class, new ServerLevel.EntityCallbacks(), entitypersistentstorage);
- StructureTemplateManager structuretemplatemanager = server.getStructureManager();
- int j = server.getPlayerList().getViewDistance();
@@ -279,16 +279,17 @@
});
+ this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
}
+
+ // Paper start
+ @Override
+ public boolean hasChunk(int chunkX, int chunkZ) {
+ return this.getChunkSource().getChunkAtIfLoadedImmediately(chunkX, chunkZ) != null;
+ }
+ // Paper end
+
/** @deprecated */
@Deprecated
@VisibleForTesting
@@ -273,8 +435,8 @@
this.serverLevelData.setClearWeatherTime(clearDuration);
this.serverLevelData.setRainTime(rainDuration);
@@ -430,7 +431,14 @@
BlockPos blockposition1 = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
Optional<BlockPos> optional = this.findLightningRod(blockposition1);
@@ -582,6 +760,7 @@
@@ -576,12 +754,13 @@
} else {
AABB axisalignedbb = AABB.encapsulatingFullBlocks(blockposition1, blockposition1.atY(this.getMaxY() + 1)).inflate(3.0D);
List<LivingEntity> list = this.getEntitiesOfClass(LivingEntity.class, axisalignedbb, (entityliving) -> {
- return entityliving != null && entityliving.isAlive() && this.canSeeSky(entityliving.blockPosition());
+ return entityliving != null && entityliving.isAlive() && this.canSeeSky(entityliving.blockPosition()) && !entityliving.isSpectator(); // Paper - Fix lightning being able to hit spectators (MC-262422)
});
if (!list.isEmpty()) {
return ((LivingEntity) list.get(this.random.nextInt(list.size()))).blockPosition();
} else {

View File

@@ -63,6 +63,7 @@
- return false;
+ return null; // Paper - Expand PlayerGameModeChangeEvent
} else {
- this.setGameModeForPlayer(gameMode, this.previousGameModeForPlayer);
+ // CraftBukkit start
+ PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this.player.getBukkitEntity(), GameMode.getByValue(gameMode.getId()), cause, cancelMessage); // Paper
+ this.level.getCraftServer().getPluginManager().callEvent(event);
@@ -70,7 +71,7 @@
+ return event; // Paper - Expand PlayerGameModeChangeEvent
+ }
+ // CraftBukkit end
this.setGameModeForPlayer(gameMode, this.previousGameModeForPlayer);
+ this.setGameModeForPlayer(gameMode, this.gameModeForPlayer); // Paper - Fix MC-259571
this.player.onUpdateAbilities();
- this.player.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player));
+ this.player.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit
@@ -134,9 +135,9 @@
+ // Update any tile entity data for this block
+ capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
+ // CraftBukkit end
+ return;
+ }
+
return;
}
+ // CraftBukkit start
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
+ if (event.isCancelled()) {
@@ -144,10 +145,10 @@
+ this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
+ // Update any tile entity data for this block
+ capturedBlockEntity = true; // Paper - Send block entities after destroy prediction
return;
}
+ return;
+ }
+ // CraftBukkit end
+
if (this.isCreative()) {
this.destroyAndAck(pos, sequence, "creative destroy");
return;

View File

@@ -48,7 +48,7 @@
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
@@ -192,11 +196,72 @@
@@ -192,12 +196,73 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
@@ -59,7 +59,7 @@
import net.minecraft.world.phys.shapes.VoxelShape;
+import org.bukkit.NamespacedKey;
import org.slf4j.Logger;
+
+// CraftBukkit start
+import io.papermc.paper.adventure.ChatProcessor; // Paper
+import io.papermc.paper.adventure.PaperAdventure; // Paper
@@ -118,9 +118,10 @@
+import org.bukkit.inventory.InventoryView;
+import org.bukkit.inventory.SmithingInventory;
+// CraftBukkit end
+
public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener {
static final Logger LOGGER = LogUtils.getLogger();
@@ -212,7 +277,9 @@
private int tickCount;
private int ackBlockChangesUpTo = -1;
@@ -323,7 +324,7 @@
boolean flag1 = entity.verticalCollisionBelow;
if (entity instanceof LivingEntity) {
@@ -449,20 +599,73 @@
@@ -449,19 +599,72 @@
d10 = d6 * d6 + d7 * d7 + d8 * d8;
boolean flag2 = false;
@@ -342,8 +343,8 @@
+ this.player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
return;
}
+ }
+
+ // CraftBukkit start - fire PlayerMoveEvent
+ Player player = this.getCraftPlayer();
+ if (!this.hasMoved) {
@@ -392,12 +393,11 @@
+ this.justTeleported = false;
+ return;
+ }
+ }
}
+ // CraftBukkit end
+
this.player.serverLevel().getChunkSource().move(this.player);
entity.recordMovementThroughBlocks(new Vec3(d0, d1, d2), entity.position());
Vec3 vec3d = new Vec3(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2);
@@ -489,16 +692,17 @@
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (packet.getId() == this.awaitingTeleport) {
@@ -1131,7 +1131,7 @@
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
if (enuminteractionresult.consumesAction()) {
@@ -1257,7 +1885,7 @@
@@ -1257,11 +1885,11 @@
} else if (enuminteractionresult instanceof InteractionResult.Success) {
InteractionResult.Success enuminteractionresult_d = (InteractionResult.Success) enuminteractionresult;
@@ -1140,6 +1140,11 @@
this.player.swing(enumhand, true);
}
}
- }
+ } else { this.player.containerMenu.sendAllDataToRemote(); } // Paper - Fix inventory desync; MC-99075
} else {
MutableComponent ichatmutablecomponent1 = Component.translatable("build.tooHigh", i).withStyle(ChatFormatting.RED);
@@ -1281,6 +1909,8 @@
@Override
public void handleUseItem(ServerboundUseItemPacket packet) {
@@ -1436,10 +1441,12 @@
}
return optional;
@@ -1566,6 +2324,127 @@
return false;
}
@@ -1564,8 +2322,129 @@
}
return false;
+ }
+
+ // CraftBukkit start - add method
+ public void chat(String s, PlayerChatMessage original, boolean async) {
+ if (s.isEmpty() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) {
@@ -1532,8 +1539,8 @@
+ this.server.console.sendMessage(s);
+ }
+ }
+ }
+
}
+ private void handleCommand(String s) {
+ org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + s); // Paper - Add async catcher
+ if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot

View File

@@ -180,7 +180,7 @@
+ }
+ if (optional.isEmpty() || invalidPlayerWorld[0]) {
+ // Paper end - reset to main world spawn if first spawn or invalid world
+ player.moveTo(player.adjustSpawnLocation(worldserver1, worldserver1.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F);
+ player.moveTo(player.adjustSpawnLocation(worldserver1, worldserver1.getSharedSpawnPos()).getBottomCenter(), worldserver1.getSharedSpawnAngle(), 0.0F); // Paper - MC-200092 - fix first spawn pos yaw being ignored
+ }
+ // Paper end - Entity#getEntitySpawnReason
player.setServerLevel(worldserver1);
@@ -391,7 +391,7 @@
if (advancementdataplayer != null) {
advancementdataplayer.save();
@@ -334,95 +519,207 @@
@@ -334,95 +519,209 @@
}
@@ -560,8 +560,10 @@
+ Player player = entity.getBukkitEntity();
+ PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress(), ((java.net.InetSocketAddress) loginlistener.connection.channel.remoteAddress()).getAddress());
+
+ if (this.bans.isBanned(gameprofile)) {
+ UserBanListEntry gameprofilebanentry = (UserBanListEntry) this.bans.get(gameprofile);
+ // Paper start - Fix MC-158900
+ UserBanListEntry gameprofilebanentry;
+ if (this.bans.isBanned(gameprofile) && (gameprofilebanentry = this.bans.get(gameprofile)) != null) {
+ // Paper end - Fix MC-158900
+
ichatmutablecomponent = Component.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
if (gameprofilebanentry.getExpires() != null) {
@@ -587,11 +589,10 @@
}
- return ichatmutablecomponent;
- } else {
- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(profile) ? Component.translatable("multiplayer.disconnect.server_full") : null;
+ // return chatmessage;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent)); // Paper - Adventure
+ } else {
} else {
- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(profile) ? Component.translatable("multiplayer.disconnect.server_full") : null;
+ // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null;
+ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure
@@ -638,7 +639,7 @@
if (entityplayer1 != null) {
set.add(entityplayer1);
@@ -431,72 +728,160 @@
@@ -431,72 +730,160 @@
Iterator iterator1 = set.iterator();
while (iterator1.hasNext()) {
@@ -820,7 +821,7 @@
return entityplayer1;
}
@@ -516,15 +901,32 @@
@@ -516,15 +903,32 @@
}
public void sendPlayerPermissionLevel(ServerPlayer player) {
@@ -855,14 +856,10 @@
this.sendAllPlayerInfoIn = 0;
}
@@ -537,9 +939,28 @@
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
@@ -541,6 +945,25 @@
}
entityplayer.connection.send(packet);
+ }
+
+ }
+
+ // CraftBukkit start - add a world/entity limited version
+ public void broadcastAll(Packet packet, net.minecraft.world.entity.player.Player entityhuman) {
+ for (int i = 0; i < this.players.size(); ++i) {
@@ -877,14 +874,15 @@
+ public void broadcastAll(Packet packet, Level world) {
+ for (int i = 0; i < world.players().size(); ++i) {
+ ((ServerPlayer) world.players().get(i)).connection.send(packet);
}
}
+ }
+
+ }
+ // CraftBukkit end
+
public void broadcastAll(Packet<?> packet, ResourceKey<Level> dimension) {
Iterator iterator = this.players.iterator();
@@ -554,7 +975,7 @@
@@ -554,7 +977,7 @@
}
@@ -893,7 +891,7 @@
PlayerTeam scoreboardteam = source.getTeam();
if (scoreboardteam != null) {
@@ -573,7 +994,7 @@
@@ -573,7 +996,7 @@
}
}
@@ -902,7 +900,7 @@
PlayerTeam scoreboardteam = source.getTeam();
if (scoreboardteam == null) {
@@ -619,7 +1040,7 @@
@@ -619,7 +1042,7 @@
}
public void deop(GameProfile profile) {
@@ -911,7 +909,7 @@
ServerPlayer entityplayer = this.getPlayer(profile.getId());
if (entityplayer != null) {
@@ -629,6 +1050,11 @@
@@ -629,6 +1052,11 @@
}
private void sendPlayerPermissionLevel(ServerPlayer player, int permissionLevel) {
@@ -923,7 +921,7 @@
if (player.connection != null) {
byte b0;
@@ -643,36 +1069,53 @@
@@ -643,36 +1071,53 @@
player.connection.send(new ClientboundEntityEventPacket(player, b0));
}
@@ -990,7 +988,7 @@
if (entityplayer != player && entityplayer.level().dimension() == worldKey) {
double d4 = x - entityplayer.getX();
double d5 = y - entityplayer.getY();
@@ -687,10 +1130,12 @@
@@ -687,10 +1132,12 @@
}
public void saveAll() {
@@ -1003,7 +1001,7 @@
}
public UserWhiteList getWhiteList() {
@@ -712,15 +1157,19 @@
@@ -712,15 +1159,19 @@
public void reloadWhiteList() {}
public void sendLevelInfo(ServerPlayer player, ServerLevel world) {
@@ -1027,7 +1025,7 @@
}
player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F));
@@ -729,8 +1178,16 @@
@@ -729,8 +1180,16 @@
public void sendAllPlayerInfo(ServerPlayer player) {
player.inventoryMenu.sendAllDataToRemote();
@@ -1045,7 +1043,7 @@
}
public int getPlayerCount() {
@@ -746,6 +1203,7 @@
@@ -746,6 +1205,7 @@
}
public void setUsingWhiteList(boolean whitelistEnabled) {
@@ -1053,7 +1051,7 @@
this.doWhiteList = whitelistEnabled;
}
@@ -786,12 +1244,36 @@
@@ -786,12 +1246,36 @@
}
public void removeAll() {
@@ -1092,7 +1090,7 @@
public void broadcastSystemMessage(Component message, boolean overlay) {
this.broadcastSystemMessage(message, (entityplayer) -> {
return message;
@@ -819,24 +1301,43 @@
@@ -819,24 +1303,43 @@
}
public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params) {
@@ -1139,7 +1137,7 @@
}
if (flag1 && sender != null) {
@@ -845,20 +1346,27 @@
@@ -845,20 +1348,27 @@
}
@@ -1172,7 +1170,7 @@
Path path = file2.toPath();
if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -867,7 +1375,7 @@
@@ -867,7 +1377,7 @@
}
serverstatisticmanager = new ServerStatsCounter(this.server, file1);
@@ -1181,7 +1179,7 @@
}
return serverstatisticmanager;
@@ -875,13 +1383,13 @@
@@ -875,13 +1385,13 @@
public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) {
UUID uuid = player.getUUID();
@@ -1197,7 +1195,7 @@
}
advancementdataplayer.setPlayer(player);
@@ -932,15 +1440,28 @@
@@ -932,15 +1442,28 @@
}
public void reloadResources() {