bag o' patches

This commit is contained in:
Jake Potrebic 2022-06-08 00:30:41 -07:00
parent 2bfe9eca4d
commit 88d7a4ed1d
38 changed files with 121 additions and 109 deletions

View file

@ -393,6 +393,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ public static final Reference<ConfiguredStructure> RUINED_PORTAL_MOUNTAIN = create("ruined_portal_mountain"); + public static final Reference<ConfiguredStructure> RUINED_PORTAL_MOUNTAIN = create("ruined_portal_mountain");
+ public static final Reference<ConfiguredStructure> RUINED_PORTAL_OCEAN = create("ruined_portal_ocean"); + public static final Reference<ConfiguredStructure> RUINED_PORTAL_OCEAN = create("ruined_portal_ocean");
+ public static final Reference<ConfiguredStructure> RUINED_PORTAL_NETHER = create("ruined_portal_nether"); + public static final Reference<ConfiguredStructure> RUINED_PORTAL_NETHER = create("ruined_portal_nether");
+ public static final Reference<ConfiguredStructure> ANCIENT_CITY = create("ancient_city");
+ +
+ private final NamespacedKey key; + private final NamespacedKey key;
+ private final StructureType structureType; + private final StructureType structureType;

View file

@ -180,7 +180,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.packRepository.setSelected(dataPacks); this.packRepository.setSelected(dataPacks);
this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository)); this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository));
this.resources.managers.updateRegistryTags(this.registryAccess()); 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 new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
if (Thread.currentThread() != this.serverThread) return; // Paper if (Thread.currentThread() != this.serverThread) return; // Paper
//this.getPlayerList().saveAll(); // Paper - we don't need to do this //this.getPlayerList().saveAll(); // Paper - we don't need to do this

View file

@ -15,12 +15,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import io.papermc.paper.world.structure.ConfiguredStructure; +import io.papermc.paper.world.structure.ConfiguredStructure;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey; 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; import org.bukkit.Keyed;
public record RegistryKey<API extends Keyed, MINECRAFT>(Class<API> apiClass, ResourceKey<? extends Registry<MINECRAFT>> resourceKey) { public record RegistryKey<API extends Keyed, MINECRAFT>(Class<API> apiClass, ResourceKey<? extends Registry<MINECRAFT>> resourceKey) {
+ +
+ public static final RegistryKey<ConfiguredStructure, ConfiguredStructureFeature<?, ?>> CONFIGURED_STRUCTURE_REGISTRY = new RegistryKey<>(ConfiguredStructure.class, Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY); + public static final RegistryKey<ConfiguredStructure, Structure> 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 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 io.papermc.paper.registry.RegistryKey;
+import net.minecraft.core.Registry; +import net.minecraft.core.Registry;
+import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; +import net.minecraft.world.level.levelgen.structure.Structure;
+import net.minecraft.world.level.levelgen.feature.StructureFeature;
+import org.bukkit.NamespacedKey; +import org.bukkit.NamespacedKey;
+import org.bukkit.StructureType; +import org.bukkit.StructureType;
+import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.NonNull;
@ -55,52 +54,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ new ConfiguredStructureRegistry().register(); + new ConfiguredStructureRegistry().register();
+ } + }
+ +
+ static final class ConfiguredStructureRegistry extends PaperRegistry<ConfiguredStructure, ConfiguredStructureFeature<?, ?>> { + static final class ConfiguredStructureRegistry extends PaperRegistry<ConfiguredStructure, Structure> {
+ +
+ private static final Supplier<Registry<StructureFeature<?>>> STRUCTURE_FEATURE_REGISTRY = registryFor(Registry.STRUCTURE_FEATURE_REGISTRY); + private static final Supplier<Registry<Structure>> STRUCTURE_FEATURE_REGISTRY = registryFor(Registry.STRUCTURE_REGISTRY);
+ +
+ public ConfiguredStructureRegistry() { + public ConfiguredStructureRegistry() {
+ super(RegistryKey.CONFIGURED_STRUCTURE_REGISTRY); + super(RegistryKey.CONFIGURED_STRUCTURE_REGISTRY);
+ } + }
+ +
+ @Override + @Override
+ public ConfiguredStructure convertToApi(NamespacedKey key, ConfiguredStructureFeature<?, ?> nms) { + public ConfiguredStructure convertToApi(NamespacedKey key, Structure nms) {
+ final ResourceLocation structureFeatureLoc = Objects.requireNonNull(STRUCTURE_FEATURE_REGISTRY.get().getKey(nms.feature)); + final ResourceLocation structureTypeLoc = Objects.requireNonNull(Registry.STRUCTURE_TYPES.getKey(nms.type()), "unexpected structure type " + nms.type());
+ final StructureType structureType = Objects.requireNonNull(StructureType.getStructureTypes().get(structureFeatureLoc.getPath()), structureFeatureLoc + " could not be converted to an API 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); + 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<TickTa
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/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java --- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
@@ -0,0 +0,0 @@ public abstract class ChunkGenerator implements BiomeManager.NoiseBiomeSource { @@ -0,0 +0,0 @@ public abstract class ChunkGenerator {
@Nullable @Nullable
public Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>> findNearestMapFeature(ServerLevel worldserver, HolderSet<ConfiguredStructureFeature<?, ?>> holderset, BlockPos center, int radius, boolean skipExistingChunks) { public Pair<BlockPos, Holder<Structure>> findNearestMapStructure(ServerLevel world, HolderSet<Structure> structures, BlockPos center, int radius, boolean skipReferencedStructures) {
+ // Paper start - StructureLocateEvent + // Paper start - StructureLocateEvent
+ final org.bukkit.World world = worldserver.getWorld(); + final org.bukkit.World bukkitWorld = world.getWorld();
+ final org.bukkit.Location origin = net.minecraft.server.MCUtil.toLocation(worldserver, center); + 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 var paperRegistry = io.papermc.paper.registry.PaperRegistry.getRegistry(io.papermc.paper.registry.RegistryKey.CONFIGURED_STRUCTURE_REGISTRY);
+ final List<io.papermc.paper.world.structure.ConfiguredStructure> configuredStructures = new ArrayList<>(); + final List<io.papermc.paper.world.structure.ConfiguredStructure> configuredStructures = new ArrayList<>();
+ for (Holder<net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature<?, ?>> holder : holderset) { + for (Holder<Structure> holder : structures) {
+ configuredStructures.add(paperRegistry.convertToApi(holder)); + 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()) { + if (!event.callEvent()) {
+ return null; + return null;
+ } + }
@ -109,24 +95,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ center = net.minecraft.server.MCUtil.toBlockPosition(event.getOrigin()); + center = net.minecraft.server.MCUtil.toBlockPosition(event.getOrigin());
+ radius = event.getRadius(); + radius = event.getRadius();
+ skipExistingChunks = event.shouldFindUnexplored(); + skipReferencedStructures = event.shouldFindUnexplored();
+ holderset = HolderSet.direct(paperRegistry::getMinecraftHolder, event.getConfiguredStructures()); + structures = HolderSet.direct(paperRegistry::getMinecraftHolder, event.getConfiguredStructures());
+ // Paper end + // Paper end
Set<Holder<Biome>> set = (Set) holderset.stream().flatMap((holder) -> { Map<StructurePlacement, Set<Holder<Structure>>> map = new Object2ObjectArrayMap();
return ((ConfiguredStructureFeature) holder.value()).biomes().stream(); Iterator iterator = structures.iterator();
}).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 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/ConfiguredStructureFeature.java --- a/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/ConfiguredStructureFeature.java +++ b/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java
@@ -0,0 +0,0 @@ public class ConfiguredStructureFeature<FC extends FeatureConfiguration, F exten @@ -0,0 +0,0 @@ public abstract class Structure {
public final HolderSet<Biome> biomes; public static final Codec<Structure> DIRECT_CODEC = Registry.STRUCTURE_TYPES.byNameCodec().dispatch(Structure::type, StructureType::codec);
public final Map<MobCategory, StructureSpawnOverride> spawnOverrides; public static final Codec<Holder<Structure>> CODEC = RegistryFileCodec.create(Registry.STRUCTURE_REGISTRY, DIRECT_CODEC);
public final boolean adaptNoise; protected final Structure.StructureSettings settings;
+ static { io.papermc.paper.world.structure.PaperConfiguredStructure.init(); } // Paper + static { io.papermc.paper.world.structure.PaperConfiguredStructure.init(); } // Paper
public ConfiguredStructureFeature(F feature, FC config, HolderSet<Biome> biomes, boolean bl, Map<MobCategory, StructureSpawnOverride> map) { public static <S extends Structure> RecordCodecBuilder<S, Structure.StructureSettings> settingsCodec(RecordCodecBuilder.Instance<S> instance) {
this.feature = feature; 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 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 new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
@ -140,7 +126,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceKey;
+import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.Bootstrap; +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 net.minecraft.world.level.levelgen.structure.BuiltinStructures;
+import org.bukkit.NamespacedKey; +import org.bukkit.NamespacedKey;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.craftbukkit.util.CraftNamespacedKey;
@ -186,11 +172,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ @Test + @Test
+ public void testMinecraftToApi() { + 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<ResourceLocation, ConfiguredStructureFeature<?, ?>> missing = new LinkedHashMap<>(); + Map<ResourceLocation, Structure> missing = new LinkedHashMap<>();
+ for (ConfiguredStructureFeature<?, ?> feature : BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE) { + for (Structure feature : BuiltinRegistries.STRUCTURES) {
+ final ResourceLocation key = BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.getKey(feature); + final ResourceLocation key = BuiltinRegistries.STRUCTURES.getKey(feature);
+ assertNotNull("Missing built-in registry key", key); + assertNotNull("Missing built-in registry key", key);
+ if (DEFAULT_CONFIGURED_STRUCTURES.get(CraftNamespacedKey.fromMinecraft(key)) == null) { + if (DEFAULT_CONFIGURED_STRUCTURES.get(CraftNamespacedKey.fromMinecraft(key)) == null) {
+ missing.put(key, feature); + missing.put(key, feature);
@ -203,11 +189,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Test + @Test
+ public void testApiToMinecraft() { + public void testApiToMinecraft() {
+ for (NamespacedKey apiKey : DEFAULT_CONFIGURED_STRUCTURES.keySet()) { + 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<ResourceLocation, ConfiguredStructureFeature<?, ?>> missing) { + private static String printMissing(Map<ResourceLocation, Structure> missing) {
+ final StringJoiner joiner = new StringJoiner("\n", "Missing: \n", ""); + final StringJoiner joiner = new StringJoiner("\n", "Missing: \n", "");
+ +
+ missing.forEach((key, configuredFeature) -> { + missing.forEach((key, configuredFeature) -> {

View file

@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } // Paper + } // 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 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java

View file

@ -11,24 +11,38 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class LoomMenu extends AbstractContainerMenu { @@ -0,0 +0,0 @@ public class LoomMenu extends AbstractContainerMenu {
@Override @Override
public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) { 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.selectedBannerPatternIndex.set(id);
- this.setupResultSlot((Holder) this.selectablePatterns.get(id));
+ // Paper start + // Paper start
+ int enumBannerPatternTypeOrdinal = id; + 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(BannerPattern.values()[id].getHashname())); + 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()) { + if (!event.callEvent()) {
+ ((Player) player.getBukkitEntity()).updateInventory(); + ((Player) player.getBukkitEntity()).updateInventory();
+ return false; + return false;
+ } + }
+ for (BannerPattern nms : BannerPattern.values()) { + Holder<BannerPattern> selectedPattern = null;
+ if (event.getPatternType().getIdentifier().equals(nms.getHashname())) { + for (int i = 0; i < this.selectablePatterns.size(); i++) {
+ enumBannerPatternTypeOrdinal = nms.ordinal(); + final Holder<BannerPattern> holder = this.selectablePatterns.get(i);
+ if (event.getPatternType().getIdentifier().equals(holder.value().getHashname())) {
+ selectablePatternIndex = i;
+ selectedPattern = holder;
+ break; + 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(); + ((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 + // Paper end
this.setupResultSlot();
return true; return true;
} else { } else {
return false;

View file

@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- source.getServer().reloadResources(dataPacks).exceptionally((throwable) -> { - source.getServer().reloadResources(dataPacks).exceptionally((throwable) -> {
+ source.getServer().reloadResources(dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.COMMAND).exceptionally((throwable) -> { + source.getServer().reloadResources(dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.COMMAND).exceptionally((throwable) -> {
ReloadCommand.LOGGER.warn("Failed to execute reload", 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; return null;
@@ -0,0 +0,0 @@ public class ReloadCommand { @@ -0,0 +0,0 @@ public class ReloadCommand {
WorldData savedata = minecraftserver.getWorldData(); WorldData savedata = minecraftserver.getWorldData();

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- t0.setFromArgument(context, "value"); - t0.setFromArgument(context, "value");
+ t0.setFromArgument(context, "value", key); // Paper + 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(); 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/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java

View file

@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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<MobEffect> 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<MobEffect> primary, Optional<MobEffect> 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
}
}

View file

@ -28,11 +28,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java --- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
+++ b/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 @@ -0,0 +0,0 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
this.populateDefaultEquipmentSlots(difficulty); this.populateDefaultEquipmentSlots(randomsource, difficulty);
this.populateDefaultEquipmentEnchantments(difficulty); this.populateDefaultEquipmentEnchantments(randomsource, difficulty);
this.reassessWeaponGoal(); this.reassessWeaponGoal();
- this.setCanPickUpLoot(this.random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); - this.setCanPickUpLoot(randomsource.nextFloat() < 0.55F * difficulty.getSpecialMultiplier());
+ this.setCanPickUpLoot(this.level.paperConfig.skeletonsAlwaysCanPickUpLoot || this.random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper + this.setCanPickUpLoot(this.level.paperConfig.skeletonsAlwaysCanPickUpLoot || randomsource.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper
if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) {
LocalDate localdate = LocalDate.now(); LocalDate localdate = LocalDate.now();
int i = localdate.get(ChronoField.DAY_OF_MONTH); int i = localdate.get(ChronoField.DAY_OF_MONTH);
@ -44,8 +44,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Object object = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt); Object object = super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt);
float f = difficulty.getSpecialMultiplier(); float f = difficulty.getSpecialMultiplier();
- this.setCanPickUpLoot(this.random.nextFloat() < 0.55F * f); - this.setCanPickUpLoot(randomsource.nextFloat() < 0.55F * f);
+ this.setCanPickUpLoot(this.level.paperConfig.zombiesAlwaysCanPickUpLoot || this.random.nextFloat() < 0.55F * f); // Paper + this.setCanPickUpLoot(this.level.paperConfig.zombiesAlwaysCanPickUpLoot || randomsource.nextFloat() < 0.55F * f); // Paper
if (object == null) { if (object == null) {
object = new Zombie.ZombieGroupData(Zombie.getSpawnAsBabyOdds(world.getRandom()), true); object = new Zombie.ZombieGroupData(Zombie.getSpawnAsBabyOdds(randomsource), true);
} }

View file

@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/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 @@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
this.recipeType = recipeType; this.recipeType = recipeType; // Paper
} }
+ private static Map<Item, Integer> cachedBurnDurations = null; // Paper - cache burn durations + private static Map<Item, Integer> cachedBurnDurations = null; // Paper - cache burn durations
@ -23,9 +23,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
AbstractFurnaceBlockEntity.add(map, (ItemLike) Items.LAVA_BUCKET, 20000); AbstractFurnaceBlockEntity.add(map, (ItemLike) Items.LAVA_BUCKET, 20000);
@@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit @@ -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.AZALEA, 100);
AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.FLOWERING_AZALEA, 100); AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.FLOWERING_AZALEA, 100);
AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.MANGROVE_ROOTS, 300);
- return map; - return map;
+ // Paper start - cache burn durations + // Paper start - cache burn durations
+ cachedBurnDurations = com.google.common.collect.ImmutableMap.copyOf(map); + cachedBurnDurations = com.google.common.collect.ImmutableMap.copyOf(map);

View file

@ -42,8 +42,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java --- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
+++ b/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 { @@ -0,0 +0,0 @@ public class Vindicator extends AbstractIllager {
private static class VindicatorBreakDoorGoal extends BreakDoorGoal {
static class VindicatorBreakDoorGoal extends BreakDoorGoal {
public VindicatorBreakDoorGoal(Mob mob) { public VindicatorBreakDoorGoal(Mob mob) {
- super(mob, 6, Vindicator.DOOR_BREAKING_PREDICATE); - 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 + super(mob, 6, com.google.common.base.Predicates.in(mob.level.paperConfig.entitiesDifficultyBreakDoors.getOrDefault(mob.getType(), mob.level.paperConfig.entitiesDifficultyBreakDoors.get(EntityType.VINDICATOR)))); // Paper

View file

@ -10,11 +10,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/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 @@ -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()) {
+ } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) { + } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) { // Paper
this.player.swing(enumhand, true); this.player.swing(enumhand, true);
} }
} }

View file

@ -9,12 +9,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java --- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
+++ b/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 { @@ -0,0 +0,0 @@ public class DispenserBlock extends BaseEntityBlock {
int i = tileentitydispenser.getRandomSlot(); int i = tileentitydispenser.getRandomSlot(world.random);
if (i < 0) { if (i < 0) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(world, pos)) {// Paper - BlockFailedDispenseEvent is called here + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(world, pos)) {// Paper - BlockFailedDispenseEvent is called here
world.levelEvent(1001, pos, 0); world.levelEvent(1001, pos, 0);
world.gameEvent(GameEvent.DISPENSE_FAIL, pos); world.gameEvent((Entity) null, GameEvent.DISPENSE_FAIL, pos);
+ } // Paper + } // Paper
} else { } else {
ItemStack itemstack = tileentitydispenser.getItem(i); ItemStack itemstack = tileentitydispenser.getItem(i);
@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/DropperBlock.java --- a/src/main/java/net/minecraft/world/level/block/DropperBlock.java
+++ b/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 { @@ -0,0 +0,0 @@ public class DropperBlock extends DispenserBlock {
int i = tileentitydispenser.getRandomSlot(); int i = tileentitydispenser.getRandomSlot(world.random);
if (i < 0) { if (i < 0) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(world, pos)) // Paper - BlockFailedDispenseEvent is called here + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFailedDispenseEvent(world, pos)) // Paper - BlockFailedDispenseEvent is called here

View file

@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/commands/ScheduleCommand.java --- a/src/main/java/net/minecraft/server/commands/ScheduleCommand.java
+++ b/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 { @@ -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<CommandSourceStack> SUGGEST_SCHEDULE = (commandcontext, suggestionsbuilder) -> { private static final SuggestionProvider<CommandSourceStack> SUGGEST_SCHEDULE = (commandcontext, suggestionsbuilder) -> {
- return SharedSuggestionProvider.suggest((Iterable) ((CommandSourceStack) commandcontext.getSource()).getServer().getWorldData().overworldData().getScheduledEvents().getEventsIds(), suggestionsbuilder); - return SharedSuggestionProvider.suggest((Iterable) ((CommandSourceStack) commandcontext.getSource()).getServer().getWorldData().overworldData().getScheduledEvents().getEventsIds(), suggestionsbuilder);

View file

@ -10,13 +10,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
}); });
optional1.ifPresent((villageplacetype) -> { optional1.ifPresent((holder) -> {
this.getServer().execute(() -> { this.getServer().execute(() -> {
+ // Paper start + // Paper start
+ if (optional.isEmpty() && this.getPoiManager().exists(blockposition1, poiType -> true)) { + if (optional.isEmpty() && this.getPoiManager().exists(blockposition1, poiType -> true)) {
+ this.getPoiManager().remove(blockposition1); + this.getPoiManager().remove(blockposition1);
+ } + }
+ // Paper end + // Paper end
this.getPoiManager().add(blockposition1, villageplacetype); this.getPoiManager().add(blockposition1, holder);
DebugPackets.sendPoiAddedPacket(this, blockposition1); DebugPackets.sendPoiAddedPacket(this, blockposition1);
}); });

View file

@ -1,29 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
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
}
}