bag o' patches

This commit is contained in:
Jake Potrebic 2022-06-08 00:30:41 -07:00
parent feca8d248c
commit 89c3c31af9
No known key found for this signature in database
GPG key ID: ECE0B3C133C016C5
39 changed files with 226 additions and 214 deletions

View file

@ -340,10 +340,10 @@ index 0000000000000000000000000000000000000000..566f9df8f615142e14330965f3491f4e
+}
diff --git a/src/main/java/io/papermc/paper/world/structure/ConfiguredStructure.java b/src/main/java/io/papermc/paper/world/structure/ConfiguredStructure.java
new file mode 100644
index 0000000000000000000000000000000000000000..280febf7482418734558c50c22688248ac2b14f3
index 0000000000000000000000000000000000000000..110d24e988fcdaba0e4ad107d161b502f9f6572e
--- /dev/null
+++ b/src/main/java/io/papermc/paper/world/structure/ConfiguredStructure.java
@@ -0,0 +1,97 @@
@@ -0,0 +1,98 @@
+package io.papermc.paper.world.structure;
+
+import io.papermc.paper.registry.Reference;
@ -393,6 +393,7 @@ index 0000000000000000000000000000000000000000..280febf7482418734558c50c22688248
+ 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_NETHER = create("ruined_portal_nether");
+ public static final Reference<ConfiguredStructure> ANCIENT_CITY = create("ancient_city");
+
+ private final NamespacedKey key;
+ private final StructureType structureType;

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Do not crash from invalid ingredient lists in
diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
index 68bd3bb6fde77a65b5271631f6ef726dc613019b..742ffe531bb8f3a9ca34dea99b044123d90cfff9 100644
index 6717e3d116b7bff8ab4d7b45f8c4ec00939c9c73..0c585354ba459ceb6badbf60dcf7b068bfa108b6 100644
--- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
@@ -275,7 +275,11 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Add PlayerTradeEvent and PlayerPurchaseEvent
Co-authored-by: Alexander <protonull@protonmail.com>
diff --git a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
index 742ffe531bb8f3a9ca34dea99b044123d90cfff9..bd283f71cb05ffbe1fed39afb41ae54dc52ec297 100644
index 0c585354ba459ceb6badbf60dcf7b068bfa108b6..5eab7d50734551d96128dfebee126a1da4c51375 100644
--- a/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/AbstractVillager.java
@@ -138,11 +138,24 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa
@ -37,10 +37,10 @@ index 742ffe531bb8f3a9ca34dea99b044123d90cfff9..bd283f71cb05ffbe1fed39afb41ae54d
CriteriaTriggers.TRADE.trigger((ServerPlayer) this.tradingPlayer, this, offer.getResult());
}
diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
index eecb852e4946c774ad295c53dbd904571262055a..3dc87e86dcd4c87e8e87e1dcd2765acb3b258bdf 100644
index 36d42b2a97168dfa525b55d8fa2f7a603b43340f..f1438e527d6291a789d2ec821481f6ec142d1c0b 100644
--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
@@ -753,6 +753,14 @@ public abstract class AbstractContainerMenu {
@@ -751,6 +751,14 @@ public abstract class AbstractContainerMenu {
public abstract boolean stillValid(Player player);
protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean fromLast) {
@ -55,7 +55,7 @@ index eecb852e4946c774ad295c53dbd904571262055a..3dc87e86dcd4c87e8e87e1dcd2765acb
boolean flag1 = false;
int k = startIndex;
@@ -775,18 +783,27 @@ public abstract class AbstractContainerMenu {
@@ -773,18 +781,27 @@ public abstract class AbstractContainerMenu {
slot = (Slot) this.slots.get(k);
itemstack1 = slot.getItem();
@ -83,7 +83,7 @@ index eecb852e4946c774ad295c53dbd904571262055a..3dc87e86dcd4c87e8e87e1dcd2765acb
flag1 = true;
}
}
@@ -817,14 +834,33 @@ public abstract class AbstractContainerMenu {
@@ -815,14 +832,33 @@ public abstract class AbstractContainerMenu {
slot = (Slot) this.slots.get(k);
itemstack1 = slot.getItem();
@ -219,10 +219,10 @@ index d41f44ed2e497ba3373d170c08488b49e88334c4..d3a99ba6f3085ad12b67ddc94cc4ab39
void notifyTradeUpdated(ItemStack stack);
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java
index 552851cff3678d605428866999951fefd4375d7a..9f6ce6c4cba1e6fe83fbac129da990748681ce94 100644
index eaec84147d3023c71865a6b2236879511e9f3685..14d4511bdd0206e0222f1356707fab66ad9d1ff4 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMerchantCustom.java
@@ -79,10 +79,25 @@ public class CraftMerchantCustom extends CraftMerchant {
@@ -78,10 +78,25 @@ public class CraftMerchantCustom extends CraftMerchant {
return this.trades;
}

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Implement TargetHitEvent
diff --git a/src/main/java/net/minecraft/world/level/block/TargetBlock.java b/src/main/java/net/minecraft/world/level/block/TargetBlock.java
index f71649338588c576cffc7fecc1e83217c529c335..20955a3944a2fcb66ad98267ef3570ddfc32980e 100644
index fdaba168dd1ed25ed8d5b4cdd89d4ad801b10388..69eaf1341d282c4783dab84533ea2c053deed529 100644
--- a/src/main/java/net/minecraft/world/level/block/TargetBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/TargetBlock.java
@@ -35,6 +35,10 @@ public class TargetBlock extends Block {

View file

@ -8,10 +8,10 @@ Before this patch, instant effects would be applied before the potion ItemStack
This patch makes it so that instant effects are applied after the potion ItemStack is removed, and the glass bottle is only put into the player's inventory if the player is not dead. Otherwise, the glass bottle is dropped on the ground.
diff --git a/src/main/java/net/minecraft/world/item/PotionItem.java b/src/main/java/net/minecraft/world/item/PotionItem.java
index 166f7483163a0cf62b000764d635ec2ee36a5036..4b5c9da0e858016c1a3afcb6eaa1ff4cbf47739e 100644
index 446ba28a38a597bc8c99e31087e5c90eb37f8335..44aecc47d94481cb6286a60fc2bb720e3486bcc2 100644
--- a/src/main/java/net/minecraft/world/item/PotionItem.java
+++ b/src/main/java/net/minecraft/world/item/PotionItem.java
@@ -41,6 +41,7 @@ public class PotionItem extends Item {
@@ -53,6 +53,7 @@ public class PotionItem extends Item {
CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayer) entityhuman, stack);
}
@ -19,7 +19,7 @@ index 166f7483163a0cf62b000764d635ec2ee36a5036..4b5c9da0e858016c1a3afcb6eaa1ff4c
if (!world.isClientSide) {
List<MobEffectInstance> list = PotionUtils.getMobEffects(stack);
Iterator iterator = list.iterator();
@@ -49,7 +50,7 @@ public class PotionItem extends Item {
@@ -61,7 +62,7 @@ public class PotionItem extends Item {
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
if (mobeffect.getEffect().isInstantenous()) {
@ -28,7 +28,7 @@ index 166f7483163a0cf62b000764d635ec2ee36a5036..4b5c9da0e858016c1a3afcb6eaa1ff4c
} else {
user.addEffect(new MobEffectInstance(mobeffect), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit
}
@@ -63,7 +64,18 @@ public class PotionItem extends Item {
@@ -75,7 +76,18 @@ public class PotionItem extends Item {
}
}

View file

@ -5,11 +5,11 @@ Subject: [PATCH] Cache burn durations
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
index 635d47d4bea679e96736ef891c40f57488cbc6a1..e62fa09ca481183be2ee158b0717172c90de1b92 100644
index d3a9b42fd4fa487e0acb1c95d57f78ccfbefbdff..1cc2c13ab07b9dc4492cec55314e12d7536d5453 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
@@ -129,7 +129,13 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
this.recipeType = recipeType;
@@ -132,7 +132,13 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
this.recipeType = recipeType; // Paper
}
+ private static Map<Item, Integer> cachedBurnDurations = null; // Paper - cache burn durations
@ -22,10 +22,10 @@ index 635d47d4bea679e96736ef891c40f57488cbc6a1..e62fa09ca481183be2ee158b0717172c
Map<Item, Integer> map = Maps.newLinkedHashMap();
AbstractFurnaceBlockEntity.add(map, (ItemLike) Items.LAVA_BUCKET, 20000);
@@ -194,7 +200,10 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
AbstractFurnaceBlockEntity.add(map, (ItemLike) Blocks.COMPOSTER, 300);
@@ -200,7 +206,10 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
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);

View file

@ -21,7 +21,7 @@ index d6cbd9ea2eb70e25a5e37e0bdda2396a99b3342e..5fe4d2005e87a7b69e98dcd68e0fff3c
private void keepLoadedRange() {
keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 10)) * 16);
diff --git a/src/main/java/net/minecraft/world/item/SpawnEggItem.java b/src/main/java/net/minecraft/world/item/SpawnEggItem.java
index 901df339e40738413ce1cce87e72be82cc893087..3d9daa9e2c35d7fd277bde37cd5d1bfc9362d2ee 100644
index b518c5d18c2d3486382ed4e59941b155d5534014..fb37846e1c9b7715e32d0d5416b1ce4968e543df 100644
--- a/src/main/java/net/minecraft/world/item/SpawnEggItem.java
+++ b/src/main/java/net/minecraft/world/item/SpawnEggItem.java
@@ -61,7 +61,7 @@ public class SpawnEggItem extends Item {

View file

@ -6,19 +6,19 @@ Subject: [PATCH] Fix interact event not being called in adventure
Call PlayerInteractEvent when left-clicking on a block in adventure mode
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 2a5eb98c6e0f54f098c24ec09c68c3a4dda21aa8..8b2c246f60886053beb9c4baf18c867910b9a8fd 100644
index ac3219f3a26f9f7fab57de0f9277695423ef46d7..bf72d96c6d6efcda40eb19d30b90f63b9bc42a83 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1764,7 +1764,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
MutableComponent ichatmutablecomponent = (new TranslatableComponent("build.tooHigh", new Object[]{i - 1})).withStyle(ChatFormatting.RED);
@@ -1778,7 +1778,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
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);
}
}
@@ -2242,7 +2242,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@@ -2411,7 +2411,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
Vec3 vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
HitResult movingobjectposition = this.player.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.player));

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Fix nerfed slime when splitting
diff --git a/src/main/java/net/minecraft/world/entity/monster/Slime.java b/src/main/java/net/minecraft/world/entity/monster/Slime.java
index 8d03466e2f546aae705c1d4dd2d562d3db2f2671..85edba5de3ce6c1fce8872855544863de84e7759 100644
index aee0180c554949eb16fe1785344c28c4ecc1e0a0..bdc6a7e6a9fcd467f653d53afd7ca2e33776fb06 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Slime.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Slime.java
@@ -239,6 +239,7 @@ public class Slime extends Mob implements Enemy {

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Add EntityLoadCrossbowEvent
diff --git a/src/main/java/net/minecraft/world/item/CrossbowItem.java b/src/main/java/net/minecraft/world/item/CrossbowItem.java
index 1ec3fd560a2b6528040bca68be4a05c9a8435ae9..c0c211c7227f4ce5d1e0e433419425e6bb13046f 100644
index d86ec8c4c1c3e7974463a545d80ed9744de0fbbb..3b8629d31dc7bc66debe9c56593fbd071a6ddd11 100644
--- a/src/main/java/net/minecraft/world/item/CrossbowItem.java
+++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java
@@ -90,7 +90,14 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
@@ -88,7 +88,14 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
int j = this.getUseDuration(stack) - remainingUseTicks;
float f = CrossbowItem.getPowerForTime(j, stack);
@ -24,7 +24,7 @@ index 1ec3fd560a2b6528040bca68be4a05c9a8435ae9..c0c211c7227f4ce5d1e0e433419425e6
CrossbowItem.setCharged(stack, true);
SoundSource soundcategory = user instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE;
@@ -100,9 +107,14 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
@@ -98,9 +105,14 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
}
private static boolean tryLoadProjectiles(LivingEntity shooter, ItemStack projectile) {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Added WorldGameRuleChangeEvent
diff --git a/src/main/java/net/minecraft/server/commands/GameRuleCommand.java b/src/main/java/net/minecraft/server/commands/GameRuleCommand.java
index f2e53fbb067a3909f386386eb3b89dfe090ee096..6f6292e7945cec1bdc69632dbfb950d6af53df42 100644
index 1b66c33a55a9516269c80f5052fb103418b11367..745b8724b7536a5b2c2c94ae8fd703ea755e8072 100644
--- a/src/main/java/net/minecraft/server/commands/GameRuleCommand.java
+++ b/src/main/java/net/minecraft/server/commands/GameRuleCommand.java
@@ -33,7 +33,7 @@ public class GameRuleCommand {
@ -14,14 +14,14 @@ index f2e53fbb067a3909f386386eb3b89dfe090ee096..6f6292e7945cec1bdc69632dbfb950d6
- 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
index 74e10d581f8c1b0b026d8f940194971efbdef434..798afc145c54306fcf0838d8daef2bdf17763da9 100644
index 800325a544bb9f228ccbeb0a52d7f380a8c6083e..3c93bfeb94168f832904a8462ae23b06e81e080d 100644
--- a/src/main/java/net/minecraft/world/level/GameRules.java
+++ b/src/main/java/net/minecraft/world/level/GameRules.java
@@ -261,10 +261,10 @@ public class GameRules {
@@ -262,10 +262,10 @@ public class GameRules {
this.type = type;
}
@ -35,7 +35,7 @@ index 74e10d581f8c1b0b026d8f940194971efbdef434..798afc145c54306fcf0838d8daef2bdf
this.onChanged(((CommandSourceStack) context.getSource()).getServer());
}
@@ -322,8 +322,11 @@ public class GameRules {
@@ -323,8 +323,11 @@ public class GameRules {
}
@Override
@ -49,7 +49,7 @@ index 74e10d581f8c1b0b026d8f940194971efbdef434..798afc145c54306fcf0838d8daef2bdf
}
public boolean get() {
@@ -387,8 +390,11 @@ public class GameRules {
@@ -388,8 +391,11 @@ public class GameRules {
}
@Override
@ -64,7 +64,7 @@ index 74e10d581f8c1b0b026d8f940194971efbdef434..798afc145c54306fcf0838d8daef2bdf
public int get() {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index f7d5c6aa18ee44e0a6651ed73c922a973bb809b3..6777b678efebc5eee72b2aa368309aea3191157f 100644
index 99d109ebd9aa0af31916dc81d1a8b1f7bc6d42be..0440a9e3449cdf1a969ba8c7863b73842afebe48 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1798,8 +1798,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Added ServerResourcesReloadedEvent
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 8ebd25e66301c62ae30d53f2104f732a32939029..3eda7f5469803af5fae138b81976ecae2b7c6c2e 100644
index 1f8ce89b46996491043f37783a80f4928acab8ce..f809420b1bd4fd9e4714cdad25cc5640e8ad9264 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2000,7 +2000,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1966,7 +1966,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
return this.functionManager;
}
@ -22,7 +22,7 @@ index 8ebd25e66301c62ae30d53f2104f732a32939029..3eda7f5469803af5fae138b81976ecae
RegistryAccess.Frozen iregistrycustom_dimension = this.registryAccess();
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
Stream<String> stream = dataPacks.stream(); // CraftBukkit - decompile error
@@ -2026,6 +2032,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1992,6 +1998,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.packRepository.setSelected(dataPacks);
this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository));
this.resources.managers.updateRegistryTags(this.registryAccess());
@ -31,7 +31,7 @@ index 8ebd25e66301c62ae30d53f2104f732a32939029..3eda7f5469803af5fae138b81976ecae
//this.getPlayerList().saveAll(); // Paper - we don't need to do this
this.getPlayerList().reloadResources();
diff --git a/src/main/java/net/minecraft/server/commands/ReloadCommand.java b/src/main/java/net/minecraft/server/commands/ReloadCommand.java
index c94252ba962262ed9546d48fe05fd5995b8c73b6..4517e59584213db1f355fd993b75b4b016e02634 100644
index 1eb85de1d10829bfb4dbbfa01efd5656dee70090..19eacd1b1c3aca23f864a1867e004455312e82f7 100644
--- a/src/main/java/net/minecraft/server/commands/ReloadCommand.java
+++ b/src/main/java/net/minecraft/server/commands/ReloadCommand.java
@@ -20,7 +20,7 @@ public class ReloadCommand {
@ -41,7 +41,7 @@ index c94252ba962262ed9546d48fe05fd5995b8c73b6..4517e59584213db1f355fd993b75b4b0
- 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;
@@ -50,7 +50,7 @@ public class ReloadCommand {
WorldData savedata = minecraftserver.getWorldData();

View file

@ -24,28 +24,28 @@ index 5fe4d2005e87a7b69e98dcd68e0fff3cc26a8c96..f4559f3bc7751da48a84d75a949c9df2
private void expMergeMaxValue() {
expMergeMaxValue = getInt("experience-merge-max-value", -1);
diff --git a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
index 609380af4de4118a543b6ec94feb176e6f6870ed..ecf12ed5014202181e78af051e4a9ca88a275794 100644
index 60064770f08cbee19eeb43bf7c144b6eefbc4888..5f679d5f148e59376669a5faa970961df219fe35 100644
--- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
+++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
@@ -147,7 +147,7 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
this.populateDefaultEquipmentSlots(difficulty);
this.populateDefaultEquipmentEnchantments(difficulty);
@@ -150,7 +150,7 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
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);
diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
index 5341f65436bb147c8aed5206c5e4515c7517bc2e..92145b35cf9f04afd388dfea8215097a9da7c5a7 100644
index 847dbd6dae8e9a615ade642c598bc7bb45fb4722..6d0461a2cf3c06d85177ca4959f330c1ec7f6788 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
@@ -503,7 +503,7 @@ public class Zombie extends Monster {
@@ -508,7 +508,7 @@ public class Zombie extends Monster {
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);
}

View file

@ -5,26 +5,26 @@ Subject: [PATCH] Implemented BlockFailedDispenseEvent
diff --git a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
index 7ffbdfb1d192e70ab2259391210d73b8821e4989..07d357b5fcb30ed9ff074a196a19de1481fe3738 100644
index c0e19826163b0eaa429d217b54bb67b8b582a669..85c5319837295bd2f85baebfe8d6660b267f1d5f 100644
--- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
@@ -83,8 +83,10 @@ public class DispenserBlock extends BaseEntityBlock {
int i = tileentitydispenser.getRandomSlot();
@@ -84,8 +84,10 @@ public class DispenserBlock extends BaseEntityBlock {
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);
DispenseItemBehavior idispensebehavior = this.getDispenseMethod(itemstack);
diff --git a/src/main/java/net/minecraft/world/level/block/DropperBlock.java b/src/main/java/net/minecraft/world/level/block/DropperBlock.java
index 47258da56363037fba17d92e1518955a5fd4ef3b..234dc491ca30853eefdf86229296cc89fc8d46c2 100644
index 1415ad60163f6584619cc7caa61f1848d6ebaa93..801c4c120e98584bcf218a4ef9bd66d7d18c1097 100644
--- a/src/main/java/net/minecraft/world/level/block/DropperBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DropperBlock.java
@@ -44,6 +44,7 @@ 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

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Added PlayerLecternPageChangeEvent
diff --git a/src/main/java/net/minecraft/world/inventory/LecternMenu.java b/src/main/java/net/minecraft/world/inventory/LecternMenu.java
index 0149b958a3bdeb529a8b7e64f4ca458d0be88998..ff79925bc6437222f9ceb133e21bbc0600cc74ed 100644
index 9b80f533e94c47ebc0d46429698e084216b632ab..52471ef87994ac91b4b0017159b61ff50774848a 100644
--- a/src/main/java/net/minecraft/world/inventory/LecternMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/LecternMenu.java
@@ -64,6 +64,7 @@ public class LecternMenu extends AbstractContainerMenu {

View file

@ -0,0 +1,48 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 25 Nov 2020 16:33:27 -0800
Subject: [PATCH] Added PlayerLoomPatternSelectEvent
diff --git a/src/main/java/net/minecraft/world/inventory/LoomMenu.java b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
index 9cbdcb87d76fa36887413754ef625a16624aadd7..e1e479156070b3c52e9949541a7dd56571dfb35b 100644
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
@@ -173,8 +173,35 @@ public class LoomMenu extends AbstractContainerMenu {
@Override
public boolean clickMenuButton(net.minecraft.world.entity.player.Player player, int id) {
if (id >= 0 && id < this.selectablePatterns.size()) {
- this.selectedBannerPatternIndex.set(id);
- this.setupResultSlot((Holder) this.selectablePatterns.get(id));
+ // Paper start
+ 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;
+ }
+ Holder<BannerPattern> selectedPattern = null;
+ for (int i = 0; i < this.selectablePatterns.size(); i++) {
+ final Holder<BannerPattern> 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(selectablePatternIndex);
+ this.setupResultSlot(java.util.Objects.requireNonNull(selectedPattern, "selectedPattern was null, this is unexpected"));
+ // Paper end
return true;
} else {
return false;

View file

@ -38,12 +38,12 @@ index f4559f3bc7751da48a84d75a949c9df298ee48b4..96fd9803810db0f8a4b25e070a56da05
public short keepLoadedRange;
private void keepLoadedRange() {
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
index 920c2101ebbdc07c7fd15903a3d641aa55f8336d..430492facbaa80471875da07bf4b9b601777d1fd 100644
index ffc8e20d916940fb5e28bac610e3c6bd3d493f78..8914a0e2aab28fe2198f8e117f206abffae8b7d0 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Vindicator.java
@@ -192,7 +192,7 @@ public class Vindicator extends AbstractIllager {
private static class VindicatorBreakDoorGoal extends BreakDoorGoal {
@@ -197,7 +197,7 @@ public class Vindicator extends AbstractIllager {
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
@ -51,7 +51,7 @@ index 920c2101ebbdc07c7fd15903a3d641aa55f8336d..430492facbaa80471875da07bf4b9b60
}
diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
index 92145b35cf9f04afd388dfea8215097a9da7c5a7..f9b7877ce5f66cc58ff1111d0fa72081a03c4f4e 100644
index 6d0461a2cf3c06d85177ca4959f330c1ec7f6788..4e348ea70ecc3836befcffcaa27c12a104f29c2a 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
@@ -97,7 +97,7 @@ public class Zombie extends Monster {

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Empty commands shall not be dispatched
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index 4bc28b66788d06d1446284f5adef6a44be736f92..e195ef979984ea7ffe4558c42ebabadf2a00950a 100644
index a8f3a84615a640d2949d268ef1ac81a051f5a38b..2dc41adc4e915f98451d79f0826b75560b716d21 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -241,6 +241,7 @@ public class Commands {
@@ -236,6 +236,7 @@ public class Commands {
command = event.getCommand();
String[] args = command.split(" ");

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Implement API to expose exact interaction point
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index d006964cb6c4c3cd843064ab685700c67df8c238..f97d97426144527cff9ebb91b26fe8541a9c6d9b 100644
index 32c78828b0c85949832dc25843c881b8eecc63d6..06e7a8b8227260c002a88119544b99a11eec8a09 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -511,7 +511,7 @@ public class ServerPlayerGameMode {
@@ -507,7 +507,7 @@ public class ServerPlayerGameMode {
cancelledBlock = true;
}

View file

@ -5,18 +5,18 @@ Subject: [PATCH] Remove stale POIs
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 053ca558c7db0b0a7c2b768e3827e0b90094fc5b..5f9376afffa369ea2480fafdda5e9fadf46f236e 100644
index 8788325368e80eb162b0f665ae0995fe74317b4a..c2c2c5f10b1f748a90f5d72148c9a9e6bdecfaf4 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1834,6 +1834,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1912,6 +1912,11 @@ 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);
});

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Fix villager boat exploit
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 8d5154cad319d7762db696cd9cd2bf8ab69f632e..65335a8dc42366c5318d583097b24443dc3c9616 100644
index bec5dbb3b103403e76cd42b942b352c453574ce1..9a27895d9528dd10e196fe7e7d2fb9d7561fa704 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -625,6 +625,14 @@ public abstract class PlayerList {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Add sendOpLevel API
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 65335a8dc42366c5318d583097b24443dc3c9616..71b6f3990ace47ac752ec825c78d7fa964011898 100644
index 9a27895d9528dd10e196fe7e7d2fb9d7561fa704..7662e4f590d9e3146783239a662b452741b97147 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1123,6 +1123,11 @@ public abstract class PlayerList {
@ -30,12 +30,12 @@ index 65335a8dc42366c5318d583097b24443dc3c9616..71b6f3990ace47ac752ec825c78d7fa9
+ } // 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 a55dc36244c7a60300c988504d214eef546dfa36..047411e24a53c2e625c05b7079406060024e5dc9 100644
index b8cc0116f5ffaa5c9c6fd2a8661c88a7e7f70370..d46ac0b59f4a3f4977dca2f499754cdc312fd688 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -609,6 +609,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -607,6 +607,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
? (org.bukkit.entity.Firework) entity.getBukkitEntity()
: null;
}

View file

@ -173,19 +173,19 @@ index 0000000000000000000000000000000000000000..6f39e343147803e15e7681c993b8797a
+public record RegistryKey<API extends Keyed, MINECRAFT>(Class<API> apiClass, ResourceKey<? extends Registry<MINECRAFT>> resourceKey) {
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 3eda7f5469803af5fae138b81976ecae2b7c6c2e..9941456a019a34384f892c44df3c73f9416bd560 100644
index f809420b1bd4fd9e4714cdad25cc5640e8ad9264..129a93d401a2d0912b1229fa394243861506c461 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2032,6 +2032,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1998,6 +1998,7 @@ 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/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 5540c5a881a9d34a8c50d6b6f0694303c76aa610..9af0bd83c03a7e9fba04f7b9f0c66029a7f4b65a 100644
index dd22329e6ebdaf319039b736f019be9bf7543ef9..0814dc37639693cf76aa1c628b71939150cabac6 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -512,6 +512,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
@ -201,7 +201,7 @@ index 5540c5a881a9d34a8c50d6b6f0694303c76aa610..9af0bd83c03a7e9fba04f7b9f0c66029
/**
diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java
index d6b6b7a3d2949126520e8256563afeb2b43bf12c..37934f0da922d696373e7a3a8cf976fcb9015271 100644
index b58962026c739ed06fbe0f702cb2877fbfa7b2e4..b135f36a3b75f150781bd1e2d5852f18862a6a3a 100644
--- a/src/test/java/org/bukkit/support/AbstractTestingBase.java
+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java
@@ -38,6 +38,15 @@ public abstract class AbstractTestingBase {

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Add StructuresLocateEvent
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java
index 6f39e343147803e15e7681c993b8797a629702e7..cbff75f19e54b37c762b209b04f6d4799152cf5b 100644
index 6f39e343147803e15e7681c993b8797a629702e7..87154ae69788249960bca376aafd90bf64d5bfe7 100644
--- a/src/main/java/io/papermc/paper/registry/RegistryKey.java
+++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java
@@ -1,8 +1,13 @@
@ -15,28 +15,27 @@ index 6f39e343147803e15e7681c993b8797a629702e7..cbff75f19e54b37c762b209b04f6d479
+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<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
new file mode 100644
index 0000000000000000000000000000000000000000..41f6c2e1e60fc32e6393097711412ca2ad643e57
index 0000000000000000000000000000000000000000..ec66a52c06aceb4e16b987e695e50dbe0f9e1c44
--- /dev/null
+++ b/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java
@@ -0,0 +1,42 @@
@@ -0,0 +1,41 @@
+package io.papermc.paper.world.structure;
+
+import io.papermc.paper.registry.PaperRegistry;
+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..41f6c2e1e60fc32e6393097711412ca2
+ 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() {
+ 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 9941456a019a34384f892c44df3c73f9416bd560..d109ef77109fbeb710eafb55a38c803b9bb37d73 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2032,7 +2032,7 @@ 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
index fff5c9d40a0bab8642376db3ec25cc1e8d666fa6..a3af8b892a01756addc8c24e0726b5a8a700cbba 100644
index 0f92f2906195f5b2b70ca02a46fa111a46f8f18f..36940a873b2f891a50009fd44a2793c1940d2b05 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
@@ -302,6 +302,26 @@ public abstract class ChunkGenerator implements BiomeManager.NoiseBiomeSource {
@@ -295,6 +295,26 @@ public abstract class ChunkGenerator {
@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
+ 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<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));
+ }
+ 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,27 +95,27 @@ index fff5c9d40a0bab8642376db3ec25cc1e8d666fa6..a3af8b892a01756addc8c24e0726b5a8
+ }
+ 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<Holder<Biome>> 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
index af9ef29f5c5a600e4544ba735c833699cc93f93a..473a54963fbe08beeff26a828827f9f72d8a29b8 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
@@ -38,6 +38,7 @@ public class ConfiguredStructureFeature<FC extends FeatureConfiguration, F exten
public final HolderSet<Biome> biomes;
public final Map<MobCategory, StructureSpawnOverride> spawnOverrides;
public final boolean adaptNoise;
Map<StructurePlacement, Set<Holder<Structure>>> 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 737956b316c02e4ccdc6eef8de4a0a299d36b9ca..b8649eab719a1b71dc686386a8db756eefb9802e 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/Structure.java
@@ -41,6 +41,7 @@ public abstract class Structure {
public static final Codec<Structure> DIRECT_CODEC = Registry.STRUCTURE_TYPES.byNameCodec().dispatch(Structure::type, StructureType::codec);
public static final Codec<Holder<Structure>> 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<Biome> biomes, boolean bl, Map<MobCategory, StructureSpawnOverride> map) {
this.feature = feature;
public static <S extends Structure> RecordCodecBuilder<S, Structure.StructureSettings> settingsCodec(RecordCodecBuilder.Instance<S> 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..29c0209327374d5a4dad4e3bacdba7fa56d80749
index 0000000000000000000000000000000000000000..9b07d3128cc788efd17ed6a6bdd3370a3d88b48b
--- /dev/null
+++ b/src/test/java/io/papermc/paper/world/structure/ConfiguredStructureTest.java
@@ -0,0 +1,89 @@
@ -140,7 +126,7 @@ index 0000000000000000000000000000000000000000..29c0209327374d5a4dad4e3bacdba7fa
+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..29c0209327374d5a4dad4e3bacdba7fa
+
+ @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<ResourceLocation, ConfiguredStructureFeature<?, ?>> missing = new LinkedHashMap<>();
+ for (ConfiguredStructureFeature<?, ?> feature : BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE) {
+ final ResourceLocation key = BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.getKey(feature);
+ Map<ResourceLocation, Structure> 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..29c0209327374d5a4dad4e3bacdba7fa
+ @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<ResourceLocation, ConfiguredStructureFeature<?, ?>> missing) {
+ private static String printMissing(Map<ResourceLocation, Structure> missing) {
+ final StringJoiner joiner = new StringJoiner("\n", "Missing: \n", "");
+
+ missing.forEach((key, configuredFeature) -> {

View file

@ -28,10 +28,10 @@ index 96fd9803810db0f8a4b25e070a56da05862e1e4e..2b3e034d6cddbe5c94f2be856833680d
public int wanderingTraderSpawnDayTicks = 24000;
public int wanderingTraderSpawnChanceFailureIncrement = 25;
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index e53d8fe713a4c9920f40bf91d6453d36520b45f7..c14cbbf7d88d99bf5f24aad5c45fcb1504187a16 100644
index 202eca5204ab5eea2d63a1900046e3e15d45f97f..7d699878267293a6bb3183c218662144706f4abe 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1631,6 +1631,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1679,6 +1679,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
public void push(Entity entity) {
if (!this.isPassengerOfSameVehicle(entity)) {
if (!entity.noPhysics && !this.noPhysics) {
@ -40,10 +40,10 @@ index e53d8fe713a4c9920f40bf91d6453d36520b45f7..c14cbbf7d88d99bf5f24aad5c45fcb15
double d1 = entity.getZ() - this.getZ();
double d2 = Mth.absMax(d0, d1);
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
index 110006087af3f87457031dad7756235363af0506..96a7bfd921e59f298f0ee502d356cc3552c30ce8 100644
index 4984b2b3294e425247b595bcf36812728fb4cd16..dd2dfffcb5715b34a58262a52e83ff3030212ac4 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
@@ -831,6 +831,7 @@ public abstract class AbstractMinecart extends Entity {
@@ -833,6 +833,7 @@ public abstract class AbstractMinecart extends Entity {
public void push(Entity entity) {
if (!this.level.isClientSide) {
if (!entity.noPhysics && !this.noPhysics) {
@ -52,10 +52,10 @@ index 110006087af3f87457031dad7756235363af0506..96a7bfd921e59f298f0ee502d356cc35
// CraftBukkit start
VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
index c75e45bcb8cd6da154c7ca1719711622c009f463..a8f37fab9c8020e884bf029145d03e3be57b7f2b 100644
index 904ef44f6bb25a617c6e80d025fa0780a3bd63ec..ae069489eeb52489e69c10207739f07f867c58e4 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -239,6 +239,7 @@ public class Boat extends Entity {
@@ -243,6 +243,7 @@ public class Boat extends Entity {
@Override
public void push(Entity entity) {

View file

@ -7,7 +7,7 @@ The duplicate ProjectileHitEvent in EntityFireball was removed. The
event was always called before the duplicate call.
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
index 3de3258418f638a1b523c6a9178bb3ef1aaf2915..fa4e930388baa2ee0a752873b2ec1a67cc020de6 100644
index d71dc286673fa7ed708be5bec4c5a6868874c090..a603d99430aedb3c242c2833e0cc8a31aba49205 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
@@ -97,7 +97,7 @@ public abstract class AbstractHurtingProjectile extends Projectile {

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Return chat component with empty text instead of throwing
diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
index 3dc87e86dcd4c87e8e87e1dcd2765acb3b258bdf..bc0a49d41bdbc5544f789150ac239617d03b5837 100644
index f1438e527d6291a789d2ec821481f6ec142d1c0b..295bb2f0b853f41089ea233b8a4017198bc38caf 100644
--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
@@ -22,6 +22,7 @@ import net.minecraft.ReportedException;

View file

@ -5,11 +5,11 @@ 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 210df39e99bfe0f373cbdf7e0cd45ff1db9cd4aa..c0127908a954d3a40ca8829e3f1f63112212f261 100644
index 2c6d5f22ef41601f863b11e2e626621d8047dd14..1eb93353766208f52e385ab445cfb754e42b7f3d 100644
--- a/src/main/java/net/minecraft/server/commands/ScheduleCommand.java
+++ b/src/main/java/net/minecraft/server/commands/ScheduleCommand.java
@@ -31,7 +31,7 @@ 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) -> {
- return SharedSuggestionProvider.suggest((Iterable) ((CommandSourceStack) commandcontext.getSource()).getServer().getWorldData().overworldData().getScheduledEvents().getEventsIds(), suggestionsbuilder);

View file

@ -22,7 +22,7 @@ index 2b3e034d6cddbe5c94f2be856833680dd7b3b4f0..9bb6b6c6ac26790eaf5f8efe55f8db74
private void disableEndCredits() {
disableEndCredits = getBoolean("game-mechanics.disable-end-credits", false);
diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
index d1ab31d03ae421e628448fe2492ff138dc57c00f..999d18610666ec442bb038da5c452e3cd77e7428 100644
index 3db309e709cd72e3aae184ff2f8b1a7b98f2c7a8..9f2e5cd76376f0f15ed7d93018af2f605eb12e15 100644
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
@@ -48,7 +48,7 @@ public abstract class PathfinderMob extends Mob {

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Implement BlockPreDispenseEvent
diff --git a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
index 07d357b5fcb30ed9ff074a196a19de1481fe3738..83ac86b3c1e7b9233f2db8e5488f97c5b44f8843 100644
index 85c5319837295bd2f85baebfe8d6660b267f1d5f..8f55d0753fa26924235c943595f0d1a06a933a6f 100644
--- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java
@@ -92,6 +92,7 @@ public class DispenserBlock extends BaseEntityBlock {
@@ -93,6 +93,7 @@ public class DispenserBlock extends BaseEntityBlock {
DispenseItemBehavior idispensebehavior = this.getDispenseMethod(itemstack);
if (idispensebehavior != DispenseItemBehavior.NOOP) {

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 995a43ddcce8afb64404ef85641badd8035c6e3c..64e1571fab5f07cfe1b5203b36754f536b303f27 100644
--- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
@@ -158,13 +158,27 @@ 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

@ -1,34 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 25 Nov 2020 16:33:27 -0800
Subject: [PATCH] Added PlayerLoomPatternSelectEvent
diff --git a/src/main/java/net/minecraft/world/inventory/LoomMenu.java b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
index fba8c59071847d9669943534ff8a0898b5787c28..1fefb682d34ab165444c45439dbc1ea28dc9079f 100644
--- a/src/main/java/net/minecraft/world/inventory/LoomMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/LoomMenu.java
@@ -168,7 +168,22 @@ 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) {
- this.selectedBannerPatternIndex.set(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()));
+ if (!event.callEvent()) {
+ ((Player) player.getBukkitEntity()).updateInventory();
+ return false;
+ }
+ for (BannerPattern nms : BannerPattern.values()) {
+ if (event.getPatternType().getIdentifier().equals(nms.getHashname())) {
+ enumBannerPatternTypeOrdinal = nms.ordinal();
+ break;
+ }
+ }
+ ((Player) player.getBukkitEntity()).updateInventory();
+ this.selectedBannerPatternIndex.set(enumBannerPatternTypeOrdinal);
+ // Paper end
this.setupResultSlot();
return true;
} else {

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 063998751c21b4f75cf3bfff6c51c4e8c42bd5f3..a515898e718effe92c91fd0ac45fbb70ddb5d626 100644
--- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
@@ -160,10 +160,16 @@ 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
}
}