9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-28 03:19:14 +00:00

修复1.21.2equippable组件

This commit is contained in:
XiaoMoMi
2025-06-29 01:33:55 +08:00
parent 729cba32b0
commit 72e4d7224b
3 changed files with 17 additions and 12 deletions

View File

@@ -112,7 +112,6 @@ public interface Item<I> {
Item<I> equippable(EquipmentData equipmentData);
Item<I> unbreakable(boolean unbreakable);
boolean unbreakable();

View File

@@ -5,10 +5,12 @@ import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigExce
import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
import net.momirealms.craftengine.core.util.VersionHelper;
import net.momirealms.sparrow.nbt.CompoundTag;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
@@ -97,22 +99,26 @@ public class EquipmentData {
return cameraOverlay;
}
public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<>();
map.put("slot", this.slot.toString().toLowerCase(Locale.ENGLISH));
public CompoundTag toNBT() {
CompoundTag tag = new CompoundTag();
tag.putString("slot", this.slot.toString().toLowerCase(Locale.ENGLISH));
if (this.assetId != null) {
map.put("asset_id", this.assetId.toString());
if (VersionHelper.isOrAbove1_21_4()) {
tag.putString("asset_id", this.assetId.toString());
} else {
tag.putString("model", this.assetId.toString());
}
}
map.put("dispensable", this.dispensable);
map.put("swappable", this.swappable);
map.put("damage_on_hurt", this.damageOnHurt);
tag.putBoolean("dispensable", this.dispensable);
tag.putBoolean("swappable", this.swappable);
tag.putBoolean("damage_on_hurt", this.damageOnHurt);
if (VersionHelper.isOrAbove1_21_5()) {
map.put("equip_on_interact", this.equipOnInteract);
tag.putBoolean("equip_on_interact", this.equipOnInteract);
}
if (this.cameraOverlay != null) {
map.put("camera_overlay", this.cameraOverlay.toString());
tag.putString("camera_overlay", this.cameraOverlay.toString());
}
return map;
return tag;
}
public static Builder builder() {