diff options
author | Owen1212055 <[email protected]> | 2024-06-17 16:12:09 -0400 |
---|---|---|
committer | Owen1212055 <[email protected]> | 2024-11-18 14:50:37 -0500 |
commit | f1f0bfc4165caf1335758ef97f9ebef7bcfc2ab3 (patch) | |
tree | 79ea55515692149525b75b1c68edc764ec1d8487 | |
parent | fc58c2a97de93c2e3c87816b8b113498b24e08c9 (diff) | |
download | Paper-f1f0bfc4165caf1335758ef97f9ebef7bcfc2ab3.tar.gz Paper-f1f0bfc4165caf1335758ef97f9ebef7bcfc2ab3.zip |
Jukebox component
-rw-r--r-- | patches/api/0480-WIP-DataComponent-API.patch | 46 | ||||
-rw-r--r-- | patches/server/1026-WIP-DataComponent-API.patch | 83 |
2 files changed, 121 insertions, 8 deletions
diff --git a/patches/api/0480-WIP-DataComponent-API.patch b/patches/api/0480-WIP-DataComponent-API.patch index 732e017c20..639fd14ae7 100644 --- a/patches/api/0480-WIP-DataComponent-API.patch +++ b/patches/api/0480-WIP-DataComponent-API.patch @@ -67,10 +67,10 @@ index 0000000000000000000000000000000000000000..50d15b4e0ed5cd17fdc95476ee4650ef +} diff --git a/src/main/java/io/papermc/paper/component/DataComponentTypes.java b/src/main/java/io/papermc/paper/component/DataComponentTypes.java new file mode 100644 -index 0000000000000000000000000000000000000000..dfb4bfa4183818d7aa6a714979b5f7b8808867f0 +index 0000000000000000000000000000000000000000..f400a1e230c51c96584e91a663d6f3500b0fb966 --- /dev/null +++ b/src/main/java/io/papermc/paper/component/DataComponentTypes.java -@@ -0,0 +1,112 @@ +@@ -0,0 +1,114 @@ +package io.papermc.paper.component; + +import io.papermc.paper.component.item.BannerPatternLayers; @@ -86,6 +86,7 @@ index 0000000000000000000000000000000000000000..dfb4bfa4183818d7aa6a714979b5f7b8 +import io.papermc.paper.component.item.ItemContainerContents; +import io.papermc.paper.component.item.ItemEnchantments; +import io.papermc.paper.component.item.ItemLore; ++import io.papermc.paper.component.item.JukeboxPlayable; +import io.papermc.paper.component.item.LockCode; +import io.papermc.paper.component.item.LodestoneTracker; +import io.papermc.paper.component.item.MapDecorations; @@ -156,6 +157,7 @@ index 0000000000000000000000000000000000000000..dfb4bfa4183818d7aa6a714979b5f7b8 + // block_entity_data + public static final DataComponentType.Valued<MusicInstrument> INSTRUMENT = valued("instrument"); + public static final DataComponentType.Valued<Integer> OMINOUS_BOTTLE_AMPLIFIER = valued("ominous_bottle_amplifier"); ++ public static final DataComponentType.Valued<JukeboxPlayable> JUKEBOX_PLAYALE = valued("jukebox_playable"); + public static final DataComponentType.Valued<List<Key>> RECIPES = valued("recipes"); + public static final DataComponentType.Valued<LodestoneTracker> LODESTONE_TRACKER = valued("lodestone_tracker"); + public static final DataComponentType.Valued<FireworkEffect> FIREWORK_EXPLOSION = valued("firework_explosion"); @@ -363,10 +365,10 @@ index 0000000000000000000000000000000000000000..48f5b0a3bceb4312a5a2e10ee27811ce +} diff --git a/src/main/java/io/papermc/paper/component/item/ComponentTypesBridge.java b/src/main/java/io/papermc/paper/component/item/ComponentTypesBridge.java new file mode 100644 -index 0000000000000000000000000000000000000000..6b00f5383bb3c957da62d2abe675f0d3059bad33 +index 0000000000000000000000000000000000000000..106790f1eb225fc6557d412f075fd40aeeebe412 --- /dev/null +++ b/src/main/java/io/papermc/paper/component/item/ComponentTypesBridge.java -@@ -0,0 +1,76 @@ +@@ -0,0 +1,78 @@ +package io.papermc.paper.component.item; + +import io.papermc.paper.util.Filtered; @@ -442,6 +444,8 @@ index 0000000000000000000000000000000000000000..6b00f5383bb3c957da62d2abe675f0d3 + LockCode.Builder lockCode(); + + ItemContainerContents.Builder itemContainerContents(); ++ ++ JukeboxPlayable.Builder jukeboxPlayable(); +} diff --git a/src/main/java/io/papermc/paper/component/item/CustomModelData.java b/src/main/java/io/papermc/paper/component/item/CustomModelData.java new file mode 100644 @@ -862,6 +866,40 @@ index 0000000000000000000000000000000000000000..f2db3054e16bcdd615b98cc728d17f96 + @NonNull Builder addAllLines(@NonNull List<@NonNull ? extends ComponentLike> lines); + } +} +diff --git a/src/main/java/io/papermc/paper/component/item/JukeboxPlayable.java b/src/main/java/io/papermc/paper/component/item/JukeboxPlayable.java +new file mode 100644 +index 0000000000000000000000000000000000000000..85ebf9c5e372ffc15b556c48f52baba540da1afa +--- /dev/null ++++ b/src/main/java/io/papermc/paper/component/item/JukeboxPlayable.java +@@ -0,0 +1,28 @@ ++package io.papermc.paper.component.item; ++ ++import io.papermc.paper.component.ComponentBuilder; ++import org.bukkit.JukeboxSong; ++import org.bukkit.attribute.Attribute; ++import org.bukkit.attribute.AttributeModifier; ++import org.checkerframework.checker.nullness.qual.NonNull; ++import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.Contract; ++import org.jetbrains.annotations.Unmodifiable; ++import java.util.List; ++ ++public interface JukeboxPlayable extends ShownInTooltip<JukeboxPlayable> { ++ ++ @Contract(value = "-> new", pure = true) ++ static JukeboxPlayable.@NonNull Builder jukeboxPlayable() { ++ return ComponentTypesBridge.bridge().jukeboxPlayable(); ++ } ++ ++ ++ @ApiStatus.NonExtendable ++ interface Builder extends ShownInTooltip.Builder<JukeboxPlayable.Builder>, ComponentBuilder<JukeboxPlayable> { ++ ++ @Contract(value = "_, -> this", mutates = "this") ++ @NonNull ++ Builder jukeboxSong(@NonNull JukeboxSong song); ++ } ++} diff --git a/src/main/java/io/papermc/paper/component/item/LockCode.java b/src/main/java/io/papermc/paper/component/item/LockCode.java new file mode 100644 index 0000000000000000000000000000000000000000..dfcd12fe3fed01ff93bce6eca732bd6f1f4cf5fd diff --git a/patches/server/1026-WIP-DataComponent-API.patch b/patches/server/1026-WIP-DataComponent-API.patch index 0d37202d54..02052bb2f2 100644 --- a/patches/server/1026-WIP-DataComponent-API.patch +++ b/patches/server/1026-WIP-DataComponent-API.patch @@ -40,10 +40,10 @@ index 0000000000000000000000000000000000000000..e538819c873a324c58bcd8e73f89510e +} diff --git a/src/main/java/io/papermc/paper/component/ComponentAdapters.java b/src/main/java/io/papermc/paper/component/ComponentAdapters.java new file mode 100644 -index 0000000000000000000000000000000000000000..067930a2f5d3655f74a52c75a10d1d2958c1adfa +index 0000000000000000000000000000000000000000..ca118915720c35075e0ceead4f5fbb2f2ae7835b --- /dev/null +++ b/src/main/java/io/papermc/paper/component/ComponentAdapters.java -@@ -0,0 +1,181 @@ +@@ -0,0 +1,183 @@ +package io.papermc.paper.component; + +import com.mojang.brigadier.exceptions.CommandSyntaxException; @@ -61,6 +61,7 @@ index 0000000000000000000000000000000000000000..067930a2f5d3655f74a52c75a10d1d29 +import io.papermc.paper.component.item.PaperItemContainerContents; +import io.papermc.paper.component.item.PaperItemEnchantments; +import io.papermc.paper.component.item.PaperItemLore; ++import io.papermc.paper.component.item.PaperJukeboxPlayable; +import io.papermc.paper.component.item.PaperLockCode; +import io.papermc.paper.component.item.PaperLodestoneTracker; +import io.papermc.paper.component.item.PaperMapDecorations; @@ -164,6 +165,7 @@ index 0000000000000000000000000000000000000000..067930a2f5d3655f74a52c75a10d1d29 + // block entity data + register(DataComponents.INSTRUMENT, CraftMusicInstrument::minecraftHolderToBukkit, CraftMusicInstrument::bukkitToMinecraftHolder); + registerIdentity(DataComponents.OMINOUS_BOTTLE_AMPLIFIER); ++ register(DataComponents.JUKEBOX_PLAYABLE, PaperJukeboxPlayable::new); + register(DataComponents.RECIPES, nms -> { + final List<Key> api = new ArrayList<>(nms.size()); + for (final ResourceLocation location : nms) { @@ -351,10 +353,10 @@ index 0000000000000000000000000000000000000000..5639559368e6866e9b0afa6688f3b12c +} diff --git a/src/main/java/io/papermc/paper/component/item/ComponentTypesBridgesImpl.java b/src/main/java/io/papermc/paper/component/item/ComponentTypesBridgesImpl.java new file mode 100644 -index 0000000000000000000000000000000000000000..5c26aec36c4e2ad2cc683735485f139cb32c05be +index 0000000000000000000000000000000000000000..8b130ee6a8eaa74e4899429d4f707e2e2615e9d0 --- /dev/null +++ b/src/main/java/io/papermc/paper/component/item/ComponentTypesBridgesImpl.java -@@ -0,0 +1,150 @@ +@@ -0,0 +1,155 @@ +package io.papermc.paper.component.item; + +import io.papermc.paper.util.Filtered; @@ -461,6 +463,11 @@ index 0000000000000000000000000000000000000000..5c26aec36c4e2ad2cc683735485f139c + } + + @Override ++ public JukeboxPlayable.Builder jukeboxPlayable() { ++ return new PaperJukeboxPlayable.BuilderImpl(); ++ } ++ ++ @Override + public WrittenBookContent.Builder writtenBookContent(final Filtered<String> title, final String author) { + return new PaperWrittenBookContent.BuilderImpl(title, author); + } @@ -1563,6 +1570,74 @@ index 0000000000000000000000000000000000000000..66c18c734d25fa4184f62146cdb84953 + } + } +} +diff --git a/src/main/java/io/papermc/paper/component/item/PaperJukeboxPlayable.java b/src/main/java/io/papermc/paper/component/item/PaperJukeboxPlayable.java +new file mode 100644 +index 0000000000000000000000000000000000000000..dbf25090748b0c6b675a4681f0d0c1b826f6757b +--- /dev/null ++++ b/src/main/java/io/papermc/paper/component/item/PaperJukeboxPlayable.java +@@ -0,0 +1,62 @@ ++package io.papermc.paper.component.item; ++ ++import com.google.common.base.Preconditions; ++import java.util.ArrayList; ++import java.util.List; ++import net.minecraft.world.item.EitherHolder; ++import org.bukkit.JukeboxSong; ++import org.bukkit.attribute.Attribute; ++import org.bukkit.attribute.AttributeModifier; ++import org.bukkit.craftbukkit.CraftEquipmentSlot; ++import org.bukkit.craftbukkit.CraftJukeboxSong; ++import org.bukkit.craftbukkit.attribute.CraftAttribute; ++import org.bukkit.craftbukkit.attribute.CraftAttributeInstance; ++import org.bukkit.craftbukkit.util.Handleable; ++import org.checkerframework.checker.nullness.qual.NonNull; ++import org.checkerframework.framework.qual.DefaultQualifier; ++ ++import static io.papermc.paper.component.item.ComponentUtils.transform; ++ ++@DefaultQualifier(NonNull.class) ++public record PaperJukeboxPlayable( ++ net.minecraft.world.item.JukeboxPlayable impl ++) implements JukeboxPlayable, Handleable<net.minecraft.world.item.JukeboxPlayable> { ++ ++ @Override ++ public net.minecraft.world.item.JukeboxPlayable getHandle() { ++ return this.impl; ++ } ++ ++ @Override ++ public boolean showInTooltip() { ++ return this.impl.showInTooltip(); ++ } ++ ++ @Override ++ public PaperJukeboxPlayable showInTooltip(final boolean showInTooltip) { ++ return new PaperJukeboxPlayable(this.impl.withTooltip(showInTooltip)); ++ } ++ ++ static final class BuilderImpl implements Builder { ++ ++ private JukeboxSong song = null; ++ private boolean showInTooltip = true; ++ ++ @Override ++ public Builder showInTooltip(final boolean showInTooltip) { ++ this.showInTooltip = showInTooltip; ++ return this; ++ } ++ ++ @Override ++ public @NonNull Builder jukeboxSong(@NonNull final JukeboxSong song) { ++ this.song = song; ++ return this; ++ } ++ ++ @Override ++ public @NonNull JukeboxPlayable build() { ++ return new PaperJukeboxPlayable(new net.minecraft.world.item.JukeboxPlayable(new EitherHolder<>(CraftJukeboxSong.bukkitToMinecraftHolder(this.song)), this.showInTooltip)); ++ } ++ } ++} diff --git a/src/main/java/io/papermc/paper/component/item/PaperLockCode.java b/src/main/java/io/papermc/paper/component/item/PaperLockCode.java new file mode 100644 index 0000000000000000000000000000000000000000..0e6320385a3eaea265bd3ffd2a9ee8310b18599d |