mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Some fixes, start updating CustomModelData API
This commit is contained in:
parent
2c2dadf75b
commit
a894c3a437
@ -859,12 +859,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import java.util.List;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Holds the custom model data.
|
||||
+ *
|
||||
+ * @see io.papermc.paper.datacomponent.DataComponentTypes#CUSTOM_MODEL_DATA
|
||||
+ */
|
||||
+@NullMarked
|
||||
@ -872,18 +874,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+@ApiStatus.NonExtendable
|
||||
+public interface CustomModelData {
|
||||
+
|
||||
+ @Contract(value = "_ -> new", pure = true)
|
||||
+ static CustomModelData customModelData(final int id) {
|
||||
+ return ItemComponentTypesBridge.bridge().customModelData(id);
|
||||
+ }
|
||||
+ // TODO
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the custom model data id.
|
||||
+ * Gets the custom model data float values.
|
||||
+ *
|
||||
+ * @return the id
|
||||
+ * @return the float values
|
||||
+ */
|
||||
+ @Contract(pure = true)
|
||||
+ int id();
|
||||
+ List<Float> floats();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the custom model data boolean values.
|
||||
+ *
|
||||
+ * @return the boolean values
|
||||
+ */
|
||||
+ @Contract(pure = true)
|
||||
+ List<Boolean> flags();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the custom model data string values.
|
||||
+ *
|
||||
+ * @return the string values
|
||||
+ */
|
||||
+ @Contract(pure = true)
|
||||
+ List<String> strings();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the custom model data color values.
|
||||
+ *
|
||||
+ * @return the color values
|
||||
+ */
|
||||
+ @Contract(pure = true)
|
||||
+ List<Integer> colors();
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/datacomponent/item/DamageResistant.java b/src/main/java/io/papermc/paper/datacomponent/item/DamageResistant.java
|
||||
new file mode 100644
|
||||
|
@ -26,4 +26,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return !this.isRemoved() && this.getHealth() > 0.0F && !this.dead; // Paper - Check this.dead
|
||||
}
|
||||
|
||||
public boolean isLookingAtMe(LivingEntity entity, double d0, boolean flag, boolean visualShape, Predicate<LivingEntity> predicate, DoubleSupplier... entityYChecks) {
|
||||
public boolean isLookingAtMe(LivingEntity entity, double d0, boolean flag, boolean visualShape, double... checkedYs) {
|
@ -969,6 +969,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import java.util.List;
|
||||
+import org.bukkit.craftbukkit.util.Handleable;
|
||||
+
|
||||
+public record PaperCustomModelData(
|
||||
@ -981,8 +982,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int id() {
|
||||
+ return this.impl.value();
|
||||
+ public List<Float> floats() {
|
||||
+ return this.impl.floats();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<Boolean> flags() {
|
||||
+ return this.impl.flags();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> strings() {
|
||||
+ return this.impl.strings();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<Integer> colors() {
|
||||
+ return this.impl.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
|
@ -8,10 +8,10 @@ diff --git a/src/main/java/net/minecraft/world/item/component/CustomData.java b/
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/component/CustomData.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/component/CustomData.java
|
||||
@@ -0,0 +0,0 @@ import org.slf4j.Logger;
|
||||
public final class CustomData {
|
||||
@@ -0,0 +0,0 @@ public final class CustomData {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final CustomData EMPTY = new CustomData(new CompoundTag());
|
||||
private static final String TYPE_TAG = "id";
|
||||
- public static final Codec<CustomData> CODEC = Codec.withAlternative(CompoundTag.CODEC, TagParser.AS_CODEC)
|
||||
+ // Paper start - Item serialization as json
|
||||
+ public static ThreadLocal<Boolean> SERIALIZE_CUSTOM_AS_SNBT = ThreadLocal.withInitial(() -> false);
|
@ -491,8 +491,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/net/minecraft/server/ReloadableServerRegistries.java
|
||||
+++ b/src/main/java/net/minecraft/server/ReloadableServerRegistries.java
|
||||
@@ -0,0 +0,0 @@ public class ReloadableServerRegistries {
|
||||
String string = Registries.elementsDirPath(type.registryKey());
|
||||
SimpleJsonResourceReloadListener.scanDirectory(resourceManager, string, ops, type.codec(), map);
|
||||
Map<ResourceLocation, T> map = new HashMap<>();
|
||||
SimpleJsonResourceReloadListener.scanDirectory(resourceManager, type.registryKey(), ops, type.codec(), map);
|
||||
map.forEach((id, value) -> io.papermc.paper.registry.PaperRegistryListenerManager.INSTANCE.registerWithListeners(writableRegistry, ResourceKey.create(type.registryKey(), id), value, DEFAULT_REGISTRATION_INFO, conversions)); // Paper - register with listeners
|
||||
- TagLoader.loadTagsForRegistry(resourceManager, writableRegistry);
|
||||
+ TagLoader.loadTagsForRegistry(resourceManager, writableRegistry, io.papermc.paper.plugin.lifecycle.event.registrar.ReloadableRegistrarEvent.Cause.RELOAD); // Paper - tag life cycle - reload
|
@ -59,6 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
BlockPos blockposition1 = pos.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
|
||||
|
||||
- if (world.getBlockState(blockposition1).is(Blocks.DIRT) && SpreadingSnowyDirtBlock.canPropagate(iblockdata1, world, blockposition1)) {
|
||||
- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, pos, blockposition1, (BlockState) iblockdata1.setValue(SpreadingSnowyDirtBlock.SNOWY, isSnowySetting(world.getBlockState(blockposition1.above())))); // CraftBukkit
|
||||
+ // Paper start - Perf: optimize dirt and snow spreading
|
||||
+ if (pos.getX() == blockposition1.getX() && pos.getY() == blockposition1.getY() && pos.getZ() == blockposition1.getZ()) {
|
||||
+ continue;
|
||||
@ -71,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ access = world.getChunkAt(blockposition1);
|
||||
+ }
|
||||
+ if (access.getBlockState(blockposition1).is(Blocks.DIRT) && SpreadingSnowyDirtBlock.canPropagate(access, iblockdata1, world, blockposition1)) {
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, pos, blockposition1, (BlockState) iblockdata1.setValue(SpreadingSnowyDirtBlock.SNOWY, isSnowySetting(world.getBlockState(blockposition1.above())))); // CraftBukkit
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, pos, blockposition1, (BlockState) iblockdata1.setValue(SpreadingSnowyDirtBlock.SNOWY, isSnowySetting(access.getBlockState(blockposition1.above())))); // CraftBukkit
|
||||
+ // Paper end - Perf: optimize dirt and snow spreading
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user