mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-04 15:41:38 +00:00
完善图腾命令
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.craftengine.core.entity;
|
||||
|
||||
import net.momirealms.craftengine.core.entity.data.EntityData;
|
||||
import net.momirealms.craftengine.core.util.Direction;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.world.World;
|
||||
@@ -30,9 +31,21 @@ public interface Entity {
|
||||
|
||||
Direction getDirection();
|
||||
|
||||
Object literalObject();
|
||||
Object platformEntity();
|
||||
|
||||
Object serverEntity();
|
||||
|
||||
String name();
|
||||
|
||||
UUID uuid();
|
||||
|
||||
Object entityData();
|
||||
|
||||
<T> T getEntityData(EntityData<T> entityData);
|
||||
|
||||
default <T> void setEntityData(EntityData<T> data, T value) {
|
||||
setEntityData(data, value, false);
|
||||
}
|
||||
|
||||
<T> void setEntityData(EntityData<T> data, T value, boolean force);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.momirealms.craftengine.core.entity.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface EntityData<T> {
|
||||
|
||||
Object serializer();
|
||||
|
||||
int id();
|
||||
|
||||
T defaultValue();
|
||||
|
||||
Object entityDataAccessor();
|
||||
|
||||
Object create(Object entityDataAccessor, Object value);
|
||||
|
||||
default Object createEntityDataIfNotDefaultValue(T value) {
|
||||
if (defaultValue().equals(value)) return null;
|
||||
return create(entityDataAccessor(), value);
|
||||
}
|
||||
|
||||
default Object createEntityData(Object value) {
|
||||
return create(entityDataAccessor(), value);
|
||||
}
|
||||
|
||||
default void addEntityDataIfNotDefaultValue(T value, List<Object> list) {
|
||||
if (!defaultValue().equals(value)) {
|
||||
list.add(create(entityDataAccessor(), value));
|
||||
}
|
||||
}
|
||||
|
||||
default void addEntityData(T value, List<Object> list) {
|
||||
list.add(create(entityDataAccessor(), value));
|
||||
}
|
||||
}
|
||||
@@ -30,4 +30,6 @@ public interface MessageConstants {
|
||||
TranslatableComponent.Builder COMMAND_UPLOAD_ON_PROGRESS = Component.translatable().key("command.upload.on_progress");
|
||||
TranslatableComponent.Builder COMMAND_SEND_RESOURCE_PACK_SUCCESS_SINGLE = Component.translatable().key("command.send_resource_pack.success.single");
|
||||
TranslatableComponent.Builder COMMAND_SEND_RESOURCE_PACK_SUCCESS_MULTIPLE = Component.translatable().key("command.send_resource_pack.success.multiple");
|
||||
TranslatableComponent.Builder COMMAND_TOTEM_SUCCESS_SINGLE = Component.translatable().key("commands.totem_animation.success.single");
|
||||
TranslatableComponent.Builder COMMAND_TOTEM_SUCCESS_MULTIPLE = Component.translatable().key("commands.totem_animation.success.multiple");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user