From efc6fa6a04121a35e69528ac48f3a0be499dea75 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Mon, 14 Jun 2021 12:58:32 -0700 Subject: [PATCH] more patches --- build-data/mappings-patch.tiny | 4 + .../Add-BlockPreDispenseEvent.patch | 0 .../Add-StructureLocateEvent.patch | 0 ...Leash-variable-to-EntityUnleashEvent.patch | 0 .../Add-sendOpLevel-API.patch | 0 .../Added-PlayerChangeBeaconEffectEvent.patch | 0 ...d-PlayerStonecutterRecipeSelectEvent.patch | 0 .../Added-Vanilla-Entity-Tags.patch | 0 .../EntityMoveEvent.patch | 0 ...onent-with-empty-text-instead-of-thr.patch | 0 .../add-DragonEggFormEvent.patch | 0 .../added-Wither-API.patch | 0 ...d-PlayerStonecutterRecipeSelectEvent.patch | 109 ---------------- .../Entity-load-save-limit-per-chunk.patch | 90 -------------- .../Make-schedule-command-per-world.patch | 37 ------ .../add-DragonEggFormEvent.patch | 117 ------------------ .../Add-StructureLocateEvent.patch | 0 ...Leash-variable-to-EntityUnleashEvent.patch | 30 ++--- .../Add-sendOpLevel-API.patch | 2 +- ...le-for-always-placing-the-dragon-egg.patch | 5 +- ...d-PlayerStonecutterRecipeSelectEvent.patch | 51 ++++++++ .../Added-Vanilla-Entity-Tags.patch | 8 +- ...ing-of-PlayerChangeBeaconEffectEvent.patch | 15 +-- ...n-for-requiring-a-player-participant.patch | 2 +- .../Configurable-max-leash-distance.patch | 0 .../EntityMoveEvent.patch | 32 ++--- ...e-spam-when-removing-chests-in-water.patch | 0 .../Fix-villager-boat-exploit.patch | 24 ++-- .../Implement-BlockPreDispenseEvent.patch | 20 +-- .../Make-schedule-command-per-world.patch | 37 ++++++ ...ileHitEvent-call-when-fireballs-dead.patch | 2 +- ...-shield-blocking-on-dimension-change.patch | 2 +- ...onent-with-empty-text-instead-of-thr.patch | 0 ...ce-map-update-when-spawning-disabled.patch | 0 patches/server/add-DragonEggFormEvent.patch | 36 ++++++ .../added-Wither-API.patch | 16 +-- 36 files changed, 174 insertions(+), 465 deletions(-) rename patches/{api-unmapped => api}/Add-BlockPreDispenseEvent.patch (100%) rename patches/{api-unmapped => api}/Add-StructureLocateEvent.patch (100%) rename patches/{api-unmapped => api}/Add-dropLeash-variable-to-EntityUnleashEvent.patch (100%) rename patches/{api-unmapped => api}/Add-sendOpLevel-API.patch (100%) rename patches/{api-unmapped => api}/Added-PlayerChangeBeaconEffectEvent.patch (100%) rename patches/{api-unmapped => api}/Added-PlayerStonecutterRecipeSelectEvent.patch (100%) rename patches/{api-unmapped => api}/Added-Vanilla-Entity-Tags.patch (100%) rename patches/{api-unmapped => api}/EntityMoveEvent.patch (100%) rename patches/{api-unmapped => api}/Return-chat-component-with-empty-text-instead-of-thr.patch (100%) rename patches/{api-unmapped => api}/add-DragonEggFormEvent.patch (100%) rename patches/{api-unmapped => api}/added-Wither-API.patch (100%) delete mode 100644 patches/server-remapped/Added-PlayerStonecutterRecipeSelectEvent.patch delete mode 100644 patches/server-remapped/Entity-load-save-limit-per-chunk.patch delete mode 100644 patches/server-remapped/Make-schedule-command-per-world.patch delete mode 100644 patches/server-remapped/add-DragonEggFormEvent.patch rename patches/{server-remapped => server}/Add-StructureLocateEvent.patch (100%) rename patches/{server-remapped => server}/Add-dropLeash-variable-to-EntityUnleashEvent.patch (88%) rename patches/{server-remapped => server}/Add-sendOpLevel-API.patch (99%) rename patches/{server-remapped => server}/Add-toggle-for-always-placing-the-dragon-egg.patch (94%) create mode 100644 patches/server/Added-PlayerStonecutterRecipeSelectEvent.patch rename patches/{server-remapped => server}/Added-Vanilla-Entity-Tags.patch (92%) rename patches/{server-remapped => server}/Added-firing-of-PlayerChangeBeaconEffectEvent.patch (64%) rename patches/{server-remapped => server}/Collision-option-for-requiring-a-player-participant.patch (99%) rename patches/{server-remapped => server}/Configurable-max-leash-distance.patch (100%) rename patches/{server-remapped => server}/EntityMoveEvent.patch (63%) rename patches/{server-remapped => server}/Fix-console-spam-when-removing-chests-in-water.patch (100%) rename patches/{server-remapped => server}/Fix-villager-boat-exploit.patch (54%) rename patches/{server-remapped => server}/Implement-BlockPreDispenseEvent.patch (61%) create mode 100644 patches/server/Make-schedule-command-per-world.patch rename patches/{server-remapped => server}/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch (96%) rename patches/{server-remapped => server}/Reset-shield-blocking-on-dimension-change.patch (90%) rename patches/{server-remapped => server}/Return-chat-component-with-empty-text-instead-of-thr.patch (100%) rename patches/{server-remapped => server}/Skip-distance-map-update-when-spawning-disabled.patch (100%) create mode 100644 patches/server/add-DragonEggFormEvent.patch rename patches/{server-remapped => server}/added-Wither-API.patch (82%) diff --git a/build-data/mappings-patch.tiny b/build-data/mappings-patch.tiny index b592b1991b..42978d9d06 100644 --- a/build-data/mappings-patch.tiny +++ b/build-data/mappings-patch.tiny @@ -83,3 +83,7 @@ c net/minecraft/world/level/block/MultifaceBlock net/minecraft/world/level/block c net/minecraft/server/players/UserCache net/minecraft/server/players/GameProfileCache m (Ljava/lang/String;)Lcom/mojang/authlib/GameProfile; getProfile get p 0 name + +# change dimension in ServerPlayer TODO (not sure what's wrong here) +#c net/minecraft/server/level/EntityPlayer net/minecraft/server/level/ServerPlayer +# m (Lnet/minecraft/server/level/ServerLevel;Lorg/bukkit/event/player/PlayerTeleportEvent$TeleportCause)Lnet/minecraft/world/entity/Entity; b changeDimension diff --git a/patches/api-unmapped/Add-BlockPreDispenseEvent.patch b/patches/api/Add-BlockPreDispenseEvent.patch similarity index 100% rename from patches/api-unmapped/Add-BlockPreDispenseEvent.patch rename to patches/api/Add-BlockPreDispenseEvent.patch diff --git a/patches/api-unmapped/Add-StructureLocateEvent.patch b/patches/api/Add-StructureLocateEvent.patch similarity index 100% rename from patches/api-unmapped/Add-StructureLocateEvent.patch rename to patches/api/Add-StructureLocateEvent.patch diff --git a/patches/api-unmapped/Add-dropLeash-variable-to-EntityUnleashEvent.patch b/patches/api/Add-dropLeash-variable-to-EntityUnleashEvent.patch similarity index 100% rename from patches/api-unmapped/Add-dropLeash-variable-to-EntityUnleashEvent.patch rename to patches/api/Add-dropLeash-variable-to-EntityUnleashEvent.patch diff --git a/patches/api-unmapped/Add-sendOpLevel-API.patch b/patches/api/Add-sendOpLevel-API.patch similarity index 100% rename from patches/api-unmapped/Add-sendOpLevel-API.patch rename to patches/api/Add-sendOpLevel-API.patch diff --git a/patches/api-unmapped/Added-PlayerChangeBeaconEffectEvent.patch b/patches/api/Added-PlayerChangeBeaconEffectEvent.patch similarity index 100% rename from patches/api-unmapped/Added-PlayerChangeBeaconEffectEvent.patch rename to patches/api/Added-PlayerChangeBeaconEffectEvent.patch diff --git a/patches/api-unmapped/Added-PlayerStonecutterRecipeSelectEvent.patch b/patches/api/Added-PlayerStonecutterRecipeSelectEvent.patch similarity index 100% rename from patches/api-unmapped/Added-PlayerStonecutterRecipeSelectEvent.patch rename to patches/api/Added-PlayerStonecutterRecipeSelectEvent.patch diff --git a/patches/api-unmapped/Added-Vanilla-Entity-Tags.patch b/patches/api/Added-Vanilla-Entity-Tags.patch similarity index 100% rename from patches/api-unmapped/Added-Vanilla-Entity-Tags.patch rename to patches/api/Added-Vanilla-Entity-Tags.patch diff --git a/patches/api-unmapped/EntityMoveEvent.patch b/patches/api/EntityMoveEvent.patch similarity index 100% rename from patches/api-unmapped/EntityMoveEvent.patch rename to patches/api/EntityMoveEvent.patch diff --git a/patches/api-unmapped/Return-chat-component-with-empty-text-instead-of-thr.patch b/patches/api/Return-chat-component-with-empty-text-instead-of-thr.patch similarity index 100% rename from patches/api-unmapped/Return-chat-component-with-empty-text-instead-of-thr.patch rename to patches/api/Return-chat-component-with-empty-text-instead-of-thr.patch diff --git a/patches/api-unmapped/add-DragonEggFormEvent.patch b/patches/api/add-DragonEggFormEvent.patch similarity index 100% rename from patches/api-unmapped/add-DragonEggFormEvent.patch rename to patches/api/add-DragonEggFormEvent.patch diff --git a/patches/api-unmapped/added-Wither-API.patch b/patches/api/added-Wither-API.patch similarity index 100% rename from patches/api-unmapped/added-Wither-API.patch rename to patches/api/added-Wither-API.patch diff --git a/patches/server-remapped/Added-PlayerStonecutterRecipeSelectEvent.patch b/patches/server-remapped/Added-PlayerStonecutterRecipeSelectEvent.patch deleted file mode 100644 index 106440cc9f..0000000000 --- a/patches/server-remapped/Added-PlayerStonecutterRecipeSelectEvent.patch +++ /dev/null @@ -1,109 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Fri, 27 Nov 2020 17:14:27 -0800 -Subject: [PATCH] Added PlayerStonecutterRecipeSelectEvent - -Co-Authored-By: MiniDigger | Martin - -diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -0,0 +0,0 @@ public abstract class AbstractContainerMenu { - return slot; - } - -- protected DataSlot addDataSlot(DataSlot containerproperty) { -+ protected DataSlot addDataSlot(DataSlot containerproperty) { return addDataSlot(containerproperty); } protected DataSlot addDataSlot(DataSlot containerproperty) { // Paper - OBFHELPER - this.dataSlots.add(containerproperty); - return containerproperty; - } -diff --git a/src/main/java/net/minecraft/world/inventory/DataSlot.java b/src/main/java/net/minecraft/world/inventory/DataSlot.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/inventory/DataSlot.java -+++ b/src/main/java/net/minecraft/world/inventory/DataSlot.java -@@ -0,0 +0,0 @@ public abstract class DataSlot { - }; - } - -- public static DataSlot shared(final int[] array, final int index) { -+ public static DataSlot shared(final int[] aint, final int i) { return shared(aint, i); } public static DataSlot shared(final int[] array, final int index) { // Paper - OBFHELPER - return new DataSlot() { - @Override - public int get() { -@@ -0,0 +0,0 @@ public abstract class DataSlot { - - public abstract void set(int value); - -- public boolean checkAndClearUpdateFlag() { -+ public boolean checkAndClearUpdateFlag() { return checkAndClearUpdateFlag(); } public boolean checkAndClearUpdateFlag() { // Paper - OBFHELPER - int i = this.get(); - boolean flag = i != this.prevValue; - -diff --git a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java -+++ b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java -@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryStonecutter; - import org.bukkit.craftbukkit.inventory.CraftInventoryView; - import org.bukkit.entity.Player; - // CraftBukkit end -+import io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent; // Paper - - public class StonecutterMenu extends AbstractContainerMenu { - - private final ContainerLevelAccess access; - private final DataSlot selectedRecipeIndex; - private final Level level; -- private List recipes; -+ private List recipes; public final List getRecipes() { return this.recipes; } // Paper - OBFHELPER - private ItemStack input; - private long lastSoundTime; - final Slot inputSlot; -@@ -0,0 +0,0 @@ public class StonecutterMenu extends AbstractContainerMenu { - - public StonecutterMenu(int syncId, Inventory playerInventory, final ContainerLevelAccess context) { - super(MenuType.STONECUTTER, syncId); -- this.selectedRecipeIndex = DataSlot.standalone(); -+ this.selectedRecipeIndex = addDataSlot(DataSlot.shared(new int[1], 0)); // Paper - allow replication - this.recipes = Lists.newArrayList(); - this.input = ItemStack.EMPTY; - this.slotUpdateListener = () -> { -@@ -0,0 +0,0 @@ public class StonecutterMenu extends AbstractContainerMenu { - @Override - public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) { - if (this.isValidRecipeIndex(id)) { -- this.selectedRecipeIndex.set(id); -+ // Paper start -+ int recipeIndex = id; -+ this.selectedRecipeIndex.set(recipeIndex); -+ this.selectedRecipeIndex.checkAndClearUpdateFlag(); // mark as changed -+ if (this.isValidRecipeIndex(id)) { -+ PlayerStonecutterRecipeSelectEvent event = new PlayerStonecutterRecipeSelectEvent((Player) player.getBukkitEntity(), (org.bukkit.inventory.StonecutterInventory) getBukkitView().getTopInventory(), (org.bukkit.inventory.StonecuttingRecipe) this.getRecipes().get(id).toBukkitRecipe()); -+ if (!event.callEvent()) { -+ ((Player) player.getBukkitEntity()).updateInventory(); -+ return false; -+ } -+ int newRecipeIndex; -+ if (!this.getRecipes().get(recipeIndex).getId().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()))) { // If the recipe did NOT stay the same -+ for (newRecipeIndex = 0; newRecipeIndex < this.getRecipes().size(); newRecipeIndex++) { -+ if (this.getRecipes().get(newRecipeIndex).getId().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()))) { -+ recipeIndex = newRecipeIndex; -+ break; -+ } -+ } -+ } -+ } -+ ((Player) player.getBukkitEntity()).updateInventory(); -+ this.selectedRecipeIndex.set(recipeIndex); // set new index, so that listeners can read it -+ // Paper end - this.setupResultSlot(); - } - - return true; - } - -+ private boolean isValidRecipeIndex(int index) { return this.isValidRecipeIndex(index); } // Paper - OBFHELPER - private boolean isValidRecipeIndex(int i) { - return i >= 0 && i < this.recipes.size(); - } diff --git a/patches/server-remapped/Entity-load-save-limit-per-chunk.patch b/patches/server-remapped/Entity-load-save-limit-per-chunk.patch deleted file mode 100644 index aebd836436..0000000000 --- a/patches/server-remapped/Entity-load-save-limit-per-chunk.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> -Date: Wed, 18 Nov 2020 20:52:25 -0800 -Subject: [PATCH] Entity load/save limit per chunk - -Adds a config option to limit the number of entities saved and loaded -to a chunk. The default values of -1 disable the limit. Although -defaults are only included for certain entites, this allows setting -limits for any entity type. - -diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -0,0 +0,0 @@ import java.util.List; - import java.util.Map; - import java.util.stream.Collectors; - import net.minecraft.world.Difficulty; -+import net.minecraft.world.entity.EntityType; - import net.minecraft.world.entity.monster.Vindicator; - import net.minecraft.world.entity.monster.Zombie; - import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray.EngineMode; -@@ -0,0 +0,0 @@ public class PaperWorldConfig { - Difficulty.class - ); - } -+ -+ public Map, Integer> entityPerChunkSaveLimits = new HashMap<>(); -+ private void entityPerChunkSaveLimits() { -+ getInt("entity-per-chunk-save-limit.experience_orb", -1); -+ getInt("entity-per-chunk-save-limit.snowball", -1); -+ getInt("entity-per-chunk-save-limit.ender_pearl", -1); -+ getInt("entity-per-chunk-save-limit.arrow", -1); -+ EntityType.getEntityNameList().forEach(name -> { -+ final EntityType type = EntityType.getByName(name.getPath()).orElseThrow(() -> new IllegalStateException("Unknown Entity Type: " + name.toString())); -+ final String path = ".entity-per-chunk-save-limit." + name.getPath(); -+ final int value = config.getInt("world-settings." + worldName + path, config.getInt("world-settings.default" + path, -1)); // get without setting defaults -+ if (value != -1) entityPerChunkSaveLimits.put(type, value); -+ }); -+ } - } -diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -@@ -0,0 +0,0 @@ public class ChunkSerializer { - - chunk.setLastSaveHadEntities(false); - -+ // Paper start -+ final Map, Integer> savedEntityCounts = Maps.newHashMap(); - for (int j = 0; j < chunk.getEntitySlices().length; ++j) { - Iterator iterator1 = chunk.getEntitySlices()[j].iterator(); - - while (iterator1.hasNext()) { - Entity entity = (Entity) iterator1.next(); -+ final EntityType entityType = entity.getType(); -+ final int saveLimit = worldserver.paperConfig.entityPerChunkSaveLimits.getOrDefault(entityType, -1); -+ if (saveLimit > -1) { -+ if (savedEntityCounts.getOrDefault(entityType, 0) >= saveLimit) { -+ continue; -+ } -+ savedEntityCounts.merge(entityType, 1, Integer::sum); -+ } -+ // Paper end - CompoundTag nbttagcompound4 = new CompoundTag(); - // Paper start - if (asyncsavedata == null && !entity.removed && (int) Math.floor(entity.getX()) >> 4 != chunk.getPos().x || (int) Math.floor(entity.getZ()) >> 4 != chunk.getPos().z) { -@@ -0,0 +0,0 @@ public class ChunkSerializer { - ListTag nbttaglist = tag.getList("Entities", 10); - Level world = chunk.getLevel(); - -+ // Paper start -+ final Map, Integer> loadedEntityCounts = Maps.newHashMap(); - for (int i = 0; i < nbttaglist.size(); ++i) { - CompoundTag nbttagcompound1 = nbttaglist.getCompound(i); - - EntityType.loadEntityRecursive(nbttagcompound1, world, (entity) -> { -+ final EntityType entityType = entity.getType(); -+ final int saveLimit = world.paperConfig.entityPerChunkSaveLimits.getOrDefault(entityType, -1); -+ if (saveLimit > -1) { -+ if (loadedEntityCounts.getOrDefault(entityType, 0) >= saveLimit) { -+ return null; -+ } -+ loadedEntityCounts.merge(entityType, 1, Integer::sum); -+ } -+ // Paper end - chunk.addEntity(entity); - return entity; - }); diff --git a/patches/server-remapped/Make-schedule-command-per-world.patch b/patches/server-remapped/Make-schedule-command-per-world.patch deleted file mode 100644 index 1ae0c41fc0..0000000000 --- a/patches/server-remapped/Make-schedule-command-per-world.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Mon, 4 Jan 2021 19:52:44 -0800 -Subject: [PATCH] Make schedule command per-world - - -diff --git a/src/main/java/net/minecraft/server/commands/ScheduleCommand.java b/src/main/java/net/minecraft/server/commands/ScheduleCommand.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/commands/ScheduleCommand.java -+++ b/src/main/java/net/minecraft/server/commands/ScheduleCommand.java -@@ -0,0 +0,0 @@ public class ScheduleCommand { - return new TranslatableComponent("commands.schedule.cleared.failure", new Object[]{object}); - }); - private static final SuggestionProvider SUGGEST_SCHEDULE = (commandcontext, suggestionsbuilder) -> { -- return SharedSuggestionProvider.suggest((Iterable) ((CommandSourceStack) commandcontext.getSource()).getServer().getWorldData().overworldData().getScheduledEvents().getEventsIds(), suggestionsbuilder); -+ return SharedSuggestionProvider.suggest((Iterable) ((CommandSourceStack) commandcontext.getSource()).getLevel().worldDataServer.overworldData().getScheduledEvents().getEventsIds(), suggestionsbuilder); // Paper - }; - - public static void register(CommandDispatcher dispatcher) { -@@ -0,0 +0,0 @@ public class ScheduleCommand { - } else { - long j = source.getLevel().getGameTime() + (long) i; - ResourceLocation minecraftkey = (ResourceLocation) pair.getFirst(); -- TimerQueue customfunctioncallbacktimerqueue = source.getServer().getWorldData().overworldData().getScheduledEvents(); -+ TimerQueue customfunctioncallbacktimerqueue = source.getLevel().worldDataServer.overworldData().getScheduledEvents(); // Paper - - ((Either) pair.getSecond()).ifLeft((customfunction) -> { - String s = minecraftkey.toString(); -@@ -0,0 +0,0 @@ public class ScheduleCommand { - } - - private static int remove(CommandSourceStack commandlistenerwrapper, String s) throws CommandSyntaxException { -- int i = commandlistenerwrapper.getServer().getWorldData().overworldData().getScheduledEvents().remove(s); -+ int i = commandlistenerwrapper.getLevel().worldDataServer.overworldData().getScheduledEvents().remove(s); // Paper - - if (i == 0) { - throw ScheduleCommand.ERROR_CANT_REMOVE.create(s); diff --git a/patches/server-remapped/add-DragonEggFormEvent.patch b/patches/server-remapped/add-DragonEggFormEvent.patch deleted file mode 100644 index c39c76c4cc..0000000000 --- a/patches/server-remapped/add-DragonEggFormEvent.patch +++ /dev/null @@ -1,117 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Trigary -Date: Mon, 25 Jan 2021 14:53:57 +0100 -Subject: [PATCH] add DragonEggFormEvent - - -diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java -+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -0,0 +0,0 @@ import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfigur - import net.minecraft.world.phys.AABB; - import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; -+import io.papermc.paper.event.block.DragonEggFormEvent; // Paper - DragonEggFormEvent - - public class EndDragonFight { - -@@ -0,0 +0,0 @@ public class EndDragonFight { - this.dragonEvent.setVisible(false); - this.spawnExitPortal(true); - this.spawnNewGateway(); -+ // Paper start - DragonEggFormEvent -+ BlockPos eggPosition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getPosition()); -+ org.bukkit.craftbukkit.block.CraftBlock eggBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, eggPosition); -+ org.bukkit.craftbukkit.block.CraftBlockState eggState = new org.bukkit.craftbukkit.block.CraftBlockState(eggBlock); -+ eggState.setData(Blocks.DRAGON_EGG.defaultBlockState()); -+ DragonEggFormEvent eggEvent = new DragonEggFormEvent(eggBlock, eggState, -+ new org.bukkit.craftbukkit.boss.CraftDragonBattle(this)); -+ // Paper end - DragonEggFormEvent - if (this.level.paperConfig.enderDragonsDeathAlwaysPlacesDragonEgg || !this.previouslyKilled) { // Paper - always place dragon egg -- this.level.setBlockAndUpdate(this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION), Blocks.DRAGON_EGG.defaultBlockState()); -+ // Paper start - DragonEggFormEvent -+ //this.world.setTypeUpdate(this.world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, WorldGenEndTrophy.a), Blocks.DRAGON_EGG.getBlockData()); -+ } else { -+ eggEvent.setCancelled(true); -+ } -+ if (eggEvent.callEvent()) { -+ eggEvent.getNewState().update(true); - } -+ // Paper end - DragonEggFormEvent - - this.previouslyKilled = true; - this.dragonKilled = true; -diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/EndPodiumFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/EndPodiumFeature.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/feature/EndPodiumFeature.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/EndPodiumFeature.java -@@ -0,0 +0,0 @@ import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConf - - public class EndPodiumFeature extends Feature { - -- public static final BlockPos END_PODIUM_LOCATION = BlockPos.ZERO; -+ public static final BlockPos END_PODIUM_LOCATION = BlockPos.ZERO; public static BlockPos getPosition() { return END_PODIUM_LOCATION; } // Paper - OBFHELPER - private final boolean active; - - public EndPodiumFeature(boolean open) { -@@ -0,0 +0,0 @@ public class EndPodiumFeature extends Feature { - this.active = open; - } - -- public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, NoneFeatureConfiguration config) { -- Iterator iterator = BlockPos.betweenClosed(new BlockPos(pos.getX() - 4, pos.getY() - 1, pos.getZ() - 4), new BlockPos(pos.getX() + 4, pos.getY() + 32, pos.getZ() + 4)).iterator(); -+ public boolean generate(WorldGenLevel generatoraccessseed, ChunkGenerator chunkgenerator, Random random, BlockPos blockposition, NoneFeatureConfiguration worldgenfeatureemptyconfiguration) { // Paper - decompile fix -+ Iterator iterator = BlockPos.betweenClosed(new BlockPos(blockposition.getX() - 4, blockposition.getY() - 1, blockposition.getZ() - 4), new BlockPos(blockposition.getX() + 4, blockposition.getY() + 32, blockposition.getZ() + 4)).iterator(); - - while (iterator.hasNext()) { - BlockPos blockposition1 = (BlockPos) iterator.next(); -- boolean flag = blockposition1.closerThan((Vec3i) pos, 2.5D); -+ boolean flag = blockposition1.closerThan((Vec3i) blockposition, 2.5D); - -- if (flag || blockposition1.closerThan((Vec3i) pos, 3.5D)) { -- if (blockposition1.getY() < pos.getY()) { -+ if (flag || blockposition1.closerThan((Vec3i) blockposition, 3.5D)) { -+ if (blockposition1.getY() < blockposition.getY()) { - if (flag) { -- this.setBlock(world, blockposition1, Blocks.BEDROCK.defaultBlockState()); -- } else if (blockposition1.getY() < pos.getY()) { -- this.setBlock(world, blockposition1, Blocks.END_STONE.defaultBlockState()); -+ this.setBlock(generatoraccessseed, blockposition1, Blocks.BEDROCK.defaultBlockState()); -+ } else if (blockposition1.getY() < blockposition.getY()) { -+ this.setBlock(generatoraccessseed, blockposition1, Blocks.END_STONE.defaultBlockState()); - } -- } else if (blockposition1.getY() > pos.getY()) { -- this.setBlock(world, blockposition1, Blocks.AIR.defaultBlockState()); -+ } else if (blockposition1.getY() > blockposition.getY()) { -+ this.setBlock(generatoraccessseed, blockposition1, Blocks.AIR.defaultBlockState()); - } else if (!flag) { -- this.setBlock(world, blockposition1, Blocks.BEDROCK.defaultBlockState()); -+ this.setBlock(generatoraccessseed, blockposition1, Blocks.BEDROCK.defaultBlockState()); - } else if (this.active) { -- this.setBlock(world, new BlockPos(blockposition1), Blocks.END_PORTAL.defaultBlockState()); -+ this.setBlock(generatoraccessseed, new BlockPos(blockposition1), Blocks.END_PORTAL.defaultBlockState()); - } else { -- this.setBlock(world, new BlockPos(blockposition1), Blocks.AIR.defaultBlockState()); -+ this.setBlock(generatoraccessseed, new BlockPos(blockposition1), Blocks.AIR.defaultBlockState()); - } - } - } - - for (int i = 0; i < 4; ++i) { -- this.setBlock(world, pos.above(i), Blocks.BEDROCK.defaultBlockState()); -+ this.setBlock(generatoraccessseed, blockposition.above(i), Blocks.BEDROCK.defaultBlockState()); - } - -- BlockPos blockposition2 = pos.above(2); -+ BlockPos blockposition2 = blockposition.above(2); - Iterator iterator1 = Direction.Plane.HORIZONTAL.iterator(); - - while (iterator1.hasNext()) { - Direction enumdirection = (Direction) iterator1.next(); - -- this.setBlock(world, blockposition2.relative(enumdirection), (BlockState) Blocks.WALL_TORCH.defaultBlockState().setValue(WallTorchBlock.FACING, enumdirection)); -+ this.setBlock(generatoraccessseed, blockposition2.relative(enumdirection), (BlockState) Blocks.WALL_TORCH.defaultBlockState().setValue(WallTorchBlock.FACING, enumdirection)); - } - - return true; diff --git a/patches/server-remapped/Add-StructureLocateEvent.patch b/patches/server/Add-StructureLocateEvent.patch similarity index 100% rename from patches/server-remapped/Add-StructureLocateEvent.patch rename to patches/server/Add-StructureLocateEvent.patch diff --git a/patches/server-remapped/Add-dropLeash-variable-to-EntityUnleashEvent.patch b/patches/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch similarity index 88% rename from patches/server-remapped/Add-dropLeash-variable-to-EntityUnleashEvent.patch rename to patches/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch index 474ca00fc3..0740c351dd 100644 --- a/patches/server-remapped/Add-dropLeash-variable-to-EntityUnleashEvent.patch +++ b/patches/server/Add-dropLeash-variable-to-EntityUnleashEvent.patch @@ -8,28 +8,20 @@ diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/n index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -0,0 +0,0 @@ import org.bukkit.event.entity.EntityTargetEvent; - import org.bukkit.event.entity.EntityTransformEvent; - import org.bukkit.event.entity.EntityUnleashEvent; - import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; -+import org.bukkit.event.player.PlayerUnleashEntityEvent; // Paper - // CraftBukkit end - - public abstract class Mob extends LivingEntity { @@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity { return InteractionResult.PASS; } else if (this.getLeashHolder() == player) { // CraftBukkit start - fire PlayerUnleashEntityEvent - if (CraftEventFactory.callPlayerUnleashEntityEvent(this, player).isCancelled()) { + // Paper start - drop leash variable -+ PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(this, player, !player.abilities.instabuild); ++ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(this, player, !player.getAbilities().instabuild); + if (event.isCancelled()) { + // Paper end ((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, this.getLeashHolder())); return InteractionResult.PASS; } // CraftBukkit end -- this.dropLeash(true, !player.abilities.instabuild); +- this.dropLeash(true, !player.getAbilities().instabuild); + this.dropLeash(true, event.isDropLeash()); // Paper - drop leash variable return InteractionResult.sidedSuccess(this.level.isClientSide); } else { @@ -73,8 +65,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit + this.dropLeash(true, event.isDropLeash()); + // Paper end - } - } + this.getAllSlots().forEach((itemstack) -> { + if (!itemstack.isEmpty()) itemstack.setCount(0); // CraftBukkit + }); diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java @@ -111,28 +104,19 @@ diff --git a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotE index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java +++ b/src/main/java/net/minecraft/world/entity/decoration/LeashFenceKnotEntity.java -@@ -0,0 +0,0 @@ import net.minecraft.world.phys.AABB; - import org.bukkit.craftbukkit.event.CraftEventFactory; - // CraftBukkit end - -+import org.bukkit.event.player.PlayerUnleashEntityEvent; // Paper -+ - public class LeashFenceKnotEntity extends HangingEntity { - - public LeashFenceKnotEntity(EntityType type, Level world) { @@ -0,0 +0,0 @@ public class LeashFenceKnotEntity extends HangingEntity { entityinsentient = (Mob) iterator.next(); if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) { // CraftBukkit start - if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, player).isCancelled()) { + // Paper start - drop leash variable -+ PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, player, !player.abilities.instabuild); ++ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, player, !player.getAbilities().instabuild); + if (event.isCancelled()) { + // Paper end die = false; continue; } -- entityinsentient.dropLeash(true, !player.abilities.instabuild); // false -> survival mode boolean +- entityinsentient.dropLeash(true, !player.getAbilities().instabuild); // false -> survival mode boolean + entityinsentient.dropLeash(true, event.isDropLeash()); // false -> survival mode boolean // Paper - drop leash variable // CraftBukkit end } diff --git a/patches/server-remapped/Add-sendOpLevel-API.patch b/patches/server/Add-sendOpLevel-API.patch similarity index 99% rename from patches/server-remapped/Add-sendOpLevel-API.patch rename to patches/server/Add-sendOpLevel-API.patch index 46ca822861..ed45760712 100644 --- a/patches/server-remapped/Add-sendOpLevel-API.patch +++ b/patches/server/Add-sendOpLevel-API.patch @@ -62,4 +62,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } // Paper end - // Spigot start + @Override diff --git a/patches/server-remapped/Add-toggle-for-always-placing-the-dragon-egg.patch b/patches/server/Add-toggle-for-always-placing-the-dragon-egg.patch similarity index 94% rename from patches/server-remapped/Add-toggle-for-always-placing-the-dragon-egg.patch rename to patches/server/Add-toggle-for-always-placing-the-dragon-egg.patch index 4633cc712e..acca36550c 100644 --- a/patches/server-remapped/Add-toggle-for-always-placing-the-dragon-egg.patch +++ b/patches/server/Add-toggle-for-always-placing-the-dragon-egg.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { - if (value != -1) entityPerChunkSaveLimits.put(type, value); - }); + private void perPlayerMobSpawns() { + perPlayerMobSpawns = getBoolean("per-player-mob-spawns", false); } + + public boolean enderDragonsDeathAlwaysPlacesDragonEgg = false; @@ -18,6 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + enderDragonsDeathAlwaysPlacesDragonEgg = getBoolean("ender-dragons-death-always-places-dragon-egg", enderDragonsDeathAlwaysPlacesDragonEgg); + } } + diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java diff --git a/patches/server/Added-PlayerStonecutterRecipeSelectEvent.patch b/patches/server/Added-PlayerStonecutterRecipeSelectEvent.patch new file mode 100644 index 0000000000..a572cf9e23 --- /dev/null +++ b/patches/server/Added-PlayerStonecutterRecipeSelectEvent.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Fri, 27 Nov 2020 17:14:27 -0800 +Subject: [PATCH] Added PlayerStonecutterRecipeSelectEvent + +Co-Authored-By: MiniDigger | Martin + +diff --git a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java ++++ b/src/main/java/net/minecraft/world/inventory/StonecutterMenu.java +@@ -0,0 +0,0 @@ public class StonecutterMenu extends AbstractContainerMenu { + + public StonecutterMenu(int syncId, Inventory playerInventory, final ContainerLevelAccess context) { + super(MenuType.STONECUTTER, syncId); +- this.selectedRecipeIndex = DataSlot.standalone(); ++ this.selectedRecipeIndex = addDataSlot(DataSlot.shared(new int[1], 0)); // Paper - allow replication + this.recipes = Lists.newArrayList(); + this.input = ItemStack.EMPTY; + this.slotUpdateListener = () -> { +@@ -0,0 +0,0 @@ public class StonecutterMenu extends AbstractContainerMenu { + @Override + public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) { + if (this.isValidRecipeIndex(id)) { +- this.selectedRecipeIndex.set(id); ++ // Paper start ++ int recipeIndex = id; ++ this.selectedRecipeIndex.set(recipeIndex); ++ this.selectedRecipeIndex.checkAndClearUpdateFlag(); // mark as changed ++ if (this.isValidRecipeIndex(id)) { ++ io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent event = new io.papermc.paper.event.player.PlayerStonecutterRecipeSelectEvent((Player) player.getBukkitEntity(), (org.bukkit.inventory.StonecutterInventory) getBukkitView().getTopInventory(), (org.bukkit.inventory.StonecuttingRecipe) this.getRecipes().get(id).toBukkitRecipe()); ++ if (!event.callEvent()) { ++ ((Player) player.getBukkitEntity()).updateInventory(); ++ return false; ++ } ++ int newRecipeIndex; ++ if (!this.getRecipes().get(recipeIndex).getId().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()))) { // If the recipe did NOT stay the same ++ for (newRecipeIndex = 0; newRecipeIndex < this.getRecipes().size(); newRecipeIndex++) { ++ if (this.getRecipes().get(newRecipeIndex).getId().equals(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(event.getStonecuttingRecipe().getKey()))) { ++ recipeIndex = newRecipeIndex; ++ break; ++ } ++ } ++ } ++ } ++ ((Player) player.getBukkitEntity()).updateInventory(); ++ this.selectedRecipeIndex.set(recipeIndex); // set new index, so that listeners can read it ++ // Paper end + this.setupResultSlot(); + } + diff --git a/patches/server-remapped/Added-Vanilla-Entity-Tags.patch b/patches/server/Added-Vanilla-Entity-Tags.patch similarity index 92% rename from patches/server-remapped/Added-Vanilla-Entity-Tags.patch rename to patches/server/Added-Vanilla-Entity-Tags.patch index 12c4aa15df..1ac4368de4 100644 --- a/patches/server-remapped/Added-Vanilla-Entity-Tags.patch +++ b/patches/server/Added-Vanilla-Entity-Tags.patch @@ -30,12 +30,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean isTagged(EntityType item) { -+ return getHandle().isTagged(CraftMagicNumbers.getEntityTypes(item)); ++ return getHandle().contains(CraftMagicNumbers.getEntityTypes(item)); + } + + @Override + public Set getValues() { -+ return Collections.unmodifiableSet(getHandle().getTagged().stream().map(CraftMagicNumbers::getEntityType).collect(Collectors.toSet())); ++ return Collections.unmodifiableSet(getHandle().getValues().stream().map(CraftMagicNumbers::getEntityType).collect(Collectors.toSet())); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -45,11 +45,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public final class CraftServer implements Server { Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type"); - return (org.bukkit.Tag) new CraftFluidTag(console.getTags().getFluids(), key); + return (org.bukkit.Tag) new CraftFluidTag(FluidTags.getAllTags(), key); + // Paper start + case org.bukkit.Tag.REGISTRY_ENTITIES: + Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity namespace must have entitytype type"); -+ return (org.bukkit.Tag) new io.papermc.paper.CraftEntityTag(console.getTags().getEntityTypes(), key); ++ return (org.bukkit.Tag) new io.papermc.paper.CraftEntityTag(net.minecraft.tags.EntityTypeTags.getAllTags(), key); + // Paper end default: throw new IllegalArgumentException(); diff --git a/patches/server-remapped/Added-firing-of-PlayerChangeBeaconEffectEvent.patch b/patches/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch similarity index 64% rename from patches/server-remapped/Added-firing-of-PlayerChangeBeaconEffectEvent.patch rename to patches/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch index 30d1ee9c92..53a437635b 100644 --- a/patches/server-remapped/Added-firing-of-PlayerChangeBeaconEffectEvent.patch +++ b/patches/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch @@ -8,17 +8,6 @@ diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/m index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java +++ b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java -@@ -0,0 +0,0 @@ import net.minecraft.world.level.block.Blocks; - import org.bukkit.craftbukkit.inventory.CraftInventoryView; - // CraftBukkit end - -+// Paper start -+import io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent; -+// Paper end -+ - public class BeaconMenu extends AbstractContainerMenu { - - private final Container beacon; @@ -0,0 +0,0 @@ public class BeaconMenu extends AbstractContainerMenu { public void updateEffects(int primaryEffectId, int secondaryEffectId) { @@ -26,12 +15,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - this.beaconData.set(1, primaryEffectId); - this.beaconData.set(2, secondaryEffectId); + // Paper start -+ PlayerChangeBeaconEffectEvent event = new PlayerChangeBeaconEffectEvent((org.bukkit.entity.Player) this.player.player.getBukkitEntity(), org.bukkit.potion.PotionEffectType.getById(primaryEffectId), org.bukkit.potion.PotionEffectType.getById(secondaryEffectId), this.access.getLocation().getBlock()); ++ io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent event = new io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent((org.bukkit.entity.Player) this.player.player.getBukkitEntity(), org.bukkit.potion.PotionEffectType.getById(primaryEffectId), org.bukkit.potion.PotionEffectType.getById(secondaryEffectId), this.access.getLocation().getBlock()); + if (event.callEvent()) { + this.beaconData.set(1, event.getPrimary() == null ? 0 : event.getPrimary().getId()); + this.beaconData.set(2, event.getSecondary() == null ? 0 : event.getSecondary().getId()); + if (!event.willConsumeItem()) return; - this.paymentSlot.a(1); + this.paymentSlot.remove(1); + } + // Paper end } diff --git a/patches/server-remapped/Collision-option-for-requiring-a-player-participant.patch b/patches/server/Collision-option-for-requiring-a-player-participant.patch similarity index 99% rename from patches/server-remapped/Collision-option-for-requiring-a-player-participant.patch rename to patches/server/Collision-option-for-requiring-a-player-participant.patch index 7a843026ac..df0094b0a3 100644 --- a/patches/server-remapped/Collision-option-for-requiring-a-player-participant.patch +++ b/patches/server/Collision-option-for-requiring-a-player-participant.patch @@ -31,7 +31,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 public void push(Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { diff --git a/patches/server-remapped/Configurable-max-leash-distance.patch b/patches/server/Configurable-max-leash-distance.patch similarity index 100% rename from patches/server-remapped/Configurable-max-leash-distance.patch rename to patches/server/Configurable-max-leash-distance.patch diff --git a/patches/server-remapped/EntityMoveEvent.patch b/patches/server/EntityMoveEvent.patch similarity index 63% rename from patches/server-remapped/EntityMoveEvent.patch rename to patches/server/EntityMoveEvent.patch index 6e7b36fd67..d0da40ed9d 100644 --- a/patches/server-remapped/EntityMoveEvent.patch +++ b/patches/server/EntityMoveEvent.patch @@ -8,20 +8,12 @@ diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -0,0 +0,0 @@ import io.netty.buffer.ByteBuf; - import io.netty.buffer.ByteBufOutputStream; - import io.netty.buffer.Unpooled; - import io.papermc.paper.adventure.PaperAdventure; // Paper -+import io.papermc.paper.event.entity.EntityMoveEvent; - import it.unimi.dsi.fastutil.longs.LongIterator; - import java.awt.image.BufferedImage; - import java.io.BufferedWriter; @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper -+ worldserver.hasEntityMoveEvent = EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - HopperBlockEntity.skipHopperEvents = worldserver.paperConfig.disableHopperMoveEvents || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper ++ worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper + net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig.disableHopperMoveEvents || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper this.profiler.push(() -> { diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -33,31 +25,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public final UUID uuid; public boolean hasPhysicsEvent = true; // Paper + public boolean hasEntityMoveEvent = false; // Paper - private static Throwable getAddToWorldStackTrace(Entity entity) { + public static Throwable getAddToWorldStackTrace(Entity entity) { return new Throwable(entity + " Added to world at " + new java.util.Date()); } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -0,0 +0,0 @@ import com.mojang.datafixers.util.Pair; - import com.mojang.serialization.DataResult; - import com.mojang.serialization.Dynamic; - import com.mojang.serialization.DynamicOps; -+import io.papermc.paper.event.entity.EntityMoveEvent; - import java.util.Collection; - import java.util.ConcurrentModificationException; - import java.util.Iterator; @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity { this.pushEntities(); this.level.getProfiler().pop(); + // Paper start -+ if (((ServerLevel) level).hasEntityMoveEvent) { -+ if (xo != getX() || yo != getY() || zo != getZ() || yRotO != yRot || xRotO != xRot) { -+ Location from = new Location(level.getWorld(), xo, yo, zo, yRotO, xRotO); -+ Location to = new Location (level.getWorld(), getX(), getY(), getZ(), yRot, xRot); -+ EntityMoveEvent event = new EntityMoveEvent(getBukkitLivingEntity(), from, to.clone()); ++ if (((ServerLevel) this.level).hasEntityMoveEvent) { ++ if (this.xo != getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { ++ Location from = new Location(this.level.getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); ++ Location to = new Location (this.level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); ++ io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone()); + if (!event.callEvent()) { + absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch()); + } else if (!to.equals(event.getTo())) { diff --git a/patches/server-remapped/Fix-console-spam-when-removing-chests-in-water.patch b/patches/server/Fix-console-spam-when-removing-chests-in-water.patch similarity index 100% rename from patches/server-remapped/Fix-console-spam-when-removing-chests-in-water.patch rename to patches/server/Fix-console-spam-when-removing-chests-in-water.patch diff --git a/patches/server-remapped/Fix-villager-boat-exploit.patch b/patches/server/Fix-villager-boat-exploit.patch similarity index 54% rename from patches/server-remapped/Fix-villager-boat-exploit.patch rename to patches/server/Fix-villager-boat-exploit.patch index 9da6751b77..2ab1f737b3 100644 --- a/patches/server-remapped/Fix-villager-boat-exploit.patch +++ b/patches/server/Fix-villager-boat-exploit.patch @@ -8,27 +8,19 @@ diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -0,0 +0,0 @@ import net.minecraft.util.Mth; - import net.minecraft.world.effect.MobEffectInstance; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.EntityType; -+import net.minecraft.world.entity.npc.AbstractVillager; - import net.minecraft.world.level.ChunkPos; - import net.minecraft.world.level.GameRules; - import net.minecraft.world.level.GameType; @@ -0,0 +0,0 @@ public abstract class PlayerList { - - for (Iterator iterator = entity.getIndirectPassengers().iterator(); iterator.hasNext(); entity1.removed = true) { - entity1 = (Entity) iterator.next(); + PlayerList.LOGGER.debug("Removing player mount"); + entityplayer.stopRiding(); + entity.getPassengersAndSelf().forEach((entity1) -> { + // Paper start -+ if (entity1 instanceof AbstractVillager) { -+ final AbstractVillager villager = (AbstractVillager) entity1; ++ if (entity1 instanceof net.minecraft.world.entity.npc.AbstractVillager) { ++ final net.minecraft.world.entity.npc.AbstractVillager villager = (net.minecraft.world.entity.npc.AbstractVillager) entity1; + final net.minecraft.world.entity.player.Player human = villager.getTradingPlayer(); + if (human != null) { + villager.setTradingPlayer(null); + } + } + // Paper end - worldserver.despawn(entity1); - } - + entity1.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER); + }); + } diff --git a/patches/server-remapped/Implement-BlockPreDispenseEvent.patch b/patches/server/Implement-BlockPreDispenseEvent.patch similarity index 61% rename from patches/server-remapped/Implement-BlockPreDispenseEvent.patch rename to patches/server/Implement-BlockPreDispenseEvent.patch index 0b7e93447f..1d8c2cfee7 100644 --- a/patches/server-remapped/Implement-BlockPreDispenseEvent.patch +++ b/patches/server/Implement-BlockPreDispenseEvent.patch @@ -12,30 +12,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 DispenseItemBehavior idispensebehavior = this.getDispenseMethod(itemstack); if (idispensebehavior != DispenseItemBehavior.NOOP) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(worldserver, pos, itemstack, i)) return; // Paper - BlockPreDispenseEvent is called here - eventFired = false; // CraftBukkit - reset event status ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(world, pos, itemstack, i)) return; // Paper - BlockPreDispenseEvent is called here + DispenserBlock.eventFired = false; // CraftBukkit - reset event status tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack)); } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -0,0 +0,0 @@ import net.minecraft.world.phys.BlockHitResult; - import net.minecraft.world.phys.EntityHitResult; - import net.minecraft.world.phys.HitResult; - import net.minecraft.world.phys.Vec3; -+import io.papermc.paper.event.block.BlockPreDispenseEvent; // Paper - import org.bukkit.Bukkit; - import org.bukkit.Location; // Paper - import org.bukkit.Material; @@ -0,0 +0,0 @@ public class CraftEventFactory { - BlockFailedDispenseEvent event = new BlockFailedDispenseEvent(block); + io.papermc.paper.event.block.BlockFailedDispenseEvent event = new io.papermc.paper.event.block.BlockFailedDispenseEvent(block); return event.callEvent(); } + -+ public static boolean handleBlockPreDispenseEvent(ServerLevel worldserver, BlockPos blockposition, ItemStack itemStack, int slot) { -+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); -+ BlockPreDispenseEvent event = new BlockPreDispenseEvent(block, org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), slot); ++ public static boolean handleBlockPreDispenseEvent(ServerLevel serverLevel, BlockPos pos, ItemStack itemStack, int slot) { ++ org.bukkit.block.Block block = serverLevel.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ io.papermc.paper.event.block.BlockPreDispenseEvent event = new io.papermc.paper.event.block.BlockPreDispenseEvent(block, org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), slot); + return event.callEvent(); + } // Paper end diff --git a/patches/server/Make-schedule-command-per-world.patch b/patches/server/Make-schedule-command-per-world.patch new file mode 100644 index 0000000000..4c5b15bfd2 --- /dev/null +++ b/patches/server/Make-schedule-command-per-world.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Mon, 4 Jan 2021 19:52:44 -0800 +Subject: [PATCH] Make schedule command per-world + + +diff --git a/src/main/java/net/minecraft/server/commands/ScheduleCommand.java b/src/main/java/net/minecraft/server/commands/ScheduleCommand.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/commands/ScheduleCommand.java ++++ b/src/main/java/net/minecraft/server/commands/ScheduleCommand.java +@@ -0,0 +0,0 @@ public class ScheduleCommand { + return new TranslatableComponent("commands.schedule.cleared.failure", eventName); + }); + private static final SuggestionProvider SUGGEST_SCHEDULE = (context, builder) -> { +- return SharedSuggestionProvider.suggest(context.getSource().getServer().getWorldData().overworldData().getScheduledEvents().getEventsIds(), builder); ++ return SharedSuggestionProvider.suggest(context.getSource().getLevel().serverLevelData.overworldData().getScheduledEvents().getEventsIds(), builder); // Paper + }; + + public static void register(CommandDispatcher dispatcher) { +@@ -0,0 +0,0 @@ public class ScheduleCommand { + } else { + long l = source.getLevel().getGameTime() + (long)time; + ResourceLocation resourceLocation = function.getFirst(); +- TimerQueue timerQueue = source.getServer().getWorldData().overworldData().getScheduledEvents(); ++ TimerQueue timerQueue = source.getLevel().serverLevelData.getScheduledEvents(); // Paper + function.getSecond().ifLeft((functionx) -> { + String string = resourceLocation.toString(); + if (replace) { +@@ -0,0 +0,0 @@ public class ScheduleCommand { + } + + private static int remove(CommandSourceStack source, String eventName) throws CommandSyntaxException { +- int i = source.getServer().getWorldData().overworldData().getScheduledEvents().remove(eventName); ++ int i = source.getLevel().serverLevelData.getScheduledEvents().remove(eventName); // Paper + if (i == 0) { + throw ERROR_CANT_REMOVE.create(eventName); + } else { diff --git a/patches/server-remapped/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch b/patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch similarity index 96% rename from patches/server-remapped/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch rename to patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch index 4d77d291ff..3d1ede7e19 100644 --- a/patches/server-remapped/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch +++ b/patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class AbstractHurtingProjectile extends Projectile { // CraftBukkit start - Fire ProjectileHitEvent - if (this.removed) { + if (this.isRemoved()) { - CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); + // CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Paper - this is an undesired duplicate event } diff --git a/patches/server-remapped/Reset-shield-blocking-on-dimension-change.patch b/patches/server/Reset-shield-blocking-on-dimension-change.patch similarity index 90% rename from patches/server-remapped/Reset-shield-blocking-on-dimension-change.patch rename to patches/server/Reset-shield-blocking-on-dimension-change.patch index ead28011ed..8b932d8808 100644 --- a/patches/server-remapped/Reset-shield-blocking-on-dimension-change.patch +++ b/patches/server/Reset-shield-blocking-on-dimension-change.patch @@ -8,7 +8,7 @@ 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 { +@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { this.level.getCraftServer().getPluginManager().callEvent(changeEvent); // CraftBukkit end } diff --git a/patches/server-remapped/Return-chat-component-with-empty-text-instead-of-thr.patch b/patches/server/Return-chat-component-with-empty-text-instead-of-thr.patch similarity index 100% rename from patches/server-remapped/Return-chat-component-with-empty-text-instead-of-thr.patch rename to patches/server/Return-chat-component-with-empty-text-instead-of-thr.patch diff --git a/patches/server-remapped/Skip-distance-map-update-when-spawning-disabled.patch b/patches/server/Skip-distance-map-update-when-spawning-disabled.patch similarity index 100% rename from patches/server-remapped/Skip-distance-map-update-when-spawning-disabled.patch rename to patches/server/Skip-distance-map-update-when-spawning-disabled.patch diff --git a/patches/server/add-DragonEggFormEvent.patch b/patches/server/add-DragonEggFormEvent.patch new file mode 100644 index 0000000000..db6e96e172 --- /dev/null +++ b/patches/server/add-DragonEggFormEvent.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Trigary +Date: Mon, 25 Jan 2021 14:53:57 +0100 +Subject: [PATCH] add DragonEggFormEvent + + +diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java ++++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java +@@ -0,0 +0,0 @@ public class EndDragonFight { + this.dragonEvent.setVisible(false); + this.spawnExitPortal(true); + this.spawnNewGateway(); ++ // Paper start - DragonEggFormEvent ++ BlockPos eggPosition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION); ++ org.bukkit.craftbukkit.block.CraftBlock eggBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, eggPosition); ++ org.bukkit.craftbukkit.block.CraftBlockState eggState = new org.bukkit.craftbukkit.block.CraftBlockState(eggBlock); ++ eggState.setData(Blocks.DRAGON_EGG.defaultBlockState()); ++ io.papermc.paper.event.block.DragonEggFormEvent eggEvent = new io.papermc.paper.event.block.DragonEggFormEvent(eggBlock, eggState, ++ new org.bukkit.craftbukkit.boss.CraftDragonBattle(this)); ++ // Paper end - DragonEggFormEvent + if (this.level.paperConfig.enderDragonsDeathAlwaysPlacesDragonEgg || !this.previouslyKilled) { // Paper - always place dragon egg +- this.level.setBlockAndUpdate(this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION), Blocks.DRAGON_EGG.defaultBlockState()); ++ // Paper start - DragonEggFormEvent ++ //this.world.setTypeUpdate(this.world.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, WorldGenEndTrophy.a), Blocks.DRAGON_EGG.getBlockData()); ++ } else { ++ eggEvent.setCancelled(true); ++ } ++ if (eggEvent.callEvent()) { ++ eggEvent.getNewState().update(true); + } ++ // Paper end - DragonEggFormEvent + + this.previouslyKilled = true; + this.dragonKilled = true; diff --git a/patches/server-remapped/added-Wither-API.patch b/patches/server/added-Wither-API.patch similarity index 82% rename from patches/server-remapped/added-Wither-API.patch rename to patches/server/added-Wither-API.patch index efda7a4c25..30377fb621 100644 --- a/patches/server-remapped/added-Wither-API.patch +++ b/patches/server/added-Wither-API.patch @@ -8,10 +8,10 @@ diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements RangedAttackMob { +@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob return entityliving.getMobType() != MobType.UNDEAD && entityliving.attackable(); }; - private static final TargetingConditions TARGETING_CONDITIONS = (new TargetingConditions()).range(20.0D).selector(WitherBoss.LIVING_ENTITY_SELECTOR); + private static final TargetingConditions TARGETING_CONDITIONS = TargetingConditions.forCombat().range(20.0D).selector(WitherBoss.LIVING_ENTITY_SELECTOR); + // Paper start + private boolean canPortal = false; + @@ -20,15 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public WitherBoss(EntityType type, Level world) { super(type, world); -@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements RangedAttackMob { - this.entityData.set((EntityDataAccessor) WitherBoss.DATA_TARGETS.get(headIndex), id); - } - -+ public final boolean isPowered() { return this.isPowered(); } // Paper - OBFHELPER - public boolean isPowered() { - return this.getHealth() <= this.getMaxHealth() / 2.0F; - } -@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements RangedAttackMob { +@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob @Override public boolean canChangeDimensions() { @@ -43,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java @@ -0,0 +0,0 @@ public class CraftWither extends CraftMonster implements Wither, com.destroystok public BossBar getBossBar() { - return bossBar; + return this.bossBar; } + + // Paper start