mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
538
This commit is contained in:
parent
02d989b548
commit
e0f5e2a1d5
@ -351,6 +351,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
/**
|
||||
* Provides protection against environmental damage
|
||||
*/
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java
|
||||
|
@ -127,11 +127,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ * @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 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ * @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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java
|
||||
|
@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy {
|
@ -48,18 +48,20 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
} else {
|
||||
this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) gameMode.getId()));
|
||||
if (gameMode == GameType.SPECTATOR) {
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
|
||||
|
||||
this.onUpdateAbilities();
|
||||
this.updateEffectVisibility();
|
||||
@ -76,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
|
||||
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
|
||||
}
|
||||
|
||||
public void loadGameTypes(@Nullable CompoundTag nbt) {
|
||||
@ -137,7 +139,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -0,0 +0,0 @@ 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
|
@ -13,12 +13,20 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
|
||||
@@ -0,0 +0,0 @@ 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;
|
||||
@@ -0,0 +0,0 @@ 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
|
||||
public boolean isTreasure() {
|
||||
- return !this.handle.is(EnchantmentTags.IN_ENCHANTING_TABLE);
|
||||
+ return this.handle.is(EnchantmentTags.TREASURE); // Paper - use treasure tag
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,37 +35,45 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
@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));
|
||||
+ 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();
|
||||
}
|
||||
- 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.isTradeable();
|
||||
+ return this.handle.is(EnchantmentTags.TRADEABLE);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isDiscoverable() {
|
||||
+ return this.handle.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.handle.getMinCost(level);
|
||||
+ return this.getHandle().definition().minCost().calculate(level);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxModifiedCost(int level) {
|
||||
+ return this.handle.getMaxCost(level);
|
||||
+ return this.getHandle().definition().maxCost().calculate(level);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getAnvilCost() {
|
||||
+ return this.handle.getAnvilCost();
|
||||
+ return this.getHandle().definition().anvilCost();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@ -67,35 +83,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ @Override
|
||||
+ public float getDamageIncrease(int level, org.bukkit.entity.EntityCategory entityCategory) {
|
||||
+ return this.handle.getDamageBonus(level, this.guessEntityTypeFromEnchantmentCategory(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) {
|
||||
+ 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);
|
||||
+ 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.EquipmentSlot> getActiveSlots() {
|
||||
+ return java.util.stream.Stream.of(this.handle.definition.slots()).map(org.bukkit.craftbukkit.CraftEquipmentSlot::getSlot).collect(java.util.stream.Collectors.toSet());
|
||||
+ }
|
||||
+ 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
|
||||
|
||||
@Override
|
Loading…
Reference in New Issue
Block a user