Adventure
== AT == public net.minecraft.network.chat.HoverEvent$ItemStackInfo item public net.minecraft.network.chat.HoverEvent$ItemStackInfo count public net.minecraft.network.chat.HoverEvent$ItemStackInfo components public net.minecraft.network.chat.contents.TranslatableContents filterAllowedArguments(Ljava/lang/Object;)Lcom/mojang/serialization/DataResult; Co-authored-by: zml <zml@stellardrift.ca> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
--- a/net/minecraft/world/BossEvent.java
|
||||
+++ b/net/minecraft/world/BossEvent.java
|
||||
@@ -13,6 +13,7 @@
|
||||
protected boolean darkenScreen;
|
||||
protected boolean playBossMusic;
|
||||
protected boolean createWorldFog;
|
||||
+ public net.kyori.adventure.bossbar.BossBar adventure; // Paper
|
||||
|
||||
public BossEvent(UUID uuid, Component name, BossEvent.BossBarColor color, BossEvent.BossBarOverlay style) {
|
||||
this.id = uuid;
|
||||
@@ -27,61 +28,75 @@
|
||||
}
|
||||
|
||||
public Component getName() {
|
||||
+ if (this.adventure != null) return io.papermc.paper.adventure.PaperAdventure.asVanilla(this.adventure.name()); // Paper
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(Component name) {
|
||||
+ if (this.adventure != null) this.adventure.name(io.papermc.paper.adventure.PaperAdventure.asAdventure(name)); // Paper
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public float getProgress() {
|
||||
+ if (this.adventure != null) return this.adventure.progress(); // Paper
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
public void setProgress(float percent) {
|
||||
+ if (this.adventure != null) this.adventure.progress(percent); // Paper
|
||||
this.progress = percent;
|
||||
}
|
||||
|
||||
public BossEvent.BossBarColor getColor() {
|
||||
+ if (this.adventure != null) return io.papermc.paper.adventure.PaperAdventure.asVanilla(this.adventure.color()); // Paper
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public void setColor(BossEvent.BossBarColor color) {
|
||||
+ if (this.adventure != null) this.adventure.color(io.papermc.paper.adventure.PaperAdventure.asAdventure(color)); // Paper
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public BossEvent.BossBarOverlay getOverlay() {
|
||||
+ if (this.adventure != null) return io.papermc.paper.adventure.PaperAdventure.asVanilla(this.adventure.overlay()); // Paper
|
||||
return this.overlay;
|
||||
}
|
||||
|
||||
public void setOverlay(BossEvent.BossBarOverlay style) {
|
||||
+ if (this.adventure != null) this.adventure.overlay(io.papermc.paper.adventure.PaperAdventure.asAdventure(style)); // Paper
|
||||
this.overlay = style;
|
||||
}
|
||||
|
||||
public boolean shouldDarkenScreen() {
|
||||
+ if (this.adventure != null) return this.adventure.hasFlag(net.kyori.adventure.bossbar.BossBar.Flag.DARKEN_SCREEN); // Paper
|
||||
return this.darkenScreen;
|
||||
}
|
||||
|
||||
public BossEvent setDarkenScreen(boolean darkenSky) {
|
||||
+ if (this.adventure != null) io.papermc.paper.adventure.PaperAdventure.setFlag(this.adventure, net.kyori.adventure.bossbar.BossBar.Flag.DARKEN_SCREEN, darkenSky); // Paper
|
||||
this.darkenScreen = darkenSky;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean shouldPlayBossMusic() {
|
||||
+ if (this.adventure != null) return this.adventure.hasFlag(net.kyori.adventure.bossbar.BossBar.Flag.PLAY_BOSS_MUSIC); // Paper
|
||||
return this.playBossMusic;
|
||||
}
|
||||
|
||||
public BossEvent setPlayBossMusic(boolean dragonMusic) {
|
||||
+ if (this.adventure != null) io.papermc.paper.adventure.PaperAdventure.setFlag(this.adventure, net.kyori.adventure.bossbar.BossBar.Flag.PLAY_BOSS_MUSIC, dragonMusic); // Paper
|
||||
this.playBossMusic = dragonMusic;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BossEvent setCreateWorldFog(boolean thickenFog) {
|
||||
+ if (this.adventure != null) io.papermc.paper.adventure.PaperAdventure.setFlag(this.adventure, net.kyori.adventure.bossbar.BossBar.Flag.CREATE_WORLD_FOG, thickenFog); // Paper
|
||||
this.createWorldFog = thickenFog;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean shouldCreateWorldFog() {
|
||||
+ if (this.adventure != null) return this.adventure.hasFlag(net.kyori.adventure.bossbar.BossBar.Flag.CREATE_WORLD_FOG); // Paper
|
||||
return this.createWorldFog;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
return instance.group(Item.CODEC.fieldOf("id").forGetter(ItemStack::getItemHolder), DataComponentPatch.CODEC.optionalFieldOf("components", DataComponentPatch.EMPTY).forGetter((itemstack) -> {
|
||||
return itemstack.components.asPatch();
|
||||
})).apply(instance, (holder, datacomponentpatch) -> {
|
||||
@@ -132,19 +161,29 @@
|
||||
@@ -132,20 +161,38 @@
|
||||
if (i <= 0) {
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
@@ -120,10 +120,19 @@
|
||||
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
||||
+ // Spigot end
|
||||
+ ITEM_STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.getItemHolder()); // CraftBukkit - decompile error
|
||||
+ // Paper start - adventure; conditionally render translatable components
|
||||
+ boolean prev = net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.get();
|
||||
+ try {
|
||||
+ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(true);
|
||||
DataComponentPatch.STREAM_CODEC.encode(registryfriendlybytebuf, itemstack.components.asPatch());
|
||||
+ } finally {
|
||||
+ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(prev);
|
||||
+ }
|
||||
+ // Paper end - adventure; conditionally render translatable components
|
||||
}
|
||||
}
|
||||
@@ -187,7 +226,7 @@
|
||||
};
|
||||
@@ -187,7 +234,7 @@
|
||||
|
||||
return dataresult.isError() ? dataresult.map((unit) -> {
|
||||
return stack;
|
||||
@@ -132,7 +141,7 @@
|
||||
int i = stack.getCount();
|
||||
|
||||
return "Item stack with stack size of " + i + " was larger than maximum: " + stack.getMaxStackSize();
|
||||
@@ -294,8 +333,9 @@
|
||||
@@ -294,8 +341,9 @@
|
||||
j = itemstack.getMaxStackSize();
|
||||
} while (i <= j);
|
||||
|
||||
@@ -143,7 +152,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -370,32 +410,190 @@
|
||||
@@ -370,32 +418,190 @@
|
||||
}
|
||||
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
@@ -339,7 +348,7 @@
|
||||
ItemStack itemstack = this.copy();
|
||||
boolean flag = this.getUseDuration(user) <= 0;
|
||||
InteractionResult enuminteractionresult = this.getItem().use(world, user, hand);
|
||||
@@ -492,7 +690,22 @@
|
||||
@@ -492,7 +698,22 @@
|
||||
|
||||
public void hurtAndBreak(int amount, ServerLevel world, @Nullable ServerPlayer player, Consumer<Item> breakCallback) {
|
||||
int j = this.processDurabilityChange(amount, world, player);
|
||||
@@ -362,7 +371,7 @@
|
||||
if (j != 0) {
|
||||
this.applyDamage(this.getDamageValue() + j, player, breakCallback);
|
||||
}
|
||||
@@ -511,6 +724,11 @@
|
||||
@@ -511,6 +732,11 @@
|
||||
this.setDamageValue(damage);
|
||||
if (this.isBroken()) {
|
||||
Item item = this.getItem();
|
||||
@@ -374,7 +383,7 @@
|
||||
|
||||
this.shrink(1);
|
||||
breakCallback.accept(item);
|
||||
@@ -518,7 +736,7 @@
|
||||
@@ -518,7 +744,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -383,7 +392,7 @@
|
||||
if (player instanceof ServerPlayer entityplayer) {
|
||||
int j = this.processDurabilityChange(amount, entityplayer.serverLevel(), entityplayer);
|
||||
|
||||
@@ -580,11 +798,11 @@
|
||||
@@ -580,11 +806,11 @@
|
||||
return this.getItem().getBarColor(this);
|
||||
}
|
||||
|
||||
@@ -397,7 +406,7 @@
|
||||
return this.getItem().overrideOtherStackedOnMe(this, stack, slot, clickType, player, cursorStackReference);
|
||||
}
|
||||
|
||||
@@ -592,8 +810,8 @@
|
||||
@@ -592,8 +818,8 @@
|
||||
Item item = this.getItem();
|
||||
|
||||
if (item.hurtEnemy(this, target, user)) {
|
||||
@@ -408,7 +417,7 @@
|
||||
|
||||
entityhuman.awardStat(Stats.ITEM_USED.get(item));
|
||||
}
|
||||
@@ -608,7 +826,7 @@
|
||||
@@ -608,7 +834,7 @@
|
||||
this.getItem().postHurtEnemy(this, target, user);
|
||||
}
|
||||
|
||||
@@ -417,7 +426,7 @@
|
||||
Item item = this.getItem();
|
||||
|
||||
if (item.mineBlock(this, world, state, pos, miner)) {
|
||||
@@ -617,11 +835,11 @@
|
||||
@@ -617,11 +843,11 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -431,7 +440,7 @@
|
||||
return this.getItem().interactLivingEntity(this, user, entity, hand);
|
||||
}
|
||||
|
||||
@@ -736,7 +954,7 @@
|
||||
@@ -736,7 +962,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -440,7 +449,7 @@
|
||||
player.awardStat(Stats.ITEM_CRAFTED.get(this.getItem()), amount);
|
||||
this.getItem().onCraftedBy(this, world, player);
|
||||
}
|
||||
@@ -768,7 +986,13 @@
|
||||
@@ -768,7 +994,13 @@
|
||||
|
||||
public boolean useOnRelease() {
|
||||
return this.getItem().useOnRelease(this);
|
||||
@@ -454,12 +463,10 @@
|
||||
|
||||
@Nullable
|
||||
public <T> T set(DataComponentType<? super T> type, @Nullable T value) {
|
||||
@@ -804,7 +1028,26 @@
|
||||
} else {
|
||||
this.getItem().verifyComponentsAfterLoad(this);
|
||||
@@ -806,6 +1038,25 @@
|
||||
}
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // Paper start - (this is just a good no conflict location)
|
||||
+ public org.bukkit.inventory.ItemStack asBukkitMirror() {
|
||||
+ return CraftItemStack.asCraftMirror(this);
|
||||
@@ -476,12 +483,13 @@
|
||||
+ bukkitStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this);
|
||||
+ }
|
||||
+ return bukkitStack;
|
||||
}
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
+
|
||||
public void applyComponents(DataComponentPatch changes) {
|
||||
this.components.applyPatch(changes);
|
||||
@@ -858,7 +1101,7 @@
|
||||
this.getItem().verifyComponentsAfterLoad(this);
|
||||
@@ -858,7 +1109,7 @@
|
||||
}
|
||||
|
||||
private <T extends TooltipProvider> void addToTooltip(DataComponentType<T> componentType, Item.TooltipContext context, Consumer<Component> textConsumer, TooltipFlag type) {
|
||||
@@ -490,7 +498,7 @@
|
||||
|
||||
if (t0 != null) {
|
||||
t0.addToTooltip(context, textConsumer, type);
|
||||
@@ -866,7 +1109,7 @@
|
||||
@@ -866,7 +1117,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -499,7 +507,7 @@
|
||||
boolean flag = this.getItem().shouldPrintOpWarning(this, player);
|
||||
|
||||
if (!type.isCreative() && this.has(DataComponents.HIDE_TOOLTIP)) {
|
||||
@@ -941,7 +1184,7 @@
|
||||
@@ -941,7 +1192,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +516,7 @@
|
||||
ItemAttributeModifiers itemattributemodifiers = (ItemAttributeModifiers) this.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY);
|
||||
|
||||
if (itemattributemodifiers.showInTooltip()) {
|
||||
@@ -966,7 +1209,7 @@
|
||||
@@ -966,7 +1217,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,7 +525,7 @@
|
||||
double d0 = modifier.amount();
|
||||
boolean flag = false;
|
||||
|
||||
@@ -1091,6 +1334,14 @@
|
||||
@@ -1091,6 +1342,14 @@
|
||||
EnchantmentHelper.forEachModifier(this, slot, attributeModifierConsumer);
|
||||
}
|
||||
|
||||
@@ -532,7 +540,7 @@
|
||||
public Component getDisplayName() {
|
||||
MutableComponent ichatmutablecomponent = Component.empty().append(this.getHoverName());
|
||||
|
||||
@@ -1153,7 +1404,7 @@
|
||||
@@ -1153,7 +1412,7 @@
|
||||
}
|
||||
|
||||
public void consume(int amount, @Nullable LivingEntity entity) {
|
||||
|
||||
@@ -109,22 +109,22 @@
|
||||
- return text;
|
||||
+ // CraftBukkit start
|
||||
+ Player player = ((ServerPlayer) entityhuman).getBukkitEntity();
|
||||
+ String[] lines = new String[4];
|
||||
+ List<net.kyori.adventure.text.Component> lines = new java.util.ArrayList<>(); // Paper - adventure
|
||||
+
|
||||
+ for (int i = 0; i < list.size(); ++i) {
|
||||
+ lines[i] = CraftChatMessage.fromComponent(signtext.getMessage(i, entityhuman.isTextFilteringEnabled()));
|
||||
+ lines.add(io.papermc.paper.adventure.PaperAdventure.asAdventure(signtext.getMessage(i, entityhuman.isTextFilteringEnabled()))); // Paper - Adventure
|
||||
+ }
|
||||
+
|
||||
+ SignChangeEvent event = new SignChangeEvent(CraftBlock.at(this.level, this.worldPosition), player, lines.clone(), (front) ? Side.FRONT : Side.BACK);
|
||||
+ SignChangeEvent event = new SignChangeEvent(CraftBlock.at(this.level, this.worldPosition), player, new java.util.ArrayList<>(lines), (front) ? Side.FRONT : Side.BACK); // Paper - Adventure
|
||||
+ entityhuman.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return originalText;
|
||||
+ }
|
||||
+
|
||||
+ Component[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines());
|
||||
+ Component[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.lines()); // Paper - Adventure
|
||||
+ for (int i = 0; i < components.length; i++) {
|
||||
+ if (!Objects.equals(lines[i], event.getLine(i))) {
|
||||
+ if (!Objects.equals(lines.get(i), event.line(i))) { // Paper - Adventure
|
||||
+ signtext = signtext.setMessage(i, components[i]);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
--- a/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||
+++ b/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||
@@ -47,6 +47,16 @@
|
||||
@@ -47,6 +47,17 @@
|
||||
import net.minecraft.world.level.saveddata.SavedData;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import io.papermc.paper.adventure.PaperAdventure; // Paper
|
||||
+import java.util.UUID;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.CraftServer;
|
||||
@@ -17,7 +18,7 @@
|
||||
public class MapItemSavedData extends SavedData {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -70,6 +80,13 @@
|
||||
@@ -70,6 +81,13 @@
|
||||
private final Map<String, MapFrame> frameMarkers = Maps.newHashMap();
|
||||
private int trackedDecorationCount;
|
||||
|
||||
@@ -31,7 +32,7 @@
|
||||
public static SavedData.Factory<MapItemSavedData> factory() {
|
||||
return new SavedData.Factory<>(() -> {
|
||||
throw new IllegalStateException("Should never create an empty map saved data");
|
||||
@@ -84,6 +101,10 @@
|
||||
@@ -84,6 +102,10 @@
|
||||
this.trackingPosition = showDecorations;
|
||||
this.unlimitedTracking = unlimitedTracking;
|
||||
this.locked = locked;
|
||||
@@ -42,7 +43,7 @@
|
||||
}
|
||||
|
||||
public static MapItemSavedData createFresh(double centerX, double centerZ, byte scale, boolean showDecorations, boolean unlimitedTracking, ResourceKey<Level> dimension) {
|
||||
@@ -101,12 +122,30 @@
|
||||
@@ -101,12 +123,30 @@
|
||||
}
|
||||
|
||||
public static MapItemSavedData load(CompoundTag nbt, HolderLookup.Provider registries) {
|
||||
@@ -76,7 +77,7 @@
|
||||
});
|
||||
int i = nbt.getInt("xCenter");
|
||||
int j = nbt.getInt("zCenter");
|
||||
@@ -131,7 +170,8 @@
|
||||
@@ -131,7 +171,8 @@
|
||||
MapBanner mapiconbanner = (MapBanner) iterator.next();
|
||||
|
||||
worldmap.bannerMarkers.put(mapiconbanner.getId(), mapiconbanner);
|
||||
@@ -86,7 +87,7 @@
|
||||
}
|
||||
|
||||
ListTag nbttaglist = nbt.getList("frames", 10);
|
||||
@@ -150,13 +190,32 @@
|
||||
@@ -150,13 +191,32 @@
|
||||
|
||||
@Override
|
||||
public CompoundTag save(CompoundTag nbt, HolderLookup.Provider registries) {
|
||||
@@ -120,7 +121,7 @@
|
||||
nbt.putInt("xCenter", this.centerX);
|
||||
nbt.putInt("zCenter", this.centerZ);
|
||||
nbt.putByte("scale", this.scale);
|
||||
@@ -443,7 +502,7 @@
|
||||
@@ -443,7 +503,7 @@
|
||||
|
||||
if (!this.isTrackedCountOverLimit(256)) {
|
||||
this.bannerMarkers.put(mapiconbanner.getId(), mapiconbanner);
|
||||
@@ -129,7 +130,7 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -554,7 +613,7 @@
|
||||
@@ -554,7 +614,7 @@
|
||||
this.player = entityhuman;
|
||||
}
|
||||
|
||||
@@ -138,7 +139,7 @@
|
||||
int i = this.minDirtyX;
|
||||
int j = this.minDirtyY;
|
||||
int k = this.maxDirtyX + 1 - this.minDirtyX;
|
||||
@@ -563,7 +622,7 @@
|
||||
@@ -563,7 +623,7 @@
|
||||
|
||||
for (int i1 = 0; i1 < k; ++i1) {
|
||||
for (int j1 = 0; j1 < l; ++j1) {
|
||||
@@ -147,7 +148,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,19 +632,29 @@
|
||||
@@ -573,19 +633,29 @@
|
||||
@Nullable
|
||||
Packet<?> nextUpdatePacket(MapId mapId) {
|
||||
MapItemSavedData.MapPatch worldmap_c;
|
||||
@@ -172,7 +173,7 @@
|
||||
+
|
||||
+ for (org.bukkit.map.MapCursor cursor : render.cursors) {
|
||||
+ if (cursor.isVisible()) {
|
||||
+ icons.add(new MapDecoration(CraftMapCursor.CraftType.bukkitToMinecraftHolder(cursor.getType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrOptional(cursor.getCaption())));
|
||||
+ icons.add(new MapDecoration(CraftMapCursor.CraftType.bukkitToMinecraftHolder(cursor.getType()), cursor.getX(), cursor.getY(), cursor.getDirection(), Optional.ofNullable(PaperAdventure.asVanilla(cursor.caption()))));
|
||||
+ }
|
||||
+ }
|
||||
+ collection = icons;
|
||||
|
||||
Reference in New Issue
Block a user