Archiviert
13
0
Dieser Commit ist enthalten in:
Bjarne Koll 2024-06-14 00:44:26 +02:00
Ursprung 083bd9e75c
Commit ed2ea4538e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 27F6CCCF55D2EE62
17 geänderte Dateien mit 180 neuen und 142 gelöschten Zeilen

Datei anzeigen

@ -339,7 +339,7 @@ index 4288bebf690a9cee6ff9a712352d1dcbb035eb77..a08c52949af1d2416ecb089fc559db2e
+ // Paper end - add Translatable
}
diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java
index 64675a3641acb50676ca0122f8473ce94de8fba7..c481b8ffb694519010f2bc3bc6447376ed802467 100644
index 64675a3641acb50676ca0122f8473ce94de8fba7..daae9bb234d2e10530b2bed35fada98652514e0e 100644
--- a/src/main/java/org/bukkit/enchantments/Enchantment.java
+++ b/src/main/java/org/bukkit/enchantments/Enchantment.java
@@ -15,7 +15,7 @@ import org.jetbrains.annotations.Nullable;
@ -351,6 +351,23 @@ index 64675a3641acb50676ca0122f8473ce94de8fba7..c481b8ffb694519010f2bc3bc6447376
/**
* Provides protection against environmental damage
*/
@@ -330,6 +330,16 @@ public abstract class Enchantment implements Keyed, Translatable {
public abstract net.kyori.adventure.text.@NotNull Component displayName(int level);
// Paper end
+ // Paper start - mark translation key as deprecated
+ /**
+ * @deprecated this method assumes that the enchantments description
+ * always be a translatable component which is not guaranteed.
+ */
+ @Override
+ @Deprecated(forRemoval = true)
+ public abstract @NotNull String translationKey();
+ // Paper end - mark translation key as deprecated
+
/**
* Gets the Enchantment at the specified key
*
diff --git a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java
index c4f86ba1037f3f0e5d697a0962d71d6f8c7c1fbe..ac0371285370594d4de1554871b19bbcd2311730 100644
--- a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java

Datei anzeigen

@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..aec3b41d7c3388e26fa203e3c062f1e6
+ }
+}
diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java
index c481b8ffb694519010f2bc3bc6447376ed802467..b35f0702c0b5a63515f5d0188c7ef61550f8410e 100644
index daae9bb234d2e10530b2bed35fada98652514e0e..fc30fbffd83285d4ec102a18454ed95289329667 100644
--- a/src/main/java/org/bukkit/enchantments/Enchantment.java
+++ b/src/main/java/org/bukkit/enchantments/Enchantment.java
@@ -290,11 +290,7 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
@ -56,7 +56,7 @@ index c481b8ffb694519010f2bc3bc6447376ed802467..b35f0702c0b5a63515f5d0188c7ef615
public abstract boolean isCursed();
/**
@@ -328,6 +324,97 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
@@ -328,6 +324,116 @@ public abstract class Enchantment implements Keyed, Translatable, net.kyori.adve
* @return the name of the enchantment with {@code level} applied
*/
public abstract net.kyori.adventure.text.@NotNull Component displayName(int level);
@ -127,11 +127,9 @@ index c481b8ffb694519010f2bc3bc6447376ed802467..b35f0702c0b5a63515f5d0188c7ef615
+ * @param level the level of enchantment
+ * @param entityCategory the category of entity
+ * @return the damage increase
+ * @deprecated Use {@link #getDamageIncrease(int, org.bukkit.entity.EntityType)} instead.
+ * Enchantment damage increase is no longer handled via {@link org.bukkit.entity.EntityCategory}s, but
+ * is instead controlled by tags, e.g. {@link org.bukkit.Tag#ENTITY_TYPES_SENSITIVE_TO_BANE_OF_ARTHROPODS}.
+ * As such, a category cannot properly represent all entities defined by the tags.
+ * @deprecated Enchantments now have a complex effect systems that cannot be reduced to a simple damage increase.
+ */
+ @Contract("-> fail")
+ @Deprecated(forRemoval = true, since = "1.20.5")
+ public abstract float getDamageIncrease(int level, @NotNull org.bukkit.entity.EntityCategory entityCategory);
+
@ -141,19 +139,40 @@ index c481b8ffb694519010f2bc3bc6447376ed802467..b35f0702c0b5a63515f5d0188c7ef615
+ * @param level the level of enchantment
+ * @param entityType the type of entity.
+ * @return the damage increase
+ * @deprecated Enchantments now have a complex effect systems that cannot be reduced to a simple damage increase.
+ */
+ @Contract("-> fail")
+ @Deprecated(forRemoval = true, since = "1.21")
+ public abstract float getDamageIncrease(int level, @NotNull org.bukkit.entity.EntityType entityType);
+
+ /**
+ * Gets the equipment slots where this enchantment is considered "active".
+ *
+ * @return the equipment slots
+ * @deprecated Use {@link #getActiveSlotGroups()} instead as enchantments are now applicable to a group of equipment slots.
+ */
+ @NotNull
+ @Deprecated(forRemoval = true, since = "1.21")
+ public java.util.Set<org.bukkit.inventory.EquipmentSlot> getActiveSlots() {
+ final java.util.Set<org.bukkit.inventory.EquipmentSlotGroup> slots = this.getActiveSlotGroups();
+ return java.util.Arrays.stream(org.bukkit.inventory.EquipmentSlot.values()).filter(e -> {
+ for (final org.bukkit.inventory.EquipmentSlotGroup group : slots) {
+ if (group.test(e)) return true;
+ }
+ return false;
+ }).collect(java.util.stream.Collectors.toSet());
+ }
+
+ /**
+ * Gets the equipment slots where this enchantment is considered "active".
+ *
+ * @return the equipment slots
+ */
+ @NotNull
+ public abstract java.util.Set<org.bukkit.inventory.EquipmentSlot> getActiveSlots();
+ public abstract java.util.Set<org.bukkit.inventory.EquipmentSlotGroup> getActiveSlotGroups();
// Paper end
/**
// Paper start - mark translation key as deprecated
diff --git a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java
index ac0371285370594d4de1554871b19bbcd2311730..da5d153a3e55a38b767359564001ad8663f9730b 100644
--- a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Introduce beacon activation/deactivation events
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
index dc39e7e3d166b0f7fb09e04b222b8db00d42b11b..a11f487197274da7cf3217f24e1cae2a343a7331 100644
index 52776ce9b7b4edd1eb474f14705d7fd83f5a66ca..e124f040386e130aebd7135434c4f06d130d28f6 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
@@ -225,6 +225,15 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name

Datei anzeigen

@ -122,10 +122,10 @@ index 0000000000000000000000000000000000000000..0d7e7db9e37ef0183c32b217bd944fb4
+ COMPRESSION_DISABLED
+}
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index fe89e8f509f3972ceb71c9aa6277524baa39985b..6c30eb3750f434341ecec0bf8e9054bb331f9757 100644
index ba41646a5edb57c4d9766df08bbc57016e2de189..2b86415e4ea197c5c44c23072c9a1cda595544a8 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -668,6 +668,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@@ -680,6 +680,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} else {
this.channel.pipeline().addAfter("prepender", "compress", new CompressionEncoder(compressionThreshold));
}
@ -133,7 +133,7 @@ index fe89e8f509f3972ceb71c9aa6277524baa39985b..6c30eb3750f434341ecec0bf8e9054bb
} else {
if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) {
this.channel.pipeline().remove("decompress");
@@ -676,6 +677,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@@ -688,6 +689,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) {
this.channel.pipeline().remove("compress");
}

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Send empty commands if tab completion is disabled
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index 43695b31cf23555d3d8a28b031ae6245f96ad1f7..3728b051b9eb9e9e06bc765a9a2fae7f45daf6ff 100644
index 937b5fe4be3573bc47754d627b60a112122a8d83..a19d132f6a71356f91b19197f02ccf312bb4b7c3 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -450,7 +450,12 @@ public class Commands {
@@ -448,7 +448,12 @@ public class Commands {
}
public void sendCommands(ServerPlayer player) {

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Add more WanderingTrader API
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
index 057eca881d279c610e933ebff5fb654625b036be..63189d6325173a42b619907b44a426848fbc6988 100644
index e51cb9c96e1bd13c00bf938436f4fc26d80055a1..856a93324f5ac411713851ccfb38dba52fb0af5e 100644
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
@@ -61,6 +61,10 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Add Adventure message to PlayerAdvancementDoneEvent
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
index f46fa0fbfec19904d21729847788c6c624a3e97f..c7e1f2bac3eca9bb72bf1f8c26cccb2905e1ddfc 100644
index d85fb1e2ea0eaef81e9039b47d18f83507e05a59..9fabf9322acd663c4452b562494e74aa42eb19da 100644
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
@@ -236,11 +236,21 @@ public class PlayerAdvancements {

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Add a "should burn in sunlight" API for Phantoms and
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 7013f1b76311a11fb7e2543ab1e792479ecad610..87ada535362303097862e811d3d573997983064f 100644
index a5593ac33878efc970c1bdd6f636438d160e9d50..6627126ab02dbd5e9d1de6b186d75d850ef11280 100644
--- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
+++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java
@@ -92,9 +92,15 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
@@ -93,9 +93,15 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
abstract SoundEvent getStepSound();
@ -26,7 +26,7 @@ index 7013f1b76311a11fb7e2543ab1e792479ecad610..87ada535362303097862e811d3d57399
if (flag) {
ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
@@ -228,7 +234,20 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
@@ -232,7 +238,20 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo
public void readAdditionalSaveData(CompoundTag nbt) {
super.readAdditionalSaveData(nbt);
this.reassessWeaponGoal();
@ -48,7 +48,7 @@ index 7013f1b76311a11fb7e2543ab1e792479ecad610..87ada535362303097862e811d3d57399
@Override
public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
diff --git a/src/main/java/net/minecraft/world/entity/monster/Phantom.java b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
index ac119e2efff7ba3c32425783ffcf4b3c44156f27..68f8945292753535a3b73acb9f48c1594f0789a4 100644
index 4b3bec32921feb1dcf71abf5e8d34fcbbc59baf5..c277dac448a64809e93dd7a447ee3dc2a86c860e 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Phantom.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Phantom.java
@@ -138,7 +138,7 @@ public class Phantom extends FlyingMob implements Enemy {
@ -57,7 +57,7 @@ index ac119e2efff7ba3c32425783ffcf4b3c44156f27..68f8945292753535a3b73acb9f48c159
public void aiStep() {
- if (this.isAlive() && this.isSunBurnTick()) {
+ if (this.isAlive() && this.shouldBurnInDay && this.isSunBurnTick()) { // Paper - shouldBurnInDay API
this.igniteForSeconds(8);
this.igniteForSeconds(8.0F);
}
@@ -169,6 +169,9 @@ public class Phantom extends FlyingMob implements Enemy {

Datei anzeigen

@ -92,10 +92,10 @@ index 0000000000000000000000000000000000000000..cf4374493c11057451a62a655514415c
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 144d09f65aca6456b060c5874b61f55a1cd5ae59..14616e4be1cfd4961fdb0d990310bf625cc821a9 100644
index ec92033fef581e42fb3f36acaba626894b369f56..d0eefb53fb88c56d72dea68269bd2b0ce6fd1c1b 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -303,6 +303,7 @@ public final class CraftServer implements Server {
@@ -305,6 +305,7 @@ public final class CraftServer implements Server {
private final List<CraftPlayer> playerView;
public int reloadCount;
public Set<String> activeCompatibilities = Collections.emptySet();
@ -103,7 +103,7 @@ index 144d09f65aca6456b060c5874b61f55a1cd5ae59..14616e4be1cfd4961fdb0d990310bf62
public static Exception excessiveVelEx; // Paper - Velocity warnings
static {
@@ -386,6 +387,7 @@ public final class CraftServer implements Server {
@@ -389,6 +390,7 @@ public final class CraftServer implements Server {
if (this.configuration.getBoolean("settings.use-map-color-cache")) {
MapPalette.setMapColorCache(new CraftMapColorCache(this.logger));
}
@ -111,7 +111,7 @@ index 144d09f65aca6456b060c5874b61f55a1cd5ae59..14616e4be1cfd4961fdb0d990310bf62
}
public boolean getCommandBlockOverride(String command) {
@@ -2992,5 +2994,11 @@ public final class CraftServer implements Server {
@@ -3000,5 +3002,11 @@ public final class CraftServer implements Server {
public com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() {
return mobGoals;
}

Datei anzeigen

@ -45,21 +45,23 @@ index 7f09119bc7d661e08a960dd2bd46006efe752d3e..d1da3600dc07107309b20ebe6e7c0c4d
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index d7a8664e9ccccdb4b4618399c72fa38c24354e46..2ff11c9aff04f404d45e0b267285e2b4a2a23b6f 100644
index 1cc771bfecc8d86d103879fbef28dbf993a7903e..ff6a8a3977ec489a372c72323e6285c16f00bd7f 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -2034,8 +2034,16 @@ public class ServerPlayer extends Player {
@@ -2087,10 +2087,18 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
}
public boolean setGameMode(GameType gameMode) {
- if (!this.gameMode.changeGameModeForPlayer(gameMode)) {
- return false;
+ // Paper start - Expand PlayerGameModeChangeEvent
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = this.setGameMode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null);
+ return event == null ? false : event.isCancelled();
+ }
+ @Nullable
+ public org.bukkit.event.player.PlayerGameModeChangeEvent setGameMode(GameType gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause cause, @Nullable net.kyori.adventure.text.Component message) {
boolean flag = this.isSpectator();
- if (!this.gameMode.changeGameModeForPlayer(gameMode)) {
- return false;
+ org.bukkit.event.player.PlayerGameModeChangeEvent event = this.gameMode.changeGameModeForPlayer(gameMode, cause, message);
+ if (event == null || event.isCancelled()) {
+ return null;
@ -67,7 +69,7 @@ index d7a8664e9ccccdb4b4618399c72fa38c24354e46..2ff11c9aff04f404d45e0b267285e2b4
} else {
this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) gameMode.getId()));
if (gameMode == GameType.SPECTATOR) {
@@ -2047,7 +2055,7 @@ public class ServerPlayer extends Player {
@@ -2106,7 +2114,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
this.onUpdateAbilities();
this.updateEffectVisibility();
@ -76,7 +78,7 @@ index d7a8664e9ccccdb4b4618399c72fa38c24354e46..2ff11c9aff04f404d45e0b267285e2b4
}
}
@@ -2457,6 +2465,16 @@ public class ServerPlayer extends Player {
@@ -2506,6 +2514,16 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
}
public void loadGameTypes(@Nullable CompoundTag nbt) {
@ -94,10 +96,10 @@ index d7a8664e9ccccdb4b4618399c72fa38c24354e46..2ff11c9aff04f404d45e0b267285e2b4
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index de3ec353ea32d5d71e2f1b4b369b79b85d7ce5e8..c55d944a70300bf77dbde918c91815cabe68496d 100644
index 5de472df78940d1b8320f73d18b2edf3a796227e..073cf184a0e7af41048ae67a9b17b4cdfcc43c35 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -72,14 +72,21 @@ public class ServerPlayerGameMode {
@@ -74,14 +74,21 @@ public class ServerPlayerGameMode {
}
public boolean changeGameModeForPlayer(GameType gameMode) {
@ -122,7 +124,7 @@ index de3ec353ea32d5d71e2f1b4b369b79b85d7ce5e8..c55d944a70300bf77dbde918c91815ca
}
// CraftBukkit end
this.setGameModeForPlayer(gameMode, this.previousGameModeForPlayer);
@@ -90,7 +97,7 @@ public class ServerPlayerGameMode {
@@ -92,7 +99,7 @@ public class ServerPlayerGameMode {
this.player.resetCurrentImpulseContext();
}
@ -132,12 +134,12 @@ index de3ec353ea32d5d71e2f1b4b369b79b85d7ce5e8..c55d944a70300bf77dbde918c91815ca
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index c8124bf451f5d03374f32a04b9b28fc9d97897ae..4a5553335cd6bbad8d3a05694710d95c96f62b9d 100644
index b1b833383c5196c2aee07fb7118cfef069abc3cd..498104eb1509e0f8389c07d1573a6b496b0bcd41 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2715,7 +2715,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2732,7 +2732,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.player = this.server.getPlayerList().respawn(this.player, false, RespawnReason.DEATH);
this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED, RespawnReason.DEATH); // CraftBukkit
if (this.server.isHardcore()) {
- this.player.setGameMode(GameType.SPECTATOR);
+ this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper - Expand PlayerGameModeChangeEvent
@ -145,10 +147,10 @@ index c8124bf451f5d03374f32a04b9b28fc9d97897ae..4a5553335cd6bbad8d3a05694710d95c
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 2d6de1734cb715554ca732d850b8df9591a3efb7..9a3ba0011f306a3cd1e3c60fcc329ab93011ebd8 100644
index 0c224de84b797856814f5378c87e6d048205e8d9..ed08f30d7163d01b5c280d20ea721da8d7f4b41e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1640,7 +1640,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -1653,7 +1653,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Preconditions.checkArgument(mode != null, "GameMode cannot be null");
if (this.getHandle().connection == null) return;

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] ItemStack repair check API
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index b89dcdf4b303042024dec1bf07f92fb08327f061..206f7fff1be676bebef086a0c1b5350cfd175e33 100644
index a71717fe99e78c480747cc61ab30b53b6667fde7..080ab25d3585552c1abd62a9992d48bf094fc065 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -551,6 +551,14 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -0,0 +1,101 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 6 May 2021 19:57:58 -0700
Subject: [PATCH] More Enchantment API
== AT ==
public net.minecraft.world.item.enchantment.Enchantment definition
Co-authored-by: Luis <luisc99@icloud.com>
Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
index 3ea6e6678432957c5caaff15ba20f8a8ddb393c9..10a74428ca8f8a869ba0d14f2a9b2126033df684 100644
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
+++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
@@ -5,6 +5,7 @@ import java.util.Locale;
import net.minecraft.Util;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
+import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.tags.EnchantmentTags;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
@@ -92,7 +93,7 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
@Override
public boolean isTreasure() {
- return !this.handle.is(EnchantmentTags.IN_ENCHANTING_TABLE);
+ return this.handle.is(EnchantmentTags.TREASURE); // Paper - use treasure tag
}
@Override
@@ -169,12 +170,66 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
// Paper start
@Override
public net.kyori.adventure.text.Component displayName(int level) {
- return io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().getFullname(level));
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(net.minecraft.world.item.enchantment.Enchantment.getFullname(this.handle, level));
}
@Override
public String translationKey() {
- return this.handle.getDescriptionId();
+ if (!(this.getHandle().description().getContents() instanceof final TranslatableContents translatableContents)) {
+ throw new UnsupportedOperationException("Description isn't translatable!"); // Paper
+ }
+ return translatableContents.getKey();
+ }
+
+ @Override
+ public boolean isTradeable() {
+ return this.handle.is(EnchantmentTags.TRADEABLE);
+ }
+
+ @Override
+ public boolean isDiscoverable() {
+ return this.handle.is(EnchantmentTags.IN_ENCHANTING_TABLE)
+ || this.handle.is(EnchantmentTags.ON_RANDOM_LOOT)
+ || this.handle.is(EnchantmentTags.ON_MOB_SPAWN_EQUIPMENT)
+ || this.handle.is(EnchantmentTags.TRADEABLE)
+ || this.handle.is(EnchantmentTags.ON_TRADED_EQUIPMENT);
+ }
+
+ @Override
+ public int getMinModifiedCost(int level) {
+ return this.getHandle().definition().minCost().calculate(level);
+ }
+
+ @Override
+ public int getMaxModifiedCost(int level) {
+ return this.getHandle().definition().maxCost().calculate(level);
+ }
+
+ @Override
+ public int getAnvilCost() {
+ return this.getHandle().definition().anvilCost();
+ }
+
+ @Override
+ public io.papermc.paper.enchantments.EnchantmentRarity getRarity() {
+ throw new UnsupportedOperationException("Enchantments don't have a rarity anymore in 1.20.5+.");
+ }
+
+ @Override
+ public float getDamageIncrease(int level, org.bukkit.entity.EntityCategory entityCategory) {
+ throw new UnsupportedOperationException("Enchantments are based on complex effect maps since 1.21, cannot compute a simple damage increase");
+ }
+
+ @Override
+ public float getDamageIncrease(int level, org.bukkit.entity.EntityType entityType) {
+ throw new UnsupportedOperationException("Enchantments are based on complex effect maps since 1.21, cannot compute a simple damage increase");
+ }
+
+ @Override
+ public java.util.Set<org.bukkit.inventory.EquipmentSlotGroup> getActiveSlotGroups() {
+ return this.getHandle().definition().slots().stream()
+ .map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot)
+ .collect(java.util.stream.Collectors.toSet());
}
// Paper end

Datei anzeigen

@ -1,101 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 6 May 2021 19:57:58 -0700
Subject: [PATCH] More Enchantment API
== AT ==
public net.minecraft.world.item.enchantment.Enchantment definition
Co-authored-by: Luis <luisc99@icloud.com>
Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
index faf0f726453aa957d17b75dfd8de5b40d984e69c..067aa761abd023991c884278a5cf0a63684026aa 100644
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
+++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
@@ -94,7 +94,7 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
@Override
public boolean isCursed() {
- return this.handle instanceof BindingCurseEnchantment || this.handle instanceof VanishingCurseEnchantment;
+ return this.handle.isCurse(); // Paper - More Enchantment API
}
@Override
@@ -166,13 +166,75 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
// Paper start
@Override
public net.kyori.adventure.text.Component displayName(int level) {
- return io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().getFullname(level));
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getFullname(level));
}
@Override
public String translationKey() {
return this.handle.getDescriptionId();
}
+
+ @Override
+ public boolean isTradeable() {
+ return this.handle.isTradeable();
+ }
+
+ @Override
+ public boolean isDiscoverable() {
+ return this.handle.isDiscoverable();
+ }
+
+ @Override
+ public int getMinModifiedCost(int level) {
+ return this.handle.getMinCost(level);
+ }
+
+ @Override
+ public int getMaxModifiedCost(int level) {
+ return this.handle.getMaxCost(level);
+ }
+
+ @Override
+ public int getAnvilCost() {
+ return this.handle.getAnvilCost();
+ }
+
+ @Override
+ public io.papermc.paper.enchantments.EnchantmentRarity getRarity() {
+ throw new UnsupportedOperationException("Enchantments don't have a rarity anymore in 1.20.5+.");
+ }
+
+ @Override
+ public float getDamageIncrease(int level, org.bukkit.entity.EntityCategory entityCategory) {
+ return this.handle.getDamageBonus(level, this.guessEntityTypeFromEnchantmentCategory(entityCategory));
+ }
+
+ @Override
+ public float getDamageIncrease(int level, org.bukkit.entity.EntityType entityType) {
+ return this.handle.getDamageBonus(level, org.bukkit.craftbukkit.util.CraftMagicNumbers.getEntityTypes(entityType));
+ }
+
+ @Deprecated(forRemoval = true)
+ private net.minecraft.world.entity.EntityType<?> guessEntityTypeFromEnchantmentCategory(
+ final org.bukkit.entity.EntityCategory entityCategory
+ ) {
+ final net.minecraft.tags.TagKey<net.minecraft.world.entity.EntityType<?>> tag = switch (entityCategory) {
+ case ARTHROPOD -> net.minecraft.tags.EntityTypeTags.SENSITIVE_TO_BANE_OF_ARTHROPODS;
+ case UNDEAD -> net.minecraft.tags.EntityTypeTags.SENSITIVE_TO_SMITE;
+ case WATER -> net.minecraft.tags.EntityTypeTags.SENSITIVE_TO_IMPALING;
+ default -> null;
+ };
+ if (tag == null) return null;
+
+ return net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.getTag(tag)
+ .map(e -> e.size() > 0 ? e.get(0).value() : null)
+ .orElse(null);
+ }
+
+ @Override
+ public java.util.Set<org.bukkit.inventory.EquipmentSlot> getActiveSlots() {
+ return java.util.stream.Stream.of(this.handle.definition.slots()).map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot).collect(java.util.stream.Collectors.toSet());
+ }
// Paper end
@Override