mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 12:29:15 +00:00
perf(entity): 减少一次冗余的调用
This commit is contained in:
@@ -11,17 +11,17 @@ public interface EntityData<T> {
|
||||
|
||||
default Object createEntityDataIfNotDefaultValue(T value) {
|
||||
if (defaultValue().equals(value)) return null;
|
||||
return EntityDataValue.create(id(), serializer(), value);
|
||||
return EntityDataValue.create(id(), serializer(), entityDataAccessor(), value);
|
||||
}
|
||||
|
||||
default void addEntityDataIfNotDefaultValue(T value, List<Object> list) {
|
||||
if (!defaultValue().equals(value)) {
|
||||
list.add(EntityDataValue.create(id(), serializer(), value));
|
||||
list.add(EntityDataValue.create(id(), serializer(), entityDataAccessor(), value));
|
||||
}
|
||||
}
|
||||
|
||||
default void addEntityData(T value, List<Object> list) {
|
||||
list.add(EntityDataValue.create(id(), serializer(), value));
|
||||
list.add(EntityDataValue.create(id(), serializer(), entityDataAccessor(), value));
|
||||
}
|
||||
|
||||
static <T> EntityData<T> of(int id, Object serializer, T defaultValue) {
|
||||
|
||||
@@ -98,8 +98,7 @@ public class EntityDataValue {
|
||||
throw new IllegalAccessError("Utility class");
|
||||
}
|
||||
|
||||
public static Object create(int id, Object serializer, Object value) {
|
||||
Object entityDataAccessor = FastNMS.INSTANCE.constructor$EntityDataAccessor(id, serializer);
|
||||
public static Object create(int id, Object serializer, Object entityDataAccessor, Object value) {
|
||||
return FastNMS.INSTANCE.method$SynchedEntityData$DataValue$create(entityDataAccessor, value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user