Skip to content

Commit 13b14be

Browse files
authored
KubeJS Duration Check (#4327)
1 parent 660a277 commit 13b14be

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/java/com/gregtechceu/gtceu/api/GTValues.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ public class GTValues {
3636
public static final int L = 144;
3737
public static final RandomSource RNG = RandomSource.createThreadSafe();
3838

39+
// shortcut for various lengths of time in ticks
40+
public static final long SECONDS = 20;
41+
public static final long MINUTES = 60 * SECONDS;
42+
public static final long HOURS = 60 * MINUTES;
43+
public static final long DAYS = 24 * HOURS;
44+
public static final long WEEKS = 7 * DAYS;
45+
public static final long MONTHS = 30 * DAYS;
46+
public static final long YEARS = 365 * DAYS;
47+
3948
/**
4049
* The Item WildCard Tag. Even shorter than the "-1" of the past
4150
*/

src/main/java/com/gregtechceu/gtceu/integration/kjs/GregTechKubeJSPlugin.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,12 @@ private static void handleGTRecipe(Map<ResourceLocation, Recipe<?>> recipesByNam
548548
// get the recipe ID without the leading type path
549549
GTRecipeBuilder builder = gtRecipeType.recipeBuilder(gtRecipe.idWithoutType());
550550
if (gtRecipe.getValue(GTRecipeSchema.DURATION) != null) {
551-
builder.duration = gtRecipe.getValue(GTRecipeSchema.DURATION).intValue();
551+
int duration = gtRecipe.getValue(GTRecipeSchema.DURATION).intValue();
552+
if (duration <= 0) {
553+
GTCEu.LOGGER.error("Duration must be a positive value, skipping recipe id: {}", gtRecipe.getId());
554+
return;
555+
}
556+
builder.duration = duration;
552557
}
553558
if (gtRecipe.getValue(GTRecipeSchema.DATA) != null) {
554559
builder.data = gtRecipe.getValue(GTRecipeSchema.DATA);

0 commit comments

Comments
 (0)