diff --git a/patches/api/Add-StructuresLocateEvent.patch b/patches/api/Add-StructuresLocateEvent.patch index fbe9c1c60e..c83d699f4f 100644 --- a/patches/api/Add-StructuresLocateEvent.patch +++ b/patches/api/Add-StructuresLocateEvent.patch @@ -393,6 +393,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public static final Reference RUINED_PORTAL_MOUNTAIN = create("ruined_portal_mountain"); + public static final Reference RUINED_PORTAL_OCEAN = create("ruined_portal_ocean"); + public static final Reference RUINED_PORTAL_NETHER = create("ruined_portal_nether"); ++ public static final Reference ANCIENT_CITY = create("ancient_city"); + + private final NamespacedKey key; + private final StructureType structureType; diff --git a/patches/unapplied/server/Add-EntityLoadCrossbowEvent.patch b/patches/server/Add-EntityLoadCrossbowEvent.patch similarity index 100% rename from patches/unapplied/server/Add-EntityLoadCrossbowEvent.patch rename to patches/server/Add-EntityLoadCrossbowEvent.patch diff --git a/patches/unapplied/server/Add-PaperRegistry.patch b/patches/server/Add-PaperRegistry.patch similarity index 99% rename from patches/unapplied/server/Add-PaperRegistry.patch rename to patches/server/Add-PaperRegistry.patch index def6301a52..248c8c26c4 100644 --- a/patches/unapplied/server/Add-PaperRegistry.patch +++ b/patches/server/Add-PaperRegistry.patch @@ -180,7 +180,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.packRepository.setSelected(dataPacks); this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository)); this.resources.managers.updateRegistryTags(this.registryAccess()); -+ io.papermc.paper.PaperRegistry.clearCaches(); // Paper ++ io.papermc.paper.registry.PaperRegistry.clearCaches(); // Paper new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper if (Thread.currentThread() != this.serverThread) return; // Paper //this.getPlayerList().saveAll(); // Paper - we don't need to do this diff --git a/patches/unapplied/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch b/patches/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch similarity index 100% rename from patches/unapplied/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch rename to patches/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch diff --git a/patches/unapplied/server/Add-StructuresLocateEvent.patch b/patches/server/Add-StructuresLocateEvent.patch similarity index 62% rename from patches/unapplied/server/Add-StructuresLocateEvent.patch rename to patches/server/Add-StructuresLocateEvent.patch index e44e751051..970a5b04cb 100644 --- a/patches/unapplied/server/Add-StructuresLocateEvent.patch +++ b/patches/server/Add-StructuresLocateEvent.patch @@ -15,12 +15,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.world.structure.ConfiguredStructure; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; -+import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; ++import net.minecraft.world.level.levelgen.structure.Structure; import org.bukkit.Keyed; public record RegistryKey(Class apiClass, ResourceKey> resourceKey) { + -+ public static final RegistryKey> CONFIGURED_STRUCTURE_REGISTRY = new RegistryKey<>(ConfiguredStructure.class, Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY); ++ public static final RegistryKey CONFIGURED_STRUCTURE_REGISTRY = new RegistryKey<>(ConfiguredStructure.class, Registry.STRUCTURE_REGISTRY); + } diff --git a/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java b/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java @@ -35,8 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.registry.RegistryKey; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceLocation; -+import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; -+import net.minecraft.world.level.levelgen.feature.StructureFeature; ++import net.minecraft.world.level.levelgen.structure.Structure; +import org.bukkit.NamespacedKey; +import org.bukkit.StructureType; +import org.checkerframework.checker.nullness.qual.NonNull; @@ -55,52 +54,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + new ConfiguredStructureRegistry().register(); + } + -+ static final class ConfiguredStructureRegistry extends PaperRegistry> { ++ static final class ConfiguredStructureRegistry extends PaperRegistry { + -+ private static final Supplier>> STRUCTURE_FEATURE_REGISTRY = registryFor(Registry.STRUCTURE_FEATURE_REGISTRY); ++ private static final Supplier> STRUCTURE_FEATURE_REGISTRY = registryFor(Registry.STRUCTURE_REGISTRY); + + public ConfiguredStructureRegistry() { + super(RegistryKey.CONFIGURED_STRUCTURE_REGISTRY); + } + + @Override -+ public ConfiguredStructure convertToApi(NamespacedKey key, ConfiguredStructureFeature nms) { -+ final ResourceLocation structureFeatureLoc = Objects.requireNonNull(STRUCTURE_FEATURE_REGISTRY.get().getKey(nms.feature)); -+ final StructureType structureType = Objects.requireNonNull(StructureType.getStructureTypes().get(structureFeatureLoc.getPath()), structureFeatureLoc + " could not be converted to an API type"); ++ public ConfiguredStructure convertToApi(NamespacedKey key, Structure nms) { ++ final ResourceLocation structureTypeLoc = Objects.requireNonNull(Registry.STRUCTURE_TYPES.getKey(nms.type()), "unexpected structure type " + nms.type()); ++ final StructureType structureType = Objects.requireNonNull(StructureType.getStructureTypes().get(structureTypeLoc.getPath()), structureTypeLoc + " could not be converted to an API type"); // TODO this is just not gonna work until upstream fixes their StructureType pseudo-enum + return new ConfiguredStructure(key, structureType); + } + } +} -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -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 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop>> findNearestMapFeature(ServerLevel worldserver, HolderSet> holderset, BlockPos center, int radius, boolean skipExistingChunks) { + public Pair> findNearestMapStructure(ServerLevel world, HolderSet structures, BlockPos center, int radius, boolean skipReferencedStructures) { + // Paper start - StructureLocateEvent -+ final org.bukkit.World world = worldserver.getWorld(); -+ final org.bukkit.Location origin = net.minecraft.server.MCUtil.toLocation(worldserver, center); ++ final org.bukkit.World bukkitWorld = world.getWorld(); ++ final org.bukkit.Location origin = net.minecraft.server.MCUtil.toLocation(world, center); + final var paperRegistry = io.papermc.paper.registry.PaperRegistry.getRegistry(io.papermc.paper.registry.RegistryKey.CONFIGURED_STRUCTURE_REGISTRY); + final List configuredStructures = new ArrayList<>(); -+ for (Holder> holder : holderset) { ++ for (Holder holder : structures) { + configuredStructures.add(paperRegistry.convertToApi(holder)); + } -+ final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(world, origin, configuredStructures, radius, skipExistingChunks); ++ final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(bukkitWorld, origin, configuredStructures, radius, skipReferencedStructures); + if (!event.callEvent()) { + return null; + } @@ -109,24 +95,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + center = net.minecraft.server.MCUtil.toBlockPosition(event.getOrigin()); + radius = event.getRadius(); -+ skipExistingChunks = event.shouldFindUnexplored(); -+ holderset = HolderSet.direct(paperRegistry::getMinecraftHolder, event.getConfiguredStructures()); ++ skipReferencedStructures = event.shouldFindUnexplored(); ++ structures = HolderSet.direct(paperRegistry::getMinecraftHolder, event.getConfiguredStructures()); + // Paper end - Set> set = (Set) holderset.stream().flatMap((holder) -> { - return ((ConfiguredStructureFeature) holder.value()).biomes().stream(); - }).collect(Collectors.toSet()); -diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/ConfiguredStructureFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/ConfiguredStructureFeature.java + Map>> map = new Object2ObjectArrayMap(); + Iterator iterator = structures.iterator(); + +diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java b/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/feature/ConfiguredStructureFeature.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/ConfiguredStructureFeature.java -@@ -0,0 +0,0 @@ public class ConfiguredStructureFeature biomes; - public final Map spawnOverrides; - public final boolean adaptNoise; +--- a/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java ++++ b/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java +@@ -0,0 +0,0 @@ public abstract class Structure { + public static final Codec DIRECT_CODEC = Registry.STRUCTURE_TYPES.byNameCodec().dispatch(Structure::type, StructureType::codec); + public static final Codec> CODEC = RegistryFileCodec.create(Registry.STRUCTURE_REGISTRY, DIRECT_CODEC); + protected final Structure.StructureSettings settings; + static { io.papermc.paper.world.structure.PaperConfiguredStructure.init(); } // Paper - public ConfiguredStructureFeature(F feature, FC config, HolderSet biomes, boolean bl, Map map) { - this.feature = feature; + public static RecordCodecBuilder settingsCodec(RecordCodecBuilder.Instance instance) { + return Structure.StructureSettings.CODEC.forGetter((feature) -> { diff --git a/src/test/java/io/papermc/paper/world/structure/ConfiguredStructureTest.java b/src/test/java/io/papermc/paper/world/structure/ConfiguredStructureTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -140,7 +126,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.Bootstrap; -+import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; ++import net.minecraft.world.level.levelgen.structure.Structure; +import net.minecraft.world.level.levelgen.structure.BuiltinStructures; +import org.bukkit.NamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; @@ -186,11 +172,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Test + public void testMinecraftToApi() { -+ assertEquals("configured structure maps should be the same size", BUILT_IN_STRUCTURES.size(), BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.size()); ++ assertEquals("configured structure maps should be the same size", BUILT_IN_STRUCTURES.size(), BuiltinRegistries.STRUCTURES.size()); + -+ Map> missing = new LinkedHashMap<>(); -+ for (ConfiguredStructureFeature feature : BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE) { -+ final ResourceLocation key = BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.getKey(feature); ++ Map missing = new LinkedHashMap<>(); ++ for (Structure feature : BuiltinRegistries.STRUCTURES) { ++ final ResourceLocation key = BuiltinRegistries.STRUCTURES.getKey(feature); + assertNotNull("Missing built-in registry key", key); + if (DEFAULT_CONFIGURED_STRUCTURES.get(CraftNamespacedKey.fromMinecraft(key)) == null) { + missing.put(key, feature); @@ -203,11 +189,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Test + public void testApiToMinecraft() { + for (NamespacedKey apiKey : DEFAULT_CONFIGURED_STRUCTURES.keySet()) { -+ assertTrue(apiKey + " does not have a minecraft counterpart", BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.containsKey(CraftNamespacedKey.toMinecraft(apiKey))); ++ assertTrue(apiKey + " does not have a minecraft counterpart", BuiltinRegistries.STRUCTURES.containsKey(CraftNamespacedKey.toMinecraft(apiKey))); + } + } + -+ private static String printMissing(Map> missing) { ++ private static String printMissing(Map missing) { + final StringJoiner joiner = new StringJoiner("\n", "Missing: \n", ""); + + missing.forEach((key, configuredFeature) -> { diff --git a/patches/unapplied/server/Add-sendOpLevel-API.patch b/patches/server/Add-sendOpLevel-API.patch similarity index 97% rename from patches/unapplied/server/Add-sendOpLevel-API.patch rename to patches/server/Add-sendOpLevel-API.patch index 8c68ed6470..06df0474fe 100644 --- a/patches/unapplied/server/Add-sendOpLevel-API.patch +++ b/patches/server/Add-sendOpLevel-API.patch @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } // Paper } - // Paper start + public boolean isWhiteListed(GameProfile profile) { 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 diff --git a/patches/unapplied/server/Added-PlayerLecternPageChangeEvent.patch b/patches/server/Added-PlayerLecternPageChangeEvent.patch similarity index 100% rename from patches/unapplied/server/Added-PlayerLecternPageChangeEvent.patch rename to patches/server/Added-PlayerLecternPageChangeEvent.patch diff --git a/patches/unapplied/server/Added-PlayerLoomPatternSelectEvent.patch b/patches/server/Added-PlayerLoomPatternSelectEvent.patch similarity index 52% rename from patches/unapplied/server/Added-PlayerLoomPatternSelectEvent.patch rename to patches/server/Added-PlayerLoomPatternSelectEvent.patch index 799661d6d9..177fb66f1c 100644 --- a/patches/unapplied/server/Added-PlayerLoomPatternSelectEvent.patch +++ b/patches/server/Added-PlayerLoomPatternSelectEvent.patch @@ -11,24 +11,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class LoomMenu extends AbstractContainerMenu { @Override public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) { - if (id > 0 && id <= BannerPattern.AVAILABLE_PATTERNS) { + if (id >= 0 && id < this.selectablePatterns.size()) { - this.selectedBannerPatternIndex.set(id); +- this.setupResultSlot((Holder) this.selectablePatterns.get(id)); + // Paper start -+ int enumBannerPatternTypeOrdinal = id; -+ io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((Player) player.getBukkitEntity(), ((CraftInventoryLoom) getBukkitView().getTopInventory()), org.bukkit.block.banner.PatternType.getByIdentifier(BannerPattern.values()[id].getHashname())); ++ int selectablePatternIndex = id; ++ io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((Player) player.getBukkitEntity(), ((CraftInventoryLoom) getBukkitView().getTopInventory()), org.bukkit.block.banner.PatternType.getByIdentifier(this.selectablePatterns.get(selectablePatternIndex).value().getHashname())); + if (!event.callEvent()) { + ((Player) player.getBukkitEntity()).updateInventory(); + return false; + } -+ for (BannerPattern nms : BannerPattern.values()) { -+ if (event.getPatternType().getIdentifier().equals(nms.getHashname())) { -+ enumBannerPatternTypeOrdinal = nms.ordinal(); ++ Holder selectedPattern = null; ++ for (int i = 0; i < this.selectablePatterns.size(); i++) { ++ final Holder holder = this.selectablePatterns.get(i); ++ if (event.getPatternType().getIdentifier().equals(holder.value().getHashname())) { ++ selectablePatternIndex = i; ++ selectedPattern = holder; + break; + } + } ++ if (selectedPattern == null) { ++ for (BannerPattern pattern : Registry.BANNER_PATTERN) { ++ if (event.getPatternType().getIdentifier().equals(pattern.getHashname())) { ++ selectedPattern = Registry.BANNER_PATTERN.getHolder(Registry.BANNER_PATTERN.getId(pattern)).orElseThrow(); ++ break; ++ } ++ } ++ selectablePatternIndex = -1; ++ } + ((Player) player.getBukkitEntity()).updateInventory(); -+ this.selectedBannerPatternIndex.set(enumBannerPatternTypeOrdinal); ++ this.selectedBannerPatternIndex.set(selectablePatternIndex); ++ this.setupResultSlot(java.util.Objects.requireNonNull(selectedPattern, "selectedPattern was null, this is unexpected")); + // Paper end - this.setupResultSlot(); return true; } else { + return false; diff --git a/patches/unapplied/server/Added-ServerResourcesReloadedEvent.patch b/patches/server/Added-ServerResourcesReloadedEvent.patch similarity index 97% rename from patches/unapplied/server/Added-ServerResourcesReloadedEvent.patch rename to patches/server/Added-ServerResourcesReloadedEvent.patch index 78f6dbd2a0..bf001ec0de 100644 --- a/patches/unapplied/server/Added-ServerResourcesReloadedEvent.patch +++ b/patches/server/Added-ServerResourcesReloadedEvent.patch @@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - source.getServer().reloadResources(dataPacks).exceptionally((throwable) -> { + source.getServer().reloadResources(dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.COMMAND).exceptionally((throwable) -> { ReloadCommand.LOGGER.warn("Failed to execute reload", throwable); - source.sendFailure(new TranslatableComponent("commands.reload.failure")); + source.sendFailure(Component.translatable("commands.reload.failure")); return null; @@ -0,0 +0,0 @@ public class ReloadCommand { WorldData savedata = minecraftserver.getWorldData(); diff --git a/patches/unapplied/server/Added-WorldGameRuleChangeEvent.patch b/patches/server/Added-WorldGameRuleChangeEvent.patch similarity index 97% rename from patches/unapplied/server/Added-WorldGameRuleChangeEvent.patch rename to patches/server/Added-WorldGameRuleChangeEvent.patch index 383fd97f73..155a040df5 100644 --- a/patches/unapplied/server/Added-WorldGameRuleChangeEvent.patch +++ b/patches/server/Added-WorldGameRuleChangeEvent.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - t0.setFromArgument(context, "value"); + t0.setFromArgument(context, "value", key); // Paper - commandlistenerwrapper.sendSuccess(new TranslatableComponent("commands.gamerule.set", new Object[]{key.getId(), t0.toString()}), true); + commandlistenerwrapper.sendSuccess(Component.translatable("commands.gamerule.set", key.getId(), t0.toString()), true); return t0.getCommandResult(); } diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java diff --git a/patches/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch b/patches/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch new file mode 100644 index 0000000000..2df709fc5b --- /dev/null +++ b/patches/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Wed, 24 Jun 2020 15:14:51 -0600 +Subject: [PATCH] Added firing of PlayerChangeBeaconEffectEvent + + +diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java +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 @@ public class BeaconMenu extends AbstractContainerMenu { + public MobEffect getSecondaryEffect() { + return MobEffect.byId(this.beaconData.get(2)); + } ++ // Paper start ++ private static @Nullable org.bukkit.potion.PotionEffectType convert(Optional effect) { ++ return effect.flatMap(net.minecraft.core.Registry.MOB_EFFECT::getResourceKey).map(key -> { ++ return org.bukkit.potion.PotionEffectType.getByKey(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(key.location())); ++ }).orElse(null); ++ } ++ // Paper end + + public void updateEffects(Optional primary, Optional secondary) { + if (this.paymentSlot.hasItem()) { +- this.beaconData.set(1, (Integer) primary.map(MobEffect::getId).orElse(-1)); +- this.beaconData.set(2, (Integer) secondary.map(MobEffect::getId).orElse(-1)); ++ // Paper start ++ io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent event = new io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent((org.bukkit.entity.Player) this.player.player.getBukkitEntity(), convert(primary), convert(secondary), this.access.getLocation().getBlock()); ++ if (event.callEvent()) { ++ this.beaconData.set(1, event.getPrimary() == null ? -1 : event.getPrimary().getId()); ++ this.beaconData.set(2, event.getSecondary() == null ? -1 : event.getSecondary().getId()); ++ if (event.willConsumeItem()) { ++ // Paper end + this.paymentSlot.remove(1); ++ } + this.access.execute(Level::blockEntityChanged); ++ } // Paper end + } + + } diff --git a/patches/unapplied/server/Added-world-settings-for-mobs-picking-up-loot.patch b/patches/server/Added-world-settings-for-mobs-picking-up-loot.patch similarity index 84% rename from patches/unapplied/server/Added-world-settings-for-mobs-picking-up-loot.patch rename to patches/server/Added-world-settings-for-mobs-picking-up-loot.patch index 9e7f143a61..9c3bd24874 100644 --- a/patches/unapplied/server/Added-world-settings-for-mobs-picking-up-loot.patch +++ b/patches/server/Added-world-settings-for-mobs-picking-up-loot.patch @@ -28,11 +28,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java @@ -0,0 +0,0 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo - this.populateDefaultEquipmentSlots(difficulty); - this.populateDefaultEquipmentEnchantments(difficulty); + this.populateDefaultEquipmentSlots(randomsource, difficulty); + this.populateDefaultEquipmentEnchantments(randomsource, difficulty); this.reassessWeaponGoal(); -- this.setCanPickUpLoot(this.random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); -+ this.setCanPickUpLoot(this.level.paperConfig.skeletonsAlwaysCanPickUpLoot || this.random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper +- this.setCanPickUpLoot(randomsource.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); ++ this.setCanPickUpLoot(this.level.paperConfig.skeletonsAlwaysCanPickUpLoot || randomsource.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { LocalDate localdate = LocalDate.now(); int i = localdate.get(ChronoField.DAY_OF_MONTH); @@ -44,8 +44,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Object object = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt); float f = difficulty.getSpecialMultiplier(); -- this.setCanPickUpLoot(this.random.nextFloat() < 0.55F * f); -+ this.setCanPickUpLoot(this.level.paperConfig.zombiesAlwaysCanPickUpLoot || this.random.nextFloat() < 0.55F * f); // Paper +- this.setCanPickUpLoot(randomsource.nextFloat() < 0.55F * f); ++ this.setCanPickUpLoot(this.level.paperConfig.zombiesAlwaysCanPickUpLoot || randomsource.nextFloat() < 0.55F * f); // Paper if (object == null) { - object = new Zombie.ZombieGroupData(Zombie.getSpawnAsBabyOdds(world.getRandom()), true); + object = new Zombie.ZombieGroupData(Zombie.getSpawnAsBabyOdds(randomsource), true); } diff --git a/patches/unapplied/server/Additional-Block-Material-API-s.patch b/patches/server/Additional-Block-Material-API-s.patch similarity index 100% rename from patches/unapplied/server/Additional-Block-Material-API-s.patch rename to patches/server/Additional-Block-Material-API-s.patch diff --git a/patches/unapplied/server/Allow-disabling-mob-spawner-spawn-egg-transformation.patch b/patches/server/Allow-disabling-mob-spawner-spawn-egg-transformation.patch similarity index 100% rename from patches/unapplied/server/Allow-disabling-mob-spawner-spawn-egg-transformation.patch rename to patches/server/Allow-disabling-mob-spawner-spawn-egg-transformation.patch diff --git a/patches/unapplied/server/Cache-burn-durations.patch b/patches/server/Cache-burn-durations.patch similarity index 92% rename from patches/unapplied/server/Cache-burn-durations.patch rename to patches/server/Cache-burn-durations.patch index d6e4a4e829..0509c3836e 100644 --- a/patches/unapplied/server/Cache-burn-durations.patch +++ b/patches/server/Cache-burn-durations.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit - this.recipeType = recipeType; + this.recipeType = recipeType; // Paper } + private static Map cachedBurnDurations = null; // Paper - cache burn durations @@ -23,9 +23,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 AbstractFurnaceBlockEntity.add(map, (ItemLike) Items.LAVA_BUCKET, 20000); @@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit - AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.COMPOSTER, 300); AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.AZALEA, 100); AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.FLOWERING_AZALEA, 100); + AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.MANGROVE_ROOTS, 300); - return map; + // Paper start - cache burn durations + cachedBurnDurations = com.google.common.collect.ImmutableMap.copyOf(map); diff --git a/patches/unapplied/server/Collision-option-for-requiring-a-player-participant.patch b/patches/server/Collision-option-for-requiring-a-player-participant.patch similarity index 100% rename from patches/unapplied/server/Collision-option-for-requiring-a-player-participant.patch rename to patches/server/Collision-option-for-requiring-a-player-participant.patch diff --git a/patches/unapplied/server/Configurable-door-breaking-difficulty.patch b/patches/server/Configurable-door-breaking-difficulty.patch similarity index 98% rename from patches/unapplied/server/Configurable-door-breaking-difficulty.patch rename to patches/server/Configurable-door-breaking-difficulty.patch index f8128de55c..f89bf53629 100644 --- a/patches/unapplied/server/Configurable-door-breaking-difficulty.patch +++ b/patches/server/Configurable-door-breaking-difficulty.patch @@ -42,8 +42,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java +++ b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java @@ -0,0 +0,0 @@ public class Vindicator extends AbstractIllager { - private static class VindicatorBreakDoorGoal extends BreakDoorGoal { + static class VindicatorBreakDoorGoal extends BreakDoorGoal { public VindicatorBreakDoorGoal(Mob mob) { - super(mob, 6, Vindicator.DOOR_BREAKING_PREDICATE); + super(mob, 6, com.google.common.base.Predicates.in(mob.level.paperConfig.entitiesDifficultyBreakDoors.getOrDefault(mob.getType(), mob.level.paperConfig.entitiesDifficultyBreakDoors.get(EntityType.VINDICATOR)))); // Paper diff --git a/patches/unapplied/server/Configurable-max-leash-distance.patch b/patches/server/Configurable-max-leash-distance.patch similarity index 100% rename from patches/unapplied/server/Configurable-max-leash-distance.patch rename to patches/server/Configurable-max-leash-distance.patch diff --git a/patches/unapplied/server/Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch b/patches/server/Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch similarity index 100% rename from patches/unapplied/server/Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch rename to patches/server/Do-not-crash-from-invalid-ingredient-lists-in-Villag.patch diff --git a/patches/unapplied/server/Empty-commands-shall-not-be-dispatched.patch b/patches/server/Empty-commands-shall-not-be-dispatched.patch similarity index 100% rename from patches/unapplied/server/Empty-commands-shall-not-be-dispatched.patch rename to patches/server/Empty-commands-shall-not-be-dispatched.patch diff --git a/patches/unapplied/server/Fix-Not-a-string-Map-Conversion-spam.patch b/patches/server/Fix-Not-a-string-Map-Conversion-spam.patch similarity index 100% rename from patches/unapplied/server/Fix-Not-a-string-Map-Conversion-spam.patch rename to patches/server/Fix-Not-a-string-Map-Conversion-spam.patch diff --git a/patches/unapplied/server/Fix-harming-potion-dupe.patch b/patches/server/Fix-harming-potion-dupe.patch similarity index 100% rename from patches/unapplied/server/Fix-harming-potion-dupe.patch rename to patches/server/Fix-harming-potion-dupe.patch diff --git a/patches/unapplied/server/Fix-interact-event-not-being-called-in-adventure.patch b/patches/server/Fix-interact-event-not-being-called-in-adventure.patch similarity index 85% rename from patches/unapplied/server/Fix-interact-event-not-being-called-in-adventure.patch rename to patches/server/Fix-interact-event-not-being-called-in-adventure.patch index af03127f15..1108fae680 100644 --- a/patches/unapplied/server/Fix-interact-event-not-being-called-in-adventure.patch +++ b/patches/server/Fix-interact-event-not-being-called-in-adventure.patch @@ -10,11 +10,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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 ServerPlayerConnection, Ser - MutableComponent ichatmutablecomponent = (new TranslatableComponent("build.tooHigh", new Object[]{i - 1})).withStyle(ChatFormatting.RED); + MutableComponent ichatmutablecomponent = Component.translatable("build.tooHigh", i - 1).withStyle(ChatFormatting.RED); - this.player.sendMessage(ichatmutablecomponent, ChatType.GAME_INFO, Util.NIL_UUID); + this.player.sendSystemMessage(ichatmutablecomponent, ChatType.GAME_INFO); - } else if (enuminteractionresult.shouldSwing()) { -+ } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) { ++ } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) { // Paper this.player.swing(enumhand, true); } } diff --git a/patches/unapplied/server/Fix-nerfed-slime-when-splitting.patch b/patches/server/Fix-nerfed-slime-when-splitting.patch similarity index 100% rename from patches/unapplied/server/Fix-nerfed-slime-when-splitting.patch rename to patches/server/Fix-nerfed-slime-when-splitting.patch diff --git a/patches/unapplied/server/Fix-villager-boat-exploit.patch b/patches/server/Fix-villager-boat-exploit.patch similarity index 100% rename from patches/unapplied/server/Fix-villager-boat-exploit.patch rename to patches/server/Fix-villager-boat-exploit.patch diff --git a/patches/unapplied/server/Guardian-beam-workaround.patch b/patches/server/Guardian-beam-workaround.patch similarity index 100% rename from patches/unapplied/server/Guardian-beam-workaround.patch rename to patches/server/Guardian-beam-workaround.patch diff --git a/patches/unapplied/server/Implement-API-to-expose-exact-interaction-point.patch b/patches/server/Implement-API-to-expose-exact-interaction-point.patch similarity index 100% rename from patches/unapplied/server/Implement-API-to-expose-exact-interaction-point.patch rename to patches/server/Implement-API-to-expose-exact-interaction-point.patch diff --git a/patches/unapplied/server/Implement-API-to-get-Material-from-Boats-and-Minecar.patch b/patches/server/Implement-API-to-get-Material-from-Boats-and-Minecar.patch similarity index 100% rename from patches/unapplied/server/Implement-API-to-get-Material-from-Boats-and-Minecar.patch rename to patches/server/Implement-API-to-get-Material-from-Boats-and-Minecar.patch diff --git a/patches/unapplied/server/Implement-BlockPreDispenseEvent.patch b/patches/server/Implement-BlockPreDispenseEvent.patch similarity index 100% rename from patches/unapplied/server/Implement-BlockPreDispenseEvent.patch rename to patches/server/Implement-BlockPreDispenseEvent.patch diff --git a/patches/unapplied/server/Implement-PlayerFlowerPotManipulateEvent.patch b/patches/server/Implement-PlayerFlowerPotManipulateEvent.patch similarity index 100% rename from patches/unapplied/server/Implement-PlayerFlowerPotManipulateEvent.patch rename to patches/server/Implement-PlayerFlowerPotManipulateEvent.patch diff --git a/patches/unapplied/server/Implement-TargetHitEvent.patch b/patches/server/Implement-TargetHitEvent.patch similarity index 100% rename from patches/unapplied/server/Implement-TargetHitEvent.patch rename to patches/server/Implement-TargetHitEvent.patch diff --git a/patches/unapplied/server/Implemented-BlockFailedDispenseEvent.patch b/patches/server/Implemented-BlockFailedDispenseEvent.patch similarity index 93% rename from patches/unapplied/server/Implemented-BlockFailedDispenseEvent.patch rename to patches/server/Implemented-BlockFailedDispenseEvent.patch index dde2471b0c..8925fc8ec9 100644 --- a/patches/unapplied/server/Implemented-BlockFailedDispenseEvent.patch +++ b/patches/server/Implemented-BlockFailedDispenseEvent.patch @@ -9,12 +9,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java @@ -0,0 +0,0 @@ public class DispenserBlock extends BaseEntityBlock { - int i = tileentitydispenser.getRandomSlot(); + int i = tileentitydispenser.getRandomSlot(world.random); if (i < 0) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(world, pos)) {// Paper - BlockFailedDispenseEvent is called here world.levelEvent(1001, pos, 0); - world.gameEvent(GameEvent.DISPENSE_FAIL, pos); + world.gameEvent((Entity) null, GameEvent.DISPENSE_FAIL, pos); + } // Paper } else { ItemStack itemstack = tileentitydispenser.getItem(i); @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/DropperBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DropperBlock.java @@ -0,0 +0,0 @@ public class DropperBlock extends DispenserBlock { - int i = tileentitydispenser.getRandomSlot(); + int i = tileentitydispenser.getRandomSlot(world.random); if (i < 0) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(world, pos)) // Paper - BlockFailedDispenseEvent is called here diff --git a/patches/unapplied/server/Make-schedule-command-per-world.patch b/patches/server/Make-schedule-command-per-world.patch similarity index 94% rename from patches/unapplied/server/Make-schedule-command-per-world.patch rename to patches/server/Make-schedule-command-per-world.patch index e6c0d235cd..d8037706ac 100644 --- a/patches/unapplied/server/Make-schedule-command-per-world.patch +++ b/patches/server/Make-schedule-command-per-world.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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}); + return Component.translatable("commands.schedule.cleared.failure", object); }); private static final SuggestionProvider SUGGEST_SCHEDULE = (commandcontext, suggestionsbuilder) -> { - return SharedSuggestionProvider.suggest((Iterable) ((CommandSourceStack) commandcontext.getSource()).getServer().getWorldData().overworldData().getScheduledEvents().getEventsIds(), suggestionsbuilder); diff --git a/patches/unapplied/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch b/patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch similarity index 100% rename from patches/unapplied/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch rename to patches/server/Remove-ProjectileHitEvent-call-when-fireballs-dead.patch diff --git a/patches/unapplied/server/Remove-stale-POIs.patch b/patches/server/Remove-stale-POIs.patch similarity index 88% rename from patches/unapplied/server/Remove-stale-POIs.patch rename to patches/server/Remove-stale-POIs.patch index f2e0e9949a..a466b72d59 100644 --- a/patches/unapplied/server/Remove-stale-POIs.patch +++ b/patches/server/Remove-stale-POIs.patch @@ -10,13 +10,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { }); - optional1.ifPresent((villageplacetype) -> { + optional1.ifPresent((holder) -> { this.getServer().execute(() -> { + // Paper start + if (optional.isEmpty() && this.getPoiManager().exists(blockposition1, poiType -> true)) { + this.getPoiManager().remove(blockposition1); + } + // Paper end - this.getPoiManager().add(blockposition1, villageplacetype); + this.getPoiManager().add(blockposition1, holder); DebugPackets.sendPoiAddedPacket(this, blockposition1); }); diff --git a/patches/unapplied/server/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/unapplied/server/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/unapplied/server/Zombie-API-breaking-doors.patch b/patches/server/Zombie-API-breaking-doors.patch similarity index 100% rename from patches/unapplied/server/Zombie-API-breaking-doors.patch rename to patches/server/Zombie-API-breaking-doors.patch diff --git a/patches/unapplied/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch b/patches/unapplied/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch deleted file mode 100644 index dba6a63c99..0000000000 --- a/patches/unapplied/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Wed, 24 Jun 2020 15:14:51 -0600 -Subject: [PATCH] Added firing of PlayerChangeBeaconEffectEvent - - -diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java -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 @@ public class BeaconMenu extends AbstractContainerMenu { - - public void updateEffects(int primaryEffectId, int secondaryEffectId) { - if (this.paymentSlot.hasItem()) { -- this.beaconData.set(1, primaryEffectId); -- this.beaconData.set(2, secondaryEffectId); -+ // Paper start -+ 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.remove(1); - this.access.execute(Level::blockEntityChanged); -+ } -+ // Paper end - } - - }