Skip to content

Commit 1591509

Browse files
committed
update LuaConverter
1 parent a62de02 commit 1591509

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,18 @@ private static void registerDefaultEntityConverters() {
147147
registerEntityConverter(Entity.class, (entity, data, ctx) -> {
148148
data.put("id", entity.getId());
149149
data.put("uuid", entity.getStringUUID());
150-
if (entity.hasCustomName()) {
151-
data.put("customName", entity.getCustomName().getString());
152-
}
153150
EntityType<?> type = entity.getType();
154151
data.put("displayName", type.getDescription().getString());
155152
data.put("name", type.builtInRegistryHolder().key().location().toString());
153+
if (entity.hasCustomName()) {
154+
data.put("customName", entity.getCustomName().getString());
155+
}
156156
if (ctx.detailed()) {
157157
data.put("type", type.getDescriptionId());
158+
data.put("tags", entity.getTags());
158159
data.put("category", type.getCategory().getName());
159160
data.put("canBurn", entity.fireImmune());
160161
data.put("canFreeze", entity.canFreeze());
161-
data.put("tags", entity.getTags());
162162
data.put("isGlowing", entity.isCurrentlyGlowing());
163163
data.put("isUnderWater", entity.isUnderWater());
164164
data.put("isInLava", entity.isInLava());
@@ -264,22 +264,25 @@ public static Map<String, Object> posToLua(BlockPos pos) {
264264

265265
public static Map<String, Object> itemToLua(@NotNull Item item) {
266266
Map<String, Object> properties = new HashMap<>();
267-
properties.put("tags", getHolderTags(item.builtInRegistryHolder()));
268267
properties.put("name", ItemUtil.getRegistryKey(item).toString());
268+
properties.put("tags", getHolderTags(item.builtInRegistryHolder()));
269269
return properties;
270270
}
271271

272272
public static Map<String, Object> fluidToLua(@NotNull Fluid fluid) {
273273
Map<String, Object> properties = new HashMap<>();
274-
properties.put("tags", getHolderTags(fluid.builtInRegistryHolder()));
275274
properties.put("name", FluidUtil.getRegistryKey(fluid).toString());
275+
properties.put("tags", getHolderTags(fluid.builtInRegistryHolder()));
276276
return properties;
277277
}
278278

279-
public static Map<String, Object> chemicalToLua(@NotNull Chemical chemical) {
279+
public static Map<String, Object> chemicalToLua(@NotNull Object /*Chemical*/ chemical0) {
280+
Chemical chemical = (Chemical) chemical0;
281+
Holder<Chemical> chemicalHolder = MekanismAPI.CHEMICAL_REGISTRY.wrapAsHolder(chemical);
280282
Map<String, Object> properties = new HashMap<>();
281-
properties.put("tags", getHolderTags(MekanismAPI.CHEMICAL_REGISTRY.wrapAsHolder(chemical)));
282283
properties.put("name", ChemicalUtil.getRegistryKey(chemical).toString());
284+
properties.put("tags", getHolderTags(chemicalHolder));
285+
properties.put("isGaseous", chemicalHolder.is(MekanismAPITags.Chemicals.GASEOUS));
283286
properties.put("radioactivity", chemical.isRadioactive());
284287
return properties;
285288
}
@@ -312,15 +315,15 @@ public static Map<String, Object> fluidStackToLua(@NotNull FluidStack stack) {
312315
return properties;
313316
}
314317

315-
public static Map<String, Object> chemicalStackToLua(@NotNull ChemicalStack stack) {
318+
public static Map<String, Object> chemicalStackToLua(@NotNull Object /*ChemicalStack*/ stack0) {
319+
ChemicalStack stack = (ChemicalStack) stack0;
316320
if (stack.isEmpty()) {
317321
return null;
318322
}
319323
Map<String, Object> properties = chemicalToLua(stack.getChemical());
320324
properties.put("count", stack.getAmount());
321325
properties.put("displayName", stack.getTextComponent().getString());
322326
properties.put("fingerprint", ChemicalUtil.getFingerprint(stack));
323-
properties.put("isGaseous", stack.is(MekanismAPITags.Chemicals.GASEOUS));
324327
return properties;
325328
}
326329

@@ -357,7 +360,8 @@ public static Map<String, Object> fluidStackToLua(@NotNull FluidStack fluidStack
357360
return properties;
358361
}
359362

360-
public static Map<String, Object> chemicalStackToLua(@NotNull ChemicalStack chemicalStack, long count) {
363+
public static Map<String, Object> chemicalStackToLua(@NotNull Object /*ChemicalStack*/ chemicalStack0, long count) {
364+
ChemicalStack chemicalStack = (ChemicalStack) chemicalStack0;
361365
if (chemicalStack.isEmpty()) {
362366
return null;
363367
}
@@ -450,7 +454,7 @@ public static Map<String, Object> teamToLua(Team team) {
450454
}
451455
return Map.of(
452456
"name", team.getName(),
453-
"color", team.getColor()
457+
"color", team.getColor().getColor()
454458
);
455459
}
456460

0 commit comments

Comments
 (0)