9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-06 15:52:03 +00:00

添加text display家具元素

This commit is contained in:
XiaoMoMi
2025-12-06 21:25:09 +08:00
parent 1566ac89c9
commit dfeff51f65
13 changed files with 437 additions and 36 deletions

View File

@@ -22,7 +22,14 @@ public abstract class BlockEntityElementConfigs {
}
public static <E extends BlockEntityElement> BlockEntityElementConfig<E> fromMap(Map<String, Object> arguments) {
Key type = Optional.ofNullable(arguments.get("type")).map(String::valueOf).map(it -> Key.withDefaultNamespace(it, "craftengine")).orElse(ITEM_DISPLAY);
Key type = Optional.ofNullable(arguments.get("type")).map(String::valueOf).map(it -> Key.withDefaultNamespace(it, "craftengine")).orElse(null);
if (type == null) {
if (arguments.containsKey("text")) {
type = TEXT_DISPLAY;
} else {
type = ITEM_DISPLAY;
}
}
@SuppressWarnings("unchecked")
BlockEntityElementConfigFactory<E> factory = (BlockEntityElementConfigFactory<E>) BuiltInRegistries.BLOCK_ENTITY_ELEMENT_TYPE.getValue(type);
if (factory == null) {

View File

@@ -0,0 +1,8 @@
package net.momirealms.craftengine.core.entity.display;
public enum TextDisplayAlignment {
CENTER,
LEFT,
RIGHT
}

View File

@@ -14,6 +14,7 @@ public class FurnitureElementConfigs {
public static final Key ITEM_DISPLAY = Key.of("craftengine:item_display");
public static final Key TEXT_DISPLAY = Key.of("craftengine:text_display");
public static final Key ITEM = Key.of("craftengine:item");
public static final Key ARMOR_STAND = Key.of("craftengine:armor_stand");
public static void register(Key key, FurnitureElementConfigFactory<?> type) {
((WritableRegistry<FurnitureElementConfigFactory<?>>) BuiltInRegistries.FURNITURE_ELEMENT_TYPE)
@@ -21,7 +22,14 @@ public class FurnitureElementConfigs {
}
public static <E extends FurnitureElement> FurnitureElementConfig<E> fromMap(Map<String, Object> arguments) {
Key type = Optional.ofNullable(arguments.get("type")).map(String::valueOf).map(it -> Key.withDefaultNamespace(it, "craftengine")).orElse(ITEM_DISPLAY);
Key type = Optional.ofNullable(arguments.get("type")).map(String::valueOf).map(it -> Key.withDefaultNamespace(it, "craftengine")).orElse(null);
if (type == null) {
if (arguments.containsKey("text")) {
type = TEXT_DISPLAY;
} else {
type = ITEM_DISPLAY;
}
}
@SuppressWarnings("unchecked")
FurnitureElementConfigFactory<E> factory = (FurnitureElementConfigFactory<E>) BuiltInRegistries.FURNITURE_ELEMENT_TYPE.getValue(type);
if (factory == null) {