Skip to content

Commit eb96d0a

Browse files
committed
Clean up KubeJS wood type recipe integration
1 parent afa0c28 commit eb96d0a

2 files changed

Lines changed: 13 additions & 20 deletions

File tree

src/main/java/com/gregtechceu/gtceu/data/recipe/misc/WoodMachineRecipes.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,14 @@ private static List<WoodTypeEntry> getDefaultEntries() {
311311
.build());
312312
}
313313
if (CUSTOM_ENTRIES == null) {
314-
CUSTOM_ENTRIES = new ArrayList<WoodTypeEntry>();
315-
var evt = new RegisterWoodsKubeEvent();
316-
GTCEuStartupEvents.REGISTER_WOODS.post(evt);
317-
CUSTOM_ENTRIES = new ArrayList<WoodTypeEntry>(evt.woods);
314+
if (GTCEu.Mods.isKubeJSLoaded()) {
315+
CUSTOM_ENTRIES = new ArrayList<WoodTypeEntry>();
316+
var evt = new RegisterWoodsKubeEvent();
317+
GTCEuStartupEvents.REGISTER_WOODS.post(evt);
318+
CUSTOM_ENTRIES = new ArrayList<WoodTypeEntry>(evt.woods);
319+
} else {
320+
CUSTOM_ENTRIES = List.of();
321+
}
318322
}
319323

320324
List<WoodTypeEntry> entries = new ArrayList<WoodTypeEntry>();

src/main/java/com/gregtechceu/gtceu/integration/kjs/events/RegisterWoodsKubeEvent.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@ public class Wrapped {
3636
this.woodName = woodName;
3737
}
3838

39-
// public Wrapped id(KubeResourceLocation _id) {
40-
// String namespace = id.wrapped().getNamespace();
41-
// // if (namespace.equals("kubejs")) {
42-
// // namespace = this.type.id.getNamespace();
43-
// // }
44-
// var idWithoutType = ResourceLocation.fromNamespaceAndPath(namespace,
45-
// _id.wrapped().getPath());
46-
// var id = idWithoutType.withPrefix(this.type.id.getPath() + "/");
47-
// return this;
48-
// }
49-
5039
private String _recipeId;
5140
private Item _plank;
5241
private Item _strippedLog;
@@ -236,7 +225,7 @@ public WoodTypeEntry toEntry() throws IllegalArgumentException {
236225
throw new IllegalArgumentException("Need a pressurePlate");
237226
}
238227

239-
var builder = new WoodTypeEntry.Builder(this.modId, this.woodName)
228+
return new WoodTypeEntry.Builder(this.modId, this.woodName)
240229
.planks(this._plank, this._recipeId + "_planks")
241230
.log(Items.OAK_LOG).removeCharcoalRecipe()
242231
.strippedLog(this._strippedLog)
@@ -256,14 +245,14 @@ public WoodTypeEntry toEntry() throws IllegalArgumentException {
256245
.pressurePlate(this._pressurePlate, this._recipeId + "_pressure_plate")
257246
.registerAllMaterialInfo()
258247
.build();
259-
return builder;
260248
}
261249

262-
boolean wasRegisted = false;
250+
boolean wasRegistered = false;
263251

264252
@HideFromJS
265253
public void register() {
266-
if (!this.wasRegisted) {
254+
if (!this.wasRegistered) {
255+
this.wasRegistered = true;
267256
try {
268257
woods.add(this.toEntry());
269258
} catch (Exception e) {
@@ -273,7 +262,7 @@ public void register() {
273262
} else
274263
GTCEu.LOGGER.warn("Tried registering a wood type twice!");
275264
}
276-
};
265+
}
277266

278267
public Wrapped register(String modId, String woodName) {
279268
var wrap = new Wrapped(modId, woodName);

0 commit comments

Comments
 (0)