-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update GroovyScript & improve material API for groovy (#2389)
- Loading branch information
Showing
7 changed files
with
136 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/gregtech/integration/groovy/GroovyExpansions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package gregtech.integration.groovy; | ||
|
||
import gregtech.api.recipes.RecipeBuilder; | ||
import gregtech.api.unification.material.Material; | ||
import gregtech.api.unification.material.event.MaterialEvent; | ||
|
||
import net.minecraft.util.ResourceLocation; | ||
|
||
import com.cleanroommc.groovyscript.GroovyScript; | ||
import com.cleanroommc.groovyscript.api.GroovyLog; | ||
|
||
public class GroovyExpansions { | ||
|
||
public static <R extends RecipeBuilder<R>> RecipeBuilder<R> property(RecipeBuilder<R> builder, String key, | ||
Object value) { | ||
if (!builder.applyProperty(key, value)) { | ||
GroovyLog.get().error("Failed to add property '{}' with '{}' to recipe", key, value); | ||
} | ||
return builder; | ||
} | ||
|
||
public static Material.Builder materialBuilder(MaterialEvent event, int id, ResourceLocation resourceLocation) { | ||
return new Material.Builder(id, resourceLocation); | ||
} | ||
|
||
public static Material.Builder materialBuilder(MaterialEvent event, int id, String domain, String path) { | ||
return materialBuilder(event, id, domain, path); | ||
} | ||
|
||
public static Material.Builder materialBuilder(MaterialEvent event, int id, String s) { | ||
String domain, path; | ||
if (s.contains(":")) { | ||
String[] parts = s.split(":", 2); | ||
domain = parts[0]; | ||
path = parts[1]; | ||
} else { | ||
domain = GroovyScript.getRunConfig().getPackId(); | ||
path = s; | ||
} | ||
return materialBuilder(event, id, new ResourceLocation(domain, path)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/main/java/gregtech/integration/groovy/GroovyRecipeBuilderExpansion.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters