mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-05 23:21:38 +01:00
Implement assetid
This commit is contained in:
parent
0eefdfb97a
commit
ebc080b944
@ -1241,9 +1241,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ Key equipSound();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the model key if present.
|
||||
+ * Gets the asset id if present.
|
||||
+ *
|
||||
+ * @return the model key or null
|
||||
+ * @return the asset id or null
|
||||
+ */
|
||||
+ @Contract(pure = true)
|
||||
+ @Nullable Key assetId();
|
||||
|
@ -1250,18 +1250,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+package io.papermc.paper.datacomponent.item;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import io.papermc.paper.registry.PaperRegistries;
|
||||
+import io.papermc.paper.registry.RegistryKey;
|
||||
+import io.papermc.paper.registry.set.PaperRegistrySets;
|
||||
+import io.papermc.paper.registry.set.RegistryKeySet;
|
||||
+import java.util.Optional;
|
||||
+import java.util.function.Function;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import net.minecraft.core.Holder;
|
||||
+import net.minecraft.core.HolderSet;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.core.registries.Registries;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.sounds.SoundEvent;
|
||||
+import net.minecraft.sounds.SoundEvents;
|
||||
+import net.minecraft.util.datafix.fixes.EquippableAssetRenameFix;
|
||||
+import net.minecraft.world.item.equipment.EquipmentAsset;
|
||||
+import net.minecraft.world.item.equipment.EquipmentAssets;
|
||||
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||
+import org.bukkit.craftbukkit.util.Handleable;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
@ -1289,11 +1295,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ @Override
|
||||
+ public @Nullable Key assetId() {
|
||||
+ // TODO
|
||||
+ throw new UnsupportedOperationException("Not yet implemented");
|
||||
+ //return this.impl.assetId()
|
||||
+ // .map(PaperAdventure::asAdventure)
|
||||
+ // .orElse(null);
|
||||
+ return this.impl.assetId()
|
||||
+ .map(PaperAdventure::asAdventureKey)
|
||||
+ .orElse(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@ -1342,7 +1346,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ private final net.minecraft.world.entity.EquipmentSlot equipmentSlot;
|
||||
+ private Holder<SoundEvent> equipSound = SoundEvents.ARMOR_EQUIP_GENERIC;
|
||||
+ private Optional<ResourceLocation> assetId = Optional.empty();
|
||||
+ private Optional<ResourceKey<EquipmentAsset>> assetId = Optional.empty();
|
||||
+ private Optional<ResourceLocation> cameraOverlay = Optional.empty();
|
||||
+ private Optional<HolderSet<net.minecraft.world.entity.EntityType<?>>> allowedEntities = Optional.empty();
|
||||
+ private boolean dispensable = true;
|
||||
@ -1362,7 +1366,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ @Override
|
||||
+ public Builder assetId(final @Nullable Key model) {
|
||||
+ this.assetId = Optional.ofNullable(model)
|
||||
+ .map(PaperAdventure::asVanilla);
|
||||
+ .map(key -> PaperAdventure.asVanilla(EquipmentAssets.ROOT_ID, key));
|
||||
+
|
||||
+ return this;
|
||||
+ }
|
||||
|
Loading…
Reference in New Issue
Block a user