mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-18 12:48:53 +01:00
fix components
This commit is contained in:
parent
b0d7153f50
commit
2206b9a5f2
3 changed files with 52 additions and 39 deletions
|
@ -54,7 +54,7 @@ public class GeneratedKeyType<T, A> extends SimpleGenerator {
|
||||||
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> VANILLA_REGISTRY_ENTRIES = VanillaRegistries.BUILDER.entries.stream()
|
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> VANILLA_REGISTRY_ENTRIES = VanillaRegistries.BUILDER.entries.stream()
|
||||||
.collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap));
|
.collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap));
|
||||||
|
|
||||||
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> EXPERIMENTAL_REGISTRY_ENTRIES = Map.of();
|
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> EXPERIMENTAL_REGISTRY_ENTRIES = Map.of(); // Update for Experimental API
|
||||||
private static final Map<RegistryKey<?>, String> REGISTRY_KEY_FIELD_NAMES;
|
private static final Map<RegistryKey<?>, String> REGISTRY_KEY_FIELD_NAMES;
|
||||||
static {
|
static {
|
||||||
final Map<RegistryKey<?>, String> map = new HashMap<>();
|
final Map<RegistryKey<?>, String> map = new HashMap<>();
|
||||||
|
@ -148,7 +148,7 @@ public class GeneratedKeyType<T, A> extends SimpleGenerator {
|
||||||
.initializer("$N(key($S))", createMethod.build(), keyPath)
|
.initializer("$N(key($S))", createMethod.build(), keyPath)
|
||||||
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.location().toString());
|
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.location().toString());
|
||||||
if (experimental.contains(key)) {
|
if (experimental.contains(key)) {
|
||||||
//fieldBuilder.addAnnotations(experimentalAnnotations(MinecraftExperimental.Requires.WINTER_DROP)); // Update for Experimental API
|
fieldBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||||
} else {
|
} else {
|
||||||
allExperimental = false;
|
allExperimental = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ index 0000000000000000000000000000000000000000..e2266d86a4dd1bf20346e48c428f8baf
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java
|
diff --git a/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..68284abd5c4358617ee7766101e942f81a001e2c
|
index 0000000000000000000000000000000000000000..aa71271632aafb4169ff0e4967273003adbc7da1
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java
|
+++ b/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java
|
||||||
@@ -0,0 +1,344 @@
|
@@ -0,0 +1,344 @@
|
||||||
|
@ -345,7 +345,7 @@ index 0000000000000000000000000000000000000000..68284abd5c4358617ee7766101e942f8
|
||||||
+ public static final DataComponentType.Valued<UseRemainder> USE_REMAINDER = valued("use_remainder");
|
+ public static final DataComponentType.Valued<UseRemainder> USE_REMAINDER = valued("use_remainder");
|
||||||
+ public static final DataComponentType.Valued<UseCooldown> USE_COOLDOWN = valued("use_cooldown");
|
+ public static final DataComponentType.Valued<UseCooldown> USE_COOLDOWN = valued("use_cooldown");
|
||||||
+ /**
|
+ /**
|
||||||
+ * If present, this item will not burn in fire.
|
+ * If present, this item will not take damage from the specified damage types.
|
||||||
+ */
|
+ */
|
||||||
+ public static final DataComponentType.Valued<DamageResistant> DAMAGE_RESISTANT = valued("damage_resistant");
|
+ public static final DataComponentType.Valued<DamageResistant> DAMAGE_RESISTANT = valued("damage_resistant");
|
||||||
+ /**
|
+ /**
|
||||||
|
@ -435,10 +435,10 @@ index 0000000000000000000000000000000000000000..68284abd5c4358617ee7766101e942f8
|
||||||
+ * Controls the amplifier amount for an Ominous Bottle's Bad Omen effect.
|
+ * Controls the amplifier amount for an Ominous Bottle's Bad Omen effect.
|
||||||
+ */
|
+ */
|
||||||
+ public static final DataComponentType.Valued<OminousBottleAmplifier> OMINOUS_BOTTLE_AMPLIFIER = valued("ominous_bottle_amplifier");
|
+ public static final DataComponentType.Valued<OminousBottleAmplifier> OMINOUS_BOTTLE_AMPLIFIER = valued("ominous_bottle_amplifier");
|
||||||
|
+ public static final DataComponentType.Valued<JukeboxPlayable> JUKEBOX_PLAYABLE = valued("jukebox_playable");
|
||||||
+ /**
|
+ /**
|
||||||
+ * List of recipes that should be unlocked when using the Knowledge Book item.
|
+ * List of recipes that should be unlocked when using the Knowledge Book item.
|
||||||
+ */
|
+ */
|
||||||
+ public static final DataComponentType.Valued<JukeboxPlayable> JUKEBOX_PLAYABLE = valued("jukebox_playable");
|
|
||||||
+ public static final DataComponentType.Valued<List<Key>> RECIPES = valued("recipes");
|
+ public static final DataComponentType.Valued<List<Key>> RECIPES = valued("recipes");
|
||||||
+ /**
|
+ /**
|
||||||
+ * If present, specifies that the Compass is a Lodestone Compass.
|
+ * If present, specifies that the Compass is a Lodestone Compass.
|
||||||
|
@ -636,7 +636,7 @@ index 0000000000000000000000000000000000000000..65f1bc8d1bea0042dca9683c43956113
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java b/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java
|
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java b/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..d47a78a6f51db66950ee67c60cfef1e21f4a4d40
|
index 0000000000000000000000000000000000000000..696a4cebb902c4afd2d2f78bb8d9261bd09d7cb1
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java
|
+++ b/src/main/java/io/papermc/paper/datacomponent/item/BundleContents.java
|
||||||
@@ -0,0 +1,65 @@
|
@@ -0,0 +1,65 @@
|
||||||
|
@ -674,7 +674,7 @@ index 0000000000000000000000000000000000000000..d47a78a6f51db66950ee67c60cfef1e2
|
||||||
+ *
|
+ *
|
||||||
+ * @return items
|
+ * @return items
|
||||||
+ */
|
+ */
|
||||||
+ @Contract(value = "-> new", pure = true)
|
+ @Contract(pure = true)
|
||||||
+ @Unmodifiable List<ItemStack> contents();
|
+ @Unmodifiable List<ItemStack> contents();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
|
@ -853,10 +853,10 @@ index 0000000000000000000000000000000000000000..8c88bbbeef179e6c6666d07c8b28157e
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/CustomModelData.java b/src/main/java/io/papermc/paper/datacomponent/item/CustomModelData.java
|
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/CustomModelData.java b/src/main/java/io/papermc/paper/datacomponent/item/CustomModelData.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..734b1750a00f711a57186f15285cfc4c2563b1a2
|
index 0000000000000000000000000000000000000000..334a87c1984cbddd835f25bbe04e03579cefc88d
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/CustomModelData.java
|
+++ b/src/main/java/io/papermc/paper/datacomponent/item/CustomModelData.java
|
||||||
@@ -0,0 +1,144 @@
|
@@ -0,0 +1,145 @@
|
||||||
+package io.papermc.paper.datacomponent.item;
|
+package io.papermc.paper.datacomponent.item;
|
||||||
+
|
+
|
||||||
+import java.util.List;
|
+import java.util.List;
|
||||||
|
@ -864,6 +864,7 @@ index 0000000000000000000000000000000000000000..734b1750a00f711a57186f15285cfc4c
|
||||||
+import org.bukkit.Color;
|
+import org.bukkit.Color;
|
||||||
+import org.jetbrains.annotations.ApiStatus;
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
+import org.jetbrains.annotations.Contract;
|
+import org.jetbrains.annotations.Contract;
|
||||||
|
+import org.jetbrains.annotations.Unmodifiable;
|
||||||
+import org.jspecify.annotations.NullMarked;
|
+import org.jspecify.annotations.NullMarked;
|
||||||
+
|
+
|
||||||
+/**
|
+/**
|
||||||
|
@ -887,7 +888,7 @@ index 0000000000000000000000000000000000000000..734b1750a00f711a57186f15285cfc4c
|
||||||
+ * @return the float values
|
+ * @return the float values
|
||||||
+ */
|
+ */
|
||||||
+ @Contract(pure = true)
|
+ @Contract(pure = true)
|
||||||
+ List<Float> floats();
|
+ @Unmodifiable List<Float> floats();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Gets the custom model data boolean values.
|
+ * Gets the custom model data boolean values.
|
||||||
|
@ -895,7 +896,7 @@ index 0000000000000000000000000000000000000000..734b1750a00f711a57186f15285cfc4c
|
||||||
+ * @return the boolean values
|
+ * @return the boolean values
|
||||||
+ */
|
+ */
|
||||||
+ @Contract(pure = true)
|
+ @Contract(pure = true)
|
||||||
+ List<Boolean> flags();
|
+ @Unmodifiable List<Boolean> flags();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Gets the custom model data string values.
|
+ * Gets the custom model data string values.
|
||||||
|
@ -903,7 +904,7 @@ index 0000000000000000000000000000000000000000..734b1750a00f711a57186f15285cfc4c
|
||||||
+ * @return the string values
|
+ * @return the string values
|
||||||
+ */
|
+ */
|
||||||
+ @Contract(pure = true)
|
+ @Contract(pure = true)
|
||||||
+ List<String> strings();
|
+ @Unmodifiable List<String> strings();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Gets the custom model data color values.
|
+ * Gets the custom model data color values.
|
||||||
|
@ -911,7 +912,7 @@ index 0000000000000000000000000000000000000000..734b1750a00f711a57186f15285cfc4c
|
||||||
+ * @return the color values
|
+ * @return the color values
|
||||||
+ */
|
+ */
|
||||||
+ @Contract(pure = true)
|
+ @Contract(pure = true)
|
||||||
+ List<Color> colors();
|
+ @Unmodifiable List<Color> colors();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Builder for {@link CustomModelData}.
|
+ * Builder for {@link CustomModelData}.
|
||||||
|
@ -923,29 +924,29 @@ index 0000000000000000000000000000000000000000..734b1750a00f711a57186f15285cfc4c
|
||||||
+ /**
|
+ /**
|
||||||
+ * Adds a float to this custom model data.
|
+ * Adds a float to this custom model data.
|
||||||
+ *
|
+ *
|
||||||
+ * @param num the float
|
+ * @param f the float
|
||||||
+ * @return the builder for chaining
|
+ * @return the builder for chaining
|
||||||
+ * @see #floats()
|
+ * @see #floats()
|
||||||
+ */
|
+ */
|
||||||
+ @Contract(value = "_ -> this", mutates = "this")
|
+ @Contract(value = "_ -> this", mutates = "this")
|
||||||
+ CustomModelData.Builder addFloat(float num);
|
+ CustomModelData.Builder addFloat(float f);
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Adds multiple floats to this custom model data.
|
+ * Adds multiple floats to this custom model data.
|
||||||
+ *
|
+ *
|
||||||
+ * @param nums the floats
|
+ * @param floats the floats
|
||||||
+ * @return the builder for chaining
|
+ * @return the builder for chaining
|
||||||
+ * @see #floats()
|
+ * @see #floats()
|
||||||
+ */
|
+ */
|
||||||
+ @Contract(value = "_ -> this", mutates = "this")
|
+ @Contract(value = "_ -> this", mutates = "this")
|
||||||
+ CustomModelData.Builder addFloats(List<Float> nums);
|
+ CustomModelData.Builder addFloats(List<Float> floats);
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Adds a flag to this custom model data.
|
+ * Adds a flag to this custom model data.
|
||||||
+ *
|
+ *
|
||||||
+ * @param flag the flag
|
+ * @param flag the flag
|
||||||
+ * @return the builder for chaining
|
+ * @return the builder for chaining
|
||||||
+ * @see #floats()
|
+ * @see #flags()
|
||||||
+ */
|
+ */
|
||||||
+ @Contract(value = "_ -> this", mutates = "this")
|
+ @Contract(value = "_ -> this", mutates = "this")
|
||||||
+ CustomModelData.Builder addFlag(boolean flag);
|
+ CustomModelData.Builder addFlag(boolean flag);
|
||||||
|
@ -983,7 +984,7 @@ index 0000000000000000000000000000000000000000..734b1750a00f711a57186f15285cfc4c
|
||||||
+ /**
|
+ /**
|
||||||
+ * Adds a color to this custom model data.
|
+ * Adds a color to this custom model data.
|
||||||
+ *
|
+ *
|
||||||
+ * @param color the float
|
+ * @param color the color
|
||||||
+ * @return the builder for chaining
|
+ * @return the builder for chaining
|
||||||
+ * @see #colors()
|
+ * @see #colors()
|
||||||
+ */
|
+ */
|
||||||
|
|
|
@ -963,13 +963,20 @@ index 0000000000000000000000000000000000000000..0bc2bad71d6945ca24f37008effc903a
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java
|
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..a47fe18c1b619df9ff3adacf5c7c670dece84179
|
index 0000000000000000000000000000000000000000..33a93c8acf79d02f8a19e66c4f52dfdd4471680e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java
|
+++ b/src/main/java/io/papermc/paper/datacomponent/item/PaperCustomModelData.java
|
||||||
@@ -0,0 +1,109 @@
|
@@ -0,0 +1,121 @@
|
||||||
+package io.papermc.paper.datacomponent.item;
|
+package io.papermc.paper.datacomponent.item;
|
||||||
+
|
+
|
||||||
+import java.util.ArrayList;
|
+import com.google.common.base.Preconditions;
|
||||||
|
+import it.unimi.dsi.fastutil.booleans.BooleanArrayList;
|
||||||
|
+import it.unimi.dsi.fastutil.booleans.BooleanList;
|
||||||
|
+import it.unimi.dsi.fastutil.floats.FloatArrayList;
|
||||||
|
+import it.unimi.dsi.fastutil.floats.FloatList;
|
||||||
|
+import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
|
+import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
|
+import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
+import java.util.Collections;
|
+import java.util.Collections;
|
||||||
+import java.util.List;
|
+import java.util.List;
|
||||||
+import io.papermc.paper.util.MCUtil;
|
+import io.papermc.paper.util.MCUtil;
|
||||||
|
@ -1007,20 +1014,23 @@ index 0000000000000000000000000000000000000000..a47fe18c1b619df9ff3adacf5c7c670d
|
||||||
+
|
+
|
||||||
+ static final class BuilderImpl implements CustomModelData.Builder {
|
+ static final class BuilderImpl implements CustomModelData.Builder {
|
||||||
+
|
+
|
||||||
+ private final List<Float> floats = new ArrayList<>();
|
+ private final FloatList floats = new FloatArrayList();
|
||||||
+ private final List<Boolean> flags = new ArrayList<>();
|
+ private final BooleanList flags = new BooleanArrayList();
|
||||||
+ private final List<String> strings = new ArrayList<>();
|
+ private final List<String> strings = new ObjectArrayList<>();
|
||||||
+ private final List<Integer> colors = new ArrayList<>();
|
+ private final IntList colors = new IntArrayList();
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Builder addFloat(final float num) {
|
+ public Builder addFloat(final float f) {
|
||||||
+ this.floats.add(num);
|
+ this.floats.add(f);
|
||||||
+ return this;
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Builder addFloats(final List<Float> nums) {
|
+ public Builder addFloats(final List<Float> floats) {
|
||||||
+ this.floats.addAll(nums);
|
+ for (Float f : floats) {
|
||||||
|
+ Preconditions.checkArgument(f != null, "Float cannot be null");
|
||||||
|
+ }
|
||||||
|
+ this.floats.addAll(floats);
|
||||||
+ return this;
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -1032,33 +1042,36 @@ index 0000000000000000000000000000000000000000..a47fe18c1b619df9ff3adacf5c7c670d
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Builder addFlags(final List<Boolean> flags) {
|
+ public Builder addFlags(final List<Boolean> flags) {
|
||||||
|
+ for (Boolean flag : flags) {
|
||||||
|
+ Preconditions.checkArgument(flag != null, "Flag cannot be null");
|
||||||
|
+ }
|
||||||
+ this.flags.addAll(flags);
|
+ this.flags.addAll(flags);
|
||||||
+ return this;
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Builder addString(final String string) {
|
+ public Builder addString(final String string) {
|
||||||
|
+ Preconditions.checkArgument(string != null, "String cannot be null");
|
||||||
+ this.strings.add(string);
|
+ this.strings.add(string);
|
||||||
+ return this;
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Builder addStrings(final List<String> strings) {
|
+ public Builder addStrings(final List<String> strings) {
|
||||||
+ this.strings.addAll(strings);
|
+ strings.forEach(this::addString);
|
||||||
+ return this;
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Builder addColor(final Color color) {
|
+ public Builder addColor(final Color color) {
|
||||||
|
+ Preconditions.checkArgument(color != null, "Color cannot be null");
|
||||||
+ this.colors.add(color.asRGB());
|
+ this.colors.add(color.asRGB());
|
||||||
+ return this;
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Builder addColors(final List<Color> colors) {
|
+ public Builder addColors(final List<Color> colors) {
|
||||||
+ for (Color color : colors) {
|
+ colors.forEach(this::addColor);
|
||||||
+ this.addColor(color);
|
|
||||||
+ }
|
|
||||||
+ return this;
|
+ return this;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -1066,14 +1079,13 @@ index 0000000000000000000000000000000000000000..a47fe18c1b619df9ff3adacf5c7c670d
|
||||||
+ public CustomModelData build() {
|
+ public CustomModelData build() {
|
||||||
+ return new PaperCustomModelData(
|
+ return new PaperCustomModelData(
|
||||||
+ new net.minecraft.world.item.component.CustomModelData(
|
+ new net.minecraft.world.item.component.CustomModelData(
|
||||||
+ this.floats,
|
+ new FloatArrayList(this.floats),
|
||||||
+ this.flags,
|
+ new BooleanArrayList(this.flags),
|
||||||
+ this.strings,
|
+ new ObjectArrayList<>(this.strings),
|
||||||
+ this.colors
|
+ new IntArrayList(this.colors)
|
||||||
+ )
|
+ )
|
||||||
+ );
|
+ );
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperDamageResistant.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperDamageResistant.java
|
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/PaperDamageResistant.java b/src/main/java/io/papermc/paper/datacomponent/item/PaperDamageResistant.java
|
||||||
|
|
Loading…
Reference in a new issue