diff --git a/patches/api-unmapped/Add-BaseComponent-sendMessage-methods-to-CommandSend.patch b/patches/api/Add-BaseComponent-sendMessage-methods-to-CommandSend.patch similarity index 100% rename from patches/api-unmapped/Add-BaseComponent-sendMessage-methods-to-CommandSend.patch rename to patches/api/Add-BaseComponent-sendMessage-methods-to-CommandSend.patch diff --git a/patches/api-unmapped/Add-BeaconEffectEvent.patch b/patches/api/Add-BeaconEffectEvent.patch similarity index 100% rename from patches/api-unmapped/Add-BeaconEffectEvent.patch rename to patches/api/Add-BeaconEffectEvent.patch diff --git a/patches/api-unmapped/Add-MetadataStoreBase.removeAll-Plugin.patch b/patches/api/Add-MetadataStoreBase.removeAll-Plugin.patch similarity index 100% rename from patches/api-unmapped/Add-MetadataStoreBase.removeAll-Plugin.patch rename to patches/api/Add-MetadataStoreBase.removeAll-Plugin.patch diff --git a/patches/api-unmapped/Add-PlayerInitialSpawnEvent.patch b/patches/api/Add-PlayerInitialSpawnEvent.patch similarity index 100% rename from patches/api-unmapped/Add-PlayerInitialSpawnEvent.patch rename to patches/api/Add-PlayerInitialSpawnEvent.patch diff --git a/patches/api-unmapped/Add-PlayerLocaleChangeEvent.patch b/patches/api/Add-PlayerLocaleChangeEvent.patch similarity index 100% rename from patches/api-unmapped/Add-PlayerLocaleChangeEvent.patch rename to patches/api/Add-PlayerLocaleChangeEvent.patch diff --git a/patches/api-unmapped/Add-a-call-helper-to-Event.patch b/patches/api/Add-a-call-helper-to-Event.patch similarity index 100% rename from patches/api-unmapped/Add-a-call-helper-to-Event.patch rename to patches/api/Add-a-call-helper-to-Event.patch diff --git a/patches/api-unmapped/Add-command-to-reload-permissions.yml-and-require-co.patch b/patches/api/Add-command-to-reload-permissions.yml-and-require-co.patch similarity index 100% rename from patches/api-unmapped/Add-command-to-reload-permissions.yml-and-require-co.patch rename to patches/api/Add-command-to-reload-permissions.yml-and-require-co.patch diff --git a/patches/api-unmapped/Add-exception-reporting-event.patch b/patches/api/Add-exception-reporting-event.patch similarity index 100% rename from patches/api-unmapped/Add-exception-reporting-event.patch rename to patches/api/Add-exception-reporting-event.patch diff --git a/patches/api-unmapped/Add-methods-for-working-with-arrows-stuck-in-living-.patch b/patches/api/Add-methods-for-working-with-arrows-stuck-in-living-.patch similarity index 100% rename from patches/api-unmapped/Add-methods-for-working-with-arrows-stuck-in-living-.patch rename to patches/api/Add-methods-for-working-with-arrows-stuck-in-living-.patch diff --git a/patches/api-unmapped/Add-player-view-distance-API.patch b/patches/api/Add-player-view-distance-API.patch similarity index 100% rename from patches/api-unmapped/Add-player-view-distance-API.patch rename to patches/api/Add-player-view-distance-API.patch diff --git a/patches/api-unmapped/Add-sender-name-to-commands.yml-replacement.patch b/patches/api/Add-sender-name-to-commands.yml-replacement.patch similarity index 100% rename from patches/api-unmapped/Add-sender-name-to-commands.yml-replacement.patch rename to patches/api/Add-sender-name-to-commands.yml-replacement.patch diff --git a/patches/api-unmapped/Automatically-disable-plugins-that-fail-to-load.patch b/patches/api/Automatically-disable-plugins-that-fail-to-load.patch similarity index 100% rename from patches/api-unmapped/Automatically-disable-plugins-that-fail-to-load.patch rename to patches/api/Automatically-disable-plugins-that-fail-to-load.patch diff --git a/patches/api-unmapped/Complete-resource-pack-API.patch b/patches/api/Complete-resource-pack-API.patch similarity index 100% rename from patches/api-unmapped/Complete-resource-pack-API.patch rename to patches/api/Complete-resource-pack-API.patch diff --git a/patches/api-unmapped/Custom-replacement-for-eaten-items.patch b/patches/api/Custom-replacement-for-eaten-items.patch similarity index 100% rename from patches/api-unmapped/Custom-replacement-for-eaten-items.patch rename to patches/api/Custom-replacement-for-eaten-items.patch diff --git a/patches/api-unmapped/Entity-AddTo-RemoveFrom-World-Events.patch b/patches/api/Entity-AddTo-RemoveFrom-World-Events.patch similarity index 100% rename from patches/api-unmapped/Entity-AddTo-RemoveFrom-World-Events.patch rename to patches/api/Entity-AddTo-RemoveFrom-World-Events.patch diff --git a/patches/api-unmapped/EntityPathfindEvent.patch b/patches/api/EntityPathfindEvent.patch similarity index 100% rename from patches/api-unmapped/EntityPathfindEvent.patch rename to patches/api/EntityPathfindEvent.patch diff --git a/patches/api-unmapped/Expose-server-CommandMap.patch b/patches/api/Expose-server-CommandMap.patch similarity index 100% rename from patches/api-unmapped/Expose-server-CommandMap.patch rename to patches/api/Expose-server-CommandMap.patch diff --git a/patches/api-unmapped/Fix-ServerListPingEvent-flagging-as-Async.patch b/patches/api/Fix-ServerListPingEvent-flagging-as-Async.patch similarity index 100% rename from patches/api-unmapped/Fix-ServerListPingEvent-flagging-as-Async.patch rename to patches/api/Fix-ServerListPingEvent-flagging-as-Async.patch diff --git a/patches/api-unmapped/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch b/patches/api/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch similarity index 100% rename from patches/api-unmapped/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch rename to patches/api/Graduate-bungeecord-chat-API-from-spigot-subclasses.patch diff --git a/patches/api-unmapped/Player-Tab-List-and-Title-APIs.patch b/patches/api/Player-Tab-List-and-Title-APIs.patch similarity index 100% rename from patches/api-unmapped/Player-Tab-List-and-Title-APIs.patch rename to patches/api/Player-Tab-List-and-Title-APIs.patch diff --git a/patches/api-unmapped/Reduce-thread-synchronization-in-MetadataStoreBase.patch b/patches/api/Reduce-thread-synchronization-in-MetadataStoreBase.patch similarity index 100% rename from patches/api-unmapped/Reduce-thread-synchronization-in-MetadataStoreBase.patch rename to patches/api/Reduce-thread-synchronization-in-MetadataStoreBase.patch diff --git a/patches/api-unmapped/Use-ASM-for-event-executors.patch b/patches/api/Use-ASM-for-event-executors.patch similarity index 100% rename from patches/api-unmapped/Use-ASM-for-event-executors.patch rename to patches/api/Use-ASM-for-event-executors.patch diff --git a/patches/server-remapped/Add-BeaconEffectEvent.patch b/patches/server-remapped/Add-BeaconEffectEvent.patch deleted file mode 100644 index 46c4ed2c2..000000000 --- a/patches/server-remapped/Add-BeaconEffectEvent.patch +++ /dev/null @@ -1,103 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Byteflux -Date: Wed, 2 Mar 2016 23:30:53 -0600 -Subject: [PATCH] Add BeaconEffectEvent - - -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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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 -@@ -0,0 +0,0 @@ import net.minecraft.world.effect.MobEffect; - import net.minecraft.world.effect.MobEffectInstance; - import net.minecraft.world.effect.MobEffects; - import net.minecraft.world.entity.player.Inventory; --import net.minecraft.world.entity.player.Player; - import net.minecraft.world.inventory.AbstractContainerMenu; - import net.minecraft.world.inventory.BeaconMenu; - import net.minecraft.world.inventory.ContainerData; -@@ -0,0 +0,0 @@ import net.minecraft.world.phys.AABB; - import org.bukkit.craftbukkit.potion.CraftPotionUtil; - import org.bukkit.potion.PotionEffect; - // CraftBukkit end -+// Paper start -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.entity.Player; -+import com.destroystokyo.paper.event.block.BeaconEffectEvent; -+// Paper end - - public class BeaconBlockEntity extends BlockEntity implements MenuProvider, TickableBlockEntity { - -@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Tick - double d0 = (double) (this.levels * 10 + 10); - - AABB axisalignedbb = (new AABB(this.worldPosition)).inflate(d0).expandTowards(0.0D, (double) this.level.getMaxBuildHeight(), 0.0D); -- List list = this.level.getEntitiesOfClass(Player.class, axisalignedbb); -+ List list = this.level.getEntitiesOfClass(net.minecraft.world.entity.player.Player.class, axisalignedbb); - - return list; - } - } - - private void applyEffect(List list, MobEffect effects, int i, int b0) { -+ // Paper - BeaconEffectEvent -+ applyEffect(list, effects, i, b0, true); -+ } -+ -+ private void applyEffect(List list, MobEffect effects, int i, int b0, boolean isPrimary) { -+ // Paper - BeaconEffectEvent - { - Iterator iterator = list.iterator(); - -- Player entityhuman; -+ net.minecraft.world.entity.player.Player entityhuman; -+ -+ // Paper start - BeaconEffectEvent -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()); -+ PotionEffect effect = CraftPotionUtil.toBukkit(new MobEffectInstance(effects, i, b0, true, true)); -+ // Paper end - - while (iterator.hasNext()) { -- entityhuman = (Player) iterator.next(); -- entityhuman.addEffect(new MobEffectInstance(effects, i, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON); -+ entityhuman = (net.minecraft.world.entity.player.Player) iterator.next(); -+ -+ // Paper start - BeaconEffectEvent -+ BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (Player) entityhuman.getBukkitEntity(), isPrimary); -+ if (CraftEventFactory.callEvent(event).isCancelled()) continue; -+ entityhuman.addEffect(new MobEffectInstance(CraftPotionUtil.fromBukkit(event.getEffect())), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON); -+ // Paper end - } - } - } -@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Tick - int i = getLevelCb(); - List list = getHumansInRange(); - -- applyEffect(list, this.primaryPower, i, b0); -+ applyEffect(list, this.primaryPower, i, b0, true); // Paper - BeaconEffectEvent - - if (hasSecondaryEffect()) { -- applyEffect(list, this.secondaryPower, i, 0); -+ applyEffect(list, this.secondaryPower, i, 0, false); // Paper - BeaconEffectEvent - } - } - -@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Tick - // CraftBukkit end - - public void playSound(SoundEvent soundeffect) { -- this.level.playSound((Player) null, this.worldPosition, soundeffect, SoundSource.BLOCKS, 1.0F, 1.0F); -+ this.level.playSound((net.minecraft.world.entity.player.Player) null, this.worldPosition, soundeffect, SoundSource.BLOCKS, 1.0F, 1.0F); - } - - public int getLevels() { -@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Tick - - @Nullable - @Override -- public AbstractContainerMenu createMenu(int syncId, Inventory inv, Player player) { -+ public AbstractContainerMenu createMenu(int syncId, Inventory inv, net.minecraft.world.entity.player.Player player) { - return BaseContainerBlockEntity.canUnlock(player, this.lockKey, this.getDisplayName()) ? new BeaconMenu(syncId, inv, this.dataAccess, ContainerLevelAccess.create(this.level, this.getBlockPos())) : null; - } - diff --git a/patches/server-remapped/Change-implementation-of-tile-entity-removal-list.patch b/patches/server-remapped/Change-implementation-of-tile-entity-removal-list.patch deleted file mode 100644 index 600e59823..000000000 --- a/patches/server-remapped/Change-implementation-of-tile-entity-removal-list.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Joseph Hirschfeld -Date: Thu, 3 Mar 2016 02:39:54 -0600 -Subject: [PATCH] Change implementation of (tile)entity removal list - -use sets for faster removal - -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl - } - } - // Spigot End -- this.blockEntitiesToUnload.addAll(chunk.getBlockEntities().values()); -+ this.tileEntityListUnload.addAll(chunk.getBlockEntities().values()); - List[] aentityslice = chunk.getEntitySlices(); // Spigot - int i = aentityslice.length; - -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - public final List blockEntityList = Lists.newArrayList(); - public final List tickableBlockEntities = Lists.newArrayList(); - protected final List pendingBlockEntities = Lists.newArrayList(); -- protected final List blockEntitiesToUnload = Lists.newArrayList(); -+ protected final java.util.Set tileEntityListUnload = com.google.common.collect.Sets.newHashSet(); - public final Thread thread; - private final boolean isDebug; - private int skyDarken; -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - gameprofilerfiller.push("blockEntities"); - timings.tileEntityTick.startTiming(); // Spigot -- if (!this.blockEntitiesToUnload.isEmpty()) { -- this.tickableBlockEntities.removeAll(this.blockEntitiesToUnload); -- this.blockEntityList.removeAll(this.blockEntitiesToUnload); -- this.blockEntitiesToUnload.clear(); -+ if (!this.tileEntityListUnload.isEmpty()) { -+ this.tickableBlockEntities.removeAll(this.tileEntityListUnload); -+ this.blockEntityList.removeAll(this.tileEntityListUnload); -+ this.tileEntityListUnload.clear(); - } - - this.updatingBlockEntities = true; diff --git a/patches/server-remapped/Send-absolute-position-the-first-time-an-entity-is-s.patch b/patches/server-remapped/Send-absolute-position-the-first-time-an-entity-is-s.patch deleted file mode 100644 index 565e58903..000000000 --- a/patches/server-remapped/Send-absolute-position-the-first-time-an-entity-is-s.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jedediah Smith -Date: Wed, 2 Mar 2016 23:13:07 -0600 -Subject: [PATCH] Send absolute position the first time an entity is seen - - -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - private final Entity entity; - private final int range; - private SectionPos lastSectionPos; -- public final Set seenBy = Sets.newHashSet(); -+ // Paper start -+ // Replace trackedPlayers Set with a Map. The value is true until the player receives -+ // their first update (which is forced to have absolute coordinates), false afterward. -+ public java.util.Map trackedPlayerMap = new java.util.HashMap<>(); -+ public Set seenBy = trackedPlayerMap.keySet(); - - public TrackedEntity(Entity entity, int i, int j, boolean flag) { -- this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, j, flag, this::broadcast, seenBy); // CraftBukkit -+ this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, j, flag, this::broadcast, trackedPlayerMap); // CraftBukkit // Paper - this.entity = entity; - this.range = i; - this.lastSectionPos = SectionPos.of(entity); -@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - player.entitiesToRemove.remove(Integer.valueOf(this.entity.getId())); - // CraftBukkit end - -- if (flag1 && this.seenBy.add(player)) { -+ if (flag1 && this.trackedPlayerMap.putIfAbsent(player, true) == null) { // Paper - this.serverEntity.addPairing(player); - } - } else if (this.seenBy.remove(player)) { -diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/level/ServerEntity.java -+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -0,0 +0,0 @@ import com.google.common.collect.Lists; - import com.mojang.datafixers.util.Pair; - import java.util.Collection; - import java.util.Collections; -+import java.util.HashSet; - import java.util.Iterator; - import java.util.List; - import java.util.Set; -@@ -0,0 +0,0 @@ public class ServerEntity { - private final Entity entity; - private final int updateInterval; - private final boolean trackDelta; -- private final Consumer> broadcast; -+ private final Consumer> broadcast; private Consumer> getPacketConsumer() { return broadcast; } // Paper - OBFHELPER - private long xp; - private long yp; - private long zp; -@@ -0,0 +0,0 @@ public class ServerEntity { - private boolean wasOnGround; - // CraftBukkit start - private final Set trackedPlayers; -+ // Paper start -+ private java.util.Map trackedPlayerMap = null; -+ -+ /** -+ * Requested in https://github.com/PaperMC/Paper/issues/1537 to allow intercepting packets -+ */ -+ public void sendPlayerPacket(ServerPlayer player, Packet packet) { -+ player.connection.send(packet); -+ } -+ -+ public ServerEntity(ServerLevel worldserver, Entity entity, int i, boolean flag, Consumer> consumer, java.util.Map trackedPlayers) { -+ this(worldserver, entity, i, flag, consumer, trackedPlayers.keySet()); -+ trackedPlayerMap = trackedPlayers; -+ } - - public ServerEntity(ServerLevel worldserver, Entity entity, int i, boolean flag, Consumer> consumer, Set trackedPlayers) { -+ // Paper end - this.trackedPlayers = trackedPlayers; - // CraftBukkit end - this.ap = Vec3.ZERO; -@@ -0,0 +0,0 @@ public class ServerEntity { - } - - if (packet1 != null) { -- this.broadcast.accept(packet1); -+ // paper start -+ if (trackedPlayerMap == null || packet1 instanceof ClientboundTeleportEntityPacket) { -+ this.broadcast.accept((packet1)); -+ } else { -+ ClientboundTeleportEntityPacket teleportPacket = null; -+ -+ for (java.util.Map.Entry viewer : trackedPlayerMap.entrySet()) { -+ if (viewer.getValue()) { -+ viewer.setValue(false); -+ if (teleportPacket == null) { -+ teleportPacket = new ClientboundTeleportEntityPacket(this.entity); -+ } -+ sendPlayerPacket(viewer.getKey(), teleportPacket); -+ } else { -+ sendPlayerPacket(viewer.getKey(), packet1); -+ } -+ } -+ } -+ // Paper end - } - - this.sendDirtyEntityData(); diff --git a/patches/server/Add-BeaconEffectEvent.patch b/patches/server/Add-BeaconEffectEvent.patch new file mode 100644 index 000000000..411c23067 --- /dev/null +++ b/patches/server/Add-BeaconEffectEvent.patch @@ -0,0 +1,62 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Byteflux +Date: Wed, 2 Mar 2016 23:30:53 -0600 +Subject: [PATCH] Add BeaconEffectEvent + + +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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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 +@@ -0,0 +0,0 @@ import net.minecraft.world.phys.AABB; + import org.bukkit.craftbukkit.potion.CraftPotionUtil; + import org.bukkit.potion.PotionEffect; + // CraftBukkit end ++// Paper start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import com.destroystokyo.paper.event.block.BeaconEffectEvent; ++// Paper end + + public class BeaconBlockEntity extends BlockEntity implements MenuProvider { + +@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider { + } + } + +- private static void applyEffect(List list, MobEffect mobeffectlist, int j, int b0) { +- { ++ private static void applyEffect(List list, MobEffect effects, int i, int b0, boolean isPrimary, BlockPos worldPosition) { // Paper - BeaconEffectEvent ++ if (!list.isEmpty()) { // Paper - BeaconEffectEvent + Iterator iterator = list.iterator(); + + Player entityhuman; ++ // Paper start - BeaconEffectEvent ++ org.bukkit.block.Block block = ((Player) list.get(0)).level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()); ++ PotionEffect effect = CraftPotionUtil.toBukkit(new MobEffectInstance(effects, i, b0, true, true)); ++ // Paper end + + while (iterator.hasNext()) { +- entityhuman = (Player) iterator.next(); +- entityhuman.addEffect(new MobEffectInstance(mobeffectlist, j, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON); ++ // Paper start - BeaconEffectEvent ++ entityhuman = (ServerPlayer) iterator.next(); ++ BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (org.bukkit.entity.Player) entityhuman.getBukkitEntity(), isPrimary); ++ if (CraftEventFactory.callEvent(event).isCancelled()) continue; ++ entityhuman.addEffect(new MobEffectInstance(CraftPotionUtil.fromBukkit(event.getEffect())), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON); ++ // Paper end + } + } + } +@@ -0,0 +0,0 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider { + int j = BeaconBlockEntity.getLevel(beaconLevel); + List list = BeaconBlockEntity.getHumansInRange(world, pos, beaconLevel); + +- BeaconBlockEntity.applyEffect(list, primaryEffect, j, b0); ++ BeaconBlockEntity.applyEffect(list, primaryEffect, j, b0, true, pos); // Paper - BeaconEffectEvent + + if (BeaconBlockEntity.hasSecondaryEffect(beaconLevel, primaryEffect, secondaryEffect)) { +- BeaconBlockEntity.applyEffect(list, secondaryEffect, j, 0); ++ BeaconBlockEntity.applyEffect(list, secondaryEffect, j, 0, false, pos); // Paper - BeaconEffectEvent + } + } + diff --git a/patches/server-remapped/Add-PlayerInitialSpawnEvent.patch b/patches/server/Add-PlayerInitialSpawnEvent.patch similarity index 96% rename from patches/server-remapped/Add-PlayerInitialSpawnEvent.patch rename to patches/server/Add-PlayerInitialSpawnEvent.patch index 6c03b2802..ed496480b 100644 --- a/patches/server-remapped/Add-PlayerInitialSpawnEvent.patch +++ b/patches/server/Add-PlayerInitialSpawnEvent.patch @@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Player bukkitPlayer = player.getBukkitEntity(); - org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new org.spigotmc.event.player.PlayerSpawnLocationEvent(bukkitPlayer, bukkitPlayer.getLocation()); + org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new com.destroystokyo.paper.event.player.PlayerInitialSpawnEvent(bukkitPlayer, bukkitPlayer.getLocation()); // Paper use our duplicate event - cserver.getPluginManager().callEvent(ev); + this.cserver.getPluginManager().callEvent(ev); Location loc = ev.getSpawnLocation(); @@ -0,0 +0,0 @@ public abstract class PlayerList { @@ -37,7 +37,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n return d1 * d1 + d2 * d2 + d3 * d3 < radius * radius; } diff --git a/patches/server-remapped/Add-World-Util-Methods.patch b/patches/server/Add-World-Util-Methods.patch similarity index 100% rename from patches/server-remapped/Add-World-Util-Methods.patch rename to patches/server/Add-World-Util-Methods.patch diff --git a/patches/server-remapped/Add-configurable-portal-search-radius.patch b/patches/server/Add-configurable-portal-search-radius.patch similarity index 79% rename from patches/server-remapped/Add-configurable-portal-search-radius.patch rename to patches/server/Add-configurable-portal-search-radius.patch index 0aa3dfa7f..d833b0818 100644 --- a/patches/server-remapped/Add-configurable-portal-search-radius.patch +++ b/patches/server/Add-configurable-portal-search-radius.patch @@ -26,18 +26,18 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n double d4 = DimensionType.getTeleportationScale(this.level.dimensionType(), destination.dimensionType()); BlockPos blockposition = new BlockPos(Mth.clamp(this.getX() * d4, d0, d2), this.getY(), Mth.clamp(this.getZ() * d4, d1, d3)); // CraftBukkit start -- CraftPortalEvent event = callPortalEvent(this, destination, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16); +- CraftPortalEvent event = this.callPortalEvent(this, destination, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16); + // Paper start + int portalSearchRadius = destination.paperConfig.portalSearchRadius; + if (level.paperConfig.portalSearchVanillaDimensionScaling && flag2) { // == THE_NETHER + portalSearchRadius = (int) (portalSearchRadius / destination.dimensionType().coordinateScale()); + } + // Paper end -+ CraftPortalEvent event = callPortalEvent(this, destination, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, portalSearchRadius, destination.paperConfig.portalCreateRadius); // Paper start - configurable portal radius ++ CraftPortalEvent event = this.callPortalEvent(this, destination, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, portalSearchRadius, destination.paperConfig.portalCreateRadius); // Paper start - configurable portal radius if (event == null) { return null; } @@ -47,10 +47,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java @@ -0,0 +0,0 @@ public class PortalForcer { - public Optional findPortalAround(BlockPos blockposition, boolean flag) { + public Optional findPortalAround(BlockPos destPos, boolean destIsNether) { // CraftBukkit start -- return findPortalAround(blockposition, flag ? 16 : 128); // Search Radius -+ return findPortalAround(blockposition, flag ? level.paperConfig.portalCreateRadius : level.paperConfig.portalSearchRadius); // Paper - search Radius +- return this.findPortal(destPos, destIsNether ? 16 : 128); // Search Radius ++ return this.findPortal(destPos, destIsNether ? level.paperConfig.portalCreateRadius : level.paperConfig.portalSearchRadius); // Search Radius // Paper - search Radius } public Optional findPortal(BlockPos blockposition, int i) { diff --git a/patches/server-remapped/Add-exception-reporting-event.patch b/patches/server/Add-exception-reporting-event.patch similarity index 82% rename from patches/server-remapped/Add-exception-reporting-event.patch rename to patches/server/Add-exception-reporting-event.patch index b19a7dd7b..5ad0b531b 100644 --- a/patches/server-remapped/Add-exception-reporting-event.patch +++ b/patches/server/Add-exception-reporting-event.patch @@ -122,19 +122,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import com.google.common.collect.Lists; import com.mojang.serialization.Codec; import java.io.IOException; -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - gameprofilerfiller.pop(); - } catch (Throwable throwable) { - // Paper start - Prevent tile entity and entity crashes -- System.err.println("TileEntity threw exception at " + tileentity.level.getWorld().getName() + ":" + tileentity.worldPosition.getX() + "," + tileentity.worldPosition.getY() + "," + tileentity.worldPosition.getZ()); -+ String msg = "TileEntity threw exception at " + tileentity.getLevel().getWorld().getName() + ":" + tileentity.getBlockPos().getX() + "," + tileentity.getBlockPos().getY() + "," + tileentity.getBlockPos().getZ(); -+ System.err.println(msg); - throwable.printStackTrace(); -+ getCraftServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable))); -+ // Paper end - tilesThisCycle--; - this.tickableBlockEntities.remove(tileTickPosition--); - continue; @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { tickConsumer.accept(entity); } catch (Throwable throwable) { @@ -144,9 +131,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + System.err.println(msg); throwable.printStackTrace(); + getCraftServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable))); - entity.removed = true; - return; + entity.discard(); // Paper end + } diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java @@ -160,12 +147,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } @@ -0,0 +0,0 @@ public final class NaturalSpawner { - entity = biomesettingsmobs_c.type.create((Level) worldaccess.getLevel()); - } catch (Exception exception) { - NaturalSpawner.LOGGER.warn("Failed to create mob", exception); -+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper - continue; - } + entity = biomesettingsmobs_c.type.create((Level) world.getLevel()); + } catch (Exception exception) { + NaturalSpawner.LOGGER.warn("Failed to create mob", exception); ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper + continue; + } 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -174,30 +161,43 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ package net.minecraft.world.level.chunk; + import com.google.common.collect.ImmutableList; +import com.destroystokyo.paper.exception.ServerInternalException; import com.google.common.collect.Maps; import com.google.common.collect.Sets; - import it.unimi.dsi.fastutil.longs.LongOpenHashSet; + import com.google.common.collect.UnmodifiableIterator; @@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess { - this.blockEntities.remove(pos); + this.blockEntities.remove(blockposition); // Paper end } else { - System.out.println("Attempted to place a tile entity (" + blockEntity + ") at " + blockEntity.getBlockPos().getX() + "," + blockEntity.getBlockPos().getY() + "," + blockEntity.getBlockPos().getZ() -- + " (" + getBlockState(pos) + ") where there was no entity tile!"); +- + " (" + this.getBlockState(blockposition) + ") where there was no entity tile!"); - System.out.println("Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16)); - new Exception().printStackTrace(); + // Paper start + ServerInternalException e = new ServerInternalException( -+ "Attempted to place a tile entity (" + blockEntity + ") at " + blockEntity.getBlockPos().getX() + "," -+ + blockEntity.getBlockPos().getY() + "," + blockEntity.getBlockPos().getZ() -+ + " (" + getBlockState(pos) + ") where there was no entity tile!\n" + -+ "Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16)); ++ "Attempted to place a tile entity (" + blockEntity + ") at " + blockEntity.getBlockPos().getX() + "," ++ + blockEntity.getBlockPos().getY() + "," + blockEntity.getBlockPos().getZ() ++ + " (" + getBlockState(blockposition) + ") where there was no entity tile!\n" + ++ "Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16)); + e.printStackTrace(); + ServerInternalException.reportInternalException(e); + // Paper end // CraftBukkit end } } +@@ -0,0 +0,0 @@ public class LevelChunk implements ChunkAccess { + gameprofilerfiller.pop(); + } catch (Throwable throwable) { + // Paper start - Prevent tile entity and entity crashes +- System.err.println("TileEntity threw exception at " + LevelChunk.this.getLevel().getWorld().getName() + ":" + this.getPos().getX() + "," + this.getPos().getY() + "," + this.getPos().getZ()); ++ String msg = "TileEntity threw exception at " + LevelChunk.this.getLevel().getWorld().getName() + ":" + this.getPos().getX() + "," + this.getPos().getY() + "," + this.getPos().getZ(); ++ System.err.println(msg); + throwable.printStackTrace(); ++ net.minecraft.world.level.chunk.LevelChunk.this.level.getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new ServerInternalException(msg, throwable))); + LevelChunk.this.removeBlockEntity(this.getPos()); + // Paper end + // Spigot start diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -211,25 +211,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } @@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { + ((java.nio.Buffer) bytebuffer).position(5); // CraftBukkit - decompile error filechannel.write(bytebuffer); - } catch (Throwable throwable1) { - throwable = throwable1; + } catch (Throwable throwable) { + com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(throwable); // Paper - throw throwable1; - } finally { if (filechannel != null) { + try { + filechannel.close(); diff --git a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java @@ -0,0 +0,0 @@ public class DimensionDataStorage { - } - } catch (Throwable throwable6) { - throwable = throwable6; -+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(throwable); // Paper - throw throwable6; - } finally { - if (fileinputstream != null) { + + pushbackInputStream.close(); + } catch (Throwable var15) { ++ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(var15); // Paper + try { + fileInputStream.close(); + } catch (Throwable var10) { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -252,13 +252,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + new ServerExceptionEvent(new ServerSchedulerException(msg, throwable, task))); // Paper end } finally { - currentTask = null; + this.currentTask = null; @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { - parsePending(); + this.parsePending(); } else { - debugTail = debugTail.setNext(new CraftAsyncDebugger(currentTick + RECENT_TICKS, task.getOwner(), task.getTaskClass())); -- executor.execute(task); -+ executor.execute(new ServerSchedulerReportingWrapper(task)); // Paper + this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); +- this.executor.execute(task); ++ this.executor.execute(new ServerSchedulerReportingWrapper(task)); // Paper // We don't need to parse pending // (async tasks must live with race-conditions if they attempt to cancel between these few lines of code) } diff --git a/patches/server-remapped/Add-methods-for-working-with-arrows-stuck-in-living-.patch b/patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch similarity index 89% rename from patches/server-remapped/Add-methods-for-working-with-arrows-stuck-in-living-.patch rename to patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch index 38ecc3e3e..7a2edb415 100644 --- a/patches/server-remapped/Add-methods-for-working-with-arrows-stuck-in-living-.patch +++ b/patches/server/Add-methods-for-working-with-arrows-stuck-in-living-.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { - getHandle().persistentInvisibility = invisible; - getHandle().setSharedFlag(5, invisible); + this.getHandle().persistentInvisibility = invisible; + this.getHandle().setSharedFlag(5, invisible); } + + // Paper start diff --git a/patches/server-remapped/Add-velocity-warnings.patch b/patches/server/Add-velocity-warnings.patch similarity index 94% rename from patches/server-remapped/Add-velocity-warnings.patch rename to patches/server/Add-velocity-warnings.patch index 6d48ddb81..622fe906c 100644 --- a/patches/server-remapped/Add-velocity-warnings.patch +++ b/patches/server/Add-velocity-warnings.patch @@ -29,8 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + CraftServer.excessiveVelEx = new Exception("Excessive velocity set detected: tried to set velocity of entity " + entity.getScoreboardName() + " id #" + getEntityId() + " to (" + velocity.getX() + "," + velocity.getY() + "," + velocity.getZ() + ")."); + } + // Paper end -+ - entity.setDeltaMovement(CraftVector.toNMS(velocity)); + this.entity.setDeltaMovement(CraftVector.toNMS(velocity)); entity.hurtMarked = true; } @@ -61,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public double getHeight() { - return getHandle().getBbHeight(); + return this.getHandle().getBbHeight(); diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java @@ -86,4 +85,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end log.log( Level.SEVERE, "------------------------------" ); log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper - dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log ); + WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log ); diff --git a/patches/server-remapped/All-chunks-are-slime-spawn-chunks-toggle.patch b/patches/server/All-chunks-are-slime-spawn-chunks-toggle.patch similarity index 82% rename from patches/server-remapped/All-chunks-are-slime-spawn-chunks-toggle.patch rename to patches/server/All-chunks-are-slime-spawn-chunks-toggle.patch index c759fa8d0..5d628f686 100644 --- a/patches/server-remapped/All-chunks-are-slime-spawn-chunks-toggle.patch +++ b/patches/server/All-chunks-are-slime-spawn-chunks-toggle.patch @@ -26,8 +26,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } ChunkPos chunkcoordintpair = new ChunkPos(pos); -- boolean flag = WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), world.getLevel().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot -+ boolean flag = world.getLevel().paperConfig.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), world.getLevel().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper +- boolean flag = WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), world.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot ++ boolean flag = world.getMinecraftWorld().paperConfig.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), world.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper if (random.nextInt(10) == 0 && flag && pos.getY() < 40) { return checkMobSpawnRules(type, world, spawnReason, pos, random); diff --git a/patches/server-remapped/Allow-Reloading-of-Custom-Permissions.patch b/patches/server/Allow-Reloading-of-Custom-Permissions.patch similarity index 100% rename from patches/server-remapped/Allow-Reloading-of-Custom-Permissions.patch rename to patches/server/Allow-Reloading-of-Custom-Permissions.patch diff --git a/patches/server-remapped/Be-a-bit-more-informative-in-maxHealth-exception.patch b/patches/server/Be-a-bit-more-informative-in-maxHealth-exception.patch similarity index 72% rename from patches/server-remapped/Be-a-bit-more-informative-in-maxHealth-exception.patch rename to patches/server/Be-a-bit-more-informative-in-maxHealth-exception.patch index 015780bf9..a4cf491aa 100644 --- a/patches/server-remapped/Be-a-bit-more-informative-in-maxHealth-exception.patch +++ b/patches/server/Be-a-bit-more-informative-in-maxHealth-exception.patch @@ -11,12 +11,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public void setHealth(double health) { health = (float) health; - if ((health < 0) || (health > getMaxHealth())) { -- throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth() + "(" + health + ")"); + if ((health < 0) || (health > this.getMaxHealth())) { +- throw new IllegalArgumentException("Health must be between 0 and " + this.getMaxHealth() + "(" + health + ")"); + // Paper - Be more informative + throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth() + ", but was " + health -+ + ". (attribute base value: " + this.getHandle().getAttribute(Attributes.MAX_HEALTH).getBaseValue() -+ + (this instanceof CraftPlayer ? ", player: " + this.getName() + ')' : ')')); ++ + ". (attribute base value: " + this.getHandle().getAttribute(Attributes.MAX_HEALTH).getBaseValue() ++ + (this instanceof CraftPlayer ? ", player: " + this.getName() + ')' : ')')); } - getHandle().setHealth((float) health); + this.getHandle().setHealth((float) health); diff --git a/patches/server-remapped/Chunk-Save-Reattempt.patch b/patches/server/Chunk-Save-Reattempt.patch similarity index 92% rename from patches/server-remapped/Chunk-Save-Reattempt.patch rename to patches/server/Chunk-Save-Reattempt.patch index c71718a8b..a12a50463 100644 --- a/patches/server-remapped/Chunk-Save-Reattempt.patch +++ b/patches/server/Chunk-Save-Reattempt.patch @@ -32,14 +32,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { - protected void write(ChunkPos pos, CompoundTag tag) throws IOException { + protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { RegionFile regionfile = this.getFile(pos, false); // CraftBukkit + int attempts = 0; Exception laste = null; while (attempts++ < 5) { try { // Paper - DataOutputStream dataoutputstream = regionfile.getChunkDataOutputStream(pos); - Throwable throwable = null; + if (nbt == null) { + regionfile.clear(pos); @@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { - + } } + // Paper start diff --git a/patches/server-remapped/Complete-resource-pack-API.patch b/patches/server/Complete-resource-pack-API.patch similarity index 79% rename from patches/server-remapped/Complete-resource-pack-API.patch rename to patches/server/Complete-resource-pack-API.patch index 05d59cd60..fda921c86 100644 --- a/patches/server-remapped/Complete-resource-pack-API.patch +++ b/patches/server/Complete-resource-pack-API.patch @@ -8,19 +8,20 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { - // CraftBukkit start - public void handleResourcePackResponse(ServerboundResourcePackPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); -- this.craftServer.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()])); +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + ServerGamePacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName()); + this.disconnect(new TranslatableComponent("multiplayer.requiredTexturePrompt.disconnect")); + } +- this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()])); // CraftBukkit +- + // Paper start + PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()]; + player.getBukkitEntity().setResourcePackStatus(packStatus); -+ this.craftServer.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getPlayer(), packStatus)); ++ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packStatus)); // CraftBukkit + // Paper end } - // CraftBukkit end + @Override diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -45,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setResourcePack(String url, String hash) { + Validate.notNull(url, "Resource pack URL cannot be null"); + Validate.notNull(hash, "Hash cannot be null"); -+ this.getHandle().sendTexturePack(url, hash); ++ this.getHandle().sendTexturePack(url, hash, false, new net.minecraft.network.chat.TextComponent("")); + } + + @Override diff --git a/patches/server-remapped/Configurable-Disabling-Cat-Chest-Detection.patch b/patches/server/Configurable-Disabling-Cat-Chest-Detection.patch similarity index 100% rename from patches/server-remapped/Configurable-Disabling-Cat-Chest-Detection.patch rename to patches/server/Configurable-Disabling-Cat-Chest-Detection.patch diff --git a/patches/server-remapped/Configurable-Non-Player-Arrow-Despawn-Rate.patch b/patches/server/Configurable-Non-Player-Arrow-Despawn-Rate.patch similarity index 98% rename from patches/server-remapped/Configurable-Non-Player-Arrow-Despawn-Rate.patch rename to patches/server/Configurable-Non-Player-Arrow-Despawn-Rate.patch index 208dcc8a1..fe145bb91 100644 --- a/patches/server-remapped/Configurable-Non-Player-Arrow-Despawn-Rate.patch +++ b/patches/server/Configurable-Non-Player-Arrow-Despawn-Rate.patch @@ -39,6 +39,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 ++this.life; - if (this.life >= ((this instanceof ThrownTrident) ? level.spigotConfig.tridentDespawnRate : level.spigotConfig.arrowDespawnRate)) { // Spigot + if (this.life >= (pickup == Pickup.CREATIVE_ONLY ? level.paperConfig.creativeArrowDespawnRate : (pickup == Pickup.DISALLOWED ? level.paperConfig.nonPlayerArrowDespawnRate : ((this instanceof ThrownTrident) ? level.spigotConfig.tridentDespawnRate : level.spigotConfig.arrowDespawnRate)))) { // Spigot // Paper - TODO: Extract this to init? - this.remove(); + this.discard(); } diff --git a/patches/server-remapped/Configurable-container-update-tick-rate.patch b/patches/server/Configurable-container-update-tick-rate.patch similarity index 90% rename from patches/server-remapped/Configurable-container-update-tick-rate.patch rename to patches/server/Configurable-container-update-tick-rate.patch index ef4e08472..b3303b37d 100644 --- a/patches/server-remapped/Configurable-container-update-tick-rate.patch +++ b/patches/server/Configurable-container-update-tick-rate.patch @@ -22,15 +22,15 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener { - public boolean ignoreSlotUpdateHack; +@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { + private int containerCounter; public int latency; public boolean wonGame; + private int containerUpdateDelay; // Paper // CraftBukkit start public String displayName; -@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener { +@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { --this.invulnerableTime; } diff --git a/patches/server-remapped/Configurable-inter-world-teleportation-safety.patch b/patches/server/Configurable-inter-world-teleportation-safety.patch similarity index 100% rename from patches/server-remapped/Configurable-inter-world-teleportation-safety.patch rename to patches/server/Configurable-inter-world-teleportation-safety.patch diff --git a/patches/server-remapped/Configurable-mob-spawner-tick-rate.patch b/patches/server/Configurable-mob-spawner-tick-rate.patch similarity index 55% rename from patches/server-remapped/Configurable-mob-spawner-tick-rate.patch rename to patches/server/Configurable-mob-spawner-tick-rate.patch index 516c5f555..7ad510094 100644 --- a/patches/server-remapped/Configurable-mob-spawner-tick-rate.patch +++ b/patches/server/Configurable-mob-spawner-tick-rate.patch @@ -23,43 +23,40 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/BaseSpawner.java +++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java @@ -0,0 +0,0 @@ public abstract class BaseSpawner { - public int maxNearbyEntities = 6; - public int requiredPlayerRange = 16; - public int spawnRange = 4; + public int requiredPlayerRange; + public int spawnRange; + private final Random random; + private int tickDelay = 0; // Paper - public BaseSpawner() {} - + public BaseSpawner() { + this.spawnPotentials = BaseSpawner.EMPTY_POTENTIALS; @@ -0,0 +0,0 @@ public abstract class BaseSpawner { } - public void tick() { + public void serverTick(ServerLevel world, BlockPos pos) { + // Paper start - Configurable mob spawner tick rate + if (spawnDelay > 0 && --tickDelay > 0) return; -+ tickDelay = this.getLevel().paperConfig.mobSpawnerTickRate; ++ tickDelay = world.paperConfig.mobSpawnerTickRate; + // Paper end - if (!this.isNearPlayer()) { - this.oSpin = this.spin; - } else { -@@ -0,0 +0,0 @@ public abstract class BaseSpawner { - world.addParticle(ParticleTypes.SMOKE, d0, d1, d2, 0.0D, 0.0D, 0.0D); - world.addParticle(ParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D); - if (this.spawnDelay > 0) { -- --this.spawnDelay; -+ this.spawnDelay -= tickDelay; // Paper - } + if (this.isNearPlayer(world, pos)) { +- if (this.spawnDelay == -1) { ++ if (this.spawnDelay < -tickDelay) { + this.delay(world, pos); + } - this.oSpin = this.spin; - this.spin = (this.spin + (double) (1000.0F / ((float) this.spawnDelay + 200.0F))) % 360.0D; + if (this.spawnDelay > 0) { +- --this.spawnDelay; ++ this.spawnDelay -= tickDelay; // Paper } else { -- if (this.spawnDelay == -1) { -+ if (this.spawnDelay < -tickDelay) { // Paper - this.delay(); - } - - if (this.spawnDelay > 0) { -- --this.spawnDelay; -+ this.spawnDelay -= tickDelay; // Paper - return; - } + boolean flag = false; +@@ -0,0 +0,0 @@ public abstract class BaseSpawner { + ((Mob) entity).finalizeSpawn(world, world.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, (SpawnGroupData) null, (CompoundTag) null); + } + // Spigot Start +- if ( entityinsentient.level.spigotConfig.nerfSpawnerMobs ) +- { ++ if (entityinsentient.level.spigotConfig.nerfSpawnerMobs) { + entityinsentient.aware = false; + } + // Spigot End diff --git a/patches/server-remapped/Custom-replacement-for-eaten-items.patch b/patches/server/Custom-replacement-for-eaten-items.patch similarity index 100% rename from patches/server-remapped/Custom-replacement-for-eaten-items.patch rename to patches/server/Custom-replacement-for-eaten-items.patch diff --git a/patches/server-remapped/Default-loading-permissions.yml-before-plugins.patch b/patches/server/Default-loading-permissions.yml-before-plugins.patch similarity index 84% rename from patches/server-remapped/Default-loading-permissions.yml-before-plugins.patch rename to patches/server/Default-loading-permissions.yml-before-plugins.patch index d10d717f0..d2c018824 100644 --- a/patches/server-remapped/Default-loading-permissions.yml-before-plugins.patch +++ b/patches/server/Default-loading-permissions.yml-before-plugins.patch @@ -34,19 +34,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - if (type == PluginLoadOrder.STARTUP) { - helpMap.clear(); - helpMap.initializeGeneralTopics(); + + if (!Main.useConsole) { + this.getLogger().info("Console input is disabled due to --noconsole command argument"); + if (com.destroystokyo.paper.PaperConfig.loadPermsBeforePlugins) loadCustomPermissions(); // Paper } - Plugin[] plugins = pluginManager.getPlugins(); + this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile()); @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - commandMap.registerServerAliases(); + this.commandMap.registerServerAliases(); DefaultPermissions.registerCorePermissions(); CraftDefaultPermissions.registerCorePermissions(); -- loadCustomPermissions(); -+ if (!com.destroystokyo.paper.PaperConfig.loadPermsBeforePlugins) loadCustomPermissions(); // Paper - helpMap.initializeCommands(); - syncCommands(); +- this.loadCustomPermissions(); ++ if (!com.destroystokyo.paper.PaperConfig.loadPermsBeforePlugins) this.loadCustomPermissions(); // Paper + this.helpMap.initializeCommands(); + this.syncCommands(); } diff --git a/patches/server-remapped/Disable-Scoreboards-for-non-players-by-default.patch b/patches/server/Disable-Scoreboards-for-non-players-by-default.patch similarity index 92% rename from patches/server-remapped/Disable-Scoreboards-for-non-players-by-default.patch rename to patches/server/Disable-Scoreboards-for-non-players-by-default.patch index 4f728a9da..e09dcbbd0 100644 --- a/patches/server-remapped/Disable-Scoreboards-for-non-players-by-default.patch +++ b/patches/server/Disable-Scoreboards-for-non-players-by-default.patch @@ -28,12 +28,12 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n @Nullable public Team getTeam() { + if (!this.level.paperConfig.nonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper - return this.level.getScoreboard().getPlayerTeam(this.getScoreboardName()); + return this.level.getScoreboard().getPlayersTeam(this.getScoreboardName()); } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -41,9 +41,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity { - if (tag.contains("Team", 8)) { - String s = tag.getString("Team"); - PlayerTeam scoreboardteam = this.level.getScoreboard().getTeam(s); + if (nbt.contains("Team", 8)) { + String s = nbt.getString("Team"); + PlayerTeam scoreboardteam = this.level.getScoreboard().getPlayerTeam(s); + if (!level.paperConfig.nonPlayerEntitiesOnScoreboards && !(this instanceof net.minecraft.world.entity.player.Player)) { scoreboardteam = null; } // Paper boolean flag = scoreboardteam != null && this.level.getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam); diff --git a/patches/server-remapped/Disable-explosion-knockback.patch b/patches/server/Disable-explosion-knockback.patch similarity index 94% rename from patches/server-remapped/Disable-explosion-knockback.patch rename to patches/server/Disable-explosion-knockback.patch index 393686dd5..e75dd9d17 100644 --- a/patches/server-remapped/Disable-explosion-knockback.patch +++ b/patches/server/Disable-explosion-knockback.patch @@ -62,8 +62,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (entity instanceof Player) { Player entityhuman = (Player) entity; -- if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.abilities.flying)) { -+ if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.abilities.flying) && !level.paperConfig.disableExplosionKnockback) { // Paper - Disable explosion knockback +- if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.getAbilities().flying)) { ++ if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.getAbilities().flying) && !level.paperConfig.disableExplosionKnockback) { // Paper - Disable explosion knockback this.hitPlayers.put(entityhuman, new Vec3(d8 * d13, d9 * d13, d10 * d13)); } } diff --git a/patches/server-remapped/Disable-ice-and-snow.patch b/patches/server/Disable-ice-and-snow.patch similarity index 100% rename from patches/server-remapped/Disable-ice-and-snow.patch rename to patches/server/Disable-ice-and-snow.patch diff --git a/patches/server-remapped/Disable-spigot-tick-limiters.patch b/patches/server/Disable-spigot-tick-limiters.patch similarity index 51% rename from patches/server-remapped/Disable-spigot-tick-limiters.patch rename to patches/server/Disable-spigot-tick-limiters.patch index d2fb47f2a..3f12790ff 100644 --- a/patches/server-remapped/Disable-spigot-tick-limiters.patch +++ b/patches/server/Disable-spigot-tick-limiters.patch @@ -10,12 +10,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { // Spigot start - // Iterator iterator = this.tileEntityListTick.iterator(); + // Iterator iterator = this.blockEntityTickers.iterator(); int tilesThisCycle = 0; -- for (tileLimiter.initTick(); -- tilesThisCycle < tickableBlockEntities.size() && (tilesThisCycle % 10 != 0 || tileLimiter.shouldContinue()); -- tileTickPosition++, tilesThisCycle++) { -+ for (tileTickPosition = 0; tileTickPosition < tickableBlockEntities.size(); tileTickPosition++) { // Paper - Disable tick limiters - tileTickPosition = (tileTickPosition < tickableBlockEntities.size()) ? tileTickPosition : 0; - BlockEntity tileentity = (BlockEntity) this.tickableBlockEntities.get(tileTickPosition); +- for (this.tileLimiter.initTick(); +- tilesThisCycle < this.blockEntityTickers.size() && (tilesThisCycle % 10 != 0 || this.tileLimiter.shouldContinue()); +- this.tileTickPosition++, tilesThisCycle++) { ++ for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters + this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0; + TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(tileTickPosition); // Spigot start diff --git a/patches/server-remapped/Disable-thunder.patch b/patches/server/Disable-thunder.patch similarity index 94% rename from patches/server-remapped/Disable-thunder.patch rename to patches/server/Disable-thunder.patch index 6770cd8b3..53ff1c9aa 100644 --- a/patches/server-remapped/Disable-thunder.patch +++ b/patches/server/Disable-thunder.patch @@ -28,6 +28,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (flag && this.isThundering() && this.random.nextInt(100000) == 0) { + if (!this.paperConfig.disableThunder && flag && this.isThundering() && this.random.nextInt(100000) == 0) { // Paper - Disable thunder - blockposition = this.findLightingTargetAround(this.getBlockRandomPos(j, 0, k, 15)); + blockposition = this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15)); if (this.isRainingAt(blockposition)) { DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition); diff --git a/patches/server-remapped/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch b/patches/server/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch similarity index 69% rename from patches/server-remapped/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch rename to patches/server/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch index e6f2a4127..2a5e34634 100644 --- a/patches/server-remapped/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch +++ b/patches/server/Don-t-nest-if-we-don-t-need-to-when-cerealising-text.patch @@ -12,14 +12,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ClientboundChatPacket implements Packet { // Paper end // Spigot start - if (components != null) { -- buf.writeByteArray(net.md_5.bungee.chat.ComponentSerializer.toString(components)); -+ //packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(components)); // Paper - comment, replaced with below + if (this.components != null) { +- buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(components)); ++ // buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(components)); // Paper - comment, replaced with below + // Paper start - don't nest if we don't need to so that we can preserve formatting + if (this.components.length == 1) { -+ buf.writeByteArray(net.md_5.bungee.chat.ComponentSerializer.toString(this.components[0])); ++ buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(this.components[0])); + } else { -+ buf.writeByteArray(net.md_5.bungee.chat.ComponentSerializer.toString(this.components)); ++ buf.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(this.components)); + } + // Paper end } else { diff --git a/patches/server-remapped/Ensure-commands-are-not-ran-async.patch b/patches/server/Ensure-commands-are-not-ran-async.patch similarity index 98% rename from patches/server-remapped/Ensure-commands-are-not-ran-async.patch rename to patches/server/Ensure-commands-are-not-ran-async.patch index eb860453b..6eda57062 100644 --- a/patches/server-remapped/Ensure-commands-are-not-ran-async.patch +++ b/patches/server/Ensure-commands-are-not-ran-async.patch @@ -17,7 +17,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { +@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser } if (!async && s.startsWith("/")) { @@ -77,8 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + // Paper End -+ - if (commandMap.dispatch(sender, commandLine)) { + if (this.commandMap.dispatch(sender, commandLine)) { return true; } diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java @@ -90,7 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 try { org.spigotmc.AsyncCatcher.enabled = false; // Spigot + org.spigotmc.AsyncCatcher.shuttingDown = true; // Paper - server.close(); + this.server.close(); } finally { try { diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java diff --git a/patches/server-remapped/Ensure-inv-drag-is-in-bounds.patch b/patches/server/Ensure-inv-drag-is-in-bounds.patch similarity index 60% rename from patches/server-remapped/Ensure-inv-drag-is-in-bounds.patch rename to patches/server/Ensure-inv-drag-is-in-bounds.patch index 525ff531a..350426330 100644 --- a/patches/server-remapped/Ensure-inv-drag-is-in-bounds.patch +++ b/patches/server/Ensure-inv-drag-is-in-bounds.patch @@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.resetQuickCraft(); } } else if (this.quickcraftStatus == 1) { -- Slot slot = (Slot) this.slots.get(i); -+ Slot slot = i < this.slots.size() ? this.slots.get(i) : null; // Paper - Ensure drag in bounds - - itemstack1 = playerinventory.getCarried(); - if (slot != null && canItemQuickReplace(slot, itemstack1, true) && slot.isAllowed(itemstack1) && (this.quickcraftType == 2 || itemstack1.getCount() > this.quickcraftSlots.size()) && this.canDragTo(slot)) { +- slot = (Slot) this.slots.get(slotIndex); ++ slot = slotIndex < this.slots.size() ? this.slots.get(slotIndex) : null; // Paper - Ensure drag in bounds + itemstack = this.getCarried(); + if (AbstractContainerMenu.canItemQuickReplace(slot, itemstack, true) && slot.mayPlace(itemstack) && (this.quickcraftType == 2 || itemstack.getCount() > this.quickcraftSlots.size()) && this.canDragTo(slot)) { + this.quickcraftSlots.add(slot); diff --git a/patches/server-remapped/Expose-server-CommandMap.patch b/patches/server/Expose-server-CommandMap.patch similarity index 91% rename from patches/server-remapped/Expose-server-CommandMap.patch rename to patches/server/Expose-server-CommandMap.patch index 2a0fe5f54..f627a4043 100644 --- a/patches/server-remapped/Expose-server-CommandMap.patch +++ b/patches/server/Expose-server-CommandMap.patch @@ -9,10 +9,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - return helpMap; + return this.helpMap; } + @Override // Paper - add override public SimpleCommandMap getCommandMap() { - return commandMap; + return this.commandMap; } diff --git a/patches/server-remapped/Handle-Item-Meta-Inconsistencies.patch b/patches/server/Handle-Item-Meta-Inconsistencies.patch similarity index 85% rename from patches/server-remapped/Handle-Item-Meta-Inconsistencies.patch rename to patches/server/Handle-Item-Meta-Inconsistencies.patch index d234ef6ab..b9c636deb 100644 --- a/patches/server-remapped/Handle-Item-Meta-Inconsistencies.patch +++ b/patches/server/Handle-Item-Meta-Inconsistencies.patch @@ -21,18 +21,18 @@ diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -0,0 +0,0 @@ import com.mojang.serialization.Codec; - import com.mojang.serialization.codecs.RecordCodecBuilder; - import java.text.DecimalFormat; - import java.text.DecimalFormatSymbols; +@@ -0,0 +0,0 @@ import java.text.DecimalFormatSymbols; + import java.util.Collection; + import java.util.Iterator; + import java.util.List; +import java.util.Collections; +import java.util.Comparator; import java.util.Locale; + import java.util.Map.Entry; import java.util.Objects; - import java.util.Optional; @@ -0,0 +0,0 @@ public final class ItemStack { - private BlockInWorld cachedPlaceBlock; - private boolean cachedPlaceBlockResult; + return this.getItem().getTooltipImage(this); + } + // Paper start + private static final java.util.Comparator enchantSorter = java.util.Comparator.comparing(o -> o.getString("id")); @@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + try { + //noinspection unchecked -+ list.sort((Comparator) enchantSorter); // Paper ++ list.sort((Comparator) enchantSorter); // Paper + } catch (Exception ignored) {} + } + // Paper end @@ -55,13 +55,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this(item, 1); } @@ -0,0 +0,0 @@ public final class ItemStack { - if (nbttagcompound.contains("tag", 10)) { // CraftBukkit start - make defensive copy as this data may be coming from the save thread this.tag = (CompoundTag) nbttagcompound.getCompound("tag").copy(); -+ processEnchantOrder(this.tag); // Paper - this.getItem().verifyTagAfterLoad(this.tag); // CraftBukkit end ++ this.processEnchantOrder(this.tag); // Paper + this.getItem().verifyTagAfterLoad(this.tag); } + @@ -0,0 +0,0 @@ public final class ItemStack { // Paper end public void setTag(@Nullable CompoundTag tag) { @@ -94,13 +94,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void addUnsafeEnchantment(Enchantment ench, int level) { Validate.notNull(ench, "Cannot add null enchantment"); -- if (!makeTag(handle)) { +- if (!CraftItemStack.makeTag(this.handle)) { - return; - } -- ListTag list = getEnchantmentList(handle); +- ListTag list = CraftItemStack.getEnchantmentList(this.handle); - if (list == null) { - list = new ListTag(); -- handle.getTag().put(ENCHANTMENTS.NBT, list); +- this.handle.getTag().put(ENCHANTMENTS.NBT, list); - } - int size = list.size(); - @@ -117,9 +117,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - tag.putShort(ENCHANTMENTS_LVL.NBT, (short) level); - list.add(tag); + // Paper start - Replace whole method -+ final ItemMeta itemMeta = getItemMeta(); ++ final ItemMeta itemMeta = this.getItemMeta(); + itemMeta.addEnchant(ench, level, true); -+ setItemMeta(itemMeta); ++ this.setItemMeta(itemMeta); + // Paper end } @@ -128,25 +128,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public boolean containsEnchantment(Enchantment ench) { -- return getEnchantmentLevel(ench) > 0; -+ return hasItemMeta() && getItemMeta().hasEnchant(ench); // Paper - use meta +- return this.getEnchantmentLevel(ench) > 0; ++ return this.hasItemMeta() && this.getItemMeta().hasEnchant(ench); // Paper - use meta } @Override public int getEnchantmentLevel(Enchantment ench) { - Validate.notNull(ench, "Cannot find null enchantment"); -- if (handle == null) { +- if (this.handle == null) { - return 0; - } - return EnchantmentHelper.getItemEnchantmentLevel(CraftEnchantment.getRaw(ench), handle); -+ return hasItemMeta() ? getItemMeta().getEnchantLevel(ench) : 0; // Paper - replace entire method with meta ++ return this.hasItemMeta() ? this.getItemMeta().getEnchantLevel(ench) : 0; // Paper - replace entire method with meta } @Override public int removeEnchantment(Enchantment ench) { Validate.notNull(ench, "Cannot remove null enchantment"); -- ListTag list = getEnchantmentList(handle), listCopy; +- ListTag list = CraftItemStack.getEnchantmentList(this.handle), listCopy; - if (list == null) { - return 0; - } @@ -168,9 +168,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - return 0; - } - if (size == 1) { -- handle.getTag().remove(ENCHANTMENTS.NBT); -- if (handle.getTag().isEmpty()) { -- handle.setTag(null); +- this.handle.getTag().remove(ENCHANTMENTS.NBT); +- if (this.handle.getTag().isEmpty()) { +- this.handle.setTag(null); - } - return level; - } @@ -182,13 +182,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - listCopy.add(list.get(i)); - } + // Paper start - replace entire method -+ final ItemMeta itemMeta = getItemMeta(); ++ final ItemMeta itemMeta = this.getItemMeta(); + int level = itemMeta.getEnchantLevel(ench); + if (level > 0) { + itemMeta.removeEnchant(ench); -+ setItemMeta(itemMeta); ++ this.setItemMeta(itemMeta); } -- handle.getTag().put(ENCHANTMENTS.NBT, listCopy); +- this.handle.getTag().put(ENCHANTMENTS.NBT, listCopy); + // Paper end return level; @@ -196,8 +196,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Map getEnchantments() { -- return getEnchantments(handle); -+ return hasItemMeta() ? getItemMeta().getEnchants() : ImmutableMap.of(); // Paper - use Item Meta +- return CraftItemStack.getEnchantments(this.handle); ++ return this.hasItemMeta() ? this.getItemMeta().getEnchants() : ImmutableMap.of(); // Paper - use Item Meta } static Map getEnchantments(net.minecraft.world.item.ItemStack item) { @@ -244,7 +244,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private CompoundTag internalTag; - private final Map unhandledTags = new HashMap(); + private final Map unhandledTags = new TreeMap<>(); // Paper - private CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY); + private CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftMetaItem.DATA_TYPE_REGISTRY); private int version = CraftMagicNumbers.INSTANCE.getDataVersion(); // Internal use only @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -292,16 +292,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Map getEnchants() { -- return hasEnchants() ? ImmutableMap.copyOf(enchantments) : ImmutableMap.of(); -+ return hasEnchants() ? ImmutableSortedMap.copyOfSorted(enchantments) : ImmutableMap.of(); // Paper +- return this.hasEnchants() ? ImmutableMap.copyOf(enchantments) : ImmutableMap.of(); ++ return this.hasEnchants() ? ImmutableSortedMap.copyOfSorted(this.enchantments) : ImmutableMap.of(); // Paper } @Override public boolean addEnchant(Enchantment ench, int level, boolean ignoreRestrictions) { Validate.notNull(ench, "Enchantment cannot be null"); - if (enchantments == null) { -- enchantments = new LinkedHashMap(4); -+ enchantments = new EnchantmentMap(); // Paper + if (this.enchantments == null) { +- this.enchantments = new LinkedHashMap(4); ++ this.enchantments = new EnchantmentMap(); // Paper } if (ignoreRestrictions || level >= ench.getStartLevel() && level <= ench.getMaxLevel()) { @@ -315,7 +315,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.hasAttributeModifiers()) { clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers); @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { - return HANDLED_TAGS; + return CraftMetaItem.HANDLED_TAGS; } } + diff --git a/patches/server-remapped/Player-Tab-List-and-Title-APIs.patch b/patches/server/Player-Tab-List-and-Title-APIs.patch similarity index 80% rename from patches/server-remapped/Player-Tab-List-and-Title-APIs.patch rename to patches/server/Player-Tab-List-and-Title-APIs.patch index 658d2f719..d184e2541 100644 --- a/patches/server-remapped/Player-Tab-List-and-Title-APIs.patch +++ b/patches/server/Player-Tab-List-and-Title-APIs.patch @@ -32,37 +32,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Nullable public static MutableComponent fromJson(String json) { return (MutableComponent) GsonHelper.fromJson(Component.Serializer.GSON, json, MutableComponent.class, false); -diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java -+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitlesPacket.java -@@ -0,0 +0,0 @@ public class ClientboundSetTitlesPacket implements Packet