Skip to content

Commit 240a4dd

Browse files
committed
[IntelligenceModding/Advanced-Peripherals-Features#90] Add customName, displayName and name to entity properties
1 parent d43419a commit 240a4dd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/de/srendi/advancedperipherals/common/util/LuaConverter.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@
4343

4444
public class LuaConverter {
4545

46-
public static Map<String, Object> entityToLua(Entity entity, boolean detailed) {
46+
public static Map<String, Object> entityToLua(Entity entity) {
4747
Map<String, Object> data = new HashMap<>();
4848
data.put("id", entity.getId());
4949
data.put("uuid", entity.getStringUUID());
50+
if (entity.hasCustomName())
51+
data.put("customName", entity.getCustomName().getString());
5052
EntityType<?> type = entity.getType();
53+
data.put("displayName", type.getDescription().getString());
54+
data.put("name", type.builtInRegistryHolder().key().location().toString());
5155
data.put("type", type.getDescriptionId());
5256
data.put("category", type.getCategory());
5357
data.put("canBurn", entity.fireImmune());
@@ -60,7 +64,7 @@ public static Map<String, Object> entityToLua(Entity entity, boolean detailed) {
6064
}
6165

6266
public static Map<String, Object> livingEntityToLua(LivingEntity entity, boolean detailed) {
63-
Map<String, Object> data = entityToLua(entity, detailed);
67+
Map<String, Object> data = entityToLua(entity);
6468
data.put("baby", entity.isBaby());
6569
data.put("health", entity.getHealth());
6670
data.put("maxHealth", entity.getMaxHealth());
@@ -121,7 +125,7 @@ public static Map<String, Object> completeEntityToLua(Entity entity, ItemStack i
121125
if (entity instanceof Player player) return playerToLua(player, detailed);
122126
if (entity instanceof Animal animal) return animalToLua(animal, itemInHand, detailed);
123127
if (entity instanceof LivingEntity livingEntity) return livingEntityToLua(livingEntity, detailed);
124-
return entityToLua(entity, detailed);
128+
return entityToLua(entity);
125129
}
126130

127131
public static Map<String, Object> completeEntityWithPositionToLua(Entity entity, BlockPos pos) {

0 commit comments

Comments
 (0)