diff --git a/gradle.properties b/gradle.properties index 78517c5db..ff36f0b91 100644 --- a/gradle.properties +++ b/gradle.properties @@ -249,7 +249,7 @@ mavenArtifactGroup = com.cleanroommc # By default this will use the files found here: https://github.com/GregTechCEu/Buildscripts/tree/master/spotless # to format your code. However, you can create your own version of these files and place them in your project's # root directory to apply your own formatting options instead. -enableSpotless = false +enableSpotless = true # Enable JUnit testing platform used for testing your code. # Uses JUnit 5. See guide and documentation here: https://junit.org/junit5/docs/current/user-guide/ diff --git a/spotless.eclipseformat.xml b/spotless.eclipseformat.xml new file mode 100644 index 000000000..b851fb145 --- /dev/null +++ b/spotless.eclipseformat.xml @@ -0,0 +1,404 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/cleanroommc/groovyscript/DisabledConfigGui.java b/src/main/java/com/cleanroommc/groovyscript/DisabledConfigGui.java index b76e691a5..30450364b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/DisabledConfigGui.java +++ b/src/main/java/com/cleanroommc/groovyscript/DisabledConfigGui.java @@ -1,16 +1,15 @@ package com.cleanroommc.groovyscript; +import java.util.Set; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.client.IModGuiFactory; -import java.util.Set; - public class DisabledConfigGui implements IModGuiFactory { @Override - public void initialize(Minecraft minecraftInstance) { - } + public void initialize(Minecraft minecraftInstance) {} @Override public boolean hasConfigGui() { diff --git a/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java b/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java index cd5a74823..268df70b9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java +++ b/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java @@ -1,31 +1,14 @@ package com.cleanroommc.groovyscript; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.command.CustomClickAction; -import com.cleanroommc.groovyscript.command.GSCommand; -import com.cleanroommc.groovyscript.compat.content.GroovyResourcePack; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.TinkersConstruct; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; -import com.cleanroommc.groovyscript.core.mixin.DefaultResourcePackAccessor; -import com.cleanroommc.groovyscript.documentation.Documentation; -import com.cleanroommc.groovyscript.documentation.linkgenerator.LinkGeneratorHooks; -import com.cleanroommc.groovyscript.event.EventHandler; -import com.cleanroommc.groovyscript.helper.JsonHelper; -import com.cleanroommc.groovyscript.mapper.ObjectMapper; -import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; -import com.cleanroommc.groovyscript.network.CReload; -import com.cleanroommc.groovyscript.network.NetworkHandler; -import com.cleanroommc.groovyscript.network.NetworkUtils; -import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; -import com.cleanroommc.groovyscript.sandbox.*; -import com.cleanroommc.groovyscript.sandbox.mapper.GroovyDeobfMapper; -import com.cleanroommc.groovyscript.sandbox.security.GrSMetaClassCreationHandle; -import com.cleanroommc.groovyscript.server.GroovyScriptLanguageServer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import groovy.lang.GroovySystem; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; +import java.util.List; +import java.util.Random; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.settings.KeyBinding; @@ -52,20 +35,40 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.relauncher.FMLLaunchHandler; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.lwjgl.input.Keyboard; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.StandardOpenOption; -import java.util.List; -import java.util.Random; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.command.CustomClickAction; +import com.cleanroommc.groovyscript.command.GSCommand; +import com.cleanroommc.groovyscript.compat.content.GroovyResourcePack; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.TinkersConstruct; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; +import com.cleanroommc.groovyscript.core.mixin.DefaultResourcePackAccessor; +import com.cleanroommc.groovyscript.documentation.Documentation; +import com.cleanroommc.groovyscript.documentation.linkgenerator.LinkGeneratorHooks; +import com.cleanroommc.groovyscript.event.EventHandler; +import com.cleanroommc.groovyscript.helper.JsonHelper; +import com.cleanroommc.groovyscript.mapper.ObjectMapper; +import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; +import com.cleanroommc.groovyscript.network.CReload; +import com.cleanroommc.groovyscript.network.NetworkHandler; +import com.cleanroommc.groovyscript.network.NetworkUtils; +import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; +import com.cleanroommc.groovyscript.sandbox.*; +import com.cleanroommc.groovyscript.sandbox.mapper.GroovyDeobfMapper; +import com.cleanroommc.groovyscript.sandbox.security.GrSMetaClassCreationHandle; +import com.cleanroommc.groovyscript.server.GroovyScriptLanguageServer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import groovy.lang.GroovySystem; @GroovyBlacklist @Mod(modid = GroovyScript.ID, @@ -99,6 +102,8 @@ public class GroovyScript { public static final Random RND = new Random(); + public GroovyScript() {} + @Mod.EventHandler public void onConstruction(FMLConstructionEvent event) { MinecraftForge.EVENT_BUS.register(this); @@ -118,7 +123,8 @@ public void onConstruction(FMLConstructionEvent event) { if (NetworkUtils.isDedicatedClient()) { // this resource pack must be added in construction ((DefaultResourcePackAccessor) Minecraft.getMinecraft()).get().add(new GroovyResourcePack()); - reloadKey = new KeyBinding("key.groovyscript.reload", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, Keyboard.KEY_R, "key.categories.groovyscript"); + reloadKey = new KeyBinding("key.groovyscript.reload", KeyConflictContext.IN_GAME, KeyModifier.CONTROL, Keyboard.KEY_R, + "key.categories.groovyscript"); ClientRegistry.registerKeyBinding(reloadKey); } @@ -194,9 +200,8 @@ public static long runGroovyScriptsInLoader(LoadStage loadStage) { public void onPostInit(FMLPostInitializationEvent event) { CustomClickAction.registerAction("copy", value -> { GuiScreen.setClipboardString(value); - Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("groovyscript.command.copy.copied_start") - .appendSibling(new TextComponentString(value).setStyle(new Style().setColor(TextFormatting.GOLD))) - .appendSibling(new TextComponentTranslation("groovyscript.command.copy.copied_end"))); + Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("groovyscript.command.copy.copied_start").appendSibling(new TextComponentString(value).setStyle(new Style().setColor(TextFormatting.GOLD))) + .appendSibling(new TextComponentTranslation("groovyscript.command.copy.copied_end"))); }); } @@ -208,64 +213,49 @@ public void onServerLoad(FMLServerStartingEvent event) { @SubscribeEvent public static void onInput(InputEvent.KeyInputEvent event) { long time = Minecraft.getSystemTime(); - if (Minecraft.getMinecraft().isIntegratedServerRunning() && reloadKey.isPressed() && time - timeSinceLastUse >= 1000 && Minecraft.getMinecraft().player.getPermissionLevel() >= 4) { + if (Minecraft.getMinecraft().isIntegratedServerRunning() && reloadKey + .isPressed() && time - timeSinceLastUse >= 1000 && Minecraft.getMinecraft().player.getPermissionLevel() >= 4) { NetworkHandler.sendToServer(new CReload()); timeSinceLastUse = time; } } @NotNull - public static String getScriptPath() { - return getScriptFile().getPath(); - } + public static String getScriptPath() { return getScriptFile().getPath(); } @NotNull public static File getMinecraftHome() { - if (minecraftHome == null) { - throw new IllegalStateException("GroovyScript is not yet loaded!"); - } + if (minecraftHome == null) { throw new IllegalStateException("GroovyScript is not yet loaded!"); } return minecraftHome; } @NotNull public static File getScriptFile() { - if (scriptPath == null) { - throw new IllegalStateException("GroovyScript is not yet loaded!"); - } + if (scriptPath == null) { throw new IllegalStateException("GroovyScript is not yet loaded!"); } return scriptPath; } @NotNull public static File getResourcesFile() { - if (resourcesFile == null) { - throw new IllegalStateException("GroovyScript is not yet loaded!"); - } + if (resourcesFile == null) { throw new IllegalStateException("GroovyScript is not yet loaded!"); } return resourcesFile; } @NotNull public static File getRunConfigFile() { - if (runConfigFile == null) { - throw new IllegalStateException("GroovyScript is not yet loaded!"); - } + if (runConfigFile == null) { throw new IllegalStateException("GroovyScript is not yet loaded!"); } return runConfigFile; } @NotNull public static GroovyScriptSandbox getSandbox() { - if (sandbox == null) { - throw new IllegalStateException("GroovyScript is not yet loaded!"); - } + if (sandbox == null) { throw new IllegalStateException("GroovyScript is not yet loaded!"); } return sandbox; } - public static boolean isSandboxLoaded() { - return sandbox != null; - } + public static boolean isSandboxLoaded() { return sandbox != null; } - public static RunConfig getRunConfig() { - return runConfig; - } + public static RunConfig getRunConfig() { return runConfig; } @ApiStatus.Internal public static void reloadRunConfig(boolean init) { @@ -289,7 +279,8 @@ private static RunConfig createRunConfig(JsonObject json) { if (!Files.exists(main.toPath())) { try { main.getParentFile().mkdirs(); - Files.write(main.toPath(), "\nprintln('Hello World!')\n".getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE, StandardOpenOption.WRITE); + Files.write(main.toPath(), "\nprintln('Hello World!')\n".getBytes(StandardCharsets.UTF_8), + StandardOpenOption.CREATE, StandardOpenOption.WRITE); } catch (IOException e) { throw new RuntimeException(e); } @@ -297,20 +288,23 @@ private static RunConfig createRunConfig(JsonObject json) { return new RunConfig(json); } - public static void postScriptRunResult(ICommandSender sender, boolean onlyLogFails, boolean running, boolean packmode, long time) { + public static void postScriptRunResult(ICommandSender sender, boolean onlyLogFails, boolean running, boolean packmode, + long time) { List errors = GroovyLogImpl.LOG.collectErrors(); if (errors.isEmpty()) { if (!onlyLogFails) { if (running) { String s = packmode ? "changes packmode" : "reloaded scripts"; - sender.sendMessage(new TextComponentString(TextFormatting.GREEN + "Successfully " + s + TextFormatting.WHITE + " in " + time + "ms")); + sender.sendMessage(new TextComponentString(TextFormatting.GREEN + "Successfully " + s + TextFormatting.WHITE + + " in " + time + "ms")); } else { sender.sendMessage(new TextComponentString(TextFormatting.GREEN + "No syntax errors found :)")); } } } else { String executing = running ? "running" : "checking"; - sender.sendMessage(new TextComponentString(TextFormatting.RED + "Found " + errors.size() + " errors while " + executing + " scripts")); + sender.sendMessage(new TextComponentString(TextFormatting.RED + "Found " + errors.size() + " errors while " + + executing + " scripts")); int n = errors.size(); if (errors.size() >= 10) { sender.sendMessage(new TextComponentString("Displaying the first 7 errors:")); diff --git a/src/main/java/com/cleanroommc/groovyscript/GroovyScriptConfig.java b/src/main/java/com/cleanroommc/groovyscript/GroovyScriptConfig.java index 7159ab83f..888cb33f7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/GroovyScriptConfig.java +++ b/src/main/java/com/cleanroommc/groovyscript/GroovyScriptConfig.java @@ -1,13 +1,13 @@ package com.cleanroommc.groovyscript; import net.minecraftforge.common.config.Config; + import org.jetbrains.annotations.ApiStatus; @Config(modid = GroovyScript.ID) public class GroovyScriptConfig { - @ApiStatus.Internal - @Config.Comment("The current set packmode") + @ApiStatus.Internal @Config.Comment("The current set packmode") public static String packmode = ""; @Config.Comment("Port for the VSC connection. Default: 25564") diff --git a/src/main/java/com/cleanroommc/groovyscript/api/GroovyBlacklist.java b/src/main/java/com/cleanroommc/groovyscript/api/GroovyBlacklist.java index 5199fcaff..58e2887a5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/GroovyBlacklist.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/GroovyBlacklist.java @@ -8,7 +8,5 @@ /** * Use this annotation on fields, methods or classes to make them inaccessible for groovy. */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR}) -public @interface GroovyBlacklist { -} +@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR}) +public @interface GroovyBlacklist {} diff --git a/src/main/java/com/cleanroommc/groovyscript/api/GroovyLog.java b/src/main/java/com/cleanroommc/groovyscript/api/GroovyLog.java index 9c932c2c9..41e60a6e5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/GroovyLog.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/GroovyLog.java @@ -1,17 +1,18 @@ package com.cleanroommc.groovyscript.api; -import com.cleanroommc.groovyscript.sandbox.GroovyLogImpl; +import java.io.PrintWriter; +import java.nio.file.Path; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Supplier; + import org.apache.logging.log4j.Level; import org.apache.logging.log4j.message.ParameterizedMessage; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.io.PrintWriter; -import java.nio.file.Path; -import java.util.List; -import java.util.function.Consumer; -import java.util.function.Supplier; +import com.cleanroommc.groovyscript.sandbox.GroovyLogImpl; /** * A interface for the GroovyScript logger. The log is separate to Minecraft's normal and debug log. diff --git a/src/main/java/com/cleanroommc/groovyscript/api/GroovyPlugin.java b/src/main/java/com/cleanroommc/groovyscript/api/GroovyPlugin.java index 45fa4822c..77538dfff 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/GroovyPlugin.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/GroovyPlugin.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.api; -import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; -import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; +import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer; + /** - * Implement this on a class to add external mod compat with GroovyScript. GroovyScript will automatically find and instantiate the class. + * Implement this on a class to add external mod compat with GroovyScript. GroovyScript will automatically find and instantiate + * the class. * A mod should have at most one class with this interface. */ public interface GroovyPlugin extends IGroovyContainer { @@ -17,8 +18,7 @@ public interface GroovyPlugin extends IGroovyContainer { * * @return a new mod property container */ - @GroovyBlacklist - @ApiStatus.OverrideOnly + @GroovyBlacklist @ApiStatus.OverrideOnly default @Nullable GroovyPropertyContainer createGroovyPropertyContainer() { return createModPropertyContainer(); } @@ -26,10 +26,7 @@ public interface GroovyPlugin extends IGroovyContainer { /** * @deprecated use {@link #createGroovyPropertyContainer()} instead */ - @GroovyBlacklist - @ApiStatus.OverrideOnly - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") + @GroovyBlacklist @ApiStatus.OverrideOnly @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") default @Nullable ModPropertyContainer createModPropertyContainer() { return null; } @@ -37,9 +34,6 @@ public interface GroovyPlugin extends IGroovyContainer { /** * This method exist because of the extended interface. It has no use in this interface. */ - @Override - @ApiStatus.NonExtendable - default boolean isLoaded() { - return true; - } + @Override @ApiStatus.NonExtendable + default boolean isLoaded() { return true; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/api/IDynamicGroovyProperty.java b/src/main/java/com/cleanroommc/groovyscript/api/IDynamicGroovyProperty.java index 5a606a468..784ce943c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/IDynamicGroovyProperty.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/IDynamicGroovyProperty.java @@ -1,15 +1,15 @@ package com.cleanroommc.groovyscript.api; +import java.util.Map; + import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import java.util.Map; - /** - * When this is implemented on a class, {@link #getProperty(String)} will be called when groovy tries to get a field from this class + * When this is implemented on a class, {@link #getProperty(String)} will be called when groovy tries to get a field from this + * class */ -@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") -@Deprecated +@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") @Deprecated public interface IDynamicGroovyProperty { /** diff --git a/src/main/java/com/cleanroommc/groovyscript/api/IGameObjectParser.java b/src/main/java/com/cleanroommc/groovyscript/api/IGameObjectParser.java index a7b930c84..c3a437efd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/IGameObjectParser.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/IGameObjectParser.java @@ -1,23 +1,24 @@ package com.cleanroommc.groovyscript.api; -import com.cleanroommc.groovyscript.mapper.ObjectMappers; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import java.util.Locale; +import java.util.Map; +import java.util.function.Function; + import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; + import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import java.util.Locale; -import java.util.Map; -import java.util.function.Function; +import com.cleanroommc.groovyscript.mapper.ObjectMappers; + +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; /** * @deprecated use {@link IObjectParser} */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") -@FunctionalInterface +@Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") @FunctionalInterface public interface IGameObjectParser extends IObjectParser { static > IGameObjectParser wrapForgeRegistry(IForgeRegistry forgeRegistry) { @@ -46,9 +47,7 @@ static IGameObjectParser wrapStringGetter(Function getter) { static IGameObjectParser wrapStringGetter(Function getter, boolean isUpperCase) { return (s, args) -> { - if (args.length > 0) { - return Result.error("extra arguments are not allowed"); - } + if (args.length > 0) { return Result.error("extra arguments are not allowed"); } T t = getter.apply(isUpperCase ? s.toUpperCase(Locale.ROOT) : s); return t == null ? Result.error() : Result.some(t); }; @@ -58,11 +57,10 @@ static IGameObjectParser wrapStringGetter(Function getter, return wrapStringGetter(getter, trueTypeFunction, false); } - static IGameObjectParser wrapStringGetter(Function getter, Function trueTypeFunction, boolean isUpperCase) { + static IGameObjectParser wrapStringGetter(Function getter, Function trueTypeFunction, + boolean isUpperCase) { return (s, args) -> { - if (args.length > 0) { - return Result.error("extra arguments are not allowed"); - } + if (args.length > 0) { return Result.error("extra arguments are not allowed"); } V v = getter.apply(isUpperCase ? s.toUpperCase(Locale.ROOT) : s); return v == null ? Result.error() : Result.some(trueTypeFunction.apply(v)); }; diff --git a/src/main/java/com/cleanroommc/groovyscript/api/IGroovyContainer.java b/src/main/java/com/cleanroommc/groovyscript/api/IGroovyContainer.java index 0d024ffbc..04ea10284 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/IGroovyContainer.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/IGroovyContainer.java @@ -1,23 +1,26 @@ package com.cleanroommc.groovyscript.api; -import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; -import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; +import java.util.Collection; +import java.util.Collections; + import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.Collections; +import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; +import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; /** * A GroovyScript compat container. Each mod compat has one of these. * For internal mod compat see {@link com.cleanroommc.groovyscript.compat.mods.ModSupport ModSupport} and - * {@link com.cleanroommc.groovyscript.compat.mods.InternalModContainer InternalModContainer}. For external compat refer to {@link GroovyPlugin}. + * {@link com.cleanroommc.groovyscript.compat.mods.InternalModContainer InternalModContainer}. For external compat refer to + * {@link GroovyPlugin}. */ public interface IGroovyContainer { /** * Returns the mod id of the compat mod. This will be used to check if the mod is loaded. - * Scripts will be able to refer to the mods {@link com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer GroovyPropertyContainer} + * Scripts will be able to refer to the mods {@link com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer + * GroovyPropertyContainer} * with this id. * * @return the compat mod id @@ -46,13 +49,13 @@ public interface IGroovyContainer { * @return aliases */ @NotNull - default Collection getAliases() { - return Collections.singletonList(getModId()); - } + default Collection getAliases() { return Collections.singletonList(getModId()); } /** - * Called before scripts are executed for the first time. Called right before {@link GroovyPropertyContainer#initialize(GroovyContainer)}. - * Used to initialize things like expansions with {@link com.cleanroommc.groovyscript.sandbox.expand.ExpansionHelper ExpansionHelper} and + * Called before scripts are executed for the first time. Called right before + * {@link GroovyPropertyContainer#initialize(GroovyContainer)}. + * Used to initialize things like expansions with {@link com.cleanroommc.groovyscript.sandbox.expand.ExpansionHelper + * ExpansionHelper} and * object mappers with {@link com.cleanroommc.groovyscript.mapper.ObjectMapperManager ObjectMapperManager}. * * @param container the created container for the compat mod @@ -68,9 +71,7 @@ default Collection getAliases() { * @see Priority */ @NotNull - default Priority getOverridePriority() { - return Priority.NONE; - } + default Priority getOverridePriority() { return Priority.NONE; } enum Priority { /** diff --git a/src/main/java/com/cleanroommc/groovyscript/api/IIngredient.java b/src/main/java/com/cleanroommc/groovyscript/api/IIngredient.java index f222630a0..a2fda84dc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/IIngredient.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/IIngredient.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.api; -import com.cleanroommc.groovyscript.helper.ingredient.OrIngredient; +import java.util.function.Predicate; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.fluids.FluidStack; + import org.jetbrains.annotations.Nullable; -import java.util.function.Predicate; +import com.cleanroommc.groovyscript.helper.ingredient.OrIngredient; /** * Base ingredient class for every ingredient. Most useful for item stacks and ore dicts. @@ -21,9 +23,7 @@ public interface IIngredient extends IResourceStack, Predicate { ItemStack[] getMatchingStacks(); - default boolean isEmpty() { - return getAmount() <= 0 || getMatchingStacks().length == 0; - } + default boolean isEmpty() { return getAmount() <= 0 || getMatchingStacks().length == 0; } default ItemStack applyTransform(ItemStack matchedInput) { return ForgeHooks.getContainerItem(matchedInput); @@ -61,20 +61,17 @@ default IIngredient withAmount(int amount) { /** * An empty ingredient with stack size 0, that matches empty item stacks */ - IIngredient EMPTY = new IIngredient() { + IIngredient EMPTY = new IIngredient() + { + @Override - public int getAmount() { - return 0; - } + public int getAmount() { return 0; } @Override - public void setAmount(int amount) { - } + public void setAmount(int amount) {} @Override - public boolean isEmpty() { - return true; - } + public boolean isEmpty() { return true; } @Override public IIngredient exactCopy() { @@ -87,9 +84,7 @@ public Ingredient toMcIngredient() { } @Override - public ItemStack[] getMatchingStacks() { - return new ItemStack[]{ItemStack.EMPTY}; - } + public ItemStack[] getMatchingStacks() { return new ItemStack[]{ItemStack.EMPTY}; } @Override public boolean test(ItemStack stack) { @@ -100,7 +95,8 @@ public boolean test(ItemStack stack) { /** * An ingredient with stack size 1, that matches any item stack */ - IIngredient ANY = new IIngredient() { + IIngredient ANY = new IIngredient() + { @Override public IIngredient exactCopy() { @@ -109,7 +105,9 @@ public IIngredient exactCopy() { @Override public Ingredient toMcIngredient() { - return new Ingredient() { + return new Ingredient() + { + @Override public boolean apply(@Nullable ItemStack p_apply_1_) { return true; @@ -118,23 +116,16 @@ public boolean apply(@Nullable ItemStack p_apply_1_) { } @Override - public ItemStack[] getMatchingStacks() { - return new ItemStack[0]; - } + public ItemStack[] getMatchingStacks() { return new ItemStack[0]; } @Override - public boolean isEmpty() { - return false; - } + public boolean isEmpty() { return false; } @Override - public int getAmount() { - return 1; - } + public int getAmount() { return 1; } @Override - public void setAmount(int amount) { - } + public void setAmount(int amount) {} @Override public boolean test(ItemStack stack) { diff --git a/src/main/java/com/cleanroommc/groovyscript/api/INBTResourceStack.java b/src/main/java/com/cleanroommc/groovyscript/api/INBTResourceStack.java index 49d85bc97..28818647e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/INBTResourceStack.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/INBTResourceStack.java @@ -1,12 +1,14 @@ package com.cleanroommc.groovyscript.api; -import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; +import java.util.Map; + import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Map; +import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; /** * An object that holds an amount and a NBT tag diff --git a/src/main/java/com/cleanroommc/groovyscript/api/INamed.java b/src/main/java/com/cleanroommc/groovyscript/api/INamed.java index 56007cbc7..de3e0a8a3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/INamed.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/INamed.java @@ -8,15 +8,11 @@ public interface INamed { default String getName() { Collection aliases = getAliases(); - if (aliases.isEmpty()) { - return "EmptyName"; - } + if (aliases.isEmpty()) { return "EmptyName"; } return aliases.iterator().next(); } @GroovyBlacklist - default boolean isEnabled() { - return true; - } + default boolean isEnabled() { return true; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/api/INbtIngredient.java b/src/main/java/com/cleanroommc/groovyscript/api/INbtIngredient.java index 14b54a04f..79b18bc8a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/INbtIngredient.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/INbtIngredient.java @@ -1,9 +1,10 @@ package com.cleanroommc.groovyscript.api; -import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; +import java.util.Map; + import net.minecraft.nbt.NBTTagCompound; -import java.util.Map; +import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; public interface INbtIngredient extends INBTResourceStack { diff --git a/src/main/java/com/cleanroommc/groovyscript/api/IObjectParser.java b/src/main/java/com/cleanroommc/groovyscript/api/IObjectParser.java index 6f1878a86..2db7e36ac 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/IObjectParser.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/IObjectParser.java @@ -1,15 +1,18 @@ package com.cleanroommc.groovyscript.api; -import com.cleanroommc.groovyscript.mapper.ObjectMappers; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import java.util.Locale; +import java.util.Map; +import java.util.function.Function; + import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; + import org.jetbrains.annotations.NotNull; -import java.util.Locale; -import java.util.Map; -import java.util.function.Function; +import com.cleanroommc.groovyscript.mapper.ObjectMappers; + +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; /** * A function to parse an object from a string and any amount of additional arguments of any type. @@ -56,9 +59,7 @@ static IObjectParser wrapStringGetter(Function getter) { static IObjectParser wrapStringGetter(Function getter, boolean isUpperCase) { return (s, args) -> { - if (args.length > 0) { - return Result.error("extra arguments are not allowed"); - } + if (args.length > 0) { return Result.error("extra arguments are not allowed"); } T t = getter.apply(isUpperCase ? s.toUpperCase(Locale.ROOT) : s); return t == null ? Result.error() : Result.some(t); }; @@ -68,11 +69,10 @@ static IObjectParser wrapStringGetter(Function getter, Func return wrapStringGetter(getter, trueTypeFunction, false); } - static IObjectParser wrapStringGetter(Function getter, Function trueTypeFunction, boolean isUpperCase) { + static IObjectParser wrapStringGetter(Function getter, Function trueTypeFunction, + boolean isUpperCase) { return (s, args) -> { - if (args.length > 0) { - return Result.error("extra arguments are not allowed"); - } + if (args.length > 0) { return Result.error("extra arguments are not allowed"); } V v = getter.apply(isUpperCase ? s.toUpperCase(Locale.ROOT) : s); return v == null ? Result.error() : Result.some(trueTypeFunction.apply(v)); }; diff --git a/src/main/java/com/cleanroommc/groovyscript/api/IRegistrar.java b/src/main/java/com/cleanroommc/groovyscript/api/IRegistrar.java index ec65a483c..40dba81a9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/IRegistrar.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/IRegistrar.java @@ -1,17 +1,16 @@ package com.cleanroommc.groovyscript.api; -import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; -import org.jetbrains.annotations.ApiStatus; - import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import org.jetbrains.annotations.ApiStatus; + +import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; + /** * @deprecated The methods of this class have been added directly to {@link GroovyContainer} */ -@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") -@Deprecated -@ApiStatus.NonExtendable +@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") @Deprecated @ApiStatus.NonExtendable public interface IRegistrar { /** @@ -32,7 +31,7 @@ public interface IRegistrar { default void addFieldsOf(Object object) { boolean staticOnly = false; Class clazz; - if (object instanceof Class c) { + if (object instanceof Classc) { clazz = c; staticOnly = true; } else { @@ -40,10 +39,7 @@ default void addFieldsOf(Object object) { } for (Field field : clazz.getDeclaredFields()) { boolean isStatic = Modifier.isStatic(field.getModifiers()); - if (!field.isAnnotationPresent(GroovyBlacklist.class) && - INamed.class.isAssignableFrom(field.getType()) && - (!staticOnly || isStatic) && - field.isAccessible()) { + if (!field.isAnnotationPresent(GroovyBlacklist.class) && INamed.class.isAssignableFrom(field.getType()) && (!staticOnly || isStatic) && field.isAccessible()) { try { Object o = field.get(isStatic ? null : object); if (o != null) { diff --git a/src/main/java/com/cleanroommc/groovyscript/api/IReloadableForgeRegistry.java b/src/main/java/com/cleanroommc/groovyscript/api/IReloadableForgeRegistry.java index d0b8c8ef6..caff8651d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/IReloadableForgeRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/IReloadableForgeRegistry.java @@ -2,6 +2,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.IForgeRegistryEntry; + import org.jetbrains.annotations.ApiStatus; /** diff --git a/src/main/java/com/cleanroommc/groovyscript/api/IScriptReloadable.java b/src/main/java/com/cleanroommc/groovyscript/api/IScriptReloadable.java index 22311b0e3..cfd705988 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/IScriptReloadable.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/IScriptReloadable.java @@ -4,12 +4,10 @@ public interface IScriptReloadable extends INamed { - @GroovyBlacklist - @ApiStatus.OverrideOnly + @GroovyBlacklist @ApiStatus.OverrideOnly void onReload(); - @GroovyBlacklist - @ApiStatus.OverrideOnly + @GroovyBlacklist @ApiStatus.OverrideOnly void afterScriptLoad(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/api/Result.java b/src/main/java/com/cleanroommc/groovyscript/api/Result.java index 2e53059a0..6c749113c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/Result.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/Result.java @@ -1,10 +1,10 @@ package com.cleanroommc.groovyscript.api; +import java.util.NoSuchElementException; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.NoSuchElementException; - /** * An interface that either holds a value or an error. * @@ -50,14 +50,10 @@ public boolean hasError() { } @Override - public @Nullable String getError() { - return null; - } + public @Nullable String getError() { return null; } @Override - public @NotNull T getValue() { - return this.value; - } + public @NotNull T getValue() { return this.value; } } class Error implements Result { @@ -74,9 +70,7 @@ public boolean hasError() { } @Override - public @Nullable String getError() { - return this.error; - } + public @Nullable String getError() { return this.error; } @Override public @NotNull T getValue() { diff --git a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Admonition.java b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Admonition.java index e2a927e33..521b9ce3f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Admonition.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Admonition.java @@ -1,24 +1,24 @@ package com.cleanroommc.groovyscript.api.documentation.annotations; -import com.google.common.base.CaseFormat; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import com.google.common.base.CaseFormat; + /** * Instructions on how to create the desired Admonition for documenting the Registry, based on the syntax to make an * Admonition for Material for MkDocs. */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ /* No targets allowed */}) +@Retention(RetentionPolicy.RUNTIME) @Target({ /* No targets allowed */}) public @interface Admonition { /** * The localization key for the admonition description, should be in the format of *
* - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.note{index of note in array} + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() + * VirtualizedRegistry#getName()}.note{index of note in array} * * * @return localization key for the admonition description @@ -36,7 +36,8 @@ /** * The type of Admonition. * The Admonition type controls the symbol, color, and default title. - * The title may be overridden by enabling {@link #hasTitle()}, after which the value of {@link #title()} will control the title. + * The title may be overridden by enabling {@link #hasTitle()}, after which the value of {@link #title()} will control the + * title. * * @return the type of Admonition, controlling symbol, color, and default title, defaults to {@link Type#NOTE} * @see Type @@ -47,12 +48,14 @@ * If {@link #hasTitle()} is enabled, overrides the title set by the type in {@link #type()}. When it is an empty string * the title will be cleared and the title bar will be removed from the Admonition. * - * @return title of the Admonition, with an empty string clears the default title set by the time, defaults to clearing the title + * @return title of the Admonition, with an empty string clears the default title set by the time, defaults to clearing the + * title */ String title() default ""; /** - * Controls if the title set by {@link #title()} is applied and overrides the default title set by the type in {@link #type()}. + * Controls if the title set by {@link #title()} is applied and overrides the default title set by the type in + * {@link #type()}. * * @return enables the custom {@link #title()}, defaults to {@code false} */ @@ -68,11 +71,13 @@ enum Format { */ STANDARD, /** - * A box which can be toggled between only rendering the title and the full text. Defaults to the collapsed form (only the title visible). + * A box which can be toggled between only rendering the title and the full text. Defaults to the collapsed form (only the + * title visible). */ COLLAPSED, /** - * A box which can be toggled between only rendering the title and the full text. Defaults to the expanded form (both title and text visible). + * A box which can be toggled between only rendering the title and the full text. Defaults to the expanded form (both + * title and text visible). */ EXPANDED } @@ -86,6 +91,7 @@ enum Format { *
- {@link #EXAMPLE Example}: Indicates an example of some code in practice. */ enum Type { + /** * Indicates a generic comment - the most common type of Admonition. */ diff --git a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Comp.java b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Comp.java index 3a7ed8ef3..966673d8d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Comp.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Comp.java @@ -10,8 +10,7 @@ * * @see Property#valid() */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ /* No targets allowed */}) +@Retention(RetentionPolicy.RUNTIME) @Target({ /* No targets allowed */}) public @interface Comp { /** @@ -26,52 +25,48 @@ /** * Used to determine the type of comparison. Contains a symbol representation and a localization key. - * * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * *
namesymbolkey
GT>groovyscript.wiki.greater_than
GTE>=groovyscript.wiki.greater_than_or_equal_to
EQ==groovyscript.wiki.equal_to
LTE<=groovyscript.wiki.less_than_or_equal_to
LT<groovyscript.wiki.less_than
NOT!=groovyscript.wiki.not
namesymbolkey
GT>groovyscript.wiki.greater_than
GTE>=groovyscript.wiki.greater_than_or_equal_to
EQ==groovyscript.wiki.equal_to
LTE<=groovyscript.wiki.less_than_or_equal_to
LT<groovyscript.wiki.less_than
NOT!=groovyscript.wiki.not
*/ enum Type { - GT(">", "greater_than"), - GTE(">=", "greater_than_or_equal_to"), - EQ("==", "equal_to"), - LTE("<=", "less_than_or_equal_to"), - LT("<", "less_than"), - NOT("!=", "not"); + + GT(">", "greater_than"), GTE(">=", "greater_than_or_equal_to"), EQ("==", "equal_to"), LTE("<=", "less_than_or_equal_to"), + LT("<", "less_than"), NOT("!=", "not"); private static final String baseLocalizationPath = "groovyscript.wiki."; @@ -83,13 +78,9 @@ enum Type { this.key = baseLocalizationPath + key; } - public String getSymbol() { - return symbol; - } + public String getSymbol() { return symbol; } - public String getKey() { - return key; - } + public String getKey() { return key; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Example.java b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Example.java index 9f2e8795f..71912a12e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Example.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Example.java @@ -9,43 +9,49 @@ * the method/recipe builder for both the wiki and the text script files.
* When combined, all examples created for any given mod should create a fully functional {@code .groovy} file. *
    - *
  • {@link #value()} a string which is inserted inside parameters calling the attached method.
  • - *
  • {@link #imports()} an array of packages that must be imported for the examples file to run properly. - * Has no impact on the wiki.
  • - *
  • {@link #def()} a string which is the name of the variable this {@link Example} will be assigned to. - * Ensure via {@link #priority()} that the declaration happens prior to any use of the variable.
  • - *
  • {@link #annotations()} an ordered array of comments that will be converted into annotations for the wiki. - * Has no impact on the examples file.
  • - *
  • {@link #commented()} if the example is commented in the examples file. - * Typically used on {@code removeAll()} methods or other methods which could be disruptive or fail to run. - * Has no impact on the wiki.
  • - *
  • {@link #priority()} is an integer that influences the sorting of the {@link Example} relative to other {@link Example}s.
  • + *
  • {@link #value()} a string which is inserted inside parameters calling the attached method.
  • + *
  • {@link #imports()} an array of packages that must be imported for the examples file to run properly. + * Has no impact on the wiki.
  • + *
  • {@link #def()} a string which is the name of the variable this {@link Example} will be assigned to. + * Ensure via {@link #priority()} that the declaration happens prior to any use of the variable.
  • + *
  • {@link #annotations()} an ordered array of comments that will be converted into annotations for the wiki. + * Has no impact on the examples file.
  • + *
  • {@link #commented()} if the example is commented in the examples file. + * Typically used on {@code removeAll()} methods or other methods which could be disruptive or fail to run. + * Has no impact on the wiki.
  • + *
  • {@link #priority()} is an integer that influences the sorting of the {@link Example} relative to other + * {@link Example}s.
  • *
*/ -@Retention(RetentionPolicy.RUNTIME) -@Target({ /* No targets allowed */}) +@Retention(RetentionPolicy.RUNTIME) @Target({ /* No targets allowed */}) public @interface Example { /** * For recipe builders, this will be a string that is a valid one-line series of methods to create a Recipe Builder that will - * pass the {@link com.cleanroommc.groovyscript.helper.recipe.IRecipeBuilder#validate() IRecipeBuilder#validate()} check and be successfully registered. + * pass the {@link com.cleanroommc.groovyscript.helper.recipe.IRecipeBuilder#validate() IRecipeBuilder#validate()} check and + * be successfully registered. *
* For methods, this should be exclusive the parameters of the method. e.g. {@code "item('minecraft:clay')"}
* Any comments for the wiki should be marked by * * /*()*{@literal /} * - * and then the actual text of the comment should be in an {@link #annotations()}. Multiple comments can be inserted, and replace the comment as expected. + * and then the actual text of the comment should be in an {@link #annotations()}. Multiple comments can be inserted, and + * replace the comment as expected. * * @return a string that will generate valid code when processed */ String value() default ""; /** - * As imports must be added to the top of the file, any imports must be split out and explicitly noted for the example(s) to function. - * Some imports are imported to all files by default via {@link com.cleanroommc.groovyscript.sandbox.GroovyScriptSandbox#getImportCustomizer() GroovyScriptSandbox#getImportCustomizer()}. + * As imports must be added to the top of the file, any imports must be split out and explicitly noted for the example(s) to + * function. + * Some imports are imported to all files by default via + * {@link com.cleanroommc.groovyscript.sandbox.GroovyScriptSandbox#getImportCustomizer() + * GroovyScriptSandbox#getImportCustomizer()}. *
- * This should contain an array of full import packages, e.g. {@code {"net.minecraft.item.Item", "net.minecraft.item.ItemStack"}} + * This should contain an array of full import packages, e.g. {@code {"net.minecraft.item.Item", + * "net.minecraft.item.ItemStack"}} * * @return an array of imports that must be added for the example(s) to work */ @@ -67,18 +73,21 @@ * An ordered array of annotations used as comments for the wiki. * Annotations for Material for MkDocs * are specialized comments which take the form of a button that opens a tooltip. They are formatted as either - * /*()*{@literal /}, or /*()!*{@literal /}, with the {@code !} controlling if the surrounding comment is rendered, with + * /*()*{@literal /}, or /*()!*{@literal /}, with the {@code !} controlling if the surrounding + * comment is rendered, with * {@code !} being present causing the surrounding comment characters to be removed.
* In most cases, /*()!*{@literal /} should be used.
* - * @return an array of strings which will replace /*()*{@literal /} or /*()!*{@literal /} to create annotations for the wiki + * @return an array of strings which will replace /*()*{@literal /} or /*()!*{@literal /} to create + * annotations for the wiki */ String[] annotations() default {}; /** * Some examples may conflict with each other, or it may be otherwise beneficial for the code to the commented by default, * yet still remain in the examples file. - * A common example of this is {@code removeAll()} methods, which may remove entries required for other examples, causing errors when + * A common example of this is {@code removeAll()} methods, which may remove entries required for other examples, causing + * errors when * the full file is run. * * @return if the code in the examples should be commented, defaults to {@code false} @@ -87,7 +96,8 @@ /** * Priority of the method, relative to other methods in the same class. - * Priorities sort entries such that lowest is first, then commented examples are last, then number of examples, then the natural order of the first example. + * Priorities sort entries such that lowest is first, then commented examples are last, then number of examples, then the + * natural order of the first example. * * @return the example priority (relative to other examples for the same method or Recipe Builder) */ diff --git a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/MethodDescription.java b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/MethodDescription.java index b8f105091..0ee3cc73a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/MethodDescription.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/MethodDescription.java @@ -9,23 +9,26 @@ /** * Documentation information for generic methods of a registry.
* All fields are optional, and most have default values generated in {@link Example}. - * *
    - *
  • {@link #description()} is a localization key that is autogenerated to be - * - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.{@link Method#getName()} - * - *
  • - *
  • {@link #example()} is an array of {@link Example}s In situations where either a single {@link Example} with multiple lines or - * multiple {@link Example}s could be used, using multiple {@link Example}s is preferable.
  • - *
  • {@link #type()} is a {@link Type} determining what type of Method is being annotated. Different types are placed in different locations of the wiki page and examples file.
  • - *
  • {@link #priority()} is an integer that influences the sorting of the {@link MethodDescription} relative to other {@link MethodDescription}s of the same {@link Type}.
  • + *
  • {@link #description()} is a localization key that is autogenerated to be + * + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() + * GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() + * VirtualizedRegistry#getName()}.{@link Method#getName()} + * + *
  • + *
  • {@link #example()} is an array of {@link Example}s In situations where either a single {@link Example} with multiple lines + * or + * multiple {@link Example}s could be used, using multiple {@link Example}s is preferable.
  • + *
  • {@link #type()} is a {@link Type} determining what type of Method is being annotated. Different types are placed in + * different locations of the wiki page and examples file.
  • + *
  • {@link #priority()} is an integer that influences the sorting of the {@link MethodDescription} relative to other + * {@link MethodDescription}s of the same {@link Type}.
  • *
* * @see Type */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface MethodDescription { /** @@ -35,7 +38,9 @@ * {@link net.minecraft.client.resources.I18n#format(String, Object...) I18n.format(description())} *
* If this is empty, will fall back to generating a description based on - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.{@link Method#getName()}. + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() + * GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() + * VirtualizedRegistry#getName()}.{@link Method#getName()}. * Then, if that does not have a lang key defined, it will attempt to use a global lang key based on the method name * groovyscript.wiki.{@link Method#getName()} * if that also does not have a lang key defined, will log a missing key in the {@code groovy.log} file. @@ -53,10 +58,12 @@ Example[] example() default {}; /** - * Determines if the method is used to add an entry to the registry, remove an entry from the registry, or simply get information about the registry. + * Determines if the method is used to add an entry to the registry, remove an entry from the registry, or simply get + * information about the registry. * Defaults to {@code Type.REMOVAL} * - * @return if the method adds entries, removes entries, or is purely a query of information. Defaults to removes entries ({@link Type#REMOVAL}) + * @return if the method adds entries, removes entries, or is purely a query of information. Defaults to removes entries + * ({@link Type#REMOVAL}) * @see Type */ Type type() default Type.REMOVAL; @@ -76,19 +83,22 @@ enum Type { /** - * Instructs that the method neither adds nor removes entries from the registry, and only checks information about the registry. + * Instructs that the method neither adds nor removes entries from the registry, and only checks information about the + * registry. * Often used in removing entries matching complex requirements that are not otherwise supported. */ QUERY, /** - * Instructs that the method adds entries to the registry, indicating it should be placed in the ADDITION category on the wiki and + * Instructs that the method adds entries to the registry, indicating it should be placed in the ADDITION category on the + * wiki and * below {@linkplain #REMOVAL}-type methods in examples files. */ ADDITION, /** - * Instructs that the method removes entries to the registry, indicating it should be placed in the REMOVAL category on the wiki and + * Instructs that the method removes entries to the registry, indicating it should be placed in the REMOVAL category on + * the wiki and * above {@linkplain #ADDITION}-type methods in examples files. */ REMOVAL, diff --git a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Property.java b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Property.java index a345ecb09..75afc4c3a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Property.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/Property.java @@ -6,54 +6,66 @@ /** * Functions in one of three ways depending on what the annotation is attached to: *
    - *
  • - * {@link ElementType#FIELD}: Marks the target field with this {@link Property}. {@link #property()} must be either set to the field name or unset. - * Can only allow one annotation per field. - *
  • - *
  • - * {@link ElementType#TYPE}: Marks the field targeted by {@link #property()} within the attached class with this {@link Property}. - * Multiple will be wrapped in {@link Properties}. - *
  • - *
  • - * {@link ElementType#METHOD}: Marks the field targeted by {@link #property()} within the class the attached method returns with this {@link Property}. - * Can only be attached via being inside {@link RecipeBuilderDescription#requirement()}. - *
  • + *
  • + * {@link ElementType#FIELD}: Marks the target field with this {@link Property}. {@link #property()} must be either set to the + * field name or unset. + * Can only allow one annotation per field. + *
  • + *
  • + * {@link ElementType#TYPE}: Marks the field targeted by {@link #property()} within the attached class with this {@link Property}. + * Multiple will be wrapped in {@link Properties}. + *
  • + *
  • + * {@link ElementType#METHOD}: Marks the field targeted by {@link #property()} within the class the attached method returns with + * this {@link Property}. + * Can only be attached via being inside {@link RecipeBuilderDescription#requirement()}. + *
  • *
*

* Elements: *

    - *
  • {@link #value()} is a localization key that is autogenerated to be - * - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link Field#getName()}.value - * - * and states what the property does. - *
  • - *
  • {@link #property()} either contains nothing if {@link Property} was created attached to a field, or the relevant {@link Field#getName()} string.
  • - *
  • {@link #defaultValue()} a string containing the default value of the property. If empty, defaults to {@code null}.
  • - *
  • {@link #valid()} is an array of {@link Comp} that indicates the requirements of the {@link Property} to pass validation.
  • - *
  • {@link #requirement()} is a localization key that states the requirements for the property to pass validation provided the requirements are too - * complex to represent via {@link #valid()}.
  • - *
  • {@link #ignoresInheritedMethods()} if this {@link Property} annotation requires any methods targeting the {@link Property} to not be inherited methods.
  • - *
  • {@link #needsOverride()} if this {@link Property} annotation needs another {@link Property} annotation with this element set to {@code true} to function. - * Used in wrapper classes, such as {@link com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder AbstractRecipeBuilder}, where some or all of the fields may not be needed in subclasses.
  • - *
  • {@link #hierarchy()} is an integer that controls the precedence of the {@link Property} annotation when multiple versions of it exist for a single field. - * A lower hierarchy overrides a higher one, with the default having a value of 10.
  • - *
  • {@link #priority()} is an integer that influences the sorting of the {@link Property} relative to other {@link Property Properties}. - * Should be set to a higher value on {@link Property Properties} that have {@link #needsOverride()} set to {@code true}, and lower on any property added via - * {@link ElementType#METHOD} to ensure proper prioritization.
  • + *
  • {@link #value()} is a localization key that is autogenerated to be + * + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() + * GroovyContainer#getModId()}.{@link Field#getName()}.value + * + * and states what the property does. + *
  • + *
  • {@link #property()} either contains nothing if {@link Property} was created attached to a field, or the relevant + * {@link Field#getName()} string.
  • + *
  • {@link #defaultValue()} a string containing the default value of the property. If empty, defaults to {@code null}.
  • + *
  • {@link #valid()} is an array of {@link Comp} that indicates the requirements of the {@link Property} to pass + * validation.
  • + *
  • {@link #requirement()} is a localization key that states the requirements for the property to pass validation provided the + * requirements are too + * complex to represent via {@link #valid()}.
  • + *
  • {@link #ignoresInheritedMethods()} if this {@link Property} annotation requires any methods targeting the {@link Property} + * to not be inherited methods.
  • + *
  • {@link #needsOverride()} if this {@link Property} annotation needs another {@link Property} annotation with this element + * set to {@code true} to function. + * Used in wrapper classes, such as {@link com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder + * AbstractRecipeBuilder}, where some or all of the fields may not be needed in subclasses.
  • + *
  • {@link #hierarchy()} is an integer that controls the precedence of the {@link Property} annotation when multiple versions + * of it exist for a single field. + * A lower hierarchy overrides a higher one, with the default having a value of 10.
  • + *
  • {@link #priority()} is an integer that influences the sorting of the {@link Property} relative to other {@link Property + * Properties}. + * Should be set to a higher value on {@link Property Properties} that have {@link #needsOverride()} set to {@code true}, and + * lower on any property added via + * {@link ElementType#METHOD} to ensure proper prioritization.
  • *
* * @see Properties */ -@Repeatable(Property.Properties.class) -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD, ElementType.TYPE}) +@Repeatable(Property.Properties.class) @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE}) public @interface Property { /** * The localization key for the name of the compat, will default to generating * - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.{@link Field#getName()}.value + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() + * GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() + * VirtualizedRegistry#getName()}.{@link Field#getName()}.value * * * @return localization key for what the target field will accomplish @@ -61,18 +73,22 @@ String value() default ""; /** - * If this {@link Property} annotation is attached to a field, this element is set to the name of the field they are attached to. - * When annotated on a field already, this should not be set or be set to the field name. Any other string will generate a warning. + * If this {@link Property} annotation is attached to a field, this element is set to the name of the field they are attached + * to. + * When annotated on a field already, this should not be set or be set to the field name. Any other string will generate a + * warning. * * @return the target property, if not annotated to a field. */ String property() default ""; /** - * The default value of the property. Only needs to be declared if the default value is different from the default value created by a new object of that type. + * The default value of the property. Only needs to be declared if the default value is different from the default value + * created by a new object of that type. * For instance, "0" is the default value for {@code int}s, and so does not have to be declared. * - * @return what the default value is, defaults to {@code false}, {@code 0}, {@code 0.0f}, {@code "null"}, etc depending on the property class. + * @return what the default value is, defaults to {@code false}, {@code 0}, {@code 0.0f}, {@code "null"}, etc depending on the + * property class. * @see com.cleanroommc.groovyscript.documentation.Builder#defaultValueConverter */ @SuppressWarnings("JavadocReference") @@ -84,32 +100,32 @@ *
- a number: Would indicate comparing directly against the number. *
- an array or list: Would indicate comparing against the length of the array/list. *
- another object: Would use to indicate {@code not null} is required. - * * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * *
validationcode
x == 1valid = @Comp("1")
x != 1valid = @Comp(value = "1", type = Comp.Type.NOT)
x != nullvalid = @Comp(value = "null", type = Comp.Type.NOT)
x > 0valid = @Comp(value = "0", type = Comp.Type.GT)
x >= 0 && x <= 5valid = {{@literal @}Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "5", type = Comp.Type.LTE)}
validationcode
x == 1valid = @Comp("1")
x != 1valid = @Comp(value = "1", type = Comp.Type.NOT)
x != nullvalid = @Comp(value = "null", type = Comp.Type.NOT)
x > 0valid = @Comp(value = "0", type = Comp.Type.GT)
x >= 0 && x <= 5valid = {{@literal @}Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "5", type = + * Comp.Type.LTE)}
* * @return an array of {@link Comp} entries indicating valid values for the property to be. @@ -131,10 +147,13 @@ boolean ignoresInheritedMethods() default false; /** - * Controls if the property needs an overriding property to enable it. Used in wrapper classes, such as {@link com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder AbstractRecipeBuilderr}, where some or all of the fields + * Controls if the property needs an overriding property to enable it. Used in wrapper classes, such as + * {@link com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder AbstractRecipeBuilderr}, where some or all of the + * fields * may not be needed in subclasses. * This can also be used to effectively disable properties from being documented by attaching it to the lowest hierarchy. - * The annotation for the given property field with the lowest {@link #hierarchy} score must have this be {@code false} for the property to be documented. + * The annotation for the given property field with the lowest {@link #hierarchy} score must have this be {@code false} for + * the property to be documented. * * @return if the property needs an overriding annotation to enable it, defaults to {@code false} */ @@ -160,12 +179,12 @@ * Wrapper to allow repeatable instances of {@link Property}. * If more than one {@link Property} is applied to anywhere other than a class, it will generate an error. * For a given Field. only a single {@link Property} should be attached, - * and for a given Method, all {@link Property} annotations should be placed inside {@link RecipeBuilderDescription#requirement()} + * and for a given Method, all {@link Property} annotations should be placed inside + * {@link RecipeBuilderDescription#requirement()} * * @see Property */ - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.TYPE) + @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @interface Properties { Property[] value(); diff --git a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderDescription.java b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderDescription.java index 277274cdd..47802a49b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderDescription.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderDescription.java @@ -10,20 +10,22 @@ * Marks the given Method as the initializing method for a Recipe Builder, indicating it returns a Recipe Builder class.
* A Recipe Builder is a class which follows the Builder design pattern, where each step of the builder returns the builder class, * allowing chaining of methods to quickly and cleanly create complicated objects which may or may not require some values. - * *
    - *
  • {@link #example()} is an array of {@link Example}s In situations where either a single {@link Example} with multiple lines or - * multiple {@link Example}s could be used, using multiple {@link Example}s is preferable.
  • - *
  • {@link #requirement()} is a localization key that is autogenerated to be - * - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.{@link Field#getName()} - * - *
  • - *
  • {@link #priority()} is an integer that influences the sorting of the {@link RecipeBuilderDescription} relative to other {@link RecipeBuilderDescription}s.
  • + *
  • {@link #example()} is an array of {@link Example}s In situations where either a single {@link Example} with multiple lines + * or + * multiple {@link Example}s could be used, using multiple {@link Example}s is preferable.
  • + *
  • {@link #requirement()} is a localization key that is autogenerated to be + * + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() + * GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() + * VirtualizedRegistry#getName()}.{@link Field#getName()} + * + *
  • + *
  • {@link #priority()} is an integer that influences the sorting of the {@link RecipeBuilderDescription} relative to other + * {@link RecipeBuilderDescription}s.
  • *
*/ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface RecipeBuilderDescription { /** @@ -35,7 +37,8 @@ Example[] example() default {}; /** - * An override to other {@link Property} declarations, and only used for {@link Property} instances which are unique to the Recipe Builder + * An override to other {@link Property} declarations, and only used for {@link Property} instances which are unique to the + * Recipe Builder * obtained via the given method. * * @return array of requirements unique to the recipe builder being accessed via this method diff --git a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderMethodDescription.java b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderMethodDescription.java index 4cc85bba4..893cf618e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderMethodDescription.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderMethodDescription.java @@ -7,17 +7,19 @@ import java.lang.reflect.Method; /** - * Marks the given Method as a Recipe Builder method, indicating it returns a Recipe Builder class and is used inside a Recipe Builder.
+ * Marks the given Method as a Recipe Builder method, indicating it returns a Recipe Builder class and is used inside a Recipe + * Builder.
* A Recipe Builder is a class which follows the Builder design pattern, where each step of the builder returns the builder class, * allowing chaining of methods to quickly and cleanly create complicated objects which may or may not require some values.
* The field element is autogenerated to be equal to the method name by default. *
    - *
  • {@link #field()} is an array that defaults to {@link Method#getName()} if not overridden, and indicates the target field(s) that the method modifies.
  • - *
  • {@link #priority()} is an integer that influences the sorting of the {@link RecipeBuilderMethodDescription} relative to other {@link RecipeBuilderMethodDescription}s.
  • + *
  • {@link #field()} is an array that defaults to {@link Method#getName()} if not overridden, and indicates the target field(s) + * that the method modifies.
  • + *
  • {@link #priority()} is an integer that influences the sorting of the {@link RecipeBuilderMethodDescription} relative to + * other {@link RecipeBuilderMethodDescription}s.
  • *
*/ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface RecipeBuilderMethodDescription { /** @@ -29,7 +31,8 @@ /** * Priority of the method, relative to other {@link RecipeBuilderMethodDescription}s modifying the shared {@link Property}. - * Priorities sort entries such that lowest is first, then by the length of {@link Method#getName()}, then by {@link String#compareToIgnoreCase} of {@link Method#getName()}. + * Priorities sort entries such that lowest is first, then by the length of {@link Method#getName()}, then by + * {@link String#compareToIgnoreCase} of {@link Method#getName()}. * * @return the method priority */ diff --git a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderRegistrationMethod.java b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderRegistrationMethod.java index 78fe53263..8134c114b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderRegistrationMethod.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RecipeBuilderRegistrationMethod.java @@ -9,8 +9,7 @@ * Indicates that the method is the final step used in a RecipeBuilder, and adds the recipe created * by the prior methods of the RecipeBuilder to the registry. */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface RecipeBuilderRegistrationMethod { /** @@ -23,7 +22,8 @@ /** * Priority of the registration method, relative to other registration methods of the same Recipe Builder. - * Priorities sort entries such that lowest is first, then by the natural order of {@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()} + * Priorities sort entries such that lowest is first, then by the natural order of + * {@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()} * * @return the method priority */ diff --git a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RegistryDescription.java b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RegistryDescription.java index d5926458f..3177a2239 100644 --- a/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RegistryDescription.java +++ b/src/main/java/com/cleanroommc/groovyscript/api/documentation/annotations/RegistryDescription.java @@ -9,35 +9,45 @@ * Marks the given class as a Groovyscript registry class.
* Many elements are autogenerated by default. *
    - *
  • - * {@link #title()} is a localization key that is autogenerated with a base of - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.title - *
  • - *
  • - * {@link #description()} is a localization key that is autogenerated with a base of - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.description - *
  • - *
  • {@link #linkGenerator()} is the name, typically a modid, of a {@link com.cleanroommc.groovyscript.documentation.linkgenerator.ILinkGenerator ILinkGenerator} - * contained in {@link com.cleanroommc.groovyscript.documentation.linkgenerator.LinkGeneratorHooks LinkGeneratorHooks}. - * This will generate a link from the wiki to the source code of the specific file the class {@link RegistryDescription} annotates is in.
  • - *
  • {@link #location()} is the name of a {@link com.cleanroommc.groovyscript.sandbox.LoadStage} and controls where all methods - * inside the {@link RegistryDescription} are generated.
  • - *
  • {@link #reloadability()} determines the status of the compat, defaulting to fully reloadable ({@link Reloadability#FULLY}).
  • - *
  • {@link #isFullyDocumented()} informs whether the {@link RegistryDescription} documents all relevant functionality.
  • - *
  • {@link #admonition()} is an array of admonition blocks to be generated at the top of the wiki page for additional information, - * commonly of the type {@link Admonition.Type#DANGER} to indicate important information.
  • - *
  • {@link #category()} determines what words are used to refer to the registry and what it contains.
  • - *
  • {@link #priority()} is an integer that influences the sorting of the {@link RegistryDescription} relative to other {@link RegistryDescription}s.
  • + *
  • + * {@link #title()} is a localization key that is autogenerated with a base of + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() + * GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() + * VirtualizedRegistry#getName()}.title + *
  • + *
  • + * {@link #description()} is a localization key that is autogenerated with a base of + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() + * GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() + * VirtualizedRegistry#getName()}.description + *
  • + *
  • {@link #linkGenerator()} is the name, typically a modid, of a + * {@link com.cleanroommc.groovyscript.documentation.linkgenerator.ILinkGenerator ILinkGenerator} + * contained in {@link com.cleanroommc.groovyscript.documentation.linkgenerator.LinkGeneratorHooks LinkGeneratorHooks}. + * This will generate a link from the wiki to the source code of the specific file the class {@link RegistryDescription} annotates + * is in.
  • + *
  • {@link #location()} is the name of a {@link com.cleanroommc.groovyscript.sandbox.LoadStage} and controls where all methods + * inside the {@link RegistryDescription} are generated.
  • + *
  • {@link #reloadability()} determines the status of the compat, defaulting to fully reloadable + * ({@link Reloadability#FULLY}).
  • + *
  • {@link #isFullyDocumented()} informs whether the {@link RegistryDescription} documents all relevant functionality.
  • + *
  • {@link #admonition()} is an array of admonition blocks to be generated at the top of the wiki page for additional + * information, + * commonly of the type {@link Admonition.Type#DANGER} to indicate important information.
  • + *
  • {@link #category()} determines what words are used to refer to the registry and what it contains.
  • + *
  • {@link #priority()} is an integer that influences the sorting of the {@link RegistryDescription} relative to other + * {@link RegistryDescription}s.
  • *
*/ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface RegistryDescription { /** * The localization key for the name of the compat, will default to generating * - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.title + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() + * GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() + * VirtualizedRegistry#getName()}.title * * * @return localization key for the compat name @@ -47,7 +57,9 @@ /** * The localization key for the description of the compat, will default to generating * - * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()}.description + * groovyscript.wiki.{@link com.cleanroommc.groovyscript.compat.mods.GroovyContainer#getModId() + * GroovyContainer#getModId()}.{@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() + * VirtualizedRegistry#getName()}.description * * * @return localization key for the compat description @@ -55,13 +67,17 @@ String description() default ""; /** - * Controls what the parser is to transform the java class file into a link so the source code may be accessed from the documentation. - * Addons should create their own instance of the {@link com.cleanroommc.groovyscript.documentation.linkgenerator.ILinkGenerator ILinkGenerator} class, + * Controls what the parser is to transform the java class file into a link so the source code may be accessed from the + * documentation. + * Addons should create their own instance of the + * {@link com.cleanroommc.groovyscript.documentation.linkgenerator.ILinkGenerator ILinkGenerator} class, * preferably with the name of the generator being set to the modid. - * If it is not set or a corresponding LinkGenerator does not exist, the {@link com.cleanroommc.groovyscript.documentation.linkgenerator.ILinkGenerator ILinkGenerator} - * converts to a link towards CleanroomMC's Groovyscript repo set to view the repo at a specific version tag. + * If it is not set or a corresponding LinkGenerator does not exist, the + * {@link com.cleanroommc.groovyscript.documentation.linkgenerator.ILinkGenerator ILinkGenerator} + * converts to a link towards CleanroomMC's Groovyscript repo set to view the repo at a specific version tag. * - * @return a string corresponding to a {@link com.cleanroommc.groovyscript.documentation.linkgenerator.ILinkGenerator ILinkGenerator}, which controls how the source code link is generated. + * @return a string corresponding to a {@link com.cleanroommc.groovyscript.documentation.linkgenerator.ILinkGenerator + * ILinkGenerator}, which controls how the source code link is generated. * @see com.cleanroommc.groovyscript.documentation.linkgenerator.ILinkGenerator ILinkGenerator */ String linkGenerator() default ""; @@ -105,7 +121,8 @@ /** * Priority of the registry, relative to other registries of the same mod. - * Priorities sort entries such that lowest is first, then by the natural order of {@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()} + * Priorities sort entries such that lowest is first, then by the natural order of + * {@link com.cleanroommc.groovyscript.registry.VirtualizedRegistry#getName() VirtualizedRegistry#getName()} * * @return the registry priority */ @@ -113,11 +130,14 @@ /** * How reloadable the compat is:
- * - {@link Reloadability#FULLY}: can be reloaded in-game, with each reload reproducing the same game-state as would be produced by restarting minecraft.
- * - {@link Reloadability#FLAWED}: can be reloaded in-game, but reloads may not recreate the same game-state as would be produced by restarting minecraft.
+ * - {@link Reloadability#FULLY}: can be reloaded in-game, with each reload reproducing the same game-state as would be + * produced by restarting minecraft.
+ * - {@link Reloadability#FLAWED}: can be reloaded in-game, but reloads may not recreate the same game-state as would be + * produced by restarting minecraft.
* - {@link Reloadability#DISABLED}: cannot be reloaded in-game, and requires a total minecraft restart to apply changes.
*/ enum Reloadability { + /** * Can be reloaded in-game, with each reload reproducing the same game-state as would be produced by restarting minecraft */ @@ -131,9 +151,7 @@ enum Reloadability { */ DISABLED; - public boolean isReloadable() { - return this != DISABLED; - } + public boolean isReloadable() { return this != DISABLED; } public boolean hasFlaws() { return this == FLAWED; @@ -146,8 +164,8 @@ public boolean hasFlaws() { * Currently, either specifically "recipes" or generically "entries" */ enum Category { - RECIPES("recipes"), - ENTRIES("entries"); + + RECIPES("recipes"), ENTRIES("entries"); private final String category; diff --git a/src/main/java/com/cleanroommc/groovyscript/command/CustomClickAction.java b/src/main/java/com/cleanroommc/groovyscript/command/CustomClickAction.java index 290748ff3..6dfdd02e4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/CustomClickAction.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/CustomClickAction.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.command; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import net.minecraft.util.text.event.ClickEvent; - import java.util.Map; import java.util.function.Consumer; +import net.minecraft.util.text.event.ClickEvent; + +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; + public class CustomClickAction { public static final String PREFIX = "$custom$"; @@ -20,9 +21,7 @@ public static ClickEvent makeCopyEvent(String value) { } public static void registerAction(String name, Consumer action) { - if (ACTIONS.containsKey(name)) { - throw new IllegalArgumentException("Action " + name + " already exists!"); - } + if (ACTIONS.containsKey(name)) { throw new IllegalArgumentException("Action " + name + " already exists!"); } ACTIONS.put(name, action); } @@ -30,9 +29,7 @@ public static boolean runActionHook(String fullId) { String[] parts = fullId.split("::", 2); if (parts.length < 2) return false; Consumer action = ACTIONS.get(parts[0]); - if (action == null) { - return false; - } + if (action == null) { return false; } action.accept(parts[1]); return true; } diff --git a/src/main/java/com/cleanroommc/groovyscript/command/GSCommand.java b/src/main/java/com/cleanroommc/groovyscript/command/GSCommand.java index f8b0fddcb..5aee038f1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/GSCommand.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/GSCommand.java @@ -1,14 +1,14 @@ package com.cleanroommc.groovyscript.command; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.compat.mods.jei.JeiPlugin; -import com.cleanroommc.groovyscript.documentation.Documentation; -import com.cleanroommc.groovyscript.event.GsHandEvent; -import com.cleanroommc.groovyscript.network.NetworkHandler; -import com.cleanroommc.groovyscript.network.SReloadScripts; -import com.cleanroommc.groovyscript.sandbox.LoadStage; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import javax.annotation.Nonnull; + import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.command.ICommandSender; @@ -37,15 +37,18 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.server.command.CommandTreeBase; + import org.jetbrains.annotations.NotNull; -import javax.annotation.Nonnull; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.compat.mods.jei.JeiPlugin; +import com.cleanroommc.groovyscript.documentation.Documentation; +import com.cleanroommc.groovyscript.event.GsHandEvent; +import com.cleanroommc.groovyscript.network.NetworkHandler; +import com.cleanroommc.groovyscript.network.SReloadScripts; +import com.cleanroommc.groovyscript.sandbox.LoadStage; public class GSCommand extends CommandTreeBase { @@ -120,10 +123,10 @@ public GSCommand() { if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) { IFluidHandler handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); if (handler != null) { - GSHandCommand.fluidInformation(messages, Arrays.stream(handler.getTankProperties()) - .map(IFluidTankProperties::getContents) - .filter(Objects::nonNull) - .collect(Collectors.toList()), prettyNbt); + GSHandCommand.fluidInformation(messages, Arrays.stream(handler.getTankProperties()).map( + IFluidTankProperties::getContents) + .filter(Objects::nonNull).collect(Collectors.toList()), + prettyNbt); } } @@ -149,24 +152,28 @@ public GSCommand() { } })); - addSubcommand(new SimpleCommand("wiki", (server, sender, args) -> - sender.sendMessage(new TextComponentString("GroovyScript wiki") - .setStyle(new Style() - .setColor(TextFormatting.GOLD) - .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Click to open wiki in browser"))) - .setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://cleanroommc.com/groovy-script/")))) - , "doc", "docs", "documentation")); + addSubcommand(new SimpleCommand("wiki", (server, sender, args) -> sender.sendMessage(new TextComponentString( + "GroovyScript wiki").setStyle(new Style().setColor(TextFormatting.GOLD) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, + new TextComponentString("Click to open wiki in browser"))) + .setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, + "https://cleanroommc.com/groovy-script/")))), + "doc", "docs", "documentation")); addSubcommand(new SimpleCommand("generateWiki", (server, sender, args) -> { Documentation.generateWiki(); - sender.sendMessage(new TextComponentString("Generated a local version of the Groovyscript wiki has been generated to the ") - .appendSibling(getTextForFile("Wiki Folder", Documentation.WIKI.toPath().toString(), new TextComponentString("Click to open the generated GroovyScript wiki folder")))); + sender.sendMessage(new TextComponentString("Generated a local version of the Groovyscript wiki has been generated to the ").appendSibling(getTextForFile("Wiki Folder", + Documentation.WIKI.toPath() + .toString(), + new TextComponentString("Click to open the generated GroovyScript wiki folder")))); }, "generateDoc", "generateDocs", "generateDocumentation")); addSubcommand(new SimpleCommand("generateExamples", (server, sender, args) -> { Documentation.generateExamples(); - sender.sendMessage(new TextComponentString("Generated examples for the enabled Groovyscript compat to the ") - .appendSibling(getTextForFile("Examples Folder", Documentation.EXAMPLES.toPath().toString(), new TextComponentString("Click to open the Groovyscript examples folder")))); + sender.sendMessage(new TextComponentString("Generated examples for the enabled Groovyscript compat to the ").appendSibling(getTextForFile("Examples Folder", + Documentation.EXAMPLES.toPath() + .toString(), + new TextComponentString("Click to open the Groovyscript examples folder")))); })); addSubcommand(new SimpleCommand("creativeTabs", (server, sender, args) -> { @@ -174,15 +181,19 @@ public GSCommand() { for (CreativeTabs tab : CreativeTabs.CREATIVE_TAB_ARRAY) { GroovyLog.get().getWriter().println(" - " + tab.getTabLabel()); } - sender.sendMessage(new TextComponentString("Creative tabs has been logged to the ") - .appendSibling(GSCommand.getTextForFile("Groovy Log", GroovyLog.get().getLogFilerPath().toString(), new TextComponentString("Click to open GroovyScript log")))); + sender.sendMessage(new TextComponentString("Creative tabs has been logged to the ").appendSibling(GSCommand.getTextForFile("Groovy Log", + GroovyLog.get() + .getLogFilerPath() + .toString(), + new TextComponentString("Click to open GroovyScript log")))); })); addSubcommand(new SimpleCommand("deleteScriptCache", (server, sender, args) -> { if (GroovyScript.getSandbox().deleteScriptCache()) { sender.sendMessage(new TextComponentString(TextFormatting.GREEN + "Deleted groovy script cache")); } else { - sender.sendMessage(new TextComponentString(TextFormatting.RED + "An error occurred while deleting groovy script cache")); + sender.sendMessage(new TextComponentString(TextFormatting.RED + + "An error occurred while deleting groovy script cache")); } })); @@ -202,34 +213,30 @@ public GSCommand() { } } - @Override - @Nonnull - public String getName() { - return "groovyscript"; - } + @Override @Nonnull + public String getName() { return "groovyscript"; } - @Override - @Nonnull - public List getAliases() { - return Arrays.asList("grs", "GroovyScript", "gs"); - } + @Override @Nonnull + public List getAliases() { return Arrays.asList("grs", "GroovyScript", "gs"); } - @Override - @Nonnull + @Override @Nonnull public String getUsage(@NotNull ICommandSender sender) { return "/grs []"; } public static void postLogFiles(ICommandSender sender) { - sender.sendMessage(getTextForFile("Groovy Log", GroovyLog.get().getLogFilerPath().toString(), new TextComponentString("Click to open GroovyScript log"))); - sender.sendMessage(getTextForFile("Minecraft Log", GroovyLog.get().getLogFilerPath().getParent().toString() + File.separator + "latest.log", new TextComponentString("Click to open Minecraft log"))); + sender.sendMessage(getTextForFile("Groovy Log", GroovyLog.get().getLogFilerPath().toString(), new TextComponentString( + "Click to open GroovyScript log"))); + sender.sendMessage(getTextForFile("Minecraft Log", GroovyLog.get().getLogFilerPath().getParent().toString() + + File.separator + "latest.log", new TextComponentString( + "Click to open Minecraft log"))); } public static ITextComponent getTextForFile(String name, String path, ITextComponent hoverText) { - return new TextComponentString(TextFormatting.UNDERLINE + (TextFormatting.GOLD + name)) - .setStyle(new Style() - .setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, path)) - .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText))); + return new TextComponentString(TextFormatting.UNDERLINE + (TextFormatting.GOLD + name)).setStyle(new Style().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, + path)) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, + hoverText))); } private static BlockPos getBlockLookingAt(EntityPlayer player) { @@ -239,9 +246,7 @@ private static BlockPos getBlockLookingAt(EntityPlayer player) { Vec3d end = eyes.add(look.x * distance, look.y * distance, look.z * distance); RayTraceResult result = player.getEntityWorld().rayTraceBlocks(eyes, end, true); - if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) { - return result.getBlockPos(); - } + if (result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) { return result.getBlockPos(); } return null; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/command/GSHandCommand.java b/src/main/java/com/cleanroommc/groovyscript/command/GSHandCommand.java index 5f4a8595e..0210a2433 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/GSHandCommand.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/GSHandCommand.java @@ -1,7 +1,8 @@ package com.cleanroommc.groovyscript.command; -import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; -import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; +import java.util.Collections; +import java.util.List; + import net.minecraft.block.state.IBlockState; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; @@ -13,11 +14,12 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; + import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; -import java.util.Collections; -import java.util.List; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; /** * Creates and sends information to the player for the `/gs hand` command @@ -29,22 +31,21 @@ public static void itemInformation(List messages, @NotNull ItemS String itemPretty = IngredientHelper.asGroovyCode(stack, true, prettyNbt); String item = IngredientHelper.asGroovyCode(stack, false, prettyNbt); - messages.add(new TextComponentString("Item:") - .setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE).setBold(true))); + messages.add(new TextComponentString("Item:").setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE).setBold(true))); messages.add(TextCopyable.string(item, " - " + itemPretty).build()); GuiScreen.setClipboardString(item); String copy = stack.getItem().getTranslationKey(stack); - messages.add(new TextComponentString("Translation key:") - .setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE).setBold(true))); + messages.add(new TextComponentString("Translation key:").setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE) + .setBold(true))); messages.add(TextCopyable.string(copy, " - " + TextFormatting.YELLOW + copy).build()); } public static void blockStateInformation(List messages, @NotNull IBlockState state) { String copyText = IngredientHelper.asGroovyCode(state, false); - messages.add(new TextComponentString("Block state:") - .setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE).setBold(true))); + messages.add(new TextComponentString("Block state:").setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE).setBold( + true))); messages.add(TextCopyable.string(copyText, " - " + IngredientHelper.asGroovyCode(state, true)).build()); } @@ -54,8 +55,8 @@ public static void fluidInformation(List messages, @NotNull Flui public static void fluidInformation(List messages, @NotNull List fluidStacks, boolean prettyNbt) { if (fluidStacks.isEmpty()) return; - messages.add(new TextComponentString("Fluids:") - .setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE).setBold(true))); + messages.add(new TextComponentString("Fluids:").setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE).setBold( + true))); for (FluidStack stack : fluidStacks) { String copyText = IngredientHelper.asGroovyCode(stack, false, prettyNbt); @@ -67,8 +68,8 @@ public static void oredictInformation(List messages, ItemStack s String s; int[] ids = OreDictionary.getOreIDs(stack); if (ids.length > 0) { - messages.add(new TextComponentString("Ore Dictionaries:") - .setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE).setBold(true))); + messages.add(new TextComponentString("Ore Dictionaries:").setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE) + .setBold(true))); for (int id : ids) { String oreName = OreDictionary.getOreName(id); s = IngredientHelper.asGroovyCode(oreName, true); @@ -84,8 +85,9 @@ public static void tileInformation(List messages, TileEntity til String msg = NbtHelper.toGroovyCode(nbt, true, true); int trimLocation = StringUtils.ordinalIndexOf(msg, "\n", 8); - messages.add(new TextComponentString("Tile NBT:") - .setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE).setBold(true))); - messages.add(TextCopyable.string(copyText, trimLocation == -1 ? msg : msg.substring(0, trimLocation) + "\n\u00A7c(trimmed)").build()); + messages.add(new TextComponentString("Tile NBT:").setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE).setBold( + true))); + messages.add(TextCopyable.string(copyText, trimLocation == -1 ? msg : msg.substring(0, trimLocation) + + "\n\u00A7c(trimmed)").build()); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/command/GSMekanismCommand.java b/src/main/java/com/cleanroommc/groovyscript/command/GSMekanismCommand.java index 11b82fe6e..25dcc91e2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/GSMekanismCommand.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/GSMekanismCommand.java @@ -1,21 +1,24 @@ package com.cleanroommc.groovyscript.command; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.compat.mods.mekanism.Mekanism; -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasRegistry; -import mekanism.api.infuse.InfuseRegistry; -import mekanism.api.infuse.InfuseType; +import java.util.Collections; +import java.util.List; + import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.server.command.CommandTreeBase; + import org.jetbrains.annotations.NotNull; -import java.util.Collections; -import java.util.List; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.compat.mods.mekanism.Mekanism; + +import mekanism.api.gas.Gas; +import mekanism.api.gas.GasRegistry; +import mekanism.api.infuse.InfuseRegistry; +import mekanism.api.infuse.InfuseType; public class GSMekanismCommand extends CommandTreeBase { @@ -37,7 +40,8 @@ public GSMekanismCommand() { } @Override - public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, String @NotNull [] args) throws CommandException { + public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, String @NotNull [] args) + throws CommandException { if (!ModSupport.MEKANISM.isLoaded()) { sender.sendMessage(new TextComponentString(TextFormatting.RED + "Mekanism is not loaded!")); return; @@ -46,9 +50,7 @@ public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sen } @Override - public @NotNull String getName() { - return "mekanism"; - } + public @NotNull String getName() { return "mekanism"; } @Override public @NotNull String getUsage(@NotNull ICommandSender sender) { @@ -56,7 +58,5 @@ public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sen } @Override - public @NotNull List getAliases() { - return Collections.singletonList("mek"); - } + public @NotNull List getAliases() { return Collections.singletonList("mek"); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/command/PackmodeCommand.java b/src/main/java/com/cleanroommc/groovyscript/command/PackmodeCommand.java index 7b68a743d..b43a3d281 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/PackmodeCommand.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/PackmodeCommand.java @@ -1,25 +1,26 @@ package com.cleanroommc.groovyscript.command; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.network.NetworkHandler; -import com.cleanroommc.groovyscript.network.SReloadScripts; -import com.cleanroommc.groovyscript.packmode.Packmode; -import com.cleanroommc.groovyscript.packmode.PackmodeSaveData; -import io.sommers.packmode.PackModeCommand; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.TextComponentString; + import org.jetbrains.annotations.NotNull; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.network.NetworkHandler; +import com.cleanroommc.groovyscript.network.SReloadScripts; +import com.cleanroommc.groovyscript.packmode.Packmode; +import com.cleanroommc.groovyscript.packmode.PackmodeSaveData; + +import io.sommers.packmode.PackModeCommand; + public class PackmodeCommand extends CommandBase { @Override - public @NotNull String getName() { - return "packmode"; - } + public @NotNull String getName() { return "packmode"; } @Override public @NotNull String getUsage(@NotNull ICommandSender sender) { @@ -27,7 +28,8 @@ public class PackmodeCommand extends CommandBase { } @Override - public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, String @NotNull [] args) throws CommandException { + public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, String @NotNull [] args) + throws CommandException { if (GroovyScript.getRunConfig().isIntegratePackmodeMod()) { new PackModeCommand().execute(server, sender, args); return; diff --git a/src/main/java/com/cleanroommc/groovyscript/command/SimpleCommand.java b/src/main/java/com/cleanroommc/groovyscript/command/SimpleCommand.java index c7a9d82f7..234f2b27a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/SimpleCommand.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/SimpleCommand.java @@ -1,14 +1,15 @@ package com.cleanroommc.groovyscript.command; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.server.MinecraftServer; -import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import org.jetbrains.annotations.NotNull; public class SimpleCommand extends CommandBase { @@ -29,9 +30,7 @@ public SimpleCommand(String name, ICommand command, String... aliases) { } @Override - public @NotNull String getName() { - return name; - } + public @NotNull String getName() { return name; } @Override public @NotNull String getUsage(@NotNull ICommandSender sender) { @@ -39,7 +38,8 @@ public SimpleCommand(String name, ICommand command, String... aliases) { } @Override - public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, String @NotNull [] args) throws CommandException { + public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, String @NotNull [] args) + throws CommandException { command.execute(server, sender, args); } @@ -49,7 +49,5 @@ public interface ICommand { } @Override - public @NotNull List getAliases() { - return aliases; - } + public @NotNull List getAliases() { return aliases; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/command/TextCopyable.java b/src/main/java/com/cleanroommc/groovyscript/command/TextCopyable.java index 9ee1d124a..b05a7fb0e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/command/TextCopyable.java +++ b/src/main/java/com/cleanroommc/groovyscript/command/TextCopyable.java @@ -33,16 +33,14 @@ public Builder translate(Object... args) { public ITextComponent build() { Style style = new Style(); if (hoverMsg == null) { - hoverMsg = new TextComponentTranslation("groovyscript.command.copy.hover") - .appendSibling(new TextComponentString(" " + copyText).setStyle(new Style().setColor(TextFormatting.GOLD))); + hoverMsg = new TextComponentTranslation("groovyscript.command.copy.hover").appendSibling(new TextComponentString(" " + + copyText).setStyle(new Style().setColor(TextFormatting.GOLD))); } style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverMsg)); style.setClickEvent(CustomClickAction.makeCopyEvent(copyText)); ITextComponent textComponent; - if (args == null) - textComponent = new TextComponentString(msg); - else - textComponent = new TextComponentTranslation(msg, args); + if (args == null) textComponent = new TextComponentString(msg); + else textComponent = new TextComponentTranslation(msg, args); textComponent.setStyle(style); return textComponent; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/WarningScreen.java b/src/main/java/com/cleanroommc/groovyscript/compat/WarningScreen.java index 76d215d26..54bf346dc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/WarningScreen.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/WarningScreen.java @@ -1,5 +1,8 @@ package com.cleanroommc.groovyscript.compat; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiScreen; @@ -9,9 +12,6 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.ArrayList; -import java.util.List; - @SideOnly(Side.CLIENT) public class WarningScreen extends GuiScreen { @@ -29,7 +29,8 @@ public WarningScreen(List messages) { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); - drawString(this.fontRenderer, this.title, this.width / 2 - this.fontRenderer.getStringWidth(this.title) / 2, 14, 0xFFFFFFFF); + drawString(this.fontRenderer, this.title, this.width / 2 - this.fontRenderer.getStringWidth(this.title) / 2, 14, + 0xFFFFFFFF); int titleHeight = 14 + this.fontRenderer.FONT_HEIGHT; int x; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/content/Content.java b/src/main/java/com/cleanroommc/groovyscript/compat/content/Content.java index f254c465e..ddc95a293 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/content/Content.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/content/Content.java @@ -1,8 +1,5 @@ package com.cleanroommc.groovyscript.compat.content; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.registry.NamedRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; @@ -11,9 +8,14 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.registry.NamedRegistry; + public class Content extends NamedRegistry { public CreativeTabs defaultTab; @@ -59,7 +61,9 @@ public GroovyFluid.Builder createFluid(String name) { } public CreativeTabs createCreativeTab(String name, ItemStack icon) { - return new CreativeTabs(name) { + return new CreativeTabs(name) + { + @Override public @NotNull ItemStack createIcon() { return icon.copy(); @@ -71,11 +75,7 @@ public CreativeTabs createCreativeTab(String name, Item icon) { return createCreativeTab(name, new ItemStack(icon)); } - public CreativeTabs getDefaultTab() { - return defaultTab; - } + public CreativeTabs getDefaultTab() { return defaultTab; } - public void setDefaultCreativeTab(CreativeTabs tab) { - this.defaultTab = tab; - } + public void setDefaultCreativeTab(CreativeTabs tab) { this.defaultTab = tab; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyBlock.java b/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyBlock.java index 8cbb776b5..c51645191 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyBlock.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyBlock.java @@ -1,13 +1,8 @@ package com.cleanroommc.groovyscript.compat.content; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; -import com.cleanroommc.groovyscript.helper.JsonHelper; -import com.cleanroommc.groovyscript.sandbox.FileUtil; -import com.google.gson.JsonObject; -import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; +import java.io.File; +import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; @@ -20,11 +15,19 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.registries.IForgeRegistry; + import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.ApiStatus; -import java.io.File; -import java.util.Map; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; +import com.cleanroommc.groovyscript.helper.JsonHelper; +import com.cleanroommc.groovyscript.sandbox.FileUtil; +import com.google.gson.JsonObject; + +import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; public class GroovyBlock extends Block { @@ -46,14 +49,14 @@ public static void register(Block block, ItemBlock itemBlock) { ResourceLocation itemLoc = itemBlock.getRegistryName(); ResourceLocation blockLoc = block.getRegistryName(); if (itemLoc == null || !itemLoc.equals(blockLoc) || BLOCKS.containsKey(itemLoc.getPath())) { - GroovyLog.get().exception(new IllegalArgumentException("The registry name of the block and the item must be non-null and equal!")); + GroovyLog.get().exception(new IllegalArgumentException( + "The registry name of the block and the item must be non-null and equal!")); return; } BLOCKS.put(itemLoc.getPath(), Pair.of(block, itemBlock)); } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal public static void initItems(IForgeRegistry registry) { for (Pair pair : BLOCKS.values()) { registry.register(pair.getRight()); @@ -61,8 +64,7 @@ public static void initItems(IForgeRegistry registry) { } } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal public static void initBlocks(IForgeRegistry registry) { for (Pair pair : BLOCKS.values()) { Block block = pair.getLeft(); @@ -75,9 +77,7 @@ public static void initBlocks(IForgeRegistry registry) { initialised = true; } - @GroovyBlacklist - @ApiStatus.Internal - @SideOnly(Side.CLIENT) + @GroovyBlacklist @ApiStatus.Internal @SideOnly(Side.CLIENT) public static void registerModels() { for (Pair pair : BLOCKS.values()) { Item item = pair.getRight(); @@ -109,7 +109,9 @@ public GroovyBlock register() { } private static void checkBlockModel(ResourceLocation loc) { - File file = FileUtil.makeFile(GroovyScript.getResourcesFile().getPath(), loc.getNamespace(), "blockstates", loc.getPath() + ".json"); + File file = FileUtil.makeFile(GroovyScript.getResourcesFile().getPath(), loc.getNamespace(), "blockstates", loc + .getPath() + + ".json"); if (!file.exists()) { JsonObject stateJson = new JsonObject(); JsonObject variantsJson = new JsonObject(); @@ -120,7 +122,8 @@ private static void checkBlockModel(ResourceLocation loc) { JsonHelper.saveJson(file, stateJson); } - file = FileUtil.makeFile(GroovyScript.getResourcesFile().getPath(), loc.getNamespace(), "models", "block", loc.getPath() + ".json"); + file = FileUtil.makeFile(GroovyScript.getResourcesFile().getPath(), loc.getNamespace(), "models", "block", loc.getPath() + + ".json"); if (!file.exists()) { JsonObject modelJson = new JsonObject(); modelJson.addProperty("parent", "block/cube_all"); @@ -132,7 +135,9 @@ private static void checkBlockModel(ResourceLocation loc) { } private static void checkItemModel(ResourceLocation loc) { - File file = FileUtil.makeFile(GroovyScript.getResourcesFile().getPath(), loc.getNamespace(), "models", "item", loc.getPath() + ".json"); + File file = FileUtil.makeFile(GroovyScript.getResourcesFile().getPath(), loc.getNamespace(), "models", "item", loc + .getPath() + + ".json"); if (!file.exists()) { JsonObject modelJson = new JsonObject(); modelJson.addProperty("parent", loc.getNamespace() + ":block/" + loc.getPath()); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyFluid.java b/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyFluid.java index 6fe92ec5f..d469487d1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyFluid.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyFluid.java @@ -1,10 +1,9 @@ package com.cleanroommc.groovyscript.compat.content; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.helper.JsonHelper; -import com.cleanroommc.groovyscript.sandbox.FileUtil; -import com.google.gson.JsonObject; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.block.statemap.StateMap; @@ -17,12 +16,15 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.registries.IForgeRegistry; + import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import java.io.File; -import java.util.ArrayList; -import java.util.List; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.helper.JsonHelper; +import com.cleanroommc.groovyscript.sandbox.FileUtil; +import com.google.gson.JsonObject; public class GroovyFluid extends Fluid { @@ -34,8 +36,7 @@ public class GroovyFluid extends Fluid { private static final List fluidBlocks = new ArrayList<>(); private static final List fluids = new ArrayList<>(); - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal public static void initBlocks(IForgeRegistry registry) { for (BlockFluidBase block : fluidBlocks) { registry.register(block); @@ -43,9 +44,7 @@ public static void initBlocks(IForgeRegistry registry) { } } - @GroovyBlacklist - @ApiStatus.Internal - @SideOnly(Side.CLIENT) + @GroovyBlacklist @ApiStatus.Internal @SideOnly(Side.CLIENT) public static void initTextures(TextureMap map) { for (GroovyFluid fluid : fluids) { map.registerSprite(fluid.flowing); @@ -56,21 +55,22 @@ public static void initTextures(TextureMap map) { } } - @GroovyBlacklist - @ApiStatus.Internal - @SideOnly(Side.CLIENT) + @GroovyBlacklist @ApiStatus.Internal @SideOnly(Side.CLIENT) public static void registerModels() { for (BlockFluidBase block : fluidBlocks) { ModelLoader.setCustomStateMapper(block, new StateMap.Builder().ignore(BlockFluidClassic.LEVEL).build()); } } - public GroovyFluid(String fluidName, ResourceLocation still, ResourceLocation flowing, @Nullable ResourceLocation overlay, int color) { + public GroovyFluid(String fluidName, ResourceLocation still, ResourceLocation flowing, @Nullable ResourceLocation overlay, + int color) { super(fluidName, still, flowing, overlay, color); } private static void checkBlockState(ResourceLocation loc) { - File file = FileUtil.makeFile(GroovyScript.getResourcesFile().getPath(), loc.getNamespace(), "blockstates", loc.getPath() + ".json"); + File file = FileUtil.makeFile(GroovyScript.getResourcesFile().getPath(), loc.getNamespace(), "blockstates", loc + .getPath() + + ".json"); if (!file.exists()) { JsonObject stateJson = new JsonObject(); stateJson.addProperty("forge_marker", 1); @@ -206,22 +206,25 @@ public Builder noBlock() { public Fluid register() { this.color |= 0xFF << 24; String mod = GroovyScript.getRunConfig().getPackId(); - Fluid fluid = new GroovyFluid(this.name, this.still, this.flowing, this.overlay, this.color) - .setFillSound(this.fillSound) - .setEmptySound(this.emptySound) - .setLuminosity(this.luminosity) - .setDensity(this.density) - .setTemperature(this.temperature) - .setViscosity(this.viscosity) - .setGaseous(this.isGaseous) - .setRarity(this.rarity) - .setUnlocalizedName(mod + "." + this.name + ".name"); + Fluid fluid = new GroovyFluid(this.name, this.still, this.flowing, this.overlay, this.color).setFillSound( + this.fillSound) + .setEmptySound(this.emptySound) + .setLuminosity(this.luminosity) + .setDensity(this.density) + .setTemperature(this.temperature) + .setViscosity(this.viscosity) + .setGaseous(this.isGaseous) + .setRarity(this.rarity) + .setUnlocalizedName(mod + + "." + + this.name + + ".name"); FluidRegistry.registerFluid(fluid); FluidRegistry.addBucketForFluid(fluid); if (this.createBlock) { - BlockFluidBase block = this.finiteFluidBlock ? - new BlockFluidFinite(fluid, this.material) : - new BlockFluidClassic(fluid, this.material); + BlockFluidBase block = this.finiteFluidBlock ? new BlockFluidFinite(fluid, this.material) : new BlockFluidClassic( + fluid, + this.material); block.setRegistryName(new ResourceLocation(mod, this.name)); fluidBlocks.add(block); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyItem.java b/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyItem.java index cba284d93..ad6686b09 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyItem.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyItem.java @@ -1,13 +1,8 @@ package com.cleanroommc.groovyscript.compat.content; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; -import com.cleanroommc.groovyscript.helper.JsonHelper; -import com.cleanroommc.groovyscript.sandbox.FileUtil; -import com.google.gson.JsonObject; -import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; +import java.io.File; +import java.util.Map; + import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; @@ -16,11 +11,19 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.IRarity; import net.minecraftforge.registries.IForgeRegistry; + import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import java.io.File; -import java.util.Map; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; +import com.cleanroommc.groovyscript.helper.JsonHelper; +import com.cleanroommc.groovyscript.sandbox.FileUtil; +import com.google.gson.JsonObject; + +import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; public class GroovyItem extends Item { @@ -41,14 +44,14 @@ public static void registerItem(Item item) { } ResourceLocation key = item.getRegistryName(); if (key == null || ITEMS.containsKey(key.getPath())) { - GroovyLog.get().exception(new IllegalArgumentException("The registry name of the item must be non-null and not match an already registered item!")); + GroovyLog.get().exception(new IllegalArgumentException( + "The registry name of the item must be non-null and not match an already registered item!")); return; } ITEMS.put(key.getPath(), item); } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal public static void registerModels() { for (Item item : ITEMS.values()) { ResourceLocation rl = item.getRegistryName(); @@ -58,8 +61,7 @@ public static void registerModels() { } } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal public static void initItems(IForgeRegistry registry) { for (Item item : ITEMS.values()) { registry.register(item); @@ -103,9 +105,7 @@ public GroovyItem register() { } @Override - public int getItemEnchantability() { - return this.enchantability; - } + public int getItemEnchantability() { return this.enchantability; } @Override public boolean hasEffect(@NotNull ItemStack stack) { @@ -118,7 +118,9 @@ public boolean hasEffect(@NotNull ItemStack stack) { } private static void checkModelFile(ResourceLocation loc) { - File modelFile = FileUtil.makeFile(GroovyScript.getResourcesFile().getPath(), loc.getNamespace(), "models", "item", loc.getPath() + ".json"); + File modelFile = FileUtil.makeFile(GroovyScript.getResourcesFile().getPath(), loc.getNamespace(), "models", "item", loc + .getPath() + + ".json"); if (!modelFile.exists()) { JsonObject modelJson = new JsonObject(); modelJson.addProperty("parent", "item/generated"); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyResourcePack.java b/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyResourcePack.java index 98060239a..1d2f07e81 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyResourcePack.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/content/GroovyResourcePack.java @@ -1,15 +1,17 @@ package com.cleanroommc.groovyscript.compat.content; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.sandbox.FileUtil; +import java.awt.image.BufferedImage; +import java.io.IOException; + import net.minecraft.client.resources.FolderResourcePack; import net.minecraft.client.resources.data.IMetadataSection; import net.minecraft.client.resources.data.MetadataSerializer; + import org.jetbrains.annotations.NotNull; -import java.awt.image.BufferedImage; -import java.io.IOException; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.sandbox.FileUtil; public class GroovyResourcePack extends FolderResourcePack { @@ -27,17 +29,14 @@ public GroovyResourcePack() { } @Override - public @NotNull BufferedImage getPackImage() throws IOException { - return null; - } + public @NotNull BufferedImage getPackImage() throws IOException { return null; } @Override - public T getPackMetadata(@NotNull MetadataSerializer metadataSerializer, @NotNull String metadataSectionName) throws IOException { + public T getPackMetadata(@NotNull MetadataSerializer metadataSerializer, + @NotNull String metadataSectionName) throws IOException { return null; } @Override - public @NotNull String getPackName() { - return "GroovyScriptResources"; - } -} \ No newline at end of file + public @NotNull String getPackName() { return "GroovyScriptResources"; } +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java index 36d68de9b..c77d064e6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java @@ -1,5 +1,17 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.Optional; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,18 +20,9 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.cleanroommc.groovyscript.sandbox.ClosureHelper; + import groovy.lang.Closure; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.Optional; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; public class Burning extends VirtualizedRegistry { @@ -27,8 +30,7 @@ public class Burning extends VirtualizedRegistry { private final List burningRecipes = new ArrayList<>(); - @Optional.Method(modid = "jei") - @GroovyBlacklist + @Optional.Method(modid = "jei") @GroovyBlacklist public List getRecipeWrappers() { return this.burningRecipes.stream().map(BurningRecipeCategory.RecipeWrapper::new).collect(Collectors.toList()); } @@ -76,20 +78,15 @@ public BurningRecipe(IIngredient input, ItemStack output, int ticks, Closure startCondition) { } @Override - public String getErrorMsg() { - return "Error adding in world burning recipe"; - } + public String getErrorMsg() { return "Error adding in world burning recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -126,7 +121,8 @@ public void validate(GroovyLog.Msg msg) { @Override public @Nullable Burning.BurningRecipe register() { if (!validate()) return null; - BurningRecipe burningRecipe = new BurningRecipe(this.input.get(0), this.output.get(0), this.ticks, this.startCondition); + BurningRecipe burningRecipe = new BurningRecipe(this.input.get(0), this.output.get(0), this.ticks, + this.startCondition); VanillaModule.inWorldCrafting.burning.add(burningRecipe); return burningRecipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Explosion.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Explosion.java index c933057fe..be884021c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Explosion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Explosion.java @@ -1,5 +1,16 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.MathHelper; +import net.minecraftforge.fml.common.Optional; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; @@ -9,23 +20,14 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import groovy.lang.Closure; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; -import net.minecraftforge.fml.common.Optional; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; +import groovy.lang.Closure; public class Explosion extends VirtualizedRegistry { private final List explosionRecipes = new ArrayList<>(); - @Optional.Method(modid = "jei") - @GroovyBlacklist + @Optional.Method(modid = "jei") @GroovyBlacklist public List getRecipeWrappers() { return this.explosionRecipes.stream().map(ExplosionRecipeCategory.RecipeWrapper::new).collect(Collectors.toList()); } @@ -71,21 +73,16 @@ public ExplosionRecipe(IIngredient input, ItemStack output, float chance, Closur this.startCondition = startCondition; } - public IIngredient getInput() { - return input; - } + public IIngredient getInput() { return input; } - public ItemStack getOutput() { - return output; - } + public ItemStack getOutput() { return output; } - public float getChance() { - return chance; - } + public float getChance() { return chance; } private boolean tryRecipe(EntityItem entityItem, ItemStack itemStack) { if (!this.input.test(itemStack)) return false; - if (this.startCondition != null && !ClosureHelper.call(true, this.startCondition, entityItem, itemStack)) return false; + if (this.startCondition != null && !ClosureHelper.call(true, this.startCondition, entityItem, itemStack)) + return false; int count = itemStack.getCount(); int amountToReplace; if (this.chance >= 1.0f) { @@ -105,7 +102,8 @@ private boolean tryRecipe(EntityItem entityItem, ItemStack itemStack) { } else { itemStack.shrink(amountToReplace); entityItem.setItem(itemStack); - EntityItem newEntityItem = new EntityItem(entityItem.world, entityItem.posX, entityItem.posY, entityItem.posZ, newStack); + EntityItem newEntityItem = new EntityItem(entityItem.world, entityItem.posX, entityItem.posY, entityItem.posZ, + newStack); entityItem.world.spawnEntity(newEntityItem); } return true; @@ -128,9 +126,7 @@ public RecipeBuilder startCondition(Closure startCondition) { } @Override - public String getErrorMsg() { - return "Error adding in world explosion recipe"; - } + public String getErrorMsg() { return "Error adding in world explosion recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -145,7 +141,8 @@ public void validate(GroovyLog.Msg msg) { @Override public @Nullable Explosion.ExplosionRecipe register() { if (!validate()) return null; - ExplosionRecipe explosionRecipe = new ExplosionRecipe(this.input.get(0), this.output.get(0), this.chance, this.startCondition); + ExplosionRecipe explosionRecipe = new ExplosionRecipe(this.input.get(0), this.output.get(0), this.chance, + this.startCondition); VanillaModule.inWorldCrafting.explosion.add(explosionRecipe); return explosionRecipe; } @@ -155,9 +152,7 @@ public void validate(GroovyLog.Msg msg) { public void findAndRunRecipe(EntityItem entityItem) { ItemStack itemStack = entityItem.getItem(); for (ExplosionRecipe explosionRecipe : this.explosionRecipes) { - if (explosionRecipe.tryRecipe(entityItem, itemStack)) { - return; - } + if (explosionRecipe.tryRecipe(entityItem, itemStack)) { return; } } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidRecipe.java index 7f521d395..45c86da5d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidRecipe.java @@ -1,18 +1,12 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import groovy.lang.Closure; -import it.unimi.dsi.fastutil.floats.FloatArrayList; -import it.unimi.dsi.fastutil.floats.FloatList; -import it.unimi.dsi.fastutil.ints.IntOpenHashSet; -import it.unimi.dsi.fastutil.ints.IntSet; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import mezz.jei.api.ingredients.IIngredients; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; +import java.util.function.Predicate; + import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.block.material.Material; @@ -29,14 +23,23 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fml.common.Optional; + import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Consumer; -import java.util.function.Predicate; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.sandbox.ClosureHelper; + +import groovy.lang.Closure; +import it.unimi.dsi.fastutil.floats.FloatArrayList; +import it.unimi.dsi.fastutil.floats.FloatList; +import it.unimi.dsi.fastutil.ints.IntOpenHashSet; +import it.unimi.dsi.fastutil.ints.IntSet; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import mezz.jei.api.ingredients.IIngredients; public abstract class FluidRecipe { @@ -50,9 +53,7 @@ public static void add(FluidRecipe fluidRecipe) { public static boolean remove(FluidRecipe fluidRecipe) { List fluidRecipes1 = fluidRecipes.get(fluidRecipe.input.getName()); - if (fluidRecipes1 != null) { - return fluidRecipes1.remove(fluidRecipe); - } + if (fluidRecipes1 != null) { return fluidRecipes1.remove(fluidRecipe); } return false; } @@ -66,7 +67,8 @@ public static List findRecipesOfType(Class clazz) return recipes; } - public static boolean removeIf(Fluid fluid, Predicate fluidRecipePredicate, Consumer removedConsumer) { + public static boolean removeIf(Fluid fluid, Predicate fluidRecipePredicate, + Consumer removedConsumer) { List recipes = fluidRecipes.get(fluid.getName()); return recipes != null && recipes.removeIf(fluidRecipe -> { if (fluidRecipePredicate.test(fluidRecipe)) { @@ -106,7 +108,8 @@ public static void forEach(Consumer consumer) { public static boolean findAndRunRecipe(Fluid fluid, World world, BlockPos pos, IBlockState blockState) { List candidates = fluidRecipes.get(fluid.getName()); if (candidates == null || candidates.isEmpty()) return false; - AxisAlignedBB aabb = new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1); + AxisAlignedBB aabb = new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos + .getZ() + 1); // get all items in the fluid block space List entitiesInFluid = world.getEntitiesWithinAABB(EntityItem.class, aabb, Entity::isEntityAlive); List itemsInFluid = new ArrayList<>(); @@ -115,9 +118,7 @@ public static boolean findAndRunRecipe(Fluid fluid, World world, BlockPos pos, I } // search for a recipe using those items for (FluidRecipe recipe : candidates) { - if (recipe.tryRecipe(world, pos, itemsInFluid)) { - return true; - } + if (recipe.tryRecipe(world, pos, itemsInFluid)) { return true; } } return false; } @@ -128,7 +129,8 @@ public static boolean findAndRunRecipe(Fluid fluid, World world, BlockPos pos, I private final Closure startCondition; private final Closure afterRecipe; - public FluidRecipe(Fluid input, IIngredient[] itemInputs, float[] itemConsumeChance, Closure startCondition, Closure afterRecipe) { + public FluidRecipe(Fluid input, IIngredient[] itemInputs, float[] itemConsumeChance, Closure startCondition, + Closure afterRecipe) { this.input = input; this.itemInputs = itemInputs; this.itemConsumeChance = itemConsumeChance; @@ -136,17 +138,11 @@ public FluidRecipe(Fluid input, IIngredient[] itemInputs, float[] itemConsumeCha this.afterRecipe = afterRecipe; } - public Fluid getFluidInput() { - return input; - } + public Fluid getFluidInput() { return input; } - public IIngredient[] getItemInputs() { - return itemInputs; - } + public IIngredient[] getItemInputs() { return itemInputs; } - public float[] getItemConsumeChance() { - return itemConsumeChance; - } + public float[] getItemConsumeChance() { return itemConsumeChance; } @Optional.Method(modid = "jei") public abstract void setJeiOutput(IIngredients ingredients); @@ -206,9 +202,7 @@ private boolean tryRecipe(World world, BlockPos pos, List itemsIn } return false; } - if (this.startCondition != null && !ClosureHelper.call(true, this.startCondition, world, pos)) { - return false; - } + if (this.startCondition != null && !ClosureHelper.call(true, this.startCondition, world, pos)) { return false; } // kill all items with the before calculated amount itemsInFluid.forEach(ItemContainer::killItems); // handle the output of the recipe @@ -231,16 +225,10 @@ private boolean tryRecipe(World world, BlockPos pos, List itemsIn public static Fluid getFluid(IBlockState state) { Block block = state.getBlock(); - if (block instanceof IFluidBlock) { - return ((IFluidBlock) block).getFluid(); - } + if (block instanceof IFluidBlock) { return ((IFluidBlock) block).getFluid(); } if (block instanceof BlockLiquid) { - if (state.getMaterial() == Material.WATER) { - return FluidRegistry.WATER; - } - if (state.getMaterial() == Material.LAVA) { - return FluidRegistry.LAVA; - } + if (state.getMaterial() == Material.WATER) { return FluidRegistry.WATER; } + if (state.getMaterial() == Material.LAVA) { return FluidRegistry.LAVA; } } return null; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToBlock.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToBlock.java index c9d9ef08c..0d3984892 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToBlock.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToBlock.java @@ -1,22 +1,25 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import groovy.lang.Closure; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; public class FluidToBlock extends VirtualizedRegistry { @@ -41,42 +44,41 @@ public boolean remove(Recipe recipe) { public boolean removeByInput(FluidStack fluid) { if (IngredientHelper.isEmpty(fluid)) { - GroovyLog.msg("Error removing in world fluid to block recipe") - .add("input fluid must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing in world fluid to block recipe").add("input fluid must not be empty").error().post(); return false; } - if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class, fluidRecipe -> addBackup((Recipe) fluidRecipe))) { - GroovyLog.msg("Error removing in world fluid to block recipe") - .add("no recipes found for {}", fluid.getFluid().getName()) - .error() - .post(); + if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class, + fluidRecipe -> addBackup((Recipe) fluidRecipe))) { + GroovyLog.msg("Error removing in world fluid to block recipe").add("no recipes found for {}", fluid.getFluid() + .getName()).error() + .post(); return false; } return true; } public boolean removeByInput(FluidStack fluid, ItemStack... input) { - if (GroovyLog.msg("Error removing in world fluid to block recipe") - .add(IngredientHelper.isEmpty(fluid), () -> "input fluid must not be empty") - .add(IngredientHelper.isEmpty(input), () -> "input ingredients must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing in world fluid to block recipe").add(IngredientHelper.isEmpty(fluid), + () -> "input fluid must not be empty").add( + IngredientHelper.isEmpty(input), + () -> "input ingredients must not be empty") + .error().postIfNotEmpty()) { return false; } - if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class && fluidRecipe.matches(input), fluidRecipe -> addBackup((Recipe) fluidRecipe))) { - GroovyLog.msg("Error removing in world fluid to block recipe") - .add("no recipes found for {}", fluid.getFluid().getName()) - .error() - .post(); + if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class && fluidRecipe.matches( + input), + fluidRecipe -> addBackup((Recipe) fluidRecipe))) { + GroovyLog.msg("Error removing in world fluid to block recipe").add("no recipes found for {}", fluid.getFluid() + .getName()).error() + .post(); return false; } return true; } public boolean removeAll() { - return FluidRecipe.removeIf(fluidRecipe -> fluidRecipe.getClass() == Recipe.class, fluidRecipe -> addBackup((Recipe) fluidRecipe)); + return FluidRecipe.removeIf(fluidRecipe -> fluidRecipe.getClass() == Recipe.class, fluidRecipe -> addBackup( + (Recipe) fluidRecipe)); } public RecipeBuilder recipeBuilder() { @@ -91,18 +93,18 @@ public static class Recipe extends FluidRecipe { private final IBlockState output; - public Recipe(Fluid input, IIngredient[] itemInputs, float[] itemConsumeChance, Closure startCondition, Closure afterRecipe, IBlockState output) { + public Recipe(Fluid input, IIngredient[] itemInputs, float[] itemConsumeChance, Closure startCondition, + Closure afterRecipe, IBlockState output) { super(input, itemInputs, itemConsumeChance, startCondition, afterRecipe); this.output = output; } - public IBlockState getOutput() { - return output; - } + public IBlockState getOutput() { return output; } @Override public void setJeiOutput(IIngredients ingredients) { - ingredients.setOutput(VanillaTypes.ITEM, new ItemStack(getOutput().getBlock(), 1, getOutput().getBlock().getMetaFromState(getOutput()))); + ingredients.setOutput(VanillaTypes.ITEM, new ItemStack(getOutput().getBlock(), 1, getOutput().getBlock() + .getMetaFromState(getOutput()))); } @Override @@ -125,9 +127,7 @@ public RecipeBuilder output(Block block) { } @Override - public String getErrorMsg() { - return "Error adding in world fluid to block recipe"; - } + public String getErrorMsg() { return "Error adding in world fluid to block recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -139,7 +139,8 @@ public void validate(GroovyLog.Msg msg) { @Override public @Nullable FluidToBlock.Recipe register() { - Recipe recipe = new Recipe(this.fluidInput.get(0).getFluid(), this.input.toArray(new IIngredient[0]), this.chances.toFloatArray(), + Recipe recipe = new Recipe(this.fluidInput.get(0).getFluid(), this.input.toArray(new IIngredient[0]), this.chances + .toFloatArray(), this.startCondition, this.afterRecipe, this.outputBlock); VanillaModule.inWorldCrafting.fluidToBlock.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToFluid.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToFluid.java index 64b4bf1ae..036b10b52 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToFluid.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToFluid.java @@ -1,20 +1,23 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import groovy.lang.Closure; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; public class FluidToFluid extends VirtualizedRegistry { @@ -39,42 +42,41 @@ public boolean remove(Recipe recipe) { public boolean removeByInput(FluidStack fluid) { if (IngredientHelper.isEmpty(fluid)) { - GroovyLog.msg("Error removing in world fluid to fluid recipe") - .add("input fluid must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing in world fluid to fluid recipe").add("input fluid must not be empty").error().post(); return false; } - if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class, fluidRecipe -> addBackup((Recipe) fluidRecipe))) { - GroovyLog.msg("Error removing in world fluid to fluid recipe") - .add("no recipes found for {}", fluid.getFluid().getName()) - .error() - .post(); + if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class, + fluidRecipe -> addBackup((Recipe) fluidRecipe))) { + GroovyLog.msg("Error removing in world fluid to fluid recipe").add("no recipes found for {}", fluid.getFluid() + .getName()).error() + .post(); return false; } return true; } public boolean removeByInput(FluidStack fluid, ItemStack... input) { - if (GroovyLog.msg("Error removing in world fluid to fluid recipe") - .add(IngredientHelper.isEmpty(fluid), () -> "input fluid must not be empty") - .add(IngredientHelper.isEmpty(input), () -> "input ingredients must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing in world fluid to fluid recipe").add(IngredientHelper.isEmpty(fluid), + () -> "input fluid must not be empty").add( + IngredientHelper.isEmpty(input), + () -> "input ingredients must not be empty") + .error().postIfNotEmpty()) { return false; } - if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class && fluidRecipe.matches(input), fluidRecipe -> addBackup((Recipe) fluidRecipe))) { - GroovyLog.msg("Error removing in world fluid to fluid recipe") - .add("no recipes found for {}", fluid.getFluid().getName()) - .error() - .post(); + if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class && fluidRecipe.matches( + input), + fluidRecipe -> addBackup((Recipe) fluidRecipe))) { + GroovyLog.msg("Error removing in world fluid to fluid recipe").add("no recipes found for {}", fluid.getFluid() + .getName()).error() + .post(); return false; } return true; } public boolean removeAll() { - return FluidRecipe.removeIf(fluidRecipe -> fluidRecipe.getClass() == Recipe.class, fluidRecipe -> addBackup((Recipe) fluidRecipe)); + return FluidRecipe.removeIf(fluidRecipe -> fluidRecipe.getClass() == Recipe.class, fluidRecipe -> addBackup( + (Recipe) fluidRecipe)); } public RecipeBuilder recipeBuilder() { @@ -89,14 +91,13 @@ public static class Recipe extends FluidRecipe { private final Fluid output; - public Recipe(Fluid input, IIngredient[] itemInputs, float[] itemConsumeChance, Closure startCondition, Closure afterRecipe, Fluid output) { + public Recipe(Fluid input, IIngredient[] itemInputs, float[] itemConsumeChance, Closure startCondition, + Closure afterRecipe, Fluid output) { super(input, itemInputs, itemConsumeChance, startCondition, afterRecipe); this.output = output; } - public Fluid getOutput() { - return output; - } + public Fluid getOutput() { return output; } @Override public void setJeiOutput(IIngredients ingredients) { @@ -112,9 +113,7 @@ public void handleRecipeResult(World world, BlockPos pos) { public static class RecipeBuilder extends FluidRecipe.RecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding in world fluid to fluid recipe"; - } + public String getErrorMsg() { return "Error adding in world fluid to fluid recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -125,7 +124,8 @@ public void validate(GroovyLog.Msg msg) { @Override public @Nullable Recipe register() { - Recipe recipe = new Recipe(this.fluidInput.get(0).getFluid(), this.input.toArray(new IIngredient[0]), this.chances.toFloatArray(), + Recipe recipe = new Recipe(this.fluidInput.get(0).getFluid(), this.input.toArray(new IIngredient[0]), this.chances + .toFloatArray(), this.startCondition, this.afterRecipe, this.fluidOutput.get(0).getFluid()); VanillaModule.inWorldCrafting.fluidToFluid.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToItem.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToItem.java index 8c51d2b26..bfad67b3b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToItem.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/FluidToItem.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -7,16 +16,10 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import groovy.lang.Closure; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; public class FluidToItem extends VirtualizedRegistry { @@ -41,42 +44,41 @@ public boolean remove(Recipe recipe) { public boolean removeByInput(FluidStack fluid) { if (IngredientHelper.isEmpty(fluid)) { - GroovyLog.msg("Error removing in world fluid to item recipe") - .add("input fluid must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing in world fluid to item recipe").add("input fluid must not be empty").error().post(); return false; } - if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class, fluidRecipe -> addBackup((Recipe) fluidRecipe))) { - GroovyLog.msg("Error removing in world fluid to item recipe") - .add("no recipes found for {}", fluid.getFluid().getName()) - .error() - .post(); + if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class, + fluidRecipe -> addBackup((Recipe) fluidRecipe))) { + GroovyLog.msg("Error removing in world fluid to item recipe").add("no recipes found for {}", fluid.getFluid() + .getName()).error() + .post(); return false; } return true; } public boolean removeByInput(FluidStack fluid, ItemStack... input) { - if (GroovyLog.msg("Error removing in world fluid to item recipe") - .add(IngredientHelper.isEmpty(fluid), () -> "input fluid must not be empty") - .add(IngredientHelper.isEmpty(input), () -> "input ingredients must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing in world fluid to item recipe").add(IngredientHelper.isEmpty(fluid), + () -> "input fluid must not be empty").add( + IngredientHelper.isEmpty(input), + () -> "input ingredients must not be empty") + .error().postIfNotEmpty()) { return false; } - if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class && fluidRecipe.matches(input), fluidRecipe -> addBackup((Recipe) fluidRecipe))) { - GroovyLog.msg("Error removing in world fluid to item recipe") - .add("no recipes found for {}", fluid.getFluid().getName()) - .error() - .post(); + if (!FluidRecipe.removeIf(fluid.getFluid(), fluidRecipe -> fluidRecipe.getClass() == Recipe.class && fluidRecipe.matches( + input), + fluidRecipe -> addBackup((Recipe) fluidRecipe))) { + GroovyLog.msg("Error removing in world fluid to item recipe").add("no recipes found for {}", fluid.getFluid() + .getName()).error() + .post(); return false; } return true; } public boolean removeAll() { - return FluidRecipe.removeIf(fluidRecipe -> fluidRecipe.getClass() == Recipe.class, fluidRecipe -> addBackup((Recipe) fluidRecipe)); + return FluidRecipe.removeIf(fluidRecipe -> fluidRecipe.getClass() == Recipe.class, fluidRecipe -> addBackup( + (Recipe) fluidRecipe)); } public RecipeBuilder recipeBuilder() { @@ -92,19 +94,16 @@ public static class Recipe extends FluidRecipe { private final ItemStack output; private final float fluidConsumptionChance; - public Recipe(Fluid input, IIngredient[] itemInputs, float[] itemConsumeChance, Closure startCondition, Closure afterRecipe, ItemStack output, float fluidConsumptionChance) { + public Recipe(Fluid input, IIngredient[] itemInputs, float[] itemConsumeChance, Closure startCondition, + Closure afterRecipe, ItemStack output, float fluidConsumptionChance) { super(input, itemInputs, itemConsumeChance, startCondition, afterRecipe); this.output = output; this.fluidConsumptionChance = fluidConsumptionChance; } - public ItemStack getOutput() { - return output; - } + public ItemStack getOutput() { return output; } - public float getFluidConsumptionChance() { - return fluidConsumptionChance; - } + public float getFluidConsumptionChance() { return fluidConsumptionChance; } @Override public void setJeiOutput(IIngredients ingredients) { @@ -135,9 +134,7 @@ public RecipeBuilder fluidConsumptionChance(float fluidConsumptionChance) { } @Override - public String getErrorMsg() { - return "Error adding in world fluid to item recipe"; - } + public String getErrorMsg() { return "Error adding in world fluid to item recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -149,7 +146,8 @@ public void validate(GroovyLog.Msg msg) { @Override public @Nullable FluidToItem.Recipe register() { - Recipe recipe = new Recipe(this.fluidInput.get(0).getFluid(), this.input.toArray(new IIngredient[0]), this.chances.toFloatArray(), + Recipe recipe = new Recipe(this.fluidInput.get(0).getFluid(), this.input.toArray(new IIngredient[0]), this.chances + .toFloatArray(), this.startCondition, this.afterRecipe, this.output.get(0), this.fluidConsumptionChance); VanillaModule.inWorldCrafting.fluidToItem.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/InWorldCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/InWorldCrafting.java index ed0623cef..0cd1293e1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/InWorldCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/InWorldCrafting.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.IScriptReloadable; -import com.cleanroommc.groovyscript.registry.NamedRegistry; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.IScriptReloadable; +import com.cleanroommc.groovyscript.registry.NamedRegistry; + public class InWorldCrafting extends NamedRegistry implements IScriptReloadable { public final FluidToFluid fluidToFluid = new FluidToFluid(); @@ -17,8 +18,7 @@ public class InWorldCrafting extends NamedRegistry implements IScriptReloadable public final Burning burning = new Burning(); public final PistonPush pistonPush = new PistonPush(); - @GroovyBlacklist - @Override + @GroovyBlacklist @Override public void onReload() { this.fluidToFluid.onReload(); this.fluidToItem.onReload(); @@ -28,8 +28,7 @@ public void onReload() { this.pistonPush.onReload(); } - @GroovyBlacklist - @Override + @GroovyBlacklist @Override public void afterScriptLoad() { this.fluidToFluid.afterScriptLoad(); this.fluidToItem.afterScriptLoad(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/PistonPush.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/PistonPush.java index 57d447070..db177795d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/PistonPush.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/PistonPush.java @@ -1,5 +1,18 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.MathHelper; +import net.minecraftforge.fml.common.Optional; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,25 +21,14 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import groovy.lang.Closure; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; -import net.minecraftforge.fml.common.Optional; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; -import java.util.stream.Collectors; +import groovy.lang.Closure; public class PistonPush extends VirtualizedRegistry { private final List pistonPushRecipes = new ArrayList<>(); - @Optional.Method(modid = "jei") - @GroovyBlacklist + @Optional.Method(modid = "jei") @GroovyBlacklist public List getRecipeWrappers() { return this.pistonPushRecipes.stream().map(PistonPushRecipeCategory.RecipeWrapper::new).collect(Collectors.toList()); } @@ -62,7 +64,8 @@ public static class PistonPushRecipe { private final int minHarvestLevel; private final Closure startCondition; - public PistonPushRecipe(IIngredient input, ItemStack output, int maxConversionsPerPush, int minHarvestLevel, Closure startCondition) { + public PistonPushRecipe(IIngredient input, ItemStack output, int maxConversionsPerPush, int minHarvestLevel, + Closure startCondition) { this.input = input; this.output = output; this.maxConversionsPerPush = maxConversionsPerPush; @@ -70,32 +73,28 @@ public PistonPushRecipe(IIngredient input, ItemStack output, int maxConversionsP this.startCondition = startCondition; } - public IIngredient getInput() { - return input; - } + public IIngredient getInput() { return input; } - public ItemStack getOutput() { - return output; - } + public ItemStack getOutput() { return output; } - public int getMaxConversionsPerPush() { - return maxConversionsPerPush; - } + public int getMaxConversionsPerPush() { return maxConversionsPerPush; } - public int getMinHarvestLevel() { - return minHarvestLevel; - } + public int getMinHarvestLevel() { return minHarvestLevel; } - private boolean tryRecipe(Consumer entitySpawner, EntityItem entityItem, ItemStack itemStack, IBlockState pushingAgainst) { + private boolean tryRecipe(Consumer entitySpawner, EntityItem entityItem, ItemStack itemStack, + IBlockState pushingAgainst) { if (!this.input.test(itemStack)) return false; - if (this.startCondition != null && !ClosureHelper.call(true, this.startCondition, entityItem, itemStack, pushingAgainst)) return false; - if (this.minHarvestLevel >= 0 && this.minHarvestLevel > pushingAgainst.getBlock().getHarvestLevel(pushingAgainst)) return false; + if (this.startCondition != null && !ClosureHelper.call(true, this.startCondition, entityItem, itemStack, + pushingAgainst)) return false; + if (this.minHarvestLevel >= 0 && this.minHarvestLevel > pushingAgainst.getBlock().getHarvestLevel(pushingAgainst)) + return false; ItemStack newStack = this.output.copy(); if (this.maxConversionsPerPush < itemStack.getCount()) { itemStack.shrink(this.maxConversionsPerPush); newStack.setCount(this.maxConversionsPerPush); entityItem.setItem(itemStack); - entitySpawner.accept(new EntityItem(entityItem.world, entityItem.posX, entityItem.posY, entityItem.posZ, newStack)); + entitySpawner.accept(new EntityItem(entityItem.world, entityItem.posX, entityItem.posY, entityItem.posZ, + newStack)); } else { newStack.setCount(itemStack.getCount()); entityItem.setItem(newStack); @@ -126,9 +125,7 @@ public RecipeBuilder startCondition(Closure beforeRecipe) { } @Override - public String getErrorMsg() { - return "Error adding in world piston push recipe"; - } + public String getErrorMsg() { return "Error adding in world piston push recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -143,7 +140,9 @@ public void validate(GroovyLog.Msg msg) { @Override public @Nullable PistonPush.PistonPushRecipe register() { if (!validate()) return null; - PistonPushRecipe pistonPushRecipe = new PistonPushRecipe(this.input.get(0), this.output.get(0), this.maxConversionsPerPush, this.minHarvestLevel, this.startCondition); + PistonPushRecipe pistonPushRecipe = new PistonPushRecipe(this.input.get(0), this.output.get(0), + this.maxConversionsPerPush, this.minHarvestLevel, + this.startCondition); VanillaModule.inWorldCrafting.pistonPush.add(pistonPushRecipe); return null; } @@ -153,9 +152,7 @@ public void validate(GroovyLog.Msg msg) { public void findAndRunRecipe(Consumer entitySpawner, EntityItem entityItem, IBlockState pushingAgainst) { ItemStack itemStack = entityItem.getItem(); for (PistonPushRecipe pistonPushRecipe : this.pistonPushRecipes) { - if (pistonPushRecipe.tryRecipe(entitySpawner, entityItem, itemStack, pushingAgainst)) { - return; - } + if (pistonPushRecipe.tryRecipe(entitySpawner, entityItem, itemStack, pushingAgainst)) { return; } } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/BurningRecipeCategory.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/BurningRecipeCategory.java index f18d58972..b4d4ad636 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/BurningRecipeCategory.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/BurningRecipeCategory.java @@ -1,24 +1,27 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting.jei; +import java.util.Arrays; +import java.util.Collections; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.compat.inworldcrafting.Burning; import com.cleanroommc.groovyscript.compat.mods.jei.BaseCategory; + import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.Collections; public class BurningRecipeCategory extends BaseCategory { @@ -32,7 +35,8 @@ public BurningRecipeCategory(IGuiHelper guiHelper) { } @Override - public void setRecipe(@NotNull IRecipeLayout recipeLayout, @NotNull RecipeWrapper recipeWrapper, @NotNull IIngredients ingredients) { + public void setRecipe(@NotNull IRecipeLayout recipeLayout, @NotNull RecipeWrapper recipeWrapper, + @NotNull IIngredients ingredients) { addItemSlot(recipeLayout, 0, true, 53, 25); addItemSlot(recipeLayout, 1, false, 105, 25); @@ -55,11 +59,8 @@ public void drawExtras(@NotNull Minecraft minecraft) { GlStateManager.popMatrix(); } - @Nullable - @Override - public IDrawable getIcon() { - return icon; - } + @Nullable @Override + public IDrawable getIcon() { return icon; } public static class RecipeWrapper implements IRecipeWrapper { @@ -71,7 +72,8 @@ public RecipeWrapper(Burning.BurningRecipe burningRecipe) { @Override public void getIngredients(IIngredients ingredients) { - ingredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(Arrays.asList(this.burningRecipe.getInput().getMatchingStacks()))); + ingredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(Arrays.asList(this.burningRecipe.getInput() + .getMatchingStacks()))); ingredients.setOutput(VanillaTypes.ITEM, this.burningRecipe.getOutput()); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/ExplosionRecipeCategory.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/ExplosionRecipeCategory.java index 930751b3d..ee5c20b8b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/ExplosionRecipeCategory.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/ExplosionRecipeCategory.java @@ -1,25 +1,28 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting.jei; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.compat.inworldcrafting.Explosion; import com.cleanroommc.groovyscript.compat.mods.jei.BaseCategory; + import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; public class ExplosionRecipeCategory extends BaseCategory { @@ -33,7 +36,8 @@ public ExplosionRecipeCategory(IGuiHelper guiHelper) { } @Override - public void setRecipe(@NotNull IRecipeLayout recipeLayout, @NotNull RecipeWrapper recipeWrapper, @NotNull IIngredients ingredients) { + public void setRecipe(@NotNull IRecipeLayout recipeLayout, @NotNull RecipeWrapper recipeWrapper, + @NotNull IIngredients ingredients) { addItemSlot(recipeLayout, 0, true, 53, 25); addItemSlot(recipeLayout, 1, false, 105, 25); @@ -56,11 +60,8 @@ public void drawExtras(@NotNull Minecraft minecraft) { GlStateManager.popMatrix(); } - @Nullable - @Override - public IDrawable getIcon() { - return icon; - } + @Nullable @Override + public IDrawable getIcon() { return icon; } public static class RecipeWrapper implements IRecipeWrapper { @@ -72,7 +73,8 @@ public RecipeWrapper(Explosion.ExplosionRecipe explosionRecipe) { @Override public void getIngredients(IIngredients ingredients) { - ingredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(Arrays.asList(this.explosionRecipe.getInput().getMatchingStacks()))); + ingredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(Arrays.asList(this.explosionRecipe.getInput() + .getMatchingStacks()))); ingredients.setOutput(VanillaTypes.ITEM, this.explosionRecipe.getOutput()); } @@ -91,7 +93,8 @@ public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHe @Override public @NotNull List getTooltipStrings(int mouseX, int mouseY) { if (this.explosionRecipe.getChance() < 1 && mouseX >= 74 && mouseX <= 72 + 28 && mouseY >= 25 && mouseY <= 54) { - return Collections.singletonList(I18n.format("groovyscript.recipe.chance_produce", FluidRecipeCategory.numberFormat.format(this.explosionRecipe.getChance()))); + return Collections.singletonList(I18n.format("groovyscript.recipe.chance_produce", + FluidRecipeCategory.numberFormat.format(this.explosionRecipe.getChance()))); } return Collections.emptyList(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/FluidRecipeCategory.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/FluidRecipeCategory.java index 4549e97b7..6362e1873 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/FluidRecipeCategory.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/jei/FluidRecipeCategory.java @@ -1,31 +1,34 @@ package com.cleanroommc.groovyscript.compat.inworldcrafting.jei; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.inworldcrafting.FluidRecipe; import com.cleanroommc.groovyscript.compat.inworldcrafting.FluidToFluid; import com.cleanroommc.groovyscript.compat.inworldcrafting.FluidToItem; import com.cleanroommc.groovyscript.compat.mods.jei.BaseCategory; + import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; public class FluidRecipeCategory extends BaseCategory { @@ -42,14 +45,14 @@ public class FluidRecipeCategory extends BaseCategory { @@ -32,7 +35,8 @@ public PistonPushRecipeCategory(IGuiHelper guiHelper) { } @Override - public void setRecipe(@NotNull IRecipeLayout recipeLayout, @NotNull RecipeWrapper recipeWrapper, @NotNull IIngredients ingredients) { + public void setRecipe(@NotNull IRecipeLayout recipeLayout, @NotNull RecipeWrapper recipeWrapper, + @NotNull IIngredients ingredients) { addItemSlot(recipeLayout, 0, true, 53, 25); addItemSlot(recipeLayout, 1, false, 105, 25); @@ -55,11 +59,8 @@ public void drawExtras(@NotNull Minecraft minecraft) { GlStateManager.popMatrix(); } - @Nullable - @Override - public IDrawable getIcon() { - return icon; - } + @Nullable @Override + public IDrawable getIcon() { return icon; } public static class RecipeWrapper implements IRecipeWrapper { @@ -71,7 +72,8 @@ public RecipeWrapper(PistonPush.PistonPushRecipe pistonPushRecipe) { @Override public void getIngredients(IIngredients ingredients) { - ingredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(Arrays.asList(this.pistonPushRecipe.getInput().getMatchingStacks()))); + ingredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(Arrays.asList(this.pistonPushRecipe.getInput() + .getMatchingStacks()))); ingredients.setOutput(VanillaTypes.ITEM, this.pistonPushRecipe.getOutput()); } @@ -79,11 +81,15 @@ public void getIngredients(IIngredients ingredients) { public void drawInfo(@NotNull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { int y = 46; if (this.pistonPushRecipe.getMaxConversionsPerPush() < 64) { - minecraft.fontRenderer.drawString(I18n.format("groovyscript.recipe.piston_push.max_items", this.pistonPushRecipe.getMaxConversionsPerPush()), 7, y, 0x404040); + minecraft.fontRenderer.drawString(I18n.format("groovyscript.recipe.piston_push.max_items", this.pistonPushRecipe + .getMaxConversionsPerPush()), + 7, y, 0x404040); } y += 11; if (this.pistonPushRecipe.getMinHarvestLevel() >= 0) { - minecraft.fontRenderer.drawString(I18n.format("groovyscript.recipe.piston_push.min_level", this.pistonPushRecipe.getMinHarvestLevel()), 7, y, 0x404040); + minecraft.fontRenderer.drawString(I18n.format("groovyscript.recipe.piston_push.min_level", this.pistonPushRecipe + .getMinHarvestLevel()), + 7, y, 0x404040); } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/loot/GroovyLootCondition.java b/src/main/java/com/cleanroommc/groovyscript/compat/loot/GroovyLootCondition.java index 427da5a39..4fcdcbe9c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/loot/GroovyLootCondition.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/loot/GroovyLootCondition.java @@ -1,14 +1,17 @@ package com.cleanroommc.groovyscript.compat.loot; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import groovy.lang.Closure; +import java.util.Arrays; +import java.util.Random; + import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.conditions.LootCondition; + import org.jetbrains.annotations.NotNull; -import java.util.Arrays; -import java.util.Random; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.sandbox.ClosureHelper; + +import groovy.lang.Closure; public class GroovyLootCondition implements LootCondition { @@ -18,8 +21,7 @@ public GroovyLootCondition(Closure condition) { this.condition = condition; if (!Arrays.equals(condition.getParameterTypes(), new Class[]{Random.class, LootContext.class})) { GroovyLog.msg("Warning: LootCondition closures must take the following parameters (java.util.Random, net.minecraft.world.storage.loot.LootContext)") - .debug() - .post(); + .debug().post(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/loot/GroovyLootFunction.java b/src/main/java/com/cleanroommc/groovyscript/compat/loot/GroovyLootFunction.java index 73f908906..626c6bf61 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/loot/GroovyLootFunction.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/loot/GroovyLootFunction.java @@ -1,16 +1,19 @@ package com.cleanroommc.groovyscript.compat.loot; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import groovy.lang.Closure; +import java.util.Arrays; +import java.util.Random; + import net.minecraft.item.ItemStack; import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.conditions.LootCondition; import net.minecraft.world.storage.loot.functions.LootFunction; + import org.jetbrains.annotations.NotNull; -import java.util.Arrays; -import java.util.Random; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.sandbox.ClosureHelper; + +import groovy.lang.Closure; public class GroovyLootFunction extends LootFunction { @@ -25,8 +28,7 @@ public GroovyLootFunction(LootCondition[] conditions, Closure function) this.function = function; if (!Arrays.equals(function.getParameterTypes(), new Class[]{ItemStack.class, Random.class, LootContext.class})) { GroovyLog.msg("Warning: LootFunction closures must take the following parameters (net.minecraft.item.ItemStack, java.util.Random, net.minecraft.world.storage.loot.LootContext)") - .debug() - .post(); + .debug().post(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/loot/Loot.java b/src/main/java/com/cleanroommc/groovyscript/compat/loot/Loot.java index 6875dfd78..b4a27d0fd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/loot/Loot.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/loot/Loot.java @@ -1,17 +1,20 @@ package com.cleanroommc.groovyscript.compat.loot; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.IScriptReloadable; -import com.cleanroommc.groovyscript.registry.NamedRegistry; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import java.util.Map; + import net.minecraft.server.MinecraftServer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.WorldServer; import net.minecraft.world.storage.loot.LootTable; import net.minecraftforge.fml.common.FMLCommonHandler; + import org.jetbrains.annotations.ApiStatus; -import java.util.Map; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.IScriptReloadable; +import com.cleanroommc.groovyscript.registry.NamedRegistry; + +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; public class Loot extends NamedRegistry implements IScriptReloadable { @@ -19,9 +22,7 @@ public class Loot extends NamedRegistry implements IScriptReloadable { // TODO add event shortcut here - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { tables.clear(); MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); @@ -32,9 +33,7 @@ public void onReload() { } } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void afterScriptLoad() { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); if (server != null) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/loot/LootEntryBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/loot/LootEntryBuilder.java index d677d6c2a..c21023b58 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/loot/LootEntryBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/loot/LootEntryBuilder.java @@ -1,10 +1,7 @@ package com.cleanroommc.groovyscript.compat.loot; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; -import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; -import com.google.common.collect.Lists; -import groovy.lang.Closure; +import java.util.*; + import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -20,9 +17,15 @@ import net.minecraft.world.storage.loot.conditions.RandomChance; import net.minecraft.world.storage.loot.conditions.RandomChanceWithLooting; import net.minecraft.world.storage.loot.functions.*; + import org.apache.logging.log4j.Level; -import java.util.*; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; +import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; +import com.google.common.collect.Lists; + +import groovy.lang.Closure; public class LootEntryBuilder { @@ -122,7 +125,8 @@ public LootEntryBuilder enchantWithLevels(boolean isTreasure, int min, int max) public LootEntryBuilder enchantWithLevels(boolean isTreasure, int min, int max, LootCondition... conditions) { out.add(min < 0.0f, () -> "enchantWithLevels minimum cannot be less than 0."); out.add(max < 0.0f, () -> "enchantWithLevels maximum cannot be less than 0."); - this.functions.add(new EnchantWithLevels(conditions, new RandomValueRange(Math.max(min, 0.0f), Math.max(max, 0.0f)), isTreasure)); + this.functions.add(new EnchantWithLevels(conditions, new RandomValueRange(Math.max(min, 0.0f), Math.max(max, 0.0f)), + isTreasure)); return this; } @@ -144,7 +148,7 @@ public LootEntryBuilder enchantRandomly(Enchantment enchantment, LootCondition.. public LootEntryBuilder enchantRandomly(Enchantment[] enchantments, LootCondition... conditions) { List list = (enchantments != null) ? Lists.newArrayList(enchantments) : null; - this.functions.add(new EnchantRandomly((conditions == null)? EMPTY_CONDITIONS : conditions, list)); + this.functions.add(new EnchantRandomly((conditions == null) ? EMPTY_CONDITIONS : conditions, list)); return this; } @@ -164,7 +168,12 @@ public LootEntryBuilder lootingBonus(float min, float max, int limit, LootCondit out.add(min < 0.0f, () -> "lootingEnchantBonus minimum cannot be less than 0."); out.add(max < 0.0f, () -> "lootingEnchantBonus maximum cannot be less than 0."); out.add(limit < 0, () -> "lootingEnchantBonus limit cannot be less than 0."); - this.functions.add(new LootingEnchantBonus((conditions == null)? EMPTY_CONDITIONS : conditions, new RandomValueRange(Math.max(min, 0.0f), Math.max(max, 0.0f)), Math.max(limit, 0))); + this.functions.add(new LootingEnchantBonus((conditions == null) ? EMPTY_CONDITIONS : conditions, new RandomValueRange(Math + .max(min, + 0.0f), + Math.max(max, + 0.0f)), + Math.max(limit, 0))); return this; } @@ -183,7 +192,10 @@ public LootEntryBuilder setDamage(int min, int max) { public LootEntryBuilder setDamage(int min, int max, LootCondition... conditions) { out.add(min < 0 || min >= 32767, () -> "setDamage minimum cannot be less than 0 or more than 32766."); out.add(max < 0 || min >= 32767, () -> "setDamage maximum cannot be less than 0 or more than 32766."); - this.functions.add(new SetDamage((conditions == null)? EMPTY_CONDITIONS : conditions, new RandomValueRange(Math.max(min, 0.0f), Math.max(max, 0.0f)))); + this.functions.add(new SetDamage((conditions == null) ? EMPTY_CONDITIONS : conditions, new RandomValueRange(Math.max(min, + 0.0f), + Math.max(max, + 0.0f)))); return this; } @@ -202,7 +214,10 @@ public LootEntryBuilder setCount(int min, int max) { public LootEntryBuilder setCount(int min, int max, LootCondition... conditions) { out.add(min < 0, () -> "setCount minimum cannot be less than 0."); out.add(max < 0, () -> "setCount maximum cannot be less than 0."); - this.functions.add(new SetCount((conditions == null)? EMPTY_CONDITIONS : conditions, new RandomValueRange(Math.max(min, 0.0f), Math.max(max, 0.0f)))); + this.functions.add(new SetCount((conditions == null) ? EMPTY_CONDITIONS : conditions, new RandomValueRange(Math.max(min, + 0.0f), + Math.max(max, + 0.0f)))); return this; } @@ -221,7 +236,11 @@ public LootEntryBuilder setMetadata(int min, int max) { public LootEntryBuilder setMetadata(int min, int max, LootCondition... conditions) { out.add(min < 0 || min >= 32767, () -> "setMetadata minimum cannot be less than 0 or more than 32766."); out.add(max < 0 || min >= 32767, () -> "setMetadata maximum cannot be less than 0 or more than 32766."); - this.functions.add(new SetMetadata((conditions == null)? EMPTY_CONDITIONS : conditions, new RandomValueRange(Math.max(min, 0.0f), Math.max(max, 0.0f)))); + this.functions.add(new SetMetadata((conditions == null) ? EMPTY_CONDITIONS : conditions, new RandomValueRange(Math.max( + min, + 0.0f), + Math.max(max, + 0.0f)))); return this; } @@ -256,7 +275,7 @@ public LootEntryBuilder setNBT(Map tag, LootCondition... conditi } public LootEntryBuilder setNBT(NBTTagCompound tag, LootCondition... conditions) { - this.functions.add(new SetNBT((conditions == null)? EMPTY_CONDITIONS : conditions, tag)); + this.functions.add(new SetNBT((conditions == null) ? EMPTY_CONDITIONS : conditions, tag)); return this; } @@ -280,7 +299,8 @@ public LootEntryBuilder randomChance(float chance) { public LootEntryBuilder randomChanceWithLooting(float chance, float lootingMultiplier) { out.add(chance < 0.0f || chance > 1.0f, () -> "randomChance must be in range [0,1]."); out.add(lootingMultiplier < 0.0f, () -> "lootingMultiplier cannot be less than 0."); - this.conditions.add(new RandomChanceWithLooting(Math.max(0.0f, Math.min(1.0f, chance)), Math.max(lootingMultiplier, 0.0f))); + this.conditions.add(new RandomChanceWithLooting(Math.max(0.0f, Math.min(1.0f, chance)), Math.max(lootingMultiplier, + 0.0f))); return this; } @@ -316,9 +336,15 @@ else if (name == null || name.isEmpty()) { if (quality < 0) out.add("quality < 0 may make the loot entry unable to be rolled"); if (validateForRegister) { - if (tableName == null || VanillaModule.loot.tables.get(tableName) == null) out.add("No valid LootTable specified").error(); - else if (poolName == null || poolName.isEmpty() || VanillaModule.loot.tables.get(tableName).getPool(poolName) == null) out.add("No valid LootPool specified").error(); - else if (VanillaModule.loot.tables.get(tableName).getPool(poolName).getEntry(name) != null) out.add("Attempted to add duplicate entry " + name + " to " + tableName + " - " + poolName); + if (tableName == null || VanillaModule.loot.tables.get(tableName) == null) out.add("No valid LootTable specified") + .error(); + else if (poolName == null || poolName.isEmpty() || VanillaModule.loot.tables.get(tableName).getPool(poolName) == null) + out.add("No valid LootPool specified").error(); + else if (VanillaModule.loot.tables.get(tableName).getPool(poolName).getEntry(name) != null) out.add( + "Attempted to add duplicate entry " + + name + " to " + + tableName + + " - " + poolName); } out.postIfNotEmpty(); @@ -327,14 +353,17 @@ else if (name == null || name.isEmpty()) { public LootEntry build() { if (!validate(false)) return null; - return new LootEntryItem(item, weight, quality, functions.toArray(new LootFunction[0]), conditions.toArray(new LootCondition[0]), name); + return new LootEntryItem(item, weight, quality, functions.toArray(new LootFunction[0]), conditions.toArray( + new LootCondition[0]), + name); } public void register() { if (!validate(true)) return; - VanillaModule.loot.tables.get(tableName).getPool(poolName).addEntry( - new LootEntryItem(item, weight, quality, functions.toArray(new LootFunction[0]), conditions.toArray(new LootCondition[0]), name) - ); + VanillaModule.loot.tables.get(tableName).getPool(poolName).addEntry(new LootEntryItem(item, weight, quality, functions + .toArray(new LootFunction[0]), + conditions.toArray(new LootCondition[0]), + name)); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/loot/LootPoolBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/loot/LootPoolBuilder.java index 55314495b..e98ab427c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/loot/LootPoolBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/loot/LootPoolBuilder.java @@ -1,8 +1,8 @@ package com.cleanroommc.groovyscript.compat.loot; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; -import groovy.lang.Closure; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.LootEntry; @@ -12,10 +12,13 @@ import net.minecraft.world.storage.loot.conditions.LootCondition; import net.minecraft.world.storage.loot.conditions.RandomChance; import net.minecraft.world.storage.loot.conditions.RandomChanceWithLooting; + import org.apache.logging.log4j.Level; -import java.util.ArrayList; -import java.util.List; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; + +import groovy.lang.Closure; public class LootPoolBuilder { @@ -53,10 +56,9 @@ public LootPoolBuilder entry(LootEntry entry) { } public LootPoolBuilder entry(ItemStack stack, int weight) { - this.lootEntries.add(new LootEntryBuilder() - .name(stack.getItem().getRegistryName().getNamespace() + ":" + stack.getMetadata()) - .item(stack) - .weight(weight).build()); + this.lootEntries.add(new LootEntryBuilder().name(stack.getItem().getRegistryName().getNamespace() + ":" + stack + .getMetadata()) + .item(stack).weight(weight).build()); return this; } @@ -118,9 +120,11 @@ public LootPoolBuilder bonusRollsRange(float min, float max) { private boolean validate(boolean validateForRegister) { if (name == null || name.isEmpty()) out.add("No name provided").error(); if (validateForRegister) { - if (tableName == null || !VanillaModule.loot.tables.containsKey(tableName)) out.add("No valid LootTable specified").error(); + if (tableName == null || !VanillaModule.loot.tables.containsKey(tableName)) out.add("No valid LootTable specified") + .error(); else if (name == null || name.isEmpty()) out.add("LootPool must have a name specified with .name()").error(); - else if (VanillaModule.loot.tables.get(tableName).getPool(name) != null) out.add("Attempted to add duplicate pool " + name + " to " + tableName).error(); + else if (VanillaModule.loot.tables.get(tableName).getPool(name) != null) out.add("Attempted to add duplicate pool " + + name + " to " + tableName).error(); } out.postIfNotEmpty(); return out.getLevel() != Level.ERROR; @@ -128,14 +132,15 @@ private boolean validate(boolean validateForRegister) { public LootPool build() { if (!validate(false)) return null; - return new LootPool(lootEntries.toArray(new LootEntry[0]), poolConditions.toArray(new LootCondition[0]), rolls, bonusRolls, name); + return new LootPool(lootEntries.toArray(new LootEntry[0]), poolConditions.toArray(new LootCondition[0]), rolls, + bonusRolls, name); } public void register() { if (!validate(true)) return; - VanillaModule.loot.tables.get(tableName).addPool( - new LootPool(lootEntries.toArray(new LootEntry[0]), poolConditions.toArray(new LootCondition[0]), rolls, bonusRolls, name) - ); + VanillaModule.loot.tables.get(tableName).addPool(new LootPool(lootEntries.toArray(new LootEntry[0]), poolConditions + .toArray(new LootCondition[0]), + rolls, bonusRolls, name)); } -} \ No newline at end of file +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ExternalModContainer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ExternalModContainer.java index bcb994aea..a869e58f8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ExternalModContainer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ExternalModContainer.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods; -import com.cleanroommc.groovyscript.api.GroovyPlugin; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import org.jetbrains.annotations.NotNull; - import java.util.Collection; import java.util.Collections; import java.util.Objects; import java.util.Set; +import org.jetbrains.annotations.NotNull; + +import com.cleanroommc.groovyscript.api.GroovyPlugin; + +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; + /** * This is used for external mod compat. Don't use this directly. Instead, implement {@link GroovyPlugin} on any class. * This class will then be automatically instanced. @@ -34,25 +36,16 @@ public class ExternalModContainer extends GroovyContainer getAliases() { - return aliases; - } + @NotNull @Override + public Collection getAliases() { return aliases; } @Override public void onCompatLoaded(GroovyContainer container) { @@ -65,7 +58,5 @@ public GroovyPropertyContainer get() { } @Override - public @NotNull GroovyPlugin.Priority getOverridePriority() { - return priority; - } + public @NotNull GroovyPlugin.Priority getOverridePriority() { return priority; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/GroovyContainer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/GroovyContainer.java index 279802121..8fc33176e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/GroovyContainer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/GroovyContainer.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods; +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IGroovyContainer; import com.cleanroommc.groovyscript.api.INamed; import com.cleanroommc.groovyscript.api.IRegistrar; import com.cleanroommc.groovyscript.mapper.ObjectMapper; -import org.jetbrains.annotations.ApiStatus; /** * This is the base class for mod compat. It is created even if the other mod is not loaded. @@ -27,19 +28,13 @@ public String toString() { /** * @deprecated Use {@link #addProperty(INamed)} and {@link #addPropertiesOfFields(Object, boolean)} from this class instead. */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") - @GroovyBlacklist - public IRegistrar getVirtualizedRegistrar() { - return getRegistrar(); - } + @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") @GroovyBlacklist + public IRegistrar getVirtualizedRegistrar() { return getRegistrar(); } /** * @deprecated Use {@link #addProperty(INamed)} and {@link #addPropertiesOfFields(Object, boolean)} from this class instead. */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") - @GroovyBlacklist + @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") @GroovyBlacklist public IRegistrar getRegistrar() { if (!isLoaded()) return null; T t = get(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/GroovyPropertyContainer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/GroovyPropertyContainer.java index 0950602c8..eceb32fec 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/GroovyPropertyContainer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/GroovyPropertyContainer.java @@ -1,19 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.UnmodifiableView; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.INamed; import com.cleanroommc.groovyscript.sandbox.expand.ExpansionHelper; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.UnmodifiableView; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; public class GroovyPropertyContainer { @@ -33,27 +35,21 @@ protected void addProperty(INamed property) { } @UnmodifiableView - public Collection getRegistries() { - return this.view.values(); - } + public Collection getRegistries() { return this.view.values(); } @UnmodifiableView - public Map getProperties() { - return view; - } + public Map getProperties() { return view; } /** * Register bracket handlers, bindings, expansions etc. here */ - @GroovyBlacklist - @ApiStatus.OverrideOnly - public void initialize(GroovyContainer owner) { - } + @GroovyBlacklist @ApiStatus.OverrideOnly + public void initialize(GroovyContainer owner) {} protected void addPropertyFieldsOf(Object object, boolean privateToo) { boolean staticOnly = false; Class clazz; - if (object instanceof Class c) { + if (object instanceof Classc) { clazz = c; staticOnly = true; } else { @@ -61,10 +57,7 @@ protected void addPropertyFieldsOf(Object object, boolean privateToo) { } for (Field field : clazz.getDeclaredFields()) { boolean isStatic = Modifier.isStatic(field.getModifiers()); - if (!field.isAnnotationPresent(GroovyBlacklist.class) && - INamed.class.isAssignableFrom(field.getType()) && - (!staticOnly || isStatic) && - (privateToo || (Modifier.isPublic(field.getModifiers())))) { + if (!field.isAnnotationPresent(GroovyBlacklist.class) && INamed.class.isAssignableFrom(field.getType()) && (!staticOnly || isStatic) && (privateToo || (Modifier.isPublic(field.getModifiers())))) { try { if (!field.isAccessible()) field.setAccessible(true); Object o = field.get(isStatic ? null : object); @@ -78,4 +71,3 @@ protected void addPropertyFieldsOf(Object object, boolean privateToo) { } } } - diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/InternalModContainer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/InternalModContainer.java index 1333a67c6..3867f62f0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/InternalModContainer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/InternalModContainer.java @@ -1,19 +1,23 @@ package com.cleanroommc.groovyscript.compat.mods; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + +import net.minecraftforge.fml.common.Loader; + +import org.jetbrains.annotations.NotNull; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyPlugin; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import net.minecraftforge.fml.common.Loader; -import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; /** - * This class is only used for internal mod compat. Do not use this. Instead, refer to {@link ExternalModContainer} ans {@link GroovyPlugin}. + * This class is only used for internal mod compat. Do not use this. Instead, refer to {@link ExternalModContainer} ans + * {@link GroovyPlugin}. * * @param type of the mod property container. */ @@ -30,7 +34,8 @@ public class InternalModContainer extends Gro InternalModContainer(String modId, String containerName, @NotNull Supplier modProperty, String... aliases) { if (ModSupport.isFrozen()) { - throw new RuntimeException("Groovy mod containers must be registered at construction event! Tried to register '" + containerName + "' too late."); + throw new RuntimeException("Groovy mod containers must be registered at construction event! Tried to register '" + + containerName + "' too late."); } if (ModSupport.INSTANCE.hasCompatFor(modId)) { GroovyScript.LOGGER.error("Error while trying to add internal compat!"); @@ -52,15 +57,10 @@ public class InternalModContainer extends Gro } @Override - public boolean isLoaded() { - return loaded; - } + public boolean isLoaded() { return loaded; } - @NotNull - @Override - public Collection getAliases() { - return aliases; - } + @NotNull @Override + public Collection getAliases() { return aliases; } @Override public T get() { @@ -68,16 +68,11 @@ public T get() { } @Override - public @NotNull String getModId() { - return modId; - } + public @NotNull String getModId() { return modId; } @Override - public @NotNull String getContainerName() { - return containerName; - } + public @NotNull String getContainerName() { return containerName; } @Override - public void onCompatLoaded(GroovyContainer container) { - } + public void onCompatLoaded(GroovyContainer container) {} } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModPropertyContainer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModPropertyContainer.java index 985862553..f2ef9b836 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModPropertyContainer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModPropertyContainer.java @@ -1,29 +1,27 @@ package com.cleanroommc.groovyscript.compat.mods; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.INamed; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; /** * @deprecated this class has been replaced by {@link GroovyPropertyContainer} */ -@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") -@Deprecated +@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") @Deprecated public class ModPropertyContainer extends GroovyPropertyContainer { /** * @deprecated use {@link #addProperty(INamed)} */ - @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") - @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") @Deprecated protected void addRegistry(INamed property) { addProperty(property); } - @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") - @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") @Deprecated public @Nullable Object getProperty(String name) { INamed property = getProperties().get(name); if (property == null) { @@ -37,22 +35,15 @@ protected void addRegistry(INamed property) { return property; } - @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") - @Deprecated - @GroovyBlacklist - @ApiStatus.OverrideOnly - public void initialize() { - } + @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") @Deprecated @GroovyBlacklist @ApiStatus.OverrideOnly + public void initialize() {} /** * Register bracket handlers, bindings, expansions etc. here */ - @GroovyBlacklist - @ApiStatus.OverrideOnly - @Override + @GroovyBlacklist @ApiStatus.OverrideOnly @Override public void initialize(GroovyContainer owner) { initialize(); } } - diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java index 5ae966e03..6c9414abd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods; +import java.util.*; + +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.discovery.ASMDataTable; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnmodifiableView; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyPlugin; @@ -46,16 +56,9 @@ import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.TinkersConstruct; import com.cleanroommc.groovyscript.compat.mods.woot.Woot; import com.cleanroommc.groovyscript.sandbox.expand.ExpansionHelper; + import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.discovery.ASMDataTable; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.UnmodifiableView; - -import java.util.*; public class ModSupport { @@ -67,55 +70,118 @@ public class ModSupport { public static final ModSupport INSTANCE = new ModSupport(); // Just for Binding purposes - public static final GroovyContainer ACTUALLY_ADDITIONS = new InternalModContainer<>("actuallyadditions", "Actually Additions", ActuallyAdditions::new, "aa"); - public static final GroovyContainer ADVANCED_MORTARS = new InternalModContainer<>("advancedmortars", "Advanced Mortars", AdvancedMortars::new); - public static final GroovyContainer AETHER = new InternalModContainer<>("aether_legacy", "Aether Legacy", Aether::new, "aether"); - public static final GroovyContainer ALCHEMISTRY = new InternalModContainer<>("alchemistry", "Alchemistry", Alchemistry::new); - public static final GroovyContainer APPLIED_ENERGISTICS_2 = new InternalModContainer<>("appliedenergistics2", "Applied Energistics 2", AppliedEnergistics2::new, "ae2"); - public static final GroovyContainer ARCANE_ARCHIVES = new InternalModContainer<>("arcanearchives", "Arcane Archives", ArcaneArchives::new); - public static final GroovyContainer ASTRAL_SORCERY = new InternalModContainer<>("astralsorcery", "Astral Sorcery", AstralSorcery::new, "astral"); + public static final GroovyContainer ACTUALLY_ADDITIONS = new InternalModContainer<>("actuallyadditions", + "Actually Additions", + ActuallyAdditions::new, + "aa"); + public static final GroovyContainer ADVANCED_MORTARS = new InternalModContainer<>("advancedmortars", + "Advanced Mortars", + AdvancedMortars::new); + public static final GroovyContainer AETHER = new InternalModContainer<>("aether_legacy", "Aether Legacy", Aether::new, + "aether"); + public static final GroovyContainer ALCHEMISTRY = new InternalModContainer<>("alchemistry", "Alchemistry", + Alchemistry::new); + public static final GroovyContainer APPLIED_ENERGISTICS_2 = new InternalModContainer<>("appliedenergistics2", + "Applied Energistics 2", + AppliedEnergistics2::new, + "ae2"); + public static final GroovyContainer ARCANE_ARCHIVES = new InternalModContainer<>("arcanearchives", + "Arcane Archives", + ArcaneArchives::new); + public static final GroovyContainer ASTRAL_SORCERY = new InternalModContainer<>("astralsorcery", + "Astral Sorcery", + AstralSorcery::new, "astral"); public static final GroovyContainer AVARITIA = new InternalModContainer<>("avaritia", "Avaritia", Avaritia::new); - public static final GroovyContainer BETTER_WITH_MODS = new InternalModContainer<>("betterwithmods", "Better With Mods", BetterWithMods::new); - public static final GroovyContainer BLOOD_MAGIC = new InternalModContainer<>("bloodmagic", "Blood Magic: Alchemical Wizardry", BloodMagic::new, "bm"); + public static final GroovyContainer BETTER_WITH_MODS = new InternalModContainer<>("betterwithmods", + "Better With Mods", + BetterWithMods::new); + public static final GroovyContainer BLOOD_MAGIC = new InternalModContainer<>("bloodmagic", + "Blood Magic: Alchemical Wizardry", + BloodMagic::new, "bm"); public static final GroovyContainer BOTANIA = new InternalModContainer<>("botania", "Botania", Botania::new); - public static final GroovyContainer CALCULATOR = new InternalModContainer<>("calculator", "Calculator", Calculator::new); + public static final GroovyContainer CALCULATOR = new InternalModContainer<>("calculator", "Calculator", + Calculator::new); public static final GroovyContainer CHISEL = new InternalModContainer<>("chisel", "Chisel", Chisel::new); - public static final GroovyContainer COMPACT_MACHINES = new InternalModContainer<>("compactmachines3", "Compact Machines 3", CompactMachines::new, "compactmachines"); - public static final GroovyContainer DRACONIC_EVOLUTION = new InternalModContainer<>("draconicevolution", "Draconic Evolution", DraconicEvolution::new, "de"); - public static final GroovyContainer ENDER_IO = new InternalModContainer<>("enderio", "Ender IO", EnderIO::new, "eio"); - public static final GroovyContainer ESSENTIALCRAFT = new InternalModContainer<>("essentialcraft", "EssentialCraft 4", EssentialCraft::new, "ec4"); - public static final GroovyContainer EVILCRAFT = new InternalModContainer<>("evilcraft", "EvilCraft", EvilCraft::new); - public static final GroovyContainer EXTENDED_CRAFTING = new InternalModContainer<>("extendedcrafting", "Extended Crafting", ExtendedCrafting::new); - public static final GroovyContainer EXTRA_UTILITIES_2 = new InternalModContainer<>("extrautils2", "Extra Utilities 2", ExtraUtils2::new, "extrautilities2"); + public static final GroovyContainer COMPACT_MACHINES = new InternalModContainer<>("compactmachines3", + "Compact Machines 3", + CompactMachines::new, + "compactmachines"); + public static final GroovyContainer DRACONIC_EVOLUTION = new InternalModContainer<>("draconicevolution", + "Draconic Evolution", + DraconicEvolution::new, + "de"); + public static final GroovyContainer ENDER_IO = new InternalModContainer<>("enderio", "Ender IO", EnderIO::new, + "eio"); + public static final GroovyContainer ESSENTIALCRAFT = new InternalModContainer<>("essentialcraft", + "EssentialCraft 4", + EssentialCraft::new, "ec4"); + public static final GroovyContainer EVILCRAFT = new InternalModContainer<>("evilcraft", "EvilCraft", + EvilCraft::new); + public static final GroovyContainer EXTENDED_CRAFTING = new InternalModContainer<>("extendedcrafting", + "Extended Crafting", + ExtendedCrafting::new); + public static final GroovyContainer EXTRA_UTILITIES_2 = new InternalModContainer<>("extrautils2", + "Extra Utilities 2", + ExtraUtils2::new, + "extrautilities2"); public static final GroovyContainer FORESTRY = new InternalModContainer<>("forestry", "Forestry", Forestry::new); - public static final GroovyContainer IMMERSIVE_ENGINEERING = new InternalModContainer<>("immersiveengineering", "Immersive Engineering", ImmersiveEngineering::new, "ie"); - public static final GroovyContainer IMMERSIVE_PETROLEUM = new InternalModContainer<>("immersivepetroleum", "Immersive Petroleum", ImmersivePetroleum::new); - public static final GroovyContainer INDUSTRIALCRAFT = new InternalModContainer<>("ic2", "Industrial Craft 2", IC2::new, "industrialcraft"); - public static final GroovyContainer INDUSTRIAL_FOREGOING = new InternalModContainer<>("industrialforegoing", "Industrial Foregoing", IndustrialForegoing::new); - public static final GroovyContainer INSPIRATIONS = new InternalModContainer<>("inspirations", "Inspirations", Inspirations::new); - public static final GroovyContainer INTEGRATED_DYNAMICS = new InternalModContainer<>("integrateddynamics", "Integrated Dynamics", IntegratedDynamics::new, "id"); - public static final GroovyContainer JEI = new InternalModContainer<>("jei", "Just Enough Items", JustEnoughItems::new, "hei"); + public static final GroovyContainer IMMERSIVE_ENGINEERING = new InternalModContainer<>("immersiveengineering", + "Immersive Engineering", + ImmersiveEngineering::new, + "ie"); + public static final GroovyContainer IMMERSIVE_PETROLEUM = new InternalModContainer<>("immersivepetroleum", + "Immersive Petroleum", + ImmersivePetroleum::new); + public static final GroovyContainer INDUSTRIALCRAFT = new InternalModContainer<>("ic2", "Industrial Craft 2", IC2::new, + "industrialcraft"); + public static final GroovyContainer INDUSTRIAL_FOREGOING = new InternalModContainer<>("industrialforegoing", + "Industrial Foregoing", + IndustrialForegoing::new); + public static final GroovyContainer INSPIRATIONS = new InternalModContainer<>("inspirations", "Inspirations", + Inspirations::new); + public static final GroovyContainer INTEGRATED_DYNAMICS = new InternalModContainer<>("integrateddynamics", + "Integrated Dynamics", + IntegratedDynamics::new, + "id"); + public static final GroovyContainer JEI = new InternalModContainer<>("jei", "Just Enough Items", + JustEnoughItems::new, "hei"); public static final GroovyContainer MEKANISM = new InternalModContainer<>("mekanism", "Mekanism", Mekanism::new); - public static final GroovyContainer LAZYAE2 = new InternalModContainer<>("threng", "LazyAE2", LazyAE2::new, "lazyae2"); - public static final GroovyContainer NATURES_AURA = new InternalModContainer<>("naturesaura", "Nature's Aura", NaturesAura::new); - public static final GroovyContainer PNEUMATIC_CRAFT = new InternalModContainer<>("pneumaticcraft", "PneumaticCraft: Repressurized", PneumaticCraft::new); - public static final GroovyContainer PRODIGY_TECH = new InternalModContainer<>("prodigytech", "Prodigy Tech", ProdigyTech::new); + public static final GroovyContainer LAZYAE2 = new InternalModContainer<>("threng", "LazyAE2", LazyAE2::new, + "lazyae2"); + public static final GroovyContainer NATURES_AURA = new InternalModContainer<>("naturesaura", "Nature's Aura", + NaturesAura::new); + public static final GroovyContainer PNEUMATIC_CRAFT = new InternalModContainer<>("pneumaticcraft", + "PneumaticCraft: Repressurized", + PneumaticCraft::new); + public static final GroovyContainer PRODIGY_TECH = new InternalModContainer<>("prodigytech", "Prodigy Tech", + ProdigyTech::new); public static final GroovyContainer PROJECT_E = new InternalModContainer<>("projecte", "ProjectE", ProjectE::new); public static final GroovyContainer PYROTECH = new InternalModContainer<>("pyrotech", "Pyrotech", PyroTech::new); public static final GroovyContainer ROOTS = new InternalModContainer<>("roots", "Roots 3", Roots::new); public static final GroovyContainer RUSTIC = new InternalModContainer<>("rustic", "Rustic", Rustic::new); - public static final GroovyContainer THAUMCRAFT = new InternalModContainer<>("thaumcraft", "Thaumcraft", Thaumcraft::new, "tc", "thaum"); - public static final GroovyContainer THERMAL_EXPANSION = new InternalModContainer<>("thermalexpansion", "Thermal Expansion", ThermalExpansion::new, "thermal"); - public static final GroovyContainer TINKERS_COMPLEMENT = new InternalModContainer<>("tcomplement", "Tinkers Complement", TinkersComplement::new, "tcomp", "tinkerscomplement"); - public static final GroovyContainer TINKERS_CONSTRUCT = new InternalModContainer<>("tconstruct", "Tinkers' Construct", TinkersConstruct::new, "ticon", "tinkersconstruct"); + public static final GroovyContainer THAUMCRAFT = new InternalModContainer<>("thaumcraft", "Thaumcraft", + Thaumcraft::new, "tc", "thaum"); + public static final GroovyContainer THERMAL_EXPANSION = new InternalModContainer<>("thermalexpansion", + "Thermal Expansion", + ThermalExpansion::new, + "thermal"); + public static final GroovyContainer TINKERS_COMPLEMENT = new InternalModContainer<>("tcomplement", + "Tinkers Complement", + TinkersComplement::new, + "tcomp", + "tinkerscomplement"); + public static final GroovyContainer TINKERS_CONSTRUCT = new InternalModContainer<>("tconstruct", + "Tinkers' Construct", + TinkersConstruct::new, + "ticon", + "tinkersconstruct"); public static final GroovyContainer WOOT = new InternalModContainer<>("woot", "Woot", Woot::new); public static Collection> getAllContainers() { return Collections.unmodifiableList(containerList); } - private ModSupport() { - } + private ModSupport() {} @ApiStatus.Internal public void setup(ASMDataTable dataTable) { @@ -139,18 +205,22 @@ private void registerContainer(GroovyPlugin container) { return; } if (ModSupport.isFrozen()) { - throw new RuntimeException("Groovy mod containers must be registered at construction event! Tried to register '" + container.getContainerName() + "' too late."); + throw new RuntimeException("Groovy mod containers must be registered at construction event! Tried to register '" + + container.getContainerName() + "' too late."); } if (!Loader.isModLoaded(container.getModId())) return; if (hasCompatFor(container.getModId())) { GroovyContainer current = getContainer(container.getModId()); if (current.getOverridePriority().ordinal() >= container.getOverridePriority().ordinal()) { // the existing container has a higher priority, keep it - GroovyScript.LOGGER.info("Overriding GroovyScript compat plugin '{}' by plugin '{}'", container.getContainerName(), current.getContainerName()); + GroovyScript.LOGGER.info("Overriding GroovyScript compat plugin '{}' by plugin '{}'", container + .getContainerName(), + current.getContainerName()); return; } // the existing container has a lower priority, yeet it - GroovyScript.LOGGER.info("Overriding GroovyScript compat plugin '{}' by plugin '{}'", current.getContainerName(), container.getContainerName()); + GroovyScript.LOGGER.info("Overriding GroovyScript compat plugin '{}' by plugin '{}'", current.getContainerName(), + container.getContainerName()); containers.values().removeIf(c -> c == current); containerList.removeIf(c -> c == current); } @@ -176,8 +246,7 @@ void registerContainer(GroovyContainer container) { } } - @Deprecated - @Nullable + @Deprecated @Nullable public Object getProperty(String name) { GroovyContainer container = containers.get(name); return container != null ? container.get() : null; @@ -185,12 +254,9 @@ public Object getProperty(String name) { @Deprecated - public @UnmodifiableView Map> getProperties() { - return containersView; - } + public @UnmodifiableView Map> getProperties() { return containersView; } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal public static void init() { frozen = true; for (GroovyContainer container : containerList) { @@ -209,9 +275,7 @@ public static void init() { @NotNull public GroovyContainer getContainer(String mod) { - if (!containers.containsKey(mod)) { - throw new IllegalStateException("There is no compat registered for '" + mod + "'!"); - } + if (!containers.containsKey(mod)) { throw new IllegalStateException("There is no compat registered for '" + mod + "'!"); } return containers.get(mod); } @@ -219,7 +283,5 @@ public boolean hasCompatFor(String mod) { return containers.containsKey(mod); } - public static boolean isFrozen() { - return frozen; - } + public static boolean isFrozen() { return frozen; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/AtomicReconstructor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/AtomicReconstructor.java index 76112efbe..34b581df6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/AtomicReconstructor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/AtomicReconstructor.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,27 +14,22 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class AtomicReconstructor extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).energyUse(1000)"), - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).energy(1000)"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay') * 2)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).energyUse(1000)"), + @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).energy(1000)"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay') * 2)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES::remove); ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.addAll(restoreFromBackup()); @@ -84,12 +84,10 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES) - .setRemover(this::remove); + return new SimpleObjectStream<>(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "1", valid = @Comp(type = Comp.Type.GT, value = "0")) @@ -108,9 +106,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Actually Additions Atomic Reconstructor recipe"; - } + public String getErrorMsg() { return "Error adding Actually Additions Atomic Reconstructor recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -119,11 +115,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(energyUse <= 0, "energyUse must be an integer greater than 0, yet it was {}", energyUse); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable LensConversionRecipe register() { if (!validate()) return null; - LensConversionRecipe recipe = new LensConversionRecipe(input.get(0).toMcIngredient(), output.get(0), energyUse, ActuallyAdditionsAPI.lensDefaultConversion); + LensConversionRecipe recipe = new LensConversionRecipe(input.get(0).toMcIngredient(), output.get(0), energyUse, + ActuallyAdditionsAPI.lensDefaultConversion); ModSupport.ACTUALLY_ADDITIONS.get().atomicReconstructor.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/BallOfFur.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/BallOfFur.java index cf1a71d57..35bb6d232 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/BallOfFur.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/BallOfFur.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,10 +11,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.BallOfFurReturn; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class BallOfFur extends VirtualizedRegistry { @@ -20,8 +23,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS::remove); ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS.addAll(restoreFromBackup()); @@ -65,8 +67,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS) - .setRemover(this::remove); + return new SimpleObjectStream<>(ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS).setRemover(this::remove); } @Property(property = "output", valid = @Comp("1")) @@ -82,9 +83,7 @@ public RecipeBuilder weight(int weight) { } @Override - public String getErrorMsg() { - return "Error adding Actually Additions Ball Of Fur recipe"; - } + public String getErrorMsg() { return "Error adding Actually Additions Ball Of Fur recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -93,8 +92,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(weight < 0, "weight must be a non negative integer, yet it was {}", weight); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable BallOfFurReturn register() { if (!validate()) return null; BallOfFurReturn recipe = new BallOfFurReturn(output.get(0), weight); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Compost.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Compost.java index b93891fac..61dd4ed9d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Compost.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Compost.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,13 +16,9 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Compost extends VirtualizedRegistry { @@ -25,8 +28,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(ActuallyAdditionsAPI.COMPOST_RECIPES::remove); ActuallyAdditionsAPI.COMPOST_RECIPES.addAll(restoreFromBackup()); @@ -85,12 +87,10 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.COMPOST_RECIPES) - .setRemover(this::remove); + return new SimpleObjectStream<>(ActuallyAdditionsAPI.COMPOST_RECIPES).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(property = "inputDisplay", valid = @Comp(type = Comp.Type.NOT, value = "null")) @@ -111,9 +111,7 @@ public RecipeBuilder outputDisplay(IBlockState outputDisplay) { } @Override - public String getErrorMsg() { - return "Error adding Actually Additions Compost recipe"; - } + public String getErrorMsg() { return "Error adding Actually Additions Compost recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -123,8 +121,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(outputDisplay == null, "inputDisplay must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CompostRecipe register() { if (!validate()) return null; CompostRecipe recipe = new CompostRecipe(input.get(0).toMcIngredient(), inputDisplay, output.get(0), outputDisplay); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Crusher.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Crusher.java index af4f977f1..df2e556e5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Crusher.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Crusher.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,25 +14,20 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Crusher extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'), item('minecraft:diamond')).chance(100)"), - @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:diamond') * 12)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'), item('minecraft:diamond')).chance(100)"), + @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:diamond') * 12)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(ActuallyAdditionsAPI.CRUSHER_RECIPES::remove); ActuallyAdditionsAPI.CRUSHER_RECIPES.addAll(restoreFromBackup()); @@ -86,8 +86,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.CRUSHER_RECIPES) - .setRemover(this::remove); + return new SimpleObjectStream<>(ActuallyAdditionsAPI.CRUSHER_RECIPES).setRemover(this::remove); } @Property(property = "input", valid = @Comp("1")) @@ -104,9 +103,7 @@ public RecipeBuilder chance(int chance) { } @Override - public String getErrorMsg() { - return "Error adding Actually Additions Crusher recipe"; - } + public String getErrorMsg() { return "Error adding Actually Additions Crusher recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -115,11 +112,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(chance < 0 || chance > 100, "chance must be a non negative integer less than 100, yet it was {}", chance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CrusherRecipe register() { if (!validate()) return null; - CrusherRecipe recipe = new CrusherRecipe(input.get(0).toMcIngredient(), output.get(0), output.size() < 2 ? ItemStack.EMPTY : output.get(1), chance); + CrusherRecipe recipe = new CrusherRecipe(input.get(0).toMcIngredient(), output.get(0), output.size() < 2 ? + ItemStack.EMPTY : output.get(1), chance); ModSupport.ACTUALLY_ADDITIONS.get().crusher.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Empowerer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Empowerer.java index 4926f94ef..6666f1d4f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Empowerer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Empowerer.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; +import java.awt.*; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,36 +16,31 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; @RegistryDescription public class Empowerer extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".mainInput(item('minecraft:clay')).input(item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay')).output(item('minecraft:diamond')).time(50).energy(1000).red(0.5).green(0.3).blue(0.2)"), - @Example(".mainInput(item('minecraft:clay')).input(item('minecraft:diamond'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay')).output(item('minecraft:diamond') * 2).time(50).color(0.5, 0.3, 0.2)"), - @Example(".mainInput(item('minecraft:diamond')).input(item('minecraft:diamond'),item('minecraft:gold_ingot'),item('minecraft:diamond'),item('minecraft:gold_ingot')).output(item('minecraft:dirt') * 8).time(50).particleColor(0x00FF88)"), - @Example(".input(item('minecraft:gold_ingot'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay')).output(item('minecraft:diamond')).time(50)") - }) + @RecipeBuilderDescription(example = {@Example(".mainInput(item('minecraft:clay')).input(item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay')).output(item('minecraft:diamond')).time(50).energy(1000).red(0.5).green(0.3).blue(0.2)"), + @Example(".mainInput(item('minecraft:clay')).input(item('minecraft:diamond'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay')).output(item('minecraft:diamond') * 2).time(50).color(0.5, 0.3, 0.2)"), + @Example(".mainInput(item('minecraft:diamond')).input(item('minecraft:diamond'),item('minecraft:gold_ingot'),item('minecraft:diamond'),item('minecraft:gold_ingot')).output(item('minecraft:dirt') * 8).time(50).particleColor(0x00FF88)"), + @Example(".input(item('minecraft:gold_ingot'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay')).output(item('minecraft:diamond')).time(50)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(ActuallyAdditionsAPI.EMPOWERER_RECIPES::remove); ActuallyAdditionsAPI.EMPOWERER_RECIPES.addAll(restoreFromBackup()); } - public EmpowererRecipe add(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor) { - EmpowererRecipe recipe = new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor); + public EmpowererRecipe add(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, + Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor) { + EmpowererRecipe recipe = new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, + time, particleColor); add(recipe); return recipe; } @@ -86,8 +88,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.EMPOWERER_RECIPES) - .setRemover(this::remove); + return new SimpleObjectStream<>(ActuallyAdditionsAPI.EMPOWERER_RECIPES).setRemover(this::remove); } @@ -136,7 +137,9 @@ public RecipeBuilder time(int time) { @RecipeBuilderMethodDescription(field = {"red", "green", "blue"}) public RecipeBuilder particleColor(float... color) { if (color.length != 3) { - GroovyLog.get().warn("Error setting color in Actually Additions Empowerer recipe. color must contain 3 floats, yet it contained {}", color.length); + GroovyLog.get().warn( + "Error setting color in Actually Additions Empowerer recipe. color must contain 3 floats, yet it contained {}", + color.length); return this; } this.red = color[0]; @@ -185,9 +188,7 @@ public RecipeBuilder blue(float blue) { } @Override - public String getErrorMsg() { - return "Error adding Actually Additions Empowerer recipe"; - } + public String getErrorMsg() { return "Error adding Actually Additions Empowerer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -204,21 +205,14 @@ public void validate(GroovyLog.Msg msg) { msg.add(blue < 0 || blue > 1, "blue must be a float between 0 and 1, yet it was {}", blue); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable EmpowererRecipe register() { if (!validate()) return null; - EmpowererRecipe recipe = new EmpowererRecipe( - mainInput.toMcIngredient(), - output.get(0), - input.get(0).toMcIngredient(), - input.get(1).toMcIngredient(), - input.get(2).toMcIngredient(), - input.get(3).toMcIngredient(), - energyPerStand, - time, - new float[]{red, green, blue} - ); + EmpowererRecipe recipe = new EmpowererRecipe(mainInput.toMcIngredient(), output.get(0), input.get(0).toMcIngredient(), + input.get(1).toMcIngredient(), input.get(2).toMcIngredient(), input.get( + 3) + .toMcIngredient(), + energyPerStand, time, new float[]{red, green, blue}); ModSupport.ACTUALLY_ADDITIONS.get().empowerer.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/NetherMiningLens.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/NetherMiningLens.java index e6fb53896..48bbafa7a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/NetherMiningLens.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/NetherMiningLens.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,23 +10,20 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.WeightedOre; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class NetherMiningLens extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".ore(ore('blockDiamond')).weight(100)"), - @Example(".ore('blockGold').weight(100)") - }) + @RecipeBuilderDescription(example = {@Example(".ore(ore('blockDiamond')).weight(100)"), + @Example(".ore('blockGold').weight(100)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(ActuallyAdditionsAPI.NETHERRACK_ORES::remove); ActuallyAdditionsAPI.NETHERRACK_ORES.addAll(restoreFromBackup()); @@ -73,8 +72,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.NETHERRACK_ORES) - .setRemover(this::remove); + return new SimpleObjectStream<>(ActuallyAdditionsAPI.NETHERRACK_ORES).setRemover(this::remove); } @@ -104,9 +102,7 @@ public RecipeBuilder weight(int weight) { } @Override - public String getErrorMsg() { - return "Error adding Actually Additions Nether Mining Lens recipe"; - } + public String getErrorMsg() { return "Error adding Actually Additions Nether Mining Lens recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -116,8 +112,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(weight < 0, "weight must be a non negative integer, yet it was {}", weight); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable WeightedOre register() { if (!validate()) return null; WeightedOre recipe = new WeightedOre(ore, weight); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/OilGen.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/OilGen.java index c16236a90..a617ef531 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/OilGen.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/OilGen.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,25 +12,20 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class OilGen extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('water')).amount(1000).time(50)"), - @Example(".fluidInput(fluid('lava') * 50).time(100)") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('water')).amount(1000).time(50)"), + @Example(".fluidInput(fluid('lava') * 50).time(100)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES::remove); ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.addAll(restoreFromBackup()); @@ -83,8 +83,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES) - .setRemover(this::remove); + return new SimpleObjectStream<>(ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES).setRemover(this::remove); } @@ -96,8 +95,7 @@ public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.GTE, value = "0")) private int time; - @Override - @RecipeBuilderMethodDescription(field = {"fluidInput", "amount"}) + @Override @RecipeBuilderMethodDescription(field = {"fluidInput", "amount"}) public RecipeBuilder fluidInput(FluidStack fluid) { this.fluidInput.add(fluid); if (this.amount == 0) this.amount = fluid.amount; @@ -117,9 +115,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Actually Additions Oil Gen recipe"; - } + public String getErrorMsg() { return "Error adding Actually Additions Oil Gen recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -129,8 +125,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(time < 0, "time must be a non negative integer, yet it was {}", time); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable OilGenRecipe register() { if (!validate()) return null; OilGenRecipe recipe = new OilGenRecipe(fluidInput.get(0).getFluid().getName(), amount, time); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/StoneMiningLens.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/StoneMiningLens.java index 654a3a66e..961cdf5c9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/StoneMiningLens.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/StoneMiningLens.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,23 +10,20 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.WeightedOre; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class StoneMiningLens extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".ore(ore('blockDiamond')).weight(100)"), - @Example(".ore('blockGold').weight(100)") - }) + @RecipeBuilderDescription(example = {@Example(".ore(ore('blockDiamond')).weight(100)"), + @Example(".ore('blockGold').weight(100)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(ActuallyAdditionsAPI.STONE_ORES::remove); ActuallyAdditionsAPI.STONE_ORES.addAll(restoreFromBackup()); @@ -73,8 +72,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.STONE_ORES) - .setRemover(this::remove); + return new SimpleObjectStream<>(ActuallyAdditionsAPI.STONE_ORES).setRemover(this::remove); } @@ -104,9 +102,7 @@ public RecipeBuilder weight(int weight) { } @Override - public String getErrorMsg() { - return "Error adding Actually Additions Stone Mining Lens recipe"; - } + public String getErrorMsg() { return "Error adding Actually Additions Stone Mining Lens recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -116,8 +112,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(weight < 0, "weight must be a non negative integer, yet it was {}", weight); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable WeightedOre register() { if (!validate()) return null; WeightedOre recipe = new WeightedOre(ore, weight); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/TreasureChest.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/TreasureChest.java index 306fb6f61..8ac9f0c34 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/TreasureChest.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/TreasureChest.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,10 +11,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class TreasureChest extends VirtualizedRegistry { @@ -20,8 +23,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(ActuallyAdditionsAPI.TREASURE_CHEST_LOOT::remove); ActuallyAdditionsAPI.TREASURE_CHEST_LOOT.addAll(restoreFromBackup()); @@ -65,8 +67,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.TREASURE_CHEST_LOOT) - .setRemover(this::remove); + return new SimpleObjectStream<>(ActuallyAdditionsAPI.TREASURE_CHEST_LOOT).setRemover(this::remove); } @@ -99,9 +100,7 @@ public RecipeBuilder max(int max) { } @Override - public String getErrorMsg() { - return "Error adding Actually Additions Treasure Chest Loot recipe"; - } + public String getErrorMsg() { return "Error adding Actually Additions Treasure Chest Loot recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -113,8 +112,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(max < min, "max must be greater than min, yet max was {} while min was {}", max, min); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable TreasureChestLoot register() { if (!validate()) return null; TreasureChestLoot recipe = new TreasureChestLoot(output.get(0), weight, min, max); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/advancedmortars/Mortar.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/advancedmortars/Mortar.java index e8deea556..51cc452da 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/advancedmortars/Mortar.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/advancedmortars/Mortar.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.advancedmortars; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -11,80 +21,70 @@ import com.codetaylor.mc.advancedmortars.modules.mortar.api.MortarAPI; import com.codetaylor.mc.advancedmortars.modules.mortar.recipe.RecipeMortar; import com.codetaylor.mc.advancedmortars.modules.mortar.reference.EnumMortarType; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; @RegistryDescription public class Mortar extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".type('stone').duration(2).output(item('minecraft:grass')).input(item('minecraft:dirt'))"), - @Example(".type('emerald').duration(4).output(item('minecraft:wheat_seeds') * 16).secondaryOutput(item('minecraft:melon_seeds')).input(ore('cropWheat'))"), - @Example(".type('obsidian').duration(8).output(item('minecraft:wheat_seeds') * 16).secondaryOutput(item('minecraft:melon_seeds'), 0.5).input(ore('cropWheat'))"), - }) + @RecipeBuilderDescription(example = {@Example(".type('stone').duration(2).output(item('minecraft:grass')).input(item('minecraft:dirt'))"), + @Example(".type('emerald').duration(4).output(item('minecraft:wheat_seeds') * 16).secondaryOutput(item('minecraft:melon_seeds')).input(ore('cropWheat'))"), + @Example(".type('obsidian').duration(8).output(item('minecraft:wheat_seeds') * 16).secondaryOutput(item('minecraft:melon_seeds'), 0.5).input(ore('cropWheat'))"),}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { - removeScripted().forEach(recipe -> ((RegistryRecipeMortarAccessor) MortarAPI.RECIPE_REGISTRY).getRecipeMap().values().forEach(list -> list.removeIf(r -> r == recipe))); + removeScripted().forEach(recipe -> ((RegistryRecipeMortarAccessor) MortarAPI.RECIPE_REGISTRY).getRecipeMap().values() + .forEach(list -> list.removeIf(r -> r == recipe))); restoreFromBackup().forEach(recipe -> getTypes(recipe).forEach(type -> add(type, recipe))); } - @MethodDescription(description = "groovyscript.wiki.advancedmortars.mortar.add0", type = MethodDescription.Type.ADDITION, example = { - @Example("['stone'], item('minecraft:diamond') * 4, 4, [ore('ingotGold')]"), - @Example("['stone'], item('minecraft:tnt'), 4, [ore('ingotGold')]") - }) + @MethodDescription(description = "groovyscript.wiki.advancedmortars.mortar.add0", + type = MethodDescription.Type.ADDITION, + example = {@Example("['stone'], item('minecraft:diamond') * 4, 4, [ore('ingotGold')]"), + @Example("['stone'], item('minecraft:tnt'), 4, [ore('ingotGold')]")}) public void add(List types, ItemStack output, int duration, List inputs) { add(types, output, duration, ItemStack.EMPTY, 0.0f, inputs); } - @MethodDescription(description = "groovyscript.wiki.advancedmortars.mortar.add1", type = MethodDescription.Type.ADDITION, example = @Example("['iron', 'wood'], item('minecraft:tnt') * 5, 4, item('minecraft:tnt'), 0.7, [ore('ingotIron'), ore('ingotIron'), ore('ingotIron'), ore('ingotIron'),ore('ingotIron'), ore('ingotIron'), ore('ingotIron'), ore('ingotIron')]")) - public void add(List types, ItemStack output, int duration, ItemStack secondaryOutput, float secondaryOutputChance, List inputs) { + @MethodDescription(description = "groovyscript.wiki.advancedmortars.mortar.add1", + type = MethodDescription.Type.ADDITION, + example = @Example("['iron', 'wood'], item('minecraft:tnt') * 5, 4, item('minecraft:tnt'), 0.7, [ore('ingotIron'), ore('ingotIron'), ore('ingotIron'), ore('ingotIron'),ore('ingotIron'), ore('ingotIron'), ore('ingotIron'), ore('ingotIron')]")) + public void add(List types, ItemStack output, int duration, ItemStack secondaryOutput, float secondaryOutputChance, + List inputs) { if (inputs == null || inputs.isEmpty()) return; if (inputs.size() > 8) { - GroovyLog.msg("Error adding Advanced Mortars recipe") - .add("maximum number of 8 input ingredients exceeded: " + inputs.size()) - .error() - .post(); + GroovyLog.msg("Error adding Advanced Mortars recipe").add("maximum number of 8 input ingredients exceeded: " + inputs + .size()) + .error().post(); return; } for (String type : types) { EnumMortarType enumMortarType = EnumMortarType.fromName(type); if (enumMortarType == null) { - GroovyLog.msg("Error adding Advanced Mortars recipe") - .add("invalid mortar type: " + type) - .add("valid types are: " + Arrays.toString(EnumMortarType.NAMES)) - .error() - .post(); + GroovyLog.msg("Error adding Advanced Mortars recipe").add("invalid mortar type: " + type).add( + "valid types are: " + + Arrays.toString(EnumMortarType.NAMES)) + .error().post(); return; } - add(enumMortarType, new RecipeMortar(output, duration, secondaryOutput, secondaryOutputChance, IngredientHelper.toIngredientNonNullList(inputs))); + add(enumMortarType, new RecipeMortar(output, duration, secondaryOutput, secondaryOutputChance, IngredientHelper + .toIngredientNonNullList(inputs))); } } public void add(EnumMortarType type, RecipeMortar recipe) { - List list = ((RegistryRecipeMortarAccessor) MortarAPI.RECIPE_REGISTRY).getRecipeMap().computeIfAbsent(type, (k) -> new ArrayList<>()); + List list = ((RegistryRecipeMortarAccessor) MortarAPI.RECIPE_REGISTRY).getRecipeMap().computeIfAbsent(type, + (k) -> new ArrayList<>()); list.add(recipe); addScripted(recipe); } public static List getTypes(RecipeMortar recipe) { - return ((RegistryRecipeMortarAccessor) MortarAPI.RECIPE_REGISTRY) - .getRecipeMap() - .entrySet() - .stream() - .filter(x -> x.getValue().contains(recipe)) - .map(Map.Entry::getKey) - .collect(Collectors.toList()); + return ((RegistryRecipeMortarAccessor) MortarAPI.RECIPE_REGISTRY).getRecipeMap().entrySet().stream().filter(x -> x + .getValue() + .contains(recipe)) + .map(Map.Entry::getKey).collect(Collectors.toList()); } @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "8")}) @@ -180,9 +180,7 @@ public RecipeBuilder secondaryOutputChance(float chance) { } @Override - public String getErrorMsg() { - return "Error adding Advanced Mortars recipe"; - } + public String getErrorMsg() { return "Error adding Advanced Mortars recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -198,11 +196,11 @@ public void validate(GroovyLog.Msg msg) { } } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipeMortar register() { if (!validate()) return null; - RecipeMortar recipe = new RecipeMortar(output.get(0), duration, secondaryOutput, secondaryOutputChance, IngredientHelper.toIngredientNonNullList(input)); + RecipeMortar recipe = new RecipeMortar(output.get(0), duration, secondaryOutput, secondaryOutputChance, + IngredientHelper.toIngredientNonNullList(input)); types.stream().map(EnumMortarType::fromName).forEach(enumMortarType -> add(enumMortarType, recipe)); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Accessory.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Accessory.java index c25bbdf00..2deebfea7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Accessory.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Accessory.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,11 +16,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.gildedgames.the_aether.api.accessories.AccessoryType; import com.gildedgames.the_aether.api.accessories.AetherAccessory; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.GameRegistry; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; @RegistryDescription public class Accessory extends ForgeRegistryWrapper { @@ -26,10 +28,8 @@ public Accessory() { public void add(ItemStack item, String type) { AccessoryType accessoryType = EnumHelper.valueOfNullable(AccessoryType.class, type, false); if (accessoryType == null) { - GroovyLog.msg("Error adding Aether accessory") - .add("type with name {} does not exist. Valid values are {}.", type, Arrays.toString(AccessoryType.values())) - .error() - .post(); + GroovyLog.msg("Error adding Aether accessory").add("type with name {} does not exist. Valid values are {}.", type, + Arrays.toString(AccessoryType.values())).error().post(); return; } AetherAccessory accessory = new AetherAccessory(item, accessoryType); @@ -69,19 +69,17 @@ public RecipeBuilder accessoryType(AccessoryType type) { } @Override - public String getErrorMsg() { - return "Error adding Aether Accessory"; - } + public String getErrorMsg() { return "Error adding Aether Accessory"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 0, 0); validateFluids(msg); - msg.add(accessoryType == null, "type with name {} does not exist. Valid values are {}.", accessoryType.toString(), Arrays.toString(AccessoryType.values())); + msg.add(accessoryType == null, "type with name {} does not exist. Valid values are {}.", accessoryType.toString(), + Arrays.toString(AccessoryType.values())); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable AetherAccessory register() { if (!validate()) return null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Enchanter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Enchanter.java index cb95f1985..d4ceb8229 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Enchanter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Enchanter.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,9 +12,6 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.gildedgames.the_aether.api.enchantments.AetherEnchantment; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.GameRegistry; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Enchanter extends ForgeRegistryWrapper { @@ -38,8 +40,7 @@ public void removeByOutput(IIngredient output) { }); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.GTE, value = "0")) @@ -52,9 +53,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Aether Enchanter Recipe"; - } + public String getErrorMsg() { return "Error adding Aether Enchanter Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -63,8 +62,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(time < 0, "time must be a non-negative integer, yet it was {}", time); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable AetherEnchantment register() { if (!validate()) return null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/EnchanterFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/EnchanterFuel.java index 99771326a..261f0cd7c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/EnchanterFuel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/EnchanterFuel.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.gildedgames.the_aether.api.enchantments.AetherEnchantmentFuel; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.GameRegistry; @RegistryDescription public class EnchanterFuel extends ForgeRegistryWrapper { @@ -22,7 +23,8 @@ public void add(ItemStack fuel, int timeGiven) { add(enchantmentFuel); } - @MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('aether_legacy:ambrosium_shard')")) + @MethodDescription(description = "groovyscript.wiki.removeByInput", + example = @Example("item('aether_legacy:ambrosium_shard')")) public void removeByItem(IIngredient fuel) { this.getRegistry().getValuesCollection().forEach(enchantmentFuel -> { if (fuel.test(enchantmentFuel.getFuelStack())) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Freezer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Freezer.java index 5ce5a9a6c..b4b4fa0a7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Freezer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Freezer.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,9 +12,6 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.gildedgames.the_aether.api.freezables.AetherFreezable; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.GameRegistry; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Freezer extends ForgeRegistryWrapper { @@ -38,8 +40,7 @@ public void removeByOutput(IIngredient output) { }); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.GTE, value = "0")) @@ -52,9 +53,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Aether Freezer Recipe"; - } + public String getErrorMsg() { return "Error adding Aether Freezer Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -63,8 +62,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(time < 0, "time must be a non-negative integer, yet it was {}", time); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable AetherFreezable register() { if (!validate()) return null; AetherFreezable freezable = new AetherFreezable(input.get(0).getMatchingStacks()[0], output.get(0), time); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/FreezerFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/FreezerFuel.java index bcce1f42a..90d3f6f1a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/FreezerFuel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/FreezerFuel.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.gildedgames.the_aether.api.freezables.AetherFreezableFuel; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.GameRegistry; @RegistryDescription public class FreezerFuel extends ForgeRegistryWrapper { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Alchemistry.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Alchemistry.java index c00701056..c7fa1b4b1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Alchemistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Alchemistry.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.alchemistry; +import net.minecraft.item.ItemStack; + +import com.cleanroommc.groovyscript.api.Result; +import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; +import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; + import al132.alchemistry.chemistry.ChemicalCompound; import al132.alchemistry.chemistry.ChemicalElement; import al132.alchemistry.chemistry.CompoundRegistry; import al132.alchemistry.chemistry.ElementRegistry; -import com.cleanroommc.groovyscript.api.Result; -import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; -import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; -import net.minecraft.item.ItemStack; public class Alchemistry extends GroovyPropertyContainer { @@ -22,23 +24,18 @@ public class Alchemistry extends GroovyPropertyContainer { @Override public void initialize(GroovyContainer container) { - container.objectMapperBuilder("element", ItemStack.class) - .parser((s, args) -> { - String parsedName = s.trim().toLowerCase().replace(" ", "_"); - ChemicalCompound compound = CompoundRegistry.INSTANCE.get(parsedName); - if (compound == null || compound.toItemStack(1).isEmpty()) { - ChemicalElement element = ElementRegistry.INSTANCE.get(parsedName); - if (element == null || element.toItemStack(1).isEmpty()) { - return Result.error(); - } - return Result.some(element.toItemStack(1)); - } - return Result.some(compound.toItemStack(1)); - }) - .defaultValue(() -> ItemStack.EMPTY) - .completerOfNamed(CompoundRegistry.INSTANCE::compounds, ChemicalCompound::getName) - .completerOfNamed(ElementRegistry.INSTANCE::getAllElements, ChemicalElement::getName) - .docOfType("chemical element or compound as item stack") - .register(); + container.objectMapperBuilder("element", ItemStack.class).parser((s, args) -> { + String parsedName = s.trim().toLowerCase().replace(" ", "_"); + ChemicalCompound compound = CompoundRegistry.INSTANCE.get(parsedName); + if (compound == null || compound.toItemStack(1).isEmpty()) { + ChemicalElement element = ElementRegistry.INSTANCE.get(parsedName); + if (element == null || element.toItemStack(1).isEmpty()) { return Result.error(); } + return Result.some(element.toItemStack(1)); + } + return Result.some(compound.toItemStack(1)); + }).defaultValue(() -> ItemStack.EMPTY).completerOfNamed(CompoundRegistry.INSTANCE::compounds, ChemicalCompound::getName) + .completerOfNamed(ElementRegistry.INSTANCE::getAllElements, ChemicalElement::getName).docOfType( + "chemical element or compound as item stack") + .register(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Atomizer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Atomizer.java index 06d5ba3ca..d8d9806d4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Atomizer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Atomizer.java @@ -1,8 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.alchemistry; -import al132.alchemistry.recipes.AtomizerRecipe; -import al132.alchemistry.recipes.LiquifierRecipe; -import al132.alchemistry.recipes.ModRecipes; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,9 +12,10 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; + +import al132.alchemistry.recipes.AtomizerRecipe; +import al132.alchemistry.recipes.LiquifierRecipe; +import al132.alchemistry.recipes.ModRecipes; @RegistryDescription public class Atomizer extends VirtualizedRegistry { @@ -23,10 +26,8 @@ public void onReload() { ModRecipes.INSTANCE.getAtomizerRecipes().addAll(restoreFromBackup()); } - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('water') * 125).output(item('minecraft:clay'))"), - @Example(".fluidInput(fluid('lava') * 500).output(item('minecraft:gold_ingot')).reversible()") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('water') * 125).output(item('minecraft:clay'))"), + @Example(".fluidInput(fluid('lava') * 500).output(item('minecraft:gold_ingot')).reversible()")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -85,8 +86,7 @@ public void removeAll() { ModRecipes.INSTANCE.getAtomizerRecipes().clear(); } - @Property(property = "fluidInput", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -105,9 +105,7 @@ public RecipeBuilder reversible() { } @Override - public String getErrorMsg() { - return "Error adding Alchemistry Atomizer recipe"; - } + public String getErrorMsg() { return "Error adding Alchemistry Atomizer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -115,9 +113,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 1, 1, 0, 0); } - @Nullable - @Override - @RecipeBuilderRegistrationMethod + @Nullable @Override @RecipeBuilderRegistrationMethod public AtomizerRecipe register() { if (!validate()) return null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Combiner.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Combiner.java index cfa72919c..7ca0c1c9f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Combiner.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Combiner.java @@ -1,7 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.alchemistry; -import al132.alchemistry.recipes.CombinerRecipe; -import al132.alchemistry.recipes.ModRecipes; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -11,11 +16,9 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.List; -import java.util.stream.Collectors; +import al132.alchemistry.recipes.CombinerRecipe; +import al132.alchemistry.recipes.ModRecipes; @RegistryDescription public class Combiner extends VirtualizedRegistry { @@ -30,10 +33,8 @@ public void onReload() { ModRecipes.INSTANCE.getCombinerRecipes().addAll(restoreFromBackup()); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2).output(item('minecraft:gold_block') * 2)"), - @Example(".input(ItemStack.EMPTY, ItemStack.EMPTY, item('minecraft:clay')).output(item('minecraft:gold_ingot'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2, item('minecraft:gold_ingot') * 2).output(item('minecraft:gold_block') * 2)"), + @Example(".input(ItemStack.EMPTY, ItemStack.EMPTY, item('minecraft:clay')).output(item('minecraft:gold_ingot'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -103,9 +104,7 @@ public RecipeBuilder gamestage(String gamestage) { } @Override - public String getErrorMsg() { - return "Error adding Alchemistry Combiner recipe"; - } + public String getErrorMsg() { return "Error adding Alchemistry Combiner recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -116,12 +115,12 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CombinerRecipe register() { if (!validate()) return null; - List inputs = input.stream().map(x -> x.isEmpty() ? ItemStack.EMPTY : IngredientHelper.toItemStack(x)).collect(Collectors.toList()); + List inputs = input.stream().map(x -> x.isEmpty() ? ItemStack.EMPTY : IngredientHelper.toItemStack(x)) + .collect(Collectors.toList()); CombinerRecipe recipe = new CombinerRecipe(output.get(0), inputs, gamestage); ModSupport.ALCHEMISTRY.get().combiner.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Dissolver.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Dissolver.java index fe29545dd..68e278e4f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Dissolver.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Dissolver.java @@ -1,6 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.alchemistry; -import al132.alchemistry.recipes.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,14 +18,8 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; +import al132.alchemistry.recipes.*; @RegistryDescription public class Dissolver extends VirtualizedRegistry { @@ -31,10 +34,8 @@ public void onReload() { ModRecipes.INSTANCE.getDissolverRecipes().addAll(restoreFromBackup()); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:gold_ingot')).probabilityOutput(item('minecraft:clay')).reversible().rolls(1)"), - @Example(".input(item('minecraft:diamond')).probabilityOutput(30, item('minecraft:clay')).probabilityOutput(30, item('minecraft:clay')).probabilityOutput(30, item('minecraft:clay')).rolls(10)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:gold_ingot')).probabilityOutput(item('minecraft:clay')).reversible().rolls(1)"), + @Example(".input(item('minecraft:diamond')).probabilityOutput(30, item('minecraft:clay')).probabilityOutput(30, item('minecraft:clay')).probabilityOutput(30, item('minecraft:clay')).rolls(10)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -79,8 +80,7 @@ public void removeAll() { ModRecipes.INSTANCE.getDissolverRecipes().clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "1", type = Comp.Type.GTE)) @@ -114,14 +114,12 @@ public RecipeBuilder probabilityOutput(Collection probabilityOutputs) return this.probabilityOutput(100, probabilityOutputs); } - @Override - @RecipeBuilderMethodDescription(field = "probabilityGroup") + @Override @RecipeBuilderMethodDescription(field = "probabilityGroup") public RecipeBuilder output(ItemStack... probabilityOutputs) { return this.probabilityOutput(100, probabilityOutputs); } - @Override - @RecipeBuilderMethodDescription(field = "probabilityGroup") + @Override @RecipeBuilderMethodDescription(field = "probabilityGroup") public RecipeBuilder output(Collection probabilityOutputs) { return this.probabilityOutput(100, probabilityOutputs); } @@ -157,9 +155,7 @@ public RecipeBuilder rolls(int rolls) { } @Override - public String getErrorMsg() { - return "Error adding Alchemistry Dissolver recipe"; - } + public String getErrorMsg() { return "Error adding Alchemistry Dissolver recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -169,15 +165,20 @@ public void validate(GroovyLog.Msg msg) { msg.add(rolls < 1, "rolls must be greater than or equal to 1, yet it was {}", rolls); } - @Nullable - @Override - @RecipeBuilderRegistrationMethod + @Nullable @Override @RecipeBuilderRegistrationMethod public DissolverRecipe register() { if (!validate()) return null; - DissolverRecipe recipe = new DissolverRecipe(input.get(0).toMcIngredient(), false, new ProbabilitySet(probabilityGroup, relativeProbability, rolls)); + DissolverRecipe recipe = new DissolverRecipe(input.get(0).toMcIngredient(), false, new ProbabilitySet( + probabilityGroup, + relativeProbability, + rolls)); if (reversible) { - ModSupport.ALCHEMISTRY.get().combiner.add(new CombinerRecipe(recipe.getInputs().get(0), probabilityGroup.stream().map(ProbabilityGroup::getOutput).flatMap(Collection::stream).collect(Collectors.toList()), "")); + ModSupport.ALCHEMISTRY.get().combiner.add(new CombinerRecipe(recipe.getInputs().get(0), probabilityGroup.stream() + .map(ProbabilityGroup::getOutput) + .flatMap(Collection::stream) + .collect(Collectors.toList()), + "")); } ModSupport.ALCHEMISTRY.get().dissolver.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Electrolyzer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Electrolyzer.java index 66e038961..7a4e8ae29 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Electrolyzer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Electrolyzer.java @@ -1,7 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.alchemistry; -import al132.alchemistry.recipes.ElectrolyzerRecipe; -import al132.alchemistry.recipes.ModRecipes; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,13 +15,10 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; -import java.util.Collection; +import al132.alchemistry.recipes.ElectrolyzerRecipe; +import al132.alchemistry.recipes.ModRecipes; +import it.unimi.dsi.fastutil.ints.IntArrayList; @RegistryDescription public class Electrolyzer extends VirtualizedRegistry { @@ -26,10 +29,8 @@ public void onReload() { ModRecipes.INSTANCE.getElectrolyzerRecipes().addAll(restoreFromBackup()); } - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('lava') * 100).output(item('minecraft:clay'))"), - @Example(".fluidInput(fluid('water') * 100).input(item('minecraft:gold_ingot')).consumptionChance(100).output(item('minecraft:gold_nugget') * 4).output(item('minecraft:gold_nugget') * 4).output(item('minecraft:gold_nugget') * 4).output(item('minecraft:gold_nugget') * 4).chance(50).chance(50)") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('lava') * 100).output(item('minecraft:clay'))"), + @Example(".fluidInput(fluid('water') * 100).input(item('minecraft:gold_ingot')).consumptionChance(100).output(item('minecraft:gold_nugget') * 4).output(item('minecraft:gold_nugget') * 4).output(item('minecraft:gold_nugget') * 4).output(item('minecraft:gold_nugget') * 4).chance(50).chance(50)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -143,28 +144,29 @@ public RecipeBuilder consumptionChance(int consumptionChance) { } @Override - public String getErrorMsg() { - return "Error adding Alchemistry Electrolyzer recipe"; - } + public String getErrorMsg() { return "Error adding Alchemistry Electrolyzer recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 0, 1, 1, 4); validateFluids(msg, 1, 1, 0, 0); validateCustom(msg, chance, 0, 2, "chance"); - msg.add(!chance.isEmpty() && chance.size() > (output.size() - 2), "chance only applies to output items after the second, cannot have more chance than output items above 2, had {} chance and {} output", chance.size(), output.size()); - msg.add(consumptionChance < 0 || consumptionChance > 100, "consumption chance must be between 0 and 100, yet it was {}", consumptionChance); + msg.add(!chance.isEmpty() && chance.size() > (output.size() - 2), + "chance only applies to output items after the second, cannot have more chance than output items above 2, had {} chance and {} output", + chance.size(), output.size()); + msg.add(consumptionChance < 0 || consumptionChance > 100, + "consumption chance must be between 0 and 100, yet it was {}", consumptionChance); } - @Nullable - @Override - @RecipeBuilderRegistrationMethod + @Nullable @Override @RecipeBuilderRegistrationMethod public ElectrolyzerRecipe register() { if (!validate()) return null; - ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(fluidInput.get(0), - input.size() >= 1 ? input.get(0).toMcIngredient() : Ingredient.EMPTY, consumptionChance, - output.get(0), output.getOrEmpty(1), - output.getOrEmpty(2), chance.size() >= 1 ? chance.getInt(0) : 0, + ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(fluidInput.get(0), input.size() >= 1 ? input.get(0) + .toMcIngredient() : + Ingredient.EMPTY, consumptionChance, output.get(0), output.getOrEmpty(1), output.getOrEmpty(2), chance + .size() >= 1 ? + chance.getInt(0) : + 0, output.getOrEmpty(3), chance.size() >= 2 ? chance.getInt(1) : 0); ModSupport.ALCHEMISTRY.get().electrolyzer.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Evaporator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Evaporator.java index 2c73139c1..5b1e2a2d9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Evaporator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Evaporator.java @@ -1,7 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.alchemistry; -import al132.alchemistry.recipes.EvaporatorRecipe; -import al132.alchemistry.recipes.ModRecipes; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,9 +12,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; + +import al132.alchemistry.recipes.EvaporatorRecipe; +import al132.alchemistry.recipes.ModRecipes; @RegistryDescription public class Evaporator extends VirtualizedRegistry { @@ -22,10 +25,8 @@ public void onReload() { ModRecipes.INSTANCE.getEvaporatorRecipes().addAll(restoreFromBackup()); } - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('lava') * 100).output(item('minecraft:redstone') * 8)"), - @Example(".fluidInput(fluid('water') * 10).output(item('minecraft:clay'))") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('lava') * 100).output(item('minecraft:redstone') * 8)"), + @Example(".fluidInput(fluid('water') * 10).output(item('minecraft:clay'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -84,14 +85,11 @@ public void removeAll() { ModRecipes.INSTANCE.getEvaporatorRecipes().clear(); } - @Property(property = "fluidInput", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Alchemistry Evaporator recipe"; - } + public String getErrorMsg() { return "Error adding Alchemistry Evaporator recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,9 +97,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 1, 1, 0, 0); } - @Nullable - @Override - @RecipeBuilderRegistrationMethod + @Nullable @Override @RecipeBuilderRegistrationMethod public EvaporatorRecipe register() { if (!validate()) return null; EvaporatorRecipe recipe = new EvaporatorRecipe(fluidInput.get(0), output.get(0)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Liquifier.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Liquifier.java index bddf605af..eb819b71e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Liquifier.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Liquifier.java @@ -1,7 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.alchemistry; -import al132.alchemistry.recipes.LiquifierRecipe; -import al132.alchemistry.recipes.ModRecipes; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,8 +12,9 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; + +import al132.alchemistry.recipes.LiquifierRecipe; +import al132.alchemistry.recipes.ModRecipes; @RegistryDescription public class Liquifier extends VirtualizedRegistry { @@ -22,10 +25,8 @@ public void onReload() { ModRecipes.INSTANCE.getLiquifierRecipes().addAll(restoreFromBackup()); } - @RecipeBuilderDescription(example = { - @Example(".input(element('carbon') * 32).fluidOutput(fluid('water') * 1000)"), - @Example(".input(item('minecraft:magma')).fluidOutput(fluid('lava') * 750)") - }) + @RecipeBuilderDescription(example = {@Example(".input(element('carbon') * 32).fluidOutput(fluid('water') * 1000)"), + @Example(".input(item('minecraft:magma')).fluidOutput(fluid('lava') * 750)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -84,14 +85,11 @@ public void removeAll() { ModRecipes.INSTANCE.getLiquifierRecipes().clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "fluidOutput", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Alchemistry Liquifier recipe"; - } + public String getErrorMsg() { return "Error adding Alchemistry Liquifier recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,9 +97,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 0, 0, 1, 1); } - @Nullable - @Override - @RecipeBuilderRegistrationMethod + @Nullable @Override @RecipeBuilderRegistrationMethod public LiquifierRecipe register() { if (!validate()) return null; LiquifierRecipe recipe = new LiquifierRecipe(IngredientHelper.toItemStack(input.get(0)), fluidOutput.get(0)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/AppliedEnergistics2.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/AppliedEnergistics2.java index fdaafb371..059acb78b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/AppliedEnergistics2.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/AppliedEnergistics2.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.appliedenergistics2; -import appeng.api.config.TunnelType; +import java.util.Arrays; +import java.util.Locale; + import com.cleanroommc.groovyscript.api.IObjectParser; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; -import java.util.Arrays; -import java.util.Locale; +import appeng.api.config.TunnelType; public class AppliedEnergistics2 extends GroovyPropertyContainer { @@ -18,10 +19,9 @@ public class AppliedEnergistics2 extends GroovyPropertyContainer { @Override public void initialize(GroovyContainer container) { - container.objectMapperBuilder("tunnel", TunnelType.class) - .parser(IObjectParser.wrapEnum(TunnelType.class, false)) - .completerOfNamed(() -> Arrays.asList(TunnelType.values()), v -> v.name().toUpperCase(Locale.ROOT)) - .docOfType("P2P tunnel type") - .register(); + container.objectMapperBuilder("tunnel", TunnelType.class).parser(IObjectParser.wrapEnum(TunnelType.class, false)) + .completerOfNamed(() -> Arrays.asList(TunnelType.values()), v -> v.name().toUpperCase(Locale.ROOT)).docOfType( + "P2P tunnel type") + .register(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Attunement.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Attunement.java index 112aff676..770d0abba 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Attunement.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Attunement.java @@ -1,18 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.appliedenergistics2; -import appeng.api.AEApi; -import appeng.api.config.TunnelType; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.capabilities.Capability; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.appliedenergistics2.P2PTunnelRegistryAccessor; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.capabilities.Capability; -import org.apache.commons.lang3.tuple.Pair; -import java.util.Map; -import java.util.stream.Collectors; +import appeng.api.AEApi; +import appeng.api.config.TunnelType; @RegistryDescription public class Attunement extends VirtualizedRegistry> { @@ -21,11 +24,16 @@ public class Attunement extends VirtualizedRegistry> { public void onReload() { removeScripted().forEach(pair -> { if (pair.getKey() instanceof ItemStack) { - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().entrySet().removeIf(x -> x.getKey().isItemEqual((ItemStack) pair.getKey()) && x.getValue() == pair.getValue()); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().entrySet().removeIf(x -> x + .getKey() + .isItemEqual((ItemStack) pair.getKey()) && x.getValue() == pair.getValue()); } else if (pair.getKey() instanceof String) { - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().entrySet().removeIf(x -> x.getKey().equals(pair.getKey()) && x.getValue() == pair.getValue()); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().entrySet().removeIf( + x -> x.getKey() + .equals(pair.getKey()) && x.getValue() == pair.getValue()); } else if (pair.getKey() instanceof Capability) { - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().entrySet().removeIf(x -> x.getKey() == pair.getKey() && x.getValue() == pair.getValue()); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().entrySet().removeIf(x -> x + .getKey() == pair.getKey() && x.getValue() == pair.getValue()); } }); restoreFromBackup().forEach(pair -> { @@ -39,107 +47,152 @@ public void onReload() { }); } - @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.add0", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay'), tunnel('item')")) + @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.add0", + type = MethodDescription.Type.ADDITION, + example = @Example("item('minecraft:clay'), tunnel('item')")) public void add(ItemStack item, TunnelType tunnel) { addScripted(Pair.of(item, tunnel)); AEApi.instance().registries().p2pTunnel().addNewAttunement(item, tunnel); } - @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.add1", type = MethodDescription.Type.ADDITION, example = @Example("'thermaldynamics', tunnel('redstone')")) + @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.add1", + type = MethodDescription.Type.ADDITION, + example = @Example("'thermaldynamics', tunnel('redstone')")) public void add(String modid, TunnelType tunnel) { addScripted(Pair.of(modid, tunnel)); AEApi.instance().registries().p2pTunnel().addNewAttunement(modid, tunnel); } - @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.add2", type = MethodDescription.Type.ADDITION, example = @Example(value = "Capabilities.FORGE_ENERGY, tunnel('item')", imports = "appeng.capabilities.Capabilities")) + @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.add2", + type = MethodDescription.Type.ADDITION, + example = @Example(value = "Capabilities.FORGE_ENERGY, tunnel('item')", + imports = "appeng.capabilities.Capabilities")) public void add(Capability capability, TunnelType tunnel) { addScripted(Pair.of(capability, tunnel)); AEApi.instance().registries().p2pTunnel().addNewAttunement(capability, tunnel); } - @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.remove0", example = @Example("item('minecraft:lever'), tunnel('redstone')")) + @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.remove0", + example = @Example("item('minecraft:lever'), tunnel('redstone')")) public void remove(ItemStack item, TunnelType tunnel) { addBackup(Pair.of(item, tunnel)); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().entrySet().removeIf(x -> x.getKey().isItemEqual(item) && x.getValue() == tunnel); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().entrySet().removeIf(x -> x.getKey() + .isItemEqual(item) && x.getValue() == tunnel); } - @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.remove1", example = @Example("'thermaldynamics', tunnel('fe_power')")) + @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.remove1", + example = @Example("'thermaldynamics', tunnel('fe_power')")) public void remove(String modid, TunnelType tunnel) { addBackup(Pair.of(modid, tunnel)); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().entrySet().removeIf(x -> x.getKey().equals(modid) && x.getValue() == tunnel); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().entrySet().removeIf(x -> x + .getKey() + .equals(modid) && x.getValue() == tunnel); } - @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.remove2", example = @Example(value = "Capabilities.FORGE_ENERGY, tunnel('fe_power')", imports = "appeng.capabilities.Capabilities")) + @MethodDescription(description = "groovyscript.wiki.appliedenergistics2.attunement.remove2", + example = @Example(value = "Capabilities.FORGE_ENERGY, tunnel('fe_power')", + imports = "appeng.capabilities.Capabilities")) public void remove(Capability capability, TunnelType tunnel) { addBackup(Pair.of(capability, tunnel)); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().entrySet().removeIf(x -> x.getKey() == capability && x.getValue() == tunnel); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().entrySet().removeIf(x -> x + .getKey() == capability && x.getValue() == tunnel); } @MethodDescription public void removeByItem(ItemStack item) { - for (Map.Entry pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().entrySet() - .stream() - .filter(x -> x.getKey().isItemEqual(item)) - .collect(Collectors.toList())) { + for (Map.Entry pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()) + .getTunnels() + .entrySet() + .stream() + .filter(x -> x.getKey() + .isItemEqual(item)) + .collect(Collectors.toList())) { addBackup(Pair.of(pair.getKey(), pair.getValue())); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().entrySet().removeIf(x -> x.getKey().isItemEqual(pair.getKey())); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().entrySet().removeIf(x -> x + .getKey() + .isItemEqual(pair.getKey())); } } @MethodDescription public void removeByMod(String modid) { - for (Map.Entry pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().entrySet() - .stream() - .filter(x -> x.getKey().equals(modid)) - .collect(Collectors.toList())) { + for (Map.Entry pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()) + .getModIdTunnels() + .entrySet() + .stream() + .filter(x -> x.getKey() + .equals(modid)) + .collect(Collectors.toList())) { addBackup(Pair.of(pair.getKey(), pair.getValue())); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().entrySet().removeIf(x -> x.getKey().equals(pair.getKey())); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().entrySet().removeIf(x -> x + .getKey() + .equals(pair.getKey())); } } @MethodDescription public void removeByCapability(Capability capability) { - for (Map.Entry, TunnelType> pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().entrySet() - .stream() - .filter(x -> x.getKey() == capability) - .collect(Collectors.toList())) { + for (Map.Entry, TunnelType> pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()) + .getCapTunnels() + .entrySet() + .stream() + .filter(x -> x.getKey() == capability) + .collect(Collectors.toList())) { addBackup(Pair.of(pair.getKey(), pair.getValue())); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().entrySet().removeIf(x -> x.getKey() == pair.getKey()); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().entrySet().removeIf(x -> x + .getKey() == pair.getKey()); } } @MethodDescription(example = @Example("tunnel('item')")) public void removeByTunnel(TunnelType tunnel) { - for (Map.Entry pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().entrySet() - .stream() - .filter(x -> x.getValue() == tunnel) - .collect(Collectors.toList())) { + for (Map.Entry pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()) + .getTunnels() + .entrySet() + .stream() + .filter(x -> x.getValue() == tunnel) + .collect(Collectors.toList())) { addBackup(Pair.of(pair.getKey(), pair.getValue())); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().entrySet().removeIf(x -> x.getKey().isItemEqual(pair.getKey())); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().entrySet().removeIf(x -> x + .getKey() + .isItemEqual(pair.getKey())); } - for (Map.Entry pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().entrySet() - .stream() - .filter(x -> x.getValue() == tunnel) - .collect(Collectors.toList())) { + for (Map.Entry pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()) + .getModIdTunnels() + .entrySet() + .stream() + .filter(x -> x.getValue() == tunnel) + .collect(Collectors.toList())) { addBackup(Pair.of(pair.getKey(), pair.getValue())); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().entrySet().removeIf(x -> x.getKey().equals(pair.getKey())); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().entrySet().removeIf(x -> x + .getKey() + .equals(pair.getKey())); } - for (Map.Entry, TunnelType> pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().entrySet() - .stream() - .filter(x -> x.getValue() == tunnel) - .collect(Collectors.toList())) { + for (Map.Entry, TunnelType> pair : ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()) + .getCapTunnels() + .entrySet() + .stream() + .filter(x -> x.getValue() == tunnel) + .collect(Collectors.toList())) { addBackup(Pair.of(pair.getKey(), pair.getValue())); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().entrySet().removeIf(x -> x.getKey() == pair.getKey()); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().entrySet().removeIf(x -> x + .getKey() == pair.getKey()); } } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().forEach((item, value) -> addBackup(Pair.of(item, value))); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().forEach((item, value) -> addBackup( + Pair.of(item, + value))); ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getTunnels().clear(); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().forEach((item, value) -> addBackup(Pair.of(item, value))); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().forEach((item, + value) -> addBackup(Pair.of(item, + value))); ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getModIdTunnels().clear(); - ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().forEach((item, value) -> addBackup(Pair.of(item, value))); + ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().forEach((item, + value) -> addBackup(Pair.of(item, + value))); ((P2PTunnelRegistryAccessor) AEApi.instance().registries().p2pTunnel()).getCapTunnels().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/CannonAmmo.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/CannonAmmo.java index 6c3f0bca5..d599fc2a6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/CannonAmmo.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/CannonAmmo.java @@ -1,18 +1,19 @@ package com.cleanroommc.groovyscript.compat.mods.appliedenergistics2; -import appeng.api.AEApi; +import net.minecraft.item.ItemStack; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.appliedenergistics2.MatterCannonAmmoRegistryAccessor; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.apache.commons.lang3.tuple.Pair; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES -) +import appeng.api.AEApi; + +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class CannonAmmo extends VirtualizedRegistry> { public CannonAmmo() { @@ -21,8 +22,15 @@ public CannonAmmo() { @Override public void onReload() { - removeScripted().forEach(pair -> ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()).getDamageModifiers().entrySet().removeIf(x -> ItemStack.areItemStacksEqual(x.getKey(), pair.getKey()))); - restoreFromBackup().forEach(pair -> ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()).getDamageModifiers().put(pair.getKey(), pair.getValue())); + removeScripted().forEach(pair -> ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()) + .getDamageModifiers() + .entrySet() + .removeIf(x -> ItemStack.areItemStacksEqual(x.getKey(), + pair.getKey()))); + restoreFromBackup().forEach(pair -> ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()) + .getDamageModifiers() + .put(pair.getKey(), + pair.getValue())); } @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay'), 10000")) @@ -33,13 +41,19 @@ public void add(ItemStack item, double value) { @MethodDescription(example = @Example("item('minecraft:gold_nugget')")) public void remove(ItemStack item) { - addBackup(Pair.of(item, ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()).getDamageModifiers().get(item))); - ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()).getDamageModifiers().entrySet().removeIf(x -> ItemStack.areItemStacksEqual(x.getKey(), item)); + addBackup(Pair.of(item, ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()) + .getDamageModifiers() + .get(item))); + ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()).getDamageModifiers().entrySet() + .removeIf(x -> ItemStack.areItemStacksEqual(x.getKey(), + item)); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()).getDamageModifiers().forEach((item, value) -> addBackup(Pair.of(item, value))); + ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()).getDamageModifiers().forEach((item, + value) -> addBackup(Pair.of(item, + value))); ((MatterCannonAmmoRegistryAccessor) AEApi.instance().registries().matterCannon()).getDamageModifiers().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Grinder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Grinder.java index a33e90a03..82023ac95 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Grinder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Grinder.java @@ -1,29 +1,30 @@ package com.cleanroommc.groovyscript.compat.mods.appliedenergistics2; -import appeng.api.AEApi; -import appeng.api.features.IGrinderRecipe; -import appeng.api.features.IGrinderRecipeBuilder; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; +import appeng.api.AEApi; +import appeng.api.features.IGrinderRecipe; +import appeng.api.features.IGrinderRecipeBuilder; @RegistryDescription public class Grinder extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'), item('minecraft:gold_ingot'), item('minecraft:diamond')).turns(1).chance1(0.5).chance2(0.3)"), - @Example(".input(item('minecraft:stone')).output(item('minecraft:clay') * 4).turns(10)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'), item('minecraft:gold_ingot'), item('minecraft:diamond')).turns(1).chance1(0.5).chance2(0.3)"), + @Example(".input(item('minecraft:stone')).output(item('minecraft:clay') * 4).turns(10)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -46,7 +47,10 @@ public void remove(IGrinderRecipe recipe) { @MethodDescription(example = @Example("item('minecraft:gold_ingot')")) public void removeByInput(ItemStack input) { - List recipes = AEApi.instance().registries().grinder().getRecipes().stream().filter(x -> ItemStack.areItemStacksEqual(x.getInput(), input)).collect(Collectors.toList()); + List recipes = AEApi.instance().registries().grinder().getRecipes().stream().filter(x -> ItemStack + .areItemStacksEqual(x.getInput(), + input)) + .collect(Collectors.toList()); for (IGrinderRecipe recipe : recipes) { AEApi.instance().registries().grinder().removeRecipe(recipe); addBackup(recipe); @@ -55,7 +59,10 @@ public void removeByInput(ItemStack input) { @MethodDescription(example = @Example("item('minecraft:quartz')")) public void removeByOutput(ItemStack output) { - List recipes = AEApi.instance().registries().grinder().getRecipes().stream().filter(x -> ItemStack.areItemStacksEqual(x.getOutput(), output)).collect(Collectors.toList()); + List recipes = AEApi.instance().registries().grinder().getRecipes().stream().filter(x -> ItemStack + .areItemStacksEqual(x.getOutput(), + output)) + .collect(Collectors.toList()); for (IGrinderRecipe recipe : recipes) { AEApi.instance().registries().grinder().removeRecipe(recipe); addBackup(recipe); @@ -77,9 +84,11 @@ public static class RecipeBuilder extends AbstractRecipeBuilder @Property(valid = @Comp(value = "0", type = Comp.Type.GT)) private int turns; - @Property(defaultValue = "1.0f", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(defaultValue = "1.0f", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) private float chance1 = 1.0f; - @Property(defaultValue = "1.0f", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(defaultValue = "1.0f", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) private float chance2 = 1.0f; @@ -109,27 +118,26 @@ public RecipeBuilder chance2(float chance) { } @Override - public String getErrorMsg() { - return "Error adding Applied Energistics 2 Grinder recipe"; - } + public String getErrorMsg() { return "Error adding Applied Energistics 2 Grinder recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 3); validateFluids(msg); msg.add(turns <= 0, "turns must be an integer greater than 0, yet it was {}", turns); - msg.add(chance1 < 0 || chance1 > 1, "chance1 must be a float greater than or equal to 0 and less than or equal to 1, yet it was {}", chance1); - msg.add(chance2 < 0 || chance2 > 1, "chance2 must be a float greater than or equal to 0 and less than or equal to 1, yet it was {}", chance2); + msg.add(chance1 < 0 || chance1 > 1, + "chance1 must be a float greater than or equal to 0 and less than or equal to 1, yet it was {}", chance1); + msg.add(chance2 < 0 || chance2 > 1, + "chance2 must be a float greater than or equal to 0 and less than or equal to 1, yet it was {}", chance2); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IGrinderRecipe register() { if (!validate()) return null; - IGrinderRecipeBuilder builder = AEApi.instance().registries().grinder().builder() - .withInput(input.get(0).toMcIngredient().getMatchingStacks()[0]) - .withOutput(output.get(0)) - .withTurns(turns); + IGrinderRecipeBuilder builder = AEApi.instance().registries().grinder().builder().withInput(input.get(0) + .toMcIngredient() + .getMatchingStacks()[0]) + .withOutput(output.get(0)).withTurns(turns); if (output.size() > 1 && !IngredientHelper.isEmpty(output.get(1))) builder.withFirstOptional(output.get(1), chance1); if (output.size() > 2 && !IngredientHelper.isEmpty(output.get(2))) builder.withSecondOptional(output.get(2), chance2); IGrinderRecipe recipe = builder.build(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Inscriber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Inscriber.java index eb2c2b25e..fad0c3a71 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Inscriber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Inscriber.java @@ -1,28 +1,29 @@ package com.cleanroommc.groovyscript.compat.mods.appliedenergistics2; -import appeng.api.AEApi; -import appeng.api.features.IInscriberRecipe; -import appeng.api.features.IInscriberRecipeBuilder; -import appeng.api.features.InscriberProcessType; +import java.util.*; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.stream.Collectors; +import appeng.api.AEApi; +import appeng.api.features.IInscriberRecipe; +import appeng.api.features.IInscriberRecipeBuilder; +import appeng.api.features.InscriberProcessType; @RegistryDescription public class Inscriber extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(ore('blockGlass')).output(item('minecraft:diamond')).top(item('minecraft:diamond')).bottom(item('minecraft:diamond')).inscribe()"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).top(item('minecraft:diamond'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(ore('blockGlass')).output(item('minecraft:diamond')).top(item('minecraft:diamond')).bottom(item('minecraft:diamond')).inscribe()"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).top(item('minecraft:diamond'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -45,7 +46,10 @@ public void remove(IInscriberRecipe recipe) { @MethodDescription(example = @Example("item('appliedenergistics2:material:59')")) public void removeByOutput(ItemStack output) { - List recipes = AEApi.instance().registries().inscriber().getRecipes().stream().filter(x -> ItemStack.areItemStacksEqual(x.getOutput(), output)).collect(Collectors.toList()); + List recipes = AEApi.instance().registries().inscriber().getRecipes().stream().filter(x -> ItemStack + .areItemStacksEqual(x.getOutput(), + output)) + .collect(Collectors.toList()); for (IInscriberRecipe recipe : recipes) { AEApi.instance().registries().inscriber().removeRecipe(recipe); addBackup(recipe); @@ -62,15 +66,16 @@ public void removeAll() { } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "InscriberProcessType.PRESS", valid = @Comp(value = "null", type = Comp.Type.NOT)) private InscriberProcessType type = InscriberProcessType.PRESS; - @Property(defaultValue = "ItemStack.EMPTY", requirement = "groovyscript.wiki.appliedenergistics2.inscriber.top_bottom.required") + @Property(defaultValue = "ItemStack.EMPTY", + requirement = "groovyscript.wiki.appliedenergistics2.inscriber.top_bottom.required") private ItemStack top = ItemStack.EMPTY; - @Property(defaultValue = "ItemStack.EMPTY", requirement = "groovyscript.wiki.appliedenergistics2.inscriber.top_bottom.required") + @Property(defaultValue = "ItemStack.EMPTY", + requirement = "groovyscript.wiki.appliedenergistics2.inscriber.top_bottom.required") private ItemStack bottom = ItemStack.EMPTY; @@ -111,26 +116,25 @@ public RecipeBuilder bottom(ItemStack bottom) { } @Override - public String getErrorMsg() { - return "Error adding Applied Energistics 2 Inscriber recipe"; - } + public String getErrorMsg() { return "Error adding Applied Energistics 2 Inscriber recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); validateFluids(msg); msg.add(type == null, "type must be defined"); - msg.add(IngredientHelper.isEmpty(top) && IngredientHelper.isEmpty(bottom), "either top or bottom must be defined, yet neither were"); + msg.add(IngredientHelper.isEmpty(top) && IngredientHelper.isEmpty(bottom), + "either top or bottom must be defined, yet neither were"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IInscriberRecipe register() { if (!validate()) return null; - IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder() - .withInputs(input.stream().flatMap(x -> Arrays.stream(x.toMcIngredient().getMatchingStacks())).collect(Collectors.toList())) - .withOutput(output.get(0)) - .withProcessType(type); + IInscriberRecipeBuilder builder = AEApi.instance().registries().inscriber().builder().withInputs(input.stream() + .flatMap(x -> Arrays.stream(x.toMcIngredient() + .getMatchingStacks())) + .collect(Collectors.toList())) + .withOutput(output.get(0)).withProcessType(type); if (!IngredientHelper.isEmpty(top)) builder.withTopOptional(top); if (!IngredientHelper.isEmpty(bottom)) builder.withBottomOptional(bottom); IInscriberRecipe recipe = builder.build(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Spatial.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Spatial.java index 56da1d435..ed98e0f91 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Spatial.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/appliedenergistics2/Spatial.java @@ -1,17 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.appliedenergistics2; -import appeng.api.AEApi; +import net.minecraft.tileentity.TileEntity; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.appliedenergistics2.MovableTileRegistryAccessor; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.tileentity.TileEntity; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES -) +import appeng.api.AEApi; + +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Spatial extends VirtualizedRegistry> { @Override @@ -25,7 +25,8 @@ public void afterScriptLoad() { ((MovableTileRegistryAccessor) AEApi.instance().registries().movable()).getValid().clear(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'net.minecraft.tileentity.TileEntityStructure'")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'net.minecraft.tileentity.TileEntityStructure'")) public void add(String className) { add(loadClass(className)); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/arcanearchives/GemCuttingTable.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/arcanearchives/GemCuttingTable.java index 08a900b6e..45242f4dc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/arcanearchives/GemCuttingTable.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/arcanearchives/GemCuttingTable.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.arcanearchives; +import java.util.Arrays; +import java.util.stream.Collectors; + +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.aranaira.arcanearchives.api.IGCTRecipe; import com.aranaira.arcanearchives.recipe.IngredientStack; import com.aranaira.arcanearchives.recipe.gct.GCTRecipe; @@ -12,23 +19,17 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.stream.Collectors; -@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.arcanearchives.gem_cutting_table.note0", type = Admonition.Type.WARNING)) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.arcanearchives.gem_cutting_table.note0", + type = Admonition.Type.WARNING)) public class GemCuttingTable extends VirtualizedRegistry { public GemCuttingTable() { super(Alias.generateOfClass(GemCuttingTable.class).and("GCT", "gct")); } - @RecipeBuilderDescription(example = { - @Example(".name('clay_craft').input(item('minecraft:stone') * 64).output(item('minecraft:clay'))"), - @Example(".input(item('minecraft:stone'),item('minecraft:gold_ingot'),item('minecraft:gold_nugget')).output(item('minecraft:clay') * 4)") - }) + @RecipeBuilderDescription(example = {@Example(".name('clay_craft').input(item('minecraft:stone') * 64).output(item('minecraft:clay'))"), + @Example(".input(item('minecraft:stone'),item('minecraft:gold_ingot'),item('minecraft:gold_nugget')).output(item('minecraft:clay') * 4)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -55,11 +56,9 @@ public boolean remove(IGCTRecipe recipe) { @MethodDescription(example = @Example("item('minecraft:gold_nugget')")) public boolean removeByInput(IIngredient input) { return GCTRecipeList.instance.getRecipes().values().removeIf(recipe -> { - boolean found = recipe.getIngredients().stream() - .map(IngredientStack::getIngredient) - .map(Ingredient::getMatchingStacks) - .flatMap(Arrays::stream) - .anyMatch(input); + boolean found = recipe.getIngredients().stream().map(IngredientStack::getIngredient).map( + Ingredient::getMatchingStacks) + .flatMap(Arrays::stream).anyMatch(input); if (found) { addBackup(recipe); } @@ -80,8 +79,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(GCTRecipeList.instance.getRecipeList()) - .setRemover(this::remove); + return new SimpleObjectStream<>(GCTRecipeList.instance.getRecipeList()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -92,19 +90,16 @@ public void removeAll() { } } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) + @Property(property = "input", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getRecipeNamePrefix() { - return "groovyscript_gem_cutting_table_"; - } + public String getRecipeNamePrefix() { return "groovyscript_gem_cutting_table_"; } @Override - public String getErrorMsg() { - return "Error adding Arcane Archives Gem Cutting Table recipe"; - } + public String getErrorMsg() { return "Error adding Arcane Archives Gem Cutting Table recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -113,11 +108,13 @@ public void validate(GroovyLog.Msg msg) { validateName(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IGCTRecipe register() { if (!validate()) return null; - IGCTRecipe recipe = new GCTRecipe(super.name, output.get(0), input.stream().map(x -> new IngredientStack(x.toMcIngredient(), x.getAmount())).collect(Collectors.toList())); + IGCTRecipe recipe = new GCTRecipe(super.name, output.get(0), input.stream().map(x -> new IngredientStack(x + .toMcIngredient(), + x.getAmount())) + .collect(Collectors.toList())); ModSupport.ARCANE_ARCHIVES.get().gemCuttingTable.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/AstralSorcery.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/AstralSorcery.java index 6fc9c7e76..47edf7a00 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/AstralSorcery.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/AstralSorcery.java @@ -1,5 +1,8 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.Result; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; @@ -11,10 +14,9 @@ import com.cleanroommc.groovyscript.core.mixin.astralsorcery.ConstellationRegistryAccessor; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.sandbox.expand.ExpansionHelper; + import hellfirepvp.astralsorcery.common.constellation.IConstellation; import hellfirepvp.astralsorcery.common.crafting.ItemHandle; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; public class AstralSorcery extends GroovyPropertyContainer { @@ -36,18 +38,14 @@ public class AstralSorcery extends GroovyPropertyContainer { @Override public void initialize(GroovyContainer container) { - container.objectMapperBuilder("constellation", IConstellation.class) - .parser((s, args) -> { - for (IConstellation constellation : ConstellationRegistryAccessor.getConstellationList()) { - if (constellation.getSimpleName().equalsIgnoreCase(s)) { - return Result.some(constellation); - } - } - return Result.error(); - }) - .completerOfNamed(ConstellationRegistryAccessor::getConstellationList, IConstellation::getSimpleName) - .docOfType("constellation") - .register(); + container.objectMapperBuilder("constellation", IConstellation.class).parser((s, args) -> { + for (IConstellation constellation : ConstellationRegistryAccessor.getConstellationList()) { + if (constellation.getSimpleName().equalsIgnoreCase(s)) { return Result.some(constellation); } + } + return Result.error(); + }).completerOfNamed(ConstellationRegistryAccessor::getConstellationList, IConstellation::getSimpleName).docOfType( + "constellation") + .register(); ExpansionHelper.mixinClass(ItemStack.class, CrystalItemStackExpansion.class); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/ChaliceInteraction.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/ChaliceInteraction.java index b110fe28d..0913a87b0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/ChaliceInteraction.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/ChaliceInteraction.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,15 +16,10 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import hellfirepvp.astralsorcery.common.base.LiquidInteraction; import it.unimi.dsi.fastutil.floats.FloatArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; - -import java.util.List; @RegistryDescription public class ChaliceInteraction extends VirtualizedRegistry { @@ -33,9 +36,7 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(getRegistry()::remove); restoreFromBackup().forEach(getRegistry()::add); @@ -47,7 +48,8 @@ private void add(LiquidInteraction recipe) { } @MethodDescription(type = MethodDescription.Type.ADDITION) - public LiquidInteraction add(int probability, FluidStack component1, FluidStack component2, LiquidInteraction.FluidInteractionAction action) { + public LiquidInteraction add(int probability, FluidStack component1, FluidStack component2, + LiquidInteraction.FluidInteractionAction action) { LiquidInteraction recipe = new LiquidInteraction(probability, component1, component2, action); addScripted(recipe); getRegistry().add(recipe); @@ -61,8 +63,12 @@ private boolean remove(LiquidInteraction recipe) { @MethodDescription public void removeByInput(Fluid fluid1, Fluid fluid2) { getRegistry().removeIf(rec -> { - if ((rec.getComponent1().getFluid().equals(fluid1) && rec.getComponent2().getFluid().equals(fluid2)) || - (rec.getComponent1().getFluid().equals(fluid2) && rec.getComponent2().getFluid().equals(fluid1))) { + if ((rec.getComponent1().getFluid().equals(fluid1) && rec.getComponent2().getFluid().equals(fluid2)) || (rec + .getComponent1() + .getFluid() + .equals(fluid2) && rec.getComponent2() + .getFluid() + .equals(fluid1))) { addBackup(rec); return true; } @@ -104,8 +110,7 @@ public void removeByOutput(ItemStack output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(getRegistry()) - .setRemover(this::remove); + return new SimpleObjectStream<>(getRegistry()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -140,8 +145,7 @@ public RecipeBuilder output(ItemStack item, int weight) { return this.result(item, weight); } - @Override - @RecipeBuilderMethodDescription(field = {"output", "probabilities"}) + @Override @RecipeBuilderMethodDescription(field = {"output", "probabilities"}) public RecipeBuilder output(ItemStack item) { return this.result(item, 1); } @@ -163,16 +167,13 @@ public RecipeBuilder fluidInput(FluidStack fluid, float chance) { return this.component(fluid, chance); } - @Override - @RecipeBuilderMethodDescription(field = {"fluidInput", "chances"}) + @Override @RecipeBuilderMethodDescription(field = {"fluidInput", "chances"}) public RecipeBuilder fluidInput(FluidStack fluid) { return this.component(fluid, 1.0F); } @Override - public String getErrorMsg() { - return "Error adding Astral Sorcery Chalice Interaction"; - } + public String getErrorMsg() { return "Error adding Astral Sorcery Chalice Interaction"; } @Override public void validate(GroovyLog.Msg msg) { @@ -184,18 +185,15 @@ public void validate(GroovyLog.Msg msg) { msg.add(chances.getFloat(0) < 0 || chances.getFloat(1) < 0, () -> "Consumption chance cannot be negative"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public LiquidInteraction register() { if (!validate()) return null; LiquidInteraction recipe = null; for (int i = 0; i < this.output.size(); i++) { - recipe = new LiquidInteraction( - probabilities.getInt(i), - fluidInput.get(0), - fluidInput.get(1), - LiquidInteraction.createItemDropAction(chances.getFloat(0), chances.getFloat(1), output.get(i)) - ); + recipe = new LiquidInteraction(probabilities.getInt(i), fluidInput.get(0), fluidInput.get(1), LiquidInteraction + .createItemDropAction(chances.getFloat(0), + chances.getFloat(1), + output.get(i))); ModSupport.ASTRAL_SORCERY.get().chaliceInteraction.add(recipe); } return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Constellation.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Constellation.java index a9babd9f1..c879d19d4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Constellation.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Constellation.java @@ -1,5 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; +import java.awt.*; +import java.util.*; +import java.util.List; + +import net.minecraft.enchantment.Enchantment; +import net.minecraft.init.Items; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.potion.Potion; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -11,6 +23,7 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.google.common.collect.Iterables; + import hellfirepvp.astralsorcery.common.constellation.*; import hellfirepvp.astralsorcery.common.constellation.star.StarLocation; import hellfirepvp.astralsorcery.common.constellation.starmap.ConstellationMapEffectRegistry; @@ -28,20 +41,8 @@ import hellfirepvp.astralsorcery.common.tile.TileAltar; import hellfirepvp.astralsorcery.common.util.OreDictAlias; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.init.Items; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.potion.Potion; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.ApiStatus; - -import java.awt.*; -import java.util.List; -import java.util.*; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Constellation extends VirtualizedRegistry { private final Map constellationMapEffectsAdded = new HashMap<>(); @@ -49,30 +50,39 @@ public class Constellation extends VirtualizedRegistry { private final Map> signatureItemsAdded = new HashMap<>(); private final Map> signatureItemsRemoved = new HashMap<>(); - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(c -> { if (ConstellationMapEffectRegistryAccessor.getEffectRegistry() != null) { ConstellationMapEffectRegistryAccessor.getEffectRegistry().remove(c); } - ConstellationRegistryAccessor.getConstellationList().removeIf(registeredConstellation -> c.getSimpleName().equals(registeredConstellation.getSimpleName())); + ConstellationRegistryAccessor.getConstellationList().removeIf(registeredConstellation -> c.getSimpleName().equals( + registeredConstellation.getSimpleName())); if (c instanceof IMajorConstellation && ConstellationRegistryAccessor.getMajorConstellations() != null) { - ConstellationRegistryAccessor.getMajorConstellations().removeIf(registeredConstellation -> c.getSimpleName().equals(registeredConstellation.getSimpleName())); + ConstellationRegistryAccessor.getMajorConstellations().removeIf(registeredConstellation -> c.getSimpleName() + .equals(registeredConstellation.getSimpleName())); } if (c instanceof IMinorConstellation && ConstellationRegistryAccessor.getMinorConstellations() != null) { - ConstellationRegistryAccessor.getMinorConstellations().removeIf(registeredConstellation -> c.getSimpleName().equals(registeredConstellation.getSimpleName())); + ConstellationRegistryAccessor.getMinorConstellations().removeIf(registeredConstellation -> c.getSimpleName() + .equals(registeredConstellation.getSimpleName())); } if (c instanceof IWeakConstellation && ConstellationRegistryAccessor.getWeakConstellations() != null) { - ConstellationRegistryAccessor.getWeakConstellations().removeIf(registeredConstellation -> c.getSimpleName().equals(registeredConstellation.getSimpleName())); + ConstellationRegistryAccessor.getWeakConstellations().removeIf(registeredConstellation -> c.getSimpleName() + .equals(registeredConstellation.getSimpleName())); } }); restoreFromBackup().forEach(ConstellationRegistry::registerConstellation); - this.constellationMapEffectsRemoved.forEach((constellation, effect) -> ConstellationMapEffectRegistry.registerMapEffect(constellation, effect.enchantmentEffects, effect.potionEffects)); - this.constellationMapEffectsAdded.forEach((constellation, effect) -> ConstellationMapEffectRegistryAccessor.getEffectRegistry().remove(constellation)); - this.signatureItemsAdded.forEach((constellation, items) -> items.forEach(item -> ((ConstellationBaseAccessor) constellation).getSignatureItems().remove(item))); + this.constellationMapEffectsRemoved.forEach((constellation, effect) -> ConstellationMapEffectRegistry.registerMapEffect( + constellation, + effect.enchantmentEffects, + effect.potionEffects)); + this.constellationMapEffectsAdded.forEach((constellation, effect) -> ConstellationMapEffectRegistryAccessor + .getEffectRegistry() + .remove(constellation)); + this.signatureItemsAdded.forEach((constellation, items) -> items.forEach( + item -> ((ConstellationBaseAccessor) constellation).getSignatureItems() + .remove(item))); this.signatureItemsRemoved.forEach((constellation, items) -> items.forEach(constellation::addSignatureItem)); this.constellationMapEffectsAdded.clear(); @@ -99,20 +109,26 @@ public boolean remove(IConstellation constellation) { if (ConstellationRegistryAccessor.getConstellationList() == null) return false; addBackup(constellation); this.removeConstellationMapEffect(constellation); - ConstellationRegistryAccessor.getConstellationList().removeIf(registeredConstellation -> constellation.getSimpleName().equals(registeredConstellation.getSimpleName())); + ConstellationRegistryAccessor.getConstellationList().removeIf(registeredConstellation -> constellation.getSimpleName() + .equals(registeredConstellation.getSimpleName())); if (constellation instanceof IMajorConstellation && ConstellationRegistryAccessor.getMajorConstellations() != null) - return ConstellationRegistryAccessor.getMajorConstellations().removeIf(registeredConstellation -> constellation.getSimpleName().equals(registeredConstellation.getSimpleName())); + return ConstellationRegistryAccessor.getMajorConstellations().removeIf(registeredConstellation -> constellation + .getSimpleName() + .equals(registeredConstellation.getSimpleName())); if (constellation instanceof IMinorConstellation && ConstellationRegistryAccessor.getMinorConstellations() != null) - return ConstellationRegistryAccessor.getMinorConstellations().removeIf(registeredConstellation -> constellation.getSimpleName().equals(registeredConstellation.getSimpleName())); + return ConstellationRegistryAccessor.getMinorConstellations().removeIf(registeredConstellation -> constellation + .getSimpleName() + .equals(registeredConstellation.getSimpleName())); if (constellation instanceof IWeakConstellation && ConstellationRegistryAccessor.getWeakConstellations() != null) - return ConstellationRegistryAccessor.getWeakConstellations().removeIf(registeredConstellation -> constellation.getSimpleName().equals(registeredConstellation.getSimpleName())); + return ConstellationRegistryAccessor.getWeakConstellations().removeIf(registeredConstellation -> constellation + .getSimpleName() + .equals(registeredConstellation.getSimpleName())); return false; } @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamConstellations() { - return new SimpleObjectStream<>(ConstellationRegistryAccessor.getConstellationList()) - .setRemover(this::remove); + return new SimpleObjectStream<>(ConstellationRegistryAccessor.getConstellationList()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -124,15 +140,20 @@ public void removeAll() { ConstellationRegistryAccessor.getWeakConstellations().clear(); } - private void addConstellationMapEffect(IConstellation constellation, List enchantmentEffectList, List potionEffectList) { - this.constellationMapEffectsAdded.put(constellation, ConstellationMapEffectRegistry.registerMapEffect(constellation, enchantmentEffectList, potionEffectList)); + private void addConstellationMapEffect(IConstellation constellation, + List enchantmentEffectList, + List potionEffectList) { + this.constellationMapEffectsAdded.put(constellation, ConstellationMapEffectRegistry.registerMapEffect(constellation, + enchantmentEffectList, + potionEffectList)); } @MethodDescription(example = @Example("constellation('discidia')")) public void removeConstellationMapEffect(IConstellation constellation) { if (ConstellationMapEffectRegistryAccessor.getEffectRegistry() == null) return; if (ConstellationMapEffectRegistryAccessor.getEffectRegistry().containsKey(constellation)) { - this.constellationMapEffectsRemoved.put(constellation, ConstellationMapEffectRegistryAccessor.getEffectRegistry().get(constellation)); + this.constellationMapEffectsRemoved.put(constellation, ConstellationMapEffectRegistryAccessor.getEffectRegistry().get( + constellation)); ConstellationMapEffectRegistryAccessor.getEffectRegistry().remove(constellation); } } @@ -140,7 +161,8 @@ public void removeConstellationMapEffect(IConstellation constellation) { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAllConstellationMapEffect() { ConstellationRegistryAccessor.getConstellationList().forEach(constellation -> { - this.constellationMapEffectsRemoved.put(constellation, ConstellationMapEffectRegistryAccessor.getEffectRegistry().get(constellation)); + this.constellationMapEffectsRemoved.put(constellation, ConstellationMapEffectRegistryAccessor.getEffectRegistry().get( + constellation)); ConstellationMapEffectRegistryAccessor.getEffectRegistry().remove(constellation); }); } @@ -187,12 +209,17 @@ public void removeAllSignatureItems() { private void updateDefaultPaperRecipe(IConstellation constellation) { ItemHandle first = (ItemHandle) Iterables.getFirst(constellation.getConstellationSignatureItems(), (Object) null); - AccessibleRecipeAdapater shapedPaper = ShapedRecipe.Builder.newShapedRecipe("internal/altar/constellationpaper/" + constellation.getSimpleName().toLowerCase(), ItemsAS.constellationPaper) - .addPart(ItemCraftingComponent.MetaType.PARCHMENT.asStack(), ShapedRecipeSlot.CENTER) - .addPart(Items.FEATHER, ShapedRecipeSlot.UPPER_CENTER) - .addPart(OreDictAlias.getDyeOreDict(EnumDyeColor.BLACK), ShapedRecipeSlot.LOWER_CENTER) - .addPart(OreDictAlias.ITEM_STARMETAL_DUST, ShapedRecipeSlot.LEFT, ShapedRecipeSlot.RIGHT) - .unregisteredAccessibleShapedRecipe(); + AccessibleRecipeAdapater shapedPaper = ShapedRecipe.Builder.newShapedRecipe("internal/altar/constellationpaper/" + + constellation.getSimpleName().toLowerCase(), + ItemsAS.constellationPaper).addPart( + ItemCraftingComponent.MetaType.PARCHMENT.asStack(), + ShapedRecipeSlot.CENTER) + .addPart(Items.FEATHER, ShapedRecipeSlot.UPPER_CENTER).addPart( + OreDictAlias.getDyeOreDict(EnumDyeColor.BLACK), + ShapedRecipeSlot.LOWER_CENTER) + .addPart(OreDictAlias.ITEM_STARMETAL_DUST, + ShapedRecipeSlot.LEFT, ShapedRecipeSlot.RIGHT) + .unregisteredAccessibleShapedRecipe(); ConstellationPaperRecipe recipe = new ConstellationPaperRecipe(shapedPaper, constellation); recipe.setInnerTraitItem(first, TraitRecipe.TraitRecipeSlot.values()); @@ -200,18 +227,25 @@ private void updateDefaultPaperRecipe(IConstellation constellation) { recipe.addOuterTraitItem(s); } - AltarRecipeRegistry.recipes.get(TileAltar.AltarLevel.TRAIT_CRAFT) - .removeIf(r -> new ResourceLocation("astralsorcery:shaped/internal/altar/constellationpaper/" + constellation.getSimpleName().toLowerCase()).equals(r.getNativeRecipe().getRegistryName())); + AltarRecipeRegistry.recipes.get(TileAltar.AltarLevel.TRAIT_CRAFT).removeIf(r -> new ResourceLocation( + "astralsorcery:shaped/internal/altar/constellationpaper/" + + constellation.getSimpleName() + .toLowerCase()).equals(r.getNativeRecipe() + .getRegistryName())); AltarRecipeRegistry.registerAltarRecipe(recipe); RecipesAS.paperCraftingRecipes.put(constellation, recipe); } private void updateDefaultCapeRecipe(IConstellation constellation) { ItemHandle first = (ItemHandle) Iterables.getFirst(constellation.getConstellationSignatureItems(), (Object) null); - AccessibleRecipeAdapater ar = ShapedRecipe.Builder.newShapedRecipe("internal/cape/att/" + constellation.getSimpleName().toLowerCase(), ItemsAS.armorImbuedCape) - .addPart(ItemsAS.armorImbuedCape, ShapedRecipeSlot.CENTER) - .addPart(first, ShapedRecipeSlot.UPPER_CENTER, ShapedRecipeSlot.LEFT, ShapedRecipeSlot.RIGHT, ShapedRecipeSlot.LOWER_CENTER) - .unregisteredAccessibleShapedRecipe(); + AccessibleRecipeAdapater ar = ShapedRecipe.Builder.newShapedRecipe("internal/cape/att/" + constellation.getSimpleName() + .toLowerCase(), + ItemsAS.armorImbuedCape).addPart( + ItemsAS.armorImbuedCape, + ShapedRecipeSlot.CENTER) + .addPart(first, ShapedRecipeSlot.UPPER_CENTER, ShapedRecipeSlot.LEFT, + ShapedRecipeSlot.RIGHT, ShapedRecipeSlot.LOWER_CENTER) + .unregisteredAccessibleShapedRecipe(); CapeAttunementRecipe recipe = new CapeAttunementRecipe(constellation, ar); recipe.setInnerTraitItem(OreDictAlias.ITEM_STARMETAL_DUST, TraitRecipe.TraitRecipeSlot.values()); @@ -219,16 +253,18 @@ private void updateDefaultCapeRecipe(IConstellation constellation) { recipe.addOuterTraitItem(s); } - AltarRecipeRegistry.recipes.get(TileAltar.AltarLevel.TRAIT_CRAFT) - .removeIf(r -> new ResourceLocation("astralsorcery:shaped/internal/cape/att/" + constellation.getSimpleName().toLowerCase()).equals(r.getNativeRecipe().getRegistryName())); + AltarRecipeRegistry.recipes.get(TileAltar.AltarLevel.TRAIT_CRAFT).removeIf(r -> new ResourceLocation( + "astralsorcery:shaped/internal/cape/att/" + + constellation.getSimpleName() + .toLowerCase()).equals(r.getNativeRecipe() + .getRegistryName())); AltarRecipeRegistry.registerAltarRecipe(recipe); RecipesAS.capeCraftingRecipes.put(constellation, recipe); } - @RecipeBuilderDescription(example = { - @Example(".major().name('square').color(0xE01903).connection(12, 2, 2, 2).connection(12, 12, 12, 2).connection(2, 12, 12, 12).connection(2, 2, 2, 12)"), - @Example(value = ".minor().name('slow').connection(10, 5, 5, 5).connection(5, 10, 5, 5).connection(3, 3, 3, 3).phase(MoonPhase.FULL)", imports = "hellfirepvp.astralsorcery.common.constellation.MoonPhase") - }) + @RecipeBuilderDescription(example = {@Example(".major().name('square').color(0xE01903).connection(12, 2, 2, 2).connection(12, 12, 12, 2).connection(2, 12, 12, 12).connection(2, 2, 2, 12)"), + @Example(value = ".minor().name('slow').connection(10, 5, 5, 5).connection(5, 10, 5, 5).connection(3, 3, 3, 3).phase(MoonPhase.FULL)", + imports = "hellfirepvp.astralsorcery.common.constellation.MoonPhase")}) public ConstellationBuilder constellationBuilder() { return new ConstellationBuilder(); } @@ -316,12 +352,9 @@ public ConstellationBuilder phase(Collection moonPhases) { private boolean validate() { ArrayList errors = new ArrayList<>(); - if (this.name == null || "".equals(this.name)) - errors.add("name must be provided"); - if (this.connections.isEmpty()) - errors.add("connections must not be empty"); - if (type == Type.MINOR && this.phases.isEmpty()) - errors.add("minor constellations require at least one moon phase"); + if (this.name == null || "".equals(this.name)) errors.add("name must be provided"); + if (this.connections.isEmpty()) errors.add("connections must not be empty"); + if (type == Type.MINOR && this.phases.isEmpty()) errors.add("minor constellations require at least one moon phase"); if (!errors.isEmpty()) { GroovyLog.Msg errorOut = GroovyLog.msg("Error adding Astral Sorcery Constellation: "); @@ -372,9 +405,7 @@ public void register() { } private enum Type { - MAJOR, - MINOR, - WEAK + MAJOR, MINOR, WEAK } } @@ -409,7 +440,8 @@ private boolean validate() { GroovyLog.Msg out = GroovyLog.msg("Error adding Astral Sorcery Constellation Map Effect").error(); out.add(this.constellation == null, "No constellation provided."); - out.add(enchantmentEffect.isEmpty() && potionEffect.isEmpty(), "Either enchantmentEffect or potionEffect must be provided, neither were found."); + out.add(enchantmentEffect.isEmpty() && potionEffect.isEmpty(), + "Either enchantmentEffect or potionEffect must be provided, neither were found."); return !out.postIfNotEmpty(); } @@ -417,7 +449,8 @@ private boolean validate() { @RecipeBuilderRegistrationMethod public void register() { if (!validate()) return; - ModSupport.ASTRAL_SORCERY.get().constellation.addConstellationMapEffect(constellation, enchantmentEffect, potionEffect); + ModSupport.ASTRAL_SORCERY.get().constellation.addConstellationMapEffect(constellation, enchantmentEffect, + potionEffect); } } @@ -455,7 +488,8 @@ public void register() { if (this.doStrip) ModSupport.ASTRAL_SORCERY.get().constellation.removeSignatureItems(this.constellation); ModSupport.ASTRAL_SORCERY.get().constellation.addSignatureItem(this.constellation, this.items); } else { - GroovyLog.msg("Error modifying Astral Sorcery constellation signature items").add("No constellation specified.").error().post(); + GroovyLog.msg("Error modifying Astral Sorcery constellation signature items").add("No constellation specified.") + .error().post(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Fountain.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Fountain.java index bc1214710..bd3a36178 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Fountain.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Fountain.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.logging.log4j.Level; +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,11 +15,8 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.IRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import hellfirepvp.astralsorcery.common.base.FluidRarityRegistry; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.apache.logging.log4j.Level; -import org.jetbrains.annotations.ApiStatus; @RegistryDescription public class Fountain extends VirtualizedRegistry { @@ -23,9 +26,7 @@ public FountainChanceHelper chanceHelper() { return new FountainChanceHelper(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList()::remove); restoreFromBackup().forEach(((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList()::add); @@ -61,10 +62,11 @@ public void add(Fluid fluid, int rarity, int guaranteedAmt, int addRand) { @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.remove0") public boolean remove(FluidRarityRegistry.FluidRarityEntry entry) { addBackup(entry); - return ((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList().removeIf(fluidRarityEntry -> fluidRarityEntry == entry); + return ((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList().removeIf( + fluidRarityEntry -> fluidRarityEntry == entry); } - @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.remove1",example = @Example("fluid('lava')")) + @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.remove1", example = @Example("fluid('lava')")) public void remove(FluidStack entry) { this.remove(entry.getFluid()); } @@ -82,8 +84,7 @@ public void remove(Fluid entry) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList()) - .setRemover(this::remove); + return new SimpleObjectStream<>(((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -156,11 +157,12 @@ public boolean validate() { return out.getLevel() != Level.ERROR; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public FluidRarityRegistry.FluidRarityEntry register() { if (!validate()) return null; - FluidRarityRegistry.FluidRarityEntry recipe = FluidRarityEntryAccessor.createFluidRarityEntry(fluid, rarity, minimumAmount, variance); + FluidRarityRegistry.FluidRarityEntry recipe = FluidRarityEntryAccessor.createFluidRarityEntry(fluid, rarity, + minimumAmount, + variance); ModSupport.ASTRAL_SORCERY.get().fountain.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Grindstone.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Grindstone.java index 15da6e41b..eb998e4ce 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Grindstone.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Grindstone.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,26 +12,21 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import hellfirepvp.astralsorcery.common.crafting.ItemHandle; import hellfirepvp.astralsorcery.common.crafting.grindstone.GrindstoneRecipe; import hellfirepvp.astralsorcery.common.crafting.grindstone.GrindstoneRecipeRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; @RegistryDescription public class Grindstone extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(ore('blockDiamond')).output(item('minecraft:clay')).weight(1).secondaryChance(1.0F)"), - @Example(".input(item('minecraft:stone')).output(item('minecraft:cobblestone')).weight(5)") - }) + @RecipeBuilderDescription(example = {@Example(".input(ore('blockDiamond')).output(item('minecraft:clay')).weight(1).secondaryChance(1.0F)"), + @Example(".input(item('minecraft:stone')).output(item('minecraft:cobblestone')).weight(5)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(r -> GrindstoneRecipeRegistry.recipes.removeIf(recipe -> r == recipe)); restoreFromBackup().forEach(GrindstoneRecipeRegistry::registerGrindstoneRecipe); @@ -68,8 +67,7 @@ public void removeByInput(ItemStack item) { @MethodDescription(example = @Example("ore('dustIron')")) public void removeByOutput(OreDictIngredient ore) { - for (ItemStack item : ore.getMatchingStacks()) - this.removeByOutput(item); + for (ItemStack item : ore.getMatchingStacks()) this.removeByOutput(item); } @MethodDescription @@ -85,8 +83,7 @@ public void removeByOutput(ItemStack item) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(GrindstoneRecipeRegistry.recipes) - .setRemover(this::remove); + return new SimpleObjectStream<>(GrindstoneRecipeRegistry.recipes).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -95,8 +92,7 @@ public void removeAll() { GrindstoneRecipeRegistry.recipes.clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) @@ -117,22 +113,21 @@ public RecipeBuilder secondaryChance(float chance) { } @Override - public String getErrorMsg() { - return "Error adding Astral Sorcery Grindstone recipe"; - } + public String getErrorMsg() { return "Error adding Astral Sorcery Grindstone recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); msg.add(weight < 0, () -> "Weight cannot be negative"); - msg.add(secondaryChance < 0 || secondaryChance > 1, () -> "Secondary chance must be between [0,1]. Instead found " + secondaryChance + "."); + msg.add(secondaryChance < 0 || secondaryChance > 1, () -> "Secondary chance must be between [0,1]. Instead found " + + secondaryChance + "."); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public GrindstoneRecipe register() { if (!validate()) return null; - GrindstoneRecipe recipe = new GrindstoneRecipe(AstralSorcery.toItemHandle(input.get(0)), output.get(0), weight, secondaryChance); + GrindstoneRecipe recipe = new GrindstoneRecipe(AstralSorcery.toItemHandle(input.get(0)), output.get(0), weight, + secondaryChance); ModSupport.ASTRAL_SORCERY.get().grindstone.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/InfusionAltar.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/InfusionAltar.java index 89ff9e162..0186593e5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/InfusionAltar.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/InfusionAltar.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,28 +13,22 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import hellfirepvp.astralsorcery.common.crafting.ItemHandle; import hellfirepvp.astralsorcery.common.crafting.infusion.AbstractInfusionRecipe; import hellfirepvp.astralsorcery.common.crafting.infusion.InfusionRecipeRegistry; import hellfirepvp.astralsorcery.common.crafting.infusion.recipes.BasicInfusionRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class InfusionAltar extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).consumption(1f).chalice(false).consumeMultiple(true).time(10)"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).consumption(1f).chalice(false).consumeMultiple(true).time(10)"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(r -> InfusionRecipeRegistry.recipes.removeIf(rec -> rec.getUniqueRecipeId() == r.getUniqueRecipeId())); restoreFromBackup().forEach(InfusionRecipeRegistry::registerInfusionRecipe); @@ -82,8 +81,7 @@ public void removeByOutput(ItemStack output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(InfusionRecipeRegistry.recipes) - .setRemover(this::remove); + return new SimpleObjectStream<>(InfusionRecipeRegistry.recipes).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -97,8 +95,7 @@ public void removeAll() { }); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) @@ -148,22 +145,22 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Astral Infusion recipe"; - } + public String getErrorMsg() { return "Error adding Astral Infusion recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); - msg.add(consumption < 0 || consumption > 1, "consumption must be a float between 0 and 1, yet it was {}", consumption); + msg.add(consumption < 0 || consumption > 1, "consumption must be a float between 0 and 1, yet it was {}", + consumption); msg.add(time <= 0, "time must be an integer greater than 0, yet it was {}", time); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable BasicInfusionRecipe register() { if (!validate()) return null; - BasicInfusionRecipe recipe = new BasicInfusionRecipe(output.get(0), AstralSorcery.toItemHandle(input.get(0))) { + BasicInfusionRecipe recipe = new BasicInfusionRecipe(output.get(0), AstralSorcery.toItemHandle(input.get(0))) + { + @Override public int craftingTickTime() { return time; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/LightTransmutation.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/LightTransmutation.java index af8fb0dc1..2a9569720 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/LightTransmutation.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/LightTransmutation.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,15 +18,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import hellfirepvp.astralsorcery.common.base.LightOreTransmutations; import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; - -import javax.annotation.Nonnull; -import java.util.List; @RegistryDescription public class LightTransmutation extends VirtualizedRegistry { @@ -28,16 +32,13 @@ private static List getRegistry() { return (List) LightOreTransmutationsAccessor.getRegisteredTransmutations(); } - @RecipeBuilderDescription(example = { - @Example(".input(block('minecraft:stone')).output(block('astralsorcery:blockmarble')).cost(100.0).constellation(constellation('armara')).inputDisplayStack(item('minecraft:stone')).outputDisplayStack(item('minecraft:dye:15').withNbt([display:[Name:'Marble']])) "), - @Example(".input(blockstate('minecraft:pumpkin')).output(blockstate('minecraft:diamond_block')).cost(0)")}) + @RecipeBuilderDescription(example = {@Example(".input(block('minecraft:stone')).output(block('astralsorcery:blockmarble')).cost(100.0).constellation(constellation('armara')).inputDisplayStack(item('minecraft:stone')).outputDisplayStack(item('minecraft:dye:15').withNbt([display:[Name:'Marble']])) "), + @Example(".input(blockstate('minecraft:pumpkin')).output(blockstate('minecraft:diamond_block')).cost(0)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(r -> getRegistry().removeIf(recipe -> r == recipe)); restoreFromBackup().forEach(r -> getRegistry().add(r)); @@ -48,17 +49,19 @@ private void add(LightOreTransmutations.Transmutation recipe) { addScripted(recipe); } - public LightOreTransmutations.Transmutation add(Block input, IBlockState output, - @Nonnull ItemStack inputDisplay, @Nonnull ItemStack outputDisplay, double cost) { - LightOreTransmutations.Transmutation recipe = new LightOreTransmutations.Transmutation(input, output, inputDisplay, outputDisplay, cost); + public LightOreTransmutations.Transmutation add(Block input, IBlockState output, @Nonnull ItemStack inputDisplay, + @Nonnull ItemStack outputDisplay, double cost) { + LightOreTransmutations.Transmutation recipe = new LightOreTransmutations.Transmutation(input, output, inputDisplay, + outputDisplay, cost); addScripted(recipe); getRegistry().add(recipe); return recipe; } - public LightOreTransmutations.Transmutation add(IBlockState input, IBlockState output, - @Nonnull ItemStack inputDisplay, @Nonnull ItemStack outputDisplay, double cost) { - LightOreTransmutations.Transmutation recipe = new LightOreTransmutations.Transmutation(input, output, inputDisplay, outputDisplay, cost); + public LightOreTransmutations.Transmutation add(IBlockState input, IBlockState output, @Nonnull ItemStack inputDisplay, + @Nonnull ItemStack outputDisplay, double cost) { + LightOreTransmutations.Transmutation recipe = new LightOreTransmutations.Transmutation(input, output, inputDisplay, + outputDisplay, cost); addScripted(recipe); getRegistry().add(recipe); return recipe; @@ -102,8 +105,7 @@ public void removeByOutput(Block block) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(getRegistry()) - .setRemover(this::remove); + return new SimpleObjectStream<>(getRegistry()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -116,7 +118,8 @@ public static class RecipeBuilder extends AbstractRecipeBuilder { @@ -29,17 +32,13 @@ private static Map getRegistry() return WellLiquefactionAccessor.getRegisteredLiquefactions(); } - @RecipeBuilderDescription(example = { - @Example(".catalyst(item('minecraft:stone')).output(fluid('astralsorcery.liquidstarlight')).productionMultiplier(1.0F).shatterMultiplier(15.0F).catalystColor(16725260)"), - @Example(".catalyst(item('minecraft:obsidian')).output(fluid('astralsorcery.liquidstarlight')).productionMultiplier(1.0F).shatterMultiplier(15.0F)") - }) + @RecipeBuilderDescription(example = {@Example(".catalyst(item('minecraft:stone')).output(fluid('astralsorcery.liquidstarlight')).productionMultiplier(1.0F).shatterMultiplier(15.0F).catalystColor(16725260)"), + @Example(".catalyst(item('minecraft:obsidian')).output(fluid('astralsorcery.liquidstarlight')).productionMultiplier(1.0F).shatterMultiplier(15.0F)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(r -> getRegistry().remove(r.catalyst)); restoreFromBackup().forEach(r -> getRegistry().put(r.catalyst, r)); @@ -51,7 +50,8 @@ public void add(WellLiquefaction.LiquefactionEntry recipe) { } @MethodDescription(description = "groovyscript.wiki.astralsorcery.lightwell.add0", type = MethodDescription.Type.ADDITION) - public void add(ItemStack catalyst, Fluid output, float productionMultiplier, float shatterMultiplier, @Nullable Color color) { + public void add(ItemStack catalyst, Fluid output, float productionMultiplier, float shatterMultiplier, + @Nullable Color color) { add(new WellLiquefaction.LiquefactionEntry(catalyst, output, productionMultiplier, shatterMultiplier, color)); } @@ -92,8 +92,7 @@ public void removeByOutput(FluidStack fluid) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(WellLiquefaction.getRegisteredLiquefactions()) - .setRemover(this::remove); + return new SimpleObjectStream<>(WellLiquefaction.getRegisteredLiquefactions()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -182,11 +181,12 @@ public boolean validate() { return out.getLevel() != Level.ERROR; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public WellLiquefaction.LiquefactionEntry register() { if (!validate()) return null; - WellLiquefaction.LiquefactionEntry recipe = new WellLiquefaction.LiquefactionEntry(catalyst, output, productionMultiplier, shatterMultiplier, color); + WellLiquefaction.LiquefactionEntry recipe = new WellLiquefaction.LiquefactionEntry(catalyst, output, + productionMultiplier, + shatterMultiplier, color); ModSupport.ASTRAL_SORCERY.get().lightwell.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/OreChance.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/OreChance.java index 9717fadda..e2726ccc3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/OreChance.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/OreChance.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -10,14 +12,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import hellfirepvp.astralsorcery.common.base.OreTypes; import hellfirepvp.astralsorcery.common.base.sets.OreEntry; -import org.jetbrains.annotations.ApiStatus; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - priority = 2000 -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES, priority = 2000) public class OreChance extends VirtualizedRegistry { private final OreTypesAccessor REGISTRY; @@ -43,9 +42,7 @@ public static OreChance treasureShrineRegistry() { return new OreChance("TreasureShrineRegistry", OreTypes.TREASURE_SHRINE_GEN); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(r -> REGISTRY.getEntries().removeIf(entry -> { if (entry.oreName.equals(r.oreName)) { @@ -106,8 +103,7 @@ public boolean remove(String ore) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(REGISTRY.getEntries()) - .setRemover(this::remove); + return new SimpleObjectStream<>(REGISTRY.getEntries()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Research.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Research.java index 1058e1477..b3e03b200 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Research.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Research.java @@ -1,11 +1,23 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; +import java.awt.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.astralsorcery.ResearchNodeAccessor; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import hellfirepvp.astralsorcery.client.gui.journal.page.*; import hellfirepvp.astralsorcery.common.crafting.altar.AltarRecipeRegistry; import hellfirepvp.astralsorcery.common.crafting.altar.recipes.AttunementRecipe; @@ -15,19 +27,8 @@ import hellfirepvp.astralsorcery.common.data.research.ResearchNode; import hellfirepvp.astralsorcery.common.data.research.ResearchProgression; import hellfirepvp.astralsorcery.common.tile.TileAltar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Research extends VirtualizedRegistry { private final Map scriptedCategories = new HashMap<>(); @@ -36,17 +37,13 @@ public class Research extends VirtualizedRegistry { private final Map> removedConnections = new HashMap<>(); private final Map movedNodes = new HashMap<>(); - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(node -> { - if (this.scriptedCategories.containsKey(node)) - this.removeNode(scriptedCategories.get(node), node); + if (this.scriptedCategories.containsKey(node)) this.removeNode(scriptedCategories.get(node), node); }); restoreFromBackup().forEach(node -> { - if (this.removedCategories.containsKey(node)) - this.addNode(removedCategories.get(node), node, false); + if (this.removedCategories.containsKey(node)) this.addNode(removedCategories.get(node), node, false); }); scriptedConnections.forEach((source, connections) -> { @@ -109,14 +106,12 @@ private void removeNode(ResearchProgression category, ResearchNode node) { @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'SOOTYMARBLE', 5, 6")) public void moveNode(String name, int x, int z) { ResearchNode node = this.getNode(name); - if (node != null) - this.moveNode(node, x, z, true); + if (node != null) this.moveNode(node, x, z, true); } private void moveNode(ResearchNode node, int x, int z, boolean doBackup) { if (node == null) return; - if (doBackup) - this.movedNodes.put(node, new Point(node.renderPosX, node.renderPosZ)); + if (doBackup) this.movedNodes.put(node, new Point(node.renderPosX, node.renderPosZ)); ((ResearchNodeAccessor) node).setX(x); ((ResearchNodeAccessor) node).setZ(z); } @@ -158,10 +153,8 @@ public void disconnectNodes(ResearchNode node1, ResearchNode node2, boolean doBa node1.getConnectionsTo().remove(node2); } - @RecipeBuilderDescription(example = { - @Example(".name('MY_TEST_RESEARCH').point(5,5).icon(item('minecraft:pumpkin')).discovery().page(mods.astralsorcery.research.pageBuilder().textPage('GROOVYSCRIPT.RESEARCH.PAGE.TEST')).page(mods.astralsorcery.research.pageBuilder().emptyPage()).connectionFrom('ALTAR1')"), - @Example(".name('MY_TEST_RESEARCH2').point(5,5).icon(item('minecraft:pumpkin')).constellation().page(mods.astralsorcery.research.pageBuilder().textPage('GROOVYSCRIPT.RESEARCH.PAGE.TEST2')).page(mods.astralsorcery.research.pageBuilder().constellationRecipePage(item('minecraft:pumpkin')))") - }) + @RecipeBuilderDescription(example = {@Example(".name('MY_TEST_RESEARCH').point(5,5).icon(item('minecraft:pumpkin')).discovery().page(mods.astralsorcery.research.pageBuilder().textPage('GROOVYSCRIPT.RESEARCH.PAGE.TEST')).page(mods.astralsorcery.research.pageBuilder().emptyPage()).connectionFrom('ALTAR1')"), + @Example(".name('MY_TEST_RESEARCH2').point(5,5).icon(item('minecraft:pumpkin')).constellation().page(mods.astralsorcery.research.pageBuilder().textPage('GROOVYSCRIPT.RESEARCH.PAGE.TEST2')).page(mods.astralsorcery.research.pageBuilder().constellationRecipePage(item('minecraft:pumpkin')))")}) public ResearchNodeBuilder researchBuilder() { return new ResearchNodeBuilder(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/crystal/CrystalHelper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/crystal/CrystalHelper.java index 749067cb7..aefc5cb04 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/crystal/CrystalHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/crystal/CrystalHelper.java @@ -1,83 +1,110 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery.crystal; +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyLog; + import hellfirepvp.astralsorcery.common.constellation.IConstellation; import hellfirepvp.astralsorcery.common.constellation.IMinorConstellation; import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation; import hellfirepvp.astralsorcery.common.item.crystal.CrystalProperties; import hellfirepvp.astralsorcery.common.item.crystal.base.ItemTunedCrystalBase; -import net.minecraft.item.ItemStack; public class CrystalHelper { public static ItemStack setSize(ItemStack crystal, int size) { - if (CrystalProperties.getCrystalProperties(crystal) == null) - CrystalProperties.applyCrystalProperties(crystal, new CrystalProperties(size, 0, 0, 0, -1)); + if (CrystalProperties.getCrystalProperties(crystal) == null) CrystalProperties.applyCrystalProperties(crystal, + new CrystalProperties(size, + 0, + 0, + 0, + -1)); else { CrystalProperties oldProps = CrystalProperties.getCrystalProperties(crystal); - CrystalProperties newProps = new CrystalProperties(size, oldProps.getPurity(), oldProps.getCollectiveCapability(), oldProps.getFracturation(), oldProps.getSizeOverride()); + CrystalProperties newProps = new CrystalProperties(size, oldProps.getPurity(), oldProps.getCollectiveCapability(), + oldProps.getFracturation(), oldProps.getSizeOverride()); CrystalProperties.applyCrystalProperties(crystal, newProps); } return crystal; } public static ItemStack setPurity(ItemStack crystal, int purity) { - if (CrystalProperties.getCrystalProperties(crystal) == null) - CrystalProperties.applyCrystalProperties(crystal, new CrystalProperties(0, purity, 0, 0, -1)); + if (CrystalProperties.getCrystalProperties(crystal) == null) CrystalProperties.applyCrystalProperties(crystal, + new CrystalProperties(0, + purity, + 0, + 0, + -1)); else { CrystalProperties oldProps = CrystalProperties.getCrystalProperties(crystal); - CrystalProperties newProps = new CrystalProperties(oldProps.getSize(), purity, oldProps.getCollectiveCapability(), oldProps.getFracturation(), oldProps.getSizeOverride()); + CrystalProperties newProps = new CrystalProperties(oldProps.getSize(), purity, oldProps.getCollectiveCapability(), + oldProps.getFracturation(), oldProps.getSizeOverride()); CrystalProperties.applyCrystalProperties(crystal, newProps); } return crystal; } public static ItemStack setCollectiveCapability(ItemStack crystal, int collectiveCapability) { - if (CrystalProperties.getCrystalProperties(crystal) == null) - CrystalProperties.applyCrystalProperties(crystal, new CrystalProperties(0, 0, collectiveCapability, 0, -1)); + if (CrystalProperties.getCrystalProperties(crystal) == null) CrystalProperties.applyCrystalProperties(crystal, + new CrystalProperties(0, + 0, + collectiveCapability, + 0, + -1)); else { CrystalProperties oldProps = CrystalProperties.getCrystalProperties(crystal); - CrystalProperties newProps = new CrystalProperties(oldProps.getSize(), oldProps.getPurity(), collectiveCapability, oldProps.getFracturation(), oldProps.getSizeOverride()); + CrystalProperties newProps = new CrystalProperties(oldProps.getSize(), oldProps.getPurity(), collectiveCapability, + oldProps.getFracturation(), oldProps.getSizeOverride()); CrystalProperties.applyCrystalProperties(crystal, newProps); } return crystal; } public static ItemStack setFracturation(ItemStack crystal, int fracturation) { - if (CrystalProperties.getCrystalProperties(crystal) == null) - CrystalProperties.applyCrystalProperties(crystal, new CrystalProperties(0, 0, 0, fracturation, -1)); + if (CrystalProperties.getCrystalProperties(crystal) == null) CrystalProperties.applyCrystalProperties(crystal, + new CrystalProperties(0, + 0, + 0, + fracturation, + -1)); else { CrystalProperties oldProps = CrystalProperties.getCrystalProperties(crystal); - CrystalProperties newProps = new CrystalProperties(oldProps.getSize(), oldProps.getPurity(), oldProps.getCollectiveCapability(), fracturation, oldProps.getSizeOverride()); + CrystalProperties newProps = new CrystalProperties(oldProps.getSize(), oldProps.getPurity(), oldProps + .getCollectiveCapability(), + fracturation, oldProps.getSizeOverride()); CrystalProperties.applyCrystalProperties(crystal, newProps); } return crystal; } public static ItemStack setSizeOverride(ItemStack crystal, int size) { - if (CrystalProperties.getCrystalProperties(crystal) == null) - CrystalProperties.applyCrystalProperties(crystal, new CrystalProperties(0, 0, 0, 0, size)); + if (CrystalProperties.getCrystalProperties(crystal) == null) CrystalProperties.applyCrystalProperties(crystal, + new CrystalProperties(0, + 0, + 0, + 0, + size)); else { CrystalProperties oldProps = CrystalProperties.getCrystalProperties(crystal); - CrystalProperties newProps = new CrystalProperties(oldProps.getSize(), oldProps.getPurity(), oldProps.getCollectiveCapability(), oldProps.getFracturation(), size); + CrystalProperties newProps = new CrystalProperties(oldProps.getSize(), oldProps.getPurity(), oldProps + .getCollectiveCapability(), + oldProps.getFracturation(), size); CrystalProperties.applyCrystalProperties(crystal, newProps); } return crystal; } public static ItemStack tuneTo(ItemStack crystal, IConstellation constellation) { - if (constellation instanceof IWeakConstellation) - ItemTunedCrystalBase.applyMainConstellation(crystal, (IWeakConstellation) constellation); - else - GroovyLog.msg("Main constellation must be Major or Weak (Bright or Dim)").error().post(); + if (constellation instanceof IWeakConstellation) ItemTunedCrystalBase.applyMainConstellation(crystal, + (IWeakConstellation) constellation); + else GroovyLog.msg("Main constellation must be Major or Weak (Bright or Dim)").error().post(); return crystal; } public static ItemStack setTrait(ItemStack crystal, IConstellation constellation) { - if (constellation instanceof IMinorConstellation) - ItemTunedCrystalBase.applyTrait(crystal, (IMinorConstellation) constellation); - else - GroovyLog.msg("Trait constellation must be Minor (Faint)").error().post(); + if (constellation instanceof IMinorConstellation) ItemTunedCrystalBase.applyTrait(crystal, + (IMinorConstellation) constellation); + else GroovyLog.msg("Trait constellation must be Minor (Faint)").error().post(); return crystal; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/crystal/CrystalItemStackExpansion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/crystal/CrystalItemStackExpansion.java index 84b24d9f2..e6f5ef2f1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/crystal/CrystalItemStackExpansion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/crystal/CrystalItemStackExpansion.java @@ -1,8 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery.crystal; -import hellfirepvp.astralsorcery.common.constellation.IConstellation; import net.minecraft.item.ItemStack; +import hellfirepvp.astralsorcery.common.constellation.IConstellation; + public class CrystalItemStackExpansion { public static ItemStack setSize(ItemStack crystal, int size) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/AttributeModifierPerkBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/AttributeModifierPerkBuilder.java index 92c876f09..f5d06bb42 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/AttributeModifierPerkBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/AttributeModifierPerkBuilder.java @@ -1,16 +1,19 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery.perktree; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.compat.mods.ModSupport; + import hellfirepvp.astralsorcery.common.constellation.perk.attribute.AttributeModifierPerk; import hellfirepvp.astralsorcery.common.constellation.perk.attribute.PerkAttributeModifier; import hellfirepvp.astralsorcery.common.constellation.perk.tree.PerkTree; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; public class AttributeModifierPerkBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/GroovyPerkTree.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/GroovyPerkTree.java index cbc7ea5b8..4ec3a417e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/GroovyPerkTree.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/GroovyPerkTree.java @@ -1,5 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery.perktree; +import static hellfirepvp.astralsorcery.common.constellation.perk.tree.PerkTree.PERK_TREE; + +import java.awt.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -7,21 +18,11 @@ import com.cleanroommc.groovyscript.core.mixin.astralsorcery.PerkTreeAccessor; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import hellfirepvp.astralsorcery.common.constellation.perk.AbstractPerk; import hellfirepvp.astralsorcery.common.constellation.perk.tree.PerkTree; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.ApiStatus; - -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import static hellfirepvp.astralsorcery.common.constellation.perk.tree.PerkTree.PERK_TREE; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - isFullyDocumented = false // TODO fully document GroovyPerkTree +@RegistryDescription(category = RegistryDescription.Category.ENTRIES, isFullyDocumented = false // TODO fully document GroovyPerkTree ) public class GroovyPerkTree extends VirtualizedRegistry { @@ -41,15 +42,19 @@ public static AttributeModifierPerkBuilder.PerkModifierBuilder effectBuilder() { return new AttributeModifierPerkBuilder.PerkModifierBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(perk -> this.remove(perk, false)); restoreFromBackup().forEach(perk -> this.add(perk, false)); - this.scriptedConnections.forEach((perk, resourceLocations) -> resourceLocations.forEach(location -> this.removeConnection(perk, this.getPerk(location), false))); - this.removedConnections.forEach((perk, resourceLocations) -> resourceLocations.forEach(location -> this.addConnection(perk, this.getPerk(location), false))); + this.scriptedConnections.forEach((perk, resourceLocations) -> resourceLocations.forEach(location -> this.removeConnection( + perk, + this.getPerk(location), + false))); + this.removedConnections.forEach((perk, resourceLocations) -> resourceLocations.forEach(location -> this.addConnection( + perk, + this.getPerk(location), + false))); this.movedPerks.forEach((perk, point) -> this.movePerk(perk, point.x, point.y, true)); @@ -86,7 +91,8 @@ public AbstractPerk getPerk(ResourceLocation perk) { return PERK_TREE.getPerk(perk); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("mods.astralsorcery.perktree.getPerk('astralsorcery:magnet_ats_reach'), 30, 30")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("mods.astralsorcery.perktree.getPerk('astralsorcery:magnet_ats_reach'), 30, 30")) public void movePerk(AbstractPerk perk, int x, int y) { this.movePerk(perk, x, y, true); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/PerkTreeConfig.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/PerkTreeConfig.java index 7528e9312..238b4c3fb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/PerkTreeConfig.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/perktree/PerkTreeConfig.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery.perktree; +import java.util.Arrays; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -7,18 +11,14 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.astralsorcery.PerkLevelManagerAccessor; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import groovy.lang.Closure; import hellfirepvp.astralsorcery.common.constellation.perk.PerkLevelManager; -import org.jetbrains.annotations.ApiStatus; - -import java.util.Arrays; @RegistryDescription public class PerkTreeConfig extends VirtualizedRegistry> { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { this.xpFunction = null; this.setLevelCap(30); @@ -26,10 +26,12 @@ public void onReload() { public Closure xpFunction; - @MethodDescription(example = @Example(value = "{ int i, long prev -> prev + 1000L + MathHelper.lfloor(Math.pow(2.0, i / 2.0F + 3)) }", imports = "net.minecraft.util.math.MathHelper"), type = MethodDescription.Type.VALUE) + @MethodDescription(example = @Example(value = "{ int i, long prev -> prev + 1000L + MathHelper.lfloor(Math.pow(2.0, i / 2.0F + 3)) }", + imports = "net.minecraft.util.math.MathHelper"), type = MethodDescription.Type.VALUE) public void setXpFunction(Closure func) { if (!Arrays.equals(func.getParameterTypes(), new Class[]{int.class, long.class})) { - GroovyLog.msg("Warning: Astral Perk xp closures must take the following parameters (int levelNumber, long previousLevelXp)").debug().post(); + GroovyLog.msg("Warning: Astral Perk xp closures must take the following parameters (int levelNumber, long previousLevelXp)") + .debug().post(); } this.xpFunction = func; resetLevelMap(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/AltarInputOrder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/AltarInputOrder.java index ecb4e8316..47b756037 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/AltarInputOrder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/AltarInputOrder.java @@ -1,38 +1,29 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery.starlightaltar; +import java.util.Arrays; + import hellfirepvp.astralsorcery.common.crafting.ItemHandle; import hellfirepvp.astralsorcery.common.tile.TileAltar; -import java.util.Arrays; - public class AltarInputOrder { - public static final int[][] DISCOVERY = new int[][]{ - {0, 1, 2}, - {3, 4, 5}, - {6, 7, 8} - }; - public static final int[][] ATTUNEMENT = new int[][]{ - {9, -1, -1, -1, 10}, - {-1, 0, 1, 2, -1}, - {-1, 3, 4, 5, -1}, - {-1, 6, 7, 8, -1}, - {11, -1, -1, -1, 12} - }; - public static final int[][] CONSTELLATION_CRAFT = new int[][]{ - {9, 13, -1, 14, 10}, - {15, 0, 1, 2, 16}, - {-1, 3, 4, 5, -1}, - {17, 6, 7, 8, 18}, - {11, 19, -1, 20, 12} - }; - public static final int[][] TRAIT_CRAFT = new int[][]{ - {9, 13, 21, 14, 10}, - {15, 0, 1, 2, 16}, - {22, 3, 4, 5, 23}, - {17, 6, 7, 8, 18}, - {11, 19, 24, 20, 12} - }; + public static final int[][] DISCOVERY = new int[][]{{0, 1, 2}, {3, 4, 5}, {6, 7, 8}}; + public static final int[][] ATTUNEMENT = new int[][]{{9, -1, -1, -1, 10}, {-1, 0, 1, 2, -1}, {-1, 3, 4, 5, -1}, {-1, 6, 7, 8, + -1}, {11, -1, + -1, -1, + 12}}; + public static final int[][] CONSTELLATION_CRAFT = new int[][]{{9, 13, -1, 14, 10}, {15, 0, 1, 2, 16}, {-1, 3, 4, 5, -1}, {17, + 6, + 7, + 8, + 18}, + {11, 19, -1, 20, 12}}; + public static final int[][] TRAIT_CRAFT = new int[][]{{9, 13, 21, 14, 10}, {15, 0, 1, 2, 16}, {22, 3, 4, 5, 23}, {17, 6, 7, 8, + 18}, {11, + 19, + 24, + 20, + 12}}; public static int[][] getMap(TileAltar.AltarLevel level) { return switch (level) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/AltarRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/AltarRecipeBuilder.java index 0a7b2f378..c00d0da57 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/AltarRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/AltarRecipeBuilder.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery.starlightaltar; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.apache.logging.log4j.Level; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,6 +21,7 @@ import com.cleanroommc.groovyscript.helper.recipe.RecipeName; import com.cleanroommc.groovyscript.registry.AbstractCraftingRecipeBuilder; import com.google.common.collect.Lists; + import hellfirepvp.astralsorcery.common.constellation.IConstellation; import hellfirepvp.astralsorcery.common.crafting.ItemHandle; import hellfirepvp.astralsorcery.common.crafting.altar.AbstractAltarRecipe; @@ -23,13 +33,6 @@ import hellfirepvp.astralsorcery.common.crafting.helper.ShapedRecipe; import hellfirepvp.astralsorcery.common.crafting.helper.ShapedRecipeSlot; import hellfirepvp.astralsorcery.common.tile.TileAltar; -import net.minecraft.item.ItemStack; -import org.apache.logging.log4j.Level; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; public class AltarRecipeBuilder { @@ -60,12 +63,13 @@ private static List computeFluidConsumptionSlots(ItemHandle[] inputs) { return fluidInputs; } - private static DiscoveryRecipe discoveryAltar(String name, ItemStack output, ItemHandle[] inputs, int starlightRequired, int craftingTickTime, List fluidStacks) { - return new DiscoveryRecipe(registerNative(name, output, inputs)) { + private static DiscoveryRecipe discoveryAltar(String name, ItemStack output, ItemHandle[] inputs, int starlightRequired, + int craftingTickTime, List fluidStacks) { + return new DiscoveryRecipe(registerNative(name, output, inputs)) + { + @Override - public int getPassiveStarlightRequired() { - return starlightRequired; - } + public int getPassiveStarlightRequired() { return starlightRequired; } @Override public int craftingTickTime() { @@ -79,12 +83,13 @@ public boolean mayDecrement(TileAltar ta, ShapedRecipeSlot slot) { }; } - private static AttunementRecipe attunementAltar(String name, ItemStack output, ItemHandle[] inputs, int starlightRequired, int craftingTickTime, List fluidStacks) { - AttunementRecipe recipe = new AttunementRecipe(registerNative(name, output, inputs)) { + private static AttunementRecipe attunementAltar(String name, ItemStack output, ItemHandle[] inputs, int starlightRequired, + int craftingTickTime, List fluidStacks) { + AttunementRecipe recipe = new AttunementRecipe(registerNative(name, output, inputs)) + { + @Override - public int getPassiveStarlightRequired() { - return starlightRequired; - } + public int getPassiveStarlightRequired() { return starlightRequired; } @Override public int craftingTickTime() { @@ -111,12 +116,14 @@ public boolean mayDecrement(TileAltar ta, AttunementAltarSlot slot) { return recipe; } - private static ConstellationRecipe constellationAltar(String name, ItemStack output, ItemHandle[] inputs, int starlightRequired, int craftingTickTime, List fluidStacks) { - ConstellationRecipe recipe = new ConstellationRecipe(registerNative(name, output, inputs)) { + private static ConstellationRecipe constellationAltar(String name, ItemStack output, ItemHandle[] inputs, + int starlightRequired, int craftingTickTime, + List fluidStacks) { + ConstellationRecipe recipe = new ConstellationRecipe(registerNative(name, output, inputs)) + { + @Override - public int getPassiveStarlightRequired() { - return starlightRequired; - } + public int getPassiveStarlightRequired() { return starlightRequired; } @Override public int craftingTickTime() { @@ -153,12 +160,14 @@ public boolean mayDecrement(TileAltar ta, ConstellationAtlarSlot slot) { return recipe; } - private static TraitRecipe traitAltar(String name, ItemStack output, ItemHandle[] inputs, int starlightRequired, int craftingTickTime, List fluidStacks, IConstellation requiredConstellation, ItemHandle[] outerInputs) { - TraitRecipe recipe = new TraitRecipe(registerNative(name, output, inputs)) { + private static TraitRecipe traitAltar(String name, ItemStack output, ItemHandle[] inputs, int starlightRequired, + int craftingTickTime, List fluidStacks, IConstellation requiredConstellation, + ItemHandle[] outerInputs) { + TraitRecipe recipe = new TraitRecipe(registerNative(name, output, inputs)) + { + @Override - public int getPassiveStarlightRequired() { - return starlightRequired; - } + public int getPassiveStarlightRequired() { return starlightRequired; } @Override public int craftingTickTime() { @@ -219,7 +228,9 @@ public boolean mayDecrement(TileAltar ta, TraitRecipeSlot slot) { @Property(property = "mirrored", needsOverride = true) @Property(property = "recipeFunction", needsOverride = true) @Property(property = "recipeAction", needsOverride = true) - @Property(property = "name", ignoresInheritedMethods = true, value = "groovyscript.wiki.astralsorcery.starlight_altar.name.value") + @Property(property = "name", + ignoresInheritedMethods = true, + value = "groovyscript.wiki.astralsorcery.starlight_altar.name.value") public static class Shaped extends AbstractCraftingRecipeBuilder.AbstractShaped { private final TileAltar.AltarLevel altarLevel; @@ -242,8 +253,7 @@ public Shaped(int width, int height, TileAltar.AltarLevel level) { this.keyMap.put(' ', IIngredient.EMPTY); } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public Shaped name(String name) { this.name = name; return this; @@ -293,9 +303,7 @@ public Shaped outerInput(Collection ings) { private boolean flattenMatrix() { ItemHandle[] in = AltarInputOrder.initInputList(this.altarLevel); int[][] map = AltarInputOrder.getMap(this.altarLevel); - if (map == null || in == null) { - return false; - } + if (map == null || in == null) { return false; } for (int i = 0; i < this.keyBasedMatrix.length; i++) { String row = this.keyBasedMatrix[i]; @@ -318,12 +326,9 @@ private boolean flattenMatrix() { } @Override - public String getRecipeNamePrefix() { - return "groovyscript_starlight_altar_recipe_"; - } + public String getRecipeNamePrefix() { return "groovyscript_starlight_altar_recipe_"; } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void validateName() { if (name == null) { name = RecipeName.generate(getRecipeNamePrefix()); @@ -363,8 +368,7 @@ public boolean validate() { return (out.getLevel() != Level.ERROR && this.flattenMatrix()); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public AbstractAltarRecipe register() { if (!validate()) return null; @@ -372,12 +376,14 @@ public AbstractAltarRecipe register() { AbstractAltarRecipe recipe = switch (altarLevel) { case DISCOVERY -> discoveryAltar(name, output, inputs, starlightRequired, craftingTickTime, fluidStacks); case ATTUNEMENT -> attunementAltar(name, output, inputs, starlightRequired, craftingTickTime, fluidStacks); - case CONSTELLATION_CRAFT -> constellationAltar(name, output, inputs, starlightRequired, craftingTickTime, fluidStacks); - case TRAIT_CRAFT -> traitAltar(name, output, inputs, starlightRequired, craftingTickTime, fluidStacks, requiredConstellation, outerInputs); + case CONSTELLATION_CRAFT -> constellationAltar(name, output, inputs, starlightRequired, craftingTickTime, + fluidStacks); + case TRAIT_CRAFT -> traitAltar(name, output, inputs, starlightRequired, craftingTickTime, fluidStacks, + requiredConstellation, outerInputs); default -> null; }; ModSupport.ASTRAL_SORCERY.get().altar.add(recipe); return recipe; } } -} \ No newline at end of file +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/StarlightAltar.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/StarlightAltar.java index 2a5f487cb..822c623e9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/StarlightAltar.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/starlightaltar/StarlightAltar.java @@ -1,57 +1,75 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery.starlightaltar; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import hellfirepvp.astralsorcery.common.crafting.altar.AbstractAltarRecipe; import hellfirepvp.astralsorcery.common.crafting.altar.AltarRecipeRegistry; import hellfirepvp.astralsorcery.common.tile.TileAltar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; - -import java.util.stream.Collectors; @RegistryDescription public class StarlightAltar extends VirtualizedRegistry { - @RecipeBuilderDescription(priority = 100, requirement = { - @Property(property = "ingredientMatrix", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", type = Comp.Type.LTE)}), - @Property(property = "starlightRequired", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "1000", type = Comp.Type.LTE)}) - }, example = @Example(".output(item('minecraft:water_bucket')).row(' ').row(' B ').row(' ').key('B', item('minecraft:bucket')).starlight(500).craftTime(10)")) + @RecipeBuilderDescription(priority = 100, + requirement = {@Property(property = "ingredientMatrix", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", + type = Comp.Type.LTE)}), + @Property(property = "starlightRequired", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "1000", + type = Comp.Type.LTE)})}, + example = @Example(".output(item('minecraft:water_bucket')).row(' ').row(' B ').row(' ').key('B', item('minecraft:bucket')).starlight(500).craftTime(10)")) public static AltarRecipeBuilder.Shaped discoveryRecipeBuilder() { return new AltarRecipeBuilder.Shaped(3, 3, TileAltar.AltarLevel.DISCOVERY); } - @RecipeBuilderDescription(priority = 200, requirement = { - @Property(property = "ingredientMatrix", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "13", type = Comp.Type.LTE)}), - @Property(property = "starlightRequired", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "2000", type = Comp.Type.LTE)}) - }) + @RecipeBuilderDescription(priority = 200, + requirement = {@Property(property = "ingredientMatrix", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "13", + type = Comp.Type.LTE)}), + @Property(property = "starlightRequired", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "2000", + type = Comp.Type.LTE)})}) public static AltarRecipeBuilder.Shaped attunementRecipeBuilder() { return new AltarRecipeBuilder.Shaped(5, 5, TileAltar.AltarLevel.ATTUNEMENT); } - @RecipeBuilderDescription(priority = 300, requirement = { - @Property(property = "ingredientMatrix", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "21", type = Comp.Type.LTE)}), - @Property(property = "starlightRequired", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "4000", type = Comp.Type.LTE)}) - }, example = @Example(".output(item('minecraft:pumpkin')).matrix('ss ss', 's s', ' d ', 's s', 'ss ss').key('s', item('minecraft:pumpkin_seeds')).key('d', ore('dirt'))")) + @RecipeBuilderDescription(priority = 300, + requirement = {@Property(property = "ingredientMatrix", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "21", + type = Comp.Type.LTE)}), + @Property(property = "starlightRequired", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "4000", + type = Comp.Type.LTE)})}, + example = @Example(".output(item('minecraft:pumpkin')).matrix('ss ss', 's s', ' d ', 's s', 'ss ss').key('s', item('minecraft:pumpkin_seeds')).key('d', ore('dirt'))")) public static AltarRecipeBuilder.Shaped constellationRecipeBuilder() { return new AltarRecipeBuilder.Shaped(5, 5, TileAltar.AltarLevel.CONSTELLATION_CRAFT); } - @RecipeBuilderDescription(priority = 400, requirement = { - @Property(property = "ingredientMatrix", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "25", type = Comp.Type.LTE)}), - @Property(property = "outerIngredients", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "24", type = Comp.Type.LTE)}), - @Property(property = "starlightRequired", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "8000", type = Comp.Type.LTE)}), - @Property(property = "requiredConstellation") - }, example = @Example(".output(item('astralsorcery:itemrockcrystalsimple').setSize(300).setPurity(50).setCutting(50)).matrix('sssss', 'sgggs', 'sgdgs', 'sgggs', 'sssss').key('s', item('minecraft:pumpkin')).key('g', ore('treeLeaves')).key('d', item('minecraft:diamond_block')).outerInput(item('astralsorcery:blockmarble')).outerInput(ore('ingotAstralStarmetal')).outerInput(fluid('astralsorcery.liquidstarlight') * 1000).outerInput(ore('treeSapling')).constellation(constellation('discidia'))")) + @RecipeBuilderDescription(priority = 400, + requirement = {@Property(property = "ingredientMatrix", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "25", + type = Comp.Type.LTE)}), + @Property(property = "outerIngredients", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "24", + type = Comp.Type.LTE)}), + @Property(property = "starlightRequired", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "8000", + type = Comp.Type.LTE)}), + @Property(property = "requiredConstellation")}, + example = @Example(".output(item('astralsorcery:itemrockcrystalsimple').setSize(300).setPurity(50).setCutting(50)).matrix('sssss', 'sgggs', 'sgdgs', 'sgggs', 'sssss').key('s', item('minecraft:pumpkin')).key('g', ore('treeLeaves')).key('d', item('minecraft:diamond_block')).outerInput(item('astralsorcery:blockmarble')).outerInput(ore('ingotAstralStarmetal')).outerInput(fluid('astralsorcery.liquidstarlight') * 1000).outerInput(ore('treeSapling')).constellation(constellation('discidia'))")) public static AltarRecipeBuilder.Shaped traitRecipeBuilder() { return new AltarRecipeBuilder.Shaped(5, 5, TileAltar.AltarLevel.TRAIT_CRAFT); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(r -> AltarRecipeRegistry.recipes.get(r.getNeededLevel()).removeIf(rec -> rec.equals(r))); restoreFromBackup().forEach(r -> AltarRecipeRegistry.recipes.get(r.getNeededLevel()).add(r)); @@ -94,8 +112,8 @@ private boolean remove(AbstractAltarRecipe recipe) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(AltarRecipeRegistry.recipes.entrySet().stream().flatMap(r -> r.getValue().stream()).collect(Collectors.toList())) - .setRemover(this::remove); + return new SimpleObjectStream<>(AltarRecipeRegistry.recipes.entrySet().stream().flatMap(r -> r.getValue().stream()) + .collect(Collectors.toList())).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/Compressor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/Compressor.java index 22a2299e6..c015a919e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/Compressor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/Compressor.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.avaritia; +import java.util.Collections; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,13 +13,10 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import morph.avaritia.recipe.AvaritiaRecipeManager; import morph.avaritia.recipe.compressor.CompressorRecipe; import morph.avaritia.recipe.compressor.ICompressorRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.Collections; @RegistryDescription public class Compressor extends VirtualizedRegistry { @@ -36,10 +39,7 @@ public boolean remove(ICompressorRecipe recipe) { @MethodDescription(example = @Example("item('avaritia:singularity', 0)")) public boolean removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing avaritia compressor recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing avaritia compressor recipe").add("output must not be empty").error().post(); return false; } return AvaritiaRecipeManager.COMPRESSOR_RECIPES.values().removeIf(recipe -> { @@ -72,24 +72,19 @@ public void add(ICompressorRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:nether_star'), item('minecraft:clay_ball'), 100")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("item('minecraft:nether_star'), item('minecraft:clay_ball'), 100")) public void add(ItemStack output, IIngredient input, int cost) { - recipeBuilder() - .inputCount(cost) - .input(input) - .output(output) - .register(); + recipeBuilder().inputCount(cost).input(input).output(output).register(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "300") private int inputCount = 300; - @Override - @RecipeBuilderMethodDescription(field = {"input", "inputCount"}) + @Override @RecipeBuilderMethodDescription(field = {"input", "inputCount"}) public AbstractRecipeBuilder input(IIngredient ingredient) { if (ingredient == null) return this; if (ingredient.getAmount() > 1) { @@ -105,14 +100,10 @@ public RecipeBuilder inputCount(int inputCount) { } @Override - public String getRecipeNamePrefix() { - return "avaritia_compressor_"; - } + public String getRecipeNamePrefix() { return "avaritia_compressor_"; } @Override - public String getErrorMsg() { - return "Error adding Avaritia compressor recipe"; - } + public String getErrorMsg() { return "Error adding Avaritia compressor recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -124,11 +115,12 @@ public void validate(GroovyLog.Msg msg) { } } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ICompressorRecipe register() { if (!validate()) return null; - CompressorRecipe recipe = new CompressorRecipe(this.output.get(0), this.inputCount, true, Collections.singletonList(this.input.get(0).toMcIngredient())); + CompressorRecipe recipe = new CompressorRecipe(this.output.get(0), this.inputCount, true, Collections.singletonList( + this.input.get(0) + .toMcIngredient())); recipe.setRegistryName(this.name); add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeCrafting.java index 77355b4fc..a9f806f4b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeCrafting.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.avaritia; +import java.util.List; + +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -7,19 +11,15 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import morph.avaritia.recipe.AvaritiaRecipeManager; import morph.avaritia.recipe.extreme.IExtremeRecipe; -import net.minecraft.item.ItemStack; - -import java.util.List; @RegistryDescription public class ExtremeCrafting extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".matrix([[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')]]).output(item('minecraft:gold_block'))"), - @Example(".output(item('minecraft:stone') * 64).matrix('DLLLLLDDD', ' DNIGIND', 'DDDNIGIND', ' DLLLLLD').key('D', item('minecraft:diamond')).key('L', item('minecraft:redstone')).key('N', item('minecraft:stone').reuse()).key('I', item('minecraft:iron_ingot')).key('G', item('minecraft:gold_ingot'))") - }) + @RecipeBuilderDescription(example = {@Example(".matrix([[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot')]]).output(item('minecraft:gold_block'))"), + @Example(".output(item('minecraft:stone') * 64).matrix('DLLLLLDDD', ' DNIGIND', 'DDDNIGIND', ' DLLLLLD').key('D', item('minecraft:diamond')).key('L', item('minecraft:redstone')).key('N', item('minecraft:stone').reuse()).key('I', item('minecraft:iron_ingot')).key('G', item('minecraft:gold_ingot'))")}) public ExtremeRecipeBuilder.Shaped shapedBuilder() { return new ExtremeRecipeBuilder.Shaped(); } @@ -37,18 +37,12 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.ADDITION) public IExtremeRecipe addShaped(ItemStack output, List> input) { - return shapedBuilder() - .matrix(input) - .output(output) - .register(); + return shapedBuilder().matrix(input).output(output).register(); } @MethodDescription(type = MethodDescription.Type.ADDITION) public IExtremeRecipe addShapeless(ItemStack output, List input) { - return shapelessBuilder() - .input(input) - .output(output) - .register(); + return shapelessBuilder().input(input).output(output).register(); } public IExtremeRecipe add(IExtremeRecipe recipe) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeRecipeBuilder.java index 5a7d24071..deae024c8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeRecipeBuilder.java @@ -7,11 +7,13 @@ import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.AbstractCraftingRecipeBuilder; + import morph.avaritia.recipe.extreme.IExtremeRecipe; public interface ExtremeRecipeBuilder { - @Property(property = "ingredientMatrix", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "81", type = Comp.Type.LTE)}) + @Property(property = "ingredientMatrix", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "81", type = Comp.Type.LTE)}) class Shaped extends AbstractCraftingRecipeBuilder.AbstractShaped { public Shaped() { @@ -19,23 +21,36 @@ public Shaped() { } @Override - public String getRecipeNamePrefix() { - return "groovyscript_extreme_shaped_"; - } + public String getRecipeNamePrefix() { return "groovyscript_extreme_shaped_"; } - @Override - @RecipeBuilderRegistrationMethod(hierarchy = 5) + @Override @RecipeBuilderRegistrationMethod(hierarchy = 5) public IExtremeRecipe register() { - GroovyLog.Msg msg = GroovyLog.msg("Error adding shaped Extended Crafting Table recipe").error() - .add((keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), () -> "No matrix was defined") - .add(keyBasedMatrix != null && ingredientMatrix != null, () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!"); + GroovyLog.Msg msg = GroovyLog.msg("Error adding shaped Extended Crafting Table recipe").error().add( + (keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), + () -> "No matrix was defined") + .add(keyBasedMatrix != null && ingredientMatrix != null, + () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!"); if (msg.postIfNotEmpty()) return null; msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); IExtremeRecipe recipe = null; if (keyBasedMatrix != null) { - recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> ExtremeShapedRecipe.make(output, ingredients, width1, height1, mirrored, recipeFunction, recipeAction))); + recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> ExtremeShapedRecipe + .make(output, + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction))); } else if (ingredientMatrix != null) { - recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> ExtremeShapedRecipe.make(output.copy(), ingredients, width1, height1, mirrored, recipeFunction, recipeAction))); + recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> ExtremeShapedRecipe.make(output + .copy(), + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction))); } if (msg.postIfNotEmpty()) return null; if (recipe != null) { @@ -47,7 +62,8 @@ public IExtremeRecipe register() { } } - @Property(property = "ingredients", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "81", type = Comp.Type.LTE)}) + @Property(property = "ingredients", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "81", type = Comp.Type.LTE)}) class Shapeless extends AbstractCraftingRecipeBuilder.AbstractShapeless { public Shapeless() { @@ -55,20 +71,18 @@ public Shapeless() { } @Override - public String getRecipeNamePrefix() { - return "groovyscript_extreme_shapeless_"; - } + public String getRecipeNamePrefix() { return "groovyscript_extreme_shapeless_"; } public boolean validate() { GroovyLog.Msg msg = GroovyLog.msg("Error adding shapeless Extended Crafting Table recipe").error(); msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); msg.add(ingredients.isEmpty(), () -> "inputs must not be empty"); - msg.add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + ingredients.size()); + msg.add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + + ingredients.size()); return !msg.postIfNotEmpty(); } - @Override - @RecipeBuilderRegistrationMethod(hierarchy = 5) + @Override @RecipeBuilderRegistrationMethod(hierarchy = 5) public IExtremeRecipe register() { if (!validate()) return null; validateName(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeShapedRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeShapedRecipe.java index 1e6c06264..d43b8d3b4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeShapedRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeShapedRecipe.java @@ -1,24 +1,29 @@ package com.cleanroommc.groovyscript.compat.mods.avaritia; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; -import groovy.lang.Closure; +import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.common.crafting.CraftingHelper; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; + +import groovy.lang.Closure; public class ExtremeShapedRecipe extends morph.avaritia.recipe.extreme.ExtremeShapedRecipe { private final ShapedCraftingRecipe groovyRecipe; - public static ExtremeShapedRecipe make(ItemStack output, List input, int width, int height, boolean mirrored, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { - ShapedCraftingRecipe recipe = new ShapedCraftingRecipe(output, input, width, height, mirrored, recipeFunction, recipeAction); + public static ExtremeShapedRecipe make(ItemStack output, List input, int width, int height, boolean mirrored, + @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { + ShapedCraftingRecipe recipe = new ShapedCraftingRecipe(output, input, width, height, mirrored, recipeFunction, + recipeAction); CraftingHelper.ShapedPrimer primer = new CraftingHelper.ShapedPrimer(); primer.width = width; primer.height = height; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeShapelessRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeShapelessRecipe.java index 7ac3dba42..919f4bc1f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeShapelessRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/avaritia/ExtremeShapelessRecipe.java @@ -1,22 +1,26 @@ package com.cleanroommc.groovyscript.compat.mods.avaritia; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; -import groovy.lang.Closure; +import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.world.World; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; + +import groovy.lang.Closure; public class ExtremeShapelessRecipe extends morph.avaritia.recipe.extreme.ExtremeShapelessRecipe { private final ShapelessCraftingRecipe groovyRecipe; - public static ExtremeShapelessRecipe make(ItemStack output, List input, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { + public static ExtremeShapelessRecipe make(ItemStack output, List input, + @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { ShapelessCraftingRecipe recipe = new ShapelessCraftingRecipe(output, input, recipeFunction, recipeAction); return new ExtremeShapelessRecipe(recipe); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilCrafting.java index 91a4fa617..53f7ee325 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilCrafting.java @@ -1,6 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.registry.anvil.AnvilCraftingManager; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.Ingredient; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -9,9 +12,8 @@ import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; + +import betterwithmods.common.registry.anvil.AnvilCraftingManager; @RegistryDescription public class AnvilCrafting extends VirtualizedRegistry { @@ -20,10 +22,8 @@ public AnvilCrafting() { super(Alias.generateOfClass(AnvilCrafting.class).andGenerate("SoulforgedSteelAnvil")); } - @RecipeBuilderDescription(example = { - @Example(".output(item('minecraft:diamond') * 32).matrix([[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],[null,null,null,item('minecraft:gold_ingot').transform({ _ -> item('minecraft:diamond') })]])"), - @Example(".output(item('minecraft:diamond')).matrix('BXXX').mirrored().key('B', item('minecraft:stone')).key('X', item('minecraft:gold_ingot'))") - }) + @RecipeBuilderDescription(example = {@Example(".output(item('minecraft:diamond') * 32).matrix([[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],[null,null,null,item('minecraft:gold_ingot').transform({ _ -> item('minecraft:diamond') })]])"), + @Example(".output(item('minecraft:diamond')).matrix('BXXX').mirrored().key('B', item('minecraft:stone')).key('X', item('minecraft:gold_ingot'))")}) public AnvilRecipeBuilder.Shaped shapedBuilder() { return new AnvilRecipeBuilder.Shaped(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilRecipeBuilder.java index 41f049679..33cefda67 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilRecipeBuilder.java @@ -1,7 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.registry.anvil.ShapedAnvilRecipe; -import betterwithmods.common.registry.anvil.ShapelessAnvilRecipe; +import net.minecraft.item.crafting.IRecipe; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Comp; import com.cleanroommc.groovyscript.api.documentation.annotations.Property; @@ -9,30 +9,49 @@ import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.AbstractCraftingRecipeBuilder; -import net.minecraft.item.crafting.IRecipe; + +import betterwithmods.common.registry.anvil.ShapedAnvilRecipe; +import betterwithmods.common.registry.anvil.ShapelessAnvilRecipe; public interface AnvilRecipeBuilder { - @Property(property = "ingredientMatrix", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "16", type = Comp.Type.LTE)}) + @Property(property = "ingredientMatrix", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "16", type = Comp.Type.LTE)}) class Shaped extends AbstractCraftingRecipeBuilder.AbstractShaped { public Shaped() { super(4, 4); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IRecipe register() { - GroovyLog.Msg msg = GroovyLog.msg("Error adding shaped Better With Mods Anvil recipe").error() - .add((keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), () -> "No matrix was defined") - .add(keyBasedMatrix != null && ingredientMatrix != null, () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!"); + GroovyLog.Msg msg = GroovyLog.msg("Error adding shaped Better With Mods Anvil recipe").error().add( + (keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), + () -> "No matrix was defined") + .add(keyBasedMatrix != null && ingredientMatrix != null, + () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!"); if (msg.postIfNotEmpty()) return null; msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); ShapedAnvilRecipe recipe = null; if (keyBasedMatrix != null) { - recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> AnvilShapedRecipe.make(name, output, ingredients, width1, height1, mirrored, recipeFunction, recipeAction))); + recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> AnvilShapedRecipe + .make(name, + output, + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction))); } else if (ingredientMatrix != null) { - recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> AnvilShapedRecipe.make(name, output.copy(), ingredients, width1, height1, mirrored, recipeFunction, recipeAction))); + recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> AnvilShapedRecipe.make(name, + output.copy(), + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction))); } if (msg.postIfNotEmpty()) return null; if (recipe != null) { @@ -43,7 +62,8 @@ public IRecipe register() { } } - @Property(property = "ingredients", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "16", type = Comp.Type.LTE)}) + @Property(property = "ingredients", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "16", type = Comp.Type.LTE)}) class Shapeless extends AbstractCraftingRecipeBuilder.AbstractShapeless { public Shapeless() { @@ -54,15 +74,16 @@ public boolean validate() { GroovyLog.Msg msg = GroovyLog.msg("Error adding shapeless Better With Mods Anvil recipe").error(); msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); msg.add(ingredients.isEmpty(), () -> "inputs must not be empty"); - msg.add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + ingredients.size()); + msg.add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + + ingredients.size()); return !msg.postIfNotEmpty(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IRecipe register() { if (!validate()) return null; - ShapelessAnvilRecipe recipe = AnvilShapelessRecipe.make(name, output.copy(), ingredients, recipeFunction, recipeAction); + ShapelessAnvilRecipe recipe = AnvilShapelessRecipe.make(name, output.copy(), ingredients, recipeFunction, + recipeAction); ModSupport.BETTER_WITH_MODS.get().anvilCrafting.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilShapedRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilShapedRecipe.java index 696318835..f6e0fa1f7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilShapedRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilShapedRecipe.java @@ -1,36 +1,43 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.registry.anvil.ShapedAnvilRecipe; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; -import groovy.lang.Closure; +import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.common.crafting.CraftingHelper; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; + +import betterwithmods.common.registry.anvil.ShapedAnvilRecipe; +import groovy.lang.Closure; public class AnvilShapedRecipe extends ShapedAnvilRecipe { private final ShapedCraftingRecipe groovyRecipe; - private AnvilShapedRecipe(ResourceLocation resourceLocation, ShapedCraftingRecipe groovyRecipe, CraftingHelper.ShapedPrimer primer) { + private AnvilShapedRecipe(ResourceLocation resourceLocation, ShapedCraftingRecipe groovyRecipe, + CraftingHelper.ShapedPrimer primer) { super(resourceLocation, groovyRecipe.getRecipeOutput(), primer); this.groovyRecipe = groovyRecipe; setMirrored(this.groovyRecipe.isMirrored()); } -// public static AnvilShapedRecipe make(ItemStack output, List input, int width, int height, boolean mirrored, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { -// return make(null, output, input, width, height, mirrored, recipeFunction, recipeAction); -// } + // public static AnvilShapedRecipe make(ItemStack output, List input, int width, int height, boolean mirrored, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { + // return make(null, output, input, width, height, mirrored, recipeFunction, recipeAction); + // } - public static AnvilShapedRecipe make(ResourceLocation resourceLocation, ItemStack output, List input, int width, int height, boolean mirrored, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { - ShapedCraftingRecipe recipe = new ShapedCraftingRecipe(output, input, width, height, mirrored, recipeFunction, recipeAction); + public static AnvilShapedRecipe make(ResourceLocation resourceLocation, ItemStack output, List input, int width, + int height, boolean mirrored, @Nullable Closure recipeFunction, + @Nullable Closure recipeAction) { + ShapedCraftingRecipe recipe = new ShapedCraftingRecipe(output, input, width, height, mirrored, recipeFunction, + recipeAction); CraftingHelper.ShapedPrimer primer = new CraftingHelper.ShapedPrimer(); primer.width = width; primer.height = height; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilShapelessRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilShapelessRecipe.java index 191e88830..4e628a9ba 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilShapelessRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilShapelessRecipe.java @@ -1,18 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.registry.anvil.ShapelessAnvilRecipe; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; -import groovy.lang.Closure; +import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; + +import betterwithmods.common.registry.anvil.ShapelessAnvilRecipe; +import groovy.lang.Closure; public class AnvilShapelessRecipe extends ShapelessAnvilRecipe { @@ -23,11 +26,12 @@ public AnvilShapelessRecipe(ResourceLocation resourceLocation, ShapelessCrafting this.groovyRecipe = groovyRecipe; } -// public static AnvilShapelessRecipe make(ItemStack output, List input, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { -// return make(null, output, input, recipeFunction, recipeAction); -// } + // public static AnvilShapelessRecipe make(ItemStack output, List input, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { + // return make(null, output, input, recipeFunction, recipeAction); + // } - public static AnvilShapelessRecipe make(ResourceLocation resourceLocation, ItemStack output, List input, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { + public static AnvilShapelessRecipe make(ResourceLocation resourceLocation, ItemStack output, List input, + @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { ShapelessCraftingRecipe recipe = new ShapelessCraftingRecipe(output, input, recipeFunction, recipeAction); return new AnvilShapelessRecipe(resourceLocation, recipe); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Cauldron.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Cauldron.java index 56f7f7621..201aa6511 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Cauldron.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Cauldron.java @@ -1,7 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.BWRegistry; -import betterwithmods.common.registry.bulk.recipes.CookingPotRecipe; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,20 +14,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; -import java.util.stream.Collectors; +import betterwithmods.common.BWRegistry; +import betterwithmods.common.registry.bulk.recipes.CookingPotRecipe; @RegistryDescription public class Cauldron extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"), - @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16).ignoreHeat()") - }) - @RecipeBuilderMethodDescription + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"), + @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16).ignoreHeat()")}) + @RecipeBuilderMethodDescription public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -124,9 +125,7 @@ public RecipeBuilder priority(int priority) { } @Override - public String getErrorMsg() { - return "Error adding Better With Mods Cauldron recipe"; - } + public String getErrorMsg() { return "Error adding Better With Mods Cauldron recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -134,12 +133,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CookingPotRecipe register() { if (!validate()) return null; - CookingPotRecipe recipe = new CookingPotRecipe(input.stream().map(IIngredient::toMcIngredient).collect(Collectors.toList()), output, heat); + CookingPotRecipe recipe = new CookingPotRecipe(input.stream().map(IIngredient::toMcIngredient).collect(Collectors + .toList()), + output, heat); recipe.setIgnoreHeat(ignoreHeat); recipe.setPriority(priority); ModSupport.BETTER_WITH_MODS.get().cauldron.add(recipe); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Crucible.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Crucible.java index 0c40d42b5..235e6fb8d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Crucible.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Crucible.java @@ -1,7 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.BWRegistry; -import betterwithmods.common.registry.bulk.recipes.CookingPotRecipe; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraftforge.items.ItemHandlerHelper; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,21 +16,16 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraftforge.items.ItemHandlerHelper; -import org.jetbrains.annotations.Nullable; -import java.util.stream.Collectors; +import betterwithmods.common.BWRegistry; +import betterwithmods.common.registry.bulk.recipes.CookingPotRecipe; @RegistryDescription public class Crucible extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"), - @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16).ignoreHeat()") - }) - @RecipeBuilderMethodDescription + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"), + @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16).ignoreHeat()")}) + @RecipeBuilderMethodDescription public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -129,9 +130,7 @@ public RecipeBuilder priority(int priority) { } @Override - public String getErrorMsg() { - return "Error adding Better With Mods Cauldron recipe"; - } + public String getErrorMsg() { return "Error adding Better With Mods Cauldron recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -139,12 +138,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CookingPotRecipe register() { if (!validate()) return null; - CookingPotRecipe recipe = new CookingPotRecipe(input.stream().map(IIngredient::toMcIngredient).collect(Collectors.toList()), output, heat); + CookingPotRecipe recipe = new CookingPotRecipe(input.stream().map(IIngredient::toMcIngredient).collect(Collectors + .toList()), + output, heat); recipe.setIgnoreHeat(ignoreHeat); recipe.setPriority(priority); ModSupport.BETTER_WITH_MODS.get().crucible.add(recipe); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Heat.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Heat.java index ee4c17748..aa2715375 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Heat.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Heat.java @@ -1,7 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.registry.block.recipe.BlockIngredient; -import betterwithmods.common.registry.heat.BWMHeatRegistry; +import java.util.List; + +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; @@ -10,17 +12,14 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.betterwithmods.BWMHeatRegistryAccessor; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import java.util.List; +import betterwithmods.common.registry.block.recipe.BlockIngredient; +import betterwithmods.common.registry.heat.BWMHeatRegistry; -@RegistryDescription( - admonition = @Admonition("groovyscript.wiki.betterwithmods.heat.note0") -) +@RegistryDescription(admonition = @Admonition("groovyscript.wiki.betterwithmods.heat.note0")) public class Heat extends VirtualizedRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(recipe -> BWMHeatRegistryAccessor.getHEAT_SOURCES().removeIf(r -> r == recipe)); BWMHeatRegistryAccessor.getHEAT_SOURCES().addAll(restoreFromBackup()); @@ -52,7 +51,8 @@ public void add(int heat, List input) { add(heat, new BlockIngredient(input)); } - @MethodDescription(type = MethodDescription.Type.VALUE, example = @Example("4, item('minecraft:redstone_block'), item('minecraft:redstone_torch')")) + @MethodDescription(type = MethodDescription.Type.VALUE, + example = @Example("4, item('minecraft:redstone_block'), item('minecraft:redstone_torch')")) public void add(int heat, ItemStack... input) { add(heat, new BlockIngredient(input)); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Hopper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Hopper.java index 7b06ae6ab..b10d3304f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Hopper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Hopper.java @@ -1,6 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.registry.HopperInteractions; +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,18 +14,14 @@ import com.cleanroommc.groovyscript.helper.ingredient.ItemStackList; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.Collection; +import betterwithmods.common.registry.HopperInteractions; @RegistryDescription public class Hopper extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('betterwithmods:iron_bar').input(ore('sand')).output(item('minecraft:clay')).inWorldItemOutput(item('minecraft:gold_ingot'))"), - @Example(".name('betterwithmods:wicker').input(item('minecraft:clay')).inWorldItemOutput(item('minecraft:gold_ingot'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('betterwithmods:iron_bar').input(ore('sand')).output(item('minecraft:clay')).inWorldItemOutput(item('minecraft:gold_ingot'))"), + @Example(".name('betterwithmods:wicker').input(item('minecraft:clay')).inWorldItemOutput(item('minecraft:gold_ingot'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -84,7 +85,9 @@ public void removeAll() { HopperInteractions.RECIPES.clear(); } - @Property(property = "name", value = "groovyscript.wiki.betterwithmods.hopper.name.value", valid = @Comp(value = "null", type = Comp.Type.NOT)) + @Property(property = "name", + value = "groovyscript.wiki.betterwithmods.hopper.name.value", + valid = @Comp(value = "null", type = Comp.Type.NOT)) @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "2", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { @@ -115,9 +118,7 @@ public RecipeBuilder inWorldItemOutput(Collection inWorldItemOutputs) } @Override - public String getErrorMsg() { - return "Error adding Better With Mods Filtered Hopper recipe"; - } + public String getErrorMsg() { return "Error adding Better With Mods Filtered Hopper recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -127,12 +128,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable HopperInteractions.HopperRecipe register() { if (!validate()) return null; - HopperInteractions.HopperRecipe recipe = new HopperInteractions.HopperRecipe(super.name.toString(), input.get(0).toMcIngredient(), output, inWorldItemOutput); + HopperInteractions.HopperRecipe recipe = new HopperInteractions.HopperRecipe(super.name.toString(), input.get(0) + .toMcIngredient(), + output, inWorldItemOutput); ModSupport.BETTER_WITH_MODS.get().hopper.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/HopperFilters.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/HopperFilters.java index d1ef1d484..1cd3444a3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/HopperFilters.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/HopperFilters.java @@ -1,8 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.api.tile.IHopperFilter; -import betterwithmods.common.BWRegistry; -import betterwithmods.common.registry.HopperFilter; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -12,27 +16,27 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; -import java.util.stream.Collectors; +import betterwithmods.api.tile.IHopperFilter; +import betterwithmods.common.BWRegistry; +import betterwithmods.common.registry.HopperFilter; @RegistryDescription public class HopperFilters extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('too_weak_to_stop').filter(item('minecraft:string'))"), - @Example(".name('groovyscript:clay_only').filter(item('minecraft:clay')).input(item('minecraft:clay'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('too_weak_to_stop').filter(item('minecraft:string'))"), + @Example(".name('groovyscript:clay_only').filter(item('minecraft:clay')).input(item('minecraft:clay'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @Override public void onReload() { - removeScripted().forEach(recipe -> ((HopperFiltersAccessor) BWRegistry.HOPPER_FILTERS).getFILTERS().remove(recipe.getName())); - restoreFromBackup().forEach(recipe -> ((HopperFiltersAccessor) BWRegistry.HOPPER_FILTERS).getFILTERS().put(recipe.getName(), recipe)); + removeScripted().forEach(recipe -> ((HopperFiltersAccessor) BWRegistry.HOPPER_FILTERS).getFILTERS().remove(recipe + .getName())); + restoreFromBackup().forEach(recipe -> ((HopperFiltersAccessor) BWRegistry.HOPPER_FILTERS).getFILTERS().put(recipe + .getName(), + recipe)); } public IHopperFilter add(IHopperFilter recipe) { @@ -87,8 +91,8 @@ public boolean removeByFiltered(IIngredient output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((HopperFiltersAccessor) BWRegistry.HOPPER_FILTERS).getFILTERS().values()) - .setRemover(this::remove); + return new SimpleObjectStream<>(((HopperFiltersAccessor) BWRegistry.HOPPER_FILTERS).getFILTERS().values()).setRemover( + this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -97,7 +101,9 @@ public void removeAll() { ((HopperFiltersAccessor) BWRegistry.HOPPER_FILTERS).getFILTERS().values().clear(); } - @Property(property = "input", value = "groovyscript.wiki.betterwithmods.hopper_filters.filtered.value", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) + @Property(property = "input", + value = "groovyscript.wiki.betterwithmods.hopper_filters.filtered.value", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) @@ -110,14 +116,10 @@ public RecipeBuilder filter(IIngredient filter) { } @Override - public String getRecipeNamePrefix() { - return "groovyscript_hopper_filter_"; - } + public String getRecipeNamePrefix() { return "groovyscript_hopper_filter_"; } @Override - public String getErrorMsg() { - return "Error adding Better With Mods Hopper Filter recipe"; - } + public String getErrorMsg() { return "Error adding Better With Mods Hopper Filter recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -127,12 +129,13 @@ public void validate(GroovyLog.Msg msg) { msg.add(IngredientHelper.isEmpty(filter), "filter must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IHopperFilter register() { if (!validate()) return null; - IHopperFilter recipe = new HopperFilter(super.name.toString(), filter.toMcIngredient(), input.stream().map(IIngredient::toMcIngredient).collect(Collectors.toList())); + IHopperFilter recipe = new HopperFilter(super.name.toString(), filter.toMcIngredient(), input.stream().map( + IIngredient::toMcIngredient) + .collect(Collectors.toList())); ModSupport.BETTER_WITH_MODS.get().hopperFilters.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Kiln.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Kiln.java index 58d5be489..187b7e1c3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Kiln.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Kiln.java @@ -1,8 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.BWRegistry; -import betterwithmods.common.registry.block.recipe.BlockIngredient; -import betterwithmods.common.registry.block.recipe.KilnRecipe; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,18 +13,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.List; +import betterwithmods.common.BWRegistry; +import betterwithmods.common.registry.block.recipe.BlockIngredient; +import betterwithmods.common.registry.block.recipe.KilnRecipe; @RegistryDescription public class Kiln extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"), - @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:gold_ingot') * 16).ignoreHeat()") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"), + @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:gold_ingot') * 16).ignoreHeat()")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -119,8 +120,7 @@ public RecipeBuilder input(ItemStack... input) { return this; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public RecipeBuilder input(IIngredient input) { this.input = new BlockIngredient(input.toMcIngredient()); return this; @@ -145,9 +145,7 @@ public RecipeBuilder ignoreHeat() { } @Override - public String getErrorMsg() { - return "Error adding Better With Mods Kiln recipe"; - } + public String getErrorMsg() { return "Error adding Better With Mods Kiln recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -155,8 +153,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable KilnRecipe register() { if (!validate()) return null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/MillStone.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/MillStone.java index 6f951cf6f..7a1484c6f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/MillStone.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/MillStone.java @@ -1,7 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.BWRegistry; -import betterwithmods.common.registry.bulk.recipes.MillRecipe; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.SoundEvent; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,12 +16,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.SoundEvent; -import org.jetbrains.annotations.Nullable; -import java.util.stream.Collectors; +import betterwithmods.common.BWRegistry; +import betterwithmods.common.registry.bulk.recipes.MillRecipe; @RegistryDescription public class MillStone extends VirtualizedRegistry { @@ -24,10 +27,8 @@ public MillStone() { super(Alias.generateOfClass(MillStone.class).andGenerate("Mill")); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16)"), - @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:gold_ingot'), item('minecraft:gold_block'), item('minecraft:clay'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16)"), + @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:gold_ingot'), item('minecraft:gold_block'), item('minecraft:clay'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -129,9 +130,7 @@ public RecipeBuilder priority(int priority) { } @Override - public String getErrorMsg() { - return "Error adding Better With Mods Mill recipe"; - } + public String getErrorMsg() { return "Error adding Better With Mods Mill recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -140,12 +139,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(ticks <= 0, "ticks must be a positive integer greater than 0, yet it was {}", ticks); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable MillRecipe register() { if (!validate()) return null; - MillRecipe recipe = new MillRecipe(input.stream().map(IIngredient::toMcIngredient).collect(Collectors.toList()), output); + MillRecipe recipe = new MillRecipe(input.stream().map(IIngredient::toMcIngredient).collect(Collectors.toList()), + output); recipe.setSound(soundEvent); recipe.setTicks(ticks); recipe.setPriority(priority); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Saw.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Saw.java index 67d2cf54c..3d79e642a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Saw.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Saw.java @@ -1,8 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.BWRegistry; -import betterwithmods.common.registry.block.recipe.BlockIngredient; -import betterwithmods.common.registry.block.recipe.SawRecipe; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,16 +13,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.List; +import betterwithmods.common.BWRegistry; +import betterwithmods.common.registry.block.recipe.BlockIngredient; +import betterwithmods.common.registry.block.recipe.SawRecipe; @RegistryDescription public class Saw extends VirtualizedRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:gold_ingot') * 16)")) - @RecipeBuilderMethodDescription + @RecipeBuilderMethodDescription public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -113,17 +116,14 @@ public RecipeBuilder input(ItemStack... input) { return this; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public RecipeBuilder input(IIngredient input) { this.input = new BlockIngredient(input.toMcIngredient()); return this; } @Override - public String getErrorMsg() { - return "Error adding Better With Mods Saw recipe"; - } + public String getErrorMsg() { return "Error adding Better With Mods Saw recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -131,8 +131,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SawRecipe register() { if (!validate()) return null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Turntable.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Turntable.java index 12ed8a8ba..dcbe4422e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Turntable.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Turntable.java @@ -1,8 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.betterwithmods; -import betterwithmods.common.BWRegistry; -import betterwithmods.common.registry.block.recipe.BlockIngredient; -import betterwithmods.common.registry.block.recipe.TurntableRecipe; +import java.util.List; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,21 +15,17 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.List; +import betterwithmods.common.BWRegistry; +import betterwithmods.common.registry.block.recipe.BlockIngredient; +import betterwithmods.common.registry.block.recipe.TurntableRecipe; @RegistryDescription public class Turntable extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:gold_block')).outputBlock(blockstate('minecraft:clay')).output(item('minecraft:gold_ingot') * 5).rotations(5)"), - @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot')).rotations(2)") - }) - @RecipeBuilderMethodDescription + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:gold_block')).outputBlock(blockstate('minecraft:clay')).output(item('minecraft:gold_ingot') * 5).rotations(5)"), + @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot')).rotations(2)")}) + @RecipeBuilderMethodDescription public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -122,8 +123,7 @@ public RecipeBuilder input(ItemStack... input) { return this; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public RecipeBuilder input(IIngredient input) { this.input = new BlockIngredient(input.toMcIngredient()); return this; @@ -142,9 +142,7 @@ public RecipeBuilder rotations(int rotations) { } @Override - public String getErrorMsg() { - return "Error adding Better With Mods Turntable recipe"; - } + public String getErrorMsg() { return "Error adding Better With Mods Turntable recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -152,8 +150,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable TurntableRecipe register() { if (!validate()) return null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyArray.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyArray.java index 214b6d75a..24fc6ac09 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyArray.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyArray.java @@ -1,7 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.bloodmagic; -import WayofTime.bloodmagic.api.impl.BloodMagicAPI; -import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyArray; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,24 +16,20 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; + +import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyArray; @RegistryDescription public class AlchemyArray extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond')).catalyst(item('bloodmagic:slate:1')).output(item('minecraft:gold_ingot')).texture('bloodmagic:textures/models/AlchemyArrays/LightSigil.png')"), - @Example(".input(item('minecraft:clay')).catalyst(item('minecraft:gold_ingot')).output(item('minecraft:diamond'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond')).catalyst(item('bloodmagic:slate:1')).output(item('minecraft:gold_ingot')).texture('bloodmagic:textures/models/AlchemyArrays/LightSigil.png')"), + @Example(".input(item('minecraft:clay')).catalyst(item('minecraft:gold_ingot')).output(item('minecraft:diamond'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes()::remove); restoreFromBackup().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes()::add); @@ -69,95 +69,88 @@ public boolean remove(RecipeAlchemyArray recipe) { @MethodDescription(example = @Example("item('bloodmagic:component:13')")) public boolean removeByInput(IIngredient input) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf(recipe -> { - boolean found = recipe.getInput().test(IngredientHelper.toItemStack(input)); - if (found) { - addBackup(recipe); - } - return found; - })) { - return true; - } - - GroovyLog.msg("Error removing Blood Magic Alchemy Array recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf( + recipe -> { + boolean found = recipe.getInput() + .test(IngredientHelper.toItemStack(input)); + if (found) { + addBackup(recipe); + } + return found; + })) { return true; } + + GroovyLog.msg("Error removing Blood Magic Alchemy Array recipe").add("could not find recipe with input {}", input).error() + .post(); return false; } @MethodDescription(example = @Example("item('bloodmagic:slate:2')")) public boolean removeByCatalyst(IIngredient catalyst) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf(recipe -> { - boolean found = recipe.getCatalyst().test(IngredientHelper.toItemStack(catalyst)); - if (found) { - addBackup(recipe); - } - return found; - })) { - return true; - } - - GroovyLog.msg("Error removing Blood Magic Alchemy Array recipe") - .add("could not find recipe with catalyst {}", catalyst) - .error() - .post(); + if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf( + recipe -> { + boolean found = recipe.getCatalyst() + .test(IngredientHelper.toItemStack(catalyst)); + if (found) { + addBackup(recipe); + } + return found; + })) { return true; } + + GroovyLog.msg("Error removing Blood Magic Alchemy Array recipe").add("could not find recipe with catalyst {}", catalyst) + .error().post(); return false; } @MethodDescription(example = @Example("item('bloodmagic:component:7'), item('bloodmagic:slate:1')")) public boolean removeByInputAndCatalyst(IIngredient input, IIngredient catalyst) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf(recipe -> { - boolean removeRecipe = recipe.getInput().test(IngredientHelper.toItemStack(input)) && recipe.getCatalyst().test(IngredientHelper.toItemStack(catalyst)); - if (removeRecipe) { - addBackup(recipe); - } - return removeRecipe; - })) { - return true; - } - - GroovyLog.msg("Error removing Blood Magic Alchemy Array recipe") - .add("could not find recipe with input {} and catalyst {}", input, catalyst) - .error() - .post(); + if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf( + recipe -> { + boolean removeRecipe = recipe.getInput() + .test(IngredientHelper.toItemStack(input)) && recipe.getCatalyst() + .test(IngredientHelper.toItemStack(catalyst)); + if (removeRecipe) { + addBackup(recipe); + } + return removeRecipe; + })) { return true; } + + GroovyLog.msg("Error removing Blood Magic Alchemy Array recipe").add( + "could not find recipe with input {} and catalyst {}", + input, catalyst).error().post(); return false; } @MethodDescription(example = @Example("item('bloodmagic:sigil_void')")) public boolean removeByOutput(ItemStack output) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf(recipe -> { - boolean matches = recipe.getOutput().isItemEqual(output); - if (matches) { - addBackup(recipe); - } - return matches; - })) { - return true; - } - - GroovyLog.msg("Error removing Blood Magic Alchemy Array recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf( + recipe -> { + boolean matches = recipe.getOutput() + .isItemEqual(output); + if (matches) { + addBackup(recipe); + } + return matches; + })) { return true; } + + GroovyLog.msg("Error removing Blood Magic Alchemy Array recipe").add("could not find recipe with output {}", output) + .error().post(); return false; } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().forEach(this::addBackup); + ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().forEach( + this::addBackup); ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().clear(); } @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -184,9 +177,7 @@ public RecipeBuilder texture(String texture) { } @Override - public String getErrorMsg() { - return "Error adding Blood Magic Alchemy Array recipe"; - } + public String getErrorMsg() { return "Error adding Blood Magic Alchemy Array recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -194,11 +185,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(catalyst == null, "Must have a catalyst ItemStack but didn't find any!"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipeAlchemyArray register() { if (!validate()) return null; - RecipeAlchemyArray recipe = new RecipeAlchemyArray(input.get(0).toMcIngredient(), catalyst.toMcIngredient(), output.get(0), texture); + RecipeAlchemyArray recipe = new RecipeAlchemyArray(input.get(0).toMcIngredient(), catalyst.toMcIngredient(), output + .get(0), + texture); ModSupport.BLOOD_MAGIC.get().alchemyArray.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyTable.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyTable.java index 03603d3af..c214f70d1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyTable.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyTable.java @@ -1,7 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.bloodmagic; -import WayofTime.bloodmagic.api.impl.BloodMagicAPI; -import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyTable; +import java.util.Collections; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.NonNullList; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,31 +18,23 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.NonNullList; -import org.jetbrains.annotations.Nullable; -import java.util.Collections; +import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyTable; -@RegistryDescription( - admonition = @Admonition(type = Admonition.Type.DANGER, - format = Admonition.Format.STANDARD, - hasTitle = true, - value = "groovyscript.wiki.bloodmagic.alchemy_table.note0") -) +@RegistryDescription(admonition = @Admonition(type = Admonition.Type.DANGER, + format = Admonition.Format.STANDARD, + hasTitle = true, + value = "groovyscript.wiki.bloodmagic.alchemy_table.note0")) public class AlchemyTable extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond'), item('minecraft:diamond')).output(item('minecraft:clay')).ticks(100).minimumTier(2).syphon(500)"), - @Example(".input(item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('bloodmagic:slate'), item('bloodmagic:slate')).output(item('minecraft:clay')).time(2000).tier(5).drain(25000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond'), item('minecraft:diamond')).output(item('minecraft:clay')).ticks(100).minimumTier(2).syphon(500)"), + @Example(".input(item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('bloodmagic:slate'), item('bloodmagic:slate')).output(item('minecraft:clay')).time(2000).tier(5).drain(25000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes()::remove); restoreFromBackup().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes()::add); @@ -72,58 +70,55 @@ public boolean removeByInput(IIngredient... input) { @MethodDescription(example = @Example("item('minecraft:nether_wart'), item('minecraft:gunpowder')")) public boolean removeByInput(NonNullList input) { // Filters down to only recipes which have inputs that match all the input IIngredients (NOTE: a recipe with ABCD would match an input of AB) - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().removeIf(recipe -> { - boolean removeRecipe = false; - for (IIngredient match : input) { - boolean foundInputMatch = false; - for (Ingredient target : recipe.getInput()) { - if (target.test(IngredientHelper.toItemStack(match))) foundInputMatch = true; - } - removeRecipe = foundInputMatch; - } - if (removeRecipe) { - addBackup(recipe); - } - return removeRecipe; - })) { - return true; - } - - GroovyLog.msg("Error removing Blood Magic Alchemy Table recipe") - .add("could not find recipe with inputs including all of {}", input) - .error() - .post(); + if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().removeIf( + recipe -> { + boolean removeRecipe = false; + for (IIngredient match : input) { + boolean foundInputMatch = false; + for (Ingredient target : recipe.getInput()) { + if (target.test(IngredientHelper.toItemStack(match))) + foundInputMatch = true; + } + removeRecipe = foundInputMatch; + } + if (removeRecipe) { + addBackup(recipe); + } + return removeRecipe; + })) { return true; } + + GroovyLog.msg("Error removing Blood Magic Alchemy Table recipe").add( + "could not find recipe with inputs including all of {}", + input).error().post(); return false; } @MethodDescription(example = @Example("item('minecraft:sand')")) public boolean removeByOutput(ItemStack output) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().removeIf(recipe -> { - boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output); - if (matches) { - addBackup(recipe); - } - return matches; - })) { - return true; - } - GroovyLog.msg("Error removing Blood Magic Alchemy Table recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().removeIf( + recipe -> { + boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), + output); + if (matches) { + addBackup(recipe); + } + return matches; + })) { return true; } + GroovyLog.msg("Error removing Blood Magic Alchemy Table recipe").add("could not find recipe with output {}", output) + .error().post(); return false; } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().forEach(this::addBackup); + ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().forEach( + this::addBackup); ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().clear(); } @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes()).setRemover(this::remove); } @@ -172,9 +167,7 @@ public RecipeBuilder tier(int tier) { } @Override - public String getErrorMsg() { - return "Error adding Blood Magic Alchemy Table recipe"; - } + public String getErrorMsg() { return "Error adding Blood Magic Alchemy Table recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -184,11 +177,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(minimumTier < 0, "minimumTier must be a nonnegative integer, yet it was {}", minimumTier); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipeAlchemyTable register() { if (!validate()) return null; - RecipeAlchemyTable recipe = new RecipeAlchemyTable(IngredientHelper.toIngredientNonNullList(input), output.get(0), syphon, ticks, minimumTier); + RecipeAlchemyTable recipe = new RecipeAlchemyTable(IngredientHelper.toIngredientNonNullList(input), output.get(0), + syphon, ticks, minimumTier); ModSupport.BLOOD_MAGIC.get().alchemyTable.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/BloodAltar.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/BloodAltar.java index 53c6902be..82d4e4b0c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/BloodAltar.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/BloodAltar.java @@ -1,8 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.bloodmagic; -import WayofTime.bloodmagic.altar.AltarTier; -import WayofTime.bloodmagic.api.impl.BloodMagicAPI; -import WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -13,31 +15,25 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; -@RegistryDescription( - admonition = { - @Admonition("groovyscript.wiki.bloodmagic.blood_altar.note0"), - @Admonition(value = "groovyscript.wiki.bloodmagic.blood_altar.note1", - type = Admonition.Type.DANGER, - format = Admonition.Format.STANDARD, - hasTitle = true) - } -) +import WayofTime.bloodmagic.altar.AltarTier; +import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar; + +@RegistryDescription(admonition = {@Admonition("groovyscript.wiki.bloodmagic.blood_altar.note0"), @Admonition( + value = "groovyscript.wiki.bloodmagic.blood_altar.note1", + type = Admonition.Type.DANGER, + format = Admonition.Format.STANDARD, + hasTitle = true)}) public class BloodAltar extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot')).minimumTier(0).drainRate(5).syphon(10).consumeRate(5)"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).tier(3).drainRate(100).syphon(50000).consumeRate(500)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot')).minimumTier(0).drainRate(5).syphon(10).consumeRate(5)"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).tier(3).drainRate(100).syphon(50000).consumeRate(500)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes()::remove); restoreFromBackup().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes()::add); @@ -65,56 +61,51 @@ public boolean remove(RecipeBloodAltar recipe) { @MethodDescription(example = @Example("item('minecraft:ender_pearl')")) public boolean removeByInput(IIngredient input) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().removeIf(recipe -> { - boolean removeRecipe = recipe.getInput().test(IngredientHelper.toItemStack(input)); - if (removeRecipe) { - addBackup(recipe); - } - return removeRecipe; - })) { - return true; - } - - GroovyLog.msg("Error removing Blood Magic Blood Altar recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().removeIf( + recipe -> { + boolean removeRecipe = recipe.getInput() + .test(IngredientHelper.toItemStack(input)); + if (removeRecipe) { + addBackup(recipe); + } + return removeRecipe; + })) { return true; } + + GroovyLog.msg("Error removing Blood Magic Blood Altar recipe").add("could not find recipe with input {}", input).error() + .post(); return false; } @MethodDescription(example = @Example("item('bloodmagic:slate:4')")) public boolean removeByOutput(ItemStack output) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().removeIf(recipe -> { - boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output); - if (matches) { - addBackup(recipe); - } - return matches; - })) { - return true; - } - - GroovyLog.msg("Error removing Blood Magic Blood Altar recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().removeIf( + recipe -> { + boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), + output); + if (matches) { + addBackup(recipe); + } + return matches; + })) { return true; } + + GroovyLog.msg("Error removing Blood Magic Blood Altar recipe").add("could not find recipe with output {}", output).error() + .post(); return false; } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().forEach(this::addBackup); + ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().forEach( + this::addBackup); ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().clear(); } @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LT, value = "AltarTier.MAXTIERS")}) @@ -156,25 +147,24 @@ public RecipeBuilder drainRate(int drainRate) { } @Override - public String getErrorMsg() { - return "Error adding Blood Magic Blood Altar recipe"; - } + public String getErrorMsg() { return "Error adding Blood Magic Blood Altar recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); msg.add(minimumTier < 0, "minimumTier must be a nonnegative integer, yet it was {}", minimumTier); - msg.add(minimumTier > AltarTier.MAXTIERS, "minimumTier must be less than the max tier (which is {}), yet it was {}", AltarTier.MAXTIERS, minimumTier); + msg.add(minimumTier > AltarTier.MAXTIERS, "minimumTier must be less than the max tier (which is {}), yet it was {}", + AltarTier.MAXTIERS, minimumTier); msg.add(syphon < 0, "syphon must be a nonnegative integer, yet it was {}", syphon); msg.add(consumeRate < 0, "consumeRate must be a nonnegative integer, yet it was {}", consumeRate); msg.add(drainRate < 0, "drainRate must be a nonnegative integer, yet it was {}", drainRate); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipeBloodAltar register() { if (!validate()) return null; - RecipeBloodAltar recipe = new RecipeBloodAltar(input.get(0).toMcIngredient(), output.get(0), minimumTier, syphon, consumeRate, drainRate); + RecipeBloodAltar recipe = new RecipeBloodAltar(input.get(0).toMcIngredient(), output.get(0), minimumTier, syphon, + consumeRate, drainRate); ModSupport.BLOOD_MAGIC.get().bloodAltar.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Meteor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Meteor.java index 82ac56367..8c835cfd6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Meteor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Meteor.java @@ -1,7 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.bloodmagic; -import WayofTime.bloodmagic.meteor.MeteorComponent; -import WayofTime.bloodmagic.meteor.MeteorRegistry; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,34 +16,30 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import WayofTime.bloodmagic.meteor.MeteorComponent; +import WayofTime.bloodmagic.meteor.MeteorRegistry; @RegistryDescription public class Meteor extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".catalyst(item('minecraft:gold_ingot')).component(ore('oreIron'), 10).component(ore('oreDiamond'), 10).component(ore('stone'), 70).radius(7).explosionStrength(10).cost(1000)"), - @Example(".catalyst(item('minecraft:clay')).component('blockClay', 10).radius(20).explosionStrength(20)") - }) + @RecipeBuilderDescription(example = {@Example(".catalyst(item('minecraft:gold_ingot')).component(ore('oreIron'), 10).component(ore('oreDiamond'), 10).component(ore('stone'), 70).radius(7).explosionStrength(10).cost(1000)"), + @Example(".catalyst(item('minecraft:clay')).component('blockClay', 10).radius(20).explosionStrength(20)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(r -> MeteorRegistry.meteorMap.remove(r.getCatalystStack())); restoreFromBackup().forEach(r -> MeteorRegistry.registerMeteor(r.getCatalystStack(), r)); } @MethodDescription(type = MethodDescription.Type.ADDITION) - public WayofTime.bloodmagic.meteor.Meteor add(ItemStack stack, List componentList, float explosionStrength, int radius, int cost) { - WayofTime.bloodmagic.meteor.Meteor recipe = new WayofTime.bloodmagic.meteor.Meteor(stack, componentList, explosionStrength, radius); + public WayofTime.bloodmagic.meteor.Meteor add(ItemStack stack, List componentList, float explosionStrength, + int radius, int cost) { + WayofTime.bloodmagic.meteor.Meteor recipe = new WayofTime.bloodmagic.meteor.Meteor(stack, componentList, + explosionStrength, radius); recipe.setCost(cost); add(recipe); return recipe; @@ -79,8 +81,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(MeteorRegistry.meteorMap.entrySet()) - .setRemover(x -> this.remove(x.getKey())); + return new SimpleObjectStream<>(MeteorRegistry.meteorMap.entrySet()).setRemover(x -> this.remove(x.getKey())); } @@ -149,9 +150,7 @@ public RecipeBuilder cost(int cost) { } @Override - public String getErrorMsg() { - return "Error adding Blood Magic Alchemy Array recipe"; - } + public String getErrorMsg() { return "Error adding Blood Magic Alchemy Array recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -164,11 +163,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(cost < 0, "Must have a nonnegative cost, but found {}!", cost); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable WayofTime.bloodmagic.meteor.Meteor register() { if (!validate()) return null; - WayofTime.bloodmagic.meteor.Meteor recipe = new WayofTime.bloodmagic.meteor.Meteor(catalyst, components, explosionStrength, radius); + WayofTime.bloodmagic.meteor.Meteor recipe = new WayofTime.bloodmagic.meteor.Meteor(catalyst, components, + explosionStrength, radius); recipe.setCost(cost); ModSupport.BLOOD_MAGIC.get().meteor.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Sacrificial.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Sacrificial.java index e61341be0..650b18e10 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Sacrificial.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Sacrificial.java @@ -1,6 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.bloodmagic; -import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import java.util.Map; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,14 +17,8 @@ import com.cleanroommc.groovyscript.core.mixin.bloodmagic.BloodMagicValueManagerAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; -import java.util.Map; +import WayofTime.bloodmagic.api.impl.BloodMagicAPI; @RegistryDescription public class Sacrificial extends VirtualizedRegistry> { @@ -25,11 +28,13 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { - removeScripted().forEach(pair -> ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getSacrificial().put(pair.getKey(), pair.getValue())); - restoreFromBackup().forEach(pair -> ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getSacrificial().remove(pair.getKey())); + removeScripted().forEach(pair -> ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getSacrificial() + .put(pair.getKey(), + pair.getValue())); + restoreFromBackup().forEach(pair -> ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getSacrificial() + .remove(pair.getKey())); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -52,7 +57,8 @@ public boolean add(Entity entity, int value) { return add(entity.getName(), value); } - @MethodDescription(description = "groovyscript.wiki.bloodmagic.sacrificial.remove0", example = @Example("resource('minecraft:villager')")) + @MethodDescription(description = "groovyscript.wiki.bloodmagic.sacrificial.remove0", + example = @Example("resource('minecraft:villager')")) public boolean remove(ResourceLocation entity) { if (EntityList.getClass(entity) != null) { ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getSacrificial().remove(entity); @@ -61,7 +67,8 @@ public boolean remove(ResourceLocation entity) { return false; } - @MethodDescription(description = "groovyscript.wiki.bloodmagic.sacrificial.remove1", example = @Example("'minecraft:villager'")) + @MethodDescription(description = "groovyscript.wiki.bloodmagic.sacrificial.remove1", + example = @Example("'minecraft:villager'")) public boolean remove(String entity) { return remove(new ResourceLocation(entity)); } @@ -71,21 +78,24 @@ public boolean remove(Entity entity) { return remove(entity.getName()); } - @MethodDescription(description = "groovyscript.wiki.bloodmagic.sacrificial.remove3", example = @Example("entity('minecraft:villager')")) + @MethodDescription(description = "groovyscript.wiki.bloodmagic.sacrificial.remove3", + example = @Example("entity('minecraft:villager')")) public boolean remove(EntityEntry entity) { return remove(entity.getName()); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getSacrificial().forEach((l, r) -> this.addBackup(Pair.of(l, r))); + ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getSacrificial().forEach((l, r) -> this + .addBackup(Pair.of(l, + r))); ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getSacrificial().clear(); } @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getSacrificial().entrySet()) - .setRemover(r -> this.remove(r.getKey())); + return new SimpleObjectStream<>(((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getSacrificial() + .entrySet()).setRemover(r -> this.remove(r.getKey())); } @@ -125,9 +135,7 @@ public RecipeBuilder value(int value) { return this; } - public String getErrorMsg() { - return "Error adding Blood Magic Tranquility key recipe"; - } + public String getErrorMsg() { return "Error adding Blood Magic Tranquility key recipe"; } public boolean validate() { GroovyLog.Msg msg = GroovyLog.msg(getErrorMsg()).error(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/TartaricForge.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/TartaricForge.java index bed4edd78..24d9b3184 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/TartaricForge.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/TartaricForge.java @@ -1,7 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.bloodmagic; -import WayofTime.bloodmagic.api.impl.BloodMagicAPI; -import WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge; +import java.util.Collections; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.NonNullList; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,26 +18,20 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.NonNullList; -import org.jetbrains.annotations.Nullable; -import java.util.Collections; +import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge; @RegistryDescription public class TartaricForge extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:gold_ingot')).soulDrain(5).minimumSouls(10)"), - @Example(".input(item('minecraft:gold_ingot'), item('minecraft:clay')).output(item('minecraft:diamond')).drain(200).minimumSouls(500)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:gold_ingot')).soulDrain(5).minimumSouls(10)"), + @Example(".input(item('minecraft:gold_ingot'), item('minecraft:clay')).output(item('minecraft:diamond')).drain(200).minimumSouls(500)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes()::remove); restoreFromBackup().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes()::add); @@ -41,11 +41,11 @@ public void onReload() { public RecipeTartaricForge add(NonNullList input, ItemStack output, double minimumSouls, double soulDrain) { double minimum; if (minimumSouls < soulDrain) { - GroovyLog.msg("Warning creating Blood Magic Tartaric Forge recipe") - .add("minimumSouls should be greater than soulDrain, yet minimumSouls was {} and soulDrain was {}", minimumSouls, soulDrain) - .add("set minimumSouls equal to soulDrain") - .warn() - .post(); + GroovyLog.msg("Warning creating Blood Magic Tartaric Forge recipe").add( + "minimumSouls should be greater than soulDrain, yet minimumSouls was {} and soulDrain was {}", + minimumSouls, soulDrain).add( + "set minimumSouls equal to soulDrain") + .warn().post(); minimum = soulDrain; } else { minimum = minimumSouls; @@ -64,14 +64,13 @@ public void add(RecipeTartaricForge recipe) { public boolean remove(RecipeTartaricForge recipe) { if (recipe == null) return false; addBackup(recipe); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().remove(recipe); + ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().remove( + recipe); return true; } - @MethodDescription(example = { - @Example("item('minecraft:cauldron'), item('minecraft:stone'), item('minecraft:dye:4'), item('minecraft:diamond')"), - @Example("item('minecraft:gunpowder'), item('minecraft:redstone')") - }) + @MethodDescription(example = {@Example("item('minecraft:cauldron'), item('minecraft:stone'), item('minecraft:dye:4'), item('minecraft:diamond')"), + @Example("item('minecraft:gunpowder'), item('minecraft:redstone')")}) public boolean removeByInput(IIngredient... input) { NonNullList inputs = NonNullList.create(); Collections.addAll(inputs, input); @@ -81,58 +80,55 @@ public boolean removeByInput(IIngredient... input) { @MethodDescription public boolean removeByInput(NonNullList input) { // Filters down to only recipes which have inputs that match all the input IIngredients (NOTE: a recipe with ABCD would match an input of AB) - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().removeIf(recipe -> { - boolean removeRecipe = false; - for (IIngredient match : input) { - boolean foundInputMatch = false; - for (Ingredient target : recipe.getInput()) { - if (target.test(IngredientHelper.toItemStack(match))) foundInputMatch = true; - } - removeRecipe = foundInputMatch; - } - if (removeRecipe) { - addBackup(recipe); - } - return removeRecipe; - })) { - return true; - } - - GroovyLog.msg("Error removing Blood Magic Tartaric Forge recipe") - .add("could not find recipe with inputs including all of {}", input) - .error() - .post(); + if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().removeIf( + recipe -> { + boolean removeRecipe = false; + for (IIngredient match : input) { + boolean foundInputMatch = false; + for (Ingredient target : recipe.getInput()) { + if (target.test(IngredientHelper.toItemStack(match))) + foundInputMatch = true; + } + removeRecipe = foundInputMatch; + } + if (removeRecipe) { + addBackup(recipe); + } + return removeRecipe; + })) { return true; } + + GroovyLog.msg("Error removing Blood Magic Tartaric Forge recipe").add( + "could not find recipe with inputs including all of {}", + input).error().post(); return false; } @MethodDescription(example = @Example("item('bloodmagic:demon_crystal')")) public boolean removeByOutput(ItemStack output) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().removeIf(recipe -> { - boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output); - if (matches) { - addBackup(recipe); - } - return matches; - })) { - return true; - } - GroovyLog.msg("Error removing Blood Magic Tartaric Forge recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().removeIf( + recipe -> { + boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), + output); + if (matches) { + addBackup(recipe); + } + return matches; + })) { return true; } + GroovyLog.msg("Error removing Blood Magic Tartaric Forge recipe").add("could not find recipe with output {}", output) + .error().post(); return false; } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().forEach(this::addBackup); + ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().forEach( + this::addBackup); ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().clear(); } @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes()).setRemover(this::remove); } @@ -163,9 +159,7 @@ public RecipeBuilder drain(int drain) { } @Override - public String getErrorMsg() { - return "Error adding Blood Magic Tartaric Forge recipe"; - } + public String getErrorMsg() { return "Error adding Blood Magic Tartaric Forge recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -174,11 +168,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(soulDrain < 0, "soulDrain must be a nonnegative integer, yet it was {}", soulDrain); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipeTartaricForge register() { if (!validate()) return null; - RecipeTartaricForge recipe = new RecipeTartaricForge(IngredientHelper.toIngredientNonNullList(input), output.get(0), minimumSouls, soulDrain); + RecipeTartaricForge recipe = new RecipeTartaricForge(IngredientHelper.toIngredientNonNullList(input), output.get(0), + minimumSouls, soulDrain); ModSupport.BLOOD_MAGIC.get().tartaricForge.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Tranquility.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Tranquility.java index f1c9aa5ee..e56aa7999 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Tranquility.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/Tranquility.java @@ -1,40 +1,45 @@ package com.cleanroommc.groovyscript.compat.mods.bloodmagic; -import WayofTime.bloodmagic.api.impl.BloodMagicAPI; -import WayofTime.bloodmagic.incense.EnumTranquilityType; -import WayofTime.bloodmagic.incense.TranquilityStack; +import java.util.Arrays; +import java.util.Locale; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.bloodmagic.BloodMagicValueManagerAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.Locale; -import java.util.Map; -import java.util.stream.Collectors; +import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import WayofTime.bloodmagic.incense.EnumTranquilityType; +import WayofTime.bloodmagic.incense.TranquilityStack; @RegistryDescription public class Tranquility extends VirtualizedRegistry> { - @RecipeBuilderDescription(example = { - @Example(".block(block('minecraft:obsidian')).tranquility('LAVA').value(10)"), - @Example(".block(block('minecraft:obsidian')).tranquility('WATER').value(10)"), - @Example(".blockstate(blockstate('minecraft:obsidian')).tranquility('LAVA').value(500)") - }) + @RecipeBuilderDescription(example = {@Example(".block(block('minecraft:obsidian')).tranquility('LAVA').value(10)"), + @Example(".block(block('minecraft:obsidian')).tranquility('WATER').value(10)"), + @Example(".blockstate(blockstate('minecraft:obsidian')).tranquility('LAVA').value(500)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @Override public void onReload() { - removeScripted().forEach(pair -> ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility().remove(pair.getKey(), pair.getValue())); - restoreFromBackup().forEach(pair -> ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility().put(pair.getKey(), pair.getValue())); + removeScripted().forEach(pair -> ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility() + .remove(pair.getKey(), + pair.getValue())); + restoreFromBackup().forEach(pair -> ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility() + .put(pair.getKey(), + pair.getValue())); } @MethodDescription(description = "groovyscript.wiki.bloodmagic.tranquility.add0", type = MethodDescription.Type.ADDITION) @@ -59,10 +64,8 @@ public void add(IBlockState blockstate, String tranquility, double value) { return; } } - GroovyLog.msg("Error adding or adjusting Blood Magic Tranquility") - .add("could not find tranquility type with string {}", tranquility) - .error() - .post(); + GroovyLog.msg("Error adding or adjusting Blood Magic Tranquility").add("could not find tranquility type with string {}", + tranquility).error().post(); } @MethodDescription(description = "groovyscript.wiki.bloodmagic.tranquility.add3", type = MethodDescription.Type.ADDITION) @@ -71,7 +74,8 @@ public void add(IBlockState blockstate, TranquilityStack tranquility) { ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility().put(blockstate, tranquility); } - @MethodDescription(description = "groovyscript.wiki.bloodmagic.tranquility.remove0", example = @Example("block('minecraft:dirt'), 'EARTHEN'")) + @MethodDescription(description = "groovyscript.wiki.bloodmagic.tranquility.remove0", + example = @Example("block('minecraft:dirt'), 'EARTHEN'")) public void remove(Block block, String tranquility) { for (IBlockState state : block.getBlockState().getValidStates()) { remove(state, tranquility); @@ -85,7 +89,8 @@ public void remove(Block block, EnumTranquilityType tranquility) { } } - @MethodDescription(description = "groovyscript.wiki.bloodmagic.tranquility.remove2", example = @Example("blockstate('minecraft:netherrack'), 'FIRE'")) + @MethodDescription(description = "groovyscript.wiki.bloodmagic.tranquility.remove2", + example = @Example("blockstate('minecraft:netherrack'), 'FIRE'")) public void remove(IBlockState blockstate, String tranquility) { for (EnumTranquilityType type : EnumTranquilityType.values()) { if (type.name().equalsIgnoreCase(tranquility)) { @@ -93,40 +98,42 @@ public void remove(IBlockState blockstate, String tranquility) { return; } } - GroovyLog.msg("Error removing Blood Magic Tranquility") - .add("could not find tranquility type with string {}", tranquility) - .error() - .post(); + GroovyLog.msg("Error removing Blood Magic Tranquility").add("could not find tranquility type with string {}", tranquility) + .error().post(); } @MethodDescription(description = "groovyscript.wiki.bloodmagic.tranquility.remove3") public boolean remove(IBlockState blockstate, EnumTranquilityType tranquility) { - for (Map.Entry entry : BloodMagicAPI.INSTANCE.getValueManager().getTranquility().entrySet()) { + for (Map.Entry entry : BloodMagicAPI.INSTANCE.getValueManager().getTranquility() + .entrySet()) { if (entry.getKey() == blockstate && entry.getValue().type == tranquility) { TranquilityStack stack = entry.getValue(); addBackup(Pair.of(entry.getKey(), entry.getValue())); - ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility().remove(blockstate, stack); + ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility().remove(blockstate, + stack); return true; } } - GroovyLog.msg("Error removing Blood Magic Tranquility") - .add("could not find tranquility entry with blockstate {} and enum {}", blockstate, tranquility.name()) - .error() - .post(); + GroovyLog.msg("Error removing Blood Magic Tranquility").add( + "could not find tranquility entry with blockstate {} and enum {}", + blockstate, tranquility.name()).error().post(); return false; } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility().forEach((l, r) -> this.addBackup(Pair.of(l, r))); + ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility().forEach((l, r) -> this + .addBackup(Pair.of(l, + r))); ((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility().clear(); } @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility().entrySet()) - .setRemover(r -> this.remove(r.getKey(), r.getValue().type)); + return new SimpleObjectStream<>(((BloodMagicValueManagerAccessor) BloodMagicAPI.INSTANCE.getValueManager()).getTranquility() + .entrySet()).setRemover(r -> this.remove(r.getKey(), + r.getValue().type)); } @@ -146,9 +153,7 @@ public RecipeBuilder blockstate(IBlockState blockstate) { this.blockstate = blockstate; if (this.block != null) { this.block = null; - GroovyLog.msg("Setting via blockstate removes the block from the builder") - .warn() - .post(); + GroovyLog.msg("Setting via blockstate removes the block from the builder").warn().post(); } return this; } @@ -158,9 +163,7 @@ public RecipeBuilder block(Block block) { this.block = block; if (this.blockstate != null) { this.blockstate = null; - GroovyLog.msg("Setting via block removes the blockstate from the builder") - .warn() - .post(); + GroovyLog.msg("Setting via block removes the blockstate from the builder").warn().post(); } return this; } @@ -181,9 +184,10 @@ public RecipeBuilder tranquility(String tranquility) { return this; } } - GroovyLog.msg("Tranquility string not found. The options are: {}, yet found {}", names.deleteCharAt(names.length() - 1).toString(), tranquility) - .warn() - .post(); + GroovyLog.msg("Tranquility string not found. The options are: {}, yet found {}", names.deleteCharAt(names + .length() - 1) + .toString(), tranquility).warn() + .post(); return this; } @@ -193,15 +197,16 @@ public RecipeBuilder value(double value) { return this; } - public String getErrorMsg() { - return "Error adding Blood Magic Tranquility key recipe"; - } + public String getErrorMsg() { return "Error adding Blood Magic Tranquility key recipe"; } public boolean validate() { GroovyLog.Msg msg = GroovyLog.msg(getErrorMsg()).error(); msg.add(blockstate == null && block == null, "either blockstate or block must be non null"); - msg.add(tranquility == null, "tranquility must be a string matching one of the Enums ({})", Arrays.stream(EnumTranquilityType.values()).map(Enum::name).collect(Collectors.joining(", "))); + msg.add(tranquility == null, "tranquility must be a string matching one of the Enums ({})", Arrays.stream( + EnumTranquilityType.values()) + .map(Enum::name) + .collect(Collectors.joining(", "))); msg.add(value < 0, "value must be a nonnegative integer, yet it was {}", value); return !msg.postIfNotEmpty(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Apothecary.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Apothecary.java index a96ac8f8d..6bd1dc0bc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Apothecary.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Apothecary.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,15 +17,10 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePetals; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - @RegistryDescription public class Apothecary extends VirtualizedRegistry { @@ -30,8 +33,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(BotaniaAPI.petalRecipes::remove); BotaniaAPI.petalRecipes.addAll(restoreFromBackup()); @@ -39,8 +41,8 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.ADDITION) public RecipePetals add(ItemStack output, IIngredient... inputs) { - RecipePetals recipe = new RecipePetals(output, Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() - : i.getMatchingStacks()[0]).toArray()); + RecipePetals recipe = new RecipePetals(output, Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? + ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]).toArray()); add(recipe); return recipe; } @@ -65,32 +67,33 @@ public boolean removeByOutput(IIngredient output) { return found; })) return true; - GroovyLog.msg("Error removing Botania Apothecary recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Botania Apothecary recipe").add("could not find recipe with output {}", output).error() + .post(); return false; } @MethodDescription(example = @Example("ore('runeFireB')")) public boolean removeByInput(IIngredient... inputs) { - List converted = Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() - : i.getMatchingStacks()[0]).collect(Collectors.toList()); + List converted = Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i) + .getOreDict() : + i.getMatchingStacks()[0]).collect(Collectors.toList()); if (BotaniaAPI.petalRecipes.removeIf(recipe -> { - boolean found = converted.stream().allMatch(o -> recipe.getInputs().stream().anyMatch(i -> o instanceof String || i instanceof String ? o.equals(i) - : ItemStack.areItemStacksEqual((ItemStack) i, (ItemStack) o))); + boolean found = converted.stream().allMatch(o -> recipe.getInputs().stream().anyMatch( + i -> o instanceof String || i instanceof String ? + o.equals(i) : ItemStack + .areItemStacksEqual((ItemStack) i, + (ItemStack) o))); if (found) addBackup(recipe); return found; })) return true; - GroovyLog.msg("Error removing Botania Apothecary recipe") - .add("could not find recipe with inputs {}", converted) - .error() - .post(); + GroovyLog.msg("Error removing Botania Apothecary recipe").add("could not find recipe with inputs {}", converted).error() + .post(); return false; } - @MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("ore('petalYellow'), ore('petalBrown')")) + @MethodDescription(description = "groovyscript.wiki.removeByInput", + example = @Example("ore('petalYellow'), ore('petalBrown')")) public boolean removeByInputs(IIngredient... inputs) { return removeByInput(inputs); } @@ -111,9 +114,7 @@ public SimpleObjectStream streamRecipes() { public class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Botania Apothecary recipe"; - } + public String getErrorMsg() { return "Error adding Botania Apothecary recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -121,12 +122,11 @@ public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 20, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipePetals register() { if (!validate()) return null; - RecipePetals recipe = new RecipePetals(output.get(0), input.stream().map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() - : i.getMatchingStacks()[0]).toArray()); + RecipePetals recipe = new RecipePetals(output.get(0), input.stream().map(i -> i instanceof OreDictIngredient ? + ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]).toArray()); add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Botania.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Botania.java index 175193e9a..f973906ee 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Botania.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Botania.java @@ -3,6 +3,7 @@ import com.cleanroommc.groovyscript.api.IObjectParser; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.LexiconCategory; import vazkii.botania.api.lexicon.LexiconEntry; @@ -30,26 +31,24 @@ public Botania() { } public static LexiconCategory getCategory(String name) { - for (LexiconCategory category : BotaniaAPI.getAllCategories()) - if (category.getUnlocalizedName().equals(name)) return category; + for (LexiconCategory category : BotaniaAPI.getAllCategories()) if (category.getUnlocalizedName().equals(name)) + return category; return null; } public static LexiconEntry getEntry(String name) { - for (LexiconEntry entry : BotaniaAPI.getAllEntries()) - if (entry.getUnlocalizedName().equals(name)) return entry; + for (LexiconEntry entry : BotaniaAPI.getAllEntries()) if (entry.getUnlocalizedName().equals(name)) return entry; return null; } // using BotaniaAPI.brewMap::get crashes - @SuppressWarnings("Convert2MethodRef") - @Override + @SuppressWarnings("Convert2MethodRef") @Override public void initialize(GroovyContainer container) { - container.objectMapperBuilder("brew", vazkii.botania.api.brew.Brew.class) - .parser(IObjectParser.wrapStringGetter(val -> BotaniaAPI.brewMap.get(val), false)) - .completerOfNames(() -> BotaniaAPI.brewMap.keySet()) - .defaultValue(() -> BotaniaAPI.fallbackBrew) - .docOfType("brew") - .register(); + container.objectMapperBuilder("brew", vazkii.botania.api.brew.Brew.class).parser(IObjectParser.wrapStringGetter( + val -> BotaniaAPI.brewMap.get(val), + false)) + .completerOfNames(() -> BotaniaAPI.brewMap.keySet()).defaultValue(() -> BotaniaAPI.fallbackBrew).docOfType( + "brew") + .register(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Brew.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Brew.java index 91a1273ff..2de01c5a2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Brew.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Brew.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.minecraft.potion.PotionEffect; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,26 +15,19 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.potion.PotionEffect; -import org.jetbrains.annotations.Nullable; -import vazkii.botania.api.BotaniaAPI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import vazkii.botania.api.BotaniaAPI; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Brew extends VirtualizedRegistry { - @RecipeBuilderDescription(example = @Example(value = ".key('groovy_example_brew').name('Groovy Brew').color(0x00FFFF).cost(100).effect(new PotionEffect(potion('minecraft:strength'), 1800, 3), new PotionEffect(potion('minecraft:speed'), 1800, 2), new PotionEffect(potion('minecraft:weakness'), 3600, 1)).incense(true).bloodPendant(true)", imports = "net.minecraft.potion.PotionEffect")) + @RecipeBuilderDescription(example = @Example(value = ".key('groovy_example_brew').name('Groovy Brew').color(0x00FFFF).cost(100).effect(new PotionEffect(potion('minecraft:strength'), 1800, 3), new PotionEffect(potion('minecraft:speed'), 1800, 2), new PotionEffect(potion('minecraft:weakness'), 3600, 1)).incense(true).bloodPendant(true)", + imports = "net.minecraft.potion.PotionEffect")) public BrewBuilder brewBuilder() { return new BrewBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(brew -> BotaniaAPI.brewMap.remove(brew.getKey())); restoreFromBackup().forEach(brew -> BotaniaAPI.brewMap.put(brew.getKey(), brew)); @@ -85,8 +86,7 @@ public BrewBuilder key(String key) { return this; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public BrewBuilder name(String name) { this.name = name; return this; @@ -156,9 +156,7 @@ public BrewBuilder effect(Collection effects) { } @Override - public String getErrorMsg() { - return "Error adding Botania Brew"; - } + public String getErrorMsg() { return "Error adding Botania Brew"; } @Override public void validate(GroovyLog.Msg msg) { @@ -170,13 +168,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(effects.size() < 1, "must have at least 1 potion effect, got " + effects.size()); } - @Nullable - @Override - @RecipeBuilderRegistrationMethod + @Nullable @Override @RecipeBuilderRegistrationMethod public vazkii.botania.api.brew.Brew register() { if (!validate()) return null; if (name == null) name = key; - vazkii.botania.api.brew.Brew brew = new vazkii.botania.api.brew.Brew(key, name, color, cost, effects.toArray(new PotionEffect[0])); + vazkii.botania.api.brew.Brew brew = new vazkii.botania.api.brew.Brew(key, name, color, cost, effects.toArray( + new PotionEffect[0])); if (!canInfuseBloodPendant) brew.setNotBloodPendantInfusable(); if (!canInfuseIncense) brew.setNotIncenseInfusable(); ModSupport.BOTANIA.get().brew.add(brew); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/BrewRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/BrewRecipe.java index 9a8156cb0..c80ec3014 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/BrewRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/BrewRecipe.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,15 +16,10 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeBrew; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - @RegistryDescription public class BrewRecipe extends VirtualizedRegistry { @@ -25,8 +28,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(BotaniaAPI.brewRecipes::remove); BotaniaAPI.brewRecipes.addAll(restoreFromBackup()); @@ -52,10 +54,7 @@ public boolean removeByOutput(String brew) { return found; })) return true; - GroovyLog.msg("Error removing Botania Brew recipe") - .add("could not find recipe with input {}", brew) - .error() - .post(); + GroovyLog.msg("Error removing Botania Brew recipe").add("could not find recipe with input {}", brew).error().post(); return false; } @@ -66,20 +65,20 @@ public boolean removeByOutput(vazkii.botania.api.brew.Brew brew) { @MethodDescription(example = @Example("item('minecraft:iron_ingot')")) public boolean removeByInput(IIngredient... inputs) { - List converted = Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() - : i.getMatchingStacks()[0]).collect(Collectors.toList()); + List converted = Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i) + .getOreDict() : + i.getMatchingStacks()[0]).collect(Collectors.toList()); if (BotaniaAPI.brewRecipes.removeIf(recipe -> { - boolean found = converted.stream().allMatch(o -> recipe.getInputs().stream().anyMatch(i -> (i instanceof String || o instanceof String) - ? i.equals(o) - : ItemStack.areItemStacksEqual((ItemStack) i, (ItemStack) o))); + boolean found = converted.stream().allMatch(o -> recipe.getInputs().stream().anyMatch( + i -> (i instanceof String || o instanceof String) ? + i.equals(o) : ItemStack + .areItemStacksEqual((ItemStack) i, + (ItemStack) o))); if (found) addBackup(recipe); return found; })) return true; - GroovyLog.msg("Error removing Botania Brew recipe") - .add("could not find recipe with inputs {}", converted) - .error() - .post(); + GroovyLog.msg("Error removing Botania Brew recipe").add("could not find recipe with inputs {}", converted).error().post(); return false; } @@ -117,9 +116,7 @@ public RecipeBuilder brew(vazkii.botania.api.brew.Brew brew) { } @Override - public String getErrorMsg() { - return "Error adding Botania Brew recipe"; - } + public String getErrorMsg() { return "Error adding Botania Brew recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -128,12 +125,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(brew == null, "Expected a valid output brew, got " + brew); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipeBrew register() { if (!validate()) return null; - RecipeBrew recipe = new RecipeBrew(brew, input.stream().map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() - : i.getMatchingStacks()[0]).toArray()); + RecipeBrew recipe = new RecipeBrew(brew, input.stream().map(i -> i instanceof OreDictIngredient ? + ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]).toArray()); add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ElvenTrade.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ElvenTrade.java index 76fe40ae2..037f82338 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ElvenTrade.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ElvenTrade.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,14 +15,10 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeElvenTrade; -import java.util.Arrays; -import java.util.List; - @RegistryDescription public class ElvenTrade extends VirtualizedRegistry { @@ -24,16 +27,15 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(BotaniaAPI.elvenTradeRecipes::remove); BotaniaAPI.elvenTradeRecipes.addAll(restoreFromBackup()); } protected Object[] convertIngredients(IIngredient[] inputs) { - return Arrays.stream(inputs).map(input -> input instanceof OreDictIngredient ? ((OreDictIngredient) input).getOreDict() - : input.getMatchingStacks()[0]).toArray(); + return Arrays.stream(inputs).map(input -> input instanceof OreDictIngredient ? ((OreDictIngredient) input).getOreDict() : + input.getMatchingStacks()[0]).toArray(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -63,15 +65,16 @@ public boolean remove(RecipeElvenTrade recipe) { @MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('botania:dreamwood')")) public boolean removeByOutputs(ItemStack... outputs) { if (BotaniaAPI.elvenTradeRecipes.removeIf(recipe -> { - boolean found = Arrays.stream(outputs).allMatch(output -> recipe.getOutputs().stream().anyMatch(o -> ItemStack.areItemStacksEqual(o, output))); + boolean found = Arrays.stream(outputs).allMatch(output -> recipe.getOutputs().stream().anyMatch(o -> ItemStack + .areItemStacksEqual(o, + output))); if (found) addBackup(recipe); return found; })) return true; - GroovyLog.msg("Error removing Botania Elven Trade recipe") - .add("could not find recipe with outputs {}", Arrays.toString(outputs)) - .error() - .post(); + GroovyLog.msg("Error removing Botania Elven Trade recipe").add("could not find recipe with outputs {}", Arrays.toString( + outputs)) + .error().post(); return false; } @@ -80,16 +83,14 @@ public boolean removeByInputs(IIngredient... inputs) { List converted = Arrays.asList(convertIngredients(inputs)); List list = Arrays.asList(inputs); if (BotaniaAPI.elvenTradeRecipes.removeIf(recipe -> { - boolean found = recipe.getInputs().stream().allMatch(input -> input instanceof String ? converted.contains(input) - : list.stream().anyMatch(i -> i.test((ItemStack) input))); + boolean found = recipe.getInputs().stream().allMatch(input -> input instanceof String ? converted.contains(input) : + list.stream().anyMatch(i -> i.test((ItemStack) input))); if (found) addBackup(recipe); return found; })) return true; - GroovyLog.msg("Error removing Botania Elven Trade recipe") - .add("could not find recipe with inputs {}", converted) - .error() - .post(); + GroovyLog.msg("Error removing Botania Elven Trade recipe").add("could not find recipe with inputs {}", converted).error() + .post(); return false; } @@ -109,9 +110,7 @@ public SimpleObjectStream streamRecipes() { public class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Botania Elven Trade recipe"; - } + public String getErrorMsg() { return "Error adding Botania Elven Trade recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -119,11 +118,11 @@ public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 99, 1, 99); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipeElvenTrade register() { if (!validate()) return null; - RecipeElvenTrade recipe = new RecipeElvenTrade(output.toArray(new ItemStack[0]), convertIngredients(input.toArray(new IIngredient[0]))); + RecipeElvenTrade recipe = new RecipeElvenTrade(output.toArray(new ItemStack[0]), convertIngredients(input.toArray( + new IIngredient[0]))); add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Knowledge.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Knowledge.java index 278dc4f90..5db69a8bc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Knowledge.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Knowledge.java @@ -1,20 +1,19 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import javax.annotation.Nullable; + +import net.minecraft.util.text.TextFormatting; + import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.util.text.TextFormatting; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.KnowledgeType; -import javax.annotation.Nullable; - -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - priority = 2000 -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES, priority = 2000) public class Knowledge extends VirtualizedRegistry { @Override @@ -23,7 +22,11 @@ public void onReload() { restoreFromBackup().forEach(type -> BotaniaAPI.knowledgeTypes.put(type.id, type)); } - @MethodDescription(description = "groovyscript.wiki.botania.knowledge.add0", type = MethodDescription.Type.ADDITION, example = @Example(value = "'newType', TextFormatting.RED, true", imports = "net.minecraft.util.text.TextFormatting", def = "newType")) + @MethodDescription(description = "groovyscript.wiki.botania.knowledge.add0", + type = MethodDescription.Type.ADDITION, + example = @Example(value = "'newType', TextFormatting.RED, true", + imports = "net.minecraft.util.text.TextFormatting", + def = "newType")) public KnowledgeType add(String id, @Nullable TextFormatting formatting, boolean autoUnlock) { KnowledgeType type = new KnowledgeType(id, formatting != null ? formatting : TextFormatting.RESET, autoUnlock); add(type); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Lexicon.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Lexicon.java index 6d8c99f24..9522f9598 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Lexicon.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Lexicon.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import java.util.*; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,10 +17,7 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.jetbrains.annotations.Nullable; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.KnowledgeType; import vazkii.botania.api.lexicon.LexiconCategory; @@ -20,29 +26,24 @@ import vazkii.botania.api.recipe.*; import vazkii.botania.common.lexicon.page.*; -import java.util.*; -import java.util.stream.Collectors; - public class Lexicon { public final Category category = new Category(); public final Entry entry = new Entry(); public final Page page = new Page(); - @RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - priority = 2100 - ) + @RegistryDescription(category = RegistryDescription.Category.ENTRIES, priority = 2100) public static class Category extends VirtualizedRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(BotaniaAPI.getAllCategories()::remove); BotaniaAPI.getAllCategories().addAll(restoreFromBackup()); } - @MethodDescription(description = "groovyscript.wiki.botania.category.add0", type = MethodDescription.Type.ADDITION, example = @Example("'first', resource('minecraft:textures/items/clay_ball.png'), 100")) + @MethodDescription(description = "groovyscript.wiki.botania.category.add0", + type = MethodDescription.Type.ADDITION, + example = @Example("'first', resource('minecraft:textures/items/clay_ball.png'), 100")) public LexiconCategory add(String name, ResourceLocation icon, int priority) { LexiconCategory category = new LexiconCategory(name); category.setIcon(icon); @@ -51,7 +52,9 @@ public LexiconCategory add(String name, ResourceLocation icon, int priority) { return category; } - @MethodDescription(description = "groovyscript.wiki.botania.category.add1", type = MethodDescription.Type.ADDITION, example = @Example("'test', resource('minecraft:textures/items/apple.png')")) + @MethodDescription(description = "groovyscript.wiki.botania.category.add1", + type = MethodDescription.Type.ADDITION, + example = @Example("'test', resource('minecraft:textures/items/apple.png')")) public LexiconCategory add(String name, ResourceLocation icon) { return add(name, icon, 5); } @@ -69,15 +72,14 @@ public boolean remove(LexiconCategory category) { return true; } - @MethodDescription(description = "groovyscript.wiki.botania.category.removeCategory", example = @Example("'botania.category.alfhomancy'")) + @MethodDescription(description = "groovyscript.wiki.botania.category.removeCategory", + example = @Example("'botania.category.alfhomancy'")) public boolean remove(String name) { LexiconCategory category = Botania.getCategory(name); if (category != null) return remove(category); - GroovyLog.msg("Error removing Botania Lexica Botania Category") - .add("could not find category with name {}", name) - .error() - .post(); + GroovyLog.msg("Error removing Botania Lexica Botania Category").add("could not find category with name {}", name) + .error().post(); return false; } @@ -99,14 +101,10 @@ public void removeAll() { } - @RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - priority = 2200 - ) + @RegistryDescription(category = RegistryDescription.Category.ENTRIES, priority = 2200) public static class Page extends VirtualizedRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(change -> change.parent.pages.remove(change.index)); restoreFromBackup().forEach(change -> change.parent.pages.add(change.index, change.page)); @@ -149,10 +147,8 @@ public void removeByEntry(LexiconEntry entry) { public void removeByEntry(String name) { LexiconEntry entry = Botania.getEntry(name); if (entry == null) { - GroovyLog.msg("Error removing Botania Lexica Botania Pages by Entry") - .add("could not find entry with name {}", name) - .error() - .post(); + GroovyLog.msg("Error removing Botania Lexica Botania Pages by Entry").add("could not find entry with name {}", + name).error().post(); return; } removeByEntry(entry); @@ -182,56 +178,67 @@ public PageLoreText createLoreTextPage(String name) { return new PageLoreText(name); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'groovy.exampleImagePage', 'minecraft:textures/items/apple.png'")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'groovy.exampleImagePage', 'minecraft:textures/items/apple.png'")) public PageImage createImagePage(String name, String image) { return new PageImage(name, image); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'groovy.exampleEntityPage', 100, 'minecraft:wither_skeleton'")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'groovy.exampleEntityPage', 100, 'minecraft:wither_skeleton'")) public PageEntity createEntityPage(String name, int size, String entity) { return new PageEntity(name, entity, size); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'groovy.exampleEntityPage', 5, entity('minecraft:wither_skeleton')")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'groovy.exampleEntityPage', 5, entity('minecraft:wither_skeleton')")) public PageEntity createEntityPage(String name, int size, EntityEntry entity) { return createEntityPage(name, size, Objects.requireNonNull(entity.getRegistryName()).toString()); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'groovy.exampleCraftingPage', 'minecraft:clay'")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'groovy.exampleCraftingPage', 'minecraft:clay'")) public PageCraftingRecipe createCraftingPage(String name, String... recipes) { return new PageCraftingRecipe(name, Arrays.stream(recipes).map(ResourceLocation::new).collect(Collectors.toList())); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "'groovy.exampleBrewingPage', 'bottomText', 'bottomText', mods.botania.brewrecipe.recipeBuilder().input(item('minecraft:clay'), ore('ingotGold'), ore('gemDiamond')).brew(brew('absorption')).register()", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "'groovy.exampleBrewingPage', 'bottomText', 'bottomText', mods.botania.brewrecipe.recipeBuilder().input(item('minecraft:clay'), ore('ingotGold'), ore('gemDiamond')).brew(brew('absorption')).register()", + commented = true)) public PageBrew createBrewingPage(String name, String bottomText, RecipeBrew recipe) { return new PageBrew(recipe, name, bottomText); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "'groovy.exampleInfusionPage', mods.botania.manainfusion.recipeBuilder().input(ore('ingotGold')).output(item('botania:manaresource', 1)).mana(500).catalyst(blockstate('minecraft:stone')).register()", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "'groovy.exampleInfusionPage', mods.botania.manainfusion.recipeBuilder().input(ore('ingotGold')).output(item('botania:manaresource', 1)).mana(500).catalyst(blockstate('minecraft:stone')).register()", + commented = true)) public PageManaInfusionRecipe createInfusionPage(String name, RecipeManaInfusion... recipes) { return new PageManaInfusionRecipe(name, Arrays.asList(recipes)); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "'groovy.exampleRunePage', mods.botania.runealtar.recipeBuilder().input(ore('gemEmerald'), item('minecraft:apple')).output(item('minecraft:diamond')).mana(500).register()", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "'groovy.exampleRunePage', mods.botania.runealtar.recipeBuilder().input(ore('gemEmerald'), item('minecraft:apple')).output(item('minecraft:diamond')).mana(500).register()", + commented = true)) public PageRuneRecipe createRunePage(String name, RecipeRuneAltar... recipes) { return new PageRuneRecipe(name, Arrays.asList(recipes)); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "'groovy.examplePetalPage', mods.botania.apothecary.recipeBuilder().input(ore('blockGold'), ore('ingotIron'), item('minecraft:apple')).output(item('minecraft:golden_apple')).register()", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "'groovy.examplePetalPage', mods.botania.apothecary.recipeBuilder().input(ore('blockGold'), ore('ingotIron'), item('minecraft:apple')).output(item('minecraft:golden_apple')).register()", + commented = true)) public PagePetalRecipe createPetalPage(String name, RecipePetals... recipes) { return new PagePetalRecipe<>(name, Arrays.asList(recipes)); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "'groovy.exampleElvenTradePage', mods.botania.elventrade.recipeBuilder().input(ore('ingotGold'), ore('ingotIron')).output(item('botania:manaresource:7')).register()", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "'groovy.exampleElvenTradePage', mods.botania.elventrade.recipeBuilder().input(ore('ingotGold'), ore('ingotIron')).output(item('botania:manaresource:7')).register()", + commented = true)) public PageElvenRecipe createElvenTradePage(String name, RecipeElvenTrade... recipes) { return new PageElvenRecipe(name, Arrays.asList(recipes)); } } - @RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - priority = 2300 - ) + @RegistryDescription(category = RegistryDescription.Category.ENTRIES, priority = 2300) public static class Entry extends VirtualizedRegistry { @RecipeBuilderDescription(example = @Example(".name('test_entry').icon(ore('blockIron')).category('test').knowledgeType(newType).page(mods.botania.lexicon.page.createTextPage('groovy.exampleTextPage'))")) @@ -239,8 +246,7 @@ public EntryBuilder entryBuilder() { return new EntryBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(BotaniaAPI.getAllEntries()::remove); restoreFromBackup().forEach(entry -> { @@ -275,15 +281,14 @@ public boolean remove(LexiconEntry entry) { return true; } - @MethodDescription(description = "groovyscript.wiki.botania.entry.removeEntry", example = @Example("'botania.entry.flowers'")) + @MethodDescription(description = "groovyscript.wiki.botania.entry.removeEntry", + example = @Example("'botania.entry.flowers'")) public boolean remove(String name) { LexiconEntry entry = Botania.getEntry(name); if (entry != null) return remove(entry); - GroovyLog.msg("Error removing Botania Lexica Botania Entry") - .add("could not find entry with name {}", name) - .error() - .post(); + GroovyLog.msg("Error removing Botania Lexica Botania Entry").add("could not find entry with name {}", name).error() + .post(); return false; } @@ -312,10 +317,9 @@ public void removeByCategory(LexiconCategory category) { public void removeByCategory(String name) { LexiconCategory category = Botania.getCategory(name); if (category == null) { - GroovyLog.msg("Error removing Botania Lexica Botania Entries by Category") - .add("could not find category with name {}", name) - .error() - .post(); + GroovyLog.msg("Error removing Botania Lexica Botania Entries by Category").add( + "could not find category with name {}", + name).error().post(); return; } removeByCategory(category); @@ -361,8 +365,7 @@ public EntryBuilder icon(IIngredient icon) { return this; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public EntryBuilder name(String name) { this.name = name; return this; @@ -414,9 +417,7 @@ public EntryBuilder extraRecipe(IIngredient stack) { } @Override - public String getErrorMsg() { - return "Error adding Botania Lexicon Entry"; - } + public String getErrorMsg() { return "Error adding Botania Lexicon Entry"; } @Override public void validate(GroovyLog.Msg msg) { @@ -427,8 +428,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(category == null, "expected a valid category, got " + category); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable LexiconEntry register() { if (!validate()) return null; LexiconEntry entry = new LexiconEntry(name, category); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Magnet.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Magnet.java index f532c4ff0..f86510e94 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Magnet.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Magnet.java @@ -1,5 +1,8 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -8,15 +11,13 @@ import com.cleanroommc.groovyscript.compat.mods.botania.recipe.MagnetSubject; import com.cleanroommc.groovyscript.core.mixin.botania.BotaniaAPIAccessor; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; + import vazkii.botania.api.BotaniaAPI; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Magnet extends VirtualizedRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(m -> BotaniaAPI.magnetBlacklist.remove(m.getMagnetKey())); restoreFromBackup().forEach(m -> BotaniaAPI.magnetBlacklist.add(m.getMagnetKey())); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ManaInfusion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ManaInfusion.java index a7a74ee34..77c8daea4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ManaInfusion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ManaInfusion.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,15 +13,12 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeManaInfusion; -@RegistryDescription( - admonition = @Admonition(value = "groovyscript.wiki.botania.mana_infusion.note", type = Admonition.Type.WARNING) -) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.botania.mana_infusion.note", + type = Admonition.Type.WARNING)) public class ManaInfusion extends VirtualizedRegistry { @RecipeBuilderDescription(example = @Example(".input(ore('ingotGold')).output(item('botania:manaresource', 1)).mana(500).catalyst(blockstate('minecraft:stone'))")) @@ -24,8 +26,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(BotaniaAPI.manaInfusionRecipes::remove); BotaniaAPI.manaInfusionRecipes.addAll(restoreFromBackup()); @@ -33,8 +34,8 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.ADDITION) public RecipeManaInfusion add(ItemStack output, IIngredient input, int mana) { - RecipeManaInfusion recipe = new RecipeManaInfusion(output, input instanceof OreDictIngredient ? ((OreDictIngredient) input).getOreDict() - : input.getMatchingStacks()[0], mana); + RecipeManaInfusion recipe = new RecipeManaInfusion(output, input instanceof OreDictIngredient ? + ((OreDictIngredient) input).getOreDict() : input.getMatchingStacks()[0], mana); add(recipe); return recipe; } @@ -59,26 +60,22 @@ public boolean removeByOutput(ItemStack output) { return found; })) return true; - GroovyLog.msg("Error removing Botania Mana Infusion recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Botania Mana Infusion recipe").add("could not find recipe with output {}", output).error() + .post(); return false; } @MethodDescription(example = @Example("item('minecraft:ender_pearl')")) public boolean removeByInput(IIngredient input) { if (BotaniaAPI.manaInfusionRecipes.removeIf(recipe -> { - boolean found = recipe.getInput() instanceof ItemStack ? input.test((ItemStack) recipe.getInput()) - : (input instanceof OreDictIngredient && ((OreDictIngredient) input).getOreDict().equals(recipe.getInput())); + boolean found = recipe.getInput() instanceof ItemStack ? input.test((ItemStack) recipe.getInput()) : + (input instanceof OreDictIngredient && ((OreDictIngredient) input).getOreDict().equals(recipe.getInput())); if (found) addBackup(recipe); return found; })) return true; - GroovyLog.msg("Error removing Botania Mana Infusion recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Botania Mana Infusion recipe").add("could not find recipe with input {}", input).error() + .post(); return false; } @@ -91,10 +88,8 @@ public boolean removeByCatalyst(IBlockState catalyst) { return found; })) return true; - GroovyLog.msg("Error removing Botania Mana Infusion recipe") - .add("could not find recipe with catalyst {}", catalyst) - .error() - .post(); + GroovyLog.msg("Error removing Botania Mana Infusion recipe").add("could not find recipe with catalyst {}", catalyst) + .error().post(); return false; } @@ -109,8 +104,7 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(BotaniaAPI.manaInfusionRecipes).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "100", valid = @Comp(value = "1", type = Comp.Type.GTE)) @@ -141,9 +135,7 @@ public RecipeBuilder useConjuration() { } @Override - public String getErrorMsg() { - return "Error adding Botania Mana Infusion recipe"; - } + public String getErrorMsg() { return "Error adding Botania Mana Infusion recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -152,13 +144,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(mana < 1, "Mana amount must be at least 1, got " + mana); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipeManaInfusion register() { if (!validate()) return null; - RecipeManaInfusion recipe = new RecipeManaInfusion(output.get(0), - input.get(0) instanceof OreDictIngredient ? ((OreDictIngredient) input.get(0)).getOreDict() - : input.get(0).getMatchingStacks()[0], mana); + RecipeManaInfusion recipe = new RecipeManaInfusion(output.get(0), input.get(0) instanceof OreDictIngredient ? + ((OreDictIngredient) input.get(0)).getOreDict() : input.get(0).getMatchingStacks()[0], mana); if (catalyst != null) recipe.setCatalyst(catalyst); add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Orechid.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Orechid.java index fcf3ae3b3..e06bbd14b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Orechid.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Orechid.java @@ -1,5 +1,8 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import java.util.ArrayList; +import java.util.List; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -9,16 +12,13 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import vazkii.botania.api.BotaniaAPI; -import java.util.ArrayList; -import java.util.List; +import vazkii.botania.api.BotaniaAPI; @RegistryDescription public class Orechid extends VirtualizedRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(recipe -> BotaniaAPI.oreWeights.remove(recipe.output)); restoreFromBackup().forEach(recipe -> BotaniaAPI.oreWeights.put(recipe.output, recipe.weight)); @@ -37,7 +37,8 @@ public OrechidRecipe add(String output, int weight) { return recipe; } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = {@Example("ore('oreEmerald'), 1350"), @Example("ore('blockGold'), 1800")}) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = {@Example("ore('oreEmerald'), 1350"), @Example("ore('blockGold'), 1800")}) public OrechidRecipe add(OreDictIngredient output, int weight) { return add(output.getOreDict(), weight); } @@ -66,14 +67,12 @@ public boolean removeByOutput(String output) { return true; } - GroovyLog.msg("Error removing Botania Orechid recipe") - .add("could not find recipe for oredict {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Botania Orechid recipe").add("could not find recipe for oredict {}", output).error().post(); return false; } - @MethodDescription(example = {@Example(value = "ore('oreEmerald')", commented = true), @Example(value = "ore('oreQuartz')", commented = true)}) + @MethodDescription(example = {@Example(value = "ore('oreEmerald')", commented = true), @Example(value = "ore('oreQuartz')", + commented = true)}) public boolean removeByOutput(OreDictIngredient output) { return removeByOutput(output.getOreDict()); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/OrechidIgnem.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/OrechidIgnem.java index 6e6dd3ce7..e24471e38 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/OrechidIgnem.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/OrechidIgnem.java @@ -1,21 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import java.util.ArrayList; +import java.util.List; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.compat.mods.botania.recipe.OrechidRecipe; -import vazkii.botania.api.BotaniaAPI; -import java.util.ArrayList; -import java.util.List; +import vazkii.botania.api.BotaniaAPI; @RegistryDescription public class OrechidIgnem extends Orechid { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(recipe -> BotaniaAPI.oreWeightsNether.remove(recipe.output)); restoreFromBackup().forEach(recipe -> BotaniaAPI.oreWeightsNether.put(recipe.output, recipe.weight)); @@ -46,8 +46,7 @@ public boolean remove(OrechidRecipe recipe) { return false; } - @Override - @MethodDescription(example = @Example("'oreQuartz'")) + @Override @MethodDescription(example = @Example("'oreQuartz'")) public boolean removeByOutput(String output) { if (BotaniaAPI.oreWeightsNether.containsKey(output)) { addBackup(new OrechidRecipe(output, BotaniaAPI.getOreWeightNether(output))); @@ -55,15 +54,12 @@ public boolean removeByOutput(String output) { return true; } - GroovyLog.msg("Error removing Botania OrechidIgnem recipe") - .add("could not find recipe for oredict {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Botania OrechidIgnem recipe").add("could not find recipe for oredict {}", output).error() + .post(); return false; } - @Override - @MethodDescription(priority = 2000, example = @Example(commented = true)) + @Override @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { getAllRecipes().forEach(this::addBackup); BotaniaAPI.oreWeightsNether.clear(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/PureDaisy.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/PureDaisy.java index 44650d5cc..bb766b70f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/PureDaisy.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/PureDaisy.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,9 +12,7 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import org.jetbrains.annotations.Nullable; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePureDaisy; @@ -21,8 +24,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(BotaniaAPI.pureDaisyRecipes::remove); BotaniaAPI.pureDaisyRecipes.addAll(restoreFromBackup()); @@ -60,10 +62,8 @@ public boolean removeByOutput(IBlockState output) { return found; })) return true; - GroovyLog.msg("Error removing Botania Pure Daisy recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Botania Pure Daisy recipe").add("could not find recipe with output {}", output).error() + .post(); return false; } @@ -75,10 +75,8 @@ public boolean removeByInput(String input) { return found; })) return true; - GroovyLog.msg("Error removing Botania Pure Daisy recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Botania Pure Daisy recipe").add("could not find recipe with input {}", input).error() + .post(); return false; } @@ -90,15 +88,14 @@ public boolean removeByInput(OreDictIngredient input) { @MethodDescription(example = @Example("blockstate('minecraft:water')")) public boolean removeByInput(IBlockState input) { if (BotaniaAPI.pureDaisyRecipes.removeIf(recipe -> { - boolean found = (recipe.getInput() instanceof IBlockState && recipe.getInput().equals(input)) || (recipe.getInput() instanceof Block && recipe.getInput() == input.getBlock()); + boolean found = (recipe.getInput() instanceof IBlockState && recipe.getInput().equals(input)) || (recipe + .getInput() instanceof Block && recipe.getInput() == input.getBlock()); if (found) addBackup(recipe); return found; })) return true; - GroovyLog.msg("Error removing Botania Pure Daisy recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Botania Pure Daisy recipe").add("could not find recipe with input {}", input).error() + .post(); return false; } @@ -124,7 +121,9 @@ public class RecipeBuilder extends AbstractRecipeBuilder { protected int time = RecipePureDaisy.DEFAULT_TIME; @Property(ignoresInheritedMethods = true, valid = @Comp(value = "null", type = Comp.Type.NOT)) protected IBlockState output; - @Property(ignoresInheritedMethods = true, requirement = "groovyscript.wiki.botania.pure_daisy.input.required", valid = @Comp(value = "null", type = Comp.Type.NOT)) + @Property(ignoresInheritedMethods = true, + requirement = "groovyscript.wiki.botania.pure_daisy.input.required", + valid = @Comp(value = "null", type = Comp.Type.NOT)) protected Object input; @RecipeBuilderMethodDescription @@ -162,9 +161,7 @@ public RecipeBuilder input(OreDictIngredient input) { } @Override - public String getErrorMsg() { - return "Error adding Botania Pure Daisy recipe"; - } + public String getErrorMsg() { return "Error adding Botania Pure Daisy recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -172,11 +169,11 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 0, 0, 0, 0); msg.add(time < 0, "time must be at least 1, got " + time); msg.add(output == null, "output must be defined"); - msg.add(input == null || !(input instanceof String || input instanceof IBlockState), "expected IBlockState or String input, got {}", input); + msg.add(input == null || !(input instanceof String || input instanceof IBlockState), + "expected IBlockState or String input, got {}", input); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipePureDaisy register() { if (!validate()) return null; RecipePureDaisy recipe = new RecipePureDaisy(input, output, time); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/RuneAltar.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/RuneAltar.java index f44286750..3db12561d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/RuneAltar.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/RuneAltar.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.botania; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,17 +17,11 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.common.block.ModBlocks; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - @RegistryDescription public class RuneAltar extends VirtualizedRegistry { @@ -27,8 +30,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(BotaniaAPI.runeAltarRecipes::remove); BotaniaAPI.runeAltarRecipes.addAll(restoreFromBackup()); @@ -36,9 +38,8 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.ADDITION) public RecipeRuneAltar add(ItemStack output, int mana, IIngredient... inputs) { - RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient - ? ((OreDictIngredient) i).getOreDict() - : i.getMatchingStacks()[0]).toArray()); + RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? + ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]).toArray()); add(recipe); return recipe; } @@ -63,29 +64,28 @@ public boolean removeByOutput(IIngredient output) { return found; })) return true; - GroovyLog.msg("Error removing Botania Rune Altar recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Botania Rune Altar recipe").add("could not find recipe with output {}", output).error() + .post(); return false; } @MethodDescription(example = @Example("ore('runeEarthB')")) public boolean removeByInput(IIngredient... inputs) { - List converted = Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() - : i.getMatchingStacks()[0]).collect(Collectors.toList()); + List converted = Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i) + .getOreDict() : + i.getMatchingStacks()[0]).collect(Collectors.toList()); if (BotaniaAPI.runeAltarRecipes.removeIf(recipe -> { - boolean found = converted.stream().allMatch(o -> recipe.getInputs().stream().anyMatch(i -> (i instanceof String || o instanceof String) - ? i.equals(o) - : ItemStack.areItemStacksEqual((ItemStack) i, (ItemStack) o))); + boolean found = converted.stream().allMatch(o -> recipe.getInputs().stream().anyMatch( + i -> (i instanceof String || o instanceof String) ? + i.equals(o) : ItemStack + .areItemStacksEqual((ItemStack) i, + (ItemStack) o))); if (found) addBackup(recipe); return found; })) return true; - GroovyLog.msg("Error removing Botania Rune Altar recipe") - .add("could not find recipe with inputs {}", converted) - .error() - .post(); + GroovyLog.msg("Error removing Botania Rune Altar recipe").add("could not find recipe with inputs {}", converted).error() + .post(); return false; } @@ -119,9 +119,7 @@ public RecipeBuilder mana(int amount) { } @Override - public String getErrorMsg() { - return "Error adding Botania Rune Altar recipe"; - } + public String getErrorMsg() { return "Error adding Botania Rune Altar recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -132,13 +130,14 @@ public void validate(GroovyLog.Msg msg) { msg.add(mana < 1, "mana must be at least 1, got " + mana); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RecipeRuneAltar register() { if (!validate()) return null; - RecipeRuneAltar recipe = new RecipeRuneAltar(output.get(0), mana, input.stream().map(i -> i instanceof OreDictIngredient - ? ((OreDictIngredient) i).getOreDict() - : i.getMatchingStacks()[0]).toArray()); + RecipeRuneAltar recipe = new RecipeRuneAltar(output.get(0), mana, input.stream().map( + i -> i instanceof OreDictIngredient ? + ((OreDictIngredient) i).getOreDict() : + i.getMatchingStacks()[0]) + .toArray()); add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/recipe/MagnetSubject.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/recipe/MagnetSubject.java index 117cfc27b..06007865f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/recipe/MagnetSubject.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/recipe/MagnetSubject.java @@ -1,8 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.botania.recipe; +import net.minecraft.block.Block; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.core.mixin.botania.BotaniaAPIAccessor; -import net.minecraft.block.Block; public class MagnetSubject { @@ -22,11 +23,10 @@ public MagnetSubject(Block block, int meta) { this.item = null; } - public boolean isBlock() { - return block != null; - } + public boolean isBlock() { return block != null; } public String getMagnetKey() { - return isBlock() ? BotaniaAPIAccessor.invokeGetMagnetKey(block, meta) : BotaniaAPIAccessor.invokeGetMagnetKey(item.getMatchingStacks()[0]); + return isBlock() ? BotaniaAPIAccessor.invokeGetMagnetKey(block, meta) : BotaniaAPIAccessor.invokeGetMagnetKey(item + .getMatchingStacks()[0]); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AlgorithmSeparator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AlgorithmSeparator.java index 7d94dde08..c41447ab5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AlgorithmSeparator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AlgorithmSeparator.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.AlgorithmSeparatorRecipes; import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; - @RegistryDescription public class AlgorithmSeparator extends VirtualizedRegistry { @@ -80,18 +83,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(AlgorithmSeparatorRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(AlgorithmSeparatorRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("2")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("2")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Algorithm Separator Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Algorithm Separator Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,13 +98,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = AlgorithmSeparatorRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), false); + CalculatorRecipe recipe = AlgorithmSeparatorRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList( + input), + output, new ArrayList<>(), false); ModSupport.CALCULATOR.get().algorithmSeparator.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AnalysingChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AnalysingChamber.java index 7ee5a8f9d..35eb9e2e9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AnalysingChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AnalysingChamber.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,49 +15,44 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.AnalysingChamberRecipes; import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; -import java.util.Arrays; - /** * To help with coding this horrid mess:
- * {@link sonar.calculator.mod.common.recipes.AnalysingChamberRecipes#addRecipes() AnalysingChamberRecipes#addRecipes()} is where recipes are added
- * {@link sonar.calculator.mod.common.item.misc.CircuitBoard#setData(ItemStack) CircuitBoard#setData} sets the data of circuits
- * {@link sonar.calculator.mod.common.tileentity.machines.TileEntityAnalysingChamber TileEntityAnalysingChamber} extracts items, specifically line 164 in analyse(int)
+ * {@link sonar.calculator.mod.common.recipes.AnalysingChamberRecipes#addRecipes() AnalysingChamberRecipes#addRecipes()} is where + * recipes are added
+ * {@link sonar.calculator.mod.common.item.misc.CircuitBoard#setData(ItemStack) CircuitBoard#setData} sets the data of + * circuits
+ * {@link sonar.calculator.mod.common.tileentity.machines.TileEntityAnalysingChamber TileEntityAnalysingChamber} extracts items, + * specifically line 164 in analyse(int)
* {@link sonar.calculator.mod.integration.jei.Recipes.Analysing Analysing} represents this in JEI, and is giving missinfo
*
- * |  Slot |   1 |   2 |    3 |    4 |     5 |     6 |
+ * | Slot | 1 | 2 | 3 | 4 | 5 | 6 |
  * |-------|-----|-----|------|------|-------|-------|
- * |  Odds |  50 | 100 | 1000 | 2000 | 10000 | 20000 | Pool of possible numbers
- * |   JEI | 6.0 | 0.2 |  0.1 | 0.02 |  0.01 |   N/A | Chance shown in JEI
- * | Valid | 2.0 | 1.0 |  0.1 | 0.05 |  0.01 | 0.005 | Actual chance
- * |  True |   N |   N |    Y |    N |     Y |     N | Chance matches
- * |  Used |  17 |  15 |   10 |   15 |    10 |     0 | What numbers are used for each slot
+ * | Odds | 50 | 100 | 1000 | 2000 | 10000 | 20000 | Pool of possible numbers
+ * | JEI | 6.0 | 0.2 | 0.1 | 0.02 | 0.01 | N/A | Chance shown in JEI
+ * | Valid | 2.0 | 1.0 | 0.1 | 0.05 | 0.01 | 0.005 | Actual chance
+ * | True | N | N | Y | N | Y | N | Chance matches
+ * | Used | 17 | 15 | 10 | 15 | 10 | 0 | What numbers are used for each slot
  * 
*/ -@RegistryDescription( - admonition = { - @Admonition("groovyscript.wiki.calculator.analysing_chamber.note0"), - @Admonition(value = "groovyscript.wiki.calculator.analysing_chamber.note1", type = Admonition.Type.WARNING, format = Admonition.Format.STANDARD) - } -) +@RegistryDescription(admonition = {@Admonition("groovyscript.wiki.calculator.analysing_chamber.note0"), @Admonition( + value = "groovyscript.wiki.calculator.analysing_chamber.note1", + type = Admonition.Type.WARNING, + format = Admonition.Format.STANDARD)}) public class AnalysingChamber extends VirtualizedRegistry { public AnalysingChamber() { super(Alias.generateOfClass(AnalysingChamber.class).andGenerate("AnalyzingChamber")); } - @RecipeBuilderDescription(example = { - @Example(".slot(6).location(1).output(item('minecraft:diamond'))"), - @Example(".slot(1).location(18).output(item('minecraft:clay'))"), - }) + @RecipeBuilderDescription(example = {@Example(".slot(6).location(1).output(item('minecraft:diamond'))"), + @Example(".slot(1).location(18).output(item('minecraft:clay'))"),}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -97,8 +99,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(AnalysingChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(AnalysingChamberRecipes.instance().getRecipes()).setRemover(this::remove); } @Property(property = "output", valid = @Comp("1")) @@ -122,9 +123,7 @@ public RecipeBuilder location(int location) { } @Override - public String getErrorMsg() { - return "Error adding Calculator Analysing Chamber Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Analysing Chamber Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -142,16 +141,17 @@ public void validate(GroovyLog.Msg msg) { yield 0; } }; - msg.add(location < 1 || location > compValue, "location must be greater than or equal to 1 and less than or equal to {}, yet it was {}", compValue, location); + msg.add(location < 1 || location > compValue, + "location must be greater than or equal to 1 and less than or equal to {}, yet it was {}", compValue, + location); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = AnalysingChamberRecipes.instance() - .buildDefaultRecipe(Arrays.asList(slot, location), output, new ArrayList<>(), false); + CalculatorRecipe recipe = AnalysingChamberRecipes.instance().buildDefaultRecipe(Arrays.asList(slot, location), output, + new ArrayList<>(), false); ModSupport.CALCULATOR.get().analysingChamber.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AtomicCalculator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AtomicCalculator.java index 627da2a45..516fe5011 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AtomicCalculator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AtomicCalculator.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.AtomicCalculatorRecipes; import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; - @RegistryDescription public class AtomicCalculator extends VirtualizedRegistry { @@ -80,18 +83,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(AtomicCalculatorRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(AtomicCalculatorRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("3")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("3")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Atomic Calculator Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Atomic Calculator Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,13 +98,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = AtomicCalculatorRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), false); + CalculatorRecipe recipe = AtomicCalculatorRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList( + input), + output, new ArrayList<>(), false); ModSupport.CALCULATOR.get().atomicCalculator.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/BasicCalculator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/BasicCalculator.java index b4b45d6ff..52b4060d1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/BasicCalculator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/BasicCalculator.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,14 +14,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.calculator.mod.common.recipes.CalculatorRecipes; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; - @RegistryDescription public class BasicCalculator extends VirtualizedRegistry { @@ -85,18 +88,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(CalculatorRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(CalculatorRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("2")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("2")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Basic Calculator Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Basic Calculator Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -104,13 +103,12 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = CalculatorRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), false); + CalculatorRecipe recipe = CalculatorRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), + output, new ArrayList<>(), false); ModSupport.CALCULATOR.get().basicCalculator.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/Calculator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/Calculator.java index c05681afd..39445fda4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/Calculator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/Calculator.java @@ -1,20 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.ingredient.IngredientList; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; -import net.minecraft.item.ItemStack; + import sonar.core.recipes.ISonarRecipeObject; import sonar.core.recipes.RecipeInterchangable; import sonar.core.recipes.RecipeItemStack; import sonar.core.recipes.RecipeOreStack; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class Calculator extends GroovyPropertyContainer { public final AlgorithmSeparator algorithmSeparator = new AlgorithmSeparator(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ConductorMast.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ConductorMast.java index c9341fcdd..8f7dfd6df 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ConductorMast.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ConductorMast.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.ConductorMastRecipes; import sonar.core.recipes.DefaultSonarRecipe; import sonar.core.recipes.ISonarRecipeObject; -import java.util.Arrays; - @RegistryDescription public class ConductorMast extends VirtualizedRegistry { @@ -80,12 +83,10 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ConductorMastRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(ConductorMastRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "1", type = Comp.Type.GTE)) @@ -98,9 +99,7 @@ public RecipeBuilder value(int value) { } @Override - public String getErrorMsg() { - return "Error adding Calculator Conductor Mast Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Conductor Mast Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -109,13 +108,14 @@ public void validate(GroovyLog.Msg msg) { msg.add(value <= 0, "value must be greater than or equal to 1, yet it was {}", value); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable DefaultSonarRecipe.Value register() { if (!validate()) return null; - DefaultSonarRecipe.Value recipe = ConductorMastRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, Arrays.asList(value), false); + DefaultSonarRecipe.Value recipe = ConductorMastRecipes.instance().buildDefaultRecipe(Calculator + .toSonarRecipeObjectList(input), + output, Arrays.asList(value), + false); ModSupport.CALCULATOR.get().conductorMast.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ExtractionChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ExtractionChamber.java index ad2b47118..22df33fb2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ExtractionChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ExtractionChamber.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,22 +14,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.calculator.mod.common.recipes.ExtractionChamberRecipes; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; -import java.util.List; - @RegistryDescription public class ExtractionChamber extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'))"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).isDamaged()") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'))"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).isDamaged()")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -84,12 +85,10 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ExtractionChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(ExtractionChamberRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -108,9 +107,7 @@ public RecipeBuilder isDamaged(boolean isDamaged) { } @Override - public String getErrorMsg() { - return "Error adding Calculator Extraction Chamber Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Extraction Chamber Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -118,18 +115,19 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; List specialOutput = new ArrayList<>(); specialOutput.add(output.get(0)); - specialOutput.add(new ExtractionChamberRecipes.ExtractionChamberOutput(new ItemStack( - isDamaged ? sonar.calculator.mod.Calculator.circuitDamaged : sonar.calculator.mod.Calculator.circuitDirty, 1, 32767))); + specialOutput.add(new ExtractionChamberRecipes.ExtractionChamberOutput(new ItemStack(isDamaged ? + sonar.calculator.mod.Calculator.circuitDamaged : sonar.calculator.mod.Calculator.circuitDirty, 1, 32767))); - CalculatorRecipe recipe = ExtractionChamberRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), specialOutput, new ArrayList<>(), false); + CalculatorRecipe recipe = ExtractionChamberRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList( + input), + specialOutput, new ArrayList<>(), + false); ModSupport.CALCULATOR.get().extractionChamber.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FabricationChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FabricationChamber.java index 88ed14826..0897cc5a2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FabricationChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FabricationChamber.java @@ -1,5 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.registries.IForgeRegistryEntry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,26 +19,16 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.registries.IForgeRegistryEntry; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.FabricationChamberRecipes; import sonar.calculator.mod.common.recipes.FabricationSonarRecipe; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - @RegistryDescription public class FabricationChamber extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('calculator:circuitboard:8').withNbt([Stable: 0, Analysed: 1])).output(item('minecraft:diamond'))"), - @Example(".input(item('calculator:circuitboard:0').withNbt([Stable: 0, Analysed: true]), item('calculator:circuitboard:1').withNbt([Stable: 0, Analysed: true]), item('calculator:circuitboard:2').withNbt([Stable: 0, Analysed: true]), item('calculator:circuitboard:3').withNbt([Stable: 0, Analysed: true]), item('calculator:circuitboard:4').withNbt([Stable: 0, Analysed: true])).input(item('calculator:circuitboard:0').withNbt([Stable: 1, Analysed: true]), item('calculator:circuitboard:1').withNbt([Stable: 1, Analysed: true]), item('calculator:circuitboard:2').withNbt([Stable: 1, Analysed: true]), item('calculator:circuitboard:3').withNbt([Stable: 1, Analysed: true]), item('calculator:circuitboard:4').withNbt([Stable: 1, Analysed: true])).output(item('minecraft:clay'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('calculator:circuitboard:8').withNbt([Stable: 0, Analysed: 1])).output(item('minecraft:diamond'))"), + @Example(".input(item('calculator:circuitboard:0').withNbt([Stable: 0, Analysed: true]), item('calculator:circuitboard:1').withNbt([Stable: 0, Analysed: true]), item('calculator:circuitboard:2').withNbt([Stable: 0, Analysed: true]), item('calculator:circuitboard:3').withNbt([Stable: 0, Analysed: true]), item('calculator:circuitboard:4').withNbt([Stable: 0, Analysed: true])).input(item('calculator:circuitboard:0').withNbt([Stable: 1, Analysed: true]), item('calculator:circuitboard:1').withNbt([Stable: 1, Analysed: true]), item('calculator:circuitboard:2').withNbt([Stable: 1, Analysed: true]), item('calculator:circuitboard:3').withNbt([Stable: 1, Analysed: true]), item('calculator:circuitboard:4').withNbt([Stable: 1, Analysed: true])).output(item('minecraft:clay'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -89,42 +90,39 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(FabricationChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(FabricationChamberRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) + @Property(property = "input", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Fabrication Chamber Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Fabrication Chamber Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, Integer.MAX_VALUE, 1, 1); validateFluids(msg); // I love streams, but this sequence is a bit short for my tastes. - List inputNames = input.stream() - .map(IngredientHelper::toItemStack) - .map(ItemStack::getItem) - .map(IForgeRegistryEntry.Impl::getRegistryName) - .filter(Objects::nonNull) - .map(ResourceLocation::toString) - .filter(x -> !x.contains("calculator:circuitboard")) - .collect(Collectors.toList()); - msg.add(!inputNames.isEmpty(), "All inputs must be an item of 'calculator:circuitboard', found {}", String.join(", ", inputNames)); + List inputNames = input.stream().map(IngredientHelper::toItemStack).map(ItemStack::getItem).map( + IForgeRegistryEntry.Impl::getRegistryName) + .filter(Objects::nonNull).map(ResourceLocation::toString).filter(x -> !x.contains( + "calculator:circuitboard")) + .collect(Collectors.toList()); + msg.add(!inputNames.isEmpty(), "All inputs must be an item of 'calculator:circuitboard', found {}", String.join(", ", + inputNames)); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable FabricationSonarRecipe register() { if (!validate()) return null; - FabricationSonarRecipe recipe = FabricationChamberRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), true); + FabricationSonarRecipe recipe = FabricationChamberRecipes.instance().buildDefaultRecipe(Calculator + .toSonarRecipeObjectList(input), + output, new ArrayList<>(), + true); ModSupport.CALCULATOR.get().fabricationChamber.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FlawlessCalculator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FlawlessCalculator.java index 79319ca66..268d84c86 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FlawlessCalculator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FlawlessCalculator.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.calculator.mod.common.recipes.FlawlessCalculatorRecipes; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; - @RegistryDescription public class FlawlessCalculator extends VirtualizedRegistry { @@ -80,18 +83,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(FlawlessCalculatorRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(FlawlessCalculatorRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("4")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("4")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Flawless Calculator Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Flawless Calculator Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,13 +98,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = FlawlessCalculatorRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), false); + CalculatorRecipe recipe = FlawlessCalculatorRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList( + input), + output, new ArrayList<>(), false); ModSupport.CALCULATOR.get().flawlessCalculator.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/GlowstoneExtractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/GlowstoneExtractor.java index 8ca67edf0..3be78d4c2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/GlowstoneExtractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/GlowstoneExtractor.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.GlowstoneExtractorRecipes; import sonar.core.recipes.DefaultSonarRecipe; import sonar.core.recipes.ISonarRecipeObject; -import java.util.Arrays; - @RegistryDescription public class GlowstoneExtractor extends VirtualizedRegistry { @@ -65,8 +68,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(GlowstoneExtractorRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(GlowstoneExtractorRecipes.instance().getRecipes()).setRemover(this::remove); } @Property(property = "input", valid = @Comp("1")) @@ -82,9 +84,7 @@ public RecipeBuilder value(int value) { } @Override - public String getErrorMsg() { - return "Error adding Calculator Glowstone Extractor Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Glowstone Extractor Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -93,13 +93,15 @@ public void validate(GroovyLog.Msg msg) { msg.add(value <= 0, "value must be greater than or equal to 1, yet it was {}", value); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable DefaultSonarRecipe.Value register() { if (!validate()) return null; - DefaultSonarRecipe.Value recipe = GlowstoneExtractorRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, Arrays.asList(value), false); + DefaultSonarRecipe.Value recipe = GlowstoneExtractorRecipes.instance().buildDefaultRecipe(Calculator + .toSonarRecipeObjectList(input), + output, Arrays.asList( + value), + false); ModSupport.CALCULATOR.get().glowstoneExtractor.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/HealthProcessor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/HealthProcessor.java index 7b20c310b..dc7daf807 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/HealthProcessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/HealthProcessor.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.HealthProcessorRecipes; import sonar.core.recipes.DefaultSonarRecipe; import sonar.core.recipes.ISonarRecipeObject; -import java.util.Arrays; - @RegistryDescription public class HealthProcessor extends VirtualizedRegistry { @@ -65,8 +68,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(HealthProcessorRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(HealthProcessorRecipes.instance().getRecipes()).setRemover(this::remove); } @Property(property = "input", valid = @Comp("1")) @@ -82,9 +84,7 @@ public RecipeBuilder value(int value) { } @Override - public String getErrorMsg() { - return "Error adding Calculator Health Processor Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Health Processor Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -93,13 +93,14 @@ public void validate(GroovyLog.Msg msg) { msg.add(value <= 0, "value must be greater than or equal to 1, yet it was {}", value); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable DefaultSonarRecipe.Value register() { if (!validate()) return null; - DefaultSonarRecipe.Value recipe = HealthProcessorRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, Arrays.asList(value), false); + DefaultSonarRecipe.Value recipe = HealthProcessorRecipes.instance().buildDefaultRecipe(Calculator + .toSonarRecipeObjectList(input), + output, Arrays.asList(value), + false); ModSupport.CALCULATOR.get().healthProcessor.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/PrecisionChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/PrecisionChamber.java index 5df6de724..ad6cfd476 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/PrecisionChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/PrecisionChamber.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,21 +13,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.calculator.mod.common.recipes.PrecisionChamberRecipes; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; - @RegistryDescription public class PrecisionChamber extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'), item('calculator:circuitdamaged:4'))"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond'), item('minecraft:diamond'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'), item('calculator:circuitdamaged:4'))"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond'), item('minecraft:diamond'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -83,18 +84,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(PrecisionChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(PrecisionChamberRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("2")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("2")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Precision Chamber Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Precision Chamber Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -102,13 +99,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = PrecisionChamberRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), false); + CalculatorRecipe recipe = PrecisionChamberRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList( + input), + output, new ArrayList<>(), false); ModSupport.CALCULATOR.get().precisionChamber.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ProcessingChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ProcessingChamber.java index ac654c943..4155075e9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ProcessingChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ProcessingChamber.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.calculator.mod.common.recipes.ProcessingChamberRecipes; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; - @RegistryDescription public class ProcessingChamber extends VirtualizedRegistry { @@ -80,18 +83,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ProcessingChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(ProcessingChamberRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Processing Chamber Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Processing Chamber Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,13 +98,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = ProcessingChamberRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), false); + CalculatorRecipe recipe = ProcessingChamberRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList( + input), + output, new ArrayList<>(), false); ModSupport.CALCULATOR.get().processingChamber.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ReassemblyChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ReassemblyChamber.java index 4a6d6202f..597df884a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ReassemblyChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ReassemblyChamber.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.calculator.mod.common.recipes.ReassemblyChamberRecipes; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; - @RegistryDescription public class ReassemblyChamber extends VirtualizedRegistry { @@ -80,18 +83,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ReassemblyChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(ReassemblyChamberRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Reassembly Chamber Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Reassembly Chamber Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,13 +98,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = ReassemblyChamberRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), false); + CalculatorRecipe recipe = ReassemblyChamberRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList( + input), + output, new ArrayList<>(), false); ModSupport.CALCULATOR.get().reassemblyChamber.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RedstoneExtractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RedstoneExtractor.java index 43d488f12..0b4835b2a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RedstoneExtractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RedstoneExtractor.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.RedstoneExtractorRecipes; import sonar.core.recipes.DefaultSonarRecipe; import sonar.core.recipes.ISonarRecipeObject; -import java.util.Arrays; - @RegistryDescription public class RedstoneExtractor extends VirtualizedRegistry { @@ -65,8 +68,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RedstoneExtractorRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(RedstoneExtractorRecipes.instance().getRecipes()).setRemover(this::remove); } @Property(property = "input", valid = @Comp("1")) @@ -82,9 +84,7 @@ public RecipeBuilder value(int value) { } @Override - public String getErrorMsg() { - return "Error adding Calculator Redstone Extractor Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Redstone Extractor Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -93,13 +93,14 @@ public void validate(GroovyLog.Msg msg) { msg.add(value <= 0, "value must be greater than or equal to 1, yet it was {}", value); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable DefaultSonarRecipe.Value register() { if (!validate()) return null; - DefaultSonarRecipe.Value recipe = RedstoneExtractorRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, Arrays.asList(value), false); + DefaultSonarRecipe.Value recipe = RedstoneExtractorRecipes.instance().buildDefaultRecipe(Calculator + .toSonarRecipeObjectList(input), + output, Arrays.asList(value), + false); ModSupport.CALCULATOR.get().redstoneExtractor.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RestorationChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RestorationChamber.java index 6e9b42271..fb54f5d3a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RestorationChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RestorationChamber.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.calculator.mod.common.recipes.RestorationChamberRecipes; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; - @RegistryDescription public class RestorationChamber extends VirtualizedRegistry { @@ -80,18 +83,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RestorationChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(RestorationChamberRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Restoration Chamber Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Restoration Chamber Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,13 +98,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = RestorationChamberRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), false); + CalculatorRecipe recipe = RestorationChamberRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList( + input), + output, new ArrayList<>(), false); ModSupport.CALCULATOR.get().restorationChamber.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ScientificCalculator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ScientificCalculator.java index 37f3bb460..386613ffc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ScientificCalculator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ScientificCalculator.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.calculator.mod.common.recipes.ScientificRecipes; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; - @RegistryDescription public class ScientificCalculator extends VirtualizedRegistry { @@ -80,18 +83,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ScientificRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(ScientificRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("2")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("2")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Scientific Calculator Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Scientific Calculator Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,13 +98,12 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = ScientificRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), false); + CalculatorRecipe recipe = ScientificRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), + output, new ArrayList<>(), false); ModSupport.CALCULATOR.get().scientificCalculator.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StarchExtractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StarchExtractor.java index 90339c87c..e84e4d57b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StarchExtractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StarchExtractor.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.StarchExtractorRecipes; import sonar.core.recipes.DefaultSonarRecipe; import sonar.core.recipes.ISonarRecipeObject; -import java.util.Arrays; - @RegistryDescription public class StarchExtractor extends VirtualizedRegistry { @@ -65,8 +68,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(StarchExtractorRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(StarchExtractorRecipes.instance().getRecipes()).setRemover(this::remove); } @Property(property = "input", valid = @Comp("1")) @@ -82,9 +84,7 @@ public RecipeBuilder value(int value) { } @Override - public String getErrorMsg() { - return "Error adding Calculator Starch Extractor Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Starch Extractor Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -93,13 +93,14 @@ public void validate(GroovyLog.Msg msg) { msg.add(value <= 0, "value must be greater than or equal to 1, yet it was {}", value); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable DefaultSonarRecipe.Value register() { if (!validate()) return null; - DefaultSonarRecipe.Value recipe = StarchExtractorRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, Arrays.asList(value), false); + DefaultSonarRecipe.Value recipe = StarchExtractorRecipes.instance().buildDefaultRecipe(Calculator + .toSonarRecipeObjectList(input), + output, Arrays.asList(value), + false); ModSupport.CALCULATOR.get().starchExtractor.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StoneSeparator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StoneSeparator.java index 34dd2eae3..512761a81 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StoneSeparator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StoneSeparator.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.calculator; +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,14 +13,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.calculator.mod.common.recipes.StoneSeparatorRecipes; import sonar.core.recipes.ISonarRecipeObject; -import java.util.ArrayList; - @RegistryDescription public class StoneSeparator extends VirtualizedRegistry { @@ -80,18 +83,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(StoneSeparatorRecipes.instance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(StoneSeparatorRecipes.instance().getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("2")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("2")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Calculator Stone Separator Recipe"; - } + public String getErrorMsg() { return "Error adding Calculator Stone Separator Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,13 +98,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CalculatorRecipe register() { if (!validate()) return null; - CalculatorRecipe recipe = StoneSeparatorRecipes.instance() - .buildDefaultRecipe(Calculator.toSonarRecipeObjectList(input), output, new ArrayList<>(), false); + CalculatorRecipe recipe = StoneSeparatorRecipes.instance().buildDefaultRecipe(Calculator.toSonarRecipeObjectList( + input), + output, new ArrayList<>(), false); ModSupport.CALCULATOR.get().stoneSeparator.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/chisel/Carving.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/chisel/Carving.java index 808de8951..f72d46eea 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/chisel/Carving.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/chisel/Carving.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.chisel; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.SoundEvent; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -9,19 +16,16 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.util.SoundEvent; -import org.apache.commons.lang3.tuple.Pair; + import team.chisel.api.carving.CarvingUtils; import team.chisel.api.carving.ICarvingGroup; import team.chisel.api.carving.ICarvingRegistry; -import java.util.Collection; - -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - admonition = @Admonition(value = "groovyscript.wiki.chisel.carving.note", type = Admonition.Type.DANGER, format = Admonition.Format.STANDARD), - isFullyDocumented = false // TODO fully document Chisel Carving +@RegistryDescription(category = RegistryDescription.Category.ENTRIES, + admonition = @Admonition(value = "groovyscript.wiki.chisel.carving.note", + type = Admonition.Type.DANGER, + format = Admonition.Format.STANDARD), + isFullyDocumented = false // TODO fully document Chisel Carving ) public class Carving extends VirtualizedRegistry> { @@ -42,7 +46,8 @@ public static CarvingGroup carvingGroup(String group) { @Override public void onReload() { removeScripted().forEach(pair -> getRegistry().removeVariation(pair.getValue(), pair.getKey())); - restoreFromBackup().forEach(pair -> getRegistry().addVariation(pair.getKey(), CarvingUtils.variationFor(pair.getValue(), 0))); + restoreFromBackup().forEach(pair -> getRegistry().addVariation(pair.getKey(), CarvingUtils.variationFor(pair.getValue(), + 0))); groupStorage.restoreFromBackup().forEach(group -> getRegistry().addGroup(CarvingUtils.getDefaultGroupFor(group))); groupStorage.removeScripted().forEach(getRegistry()::removeGroup); @@ -58,25 +63,31 @@ public void addVariation(String groupName, ItemStack item) { getRegistry().addVariation(groupName, CarvingUtils.variationFor(item, 0)); addScripted(Pair.of(groupName, item)); } catch (UnsupportedOperationException e) { - GroovyLog.msg("Error adding a Chisel Carving variation") - .add("you cannot add variations to Oredict chisel groups {}", groupName) - .add("instead, edit the oredict via `oredict.add('{}', {})`", groupName, IngredientHelper.asGroovyCode(item, false)) - .error() - .post(); + GroovyLog.msg("Error adding a Chisel Carving variation").add("you cannot add variations to Oredict chisel groups {}", + groupName).add( + "instead, edit the oredict via `oredict.add('{}', {})`", + groupName, IngredientHelper.asGroovyCode( + item, + false)) + .error().post(); } } - @MethodDescription(example = {@Example("'antiblock', item('chisel:antiblock:3')"), @Example("'antiblock', item('chisel:antiblock:15')")}) + @MethodDescription(example = {@Example("'antiblock', item('chisel:antiblock:3')"), + @Example("'antiblock', item('chisel:antiblock:15')")}) public void removeVariation(String groupName, ItemStack item) { try { getRegistry().removeVariation(item, groupName); addBackup(Pair.of(groupName, item)); } catch (UnsupportedOperationException e) { - GroovyLog.msg("Error removing a Chisel Carving variation") - .add("you cannot remove variations to Oredict chisel groups {}", groupName) - .add("instead, edit the oredict via `oredict.remove('{}', {})`", groupName, IngredientHelper.asGroovyCode(item, false)) - .error() - .post(); + GroovyLog.msg("Error removing a Chisel Carving variation").add( + "you cannot remove variations to Oredict chisel groups {}", + groupName).add( + "instead, edit the oredict via `oredict.remove('{}', {})`", + groupName, IngredientHelper + .asGroovyCode(item, + false)) + .error().post(); } } @@ -84,10 +95,9 @@ public void removeVariation(String groupName, ItemStack item) { public void setSound(String group, SoundEvent sound) { ICarvingGroup carvingGroup = getRegistry().getGroup(group); if (carvingGroup == null) { - GroovyLog.msg("Error setting the sound for a Chisel Carving group") - .add("could not find a Carving Group with the name {}", group) - .error() - .post(); + GroovyLog.msg("Error setting the sound for a Chisel Carving group").add( + "could not find a Carving Group with the name {}", + group).error().post(); return; } setSound(carvingGroup, sound); @@ -102,10 +112,8 @@ public void setSound(ICarvingGroup group, SoundEvent sound) { @MethodDescription(example = @Example("'demo'"), type = MethodDescription.Type.ADDITION) public void addGroup(String groupName) { if (getRegistry().getSortedGroupNames().contains(groupName)) { - GroovyLog.msg("Error adding Chisel Carving group") - .add("found a duplicate Chisel Carving group with name {}", groupName) - .error() - .post(); + GroovyLog.msg("Error adding Chisel Carving group").add("found a duplicate Chisel Carving group with name {}", + groupName).error().post(); return; } getRegistry().addGroup(CarvingUtils.getDefaultGroupFor(groupName)); @@ -115,10 +123,8 @@ public void addGroup(String groupName) { @MethodDescription(example = @Example("'blockDiamond'")) public void removeGroup(String groupName) { if (!getRegistry().getSortedGroupNames().contains(groupName)) { - GroovyLog.msg("Error removing Chisel Carving group") - .add("could not find Chisel Carving group with name {}", groupName) - .error() - .post(); + GroovyLog.msg("Error removing Chisel Carving group").add("could not find Chisel Carving group with name {}", + groupName).error().post(); return; } getRegistry().removeGroup(groupName); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/compactmachines/Miniaturization.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/compactmachines/Miniaturization.java index 50918e234..698e7cbf2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/compactmachines/Miniaturization.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/compactmachines/Miniaturization.java @@ -1,30 +1,31 @@ package com.cleanroommc.groovyscript.compat.mods.compactmachines; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import org.dave.compactmachines3.miniaturization.MultiblockRecipes; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import org.dave.compactmachines3.miniaturization.MultiblockRecipes; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; @RegistryDescription public class Miniaturization extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('diamond_rectangle').input(item('minecraft:clay')).output(item('minecraft:clay')).symmetrical().ticks(10).shape([['www', 'www']]).key('w', blockstate('minecraft:diamond_block'))"), - @Example(".name('groovy_rocket').input(item('minecraft:diamond')).output(item('minecraft:clay') * 64).symmetrical().ticks(5400).key('a', blockstate('minecraft:stained_glass:0')).key('b', blockstate('minecraft:stained_glass:1')).key('c', blockstate('minecraft:stained_glass:2')).key('d', blockstate('minecraft:stained_glass:3')).key('e', blockstate('minecraft:diamond_block')).key('f', blockstate('minecraft:stained_glass:5')).key('g', blockstate('minecraft:stained_glass:6')).layer(' ', ' ', ' a ', ' aaa ', ' a ', ' ', ' ').layer(' ', ' b ', ' aaa ', ' baaab ', ' aaa ', ' b ', ' ').layer(' ', ' c ', ' cac ', ' caeac ', ' cac ', ' c ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' g ', ' cac ', ' caeac ', ' cac ', ' f ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' c ', ' cac ', ' caeac ', ' cac ', ' c ', ' ').layer(' ', ' a ', ' aaa ', ' aaaaa ', ' aaa ', ' a ', ' ').layer(' a ', ' ccc ', ' cdddc ', 'acdddca', ' cdddc ', ' ccc ', ' a ')\n") - }) + @RecipeBuilderDescription(example = {@Example(".name('diamond_rectangle').input(item('minecraft:clay')).output(item('minecraft:clay')).symmetrical().ticks(10).shape([['www', 'www']]).key('w', blockstate('minecraft:diamond_block'))"), + @Example(".name('groovy_rocket').input(item('minecraft:diamond')).output(item('minecraft:clay') * 64).symmetrical().ticks(5400).key('a', blockstate('minecraft:stained_glass:0')).key('b', blockstate('minecraft:stained_glass:1')).key('c', blockstate('minecraft:stained_glass:2')).key('d', blockstate('minecraft:stained_glass:3')).key('e', blockstate('minecraft:diamond_block')).key('f', blockstate('minecraft:stained_glass:5')).key('g', blockstate('minecraft:stained_glass:6')).layer(' ', ' ', ' a ', ' aaa ', ' a ', ' ', ' ').layer(' ', ' b ', ' aaa ', ' baaab ', ' aaa ', ' b ', ' ').layer(' ', ' c ', ' cac ', ' caeac ', ' cac ', ' c ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' g ', ' cac ', ' caeac ', ' cac ', ' f ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' a ', ' aaa ', ' aaeaa ', ' aaa ', ' a ', ' ').layer(' ', ' c ', ' cac ', ' caeac ', ' cac ', ' c ', ' ').layer(' ', ' a ', ' aaa ', ' aaaaa ', ' aaa ', ' a ', ' ').layer(' a ', ' ccc ', ' cdddc ', 'acdddca', ' cdddc ', ' ccc ', ' a ')\n")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -47,7 +48,10 @@ public boolean remove(org.dave.compactmachines3.miniaturization.MultiblockRecipe @MethodDescription(example = @Example("item('minecraft:ender_pearl')")) public void removeByInput(ItemStack input) { - for (org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe : MultiblockRecipes.getRecipes().stream().filter(r -> r.getCatalystStack().isItemEqual(input)).collect(Collectors.toList())) { + for (org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe : MultiblockRecipes.getRecipes().stream().filter( + r -> r.getCatalystStack() + .isItemEqual(input)) + .collect(Collectors.toList())) { addBackup(recipe); MultiblockRecipes.getRecipes().removeIf(r -> r == recipe); } @@ -60,7 +64,10 @@ public void removeByCatalyst(ItemStack catalyst) { @MethodDescription(example = @Example("item('compactmachines3:machine:3')")) public void removeByOutput(ItemStack output) { - for (org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe : MultiblockRecipes.getRecipes().stream().filter(r -> r.getTargetStack().isItemEqual(output)).collect(Collectors.toList())) { + for (org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe : MultiblockRecipes.getRecipes().stream().filter( + r -> r.getTargetStack() + .isItemEqual(output)) + .collect(Collectors.toList())) { addBackup(recipe); MultiblockRecipes.getRecipes().removeIf(r -> r == recipe); } @@ -77,8 +84,7 @@ public SimpleObjectStream(MultiblockRecipes.getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "' ' = air, '_' = air") @@ -167,9 +173,7 @@ public RecipeBuilder duration(int duration) { } @Override - public String getErrorMsg() { - return "Error adding Compact Machines Multiblock recipe"; - } + public String getErrorMsg() { return "Error adding Compact Machines Multiblock recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -179,32 +183,34 @@ public void validate(GroovyLog.Msg msg) { for (String error : errors) { msg.add(error); } - String missingKeys = shape.stream().flatMap(l -> l.stream().flatMap(g -> Arrays.stream(g.split("")).map(q -> q.charAt(0)))) - .distinct() - .filter(x -> !(keyMap.containsKey(x) || x == ' ' || x == '_')) - .map(String::valueOf) - .collect(Collectors.joining()); - msg.add(!missingKeys.isEmpty(), "shape must contain only characters that are underscore('_'), space(' '), or declared via a key, but the following keys were not declared: {}", missingKeys); + String missingKeys = shape.stream().flatMap(l -> l.stream().flatMap(g -> Arrays.stream(g.split("")).map(q -> q.charAt( + 0)))) + .distinct().filter(x -> !(keyMap.containsKey(x) || x == ' ' || x == '_')).map( + String::valueOf) + .collect(Collectors.joining()); + msg.add(!missingKeys.isEmpty(), + "shape must contain only characters that are underscore('_'), space(' '), or declared via a key, but the following keys were not declared: {}", + missingKeys); } - @Nullable - @Override - @RecipeBuilderRegistrationMethod + @Nullable @Override @RecipeBuilderRegistrationMethod public org.dave.compactmachines3.miniaturization.MultiblockRecipe register() { if (!validate()) return null; - org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe = new org.dave.compactmachines3.miniaturization.MultiblockRecipe( - super.name.toString(), - output.get(0), - input.get(0).getMatchingStacks()[0].getItem(), - input.get(0).getMatchingStacks()[0].getMetadata(), - input.get(0).getMatchingStacks()[0].getTagCompound(), - symmetrical, - ticks - ); - - String[][][] target = shape.stream().map(l -> l.stream().map(g -> g.replace(" ", "_").split("")) - .toArray(String[][]::new)).toArray(String[][][]::new); + org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe = new org.dave.compactmachines3.miniaturization.MultiblockRecipe(super.name.toString(), + output.get(0), + input.get(0) + .getMatchingStacks()[0].getItem(), + input.get(0) + .getMatchingStacks()[0].getMetadata(), + input.get(0) + .getMatchingStacks()[0].getTagCompound(), + symmetrical, + ticks); + + String[][][] target = shape.stream().map(l -> l.stream().map(g -> g.replace(" ", "_").split("")).toArray( + String[][]::new)) + .toArray(String[][][]::new); recipe.setPositionMap(target); @@ -234,21 +240,13 @@ public ReferenceValues(IBlockState state, NBTTagCompound nbt, boolean ignoreMeta this.reference = reference; } - public IBlockState getState() { - return state; - } + public IBlockState getState() { return state; } - public NBTTagCompound getNbt() { - return nbt; - } + public NBTTagCompound getNbt() { return nbt; } - public boolean isIgnoreMeta() { - return ignoreMeta; - } + public boolean isIgnoreMeta() { return ignoreMeta; } - public ItemStack getReference() { - return reference; - } + public ItemStack getReference() { return reference; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/EnergyCore.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/EnergyCore.java index 045f0709d..c74ea99ba 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/EnergyCore.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/EnergyCore.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.draconicevolution; +import java.util.Arrays; +import java.util.Collection; + +import net.minecraft.block.state.IBlockState; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.GroovyScriptConfig; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; @@ -12,11 +19,6 @@ import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.BlockStates; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ArrayUtils; -import net.minecraft.block.state.IBlockState; -import org.jetbrains.annotations.ApiStatus; - -import java.util.Arrays; -import java.util.Collection; @RegistryDescription public class EnergyCore implements IScriptReloadable { @@ -42,14 +44,10 @@ private void init() { } @Override - public boolean isEnabled() { - return GroovyScriptConfig.compat.draconicEvolutionEnergyCore; - } + public boolean isEnabled() { return GroovyScriptConfig.compat.draconicEvolutionEnergyCore; } @Override - public Collection getAliases() { - return Alias.generateOfClass(EnergyCore.class); - } + public Collection getAliases() { return Alias.generateOfClass(EnergyCore.class); } @Override public void onReload() { @@ -66,12 +64,9 @@ public void onReload() { public void afterScriptLoad() {} @GroovyBlacklist - public int getVersion() { - return version; - } + public int getVersion() { return version; } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal public void applyEdit(BlockStateMultiblockStorage[] mbs) { for (int i = 0; i < mbs.length; i++) { mbs[i].setStructure(this.edited[i]); @@ -80,10 +75,9 @@ public void applyEdit(BlockStateMultiblockStorage[] mbs) { private void replaceBlock(int tier, BlockStates edit, boolean inner) { if (tier < 1 || tier > 8) { - GroovyLog.msg("Error setting block of Draconic Evolution Energy Core") - .add("Tier {} is invalid. Must be between 1 and 8") - .error() - .post(); + GroovyLog.msg("Error setting block of Draconic Evolution Energy Core").add( + "Tier {} is invalid. Must be between 1 and 8") + .error().post(); return; } init(); @@ -101,31 +95,29 @@ private void replaceBlock(int tier, BlockStates edit, boolean inner) { (inner ? this.inner : this.outer)[tier - 1] = edit; } - @MethodDescription(description = "groovyscript.wiki.draconicevolution.inner_block", type = MethodDescription.Type.VALUE, example = { - @Example("7, blockstate('minecraft:stone', 1)") - }) + @MethodDescription(description = "groovyscript.wiki.draconicevolution.inner_block", + type = MethodDescription.Type.VALUE, + example = {@Example("7, blockstate('minecraft:stone', 1)")}) public EnergyCore setInnerBlock(int tier, IBlockState... blockStates) { if (blockStates == null || blockStates.length == 0) { - GroovyLog.msg("Error setting inner block of tier {} Draconic Evolution Energy Core", tier) - .add("block states must not be null or empty") - .error() - .post(); + GroovyLog.msg("Error setting inner block of tier {} Draconic Evolution Energy Core", tier).add( + "block states must not be null or empty") + .error().post(); return this; } replaceBlock(tier, BlockStates.of(blockStates), true); return this; } - @MethodDescription(description = "groovyscript.wiki.draconicevolution.outer_block", type = MethodDescription.Type.VALUE, example = { - @Example("7, blockstate('minecraft:diamond_block')"), - @Example("2, blockstate('minecraft:diamond_block')") - }) + @MethodDescription(description = "groovyscript.wiki.draconicevolution.outer_block", + type = MethodDescription.Type.VALUE, + example = {@Example("7, blockstate('minecraft:diamond_block')"), + @Example("2, blockstate('minecraft:diamond_block')")}) public EnergyCore setOuterBlock(int tier, IBlockState... blockStates) { if (blockStates == null || blockStates.length == 0) { - GroovyLog.msg("Error setting outer block of tier {} Draconic Evolution Energy Core", tier) - .add("block states must not be null or empty") - .error() - .post(); + GroovyLog.msg("Error setting outer block of tier {} Draconic Evolution Energy Core", tier).add( + "block states must not be null or empty") + .error().post(); return this; } replaceBlock(tier, BlockStates.of(blockStates), false); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/Fusion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/Fusion.java index 35d83ced8..6f907c9d7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/Fusion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/Fusion.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.draconicevolution; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.brandon3055.draconicevolution.api.fusioncrafting.IFusionRecipe; import com.brandon3055.draconicevolution.lib.RecipeManager; import com.cleanroommc.groovyscript.api.GroovyLog; @@ -10,10 +16,6 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.stream.Collectors; @RegistryDescription public class Fusion extends VirtualizedRegistry { @@ -24,10 +26,8 @@ public void onReload() { restoreFromBackup().forEach(RecipeManager.FUSION_REGISTRY::add); } - @RecipeBuilderDescription(example = { - @Example(".catalyst(item('minecraft:diamond')).input(ore('ingotIron'), ore('ingotIron'), item('minecraft:dirt'), item('minecraft:grass'), item('minecraft:grass'), item('minecraft:dirt'), ore('ingotGold'), ore('ingotGold')).output(item('minecraft:nether_star')).energy(10).tier(1)"), - @Example(".catalyst(item('minecraft:diamond')).input(item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:nether_star')).energy(100000).tierChaotic()") - }) + @RecipeBuilderDescription(example = {@Example(".catalyst(item('minecraft:diamond')).input(ore('ingotIron'), ore('ingotIron'), item('minecraft:dirt'), item('minecraft:grass'), item('minecraft:grass'), item('minecraft:dirt'), ore('ingotGold'), ore('ingotGold')).output(item('minecraft:nether_star')).energy(10).tier(1)"), + @Example(".catalyst(item('minecraft:diamond')).input(item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:nether_star')).energy(100000).tierChaotic()")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -48,7 +48,9 @@ public boolean remove(IFusionRecipe recipe) { @MethodDescription(example = @Example("item('draconicevolution:chaos_shard')")) public void removeByCatalyst(ItemStack item) { - for (IFusionRecipe recipe : RecipeManager.FUSION_REGISTRY.getRecipes().stream().filter(x -> x.getRecipeCatalyst().isItemEqual(item)).collect(Collectors.toList())) { + for (IFusionRecipe recipe : RecipeManager.FUSION_REGISTRY.getRecipes().stream().filter(x -> x.getRecipeCatalyst() + .isItemEqual(item)).collect( + Collectors.toList())) { remove(recipe); } } @@ -61,8 +63,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((FusionRegistryAccessor) RecipeManager.FUSION_REGISTRY).getREGISTRY()) - .setRemover(this::remove); + return new SimpleObjectStream<>(((FusionRegistryAccessor) RecipeManager.FUSION_REGISTRY).getREGISTRY()).setRemover(this::remove); } @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "54")}) @@ -120,9 +121,7 @@ public RecipeBuilder tierChaotic() { } @Override - public String getErrorMsg() { - return "Error adding Draconic Evolution Fusion recipe"; - } + public String getErrorMsg() { return "Error adding Draconic Evolution Fusion recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -133,8 +132,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(energy <= 0, "energy must be greater than 0, yet it was {}", energy); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IFusionRecipe register() { if (!validate()) return null; GroovyFusionRecipe recipe = new GroovyFusionRecipe(output.get(0), catalyst, input, energy, tier); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/GroovyFusionRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/GroovyFusionRecipe.java index b0e7dbe83..cb28e27a4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/GroovyFusionRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/GroovyFusionRecipe.java @@ -1,19 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.draconicevolution; -import com.brandon3055.draconicevolution.api.fusioncrafting.ICraftingInjector; -import com.brandon3055.draconicevolution.api.fusioncrafting.IFusionCraftingInventory; -import com.brandon3055.draconicevolution.api.fusioncrafting.IFusionRecipe; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; +import com.brandon3055.draconicevolution.api.fusioncrafting.ICraftingInjector; +import com.brandon3055.draconicevolution.api.fusioncrafting.IFusionCraftingInventory; +import com.brandon3055.draconicevolution.api.fusioncrafting.IFusionRecipe; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; public class GroovyFusionRecipe implements IFusionRecipe { @@ -24,7 +26,8 @@ public class GroovyFusionRecipe implements IFusionRecipe { protected final long energyCost; protected final int craftingTier; - public GroovyFusionRecipe(ItemStack result, ItemStack catalyst, Collection input, long energyCost, int craftingTier) { + public GroovyFusionRecipe(ItemStack result, ItemStack catalyst, Collection input, long energyCost, + int craftingTier) { this.result = result; this.catalyst = catalyst; this.ingredients = new ArrayList<>(input); @@ -48,31 +51,21 @@ public boolean isRecipeCatalyst(ItemStack itemStack) { } @Override - public List getRecipeIngredients() { - return this.displayItems; - } + public List getRecipeIngredients() { return this.displayItems; } @Override - public int getRecipeTier() { - return craftingTier; - } + public int getRecipeTier() { return craftingTier; } @Override - public ItemStack getRecipeCatalyst() { - return catalyst; - } + public ItemStack getRecipeCatalyst() { return catalyst; } @Override - public long getIngredientEnergyCost() { - return energyCost; - } + public long getIngredientEnergyCost() { return energyCost; } @Override public boolean matches(IFusionCraftingInventory inventory, World world, BlockPos blockPos) { ItemStack coreStack = inventory.getStackInCore(0); - if (coreStack.isEmpty() || !isRecipeCatalyst(coreStack) || coreStack.getCount() < catalyst.getCount()) { - return false; - } + if (coreStack.isEmpty() || !isRecipeCatalyst(coreStack) || coreStack.getCount() < catalyst.getCount()) { return false; } List injectors = new ArrayList<>(inventory.getInjectors()); int found = 0; @@ -81,7 +74,8 @@ public boolean matches(IFusionCraftingInventory inventory, World world, BlockPos Iterator it = injectors.iterator(); while (it.hasNext()) { ICraftingInjector craftingInjector = it.next(); - if (ingredient.test(craftingInjector.getStackInPedestal()) && ingredient.getAmount() <= craftingInjector.getStackInPedestal().getCount()) { + if (ingredient.test(craftingInjector.getStackInPedestal()) && ingredient.getAmount() <= craftingInjector.getStackInPedestal() + .getCount()) { found++; it.remove(); break; @@ -133,17 +127,13 @@ public void onCraftingTick(IFusionCraftingInventory iFusionCraftingInventory, Wo @Override public String canCraft(IFusionCraftingInventory inventory, World world, BlockPos blockPos) { - if (!inventory.getStackInCore(1).isEmpty()) { - return "outputObstructed"; - } + if (!inventory.getStackInCore(1).isEmpty()) { return "outputObstructed"; } Iterator it = inventory.getInjectors().iterator(); ICraftingInjector pedestal; do { - if (!it.hasNext()) { - return "true"; - } + if (!it.hasNext()) { return "true"; } pedestal = it.next(); } while (pedestal.getStackInPedestal().isEmpty() || pedestal.getPedestalTier() >= this.craftingTier); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateEnergyCoreStructure.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateEnergyCoreStructure.java index 2777fe295..05d0cc2e9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateEnergyCoreStructure.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateEnergyCoreStructure.java @@ -1,17 +1,8 @@ package com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers; -import com.brandon3055.brandonscore.lib.Vec3D; -import com.brandon3055.brandonscore.utils.ModelUtils; -import com.brandon3055.brandonscore.utils.Utils; -import com.brandon3055.draconicevolution.DEConfig; -import com.brandon3055.draconicevolution.DEFeatures; -import com.brandon3055.draconicevolution.blocks.tileentity.TileEnergyStorageCore; -import com.brandon3055.draconicevolution.blocks.tileentity.TileInvisECoreBlock; -import com.brandon3055.draconicevolution.client.gui.GuiEnergyCore; -import com.brandon3055.draconicevolution.client.handler.ClientEventHandler; -import com.brandon3055.draconicevolution.world.EnergyCoreStructure; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import java.util.List; +import java.util.Objects; + import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; @@ -22,10 +13,21 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; + import org.lwjgl.opengl.GL11; -import java.util.List; -import java.util.Objects; +import com.brandon3055.brandonscore.lib.Vec3D; +import com.brandon3055.brandonscore.utils.ModelUtils; +import com.brandon3055.brandonscore.utils.Utils; +import com.brandon3055.draconicevolution.DEConfig; +import com.brandon3055.draconicevolution.DEFeatures; +import com.brandon3055.draconicevolution.blocks.tileentity.TileEnergyStorageCore; +import com.brandon3055.draconicevolution.blocks.tileentity.TileInvisECoreBlock; +import com.brandon3055.draconicevolution.client.gui.GuiEnergyCore; +import com.brandon3055.draconicevolution.client.handler.ClientEventHandler; +import com.brandon3055.draconicevolution.world.EnergyCoreStructure; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; public class BlockStateEnergyCoreStructure extends EnergyCoreStructure { @@ -62,9 +64,7 @@ public BlockStateEnergyCoreStructure(TileEnergyStorageCore core) { structureTiers[7] = buildTierOMG(); } - public BlockStateMultiblockHelper getHelper() { - return helper; - } + public BlockStateMultiblockHelper getHelper() { return helper; } public boolean checkVersion() { if (version != ModSupport.DRACONIC_EVOLUTION.get().energyCore.getVersion()) { @@ -127,7 +127,8 @@ private void forTier(int tier, int flag) { if (checkTier < 0) { GroovyScript.LOGGER.error("[EnergyCoreStructure] Tier value to small. As far as TileEnergyStorageCore is concerned the tiers now start at 1 not 0. This class automatically handles the conversion now"); } else if (checkTier >= structureTiers.length) { - GroovyScript.LOGGER.error("[EnergyCoreStructure#placeTier] There are only 8 tiers, but tried to use tier {}", checkTier); + GroovyScript.LOGGER.error("[EnergyCoreStructure#placeTier] There are only 8 tiers, but tried to use tier {}", + checkTier); } else { structureTiers[checkTier].forEachInStructure(core.getWorld(), core.getPos().add(getCoreOffset(checkTier + 1)), flag); } @@ -139,12 +140,9 @@ public BlockStateMultiblockStorage getStorageForTier(int tier) { } public void forBlock(BlockStates states, World world, BlockPos pos, BlockPos startPos, int flag) { - if (states == null) - return; + if (states == null) return; - if (states.isWildcard() || - states.equals(coreBlock())) - return; + if (states.isWildcard() || states.equals(coreBlock())) return; //region Render Build Guide @@ -187,8 +185,7 @@ else if (flag == FLAG_REVERT) { //endregion } - @SideOnly(Side.CLIENT) - @SuppressWarnings("unused") + @SideOnly(Side.CLIENT) @SuppressWarnings("unused") private void renderBuildGuide(BlockStates states, World world, BlockPos pos, BlockPos startPos, int flag) { Vec3D corePos = Vec3D.getCenter(startPos.subtract(getCoreOffset(core.tier.value))); double dist = Utils.getDistanceAtoB(corePos, Vec3D.getCenter(pos)); @@ -201,11 +198,10 @@ private void renderBuildGuide(BlockStates states, World world, BlockPos pos, Blo IBlockState atState = world.getBlockState(pos); boolean invalid = !world.isAirBlock(pos) && !states.matches(atState, false); - if (dist + 2 > pDist && !invalid) { - return; - } + if (dist + 2 > pDist && !invalid) { return; } - BlockPos translation = new BlockPos(pos.getX() - startPos.getX(), pos.getY() - startPos.getY(), pos.getZ() - startPos.getZ()); + BlockPos translation = new BlockPos(pos.getX() - startPos.getX(), pos.getY() - startPos.getY(), pos.getZ() - startPos + .getZ()); translation = translation.add(getCoreOffset(core.tier.value)); int alpha = 0xFF000000; @@ -276,16 +272,13 @@ public BlockPos getCoreOffset(int tier) { } public void setBlock(BlockStates states, World world, BlockPos pos) { - if (states == null) - return; + if (states == null) return; if (!states.equals(coreBlock())) { helper.setBlock(states, world, pos); } } - public BlockStateMultiblockStorage[] getStructureTiers() { - return structureTiers; - } + public BlockStateMultiblockStorage[] getStructureTiers() { return structureTiers; } private BlockStateMultiblockStorage buildTier1() { BlockStateMultiblockStorage storage = new BlockStateMultiblockStorage(1, helper, this); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateMultiblockHelper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateMultiblockHelper.java index 76351e5dd..6206580b5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateMultiblockHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateMultiblockHelper.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers; -import com.brandon3055.brandonscore.utils.MultiBlockHelper; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import com.brandon3055.brandonscore.utils.MultiBlockHelper; + public class BlockStateMultiblockHelper extends MultiBlockHelper { public IBlockState expectedBlockState; @@ -18,6 +19,5 @@ public void setBlock(BlockStates states, World world, BlockPos pos) { } @SuppressWarnings({"unused", "EmptyMethod"}) - public void forBlock(BlockStates state, World world, BlockPos pos, BlockPos startPos, int flag) { - } + public void forBlock(BlockStates state, World world, BlockPos pos, BlockPos startPos, int flag) {} } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateMultiblockStorage.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateMultiblockStorage.java index 3d0f21ee5..c0e4351de 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateMultiblockStorage.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/draconicevolution/helpers/BlockStateMultiblockStorage.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers; -import com.brandon3055.brandonscore.lib.MultiBlockStorage; -import com.cleanroommc.groovyscript.helper.ArrayUtils; +import java.util.function.BiConsumer; + import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.function.BiConsumer; +import com.brandon3055.brandonscore.lib.MultiBlockStorage; +import com.cleanroommc.groovyscript.helper.ArrayUtils; public class BlockStateMultiblockStorage extends MultiBlockStorage { @@ -16,7 +17,8 @@ public class BlockStateMultiblockStorage extends MultiBlockStorage { private int xPos; private int yPos; - public BlockStateMultiblockStorage(int size, BlockStateMultiblockHelper helper, BlockStateEnergyCoreStructure energyCoreStructure) { + public BlockStateMultiblockStorage(int size, BlockStateMultiblockHelper helper, + BlockStateEnergyCoreStructure energyCoreStructure) { super(size, helper); this.helper = helper; this.size = size; @@ -45,15 +47,14 @@ public void addRow(BlockStates... zRow) { */ public void mirrorLayers(int minY, int maxY) { if (yPos < maxY) { - throw new IllegalArgumentException("[MultiBlockStorage] Cannot mirror from minY " + minY + " to maxY " + maxY + " as have not reached maxY yet!"); + throw new IllegalArgumentException("[MultiBlockStorage] Cannot mirror from minY " + minY + " to maxY " + maxY + + " as have not reached maxY yet!"); } // Loop from last to first (mirror), excluding maxY, including minY for (int y = maxY - 1; y >= minY; y--) { - if (y != minY || xPos != 0) - newLayer(); + if (y != minY || xPos != 0) newLayer(); - for (int x = 0; x < size; x++) - addRow(structure[x][y]); + for (int x = 0; x < size; x++) addRow(structure[x][y]); } } @@ -68,9 +69,7 @@ public void mirrorHalf() { public void newLayer() { xPos = 0; yPos++; - if (this.yPos >= size) { - throw new RuntimeException("[MultiBlockStorage] Attempt to add too many layers to structure"); - } + if (this.yPos >= size) { throw new RuntimeException("[MultiBlockStorage] Attempt to add too many layers to structure"); } } @Override @@ -117,15 +116,9 @@ public void forEachBlockStates(BlockPos startPos, BiConsumer { @@ -42,18 +45,15 @@ public AlloySmelter() { super(Alias.generateOfClassAnd(AlloySmelter.class, "Alloying")); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond') * 4, item('minecraft:clay') * 32).output(item('minecraft:nether_star')).energy(100000).xp(500).tierEnhanced()"), - @Example(".input(item('minecraft:clay') * 4, item('minecraft:diamond')).output(item('minecraft:obsidian')).tierNormal()"), - @Example(".input(item('minecraft:diamond') * 4, item('minecraft:gold_ingot') * 2).output(item('minecraft:clay') * 4).tierSimple()"), - @Example(".input(item('minecraft:diamond') * 2, item('minecraft:gold_nugget') * 2).output(item('minecraft:clay') * 4).tierAny()") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond') * 4, item('minecraft:clay') * 32).output(item('minecraft:nether_star')).energy(100000).xp(500).tierEnhanced()"), + @Example(".input(item('minecraft:clay') * 4, item('minecraft:diamond')).output(item('minecraft:obsidian')).tierNormal()"), + @Example(".input(item('minecraft:diamond') * 4, item('minecraft:gold_ingot') * 2).output(item('minecraft:clay') * 4).tierSimple()"), + @Example(".input(item('minecraft:diamond') * 2, item('minecraft:gold_nugget') * 2).output(item('minecraft:clay') * 4).tierAny()")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { AlloyRecipeManagerAccessor accessor = (AlloyRecipeManagerAccessor) AlloyRecipeManager.getInstance(); TriItemLookup lookup = accessor.getLookup(); @@ -72,9 +72,7 @@ public void onReload() { } } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void afterScriptLoad() { if (this.removalQueue != null) { removeInternal(this.removalQueue); @@ -113,29 +111,22 @@ public List find(ItemStack output) { return recipes; } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal private void removeInternal(Collection recipes) { AlloyRecipeManagerAccessor accessor = (AlloyRecipeManagerAccessor) AlloyRecipeManager.getInstance(); - @SuppressWarnings("unchecked") - Int2ObjectOpenHashMap, ItemRecipeNode>>> map = - ((ItemRecipeNodeAccessor>>) - ((TriItemLookupAccessor) accessor.getLookup()).getRoot()).getMap(); + @SuppressWarnings("unchecked") Int2ObjectOpenHashMap, ItemRecipeNode>>> map = ((ItemRecipeNodeAccessor>>) ((TriItemLookupAccessor) accessor.getLookup()).getRoot()).getMap(); for (NNPair, ItemRecipeNode>> pair : map.values()) { Iterator listIter = pair.left.iterator(); while (listIter.hasNext()) { if (recipes.contains(listIter.next())) { listIter.remove(); - @SuppressWarnings("unchecked") - Int2ObjectOpenHashMap, ItemRecipeLeafNode>> nestedMap = - ((ItemRecipeNodeAccessor>) pair.right).getMap(); + @SuppressWarnings("unchecked") Int2ObjectOpenHashMap, ItemRecipeLeafNode>> nestedMap = ((ItemRecipeNodeAccessor>) pair.right).getMap(); for (NNPair, ItemRecipeLeafNode> nestedPair : nestedMap.values()) { Iterator nestedListIter = nestedPair.left.iterator(); while (nestedListIter.hasNext()) { if (recipes.contains(nestedListIter.next())) { nestedListIter.remove(); - @SuppressWarnings("unchecked") - Int2ObjectOpenHashMap> lastNestedMap = ((ItemRecipeLeafNodeAccessor) nestedPair.right).getMap(); + @SuppressWarnings("unchecked") Int2ObjectOpenHashMap> lastNestedMap = ((ItemRecipeLeafNodeAccessor) nestedPair.right).getMap(); for (NNList lastNestedList : lastNestedMap.values()) { lastNestedList.removeIf(recipes::contains); } @@ -149,20 +140,16 @@ private void removeInternal(Collection recipes) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - List list = MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.ALLOYSMELTER).values().stream() - .filter(r -> r instanceof IManyToOneRecipe) - .map(r -> (IManyToOneRecipe) r).collect(Collectors.toList()); - return new SimpleObjectStream<>(list) - .setRemover(this::remove); + List list = MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.ALLOYSMELTER) + .values().stream().filter(r -> r instanceof IManyToOneRecipe) + .map(r -> (IManyToOneRecipe) r).collect(Collectors.toList()); + return new SimpleObjectStream<>(list).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { AlloyRecipeManagerAccessor accessor = (AlloyRecipeManagerAccessor) AlloyRecipeManager.getInstance(); - @SuppressWarnings("unchecked") - Int2ObjectOpenHashMap, ItemRecipeNode>>> map = - ((ItemRecipeNodeAccessor>>) - ((TriItemLookupAccessor) accessor.getLookup()).getRoot()).getMap(); + @SuppressWarnings("unchecked") Int2ObjectOpenHashMap, ItemRecipeNode>>> map = ((ItemRecipeNodeAccessor>>) ((TriItemLookupAccessor) accessor.getLookup()).getRoot()).getMap(); for (NNPair, ItemRecipeNode>> pair : map.values()) { Iterator listIter = pair.left.iterator(); while (listIter.hasNext()) { @@ -189,9 +176,7 @@ public RecipeBuilder xp(float xp) { } @Override - public String getErrorMsg() { - return "Error adding EnderIO Alloy Smelter recipe"; - } + public String getErrorMsg() { return "Error adding EnderIO Alloy Smelter recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -201,11 +186,12 @@ public void validate(GroovyLog.Msg msg) { if (xp < 0) xp = 0; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable Void register() { if (!validate()) return null; - AlloyRecipeManager.getInstance().addRecipe(true, ArrayUtils.mapToList(input, RecipeInput::new, new NNList<>()), output.get(0), energy, xp, level); + AlloyRecipeManager.getInstance().addRecipe(true, ArrayUtils.mapToList(input, RecipeInput::new, new NNList<>()), output + .get(0), + energy, xp, level); return null; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Enchanter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Enchanter.java index cec0894f6..b24e7cecb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Enchanter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Enchanter.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.minecraft.enchantment.Enchantment; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,31 +22,21 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.IRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import crazypants.enderio.base.recipe.IMachineRecipe; import crazypants.enderio.base.recipe.MachineRecipeRegistry; import crazypants.enderio.base.recipe.enchanter.EnchanterRecipe; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; @RegistryDescription public class Enchanter extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".enchantment(enchantment('minecraft:unbreaking')).input(item('minecraft:diamond'))"), - @Example(".enchantment(enchantment('minecraft:sharpness')).input(item('minecraft:clay')).amountPerLevel(3).xpCostMultiplier(2).customBook(item('minecraft:book')).customLapis(item('minecraft:diamond'))") - }) + @RecipeBuilderDescription(example = {@Example(".enchantment(enchantment('minecraft:unbreaking')).input(item('minecraft:diamond'))"), + @Example(".enchantment(enchantment('minecraft:sharpness')).input(item('minecraft:clay')).amountPerLevel(3).xpCostMultiplier(2).customBook(item('minecraft:book')).customLapis(item('minecraft:diamond'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(MachineRecipeRegistry.instance::removeRecipe); restoreFromBackup().forEach(MachineRecipeRegistry.instance::registerRecipe); @@ -49,10 +49,7 @@ public void add(EnchanterRecipe recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION) public void add(Enchantment enchantment, IIngredient input) { - recipeBuilder() - .enchantment(enchantment) - .input(input) - .register(); + recipeBuilder().enchantment(enchantment).input(input).register(); } public boolean remove(EnchanterRecipe recipe) { @@ -69,7 +66,8 @@ public void remove(Enchantment enchantment) { return; } List recipes = new ArrayList<>(); - for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.ENCHANTER).values()) { + for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.ENCHANTER) + .values()) { if (recipe instanceof EnchanterRecipe && enchantment == ((EnchanterRecipe) recipe).getEnchantment()) { recipes.add((EnchanterRecipe) recipe); } @@ -86,14 +84,16 @@ public void remove(Enchantment enchantment) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>((Collection) MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.ENCHANTER).values()) - .setRemover(this::remove); + return new SimpleObjectStream<>((Collection) MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.ENCHANTER) + .values()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.ENCHANTER).forEach((r, l) -> addBackup((EnchanterRecipe) l)); - ((SimpleRecipeGroupHolderAccessor) MachineRecipeRegistry.instance.getRecipeHolderssForMachine(MachineRecipeRegistry.ENCHANTER)).getRecipes().clear(); + MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.ENCHANTER).forEach((r, l) -> addBackup( + (EnchanterRecipe) l)); + ((SimpleRecipeGroupHolderAccessor) MachineRecipeRegistry.instance.getRecipeHolderssForMachine(MachineRecipeRegistry.ENCHANTER)).getRecipes() + .clear(); } public static class RecipeBuilder implements IRecipeBuilder { @@ -149,18 +149,18 @@ public RecipeBuilder customLapis(IIngredient lapis) { @Override public boolean validate() { - GroovyLog.Msg msg = GroovyLog.msg("Error adding EnderIO Enchanter recipe").error() - .add(enchantment == null, () -> "enchantment must not be null") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(book), () -> "custom book must not be empty") - .add(IngredientHelper.isEmpty(lapis), () -> "custom lapis must not be empty"); + GroovyLog.Msg msg = GroovyLog.msg("Error adding EnderIO Enchanter recipe").error().add(enchantment == null, + () -> "enchantment must not be null") + .add(IngredientHelper.isEmpty(input), () -> "input must not be empty").add( + IngredientHelper.isEmpty(book), + () -> "custom book must not be empty") + .add(IngredientHelper.isEmpty(lapis), () -> "custom lapis must not be empty"); if (amount <= 0 && input != null) amount = input.getAmount(); return !msg.postIfNotEmpty(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable EnchanterRecipe register() { if (!validate()) return null; EnchanterRecipe recipe = new CustomEnchanterRecipe(input, amount, enchantment, costMultiplier, lapis, book); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/FluidCoolant.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/FluidCoolant.java index 2e97683ed..33ec03258 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/FluidCoolant.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/FluidCoolant.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -9,13 +16,9 @@ import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import crazypants.enderio.base.fluid.FluidFuelRegister; import crazypants.enderio.base.fluid.IFluidCoolant; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription public class FluidCoolant extends VirtualizedRegistry { @@ -48,7 +51,8 @@ public void addCoolant(IFluidCoolant fluidCoolant) { GroovyLog.get().error("Error adding EnderIO coolant for null fluidCoolant!"); return; } - ((FluidFuelRegisterAccessor) FluidFuelRegister.instance).getCoolants().put(fluidCoolant.getFluid().getName(), fluidCoolant); + ((FluidFuelRegisterAccessor) FluidFuelRegister.instance).getCoolants().put(fluidCoolant.getFluid().getName(), + fluidCoolant); addScripted(fluidCoolant); } @@ -90,8 +94,7 @@ public IFluidCoolant find(Fluid fluid) { return ((FluidFuelRegisterAccessor) FluidFuelRegister.instance).getCoolants().get(fluid.getName()); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { FluidFuelRegisterAccessor accessor = (FluidFuelRegisterAccessor) FluidFuelRegister.instance; removeScripted().forEach(c -> accessor.getCoolants().remove(c.getFluid().getName())); @@ -101,7 +104,7 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { return new SimpleObjectStream<>(((FluidFuelRegisterAccessor) FluidFuelRegister.instance).getCoolants().entrySet()) - .setRemover(r -> remove(r.getValue())); + .setRemover(r -> remove(r.getValue())); } @MethodDescription(priority = 2000, example = @Example(commented = true)) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/FluidFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/FluidFuel.java index 11d414b80..4846fe7c5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/FluidFuel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/FluidFuel.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -9,13 +16,9 @@ import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import crazypants.enderio.base.fluid.FluidFuelRegister; import crazypants.enderio.base.fluid.IFluidFuel; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription public class FluidFuel extends VirtualizedRegistry { @@ -85,8 +88,7 @@ public IFluidFuel find(Fluid fluid) { return FluidFuelRegister.instance.getFuel(fluid); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { FluidFuelRegisterAccessor accessor = (FluidFuelRegisterAccessor) FluidFuelRegister.instance; removeScripted().forEach(c -> accessor.getFuels().remove(c.getFluid().getName())); @@ -96,7 +98,7 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { return new SimpleObjectStream<>(((FluidFuelRegisterAccessor) FluidFuelRegister.instance).getFuels().entrySet()) - .setRemover(r -> remove(r.getValue())); + .setRemover(r -> remove(r.getValue())); } @MethodDescription(priority = 2000, example = @Example(commented = true)) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMill.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMill.java index 7a4116c8a..7da4a0a05 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMill.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMill.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -11,6 +15,7 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import crazypants.enderio.base.recipe.Recipe; import crazypants.enderio.base.recipe.RecipeBonusType; import crazypants.enderio.base.recipe.RecipeLevel; @@ -18,8 +23,6 @@ import crazypants.enderio.base.recipe.sagmill.SagMillRecipeManager; import it.unimi.dsi.fastutil.floats.FloatArrayList; import it.unimi.dsi.fastutil.floats.FloatList; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class SagMill extends VirtualizedRegistry { @@ -28,12 +31,10 @@ public SagMill() { super(Alias.generateOfClassAnd(SagMill.class, "Sag").and("SAGMill")); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:diamond') * 4).output(item('minecraft:clay_ball') * 2, 0.7).output(item('minecraft:gold_ingot'), 0.1).output(item('minecraft:gold_ingot'), 0.1).bonusTypeMultiply().energy(1000).tierEnhanced()"), - @Example(".input(item('minecraft:clay_ball')).output(item('minecraft:diamond') * 4).output(item('minecraft:gold_ingot'), 0.1).bonusTypeChance().tierNormal()"), - @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot'), 0.1).bonusTypeNone().tierSimple()"), - @Example(".input(item('minecraft:nether_star')).output(item('minecraft:clay_ball') * 2, 0.7).output(item('minecraft:gold_ingot'), 0.1).tierAny()") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond_block')).output(item('minecraft:diamond') * 4).output(item('minecraft:clay_ball') * 2, 0.7).output(item('minecraft:gold_ingot'), 0.1).output(item('minecraft:gold_ingot'), 0.1).bonusTypeMultiply().energy(1000).tierEnhanced()"), + @Example(".input(item('minecraft:clay_ball')).output(item('minecraft:diamond') * 4).output(item('minecraft:gold_ingot'), 0.1).bonusTypeChance().tierNormal()"), + @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot'), 0.1).bonusTypeNone().tierSimple()"), + @Example(".input(item('minecraft:nether_star')).output(item('minecraft:clay_ball') * 2, 0.7).output(item('minecraft:gold_ingot'), 0.1).tierAny()")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -61,8 +62,7 @@ public void removeByInput(ItemStack input) { } } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(SagMillRecipeManager.getInstance().getRecipes()::remove); restoreFromBackup().forEach(SagMillRecipeManager.getInstance().getRecipes()::add); @@ -70,8 +70,7 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SagMillRecipeManager.getInstance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(SagMillRecipeManager.getInstance().getRecipes()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -98,8 +97,7 @@ public RecipeBuilder output(ItemStack itemStack, float chance) { return this; } - @Override - @RecipeBuilderMethodDescription(field = {"output", "chances"}) + @Override @RecipeBuilderMethodDescription(field = {"output", "chances"}) public AbstractRecipeBuilder output(ItemStack output) { return output(output, 1.0f); } @@ -123,9 +121,7 @@ public RecipeBuilder bonusTypeChance() { } @Override - public String getErrorMsg() { - return "Error adding EnderIO Sag Mill recipe"; - } + public String getErrorMsg() { return "Error adding EnderIO Sag Mill recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -134,8 +130,7 @@ public void validate(GroovyLog.Msg msg) { if (energy <= 0) energy = 5000; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable Recipe register() { if (!validate()) return null; RecipeOutput[] outputs = new RecipeOutput[output.size()]; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMillGrinding.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMillGrinding.java index 0f5ce24a5..20bd2a861 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMillGrinding.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMillGrinding.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,10 +13,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import crazypants.enderio.base.recipe.sagmill.GrindingBall; import crazypants.enderio.base.recipe.sagmill.SagMillRecipeManager; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class SagMillGrinding extends VirtualizedRegistry { @@ -49,8 +52,7 @@ public boolean remove(ItemStack grindingBall) { return false; } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(SagMillRecipeManager.getInstance().getBalls()::remove); restoreFromBackup().forEach(SagMillRecipeManager.getInstance().getBalls()::add); @@ -58,8 +60,7 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SagMillRecipeManager.getInstance().getBalls()) - .setRemover(this::remove); + return new SimpleObjectStream<>(SagMillRecipeManager.getInstance().getBalls()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -105,9 +106,7 @@ public RecipeBuilder duration(int duration) { } @Override - public String getErrorMsg() { - return "Error adding EnderIO Sag Mill Grinding Ball entry"; - } + public String getErrorMsg() { return "Error adding EnderIO Sag Mill Grinding Ball entry"; } @Override public void validate(GroovyLog.Msg msg) { @@ -119,8 +118,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(duration <= 0, "duration must be an integer greater than 0, yet it was {}", duration); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable GrindingBall register() { if (!validate()) return null; GrindingBall recipe = new GrindingBall(new RecipeInput(input.get(0)), grinding, chance, power, duration); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SliceNSplice.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SliceNSplice.java index 0f68279e1..e657d9681 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SliceNSplice.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SliceNSplice.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -13,16 +22,10 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import crazypants.enderio.base.recipe.*; import crazypants.enderio.base.recipe.sagmill.SagMillRecipeManager; import crazypants.enderio.base.recipe.slicensplice.SliceAndSpliceRecipeManager; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; @RegistryDescription public class SliceNSplice extends VirtualizedRegistry { @@ -38,11 +41,7 @@ public RecipeBuilder recipeBuilder() { @MethodDescription(type = MethodDescription.Type.ADDITION) public void add(ItemStack output, List input, int energy) { - recipeBuilder() - .energy(energy) - .output(output) - .input(input) - .register(); + recipeBuilder().energy(energy).output(output).input(input).register(); } public void add(IManyToOneRecipe recipe) { @@ -82,7 +81,8 @@ public void remove(ItemStack output) { @MethodDescription(example = @Example("[item('enderio:item_alloy_ingot:7'), item('enderio:block_enderman_skull'), item('enderio:item_alloy_ingot:7'), item('minecraft:potion').withNbt(['Potion': 'minecraft:water']), item('enderio:item_basic_capacitor'), item('minecraft:potion').withNbt(['Potion': 'minecraft:water'])]")) public void removeByInput(List input) { - IRecipe recipe = SliceAndSpliceRecipeManager.getInstance().getRecipeForInputs(RecipeLevel.IGNORE, RecipeUtils.getMachineInputs(input)); + IRecipe recipe = SliceAndSpliceRecipeManager.getInstance().getRecipeForInputs(RecipeLevel.IGNORE, RecipeUtils + .getMachineInputs(input)); if (recipe instanceof IManyToOneRecipe) { SliceAndSpliceRecipeManager.getInstance().getRecipes().remove(recipe); addBackup((IManyToOneRecipe) recipe); @@ -91,8 +91,7 @@ public void removeByInput(List input) { } } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(SliceAndSpliceRecipeManager.getInstance().getRecipes()::remove); restoreFromBackup().forEach(SliceAndSpliceRecipeManager.getInstance().getRecipes()::add); @@ -100,8 +99,7 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SliceAndSpliceRecipeManager.getInstance().getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(SliceAndSpliceRecipeManager.getInstance().getRecipes()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -114,9 +112,9 @@ public void removeAll() { @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(valid = @Comp(value = "0",type = Comp.Type.GTE)) + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) private float xp; - @Property(valid = @Comp(value = "0",type = Comp.Type.GT)) + @Property(valid = @Comp(value = "0", type = Comp.Type.GT)) private int energy; @RecipeBuilderMethodDescription @@ -132,9 +130,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding EnderIO Slice'n'Splice recipe"; - } + public String getErrorMsg() { return "Error adding EnderIO Slice'n'Splice recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -147,8 +143,7 @@ public void validate(GroovyLog.Msg msg) { if (xp < 0) xp = 0; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IRecipe register() { if (!validate()) return null; RecipeOutput recipeOutput = new RecipeOutput(output.get(0), 1, xp); @@ -158,7 +153,8 @@ public void validate(GroovyLog.Msg msg) { if (IngredientHelper.isEmpty(ingredient)) continue; inputs.add(new RecipeInput(ingredient, i)); } - ManyToOneRecipe recipe = new ManyToOneRecipe(recipeOutput, energy, RecipeBonusType.NONE, RecipeLevel.IGNORE, inputs.toArray(new IRecipeInput[0])); + ManyToOneRecipe recipe = new ManyToOneRecipe(recipeOutput, energy, RecipeBonusType.NONE, RecipeLevel.IGNORE, inputs + .toArray(new IRecipeInput[0])); ModSupport.ENDER_IO.get().sliceNSplice.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SoulBinder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SoulBinder.java index 5df7ed87e..42890ce5b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SoulBinder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SoulBinder.java @@ -1,5 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.minecraft.entity.EntityList; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.EntityEntry; +import net.minecraftforge.oredict.OreDictionary; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,21 +22,12 @@ import com.cleanroommc.groovyscript.helper.recipe.RecipeName; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.enderio.core.common.util.NNList; + import crazypants.enderio.base.recipe.IMachineRecipe; import crazypants.enderio.base.recipe.MachineRecipeRegistry; import crazypants.enderio.base.recipe.RecipeLevel; import crazypants.enderio.base.recipe.soul.BasicSoulBinderRecipe; import crazypants.enderio.base.recipe.soul.ISoulBinderRecipe; -import net.minecraft.entity.EntityList; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.EntityEntry; -import net.minecraftforge.oredict.OreDictionary; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; @RegistryDescription public class SoulBinder extends VirtualizedRegistry { @@ -49,7 +52,8 @@ public boolean remove(ISoulBinderRecipe recipe) { @MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('enderio:item_material:17')")) public void remove(ItemStack output) { List recipes = new ArrayList<>(); - for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.SOULBINDER).values()) { + for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.SOULBINDER) + .values()) { if (OreDictionary.itemMatches(output, ((ISoulBinderRecipe) recipe).getOutputStack(), false)) { recipes.add((ISoulBinderRecipe) recipe); } @@ -64,8 +68,7 @@ public void remove(ItemStack output) { } } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(MachineRecipeRegistry.instance::removeRecipe); restoreFromBackup().forEach(MachineRecipeRegistry.instance::registerRecipe); @@ -73,18 +76,19 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>((Collection) MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.SOULBINDER).values()) - .setRemover(this::remove); + return new SimpleObjectStream<>((Collection) MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.SOULBINDER) + .values()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.SOULBINDER).forEach((r, l) -> addBackup((ISoulBinderRecipe) l)); - ((SimpleRecipeGroupHolderAccessor) MachineRecipeRegistry.instance.getRecipeHolderssForMachine(MachineRecipeRegistry.SOULBINDER)).getRecipes().clear(); + MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.SOULBINDER).forEach((r, l) -> addBackup( + (ISoulBinderRecipe) l)); + ((SimpleRecipeGroupHolderAccessor) MachineRecipeRegistry.instance.getRecipeHolderssForMachine(MachineRecipeRegistry.SOULBINDER)).getRecipes() + .clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(ignoresInheritedMethods = true) @@ -97,8 +101,7 @@ public static class RecipeBuilder extends AbstractRecipeBuilder entities = new NNList<>(); private final List entityErrors = new ArrayList<>(); - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public RecipeBuilder name(String name) { this.name = name; return this; @@ -166,9 +169,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding EnderIO Soul Binder recipe"; - } + public String getErrorMsg() { return "Error adding EnderIO Soul Binder recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -184,20 +185,13 @@ public void validate(GroovyLog.Msg msg) { if (name == null || name.isEmpty()) name = RecipeName.generate(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable BasicSoulBinderRecipe register() { if (!validate()) return null; - BasicSoulBinderRecipe recipe = new BasicSoulBinderRecipe( - input.get(0).getMatchingStacks()[0], - output.get(0), - energy, - xp, - name, - RecipeLevel.IGNORE, - entities, - new BasicSoulBinderRecipe.OutputFilter() { - }); + BasicSoulBinderRecipe recipe = new BasicSoulBinderRecipe(input.get(0).getMatchingStacks()[0], output.get(0), energy, + xp, name, RecipeLevel.IGNORE, entities, + new BasicSoulBinderRecipe.OutputFilter() + {}); ModSupport.ENDER_IO.get().soulBinder.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Tank.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Tank.java index ed1a42ca0..608538251 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Tank.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Tank.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; @@ -14,27 +23,19 @@ import com.cleanroommc.groovyscript.helper.recipe.RecipeName; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.enderio.core.common.util.stackable.Things; + import crazypants.enderio.base.recipe.IMachineRecipe; import crazypants.enderio.base.recipe.MachineRecipeRegistry; import crazypants.enderio.base.recipe.RecipeLevel; import crazypants.enderio.base.recipe.tank.TankMachineRecipe; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; @RegistryDescription public class Tank extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".drain().input(item('minecraft:clay')).output(item('minecraft:diamond')).fluidInput(fluid('water') * 500)"), - @Example(".fill().input(item('minecraft:diamond')).output(item('minecraft:clay')).fluidOutput(fluid('water') * 500)"), - @Example(".drain().input(item('minecraft:diamond')).fluidInput(fluid('fire_water') * 8000)"), - @Example(".fill().input(item('minecraft:diamond')).fluidOutput(fluid('fire_water') * 8000)") - }) + @RecipeBuilderDescription(example = {@Example(".drain().input(item('minecraft:clay')).output(item('minecraft:diamond')).fluidInput(fluid('water') * 500)"), + @Example(".fill().input(item('minecraft:diamond')).output(item('minecraft:clay')).fluidOutput(fluid('water') * 500)"), + @Example(".drain().input(item('minecraft:diamond')).fluidInput(fluid('fire_water') * 8000)"), + @Example(".fill().input(item('minecraft:diamond')).fluidOutput(fluid('fire_water') * 8000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -46,7 +47,8 @@ public void add(TankMachineRecipe recipe) { @MethodDescription(description = "groovyscript.wiki.enderio.tank.addFill0", type = MethodDescription.Type.ADDITION) public void addFill(IIngredient input, FluidStack inputFluid, ItemStack output) { - addFill(GroovyScript.getRunConfig().getPackId() + ":" + RecipeName.generate("groovyscript_enderio_tank_"), input, inputFluid, output); + addFill(GroovyScript.getRunConfig().getPackId() + ":" + RecipeName.generate("groovyscript_enderio_tank_"), input, + inputFluid, output); } @MethodDescription(description = "groovyscript.wiki.enderio.tank.addFill1", type = MethodDescription.Type.ADDITION) @@ -59,13 +61,15 @@ public void addFill(String recipeName, IIngredient input, FluidStack inputFluid, Things in = RecipeUtils.toThings(input); Things out = new Things().add(output); - TankMachineRecipe rec = new TankMachineRecipe(recipeName, true, in, inputFluid, out, TankMachineRecipe.Logic.NONE, RecipeLevel.IGNORE); + TankMachineRecipe rec = new TankMachineRecipe(recipeName, true, in, inputFluid, out, TankMachineRecipe.Logic.NONE, + RecipeLevel.IGNORE); add(rec); } @MethodDescription(description = "groovyscript.wiki.enderio.tank.addDrain0", type = MethodDescription.Type.ADDITION) public void addDrain(IIngredient input, FluidStack outputFluid, ItemStack output) { - addDrain(GroovyScript.getRunConfig().getPackId() + ":" + RecipeName.generate("groovyscript_enderio_tank_"), input, outputFluid, output); + addDrain(GroovyScript.getRunConfig().getPackId() + ":" + RecipeName.generate("groovyscript_enderio_tank_"), input, + outputFluid, output); } @MethodDescription(description = "groovyscript.wiki.enderio.tank.addDrain1", type = MethodDescription.Type.ADDITION) @@ -78,7 +82,8 @@ public void addDrain(String recipeName, IIngredient input, FluidStack outputFlui Things in = RecipeUtils.toThings(input); Things out = new Things().add(output); - TankMachineRecipe rec = new TankMachineRecipe(recipeName, false, in, outputFluid, out, TankMachineRecipe.Logic.NONE, RecipeLevel.IGNORE); + TankMachineRecipe rec = new TankMachineRecipe(recipeName, false, in, outputFluid, out, TankMachineRecipe.Logic.NONE, + RecipeLevel.IGNORE); add(rec); } @@ -89,7 +94,8 @@ public boolean remove(TankMachineRecipe recipe) { return true; } - @MethodDescription(description = "groovyscript.wiki.enderio.tank.removeFill0", example = @Example("item('minecraft:glass_bottle'), fluid('xpjuice')")) + @MethodDescription(description = "groovyscript.wiki.enderio.tank.removeFill0", + example = @Example("item('minecraft:glass_bottle'), fluid('xpjuice')")) public void removeFill(ItemStack input, FluidStack fluid) { GroovyLog.Msg msg = GroovyLog.msg("Error removing EnderIO Tank filling recipe").error(); msg.add(IngredientHelper.isEmpty(fluid), () -> "fluid must not be empty"); @@ -97,14 +103,17 @@ public void removeFill(ItemStack input, FluidStack fluid) { if (msg.postIfNotEmpty()) return; List recipes = new ArrayList<>(); - for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_FILLING).values()) { + for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_FILLING) + .values()) { TankMachineRecipe tankMachineRecipe = (TankMachineRecipe) recipe; if (tankMachineRecipe.getFluid().isFluidEqual(fluid) && tankMachineRecipe.getInput().contains(input)) { recipes.add(tankMachineRecipe); } } if (recipes.isEmpty()) { - GroovyLog.get().error("Could not find EnderIO Tank filling recipes for fluid {} and input {}", fluid.getFluid().getName(), input); + GroovyLog.get().error("Could not find EnderIO Tank filling recipes for fluid {} and input {}", fluid.getFluid() + .getName(), + input); } else { recipes.forEach(this::addBackup); recipes.forEach(MachineRecipeRegistry.instance::removeRecipe); @@ -119,21 +128,25 @@ public void removeFill(FluidStack fluid, ItemStack output) { if (msg.postIfNotEmpty()) return; List recipes = new ArrayList<>(); - for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_FILLING).values()) { + for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_FILLING) + .values()) { TankMachineRecipe tankMachineRecipe = (TankMachineRecipe) recipe; if (tankMachineRecipe.getFluid().isFluidEqual(fluid) && tankMachineRecipe.getOutput().contains(output)) { recipes.add(tankMachineRecipe); } } if (recipes.isEmpty()) { - GroovyLog.get().error("Could not find EnderIO Tank filling recipes for fluid {} and output {}", fluid.getFluid().getName(), output); + GroovyLog.get().error("Could not find EnderIO Tank filling recipes for fluid {} and output {}", fluid.getFluid() + .getName(), + output); } else { recipes.forEach(this::addBackup); recipes.forEach(MachineRecipeRegistry.instance::removeRecipe); } } - @MethodDescription(description = "groovyscript.wiki.enderio.tank.removeDrain0", example = @Example("item('minecraft:experience_bottle'), fluid('xpjuice')")) + @MethodDescription(description = "groovyscript.wiki.enderio.tank.removeDrain0", + example = @Example("item('minecraft:experience_bottle'), fluid('xpjuice')")) public void removeDrain(ItemStack input, FluidStack fluid) { GroovyLog.Msg msg = GroovyLog.msg("Error removing EnderIO Tank draining recipe").error(); msg.add(IngredientHelper.isEmpty(fluid), () -> "fluid must not be empty"); @@ -141,14 +154,17 @@ public void removeDrain(ItemStack input, FluidStack fluid) { if (msg.postIfNotEmpty()) return; List recipes = new ArrayList<>(); - for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_EMPTYING).values()) { + for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_EMPTYING) + .values()) { TankMachineRecipe tankMachineRecipe = (TankMachineRecipe) recipe; if (tankMachineRecipe.getFluid().isFluidEqual(fluid) && tankMachineRecipe.getInput().contains(input)) { recipes.add(tankMachineRecipe); } } if (recipes.isEmpty()) { - GroovyLog.get().error("Could not find EnderIO Tank draining recipes for fluid {} and input {}", fluid.getFluid().getName(), input); + GroovyLog.get().error("Could not find EnderIO Tank draining recipes for fluid {} and input {}", fluid.getFluid() + .getName(), + input); } else { recipes.forEach(this::addBackup); recipes.forEach(MachineRecipeRegistry.instance::removeRecipe); @@ -163,22 +179,24 @@ public void removeDrain(FluidStack fluid, ItemStack output) { if (msg.postIfNotEmpty()) return; List recipes = new ArrayList<>(); - for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_EMPTYING).values()) { + for (IMachineRecipe recipe : MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_EMPTYING) + .values()) { TankMachineRecipe tankMachineRecipe = (TankMachineRecipe) recipe; if (tankMachineRecipe.getFluid().isFluidEqual(fluid) && tankMachineRecipe.getOutput().contains(output)) { recipes.add(tankMachineRecipe); } } if (recipes.isEmpty()) { - GroovyLog.get().error("Could not find EnderIO Tank draining recipes for fluid {} and output {}", fluid.getFluid().getName(), output); + GroovyLog.get().error("Could not find EnderIO Tank draining recipes for fluid {} and output {}", fluid.getFluid() + .getName(), + output); } else { recipes.forEach(this::addBackup); recipes.forEach(MachineRecipeRegistry.instance::removeRecipe); } } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(MachineRecipeRegistry.instance::removeRecipe); restoreFromBackup().forEach(MachineRecipeRegistry.instance::registerRecipe); @@ -187,23 +205,31 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { List list = new ArrayList<>(); - list.addAll((Collection) MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_FILLING).values()); - list.addAll((Collection) MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_EMPTYING).values()); + list.addAll((Collection) MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_FILLING) + .values()); + list.addAll((Collection) MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_EMPTYING) + .values()); return new SimpleObjectStream<>(list).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_FILLING).forEach((r, l) -> addBackup((TankMachineRecipe) l)); - ((SimpleRecipeGroupHolderAccessor) MachineRecipeRegistry.instance.getRecipeHolderssForMachine(MachineRecipeRegistry.TANK_FILLING)).getRecipes().clear(); - MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_EMPTYING).forEach((r, l) -> addBackup((TankMachineRecipe) l)); - ((SimpleRecipeGroupHolderAccessor) MachineRecipeRegistry.instance.getRecipeHolderssForMachine(MachineRecipeRegistry.TANK_EMPTYING)).getRecipes().clear(); + MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_FILLING).forEach((r, l) -> addBackup( + (TankMachineRecipe) l)); + ((SimpleRecipeGroupHolderAccessor) MachineRecipeRegistry.instance.getRecipeHolderssForMachine(MachineRecipeRegistry.TANK_FILLING)).getRecipes() + .clear(); + MachineRecipeRegistry.instance.getRecipesForMachine(MachineRecipeRegistry.TANK_EMPTYING).forEach((r, l) -> addBackup( + (TankMachineRecipe) l)); + ((SimpleRecipeGroupHolderAccessor) MachineRecipeRegistry.instance.getRecipeHolderssForMachine(MachineRecipeRegistry.TANK_EMPTYING)).getRecipes() + .clear(); } @Property(property = "input", valid = @Comp("1")) - @Property(property = "fluidInput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(property = "fluidInput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) - @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(property = "fluidOutput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -222,14 +248,10 @@ public RecipeBuilder drain() { } @Override - public String getErrorMsg() { - return "Error adding EnderIO Tank recipe"; - } + public String getErrorMsg() { return "Error adding EnderIO Tank recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_enderio_tank_"; - } + public String getRecipeNamePrefix() { return "groovyscript_enderio_tank_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -238,17 +260,18 @@ public void validate(GroovyLog.Msg msg) { if (isFilling) validateFluids(msg, 0, 0, 1, 1); else validateFluids(msg, 1, 1, 0, 0); msg.add(msg.hasSubMessages(), "The Tank Recipe Builder requires an input fluid stack if it is draining and " + - "an output fluid stack if it is filling. This recipe was {}.", isFilling ? "filling" : "draining"); + "an output fluid stack if it is filling. This recipe was {}.", isFilling ? "filling" : + "draining"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable TankMachineRecipe register() { if (!validate()) return null; Things in = RecipeUtils.toThings(input.get(0)); Things out = new Things().add(output.getOrEmpty(0)); - TankMachineRecipe recipe = new TankMachineRecipe(super.name.toString(), isFilling, in, isFilling ? fluidOutput.get(0) - : fluidInput.get(0), out, TankMachineRecipe.Logic.NONE, RecipeLevel.IGNORE); + TankMachineRecipe recipe = new TankMachineRecipe(super.name.toString(), isFilling, in, isFilling ? fluidOutput.get( + 0) : + fluidInput.get(0), out, TankMachineRecipe.Logic.NONE, RecipeLevel.IGNORE); ModSupport.ENDER_IO.get().tank.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Vat.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Vat.java index afc271b09..b3f092af3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Vat.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/Vat.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,26 +20,19 @@ import com.cleanroommc.groovyscript.helper.recipe.IRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.enderio.core.common.util.NNList; + import crazypants.enderio.base.recipe.*; import crazypants.enderio.base.recipe.vat.VatRecipe; import crazypants.enderio.base.recipe.vat.VatRecipeManager; import it.unimi.dsi.fastutil.floats.FloatArrayList; import it.unimi.dsi.fastutil.floats.FloatList; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; @RegistryDescription public class Vat extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(fluid('lava')).output(fluid('hootch')).baseMultiplier(2).itemInputLeft(item('minecraft:clay'), 2).itemInputLeft(item('minecraft:clay_ball'), 0.5).itemInputRight(item('minecraft:diamond'), 5).itemInputRight(item('minecraft:diamond_block'), 50).itemInputRight(item('minecraft:gold_block'), 10).itemInputRight(item('minecraft:gold_ingot'), 1).itemInputRight(item('minecraft:gold_nugget'), 0.1).energy(1000).tierEnhanced()"), - @Example(".input(fluid('hootch') * 100).output(fluid('water') * 50).itemInputLeft(item('minecraft:clay_ball'), 1).itemInputRight(item('minecraft:diamond'), 1).energy(1000).tierNormal()"), - @Example(".input(fluid('water')).output(fluid('hootch')).itemInputLeft(item('minecraft:clay'), 2).itemInputLeft(item('minecraft:clay_ball'), 0.5).itemInputRight(item('minecraft:diamond'), 5).itemInputRight(item('minecraft:gold_ingot'), 1).energy(1000).tierAny()") - }) + @RecipeBuilderDescription(example = {@Example(".input(fluid('lava')).output(fluid('hootch')).baseMultiplier(2).itemInputLeft(item('minecraft:clay'), 2).itemInputLeft(item('minecraft:clay_ball'), 0.5).itemInputRight(item('minecraft:diamond'), 5).itemInputRight(item('minecraft:diamond_block'), 50).itemInputRight(item('minecraft:gold_block'), 10).itemInputRight(item('minecraft:gold_ingot'), 1).itemInputRight(item('minecraft:gold_nugget'), 0.1).energy(1000).tierEnhanced()"), + @Example(".input(fluid('hootch') * 100).output(fluid('water') * 50).itemInputLeft(item('minecraft:clay_ball'), 1).itemInputRight(item('minecraft:diamond'), 1).energy(1000).tierNormal()"), + @Example(".input(fluid('water')).output(fluid('hootch')).itemInputLeft(item('minecraft:clay'), 2).itemInputLeft(item('minecraft:clay_ball'), 0.5).itemInputRight(item('minecraft:diamond'), 5).itemInputRight(item('minecraft:gold_ingot'), 1).energy(1000).tierAny()")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -66,8 +67,7 @@ public void remove(FluidStack output) { } } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { NNList recipes = VatRecipeManager.getInstance().getRecipes(); removeScripted().forEach(recipes::remove); @@ -76,8 +76,8 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(VatRecipeManager.getInstance().getRecipes().stream().map(r -> (VatRecipe) r).collect(Collectors.toList())) - .setRemover(this::remove); + return new SimpleObjectStream<>(VatRecipeManager.getInstance().getRecipes().stream().map(r -> (VatRecipe) r).collect( + Collectors.toList())).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -175,8 +175,7 @@ public boolean validate() { return !msg.postIfNotEmpty(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable Recipe register() { if (!validate()) return null; List inputs = new ArrayList<>(); @@ -194,7 +193,8 @@ public boolean validate() { } inputs.add(new crazypants.enderio.base.recipe.RecipeInput(input, baseMultiplier)); - Recipe recipe = new Recipe(new RecipeOutput(output), energy, RecipeBonusType.NONE, level, inputs.toArray(new IRecipeInput[0])); + Recipe recipe = new Recipe(new RecipeOutput(output), energy, RecipeBonusType.NONE, level, inputs.toArray( + new IRecipeInput[0])); ModSupport.ENDER_IO.get().vat.add(recipe); return recipe; } @@ -210,8 +210,6 @@ public VatRecipeInput(IIngredient ing, int slot, float multiplier) { } @Override - public float getMulitplier() { - return multiplier; - } + public float getMulitplier() { return multiplier; } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/CustomEnchanterRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/CustomEnchanterRecipe.java index a1fa09c4c..cb5f76871 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/CustomEnchanterRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/CustomEnchanterRecipe.java @@ -1,40 +1,38 @@ package com.cleanroommc.groovyscript.compat.mods.enderio.recipe; +import javax.annotation.Nonnull; + +import net.minecraft.enchantment.Enchantment; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.NotNull; + import com.cleanroommc.groovyscript.api.IIngredient; import com.enderio.core.common.util.NNList; import com.enderio.core.common.util.stackable.Things; + import crazypants.enderio.base.recipe.MachineRecipeInput; import crazypants.enderio.base.recipe.RecipeLevel; import crazypants.enderio.base.recipe.enchanter.EnchanterRecipe; import crazypants.enderio.util.Prep; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.NotNull; - -import javax.annotation.Nonnull; public class CustomEnchanterRecipe extends EnchanterRecipe { private final Things lapis; private final Things book; - public CustomEnchanterRecipe(@NotNull IIngredient input, int stackSizePerLevel, @NotNull Enchantment enchantment, double costMultiplier, IIngredient lapis, IIngredient book) { + public CustomEnchanterRecipe(@NotNull IIngredient input, int stackSizePerLevel, @NotNull Enchantment enchantment, + double costMultiplier, IIngredient lapis, IIngredient book) { super(RecipeLevel.IGNORE, RecipeUtils.toThings(input), stackSizePerLevel, enchantment, costMultiplier); this.lapis = RecipeUtils.toThings(lapis); this.book = RecipeUtils.toThings(book); } - @NotNull - @Override - public Things getLapis() { - return lapis; - } + @NotNull @Override + public Things getLapis() { return lapis; } - @NotNull - @Override - public Things getBook() { - return book; - } + @NotNull @Override + public Things getBook() { return book; } @Override public boolean isRecipe(@Nonnull RecipeLevel machineLevel, @Nonnull NNList inputs) { @@ -63,6 +61,7 @@ public boolean isValidInput(@Nonnull RecipeLevel machineLevel, @Nonnull MachineR ItemStack slot0 = MachineRecipeInput.getInputForSlot(0, inputs); ItemStack slot1 = MachineRecipeInput.getInputForSlot(1, inputs); ItemStack slot2 = MachineRecipeInput.getInputForSlot(2, inputs); - return (Prep.isInvalid(slot0) || getBook().contains(slot0)) && (Prep.isInvalid(slot1) || this.getInput().contains(slot1)) && (Prep.isInvalid(slot2) || getLapis().contains(slot2)); + return (Prep.isInvalid(slot0) || getBook().contains(slot0)) && (Prep.isInvalid(slot1) || this.getInput().contains( + slot1)) && (Prep.isInvalid(slot2) || getLapis().contains(slot2)); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/EnderIORecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/EnderIORecipeBuilder.java index 7d6040498..d95085b4c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/EnderIORecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/EnderIORecipeBuilder.java @@ -3,11 +3,15 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.Property; import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderMethodDescription; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import crazypants.enderio.base.recipe.RecipeLevel; public abstract class EnderIORecipeBuilder extends AbstractRecipeBuilder { - @Property(value = "groovyscript.wiki.enderio.level.value", needsOverride = true,defaultValue = "RecipeLevel.IGNORE", hierarchy = 20) + @Property(value = "groovyscript.wiki.enderio.level.value", + needsOverride = true, + defaultValue = "RecipeLevel.IGNORE", + hierarchy = 20) protected RecipeLevel level = RecipeLevel.IGNORE; @Property(value = "groovyscript.wiki.enderio.energy.value", needsOverride = true, hierarchy = 20) protected int energy; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/ManyToOneRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/ManyToOneRecipe.java index b9caf8e1f..13b77996e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/ManyToOneRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/ManyToOneRecipe.java @@ -1,24 +1,26 @@ package com.cleanroommc.groovyscript.compat.mods.enderio.recipe; -import com.enderio.core.common.util.NNList; -import crazypants.enderio.base.recipe.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import com.enderio.core.common.util.NNList; + +import crazypants.enderio.base.recipe.*; public class ManyToOneRecipe extends Recipe { - public ManyToOneRecipe(RecipeOutput output, int energyRequired, RecipeBonusType bonusType, RecipeLevel level, IRecipeInput... input) { + public ManyToOneRecipe(RecipeOutput output, int energyRequired, RecipeBonusType bonusType, RecipeLevel level, + IRecipeInput... input) { super(output, energyRequired, bonusType, level, input); } - public RecipeOutput getOutput() { - return getOutputs()[0]; - } + public RecipeOutput getOutput() { return getOutputs()[0]; } @Override public boolean isInputForRecipe(NNList machineInputs) { @@ -41,13 +43,9 @@ public boolean isValidInput(@NotNull FluidStack fluid) { @Override public boolean isValidInput(int slot, @NotNull ItemStack item) { IRecipeInput input = getInputs()[slot]; - if ((input.getSlotNumber() < 0 || input.getSlotNumber() == slot) && input.isInput(item)) { - return true; - } + if ((input.getSlotNumber() < 0 || input.getSlotNumber() == slot) && input.isInput(item)) { return true; } for (IRecipeInput input1 : getInputs()) { - if ((input1.getSlotNumber() < 0 || input1.getSlotNumber() == slot) && input1.isInput(item)) { - return true; - } + if ((input1.getSlotNumber() < 0 || input1.getSlotNumber() == slot) && input1.isInput(item)) { return true; } } return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/RecipeInput.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/RecipeInput.java index f9fa90586..ad5738737 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/RecipeInput.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/RecipeInput.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.enderio.recipe; +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; -import crazypants.enderio.base.recipe.IRecipeInput; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import javax.annotation.Nonnull; +import crazypants.enderio.base.recipe.IRecipeInput; public class RecipeInput implements IRecipeInput { @@ -26,37 +28,27 @@ public RecipeInput(IIngredient ing, int slot) { } } - @Nonnull - @Override + @Nonnull @Override public IRecipeInput copy() { return new RecipeInput(ing); } @Override - public boolean isFluid() { - return ing instanceof FluidStack; - } + public boolean isFluid() { return ing instanceof FluidStack; } - @Nonnull - @Override + @Nonnull @Override public ItemStack getInput() { return ing.getMatchingStacks().length == 0 ? ItemStack.EMPTY : ing.getMatchingStacks()[0].copy(); } @Override - public FluidStack getFluidInput() { - return ing instanceof FluidStack ? ((FluidStack) ing).copy() : null; - } + public FluidStack getFluidInput() { return ing instanceof FluidStack ? ((FluidStack) ing).copy() : null; } @Override - public float getMulitplier() { - return 1; - } + public float getMulitplier() { return 1; } @Override - public int getSlotNumber() { - return slot; - } + public int getSlotNumber() { return slot; } @Override public boolean isInput(@Nonnull ItemStack test) { @@ -72,15 +64,12 @@ public boolean isInput(FluidStack test) { public ItemStack[] getEquivelentInputs() { ItemStack[] org = ing.getMatchingStacks(); ItemStack[] copy = new ItemStack[org.length]; - for (int i = 0; i < copy.length; i++) - copy[i] = org[i].copy(); + for (int i = 0; i < copy.length; i++) copy[i] = org[i].copy(); return copy; } @Override - public boolean isValid() { - return true; - } + public boolean isValid() { return true; } @Override public void shrinkStack(int count) { @@ -88,8 +77,6 @@ public void shrinkStack(int count) { } @Override - public int getStackSize() { - return ing.getAmount(); - } + public int getStackSize() { return ing.getAmount(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/RecipeUtils.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/RecipeUtils.java index 7d84bfd75..e931cd632 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/RecipeUtils.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/RecipeUtils.java @@ -1,16 +1,18 @@ package com.cleanroommc.groovyscript.compat.mods.enderio.recipe; +import java.util.Collection; +import java.util.List; + +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.ArrayUtils; import com.enderio.core.common.util.NNList; import com.enderio.core.common.util.stackable.Things; + import crazypants.enderio.base.recipe.IRecipeInput; import crazypants.enderio.base.recipe.MachineRecipeInput; import crazypants.enderio.base.recipe.RecipeOutput; -import net.minecraft.item.ItemStack; - -import java.util.Collection; -import java.util.List; public class RecipeUtils { @@ -44,8 +46,7 @@ public static RecipeOutput[] toEIOOutputs(ItemStack[] inputs, float[] chances, f public static String getDisplayString(IIngredient... ings) { StringBuilder sb = new StringBuilder("["); - for (IIngredient i : ings) - sb.append(i == null ? i : i + ","); + for (IIngredient i : ings) sb.append(i == null ? i : i + ","); sb.replace(sb.length() - 1, sb.length(), ""); return sb.append("]").toString(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/SagRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/SagRecipe.java index d4dd496e1..83789ba3f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/SagRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/recipe/SagRecipe.java @@ -1,13 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.enderio.recipe; -import com.enderio.core.common.util.NNList; -import crazypants.enderio.base.recipe.*; import net.minecraftforge.fluids.FluidStack; + import org.jetbrains.annotations.NotNull; +import com.enderio.core.common.util.NNList; + +import crazypants.enderio.base.recipe.*; + public class SagRecipe extends Recipe { - public SagRecipe(IRecipeInput input, int energyRequired, RecipeBonusType bonusType, RecipeLevel level, RecipeOutput... output) { + public SagRecipe(IRecipeInput input, int energyRequired, RecipeBonusType bonusType, RecipeLevel level, + RecipeOutput... output) { super(input, energyRequired, bonusType, level, output); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/DemonTradeManager.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/DemonTradeManager.java index e81393d46..d89334e4c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/DemonTradeManager.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/DemonTradeManager.java @@ -1,5 +1,8 @@ package com.cleanroommc.groovyscript.compat.mods.essentialcraft; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.EntityEntry; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -8,13 +11,12 @@ import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import essentialcraft.api.DemonTrade; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.EntityEntry; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - admonition = @Admonition(value = "groovyscript.wiki.essentialcraft.demon_trade.note0", type = Admonition.Type.DANGER)) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES, + admonition = @Admonition(value = "groovyscript.wiki.essentialcraft.demon_trade.note0", + type = Admonition.Type.DANGER)) public class DemonTradeManager extends VirtualizedRegistry { public DemonTradeManager() { @@ -57,7 +59,8 @@ public boolean remove(IIngredient x) { }); } - @MethodDescription(description = "groovyscript.wiki.essentialcraft.demon_trade.removeEntity", example = @Example("entity('minecraft:enderman')")) + @MethodDescription(description = "groovyscript.wiki.essentialcraft.demon_trade.removeEntity", + example = @Example("entity('minecraft:enderman')")) public boolean remove(EntityEntry x) { return DemonTrade.TRADES.removeIf(r -> { if (r.desiredItem.isEmpty() && x.equals(r.entityType)) { @@ -89,4 +92,4 @@ public void removeAll() { public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(DemonTrade.TRADES).setRemover(this::remove); } -} \ No newline at end of file +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagicianTable.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagicianTable.java index 2394b6656..59882678c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagicianTable.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagicianTable.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.essentialcraft; +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,12 +11,12 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import essentialcraft.api.MagicianTableRecipe; import essentialcraft.api.MagicianTableRecipes; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; -@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.essentialcraft.magician_table.note0", type = Admonition.Type.WARNING)) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.essentialcraft.magician_table.note0", + type = Admonition.Type.WARNING)) public class MagicianTable extends VirtualizedRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond'), ore('ingotGold'), ore('ingotGold'), ore('stickWood'), ore('stickWood')).output(item('minecraft:iron_ingot')).mru(500)")) @@ -65,9 +69,7 @@ public RecipeBuilder mru(int cost) { } @Override - public String getErrorMsg() { - return "Error adding Magician Table Recipe"; - } + public String getErrorMsg() { return "Error adding Magician Table Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -76,8 +78,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(mru < 1, "mru cost must be 1 or greater, got {}", mru); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable MagicianTableRecipe register() { if (!validate()) return null; Ingredient[] inputIngredient = input.stream().map(IIngredient::toMcIngredient).toArray(Ingredient[]::new); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagmaticSmeltery.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagmaticSmeltery.java index fb4781bde..e3753eb8a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagmaticSmeltery.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagmaticSmeltery.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.essentialcraft; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -7,12 +9,12 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.IRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import essentialcraft.api.OreSmeltingRecipe; -import org.jetbrains.annotations.Nullable; -@RegistryDescription(reloadability = RegistryDescription.Reloadability.DISABLED, admonition = { - @Admonition(value = "groovyscript.wiki.essentialcraft.magmatic_smeltery.note0", type = Admonition.Type.WARNING), -}) +@RegistryDescription(reloadability = RegistryDescription.Reloadability.DISABLED, + admonition = {@Admonition(value = "groovyscript.wiki.essentialcraft.magmatic_smeltery.note0", + type = Admonition.Type.WARNING),}) public class MagmaticSmeltery extends VirtualizedRegistry { @RecipeBuilderDescription(example = @Example(".input('blockIron').output('ingotGold').factor(3).color(0x0000ff)")) @@ -104,12 +106,11 @@ public MagmaticSmeltery.RecipeBuilder factor(int factor) { return this; } - public String getErrorMsg() { - return "Error adding Magmatic Smeltery Recipe"; - } + public String getErrorMsg() { return "Error adding Magmatic Smeltery Recipe"; } public void validate(GroovyLog.Msg msg) { - msg.add(OreSmeltingRecipe.RECIPE_MAP.containsKey(input), "This OreDict can already be processed in Magmatic Smeltery: {}", input); + msg.add(OreSmeltingRecipe.RECIPE_MAP.containsKey(input), + "This OreDict can already be processed in Magmatic Smeltery: {}", input); msg.add(color < 0 || color >= (1 << 24), "color must be between 0 and 0xffffff, got {}", Integer.toHexString(color)); } @@ -120,8 +121,7 @@ public boolean validate() { return !msg.postIfNotEmpty(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable OreSmeltingRecipe register() { if (!validate()) return null; OreSmeltingRecipe recipe = new OreSmeltingRecipe(input, output, color, factor); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MithrilineFurnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MithrilineFurnace.java index 72599bbd6..681dbd062 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MithrilineFurnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MithrilineFurnace.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.essentialcraft; +import java.util.Arrays; + +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,12 +13,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import essentialcraft.api.MithrilineFurnaceRecipe; import essentialcraft.api.MithrilineFurnaceRecipes; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; @RegistryDescription public class MithrilineFurnace extends VirtualizedRegistry { @@ -64,8 +67,7 @@ public SimpleObjectStream streamRecipes() { }); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.GTE, value = "1")) @@ -78,9 +80,7 @@ public RecipeBuilder espe(int cost) { } @Override - public String getErrorMsg() { - return "Error adding Mithriline Furnace Recipe"; - } + public String getErrorMsg() { return "Error adding Mithriline Furnace Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -89,8 +89,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(espe < 1, "espe cost must be 1 or greater, got {}", espe); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable MithrilineFurnaceRecipe register() { if (!validate()) return null; int stackSize = input.get(0).getAmount(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/RadiatingChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/RadiatingChamber.java index 65974fd6c..a440e13c6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/RadiatingChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/RadiatingChamber.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.essentialcraft; +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,10 +11,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import essentialcraft.api.RadiatingChamberRecipe; import essentialcraft.api.RadiatingChamberRecipes; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class RadiatingChamber extends VirtualizedRegistry { @@ -64,7 +67,8 @@ public static class RecipeBuilder extends AbstractRecipeBuilder 2.0f, "lower balance must be between 0.0f and 2.0f, got {}", lowerBalance); - msg.add(upperBalance < 0.0f || upperBalance > 2.0f, "upper balance must be between 0.0f and 2.0f, got {}", upperBalance); + msg.add(lowerBalance < 0.0f || lowerBalance > 2.0f, "lower balance must be between 0.0f and 2.0f, got {}", + lowerBalance); + msg.add(upperBalance < 0.0f || upperBalance > 2.0f, "upper balance must be between 0.0f and 2.0f, got {}", + upperBalance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RadiatingChamberRecipe register() { if (!validate()) return null; Ingredient[] inputIngredient = input.stream().map(IIngredient::toMcIngredient).toArray(Ingredient[]::new); // the attribute names lie to the devs, they're called 'int mruRequired' and 'float costModifier' // but actually they're 'int timeInTicks' and 'float mruPerTick' - RadiatingChamberRecipe recipe = new RadiatingChamberRecipe(inputIngredient, output.get(0), time, upperBalance, lowerBalance, mruPerTick); + RadiatingChamberRecipe recipe = new RadiatingChamberRecipe(inputIngredient, output.get(0), time, upperBalance, + lowerBalance, mruPerTick); ModSupport.ESSENTIALCRAFT.get().radiatingChamber.addScripted(recipe); RadiatingChamberRecipes.addRecipe(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/WindRune.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/WindRune.java index 857dcf3e9..4cb1b522e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/WindRune.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/WindRune.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.essentialcraft; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,10 +12,8 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import essentialcraft.api.WindImbueRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class WindRune extends VirtualizedRegistry { @@ -64,8 +67,7 @@ public SimpleObjectStream streamRecipes() { }); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.GTE, value = "1")) @@ -78,9 +80,7 @@ public RecipeBuilder espe(int cost) { } @Override - public String getErrorMsg() { - return "Error adding Wind Rune Recipe"; - } + public String getErrorMsg() { return "Error adding Wind Rune Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -89,8 +89,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(espe < 1, "espe cost must be 1 or greater, got {}", espe); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable WindImbueRecipe register() { if (!validate()) return null; Ingredient inputItem = input.get(0).toMcIngredient(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/BloodInfuser.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/BloodInfuser.java index af5f6642a..195392770 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/BloodInfuser.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/BloodInfuser.java @@ -1,15 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.evilcraft; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; + import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.cyclopscore.recipe.custom.component.IngredientRecipeComponent; import org.cyclops.evilcraft.Configs; @@ -18,19 +13,23 @@ import org.cyclops.evilcraft.core.recipe.custom.IngredientFluidStackAndTierRecipeComponent; import org.jetbrains.annotations.Nullable; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + @RegistryDescription -public class BloodInfuser extends VirtualizedRegistry> { +public class BloodInfuser extends + VirtualizedRegistry> { @Override - public boolean isEnabled() { - return Configs.isEnabled(BloodInfuserConfig.class); - } + public boolean isEnabled() { return Configs.isEnabled(BloodInfuserConfig.class); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:clay')).fluidInput(fluid('evilcraftblood') * 1000).tier(3).duration(100).xp(10000)"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).fluidInput(100000)"), - @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay') * 4).fluidInput(5000).tier(1)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:clay')).fluidInput(fluid('evilcraftblood') * 1000).tier(3).duration(100).xp(10000)"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).fluidInput(100000)"), + @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay') * 4).fluidInput(5000).tier(1)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -45,7 +44,8 @@ public void add(IRecipe recipe, boolean add) { + public void add(IRecipe recipe, + boolean add) { if (recipe == null) return; addScripted(recipe); if (add) org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().add(recipe); @@ -89,13 +89,14 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { return new SimpleObjectStream<>(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); + .setRemover(this::remove); } @Property(property = "input", valid = @Comp("1")) @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) - public static class RecipeBuilder extends AbstractRecipeBuilder> { + public static class RecipeBuilder extends + AbstractRecipeBuilder> { private static final Fluid bloodFluid = FluidRegistry.getFluid("evilcraftblood"); @@ -137,9 +138,7 @@ public RecipeBuilder fluidInput(int amount) { } @Override - public String getErrorMsg() { - return "Error adding EvilCraft Blood Infuser Recipe"; - } + public String getErrorMsg() { return "Error adding EvilCraft Blood Infuser Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -150,16 +149,18 @@ public void validate(GroovyLog.Msg msg) { msg.add(xp < 0, "xp must be a non negative integer, yet it was {}", xp); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IRecipe register() { if (!validate()) return null; - IRecipe recipe = - org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().registerRecipe( - new IngredientFluidStackAndTierRecipeComponent(input.get(0).toMcIngredient(), fluidInput.get(0), tier), - new IngredientRecipeComponent(output.get(0)), - new DurationXpRecipeProperties(duration, xp) - ); + IRecipe recipe = org.cyclops.evilcraft.block.BloodInfuser.getInstance() + .getRecipeRegistry() + .registerRecipe(new IngredientFluidStackAndTierRecipeComponent(input.get(0) + .toMcIngredient(), + fluidInput.get(0), + tier), + new IngredientRecipeComponent(output.get(0)), + new DurationXpRecipeProperties(duration, + xp)); ModSupport.EVILCRAFT.get().bloodInfuser.add(recipe, false); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EnvironmentalAccumulator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EnvironmentalAccumulator.java index 916926f9f..8400232be 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EnvironmentalAccumulator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EnvironmentalAccumulator.java @@ -1,12 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.evilcraft; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import java.util.Locale; + import net.minecraft.item.ItemStack; + import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.evilcraft.Configs; import org.cyclops.evilcraft.block.EnvironmentalAccumulatorConfig; @@ -15,36 +12,41 @@ import org.cyclops.evilcraft.core.weather.WeatherType; import org.jetbrains.annotations.Nullable; -import java.util.Locale; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; @RegistryDescription -public class EnvironmentalAccumulator extends VirtualizedRegistry> { +public class EnvironmentalAccumulator extends + VirtualizedRegistry> { @Override - public boolean isEnabled() { - return Configs.isEnabled(EnvironmentalAccumulatorConfig.class); - } + public boolean isEnabled() { return Configs.isEnabled(EnvironmentalAccumulatorConfig.class); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:clay') * 2).inputWeather(weather('clear')).outputWeather(weather('rain')).processingspeed(1).cooldowntime(1000).duration(10)"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).inputWeather(weather('rain')).outputWeather(weather('lightning')).speed(10).cooldown(1)"), - @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay') * 16).inputWeather(weather('lightning')).outputWeather(weather('lightning'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:clay') * 2).inputWeather(weather('clear')).outputWeather(weather('rain')).processingspeed(1).cooldowntime(1000).duration(10)"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).inputWeather(weather('rain')).outputWeather(weather('lightning')).speed(10).cooldown(1)"), + @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay') * 16).inputWeather(weather('lightning')).outputWeather(weather('lightning'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @Override public void onReload() { - removeScripted().forEach(org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes()::remove); - restoreFromBackup().forEach(org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes()::add); + removeScripted().forEach(org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry() + .allRecipes()::remove); + restoreFromBackup().forEach(org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry() + .allRecipes()::add); } public void add(IRecipe recipe) { this.add(recipe, true); } - public void add(IRecipe recipe, boolean add) { + public void add(IRecipe recipe, + boolean add) { if (recipe == null) return; addScripted(recipe); if (add) org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes().add(recipe); @@ -81,25 +83,29 @@ public boolean removeByOutput(ItemStack input) { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes().forEach(this::addBackup); + org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes().forEach( + this::addBackup); org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes().clear(); } @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry() + .allRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) - public static class RecipeBuilder extends AbstractRecipeBuilder> { + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) + public static class RecipeBuilder extends + AbstractRecipeBuilder> { - @Property(defaultValue = "EnvironmentalAccumulatorConfig.defaultProcessItemSpeed", valid = @Comp(value = "0", type = Comp.Type.GTE)) + @Property(defaultValue = "EnvironmentalAccumulatorConfig.defaultProcessItemSpeed", + valid = @Comp(value = "0", type = Comp.Type.GTE)) private double processingspeed = EnvironmentalAccumulatorConfig.defaultProcessItemSpeed; - @Property(defaultValue = "EnvironmentalAccumulatorConfig.defaultTickCooldown", valid = @Comp(value = "0", type = Comp.Type.GTE)) + @Property(defaultValue = "EnvironmentalAccumulatorConfig.defaultTickCooldown", + valid = @Comp(value = "0", type = Comp.Type.GTE)) private int cooldowntime = EnvironmentalAccumulatorConfig.defaultTickCooldown; - @Property(defaultValue = "EnvironmentalAccumulatorConfig.defaultProcessItemTickCount", valid = @Comp(value = "0", type = Comp.Type.GTE)) + @Property(defaultValue = "EnvironmentalAccumulatorConfig.defaultProcessItemTickCount", + valid = @Comp(value = "0", type = Comp.Type.GTE)) private int duration = EnvironmentalAccumulatorConfig.defaultProcessItemTickCount; @Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) private WeatherType inputWeather; @@ -161,9 +167,7 @@ public RecipeBuilder outputWeather(WeatherType outputWeather) { } @Override - public String getErrorMsg() { - return "Error adding EvilCraft Environmental Accumulator Recipe"; - } + public String getErrorMsg() { return "Error adding EvilCraft Environmental Accumulator Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -176,16 +180,19 @@ public void validate(GroovyLog.Msg msg) { msg.add(processingspeed < 0, "processingspeed must be a non negative integer, yet it was {}", processingspeed); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IRecipe register() { if (!validate()) return null; - IRecipe recipe = - org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().registerRecipe( - new EnvironmentalAccumulatorRecipeComponent(input.get(0).toMcIngredient(), inputWeather), - new EnvironmentalAccumulatorRecipeComponent(output.get(0), outputWeather), - new EnvironmentalAccumulatorRecipeProperties(duration, cooldowntime, processingspeed) - ); + IRecipe recipe = org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance() + .getRecipeRegistry() + .registerRecipe(new EnvironmentalAccumulatorRecipeComponent(input.get(0) + .toMcIngredient(), + inputWeather), + new EnvironmentalAccumulatorRecipeComponent(output.get(0), + outputWeather), + new EnvironmentalAccumulatorRecipeProperties(duration, + cooldowntime, + processingspeed)); ModSupport.EVILCRAFT.get().environmentalAccumulator.add(recipe, false); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EvilCraft.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EvilCraft.java index b1992cb66..b4dc91c3a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EvilCraft.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EvilCraft.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.evilcraft; +import java.util.Arrays; +import java.util.List; + +import org.cyclops.evilcraft.core.weather.WeatherType; + import com.cleanroommc.groovyscript.api.IObjectParser; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; -import org.cyclops.evilcraft.core.weather.WeatherType; - -import java.util.Arrays; -import java.util.List; public class EvilCraft extends GroovyPropertyContainer { @@ -16,11 +17,9 @@ public class EvilCraft extends GroovyPropertyContainer { @Override public void initialize(GroovyContainer container) { final List weatherTypes = Arrays.asList("any", "clear", "rain", "lightning"); - container.objectMapperBuilder("weather", WeatherType.class) - .parser(IObjectParser.wrapStringGetter(WeatherType::valueOf, true)) - .completerOfNames(() -> weatherTypes) // elements don't have names - .defaultValue(() -> WeatherType.ANY) - .docOfType("weather type") - .register(); + container.objectMapperBuilder("weather", WeatherType.class).parser(IObjectParser.wrapStringGetter(WeatherType::valueOf, + true)).completerOfNames( + () -> weatherTypes) // elements don't have names + .defaultValue(() -> WeatherType.ANY).docOfType("weather type").register(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CombinationCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CombinationCrafting.java index df76efd1e..65e1d3cc3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CombinationCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CombinationCrafting.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.extendedcrafting; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.NonNullList; + +import org.jetbrains.annotations.Nullable; + import com.blakebr0.extendedcrafting.config.ModConfig; import com.blakebr0.extendedcrafting.crafting.CombinationRecipe; import com.blakebr0.extendedcrafting.crafting.CombinationRecipeManager; @@ -12,16 +20,10 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.NonNullList; -import org.jetbrains.annotations.Nullable; - -import java.util.Collection; -@RegistryDescription( - admonition = @Admonition(value = "groovyscript.wiki.extendedcrafting.combination_crafting.note0", type = Admonition.Type.INFO, format = Admonition.Format.STANDARD) -) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.extendedcrafting.combination_crafting.note0", + type = Admonition.Type.INFO, + format = Admonition.Format.STANDARD)) public class CombinationCrafting extends VirtualizedRegistry { public CombinationCrafting() { @@ -42,12 +44,14 @@ public CombinationRecipe add(CombinationRecipe recipe) { return recipe; } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.combination_crafting.add0", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.combination_crafting.add0", + type = MethodDescription.Type.ADDITION) public CombinationRecipe add(ItemStack output, long cost, Ingredient input, NonNullList pedestals) { return add(output, cost, ModConfig.confCraftingCoreRFRate, input, pedestals); } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.combination_crafting.add1", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.combination_crafting.add1", + type = MethodDescription.Type.ADDITION) public CombinationRecipe add(ItemStack output, long cost, int perTick, Ingredient input, NonNullList pedestals) { return add(new CombinationRecipe(output, cost, perTick, input, pedestals)); } @@ -100,16 +104,13 @@ public void removeAll() { } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:pumpkin')).pedestals(item('minecraft:pumpkin') * 8).output(item('minecraft:diamond') * 2).cost(100).perTick(100)"), - @Example(".input(item('minecraft:pumpkin')).pedestals(item('minecraft:pumpkin'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:pumpkin')).output(item('minecraft:gold_ingot') * 2).cost(10000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:pumpkin')).pedestals(item('minecraft:pumpkin') * 8).output(item('minecraft:diamond') * 2).cost(100).perTick(100)"), + @Example(".input(item('minecraft:pumpkin')).pedestals(item('minecraft:pumpkin'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:pumpkin')).output(item('minecraft:gold_ingot') * 2).cost(10000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -141,8 +142,7 @@ public RecipeBuilder costPerTick(int costPerTick) { return perTick(costPerTick); } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public RecipeBuilder input(IIngredient ingredient) { this.input.add(ingredient.withAmount(1)); return this; @@ -173,9 +173,7 @@ public RecipeBuilder pedestals(IIngredient... pedestals) { } @Override - public String getErrorMsg() { - return "Error adding Extended Crafting Combination Crafting recipe"; - } + public String getErrorMsg() { return "Error adding Extended Crafting Combination Crafting recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -185,12 +183,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(perTick < 0, () -> "per tick must not be negative"); } - @Nullable - @Override - @RecipeBuilderRegistrationMethod + @Nullable @Override @RecipeBuilderRegistrationMethod public CombinationRecipe register() { if (!validate()) return null; - CombinationRecipe recipe = new CombinationRecipe(output.get(0), cost, perTick, input.get(0).toMcIngredient(), IngredientHelper.toIngredientNonNullList(pedestals)); + CombinationRecipe recipe = new CombinationRecipe(output.get(0), cost, perTick, input.get(0).toMcIngredient(), + IngredientHelper.toIngredientNonNullList(pedestals)); ModSupport.EXTENDED_CRAFTING.get().combinationCrafting.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CompressionCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CompressionCrafting.java index 32f94d3a9..9b0eb4635 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CompressionCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CompressionCrafting.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.extendedcrafting; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.blakebr0.extendedcrafting.config.ModConfig; import com.blakebr0.extendedcrafting.crafting.CompressorRecipe; import com.blakebr0.extendedcrafting.crafting.CompressorRecipeManager; @@ -13,8 +17,6 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class CompressionCrafting extends VirtualizedRegistry { @@ -37,14 +39,19 @@ public CompressorRecipe add(CompressorRecipe recipe) { return recipe; } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.compression_crafting.add0", type = MethodDescription.Type.ADDITION) - public CompressorRecipe add(ItemStack output, IIngredient input, int inputCount, IIngredient catalyst, boolean consumeCatalyst, int powerCost) { + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.compression_crafting.add0", + type = MethodDescription.Type.ADDITION) + public CompressorRecipe add(ItemStack output, IIngredient input, int inputCount, IIngredient catalyst, + boolean consumeCatalyst, int powerCost) { return add(output, input, inputCount, catalyst, consumeCatalyst, powerCost, ModConfig.confCompressorRFRate); } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.compression_crafting.add1", type = MethodDescription.Type.ADDITION) - public CompressorRecipe add(ItemStack output, IIngredient input, int inputCount, IIngredient catalyst, boolean consumeCatalyst, int powerCost, int powerRate) { - return add(new CompressorRecipe(output, input.toMcIngredient(), inputCount, catalyst.toMcIngredient(), consumeCatalyst, powerCost, powerRate)); + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.compression_crafting.add1", + type = MethodDescription.Type.ADDITION) + public CompressorRecipe add(ItemStack output, IIngredient input, int inputCount, IIngredient catalyst, + boolean consumeCatalyst, int powerCost, int powerRate) { + return add(new CompressorRecipe(output, input.toMcIngredient(), inputCount, catalyst.toMcIngredient(), consumeCatalyst, + powerCost, powerRate)); } @MethodDescription(example = @Example("item('extendedcrafting:singularity:6')")) @@ -99,10 +106,8 @@ public void removeAll() { CompressorRecipeManager.getInstance().getRecipes().clear(); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).inputCount(100).output(item('minecraft:gold_ingot') * 7).catalyst(item('minecraft:diamond')).consumeCatalyst(true).powerCost(10000).powerRate(1000)"), - @Example(".input(item('minecraft:clay') * 10).output(item('minecraft:diamond') * 2).powerCost(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).inputCount(100).output(item('minecraft:gold_ingot') * 7).catalyst(item('minecraft:diamond')).consumeCatalyst(true).powerCost(10000).powerRate(1000)"), + @Example(".input(item('minecraft:clay') * 10).output(item('minecraft:diamond') * 2).powerCost(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -113,7 +118,8 @@ public static class RecipeBuilder extends AbstractRecipeBuilder 1) { @@ -164,9 +169,7 @@ public RecipeBuilder powerRate(int powerRate) { } @Override - public String getErrorMsg() { - return "Error adding Extended Crafting Compression Crafting recipe"; - } + public String getErrorMsg() { return "Error adding Extended Crafting Compression Crafting recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -178,12 +181,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(powerRate < 0, "power rate must not be negative"); } - @Nullable - @Override - @RecipeBuilderRegistrationMethod + @Nullable @Override @RecipeBuilderRegistrationMethod public CompressorRecipe register() { if (!validate()) return null; - CompressorRecipe recipe = new CompressorRecipe(output.get(0), input.get(0).toMcIngredient(), inputCount, catalyst.toMcIngredient(), consumeCatalyst, powerCost, powerRate); + CompressorRecipe recipe = new CompressorRecipe(output.get(0), input.get(0).toMcIngredient(), inputCount, catalyst + .toMcIngredient(), + consumeCatalyst, powerCost, powerRate); ModSupport.EXTENDED_CRAFTING.get().compressionCrafting.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderCrafting.java index 072974410..a253fcd7a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderCrafting.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.extendedcrafting; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; + import com.blakebr0.extendedcrafting.config.ModConfig; import com.blakebr0.extendedcrafting.crafting.endercrafter.EnderCrafterRecipeManager; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,26 +14,18 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; - -import java.util.List; @RegistryDescription public class EnderCrafting extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".output(item('minecraft:stone')).matrix('BXX', 'X B').key('B', item('minecraft:stone')).key('X', item('minecraft:gold_ingot')).time(1).mirrored()"), - @Example(".output(item('minecraft:diamond') * 32).matrix([[item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')],[item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')],[item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')]]).time(1)") - }) + @RecipeBuilderDescription(example = {@Example(".output(item('minecraft:stone')).matrix('BXX', 'X B').key('B', item('minecraft:stone')).key('X', item('minecraft:gold_ingot')).time(1).mirrored()"), + @Example(".output(item('minecraft:diamond') * 32).matrix([[item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')],[item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')],[item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')]]).time(1)")}) public EnderRecipeBuilder.Shaped shapedBuilder() { return new EnderRecipeBuilder.Shaped(); } - @RecipeBuilderDescription(example = { - @Example(".output(item('minecraft:clay') * 8).input(item('minecraft:stone'), item('minecraft:stone'), item('minecraft:stone'))"), - @Example(".output(item('minecraft:clay') * 32).input(item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond')).time(1)") - }) + @RecipeBuilderDescription(example = {@Example(".output(item('minecraft:clay') * 8).input(item('minecraft:stone'), item('minecraft:stone'), item('minecraft:stone'))"), + @Example(".output(item('minecraft:clay') * 32).input(item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond')).time(1)")}) public EnderRecipeBuilder.Shapeless shapelessBuilder() { return new EnderRecipeBuilder.Shapeless(); } @@ -39,32 +36,28 @@ public void onReload() { EnderCrafterRecipeManager.getInstance().getRecipes().addAll(restoreFromBackup()); } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.ender_crafting.addShaped0", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.ender_crafting.addShaped0", + type = MethodDescription.Type.ADDITION) public IRecipe addShaped(ItemStack output, List> input) { return addShaped(ModConfig.confEnderTimeRequired, output, input); } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.ender_crafting.addShaped1", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.ender_crafting.addShaped1", + type = MethodDescription.Type.ADDITION) public IRecipe addShaped(int time, ItemStack output, List> input) { - return shapedBuilder() - .time(time) - .matrix(input) - .output(output) - .register(); + return shapedBuilder().time(time).matrix(input).output(output).register(); } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.ender_crafting.addShapeless0", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.ender_crafting.addShapeless0", + type = MethodDescription.Type.ADDITION) public IRecipe addShapeless(ItemStack output, List input) { return addShapeless(ModConfig.confEnderTimeRequired, output, input); } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.ender_crafting.addShapeless1", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.ender_crafting.addShapeless1", + type = MethodDescription.Type.ADDITION) public IRecipe addShapeless(int time, ItemStack output, List input) { - return shapelessBuilder() - .time(time) - .input(input) - .output(output) - .register(); + return shapelessBuilder().time(time).input(input).output(output).register(); } public IRecipe add(IRecipe recipe) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderRecipeBuilder.java index 7e3930c09..87eb490ab 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderRecipeBuilder.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.extendedcrafting; +import net.minecraft.item.crafting.IRecipe; + import com.blakebr0.extendedcrafting.config.ModConfig; import com.blakebr0.extendedcrafting.crafting.table.TableRecipeBase; import com.cleanroommc.groovyscript.api.GroovyLog; @@ -10,7 +12,6 @@ import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.AbstractCraftingRecipeBuilder; -import net.minecraft.item.crafting.IRecipe; public interface EnderRecipeBuilder { @@ -37,12 +38,9 @@ public Shaped() { } @Override - public String getRecipeNamePrefix() { - return "groovyscript_ender_shaped_"; - } + public String getRecipeNamePrefix() { return "groovyscript_ender_shaped_"; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public Shaped time(int time) { this.time = time; return this; @@ -50,24 +48,40 @@ public Shaped time(int time) { public boolean validate() { GroovyLog.Msg msg = GroovyLog.msg("Error adding shaped Ender Crafting recipe").error(); - msg.add((keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), () -> "No matrix was defined"); - msg.add(keyBasedMatrix != null && ingredientMatrix != null, () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!"); + msg.add((keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), + () -> "No matrix was defined"); + msg.add(keyBasedMatrix != null && ingredientMatrix != null, + () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!"); msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); msg.add(time < 0, "time must be a nonnegative integer, yet it was {}", time); return !msg.postIfNotEmpty(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IRecipe register() { if (!validate()) return null; GroovyLog.Msg msg = GroovyLog.msg("Error adding shaped Ender Crafting recipe").error(); ShapedTableRecipe recipe = null; if (keyBasedMatrix != null) { - recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> ShapedTableRecipe.make(1, output, ingredients, width1, height1, mirrored, recipeFunction, recipeAction))); + recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> ShapedTableRecipe + .make(1, + output, + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction))); } else if (ingredientMatrix != null) { - recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> ShapedTableRecipe.make(1, output.copy(), ingredients, width1, height1, mirrored, recipeFunction, recipeAction))); + recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> ShapedTableRecipe.make(1, output + .copy(), + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction))); } if (recipe == null) { msg.add("The recipe could not be parsed!"); @@ -91,12 +105,9 @@ public Shapeless() { } @Override - public String getRecipeNamePrefix() { - return "groovyscript_ender_shapeless_"; - } + public String getRecipeNamePrefix() { return "groovyscript_ender_shapeless_"; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public Shapeless time(int time) { this.time = time; return this; @@ -106,13 +117,13 @@ public boolean validate() { GroovyLog.Msg msg = GroovyLog.msg("Error adding shapeless Ender Crafting recipe").error(); msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); msg.add(ingredients.isEmpty(), () -> "inputs must not be empty"); - msg.add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + ingredients.size()); + msg.add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + + ingredients.size()); msg.add(time < 0, "time must be a nonnegative integer, yet it was {}", time); return !msg.postIfNotEmpty(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IRecipe register() { if (!validate()) return null; ShapelessTableRecipe recipe = ShapelessTableRecipe.make(1, output.copy(), ingredients, recipeFunction, recipeAction); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/ShapedTableRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/ShapedTableRecipe.java index 7b8f20efe..cad6269fa 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/ShapedTableRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/ShapedTableRecipe.java @@ -1,29 +1,36 @@ package com.cleanroommc.groovyscript.compat.mods.extendedcrafting; -import com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; -import groovy.lang.Closure; +import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.world.World; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; +import com.blakebr0.extendedcrafting.crafting.table.TableRecipeShaped; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; + +import groovy.lang.Closure; public class ShapedTableRecipe extends TableRecipeShaped { private final ShapedCraftingRecipe groovyRecipe; - public static ShapedTableRecipe make(int tier, ItemStack output, List input, int width, int height, boolean mirrored, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { - ShapedCraftingRecipe recipe = new ShapedCraftingRecipe(output, input, width, height, mirrored, recipeFunction, recipeAction); + public static ShapedTableRecipe make(int tier, ItemStack output, List input, int width, int height, + boolean mirrored, @Nullable Closure recipeFunction, + @Nullable Closure recipeAction) { + ShapedCraftingRecipe recipe = new ShapedCraftingRecipe(output, input, width, height, mirrored, recipeFunction, + recipeAction); return new ShapedTableRecipe(tier, recipe); } public ShapedTableRecipe(int tier, ShapedCraftingRecipe groovyRecipe) { - super(tier, groovyRecipe.getRecipeOutput(), groovyRecipe.getRecipeWidth(), groovyRecipe.getRecipeHeight(), groovyRecipe.getIngredients()); + super(tier, groovyRecipe.getRecipeOutput(), groovyRecipe.getRecipeWidth(), groovyRecipe.getRecipeHeight(), groovyRecipe + .getIngredients()); this.groovyRecipe = groovyRecipe; setMirrored(this.groovyRecipe.isMirrored()); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/ShapelessTableRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/ShapelessTableRecipe.java index 6c3a906fa..639181579 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/ShapelessTableRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/ShapelessTableRecipe.java @@ -1,23 +1,27 @@ package com.cleanroommc.groovyscript.compat.mods.extendedcrafting; -import com.blakebr0.extendedcrafting.crafting.table.TableRecipeShapeless; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; -import groovy.lang.Closure; +import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.world.World; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; +import com.blakebr0.extendedcrafting.crafting.table.TableRecipeShapeless; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; + +import groovy.lang.Closure; public class ShapelessTableRecipe extends TableRecipeShapeless { private final ShapelessCraftingRecipe groovyRecipe; - public static ShapelessTableRecipe make(int tier, ItemStack output, List input, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { + public static ShapelessTableRecipe make(int tier, ItemStack output, List input, + @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { ShapelessCraftingRecipe recipe = new ShapelessCraftingRecipe(output, input, recipeFunction, recipeAction); return new ShapelessTableRecipe(tier, recipe); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableCrafting.java index 4ce63b432..cc464ddf3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableCrafting.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.extendedcrafting; +import java.util.List; + +import net.minecraft.item.ItemStack; + import com.blakebr0.extendedcrafting.crafting.table.ITieredRecipe; import com.blakebr0.extendedcrafting.crafting.table.TableRecipeManager; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,20 +13,15 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; - -import java.util.List; @RegistryDescription public class TableCrafting extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".output(item('minecraft:stone') * 64).matrix('DLLLLLDDD', ' DNIGIND', 'DDDNIGIND', ' DLLLLLD').key('D', item('minecraft:diamond')).key('L', item('minecraft:redstone')).key('N', item('minecraft:stone')).key('I', item('minecraft:iron_ingot')).key('G', item('minecraft:gold_ingot')).tierUltimate()"), - @Example(".tierAdvanced().output(item('minecraft:stone') * 8).matrix('BXX').mirrored().key('B', item('minecraft:stone')).key('X', item('minecraft:gold_ingot'))"), - @Example(".tierAny().output(item('minecraft:diamond')).matrix('BXXXBX').mirrored().key('B', item('minecraft:stone')).key('X', item('minecraft:gold_ingot'))"), - @Example(".matrix([[item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')]]).output(item('minecraft:gold_ingot') * 64).tier(4)"), - @Example(".matrix([[item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')]]).output(item('minecraft:gold_ingot') * 64)") - }) + @RecipeBuilderDescription(example = {@Example(".output(item('minecraft:stone') * 64).matrix('DLLLLLDDD', ' DNIGIND', 'DDDNIGIND', ' DLLLLLD').key('D', item('minecraft:diamond')).key('L', item('minecraft:redstone')).key('N', item('minecraft:stone')).key('I', item('minecraft:iron_ingot')).key('G', item('minecraft:gold_ingot')).tierUltimate()"), + @Example(".tierAdvanced().output(item('minecraft:stone') * 8).matrix('BXX').mirrored().key('B', item('minecraft:stone')).key('X', item('minecraft:gold_ingot'))"), + @Example(".tierAny().output(item('minecraft:diamond')).matrix('BXXXBX').mirrored().key('B', item('minecraft:stone')).key('X', item('minecraft:gold_ingot'))"), + @Example(".matrix([[item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')]]).output(item('minecraft:gold_ingot') * 64).tier(4)"), + @Example(".matrix([[item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')], [item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot')]]).output(item('minecraft:gold_ingot') * 64)")}) public TableRecipeBuilder.Shaped shapedBuilder() { return new TableRecipeBuilder.Shaped(); } @@ -38,32 +37,28 @@ public void onReload() { TableRecipeManager.getInstance().getRecipes().addAll(restoreFromBackup()); } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.table_crafting.addShaped0", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.table_crafting.addShaped0", + type = MethodDescription.Type.ADDITION) public ITieredRecipe addShaped(ItemStack output, List> input) { return addShaped(0, output, input); } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.table_crafting.addShaped1", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.table_crafting.addShaped1", + type = MethodDescription.Type.ADDITION) public ITieredRecipe addShaped(int tier, ItemStack output, List> input) { - return shapedBuilder() - .tier(tier) - .matrix(input) - .output(output) - .register(); + return shapedBuilder().tier(tier).matrix(input).output(output).register(); } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.table_crafting.addShapeless0", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.table_crafting.addShapeless0", + type = MethodDescription.Type.ADDITION) public ITieredRecipe addShapeless(ItemStack output, List input) { return addShapeless(0, output, input); } - @MethodDescription(description = "groovyscript.wiki.extendedcrafting.table_crafting.addShapeless1", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.extendedcrafting.table_crafting.addShapeless1", + type = MethodDescription.Type.ADDITION) public ITieredRecipe addShapeless(int tier, ItemStack output, List input) { - return shapelessBuilder() - .tier(tier) - .input(input) - .output(output) - .register(); + return shapelessBuilder().tier(tier).input(input).output(output).register(); } public ITieredRecipe add(ITieredRecipe recipe) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableRecipeBuilder.java index 1e8136dad..242d011bc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableRecipeBuilder.java @@ -41,7 +41,8 @@ default TableRecipeBuilder tierUltimate() { return tier(4); } - @Property(property = "ingredientMatrix", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "81", type = Comp.Type.LTE)}) + @Property(property = "ingredientMatrix", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "81", type = Comp.Type.LTE)}) class Shaped extends AbstractCraftingRecipeBuilder.AbstractShaped implements TableRecipeBuilder { // 0 = any table it fits in, 1-4 specifically that tier of table @@ -53,12 +54,9 @@ public Shaped() { } @Override - public String getRecipeNamePrefix() { - return "groovyscript_table_shaped_"; - } + public String getRecipeNamePrefix() { return "groovyscript_table_shaped_"; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public TableRecipeBuilder.Shaped tier(int tier) { this.tier = tier; int size = this.tier == 0 ? 9 : this.tier * 2 + 1; @@ -67,19 +65,35 @@ public TableRecipeBuilder.Shaped tier(int tier) { return this; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public ITieredRecipe register() { - GroovyLog.Msg msg = GroovyLog.msg("Error adding shaped Extended Crafting Table recipe").error() - .add((keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), () -> "No matrix was defined") - .add(keyBasedMatrix != null && ingredientMatrix != null, () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!"); + GroovyLog.Msg msg = GroovyLog.msg("Error adding shaped Extended Crafting Table recipe").error().add( + (keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), + () -> "No matrix was defined") + .add(keyBasedMatrix != null && ingredientMatrix != null, + () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!"); if (msg.postIfNotEmpty()) return null; msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); TableRecipeShaped recipe = null; if (keyBasedMatrix != null) { - recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> ShapedTableRecipe.make(tier, output, ingredients, width1, height1, mirrored, recipeFunction, recipeAction))); + recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> ShapedTableRecipe + .make(tier, + output, + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction))); } else if (ingredientMatrix != null) { - recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> ShapedTableRecipe.make(tier, output.copy(), ingredients, width1, height1, mirrored, recipeFunction, recipeAction))); + recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> ShapedTableRecipe.make(tier, + output.copy(), + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction))); } if (msg.postIfNotEmpty()) return null; if (recipe != null) { @@ -89,7 +103,8 @@ public ITieredRecipe register() { } } - @Property(property = "ingredients", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "81", type = Comp.Type.LTE)}) + @Property(property = "ingredients", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "81", type = Comp.Type.LTE)}) class Shapeless extends AbstractCraftingRecipeBuilder.AbstractShapeless implements TableRecipeBuilder { // 0 = any table it fits in, 1-4 specifically that tier of table @@ -101,12 +116,9 @@ public Shapeless() { } @Override - public String getRecipeNamePrefix() { - return "groovyscript_table_shapeless_"; - } + public String getRecipeNamePrefix() { return "groovyscript_table_shapeless_"; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public TableRecipeBuilder.Shapeless tier(int tier) { this.tier = tier; int size = this.tier == 0 ? 9 : this.tier * 2 + 1; @@ -120,15 +132,16 @@ public boolean validate() { msg.add(tier < 0 || tier > 4, () -> "tier must be between 0 and 4, was instead " + tier); msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); msg.add(ingredients.isEmpty(), () -> "inputs must not be empty"); - msg.add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + ingredients.size()); + msg.add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + + ingredients.size()); return !msg.postIfNotEmpty(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public ITieredRecipe register() { if (!validate()) return null; - ShapelessTableRecipe recipe = ShapelessTableRecipe.make(tier, output.copy(), ingredients, recipeFunction, recipeAction); + ShapelessTableRecipe recipe = ShapelessTableRecipe.make(tier, output.copy(), ingredients, recipeFunction, + recipeAction); ModSupport.EXTENDED_CRAFTING.get().tableCrafting.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Crusher.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Crusher.java index 9ac0a53db..ddcebfc78 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Crusher.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Crusher.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.extrautils2; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -11,10 +15,6 @@ import com.rwtema.extrautils2.api.machine.IMachineRecipe; import com.rwtema.extrautils2.api.machine.XUMachineCrusher; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - @RegistryDescription public class Crusher extends VirtualizedRegistry { @@ -44,7 +44,8 @@ public boolean remove(IMachineRecipe recipe) { public boolean removeByInput(IIngredient input) { List agony = new ArrayList<>(); for (IMachineRecipe recipe : XUMachineCrusher.INSTANCE.recipes_registry) { - if (recipe.getJEIInputItemExamples().stream().flatMap(x -> x.getKey().get(XUMachineCrusher.INPUT).stream()).anyMatch(input)) { + if (recipe.getJEIInputItemExamples().stream().flatMap(x -> x.getKey().get(XUMachineCrusher.INPUT).stream()).anyMatch( + input)) { agony.add(recipe); } } @@ -77,10 +78,8 @@ public void removeAll() { } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).energy(1000).time(5)"), - @Example(".input(item('minecraft:blaze_rod')).output(item('minecraft:gold_ingot') * 3).output(item('minecraft:gold_ingot')).chance(0.2f).energy(1000).time(5)"), - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).energy(1000).time(5)"), + @Example(".input(item('minecraft:blaze_rod')).output(item('minecraft:gold_ingot') * 3).output(item('minecraft:gold_ingot')).chance(0.2f).energy(1000).time(5)"),}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -115,9 +114,7 @@ public RecipeBuilder chance(float chance) { } @Override - public String getErrorMsg() { - return "Error adding Extra Utilities 2 Crusher recipe"; - } + public String getErrorMsg() { return "Error adding Extra Utilities 2 Crusher recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -128,12 +125,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(chance < 0 || chance > 1, "chance must be between 0 and 1, yet it was {}", chance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IMachineRecipe register() { if (!validate()) return null; com.rwtema.extrautils2.api.machine.RecipeBuilder builder = com.rwtema.extrautils2.api.machine.RecipeBuilder.newbuilder(XUMachineCrusher.INSTANCE); - builder.setItemInput(XUMachineCrusher.INPUT, Arrays.asList(input.get(0).getMatchingStacks()), input.get(0).getAmount()); + builder.setItemInput(XUMachineCrusher.INPUT, Arrays.asList(input.get(0).getMatchingStacks()), input.get(0) + .getAmount()); builder.setItemOutput(XUMachineCrusher.OUTPUT, output.get(0)); if (!IngredientHelper.isEmpty(output.getOrEmpty(1))) { builder.setItemOutput(XUMachineCrusher.OUTPUT_SECONDARY, output.get(1)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Enchanter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Enchanter.java index 0d4833579..bb2a83480 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Enchanter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Enchanter.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.extrautils2; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,10 +14,6 @@ import com.rwtema.extrautils2.api.machine.IMachineRecipe; import com.rwtema.extrautils2.api.machine.XUMachineEnchanter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - @RegistryDescription public class Enchanter extends VirtualizedRegistry { @@ -43,7 +43,8 @@ public boolean remove(IMachineRecipe recipe) { public boolean removeByInput(IIngredient input) { List agony = new ArrayList<>(); for (IMachineRecipe recipe : XUMachineEnchanter.INSTANCE.recipes_registry) { - if (recipe.getJEIInputItemExamples().stream().flatMap(x -> x.getKey().get(XUMachineEnchanter.INPUT).stream()).anyMatch(input)) { + if (recipe.getJEIInputItemExamples().stream().flatMap(x -> x.getKey().get(XUMachineEnchanter.INPUT).stream()) + .anyMatch(input)) { agony.add(recipe); } } @@ -103,9 +104,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Extra Utilities 2 Enchanter recipe"; - } + public String getErrorMsg() { return "Error adding Extra Utilities 2 Enchanter recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -115,15 +114,16 @@ public void validate(GroovyLog.Msg msg) { msg.add(time <= 0, () -> "time must not be less than or equal to 0"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IMachineRecipe register() { if (!validate()) return null; com.rwtema.extrautils2.api.machine.RecipeBuilder builder = com.rwtema.extrautils2.api.machine.RecipeBuilder.newbuilder(XUMachineEnchanter.INSTANCE); - builder.setItemInput(XUMachineEnchanter.INPUT, Arrays.asList(input.get(0).getMatchingStacks()), input.get(0).getAmount()); + builder.setItemInput(XUMachineEnchanter.INPUT, Arrays.asList(input.get(0).getMatchingStacks()), input.get(0) + .getAmount()); builder.setItemOutput(XUMachineEnchanter.OUTPUT, output.get(0)); if (input.get(1).getAmount() > 0) { - builder.setItemInput(XUMachineEnchanter.INPUT_LAPIS, Arrays.asList(input.get(1).getMatchingStacks()), input.get(1).getAmount()); + builder.setItemInput(XUMachineEnchanter.INPUT_LAPIS, Arrays.asList(input.get(1).getMatchingStacks()), input.get(1) + .getAmount()); } builder.setEnergy(energy); builder.setProcessingTime(time); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Furnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Furnace.java index a2263deeb..74a6a65f7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Furnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Furnace.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.extrautils2; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,16 +14,10 @@ import com.rwtema.extrautils2.api.machine.IMachineRecipe; import com.rwtema.extrautils2.api.machine.XUMachineFurnace; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -@RegistryDescription( - admonition = @Admonition(type = Admonition.Type.WARNING, - format = Admonition.Format.STANDARD, - hasTitle = true, - value = "groovyscript.wiki.extrautils2.furnace.removeWarning") -) +@RegistryDescription(admonition = @Admonition(type = Admonition.Type.WARNING, + format = Admonition.Format.STANDARD, + hasTitle = true, + value = "groovyscript.wiki.extrautils2.furnace.removeWarning")) public class Furnace extends VirtualizedRegistry { @Override @@ -48,7 +46,8 @@ public boolean remove(IMachineRecipe recipe) { public boolean removeByInput(IIngredient input) { List agony = new ArrayList<>(); for (IMachineRecipe recipe : XUMachineFurnace.INSTANCE.recipes_registry) { - if (recipe.getJEIInputItemExamples().stream().flatMap(x -> x.getKey().get(XUMachineFurnace.INPUT).stream()).anyMatch(input)) { + if (recipe.getJEIInputItemExamples().stream().flatMap(x -> x.getKey().get(XUMachineFurnace.INPUT).stream()).anyMatch( + input)) { agony.add(recipe); } } @@ -85,8 +84,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) @@ -107,9 +105,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Extra Utilities 2 Furnace recipe"; - } + public String getErrorMsg() { return "Error adding Extra Utilities 2 Furnace recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -119,12 +115,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(time <= 0, () -> "time must not be less than or equal to 0"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IMachineRecipe register() { if (!validate()) return null; com.rwtema.extrautils2.api.machine.RecipeBuilder builder = com.rwtema.extrautils2.api.machine.RecipeBuilder.newbuilder(XUMachineFurnace.INSTANCE); - builder.setItemInput(XUMachineFurnace.INPUT, Arrays.asList(input.get(0).getMatchingStacks()), input.get(0).getAmount()); + builder.setItemInput(XUMachineFurnace.INPUT, Arrays.asList(input.get(0).getMatchingStacks()), input.get(0) + .getAmount()); builder.setItemOutput(XUMachineFurnace.OUTPUT, output.get(0)); builder.setEnergy(energy); builder.setProcessingTime(time); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Generator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Generator.java index 7b37d0788..95fbb28c5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Generator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Generator.java @@ -1,5 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.extrautils2; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -11,25 +22,14 @@ import com.rwtema.extrautils2.api.machine.Machine; import com.rwtema.extrautils2.api.machine.MachineRegistry; import com.rwtema.extrautils2.api.machine.XUMachineGenerators; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; @RegistryDescription public class Generator extends VirtualizedRegistry> { - @RecipeBuilderDescription(example = { - @Example(".generator('extrautils2:generator_pink').input(item('minecraft:clay')).energy(1000).energyPerTick(100)"), - @Example(".generator('extrautils2:generator_slime').input(item('minecraft:clay') * 3).input(item('minecraft:gold_ingot')).energy(1000000).energyPerTick(100)"), - @Example(".generator('extrautils2:generator_redstone').input(item('minecraft:clay') * 3).fluidInput(fluid('water') * 300).energy(1000).energyPerTick(100)"), - @Example(".generator('extrautils2:generator_lava').fluidInput(fluid('water') * 300).energy(100).energyPerTick(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".generator('extrautils2:generator_pink').input(item('minecraft:clay')).energy(1000).energyPerTick(100)"), + @Example(".generator('extrautils2:generator_slime').input(item('minecraft:clay') * 3).input(item('minecraft:gold_ingot')).energy(1000000).energyPerTick(100)"), + @Example(".generator('extrautils2:generator_redstone').input(item('minecraft:clay') * 3).fluidInput(fluid('water') * 300).energy(1000).energyPerTick(100)"), + @Example(".generator('extrautils2:generator_lava').fluidInput(fluid('water') * 300).energy(100).energyPerTick(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -86,7 +86,8 @@ public boolean remove(ResourceLocation name, IMachineRecipe recipe) { public boolean remove(Machine machine, ItemStack input) { List agony = new ArrayList<>(); for (IMachineRecipe recipe : machine.recipes_registry) { - if (recipe.getJEIInputItemExamples().stream().flatMap(x -> x.getKey().get(XUMachineGenerators.INPUT_ITEM).stream()).anyMatch(input::isItemEqual)) { + if (recipe.getJEIInputItemExamples().stream().flatMap(x -> x.getKey().get(XUMachineGenerators.INPUT_ITEM).stream()) + .anyMatch(input::isItemEqual)) { agony.add(recipe); } } @@ -97,7 +98,8 @@ public boolean remove(Machine machine, ItemStack input) { return !agony.isEmpty(); } - @MethodDescription(description = "groovyscript.wiki.extrautils2.generator.remove0", example = @Example("'extrautils2:generator_culinary', item('minecraft:apple')")) + @MethodDescription(description = "groovyscript.wiki.extrautils2.generator.remove0", + example = @Example("'extrautils2:generator_culinary', item('minecraft:apple')")) public boolean remove(String name, ItemStack input) { Machine machine = MachineRegistry.getMachine(name); if (machine == null) { @@ -116,7 +118,8 @@ public boolean remove(ResourceLocation name, ItemStack input) { public boolean remove(Machine machine, FluidStack input) { List agony = new ArrayList<>(); for (IMachineRecipe recipe : machine.recipes_registry) { - if (recipe.getJEIInputItemExamples().stream().flatMap(x -> x.getValue().get(XUMachineGenerators.INPUT_FLUID).stream()).anyMatch(input::isFluidEqual)) { + if (recipe.getJEIInputItemExamples().stream().flatMap(x -> x.getValue().get(XUMachineGenerators.INPUT_FLUID).stream()) + .anyMatch(input::isFluidEqual)) { agony.add(recipe); } } @@ -127,7 +130,8 @@ public boolean remove(Machine machine, FluidStack input) { return !agony.isEmpty(); } - @MethodDescription(description = "groovyscript.wiki.extrautils2.generator.remove1", example = @Example("'extrautils2:generator_lava', fluid('lava')")) + @MethodDescription(description = "groovyscript.wiki.extrautils2.generator.remove1", + example = @Example("'extrautils2:generator_lava', fluid('lava')")) public boolean remove(String name, FluidStack input) { Machine machine = MachineRegistry.getMachine(name); if (machine == null) { @@ -169,7 +173,8 @@ public boolean removeByGenerator(Machine machine) { return !agony.isEmpty(); } - @MethodDescription(description = "groovyscript.wiki.extrautils2.generator.removeByGenerator", example = @Example("'extrautils2:generator_death'")) + @MethodDescription(description = "groovyscript.wiki.extrautils2.generator.removeByGenerator", + example = @Example("'extrautils2:generator_death'")) public boolean removeByGenerator(String name) { Machine machine = MachineRegistry.getMachine(name); if (machine == null) { @@ -195,22 +200,13 @@ public void removeAll() { public enum Generators { - FURNACE("extrautils2:generator"), - SURVIVALIST("extrautils2:generator_survival"), - CULINARY("extrautils2:generator_culinary"), - POTION("extrautils2:generator_potion"), - TNT("extrautils2:generator_tnt"), - LAVA("extrautils2:generator_lava", 0, true), - PINK("extrautils2:generator_pink"), - NETHERSTAR("extrautils2:generator_netherstar"), - ENDER("extrautils2:generator_ender"), - REDSTONE("extrautils2:generator_redstone", 1, true), - OVERCLOCK("extrautils2:generator_overclock"), - DRAGON("extrautils2:generator_dragonsbreath"), - ICE("extrautils2:generator_ice"), - DEATH("extrautils2:generator_death"), - ENCHANT("extrautils2:generator_enchant"), - SLIME("extrautils2:generator_slime", 2); + FURNACE("extrautils2:generator"), SURVIVALIST("extrautils2:generator_survival"), + CULINARY("extrautils2:generator_culinary"), POTION("extrautils2:generator_potion"), TNT("extrautils2:generator_tnt"), + LAVA("extrautils2:generator_lava", 0, true), PINK("extrautils2:generator_pink"), + NETHERSTAR("extrautils2:generator_netherstar"), ENDER("extrautils2:generator_ender"), + REDSTONE("extrautils2:generator_redstone", 1, true), OVERCLOCK("extrautils2:generator_overclock"), + DRAGON("extrautils2:generator_dragonsbreath"), ICE("extrautils2:generator_ice"), DEATH("extrautils2:generator_death"), + ENCHANT("extrautils2:generator_enchant"), SLIME("extrautils2:generator_slime", 2); private final String location; private final int itemSlots; @@ -248,7 +244,8 @@ public String toString() { } @Property(property = "input", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "2", type = Comp.Type.LTE)}) - @Property(property = "fluidInput", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) + @Property(property = "fluidInput", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) @@ -287,9 +284,7 @@ public RecipeBuilder energyPerTick(int energyPerTick) { } @Override - public String getErrorMsg() { - return "Error adding Extra Utilities 2 Generator recipe"; - } + public String getErrorMsg() { return "Error adding Extra Utilities 2 Generator recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -307,17 +302,22 @@ public void validate(GroovyLog.Msg msg) { msg.add(energyPerTick <= 0, () -> "energyPerTick must not be less than or equal to 0"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IMachineRecipe register() { if (!validate()) return null; com.rwtema.extrautils2.api.machine.RecipeBuilder builder = com.rwtema.extrautils2.api.machine.RecipeBuilder.newbuilder(generator); builder.setRFRate(energy, energyPerTick); if (!input.isEmpty()) { - builder.setItemInput(XUMachineGenerators.INPUT_ITEM, Arrays.stream(input.get(0).getMatchingStacks()).collect(Collectors.toList()), input.get(0).getAmount()); + builder.setItemInput(XUMachineGenerators.INPUT_ITEM, Arrays.stream(input.get(0).getMatchingStacks()).collect( + Collectors.toList()), + input.get(0).getAmount()); if (input.size() == 2) { - builder.setItemInput(MachineInitAccessor.getSLOT_SLIME_SECONDARY(), Arrays.stream(input.get(1).getMatchingStacks()).collect(Collectors.toList()), input.get(1).getAmount()); + builder.setItemInput(MachineInitAccessor.getSLOT_SLIME_SECONDARY(), Arrays.stream(input.get(1) + .getMatchingStacks()) + .collect(Collectors.toList()), input + .get(1) + .getAmount()); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/GridPowerPassiveGenerator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/GridPowerPassiveGenerator.java index be143938d..dcd3d0efe 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/GridPowerPassiveGenerator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/GridPowerPassiveGenerator.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.extrautils2; +import java.util.Arrays; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -9,19 +17,15 @@ import com.rwtema.extrautils2.blocks.BlockPassiveGenerator; import com.rwtema.extrautils2.power.IWorldPowerMultiplier; import com.rwtema.extrautils2.tile.TilePassiveGenerator; + import groovy.lang.Closure; import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.Arrays; -import java.util.Map; @RegistryDescription -public class GridPowerPassiveGenerator extends VirtualizedRegistry> { +public class GridPowerPassiveGenerator extends + VirtualizedRegistry> { public final Map basePowerMap = new Object2FloatOpenHashMap<>(); public final Map> powerLevelMap = new Object2ObjectOpenHashMap<>(); @@ -57,12 +61,13 @@ public void setPowerMultiplier(BlockPassiveGenerator.GeneratorType generator, IW ((GeneratorTypeAccessor) generator).setPowerMultiplier(worldPowerMultiplier); } - @MethodDescription(example = @Example(value = "resource('generators:wind'), IWorldPowerMultiplier.CONSTANT", imports = "com.rwtema.extrautils2.power.IWorldPowerMultiplier"), type = MethodDescription.Type.VALUE) + @MethodDescription(example = @Example(value = "resource('generators:wind'), IWorldPowerMultiplier.CONSTANT", + imports = "com.rwtema.extrautils2.power.IWorldPowerMultiplier"), + type = MethodDescription.Type.VALUE) public void setPowerMultiplier(ResourceLocation generator, IWorldPowerMultiplier worldPowerMultiplier) { - Arrays.stream(BlockPassiveGenerator.GeneratorType.values()) - .filter(x -> ((GeneratorTypeAccessor) x).getKey().equals(generator)) - .findFirst() - .ifPresent(x -> setPowerMultiplier(x, worldPowerMultiplier)); + Arrays.stream(BlockPassiveGenerator.GeneratorType.values()).filter(x -> ((GeneratorTypeAccessor) x).getKey().equals( + generator)) + .findFirst().ifPresent(x -> setPowerMultiplier(x, worldPowerMultiplier)); } @MethodDescription(type = MethodDescription.Type.VALUE) @@ -71,20 +76,17 @@ public void setPowerMultiplier(String generator, IWorldPowerMultiplier worldPowe } @MethodDescription(type = MethodDescription.Type.VALUE, - example = @Example(value = "resource('generators:solar'), { TilePassiveGenerator generator, World world -> 100f }", imports = "com.rwtema.extrautils2.tile.TilePassiveGenerator")) + example = @Example(value = "resource('generators:solar'), { TilePassiveGenerator generator, World world -> 100f }", + imports = "com.rwtema.extrautils2.tile.TilePassiveGenerator")) public void setPowerLevel(ResourceLocation generator, Closure powerLevel) { if (powerLevel == null) { - GroovyLog.msg("Extra Utilities 2 Grid Power Passive Generator powerLevel closure must be defined") - .error() - .post(); + GroovyLog.msg("Extra Utilities 2 Grid Power Passive Generator powerLevel closure must be defined").error().post(); return; } if (!Arrays.equals(powerLevel.getParameterTypes(), new Class[]{TilePassiveGenerator.class, World.class})) { GroovyLog.msg("Extra Utilities 2 Grid Power Passive Generator powerLevel closure should be a closure with exactly two parameters:") - .add("com.rwtema.extrautils2.tile.TilePassiveGenerator generator, net.minecraft.world.World world in that order.") - .add("but had {}, {} instead", (Object[]) powerLevel.getParameterTypes()) - .debug() - .post(); + .add("com.rwtema.extrautils2.tile.TilePassiveGenerator generator, net.minecraft.world.World world in that order.") + .add("but had {}, {} instead", (Object[]) powerLevel.getParameterTypes()).debug().post(); } this.powerLevelMap.put(generator, powerLevel); } @@ -94,10 +96,8 @@ public void setPowerLevel(String generator, Closure powerLevel) { setPowerLevel(new ResourceLocation(generator), powerLevel); } - @MethodDescription(example = { - @Example("resource('generators:player_wind_up'), 100f"), - @Example("resource('generators:creative'), 5f") - }, type = MethodDescription.Type.VALUE) + @MethodDescription(example = {@Example("resource('generators:player_wind_up'), 100f"), + @Example("resource('generators:creative'), 5f")}, type = MethodDescription.Type.VALUE) public void setBasePower(ResourceLocation generator, float basePower) { basePowerMap.put(generator, basePower); } @@ -107,7 +107,8 @@ public void setBasePower(String generator, float basePower) { setBasePower(new ResourceLocation(generator), basePower); } - @MethodDescription(example = @Example("resource('generators:creative'), 500.0F, 0.5F, 1000.0F, 0.25F, 1500.0F, 0.05F"), type = MethodDescription.Type.VALUE) + @MethodDescription(example = @Example("resource('generators:creative'), 500.0F, 0.5F, 1000.0F, 0.25F, 1500.0F, 0.05F"), + type = MethodDescription.Type.VALUE) public void setScaling(ResourceLocation generator, float... scaling) { scalingMap.put(generator, scaling); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Resonator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Resonator.java index d9848e611..e728ffc75 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Resonator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Resonator.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.extrautils2; +import java.util.Arrays; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.items.ItemHandlerHelper; + +import org.codehaus.groovy.runtime.MethodClosure; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -14,15 +24,8 @@ import com.rwtema.extrautils2.tile.TileRainbowGenerator; import com.rwtema.extrautils2.tile.TileResonator; import com.rwtema.extrautils2.utils.Lang; -import groovy.lang.Closure; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.items.ItemHandlerHelper; -import org.codehaus.groovy.runtime.MethodClosure; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.Collection; +import groovy.lang.Closure; @RegistryDescription public class Resonator extends VirtualizedRegistry { @@ -82,11 +85,9 @@ public void removeAll() { TileResonator.resonatorRecipes.clear(); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).rainbow().energy(1000)"), - @Example(".input(item('minecraft:gold_block')).output(item('minecraft:clay') * 5).energy(100)"), - @Example(".input(item('minecraft:redstone')).output(item('extrautils2:ingredients:4')).ownerTag().energy(5000)"), - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).rainbow().energy(1000)"), + @Example(".input(item('minecraft:gold_block')).output(item('minecraft:clay') * 5).energy(100)"), + @Example(".input(item('minecraft:redstone')).output(item('extrautils2:ingredients:4')).ownerTag().energy(5000)"),}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -96,8 +97,7 @@ public interface ShouldProgress { boolean run(TileEntity resonator, int frequency, ItemStack input); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "100", type = Comp.Type.GTE)) @@ -141,24 +141,19 @@ public RecipeBuilder requirementText(String requirementText) { @RecipeBuilderMethodDescription public RecipeBuilder shouldProgress(Closure shouldProgress) { if (shouldProgress == null) { - GroovyLog.msg("Extra Utilities 2 Resonator shouldProgress closure must be defined") - .error() - .post(); + GroovyLog.msg("Extra Utilities 2 Resonator shouldProgress closure must be defined").error().post(); return this; } if (!Arrays.equals(shouldProgress.getParameterTypes(), new Class[]{TileEntity.class, int.class, ItemStack.class})) { GroovyLog.msg("Extra Utilities 2 Resonator shouldProgress closure should be a closure with exactly three parameters:") - .add("net.minecraft.tileentity.TileEntity resonator, int frequency, net.minecraft.item.ItemStack input in that order.") - .add("but had {}, {}, {} instead", (Object[]) shouldProgress.getParameterTypes()) - .debug() - .post(); + .add("net.minecraft.tileentity.TileEntity resonator, int frequency, net.minecraft.item.ItemStack input in that order.") + .add("but had {}, {}, {} instead", (Object[]) shouldProgress.getParameterTypes()).debug().post(); } this.shouldProgress = shouldProgress; return this; } - @SuppressWarnings("unchecked") - @RecipeBuilderMethodDescription(field = {"requirementText", "shouldProgress"}) + @SuppressWarnings("unchecked") @RecipeBuilderMethodDescription(field = {"requirementText", "shouldProgress"}) public RecipeBuilder rainbow() { this.requirementText = Lang.translate("[Requires an active Rainbow Generator]"); @@ -169,9 +164,7 @@ public RecipeBuilder rainbow() { Collection s = freq.getSubTypes(TileRainbowGenerator.rainbowGenerators); if (s != null) { for (TileRainbowGenerator power : s) { - if (power.providing) { - return true; - } + if (power.providing) { return true; } } } } @@ -183,9 +176,7 @@ public RecipeBuilder rainbow() { @Override - public String getErrorMsg() { - return "Error adding Extra Utilities 2 Resonator recipe"; - } + public String getErrorMsg() { return "Error adding Extra Utilities 2 Resonator recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -194,16 +185,14 @@ public void validate(GroovyLog.Msg msg) { msg.add(energy < 100, () -> "energy must not be less than 1 GP (100)"); } - @Nullable - @Override - @RecipeBuilderRegistrationMethod + @Nullable @Override @RecipeBuilderRegistrationMethod public IResonatorRecipe register() { if (!validate()) return null; - IResonatorRecipe recipe = new ResonatorRecipe(input.get(0).getMatchingStacks()[0], output.get(0), energy, ownerTag) { + IResonatorRecipe recipe = new ResonatorRecipe(input.get(0).getMatchingStacks()[0], output.get(0), energy, ownerTag) + { + @Override - public String getRequirementText() { - return requirementText == null ? "" : requirementText; - } + public String getRequirementText() { return requirementText == null ? "" : requirementText; } @Override public boolean shouldProgress(TileEntity resonator, int frequency, ItemStack input) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/BeeMutations.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/BeeMutations.java index b045cd644..fb3b627bc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/BeeMutations.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/BeeMutations.java @@ -1,10 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import java.util.Arrays; +import java.util.Objects; +import java.util.function.Function; + +import javax.annotation.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.core.mixin.forestry.BeeRootAccessor; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; + import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.IBeeMutation; import forestry.api.apiculture.IBeeMutationBuilder; @@ -14,34 +21,26 @@ import forestry.apiculture.genetics.alleles.AlleleBeeSpecies; import forestry.modules.ForestryModuleUids; -import javax.annotation.Nullable; -import java.util.Arrays; -import java.util.Objects; -import java.util.function.Function; - public class BeeMutations extends ForestryRegistry { public BeeMutations() { super(Alias.generateOfClassAnd(BeeMutations.class, "Mutations")); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(BeeRootAccessor.getBeeMutations()::remove); restoreFromBackup().forEach(BeeRootAccessor.getBeeMutations()::add); } - @Override - @GroovyBlacklist - public boolean isEnabled() { - return ForestryAPI.moduleManager.isModuleEnabled("forestry", ForestryModuleUids.APICULTURE); - } + @Override @GroovyBlacklist + public boolean isEnabled() { return ForestryAPI.moduleManager.isModuleEnabled("forestry", ForestryModuleUids.APICULTURE); } public IBeeMutation add(AlleleBeeSpecies output, AlleleBeeSpecies a, AlleleBeeSpecies b, double chance, @Nullable Function requirement) { - BeeMutation mutation = new BeeMutation(a, b, Objects.requireNonNull(BeeManager.beeRoot).getTemplate(output), (int) Math.round(100 * chance)); + BeeMutation mutation = new BeeMutation(a, b, Objects.requireNonNull(BeeManager.beeRoot).getTemplate(output), (int) Math + .round(100 * chance)); if (requirement != null) mutation = (BeeMutation) requirement.apply(mutation); add(mutation); return mutation; @@ -65,15 +64,13 @@ public boolean remove(IBeeMutation mutation) { public boolean removeByOutput(AlleleBeeSpecies species) { if (BeeRootAccessor.getBeeMutations().removeIf(mutation -> { - boolean found = Arrays.equals(mutation.getTemplate(), Objects.requireNonNull(BeeManager.beeRoot).getTemplate(species)); + boolean found = Arrays.equals(mutation.getTemplate(), Objects.requireNonNull(BeeManager.beeRoot).getTemplate( + species)); if (found) addBackup(mutation); return found; })) return true; - GroovyLog.msg("Error removing bee mutation") - .add("could not find bee mutation with output {}", species) - .error() - .post(); + GroovyLog.msg("Error removing bee mutation").add("could not find bee mutation with output {}", species).error().post(); return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/BeeProduce.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/BeeProduce.java index c6b0e2b87..e2bd883ea 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/BeeProduce.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/BeeProduce.java @@ -1,17 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.forestry.recipe.BeeProduct; import com.cleanroommc.groovyscript.core.mixin.forestry.AlleleRegistryAccessor; import com.cleanroommc.groovyscript.helper.Alias; + import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; import forestry.apiculture.genetics.alleles.AlleleBeeSpecies; import forestry.modules.ForestryModuleUids; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; public class BeeProduce extends ForestryRegistry { @@ -19,31 +22,28 @@ public BeeProduce() { super(Alias.generateOfClassAnd(BeeProduce.class, "Produce")); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(this::removeFromBee); restoreFromBackup().forEach(this::addToBee); } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal public void addToBee(BeeProduct product) { - (product.special ? product.species.getSpecialtyChances() : product.species.getProductChances()).put(product.item, product.chance); + (product.special ? product.species.getSpecialtyChances() : product.species.getProductChances()).put(product.item, + product.chance); } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal public boolean removeFromBee(BeeProduct product) { - return (product.special ? product.species.getSpecialtyChances() : product.species.getProductChances()).remove(product.item, product.chance); + return (product.special ? product.species.getSpecialtyChances() : product.species.getProductChances()).remove( + product.item, + product.chance); } - @Override - @GroovyBlacklist - public boolean isEnabled() { - return ForestryAPI.moduleManager.isModuleEnabled("forestry", ForestryModuleUids.APICULTURE); - } + @Override @GroovyBlacklist + public boolean isEnabled() { return ForestryAPI.moduleManager.isModuleEnabled("forestry", ForestryModuleUids.APICULTURE); } public BeeProduct add(AlleleBeeSpecies species, ItemStack output, float chance, boolean specialty) { BeeProduct product = new BeeProduct(species, output, chance, specialty); @@ -74,10 +74,8 @@ public boolean removeProduct(AlleleBeeSpecies species, IIngredient output) { return found; })) return true; - GroovyLog.msg("Error removing product for bee") - .add("could not find product {} for species {}", output, species) - .error() - .post(); + GroovyLog.msg("Error removing product for bee").add("could not find product {} for species {}", output, species).error() + .post(); return false; } @@ -88,10 +86,8 @@ public boolean removeSpecialty(AlleleBeeSpecies species, IIngredient output) { return found; })) return true; - GroovyLog.msg("Error removing specialty product for bee") - .add("could not find specialty product {} for species {}", output, species) - .error() - .post(); + GroovyLog.msg("Error removing specialty product for bee").add("could not find specialty product {} for species {}", + output, species).error().post(); return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Carpenter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Carpenter.java index 88117da7e..7d3abbdd7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Carpenter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Carpenter.java @@ -1,5 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -7,19 +18,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import forestry.api.recipes.ICarpenterRecipe; import forestry.core.recipes.ShapedRecipeCustom; import forestry.factory.recipes.CarpenterRecipe; import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; public class Carpenter extends ForestryRegistry { @@ -27,8 +30,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(CarpenterRecipeManagerAccessor.getRecipes()::remove); @@ -54,10 +56,8 @@ public boolean removeByOutput(IIngredient output) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Carpenter recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Carpenter recipe").add("could not find recipe with output {}", output).error() + .post(); return false; } @@ -68,10 +68,8 @@ public boolean removeByFluidInput(FluidStack input) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Carpenter recipe") - .add("could not find recipe with fluid input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Carpenter recipe").add("could not find recipe with fluid input {}", input).error() + .post(); return false; } @@ -82,10 +80,7 @@ public boolean removeByBox(IIngredient box) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Carpenter recipe") - .add("could not find recipe with box {}", box) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Carpenter recipe").add("could not find recipe with box {}", box).error().post(); return false; } @@ -109,10 +104,8 @@ public boolean removeByInput(IIngredient... inputs) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Carpenter recipe") - .add("could not find recipe with inputs {}", (Object[]) inputs) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Carpenter recipe").add("could not find recipe with inputs {}", (Object[]) inputs) + .error().post(); return false; } @@ -125,9 +118,9 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(CarpenterRecipeManagerAccessor.getRecipes()).setRemover(this::remove); } - @GroovyBlacklist - @ApiStatus.Internal - public static ShapedRecipeCustom convertPatternToInternal(ItemStack output, String[] pattern, Char2ObjectOpenHashMap keyMap) { + @GroovyBlacklist @ApiStatus.Internal + public static ShapedRecipeCustom convertPatternToInternal(ItemStack output, String[] pattern, + Char2ObjectOpenHashMap keyMap) { List argList = new ArrayList<>(Arrays.asList(pattern)); for (Map.Entry entry : keyMap.entrySet()) { argList.add(entry.getKey()); @@ -137,8 +130,7 @@ public static ShapedRecipeCustom convertPatternToInternal(ItemStack output, Stri return ShapedRecipeCustom.createShapedRecipe(output, argList.toArray()); } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal public static void validatePattern(GroovyLog.Msg msg, String[] pattern, Char2ObjectOpenHashMap keyMap) { msg.add(pattern == null || pattern.length == 0, "No pattern was defined."); if (pattern != null && pattern.length > 1) { @@ -157,9 +149,8 @@ public static void validatePattern(GroovyLog.Msg msg, String[] pattern, Char2Obj } } if (pattern != null) { - for (String line : pattern) - for (char c : line.toCharArray()) - msg.add(!keyMap.containsKey(c), "key '" + c + "' is not defined!"); + for (String line : pattern) for (char c : line.toCharArray()) msg.add(!keyMap.containsKey(c), "key '" + c + + "' is not defined!"); } } @@ -191,9 +182,7 @@ public RecipeBuilder shape(String... pattern) { } @Override - public String getErrorMsg() { - return "Error adding Forestry Carpenter recipe"; - } + public String getErrorMsg() { return "Error adding Forestry Carpenter recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -205,7 +194,8 @@ public void validate(GroovyLog.Msg msg) { @Override public @Nullable ICarpenterRecipe register() { if (!validate()) return null; - ICarpenterRecipe recipe = new CarpenterRecipe(time, fluidInput.getOrEmpty(0), box.getMatchingStacks()[0], convertPatternToInternal(output.get(0), pattern, keys)); + ICarpenterRecipe recipe = new CarpenterRecipe(time, fluidInput.getOrEmpty(0), box.getMatchingStacks()[0], + convertPatternToInternal(output.get(0), pattern, keys)); add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Centrifuge.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Centrifuge.java index 4672133a2..cbf2a64da 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Centrifuge.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Centrifuge.java @@ -1,21 +1,24 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import java.util.Arrays; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.core.mixin.forestry.CentrifugeRecipeManagerAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import forestry.api.recipes.ICentrifugeRecipe; import forestry.factory.recipes.CentrifugeRecipe; import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; public class Centrifuge extends ForestryRegistry { @@ -23,8 +26,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(CentrifugeRecipeManagerAccessor.getRecipes()::remove); @@ -50,10 +52,8 @@ public boolean removeByInput(IIngredient input) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Centrifuge recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Centrifuge recipe").add("could not find recipe with input {}", input).error() + .post(); return false; } @@ -65,10 +65,8 @@ public boolean removeByOutputs(IIngredient... output) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Centrifuge recipe") - .add("could not find recipe with outputs {}", list) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Centrifuge recipe").add("could not find recipe with outputs {}", list).error() + .post(); return false; } @@ -106,9 +104,7 @@ public RecipeBuilder output(ItemStack output) { } @Override - public String getErrorMsg() { - return "Error adding Forestry Centrifuge recipe"; - } + public String getErrorMsg() { return "Error adding Forestry Centrifuge recipe"; } @Override public void validate(GroovyLog.Msg msg) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/CharcoalPile.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/CharcoalPile.java index 21f5d44d0..04bac6d9e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/CharcoalPile.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/CharcoalPile.java @@ -1,31 +1,29 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import net.minecraft.block.state.IBlockState; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.core.mixin.forestry.CharcoalManagerAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; + import forestry.api.arboriculture.ICharcoalPileWall; import forestry.api.arboriculture.TreeManager; import forestry.api.core.ForestryAPI; import forestry.arboriculture.charcoal.CharcoalPileWall; import forestry.modules.ForestryModuleUids; -import net.minecraft.block.state.IBlockState; public class CharcoalPile extends ForestryRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(((CharcoalManagerAccessor) TreeManager.charcoalManager).getWalls()::remove); restoreFromBackup().forEach(((CharcoalManagerAccessor) TreeManager.charcoalManager).getWalls()::add); } - @Override - @GroovyBlacklist - public boolean isEnabled() { - return ForestryAPI.moduleManager.isModuleEnabled("forestry", ForestryModuleUids.CHARCOAL); - } + @Override @GroovyBlacklist + public boolean isEnabled() { return ForestryAPI.moduleManager.isModuleEnabled("forestry", ForestryModuleUids.CHARCOAL); } public ICharcoalPileWall add(IBlockState state, int amount) { if (!isEnabled() || state == null) return null; @@ -54,10 +52,7 @@ public boolean removeWall(IBlockState state) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Charcoal Pile wall") - .add("could not find wall for block {}", state) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Charcoal Pile wall").add("could not find wall for block {}", state).error().post(); return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Fermenter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Fermenter.java index 053679855..bfb0055de 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Fermenter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Fermenter.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -7,10 +11,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import forestry.api.recipes.IFermenterRecipe; import forestry.factory.recipes.FermenterRecipe; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; public class Fermenter extends ForestryRegistry { @@ -18,8 +21,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(FermenterRecipeManagerAccessor.getRecipes()::remove); @@ -28,8 +30,8 @@ public void onReload() { public IFermenterRecipe add(FluidStack output, FluidStack input, IIngredient catalyst, int value, float modifier) { IFermenterRecipe recipe; - if (catalyst instanceof OreDictIngredient) - recipe = new FermenterRecipe(((OreDictIngredient) catalyst).getOreDict(), value, modifier, input.getFluid(), output); + if (catalyst instanceof OreDictIngredient) recipe = new FermenterRecipe(((OreDictIngredient) catalyst).getOreDict(), + value, modifier, input.getFluid(), output); else recipe = new FermenterRecipe(catalyst.getMatchingStacks()[0], value, modifier, input.getFluid(), output); add(recipe); return recipe; @@ -54,25 +56,22 @@ public boolean removeByInput(FluidStack input) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Fermenter recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Fermenter recipe").add("could not find recipe with input {}", input).error() + .post(); return false; } public boolean removeByCatalyst(IIngredient input) { if (FermenterRecipeManagerAccessor.getRecipes().removeIf(recipe -> { - boolean found = input instanceof OreDictIngredient ? recipe.getResourceOreName().equals(((OreDictIngredient) input).getOreDict()) - : recipe.getResource().isItemEqual(input.getMatchingStacks()[0]); + boolean found = input instanceof OreDictIngredient ? recipe.getResourceOreName().equals(((OreDictIngredient) input) + .getOreDict()) : + recipe.getResource().isItemEqual(input.getMatchingStacks()[0]); if (found) addBackup(recipe); return found; })) return true; - GroovyLog.msg("Error removing Forestry Fermenter recipe") - .add("could not find recipe with catalyst {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Fermenter recipe").add("could not find recipe with catalyst {}", input).error() + .post(); return false; } @@ -83,10 +82,8 @@ public boolean removeByOutput(FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Fermenter recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Fermenter recipe").add("could not find recipe with output {}", output).error() + .post(); return false; } @@ -115,9 +112,7 @@ public RecipeBuilder modifier(float modifier) { } @Override - public String getErrorMsg() { - return "Error adding Forestry Fermenter recipe"; - } + public String getErrorMsg() { return "Error adding Forestry Fermenter recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -130,9 +125,11 @@ public void validate(GroovyLog.Msg msg) { if (!validate()) return null; IFermenterRecipe recipe; IIngredient catalyst = input.get(0); - if (catalyst instanceof OreDictIngredient) - recipe = new FermenterRecipe(((OreDictIngredient) catalyst).getOreDict(), value, modifier, fluidInput.get(0).getFluid(), fluidOutput.get(0)); - else recipe = new FermenterRecipe(catalyst.getMatchingStacks()[0], value, modifier, fluidInput.get(0).getFluid(), fluidOutput.get(0)); + if (catalyst instanceof OreDictIngredient) recipe = new FermenterRecipe(((OreDictIngredient) catalyst).getOreDict(), + value, modifier, fluidInput.get(0).getFluid(), + fluidOutput.get(0)); + else recipe = new FermenterRecipe(catalyst.getMatchingStacks()[0], value, modifier, fluidInput.get(0).getFluid(), + fluidOutput.get(0)); add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Forestry.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Forestry.java index df1991481..1263f6f5e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Forestry.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Forestry.java @@ -3,6 +3,7 @@ import com.cleanroommc.groovyscript.api.Result; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; + import forestry.api.apiculture.IAlleleBeeSpecies; import forestry.api.core.ForestryAPI; import forestry.api.genetics.AlleleManager; @@ -50,10 +51,11 @@ protected static String getNormalName(String name) { @Override public void initialize(GroovyContainer container) { - container.objectMapperBuilder("species", AlleleBeeSpecies.class) - .parser(Forestry::parseSpecies) - .completerOfNamed(() -> AlleleManager.alleleRegistry.getRegisteredAlleles().keySet(), s -> s.replace('.', ':')) // elements don't have names - .docOfType("allele bee species") - .register(); + container.objectMapperBuilder("species", AlleleBeeSpecies.class).parser(Forestry::parseSpecies).completerOfNamed( + () -> AlleleManager.alleleRegistry.getRegisteredAlleles() + .keySet(), + s -> s.replace('.', + ':')) // elements don't have names + .docOfType("allele bee species").register(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/ForestryRegistry.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/ForestryRegistry.java index 296bdd622..8f317a436 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/ForestryRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/ForestryRegistry.java @@ -1,27 +1,24 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import java.util.Collection; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import forestry.api.core.ForestryAPI; import forestry.modules.ForestryModuleUids; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - -import java.util.Collection; public abstract class ForestryRegistry extends VirtualizedRegistry { - public ForestryRegistry() { - } + public ForestryRegistry() {} public ForestryRegistry(@Nullable Collection aliases) { super(aliases); } - @Override - @GroovyBlacklist - @ApiStatus.Internal - public boolean isEnabled() { - return ForestryAPI.moduleManager.isModuleEnabled("forestry", ForestryModuleUids.FACTORY); - } + @Override @GroovyBlacklist @ApiStatus.Internal + public boolean isEnabled() { return ForestryAPI.moduleManager.isModuleEnabled("forestry", ForestryModuleUids.FACTORY); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Moistener.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Moistener.java index afa39c97a..5fbd159c5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Moistener.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Moistener.java @@ -1,15 +1,18 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.core.mixin.forestry.MoistenerRecipeManagerAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import forestry.api.recipes.IMoistenerRecipe; import forestry.factory.recipes.MoistenerRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; public class Moistener extends ForestryRegistry { @@ -17,8 +20,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(MoistenerRecipeManagerAccessor.getRecipes()::remove); @@ -50,10 +52,8 @@ public boolean removeByInput(IIngredient input) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Moistener recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Moistener recipe").add("could not find recipe with input {}", input).error() + .post(); return false; } @@ -64,10 +64,8 @@ public boolean removeByOutput(IIngredient output) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Moistener recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Moistener recipe").add("could not find recipe with output {}", output).error() + .post(); return false; } @@ -90,9 +88,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Forestry Moistener recipe"; - } + public String getErrorMsg() { return "Error adding Forestry Moistener recipe"; } @Override public void validate(GroovyLog.Msg msg) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/MoistenerFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/MoistenerFuel.java index a7b82b1a0..f4c4657e2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/MoistenerFuel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/MoistenerFuel.java @@ -1,16 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; + import forestry.api.fuels.FuelManager; -import net.minecraft.item.ItemStack; public class MoistenerFuel extends ForestryRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(fuel -> FuelManager.moistenerResource.remove(fuel.getItem(), fuel)); @@ -18,7 +19,8 @@ public void onReload() { } public forestry.api.fuels.MoistenerFuel add(ItemStack output, IIngredient input, int value, int stage) { - forestry.api.fuels.MoistenerFuel fuel = new forestry.api.fuels.MoistenerFuel(output, input.getMatchingStacks()[0], stage, value); + forestry.api.fuels.MoistenerFuel fuel = new forestry.api.fuels.MoistenerFuel(output, input.getMatchingStacks()[0], stage, + value); add(fuel); return fuel; } @@ -43,10 +45,7 @@ public boolean removeByInput(IIngredient input) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Moistener fuel") - .add("Could not find fuel with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Moistener fuel").add("Could not find fuel with input {}", input).error().post(); return false; } @@ -57,10 +56,7 @@ public boolean removeByOutput(ItemStack output) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Moistener fuel") - .add("Could not find fuel with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Moistener fuel").add("Could not find fuel with output {}", output).error().post(); return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Squeezer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Squeezer.java index 70e1b3654..38e6f810c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Squeezer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Squeezer.java @@ -1,21 +1,24 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.core.mixin.forestry.SqueezerRecipeManagerAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import forestry.api.recipes.ISqueezerRecipe; import forestry.factory.recipes.SqueezerRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.Set; -import java.util.stream.Collectors; public class Squeezer extends ForestryRegistry { @@ -23,8 +26,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(SqueezerRecipeManagerAccessor.getRecipes()::remove); @@ -32,7 +34,10 @@ public void onReload() { } public ISqueezerRecipe add(FluidStack output, IIngredient remnant, int time, int remnantChance, IIngredient... inputs) { - ISqueezerRecipe recipe = new SqueezerRecipe(time, NonNullList.from(ItemStack.EMPTY, Arrays.stream(inputs).map(i -> i.getMatchingStacks()[0]).toArray(ItemStack[]::new)), output, remnant.getMatchingStacks()[0], remnantChance); + ISqueezerRecipe recipe = new SqueezerRecipe(time, NonNullList.from(ItemStack.EMPTY, Arrays.stream(inputs).map(i -> i + .getMatchingStacks()[0]) + .toArray(ItemStack[]::new)), + output, remnant.getMatchingStacks()[0], remnantChance); add(recipe); return recipe; } @@ -56,10 +61,8 @@ public boolean removeByOutput(FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Squeezer recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Squeezer recipe").add("could not find recipe with output {}", output).error() + .post(); return false; } @@ -71,10 +74,8 @@ public boolean removeByInputs(IIngredient... input) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Squeezer recipe") - .add("could not find recipe with inputs {}", inputs) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Squeezer recipe").add("could not find recipe with inputs {}", inputs).error() + .post(); return false; } @@ -107,9 +108,7 @@ public RecipeBuilder chance(float chance) { } @Override - public String getErrorMsg() { - return "Error adding Forestry Squeezer recipe"; - } + public String getErrorMsg() { return "Error adding Forestry Squeezer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -120,7 +119,8 @@ public void validate(GroovyLog.Msg msg) { @Override public @Nullable ISqueezerRecipe register() { if (!validate()) return null; - NonNullList list = NonNullList.from(ItemStack.EMPTY, input.stream().map(i -> i.getMatchingStacks()[0]).toArray(ItemStack[]::new)); + NonNullList list = NonNullList.from(ItemStack.EMPTY, input.stream().map(i -> i.getMatchingStacks()[0]) + .toArray(ItemStack[]::new)); ISqueezerRecipe recipe = new SqueezerRecipe(time, list, fluidOutput.get(0), output.getOrEmpty(0), chance); add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Still.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Still.java index f6634ccd9..7a21ac05f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Still.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/Still.java @@ -1,14 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.core.mixin.forestry.StillRecipeManagerAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import forestry.api.recipes.IStillRecipe; import forestry.factory.recipes.StillRecipe; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; public class Still extends ForestryRegistry { @@ -16,8 +19,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(StillRecipeManagerAccessor.getRecipes()::remove); @@ -49,10 +51,7 @@ public boolean removeByInput(FluidStack input) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Still recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Still recipe").add("could not find recipe with input {}", input).error().post(); return false; } @@ -63,10 +62,7 @@ public boolean removeByOutput(FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Still recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Still recipe").add("could not find recipe with output {}", output).error().post(); return false; } @@ -89,9 +85,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Forestry Still recipe"; - } + public String getErrorMsg() { return "Error adding Forestry Still recipe"; } @Override public void validate(GroovyLog.Msg msg) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/ThermionicFabricator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/ThermionicFabricator.java index bce89ded3..5bb007151 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/ThermionicFabricator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/ThermionicFabricator.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.forestry; +import java.util.Arrays; + +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,6 +14,7 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import forestry.api.recipes.IFabricatorRecipe; import forestry.api.recipes.IFabricatorSmeltingRecipe; import forestry.core.recipes.ShapedRecipeCustom; @@ -15,10 +22,6 @@ import forestry.factory.recipes.FabricatorSmeltingRecipe; import forestry.factory.recipes.FabricatorSmeltingRecipeManager; import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; public class ThermionicFabricator extends ForestryRegistry { @@ -32,8 +35,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(FabricatorRecipeManagerAccessor.getRecipes()::remove); @@ -59,10 +61,8 @@ public boolean removeByFluid(FluidStack input) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Thermionic Fabricator recipe") - .add("could not find recipe with fluid input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Thermionic Fabricator recipe").add("could not find recipe with fluid input {}", + input).error().post(); return false; } @@ -73,10 +73,8 @@ public boolean removeByCatalyst(IIngredient catalyst) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Thermionic Fabricator recipe") - .add("could not find recipe with catalyst {}", catalyst) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Thermionic Fabricator recipe").add("could not find recipe with catalyst {}", + catalyst).error().post(); return false; } @@ -87,10 +85,8 @@ public boolean removeByOutput(IIngredient output) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Thermionic Fabricator recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Thermionic Fabricator recipe").add("could not find recipe with output {}", output) + .error().post(); return false; } @@ -114,10 +110,8 @@ public boolean removeByInput(IIngredient... input) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Thermionic Fabricator recipe") - .add("could not find recipe with inputs {}", (Object[]) input) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Thermionic Fabricator recipe").add("could not find recipe with inputs {}", + (Object[]) input).error().post(); return false; } @@ -152,9 +146,7 @@ public RecipeBuilder shape(String... pattern) { } @Override - public String getErrorMsg() { - return "Error adding Forestry Thermionic Fabricator recipe"; - } + public String getErrorMsg() { return "Error adding Forestry Thermionic Fabricator recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -167,7 +159,10 @@ public void validate(GroovyLog.Msg msg) { public @Nullable IFabricatorRecipe register() { if (!validate()) return null; ShapedRecipeCustom internal = Carpenter.convertPatternToInternal(output.get(0), pattern, keys); - IFabricatorRecipe recipe = new FabricatorRecipe(catalyst.getMatchingStacks()[0], fluidInput.get(0), output.get(0), internal.getRawIngredients(), internal.getOreDicts(), internal.getWidth(), internal.getHeight()); + IFabricatorRecipe recipe = new FabricatorRecipe(catalyst.getMatchingStacks()[0], fluidInput.get(0), output.get(0), + internal.getRawIngredients(), internal.getOreDicts(), internal + .getWidth(), + internal.getHeight()); add(recipe); return recipe; } @@ -175,8 +170,7 @@ public void validate(GroovyLog.Msg msg) { public static class Smelting extends ForestryRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { if (!isEnabled()) return; removeScripted().forEach(FabricatorSmeltingRecipeManager.recipes::remove); @@ -208,10 +202,9 @@ public boolean removeByInput(IIngredient input) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Thermionic Fabricator Smelting recipe") - .add("Could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Thermionic Fabricator Smelting recipe").add( + "Could not find recipe with input {}", + input).error().post(); return false; } @@ -222,10 +215,9 @@ public boolean removeByOutput(FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Forestry Thermionic Fabricator Smelting recipe") - .add("Could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Forestry Thermionic Fabricator Smelting recipe").add( + "Could not find recipe with output {}", + output).error().post(); return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/recipe/BeeProduct.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/recipe/BeeProduct.java index 4c4cfa41e..c79eec850 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/recipe/BeeProduct.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/forestry/recipe/BeeProduct.java @@ -1,8 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.forestry.recipe; -import forestry.apiculture.genetics.alleles.AlleleBeeSpecies; import net.minecraft.item.ItemStack; +import forestry.apiculture.genetics.alleles.AlleleBeeSpecies; + public class BeeProduct { public final AlleleBeeSpecies species; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/Centrifuge.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/Centrifuge.java index f6cb96693..5e578048b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/Centrifuge.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/Centrifuge.java @@ -1,21 +1,23 @@ package com.cleanroommc.groovyscript.compat.mods.ic2; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; public class Centrifuge extends VirtualizedRegistry>> { @@ -51,13 +53,11 @@ public boolean remove(MachineRecipe> recipe) public void removeByOutput(ItemStack... outputs) { if (outputs == null || outputs.length < 1) { - GroovyLog.msg("Error removing Industrialcraft 2 Centrifuge recipe") - .add("outputs must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Centrifuge recipe").add("outputs must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.centrifuge.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.centrifuge.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> recipe = iterator.next(); if (recipe.getOutput().size() == outputs.length) { @@ -78,13 +78,11 @@ public void removeByOutput(ItemStack... outputs) { public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Centrifuge recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Centrifuge recipe").add("input must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.centrifuge.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.centrifuge.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(input)) { iterator.remove(); @@ -94,7 +92,8 @@ public void removeByInput(ItemStack input) { } public void removeAll() { - for (Iterator>> iterator = Recipes.centrifuge.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.centrifuge.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); iterator.remove(); addBackup(rec); @@ -106,7 +105,8 @@ public SimpleObjectStream>> st } private boolean remove(MachineRecipe> recipe, boolean backup) { - for (Iterator>> iterator = Recipes.centrifuge.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.centrifuge.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(recipe.getInput().getInputs().get(0))) { iterator.remove(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/IC2.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/IC2.java index 68f631257..edf80ba04 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/IC2.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/IC2.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.ic2; -import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; -import com.cleanroommc.groovyscript.compat.mods.ic2.classic.*; -import com.cleanroommc.groovyscript.compat.mods.ic2.exp.*; +import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; -import java.util.List; +import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; +import com.cleanroommc.groovyscript.compat.mods.ic2.classic.*; +import com.cleanroommc.groovyscript.compat.mods.ic2.exp.*; public class IC2 extends GroovyPropertyContainer { @@ -70,9 +71,7 @@ public IC2() { public static boolean isExp() { for (ModContainer container : Loader.instance().getActiveModList()) { - if ("ic2".equals(container.getModId())) { - return container.getMetadata().version.contains("ex"); - } + if ("ic2".equals(container.getModId())) { return container.getMetadata().version.contains("ex"); } } return false; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/MetalFormer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/MetalFormer.java index 4772931b1..3e9709f96 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/MetalFormer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/MetalFormer.java @@ -1,18 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.ic2; +import java.util.*; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IBasicMachineRecipeManager; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.*; public class MetalFormer extends VirtualizedRegistry { @@ -27,13 +29,17 @@ public void add(int type, MachineRecipe> rec } public MachineRecipe> add(int type, IIngredient input, ItemStack output) { - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); add(type, recipe); return recipe; } - public MachineRecipe> add(int type, IIngredient input, ItemStack output, NBTTagCompound tag) { - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output), tag); + public MachineRecipe> add(int type, IIngredient input, ItemStack output, + NBTTagCompound tag) { + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output), + tag); add(type, recipe); return recipe; } @@ -55,14 +61,15 @@ public boolean remove(MachineRecipe> recipe) } public void removeByOutput(int type, ItemStack output) { - if (GroovyLog.msg("Error removing Industrialcraft 2 Metal Former recipe") - .add(type < 0 || type > 2, () -> "type must be between 0-2") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Industrialcraft 2 Metal Former recipe").add(type < 0 || type > 2, + () -> "type must be between 0-2").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return; } - for (Iterator>> iterator = getManager(type).getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = getManager(type).getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (ItemStack.areItemStacksEqual((ItemStack) rec.getOutput().toArray()[0], output)) { iterator.remove(); @@ -72,14 +79,15 @@ public void removeByOutput(int type, ItemStack output) { } public void removeByInput(int type, ItemStack input) { - if (GroovyLog.msg("Error removing Industrialcraft 2 Metal Former recipe") - .add(type < 0 || type > 2, () -> "type must be between 0-2") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Industrialcraft 2 Metal Former recipe").add(type < 0 || type > 2, + () -> "type must be between 0-2").add( + IngredientHelper.isEmpty(input), + () -> "input must not be empty") + .error().postIfNotEmpty()) { return; } - for (Iterator>> iterator = getManager(type).getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = getManager(type).getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(input)) { iterator.remove(); @@ -90,13 +98,11 @@ public void removeByInput(int type, ItemStack input) { public void removeAll(int type) { if (type < 0 || type > 2) { - GroovyLog.msg("Error removing Industrialcraft 2 Metal Former recipe") - .add("type must be between 0-2") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Metal Former recipe").add("type must be between 0-2").error().post(); return; } - for (Iterator>> iterator = getManager(type).getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = getManager(type).getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); iterator.remove(); addBackup(new MetalFormerRecipe(type, rec)); @@ -104,7 +110,8 @@ public void removeAll(int type) { } private boolean remove(int type, MachineRecipe> recipe, boolean backup) { - for (Iterator>> iterator = getManager(type).getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = getManager(type).getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(recipe.getInput().getInputs().get(0))) { iterator.remove(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/OreWasher.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/OreWasher.java index dc1055f55..eeb63f610 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/OreWasher.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/OreWasher.java @@ -1,21 +1,23 @@ package com.cleanroommc.groovyscript.compat.mods.ic2; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; public class OreWasher extends VirtualizedRegistry>> { @@ -55,13 +57,11 @@ public boolean remove(MachineRecipe> recipe) public void removeByOutput(ItemStack... outputs) { if (outputs == null || outputs.length < 1) { - GroovyLog.msg("Error removing Industrialcraft 2 Ore Washer recipe") - .add("outputs must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Ore Washer recipe").add("outputs must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.oreWashing.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.oreWashing.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> recipe = iterator.next(); if (recipe.getOutput().size() == outputs.length) { @@ -82,13 +82,11 @@ public void removeByOutput(ItemStack... outputs) { public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Ore Washer recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Ore Washer recipe").add("input must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.oreWashing.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.oreWashing.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(input)) { iterator.remove(); @@ -98,7 +96,8 @@ public void removeByInput(ItemStack input) { } public void removeAll() { - for (Iterator>> iterator = Recipes.oreWashing.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.oreWashing.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); iterator.remove(); addBackup(rec); @@ -106,7 +105,8 @@ public void removeAll() { } private boolean remove(MachineRecipe> recipe, boolean backup) { - for (Iterator>> iterator = Recipes.oreWashing.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.oreWashing.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(recipe.getInput().getInputs().get(0))) { iterator.remove(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/RecipeInput.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/RecipeInput.java index 3f8974849..7b6ef86cb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/RecipeInput.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/RecipeInput.java @@ -1,12 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.ic2; -import com.cleanroommc.groovyscript.api.IIngredient; -import ic2.api.recipe.IRecipeInput; -import net.minecraft.item.ItemStack; - import java.util.Arrays; import java.util.List; +import net.minecraft.item.ItemStack; + +import com.cleanroommc.groovyscript.api.IIngredient; + +import ic2.api.recipe.IRecipeInput; + public class RecipeInput implements IRecipeInput { private final IIngredient ingredient; @@ -21,12 +23,8 @@ public boolean matches(ItemStack itemStack) { } @Override - public int getAmount() { - return this.ingredient.getAmount(); - } + public int getAmount() { return this.ingredient.getAmount(); } @Override - public List getInputs() { - return Arrays.asList(this.ingredient.getMatchingStacks()); - } + public List getInputs() { return Arrays.asList(this.ingredient.getMatchingStacks()); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/Canner.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/Canner.java index c351e9df6..8905ebff4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/Canner.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/Canner.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.classic; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.Tuple; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; @@ -8,19 +16,13 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.ingredient.ItemsIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.classic.recipe.ClassicRecipes; import ic2.api.classic.recipe.machine.ICannerRegistry; import ic2.api.classic.recipe.machine.IFoodCanEffect; import ic2.api.item.ICustomDamageItem; import ic2.api.recipe.IRecipeInput; import ic2.core.util.helpers.ItemWithMeta; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Tuple; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; public class Canner extends VirtualizedRegistry { @@ -31,25 +33,23 @@ public void onReload() { } public CanningRecipe addCanning(ItemStack output, IIngredient input, ItemStack container) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Canner Canning recipe") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Canner Canning recipe").add(IngredientHelper.isEmpty(output), + () -> "output must not be empty").add( + IngredientHelper.isEmpty(input), + () -> "input must not be empty") + .error().postIfNotEmpty()) { return null; } - CanningRecipe recipe = new CanningRecipe(RecipeType.CANNING_RECIPE).setOutput(output).setInput(input).setContainer(container); + CanningRecipe recipe = new CanningRecipe(RecipeType.CANNING_RECIPE).setOutput(output).setInput(input).setContainer( + container); add(recipe); addScripted(recipe); return recipe; } public CanningRecipe registerItemEffect(int id, IIngredient input) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Canner Item Effect recipe") - .add(id < 0, () -> "id must not be negative") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Canner Item Effect recipe").add(id < 0, () -> "id must not be negative") + .add(IngredientHelper.isEmpty(input), () -> "input must not be empty").error().postIfNotEmpty()) { return null; } CanningRecipe recipe = new CanningRecipe(RecipeType.ITEM_EFFECT).setInt(id).setInput(input); @@ -59,11 +59,11 @@ public CanningRecipe registerItemEffect(int id, IIngredient input) { } public CanningRecipe registerFuelValue(IIngredient ingredient, int value) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Canner Fuel Value") - .add(IngredientHelper.isEmpty(ingredient), () -> "ingredient must not be empty") - .add(value <= 0, () -> "value must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Canner Fuel Value").add(IngredientHelper.isEmpty(ingredient), + () -> "ingredient must not be empty").add( + value <= 0, + () -> "value must be higher than zero") + .error().postIfNotEmpty()) { return null; } CanningRecipe recipe = new CanningRecipe(RecipeType.FUEL_VALUE).setInt(value).setInput(ingredient); @@ -73,11 +73,11 @@ public CanningRecipe registerFuelValue(IIngredient ingredient, int value) { } public CanningRecipe registerFuelValue(IIngredient ingredient, int value, float value1) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Canner Fuel Value") - .add(IngredientHelper.isEmpty(ingredient), () -> "ingredient must not be empty") - .add(value <= 0, () -> "value must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Canner Fuel Value").add(IngredientHelper.isEmpty(ingredient), + () -> "ingredient must not be empty").add( + value <= 0, + () -> "value must be higher than zero") + .error().postIfNotEmpty()) { return null; } CanningRecipe recipe = new CanningRecipe(RecipeType.FUEL_VALUE).setInt(value).setInput(ingredient).setFloat(value1); @@ -87,7 +87,8 @@ public CanningRecipe registerFuelValue(IIngredient ingredient, int value, float } public SimpleObjectStream>>> streamCanningRecipes() { - return new SimpleObjectStream<>(ClassicRecipes.canningMachine.getCanningMap().entrySet()).setRemover(r -> this.removeCanning(r.getKey())); + return new SimpleObjectStream<>(ClassicRecipes.canningMachine.getCanningMap().entrySet()).setRemover(r -> this + .removeCanning(r.getKey())); } public SimpleObjectStream streamFuelValues() { @@ -95,17 +96,19 @@ public SimpleObjectStream streamFuelValues() { } public SimpleObjectStream> streamItemEffects() { - return new SimpleObjectStream<>(ClassicRecipes.canningMachine.getEffectMap().entrySet()).setRemover(r -> this.removeItemEffect(r.getKey())); + return new SimpleObjectStream<>(ClassicRecipes.canningMachine.getEffectMap().entrySet()).setRemover(r -> this + .removeItemEffect(r.getKey())); } public SimpleObjectStream>>>> streamRepairRecipes() { return new SimpleObjectStream<>(ClassicRecipes.canningMachine.getRepairMap().entrySet()).setRemover(entry -> { for (Tuple> tuple : entry.getValue()) { - CanningRecipe recipe = new CanningRecipe(RecipeType.REPAIR) - .setDamageItem(entry.getKey()) - .setMeta(tuple.getFirst()) - .setInput(new ItemsIngredient(tuple.getSecond().getFirst().getInputs())) - .setInt(tuple.getSecond().getSecond()); + CanningRecipe recipe = new CanningRecipe(RecipeType.REPAIR).setDamageItem(entry.getKey()).setMeta(tuple + .getFirst()) + .setInput(new ItemsIngredient(tuple.getSecond() + .getFirst() + .getInputs())) + .setInt(tuple.getSecond().getSecond()); remove(recipe); addBackup(recipe); } @@ -115,21 +118,16 @@ public SimpleObjectStream> idToItems = ((ClassicCanningMachineRegistryAccessor) ClassicRecipes.canningMachine).getIdToItems(); if (id < 0 || id >= idToItems.size()) { - GroovyLog.msg("Error removing Industrialcraft 2 Canner Item Effect recipe") - .add("id must be between 0-%d", idToItems.size()) - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Canner Item Effect recipe").add("id must be between 0-%d", idToItems + .size()) + .error().post(); return false; } - CanningRecipe recipe = new CanningRecipe(RecipeType.ITEM_EFFECT).setInput(new ItemsIngredient(asItemStackList(idToItems.get(id)))).setInt(id); + CanningRecipe recipe = new CanningRecipe(RecipeType.ITEM_EFFECT).setInput(new ItemsIngredient(asItemStackList(idToItems.get(id)))) + .setInt(id); ClassicRecipes.canningMachine.deleteEffectID(id, true); addBackup(recipe); return true; @@ -161,16 +161,23 @@ public boolean removeItemEffect(int id) { public void removeAllItemEffect() { Map> idToItems = ((ClassicCanningMachineRegistryAccessor) ClassicRecipes.canningMachine).getIdToItems(); for (int i = 0; i < ClassicRecipes.canningMachine.getEffectMap().size(); i++) { - CanningRecipe recipe = new CanningRecipe(RecipeType.ITEM_EFFECT).setInput(new ItemsIngredient(asItemStackList(idToItems.get(i)))).setInt(i); + CanningRecipe recipe = new CanningRecipe(RecipeType.ITEM_EFFECT).setInput(new ItemsIngredient(asItemStackList(idToItems.get(i)))) + .setInt(i); remove(recipe); addBackup(recipe); } } public boolean removeAllRepair() { - for (Map.Entry>>> entry : ClassicRecipes.canningMachine.getRepairMap().entrySet()) { + for (Map.Entry>>> entry : ClassicRecipes.canningMachine.getRepairMap() + .entrySet()) { for (Tuple> tuple : entry.getValue()) { - CanningRecipe recipe = new CanningRecipe(RecipeType.REPAIR).setDamageItem(entry.getKey()).setMeta(tuple.getFirst()).setInput(new ItemsIngredient(tuple.getSecond().getFirst().getInputs())).setInt(tuple.getSecond().getSecond()); + CanningRecipe recipe = new CanningRecipe(RecipeType.REPAIR).setDamageItem(entry.getKey()).setMeta(tuple + .getFirst()) + .setInput(new ItemsIngredient(tuple.getSecond() + .getFirst() + .getInputs())) + .setInt(tuple.getSecond().getSecond()); remove(recipe); addBackup(recipe); } @@ -180,42 +187,46 @@ public boolean removeAllRepair() { public boolean removeCanning(ItemStack container) { if (IngredientHelper.isEmpty(container)) { - GroovyLog.msg("Error removing Industrialcraft 2 Canning Machine recipe") - .add("container must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Canning Machine recipe").add("container must not be empty").error() + .post(); return false; } - for (Map.Entry>> entry : ClassicRecipes.canningMachine.getCanningMap().entrySet()) { + for (Map.Entry>> entry : ClassicRecipes.canningMachine.getCanningMap() + .entrySet()) { if (ItemStack.areItemStacksEqual(entry.getKey(), container)) { for (Tuple tuple : entry.getValue()) { - CanningRecipe recipe = new CanningRecipe(RecipeType.CANNING_RECIPE).setContainer(container).setInput(new ItemsIngredient(tuple.getFirst().getInputs())).setOutput(tuple.getSecond()); + CanningRecipe recipe = new CanningRecipe(RecipeType.CANNING_RECIPE).setContainer(container).setInput( + new ItemsIngredient(tuple.getFirst() + .getInputs())) + .setOutput(tuple.getSecond()); addBackup(recipe); } ClassicRecipes.canningMachine.removeCanningRecipe(container); return true; } } - GroovyLog.msg("Error removing Industrialcraft 2 Canning Machine recipe") - .add("no recipes found for {}", container) - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Canning Machine recipe").add("no recipes found for {}", container).error() + .post(); return false; } public void removeCanningByInputs(ItemStack input, ItemStack container) { - if (GroovyLog.msg("Error removing Industrialcraft 2 Canning Machine recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(container), () -> "container must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Industrialcraft 2 Canning Machine recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(container), + () -> "container must not be empty") + .error().postIfNotEmpty()) { return; } - for (Map.Entry>> entry : ClassicRecipes.canningMachine.getCanningMap().entrySet()) { + for (Map.Entry>> entry : ClassicRecipes.canningMachine.getCanningMap() + .entrySet()) { if (ItemStack.areItemStacksEqual(entry.getKey(), container)) { for (Tuple tuple : entry.getValue()) { if (tuple.getFirst().matches(input)) { - CanningRecipe recipe = new CanningRecipe(RecipeType.CANNING_RECIPE).setContainer(container).setInput(new ItemsIngredient(tuple.getFirst().getInputs())).setOutput(tuple.getSecond()); + CanningRecipe recipe = new CanningRecipe(RecipeType.CANNING_RECIPE).setContainer(container).setInput( + new ItemsIngredient(tuple.getFirst() + .getInputs())) + .setOutput(tuple.getSecond()); remove(recipe); addBackup(recipe); } @@ -226,16 +237,18 @@ public void removeCanningByInputs(ItemStack input, ItemStack container) { public void removeCanningByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft 2 Canning Machine recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Canning Machine recipe").add("output must not be empty").error() + .post(); return; } - for (Map.Entry>> entry : ClassicRecipes.canningMachine.getCanningMap().entrySet()) { + for (Map.Entry>> entry : ClassicRecipes.canningMachine.getCanningMap() + .entrySet()) { for (Tuple tuple : entry.getValue()) { if (ItemStack.areItemStacksEqual(tuple.getSecond(), output)) { - CanningRecipe recipe = new CanningRecipe(RecipeType.CANNING_RECIPE).setContainer(entry.getKey()).setInput(new ItemsIngredient(tuple.getFirst().getInputs())).setOutput(tuple.getSecond()); + CanningRecipe recipe = new CanningRecipe(RecipeType.CANNING_RECIPE).setContainer(entry.getKey()).setInput( + new ItemsIngredient(tuple.getFirst() + .getInputs())) + .setOutput(tuple.getSecond()); remove(recipe); addBackup(recipe); } @@ -244,9 +257,13 @@ public void removeCanningByOutput(ItemStack output) { } public void removeAllCanning() { - for (Map.Entry>> entry : ClassicRecipes.canningMachine.getCanningMap().entrySet()) { + for (Map.Entry>> entry : ClassicRecipes.canningMachine.getCanningMap() + .entrySet()) { for (Tuple tuple : entry.getValue()) { - CanningRecipe recipe = new CanningRecipe(RecipeType.CANNING_RECIPE).setContainer(entry.getKey().copy()).setInput(new ItemsIngredient(new ArrayList<>(tuple.getFirst().getInputs()))).setOutput(tuple.getSecond().copy()); + CanningRecipe recipe = new CanningRecipe(RecipeType.CANNING_RECIPE).setContainer(entry.getKey().copy()).setInput( + new ItemsIngredient(new ArrayList<>(tuple.getFirst() + .getInputs()))) + .setOutput(tuple.getSecond().copy()); addBackup(recipe); } ClassicRecipes.canningMachine.removeCanningRecipe(entry.getKey()); @@ -255,8 +272,11 @@ public void removeAllCanning() { private void add(CanningRecipe recipe) { switch (recipe.type) { - case CANNING_RECIPE -> ClassicRecipes.canningMachine.registerCannerItem(recipe.container, new RecipeInput(recipe.input), recipe.output); - case ITEM_EFFECT -> ClassicRecipes.canningMachine.registerItemsForEffect(recipe.intValue, recipe.input.getMatchingStacks()); + case CANNING_RECIPE -> ClassicRecipes.canningMachine.registerCannerItem(recipe.container, new RecipeInput( + recipe.input), + recipe.output); + case ITEM_EFFECT -> ClassicRecipes.canningMachine.registerItemsForEffect(recipe.intValue, recipe.input + .getMatchingStacks()); case FUEL_VALUE -> { for (ItemStack stack : recipe.input.getMatchingStacks()) { ClassicRecipes.canningMachine.registerFuelValue(stack, recipe.intValue); @@ -265,13 +285,16 @@ private void add(CanningRecipe recipe) { } } } - case REPAIR -> ClassicRecipes.canningMachine.addRepairRecipe(recipe.damageItem, recipe.meta, new RecipeInput(recipe.input), recipe.intValue); + case REPAIR -> ClassicRecipes.canningMachine.addRepairRecipe(recipe.damageItem, recipe.meta, new RecipeInput( + recipe.input), + recipe.intValue); } } private void remove(CanningRecipe recipe) { switch (recipe.type) { - case CANNING_RECIPE -> ClassicRecipes.canningMachine.removeCanningRecipe(recipe.container, recipe.input.getMatchingStacks()[0]); + case CANNING_RECIPE -> ClassicRecipes.canningMachine.removeCanningRecipe(recipe.container, recipe.input + .getMatchingStacks()[0]); case ITEM_EFFECT -> ClassicRecipes.canningMachine.deleteEffectID(recipe.intValue, true); case FUEL_VALUE -> { for (ItemStack stack : recipe.input.getMatchingStacks()) { @@ -346,9 +369,6 @@ public CanningRecipe setDamageItem(ICustomDamageItem item) { } private enum RecipeType { - ITEM_EFFECT, - FUEL_VALUE, - CANNING_RECIPE, - REPAIR + ITEM_EFFECT, FUEL_VALUE, CANNING_RECIPE, REPAIR } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicCompressor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicCompressor.java index f868d0d04..a24618f4f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicCompressor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicCompressor.java @@ -1,40 +1,46 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.classic; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; import com.cleanroommc.groovyscript.compat.mods.ic2.exp.Compressor; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import ic2.api.classic.recipe.ClassicRecipes; import ic2.api.classic.recipe.machine.IMachineRecipeList; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; public class ClassicCompressor extends Compressor { @Override public void onReload() { removeScripted().forEach(recipe -> ClassicRecipes.compressor.removeRecipe(recipe.getInput())); - restoreFromBackup().forEach(recipe -> ClassicRecipes.compressor.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput().toArray()[0], String.valueOf(recipe.hashCode()))); + restoreFromBackup().forEach(recipe -> ClassicRecipes.compressor.addRecipe(recipe.getInput(), (ItemStack) recipe + .getOutput() + .toArray()[0], + String.valueOf(recipe.hashCode()))); } @Override public MachineRecipe> add(IIngredient input, ItemStack output) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Compressor recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Compressor recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); add(recipe); return recipe; } @@ -45,21 +51,20 @@ public MachineRecipe> add(IIngredient input, } public MachineRecipe> add(IIngredient input, ItemStack output, float xp) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Compressor recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Compressor recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } if (xp < 0) { - GroovyLog.msg("Error adding Industrialcraft 2 Compressor recipe") - .add("xp must not be negative, defaulting to zero") - .warn() - .post(); + GroovyLog.msg("Error adding Industrialcraft 2 Compressor recipe").add("xp must not be negative, defaulting to zero") + .warn().post(); xp = 0.0F; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); ClassicRecipes.compressor.addRecipe(recipe.getInput(), output, xp, String.valueOf(recipe.hashCode())); addScripted(recipe); return recipe; @@ -68,15 +73,14 @@ public MachineRecipe> add(IIngredient input, @Override public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft 2 Compressor recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Compressor recipe").add("output must not be empty").error().post(); return; } for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.compressor.getRecipeMap()) { if (ItemStack.areItemStacksEqual(entry.getOutput().getAllOutputs().get(0), output)) { - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry + .getOutput() + .getAllOutputs()); remove(recipe); } } @@ -85,21 +89,16 @@ public void removeByOutput(ItemStack output) { @Override public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Compressor recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Compressor recipe").add("input must not be empty").error().post(); return; } IMachineRecipeList.RecipeEntry entry = ClassicRecipes.compressor.getRecipeInAndOutput(input, false); if (entry == null) { - GroovyLog.msg("Error removing Industrialcraft 2 Compressor recipe") - .add("no recipes found for", input) - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Compressor recipe").add("no recipes found for", input).error().post(); return; } - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput() + .getAllOutputs()); ClassicRecipes.compressor.removeRecipe(entry); addBackup(recipe); } @@ -112,14 +111,16 @@ public boolean remove(IMachineRecipeList.RecipeEntry entry) { @Override public void removeAll() { for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.compressor.getRecipeMap()) { - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput() + .getAllOutputs()); remove(recipe); } } @Override public void add(MachineRecipe> recipe) { - ClassicRecipes.compressor.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput().toArray()[0], String.valueOf(recipe.hashCode())); + ClassicRecipes.compressor.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput().toArray()[0], String.valueOf(recipe + .hashCode())); addScripted(recipe); } @@ -133,7 +134,8 @@ public boolean remove(MachineRecipe> recipe) protected List>> asList() { List>> list = new ArrayList<>(); for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.compressor.getRecipeMap()) { - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput() + .getAllOutputs()); list.add(recipe); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicElectrolyzer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicElectrolyzer.java index 5a123c573..3ff08e8f3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicElectrolyzer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicElectrolyzer.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.classic; +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.classic.recipe.ClassicRecipes; import ic2.api.classic.recipe.machine.IElectrolyzerRecipeList; -import net.minecraft.item.ItemStack; public class ClassicElectrolyzer extends VirtualizedRegistry { @@ -23,12 +25,11 @@ public void onReload() { } public ElectrolyzerRecipe addBoth(ItemStack output, IIngredient input, int energy) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Electrolyzer recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .add(energy <= 0, () -> "energy must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Electrolyzer recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .add(energy <= 0, () -> "energy must be higher than zero").error().postIfNotEmpty()) { return null; } ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(RecipeType.BOTH, input, output, energy); @@ -38,12 +39,11 @@ public ElectrolyzerRecipe addBoth(ItemStack output, IIngredient input, int energ } public ElectrolyzerRecipe addCharge(ItemStack output, IIngredient input, int energy) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Electrolyzer recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .add(energy <= 0, () -> "energy must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Electrolyzer recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .add(energy <= 0, () -> "energy must be higher than zero").error().postIfNotEmpty()) { return null; } ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(RecipeType.CHARGE, input, output, energy); @@ -53,12 +53,11 @@ public ElectrolyzerRecipe addCharge(ItemStack output, IIngredient input, int ene } public ElectrolyzerRecipe addDischarge(ItemStack output, IIngredient input, int energy) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Electrolyzer recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .add(energy <= 0, () -> "energy must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Electrolyzer recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .add(energy <= 0, () -> "energy must be higher than zero").error().postIfNotEmpty()) { return null; } ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(RecipeType.DISCHARGE, input, output, energy); @@ -73,53 +72,49 @@ public SimpleObjectStream streamRecipes() { public boolean removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe").add("output must not be empty").error().post(); return false; } for (IElectrolyzerRecipeList.RecipeEntry entry : ClassicRecipes.electrolyzer.getRecipeList()) { if (ItemStack.areItemStacksEqual(entry.getOutput(), output)) { - ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(getFromEntry(entry), IngredientHelper.toIIngredient(entry.getInput()), entry.getOutput(), entry.getEnergy()); + ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(getFromEntry(entry), IngredientHelper.toIIngredient(entry + .getInput()), + entry.getOutput(), entry.getEnergy()); remove(recipe); addBackup(recipe); return true; } } - GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe") - .add("no recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe").add("no recipes found for {}", output).error() + .post(); return false; } public boolean removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe").add("input must not be empty").error().post(); return false; } for (IElectrolyzerRecipeList.RecipeEntry entry : ClassicRecipes.electrolyzer.getRecipeList()) { if (ItemStack.areItemStacksEqual(entry.getInput(), input)) { - ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(getFromEntry(entry), IngredientHelper.toIIngredient(entry.getInput()), entry.getOutput(), entry.getEnergy()); + ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(getFromEntry(entry), IngredientHelper.toIIngredient(entry + .getInput()), + entry.getOutput(), entry.getEnergy()); remove(recipe); addBackup(recipe); return true; } } - GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe") - .add("no recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe").add("no recipes found for {}", input).error() + .post(); return false; } public void removeAll() { for (IElectrolyzerRecipeList.RecipeEntry entry : ClassicRecipes.electrolyzer.getRecipeList()) { - ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(getFromEntry(entry), IngredientHelper.toIIngredient(entry.getInput()), entry.getOutput(), entry.getEnergy()); + ElectrolyzerRecipe recipe = new ElectrolyzerRecipe(getFromEntry(entry), IngredientHelper.toIIngredient(entry + .getInput()), + entry.getOutput(), entry.getEnergy()); remove(recipe); addBackup(recipe); } @@ -129,17 +124,20 @@ private void add(ElectrolyzerRecipe recipe) { switch (recipe.type) { case CHARGE -> { for (ItemStack stack : recipe.input.getMatchingStacks()) { - ClassicRecipes.electrolyzer.addChargeRecipe(stack, recipe.output, recipe.energy, String.valueOf(recipe.hashCode())); + ClassicRecipes.electrolyzer.addChargeRecipe(stack, recipe.output, recipe.energy, String.valueOf(recipe + .hashCode())); } } case DISCHARGE -> { for (ItemStack stack : recipe.input.getMatchingStacks()) { - ClassicRecipes.electrolyzer.addDischargeRecipe(stack, recipe.output, recipe.energy, String.valueOf(recipe.hashCode())); + ClassicRecipes.electrolyzer.addDischargeRecipe(stack, recipe.output, recipe.energy, String.valueOf(recipe + .hashCode())); } } case BOTH -> { for (ItemStack stack : recipe.input.getMatchingStacks()) { - ClassicRecipes.electrolyzer.addBothRecipe(stack, recipe.output, recipe.energy, String.valueOf(recipe.hashCode())); + ClassicRecipes.electrolyzer.addBothRecipe(stack, recipe.output, recipe.energy, String.valueOf(recipe + .hashCode())); } } } @@ -192,8 +190,6 @@ private RecipeType getFromEntry(IElectrolyzerRecipeList.RecipeEntry entry) { } private enum RecipeType { - CHARGE, - DISCHARGE, - BOTH + CHARGE, DISCHARGE, BOTH } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicExtractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicExtractor.java index ba6fc9f5c..fdcb349e9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicExtractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicExtractor.java @@ -1,66 +1,71 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.classic; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; import com.cleanroommc.groovyscript.compat.mods.ic2.exp.Extractor; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import ic2.api.classic.recipe.ClassicRecipes; import ic2.api.classic.recipe.machine.IMachineRecipeList; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; public class ClassicExtractor extends Extractor { @Override public void onReload() { removeScripted().forEach(recipe -> ClassicRecipes.extractor.removeRecipe(recipe.getInput())); - restoreFromBackup().forEach(recipe -> ClassicRecipes.extractor.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput().toArray()[0], String.valueOf(recipe.hashCode()))); + restoreFromBackup().forEach(recipe -> ClassicRecipes.extractor.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput() + .toArray()[0], + String.valueOf(recipe.hashCode()))); } @Override public void add(MachineRecipe> recipe) { - ClassicRecipes.extractor.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput().toArray()[0], String.valueOf(recipe.hashCode())); + ClassicRecipes.extractor.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput().toArray()[0], String.valueOf(recipe + .hashCode())); addScripted(recipe); } @Override public MachineRecipe> add(IIngredient input, ItemStack output) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Extractor recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Extractor recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); add(recipe); return recipe; } public MachineRecipe> add(IIngredient input, ItemStack output, float xp) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Extractor recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Extractor recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } if (xp < 0) { - GroovyLog.msg("Error adding Industrialcraft 2 Extractor recipe") - .add("xp must not be negative, defaulting to zero") - .warn() - .post(); + GroovyLog.msg("Error adding Industrialcraft 2 Extractor recipe").add("xp must not be negative, defaulting to zero") + .warn().post(); xp = 0.0F; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); ClassicRecipes.extractor.addRecipe(recipe.getInput(), output, xp, String.valueOf(recipe.hashCode())); addScripted(recipe); return recipe; @@ -74,14 +79,12 @@ public MachineRecipe> add(IIngredient input, @Override public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft 2 Extractor recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Extractor recipe").add("output must not be empty").error().post(); return; } for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.extractor.getRecipeMap()) { - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput() + .getAllOutputs()); if (ItemStack.areItemStacksEqual(entry.getOutput().getAllOutputs().get(0), output)) { remove(recipe); } @@ -91,21 +94,16 @@ public void removeByOutput(ItemStack output) { @Override public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Extractor recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Extractor recipe").add("input must not be empty").error().post(); return; } IMachineRecipeList.RecipeEntry entry = ClassicRecipes.extractor.getRecipeInAndOutput(input, false); if (entry == null) { - GroovyLog.msg("Error removing Industrialcraft 2 Extractor recipe") - .add("no recipes found for", input) - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Extractor recipe").add("no recipes found for", input).error().post(); return; } - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput() + .getAllOutputs()); ClassicRecipes.extractor.removeRecipe(entry); addBackup(recipe); } @@ -118,7 +116,8 @@ public boolean remove(IMachineRecipeList.RecipeEntry entry) { @Override public void removeAll() { for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.extractor.getRecipeMap()) { - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput() + .getAllOutputs()); remove(recipe); } } @@ -134,7 +133,8 @@ public boolean remove(MachineRecipe> recipe) protected List>> asList() { List>> list = new ArrayList<>(); for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.extractor.getRecipeMap()) { - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput() + .getAllOutputs()); list.add(recipe); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicMacerator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicMacerator.java index 15bd09c87..0760a7984 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicMacerator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicMacerator.java @@ -1,60 +1,64 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.classic; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; import com.cleanroommc.groovyscript.compat.mods.ic2.exp.Macerator; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import ic2.api.classic.recipe.ClassicRecipes; import ic2.api.classic.recipe.machine.IMachineRecipeList; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; public class ClassicMacerator extends Macerator { @Override public void onReload() { removeScripted().forEach(recipe -> ClassicRecipes.macerator.removeRecipe(recipe.getInput())); - restoreFromBackup().forEach(recipe -> ClassicRecipes.macerator.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput().toArray()[0], String.valueOf(recipe.hashCode()))); + restoreFromBackup().forEach(recipe -> ClassicRecipes.macerator.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput() + .toArray()[0], + String.valueOf(recipe.hashCode()))); } @Override public MachineRecipe> add(ItemStack output, IIngredient input) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Macerator recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Macerator recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); add(recipe); return recipe; } public MachineRecipe> add(ItemStack output, IIngredient input, float xp) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Macerator recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Macerator recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } if (xp < 0) { - GroovyLog.msg("Error adding Industrialcraft 2 Macerator recipe") - .add("xp must not be negative, defaulting to zero") - .warn() - .post(); + GroovyLog.msg("Error adding Industrialcraft 2 Macerator recipe").add("xp must not be negative, defaulting to zero") + .warn().post(); xp = 0.0F; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); ClassicRecipes.macerator.addRecipe(recipe.getInput(), output, xp, String.valueOf(recipe.hashCode())); addScripted(recipe); return recipe; @@ -73,15 +77,14 @@ public boolean remove(IMachineRecipeList.RecipeEntry entry) { @Override public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft 2 Macerator recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Macerator recipe").add("output must not be empty").error().post(); return; } for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.macerator.getRecipeMap()) { if (ItemStack.areItemStacksEqual(entry.getOutput().getAllOutputs().get(0), output)) { - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry + .getOutput() + .getAllOutputs()); remove(recipe); } } @@ -90,21 +93,16 @@ public void removeByOutput(ItemStack output) { @Override public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Macerator recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Macerator recipe").add("input must not be empty").error().post(); return; } IMachineRecipeList.RecipeEntry entry = ClassicRecipes.macerator.getRecipeInAndOutput(input, false); if (entry == null) { - GroovyLog.msg("Error removing Industrialcraft 2 Macerator recipe") - .add("no recipes found for", input) - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Macerator recipe").add("no recipes found for", input).error().post(); return; } - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput() + .getAllOutputs()); ClassicRecipes.macerator.removeRecipe(entry); addBackup(recipe); } @@ -112,7 +110,8 @@ public void removeByInput(ItemStack input) { @Override public void removeAll() { for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.macerator.getRecipeMap()) { - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput() + .getAllOutputs()); remove(recipe); } } @@ -120,7 +119,8 @@ public void removeAll() { @Override public void add(MachineRecipe> recipe) { addScripted(recipe); - ClassicRecipes.macerator.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput().toArray()[0], String.valueOf(recipe.hashCode())); + ClassicRecipes.macerator.addRecipe(recipe.getInput(), (ItemStack) recipe.getOutput().toArray()[0], String.valueOf(recipe + .hashCode())); } @Override @@ -133,7 +133,8 @@ public boolean remove(MachineRecipe> recipe) protected List>> asList() { List>> list = new ArrayList<>(); for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.macerator.getRecipeMap()) { - MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput().getAllOutputs()); + MachineRecipe> recipe = new MachineRecipe<>(entry.getInput(), entry.getOutput() + .getAllOutputs()); list.add(recipe); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicScrapbox.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicScrapbox.java index a0ddc0270..df44598aa 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicScrapbox.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/ClassicScrapbox.java @@ -1,19 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.classic; +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.compat.mods.ic2.exp.Scrapbox; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import ic2.api.classic.recipe.ClassicRecipes; import ic2.api.classic.recipe.custom.IClassicScrapBoxManager; -import net.minecraft.item.ItemStack; public class ClassicScrapbox extends Scrapbox { @Override public void onReload() { removeScripted().forEach(drop -> ClassicRecipes.scrapboxDrops.removeDrop(getDrop(((Drop) drop).stack))); - restoreFromBackup().forEach(drop -> ClassicRecipes.scrapboxDrops.addDrop(((IClassicScrapBoxManager.IDrop) drop).getDrop(), ((IClassicScrapBoxManager.IDrop) drop).getChance())); + restoreFromBackup().forEach(drop -> ClassicRecipes.scrapboxDrops.addDrop(((IClassicScrapBoxManager.IDrop) drop).getDrop(), + ((IClassicScrapBoxManager.IDrop) drop).getChance())); } public void add(IClassicScrapBoxManager.IDrop drop) { @@ -23,11 +26,10 @@ public void add(IClassicScrapBoxManager.IDrop drop) { @Override public void add(ItemStack stack, float chance) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Scrapbox recipe") - .add(IngredientHelper.isEmpty(stack), () -> "stack must not be emtpy") - .add(chance <= 0, () -> "chance must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Scrapbox recipe").add(IngredientHelper.isEmpty(stack), + () -> "stack must not be emtpy").add(chance <= 0, + () -> "chance must be higher than zero") + .error().postIfNotEmpty()) { return; } ClassicRecipes.scrapboxDrops.addDrop(stack, chance); @@ -45,10 +47,7 @@ public void remove(IClassicScrapBoxManager.IDrop drop) { public boolean remove(ItemStack stack) { if (IngredientHelper.isEmpty(stack)) { - GroovyLog.msg("Error removing Industrialcraft 2 Scrapbox recipe") - .add("stack must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Scrapbox recipe").add("stack must not be empty").error().post(); return false; } for (IClassicScrapBoxManager.IDrop drop : ClassicRecipes.scrapboxDrops.getEntries()) { @@ -57,10 +56,7 @@ public boolean remove(ItemStack stack) { return true; } } - GroovyLog.msg("Error removing Industrialcraft 2 Scrapbox recipe") - .add("no recipes found for {}", stack) - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Scrapbox recipe").add("no recipes found for {}", stack).error().post(); return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/LiquidFuelGenerator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/LiquidFuelGenerator.java index af175f8bd..0e766d566 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/LiquidFuelGenerator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/LiquidFuelGenerator.java @@ -1,16 +1,18 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.classic; +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.classic.recipe.ClassicRecipes; import ic2.api.classic.recipe.custom.ILiquidFuelGeneratorRegistry; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import java.util.Map; public class LiquidFuelGenerator extends VirtualizedRegistry { @@ -30,12 +32,10 @@ public void add(LFGRecipe recipe) { } public LFGRecipe add(FluidStack fluid, int burnTicks, float euPerTick) { - if (GroovyLog.msg("Error adding Fluid Generator recipe") - .add(IngredientHelper.isEmpty(fluid), () -> "fluid must not be empty") - .add(burnTicks <= 0, () -> "burnTicks must be higher than zero") - .add(euPerTick <= 0, () -> "euPerTick must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Fluid Generator recipe").add(IngredientHelper.isEmpty(fluid), + () -> "fluid must not be empty").add(burnTicks <= 0, + () -> "burnTicks must be higher than zero") + .add(euPerTick <= 0, () -> "euPerTick must be higher than zero").error().postIfNotEmpty()) { return null; } LFGRecipe recipe = new LFGRecipe(fluid, burnTicks, euPerTick); @@ -45,10 +45,7 @@ public LFGRecipe add(FluidStack fluid, int burnTicks, float euPerTick) { public boolean remove(FluidStack fluid) { if (IngredientHelper.isEmpty(fluid)) { - GroovyLog.msg("Error removing Liquid Fuel Generator recipe") - .add("fluid must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Liquid Fuel Generator recipe").add("fluid must not be empty").error().post(); return false; } return remove(fluid.getFluid()); @@ -56,18 +53,12 @@ public boolean remove(FluidStack fluid) { public boolean remove(Fluid fluid) { if (fluid == null) { - GroovyLog.msg("Error removing Liquid Fuel Generator recipe") - .add("fluid must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Liquid Fuel Generator recipe").add("fluid must not be empty").error().post(); return false; } ILiquidFuelGeneratorRegistry.BurnEntry entry = ClassicRecipes.fluidGenerator.getBurnEntry(fluid); if (entry == null) { - GroovyLog.msg("Error removing Liquid Fuel Generator recipe") - .add("no recipes found for {}", fluid) - .error() - .post(); + GroovyLog.msg("Error removing Liquid Fuel Generator recipe").add("no recipes found for {}", fluid).error().post(); return false; } remove(new LFGRecipe(fluid, entry.getTicksLast(), entry.getProduction())); @@ -75,7 +66,8 @@ public boolean remove(Fluid fluid) { } public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ClassicRecipes.fluidGenerator.getBurnMap().entrySet()).setRemover(r -> remove(r.getKey())); + return new SimpleObjectStream<>(ClassicRecipes.fluidGenerator.getBurnMap().entrySet()).setRemover(r -> remove(r + .getKey())); } public void remove(LFGRecipe recipe) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/RareEarthExtractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/RareEarthExtractor.java index f7d655774..47f60d00e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/RareEarthExtractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/RareEarthExtractor.java @@ -1,20 +1,23 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.classic; +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.classic.recipe.ClassicRecipes; import ic2.api.classic.recipe.machine.IRareEarthExtractorRecipeList; -import net.minecraft.item.ItemStack; public class RareEarthExtractor extends VirtualizedRegistry { @Override public void onReload() { removeScripted().forEach(recipe -> ClassicRecipes.earthExtractor.removeEntry(recipe.getItem())); - restoreFromBackup().forEach(recipe -> ClassicRecipes.earthExtractor.registerValue(recipe.getEarthValue(), recipe.getItem())); + restoreFromBackup().forEach(recipe -> ClassicRecipes.earthExtractor.registerValue(recipe.getEarthValue(), recipe + .getItem())); } public void add(IRareEarthExtractorRecipeList.EarthEntry entry) { @@ -23,11 +26,11 @@ public void add(IRareEarthExtractorRecipeList.EarthEntry entry) { } public void add(IIngredient input, float value) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Rare Earth Extractor recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(value <= 0, () -> "value must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Rare Earth Extractor recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + value <= 0, + () -> "value must be higher than zero") + .error().postIfNotEmpty()) { return; } for (ItemStack stack : input.getMatchingStacks()) { @@ -42,10 +45,7 @@ public SimpleObjectStream streamRecipe public boolean remove(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Rare Earth Extractor recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Rare Earth Extractor recipe").add("input must not be empty").error().post(); return false; } for (IRareEarthExtractorRecipeList.EarthEntry entry : ClassicRecipes.earthExtractor.getRecipeList()) { @@ -54,10 +54,7 @@ public boolean remove(ItemStack input) { return true; } } - GroovyLog.msg("Error removing Rare Earth Extractor recipe") - .add("no recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Rare Earth Extractor recipe").add("no recipes found for {}", input).error().post(); return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/Sawmill.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/Sawmill.java index bfb4d48b2..44ceeb5d6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/Sawmill.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/classic/Sawmill.java @@ -1,55 +1,62 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.classic; +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.classic.recipe.ClassicRecipes; import ic2.api.classic.recipe.machine.IMachineRecipeList; import ic2.api.classic.recipe.machine.MachineExpOutput; import ic2.api.classic.recipe.machine.MachineOutput; -import net.minecraft.item.ItemStack; public class Sawmill extends VirtualizedRegistry { @Override public void onReload() { removeScripted().forEach(recipe -> ClassicRecipes.sawMill.removeRecipe(recipe)); - restoreFromBackup().forEach(recipe -> ClassicRecipes.sawMill.addRecipe(recipe.getInput(), recipe.getOutput(), String.valueOf(recipe.hashCode()))); + restoreFromBackup().forEach(recipe -> ClassicRecipes.sawMill.addRecipe(recipe.getInput(), recipe.getOutput(), String + .valueOf(recipe.hashCode()))); } public IMachineRecipeList.RecipeEntry add(ItemStack output, IIngredient input) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Sawmill recipe") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Sawmill recipe").add(IngredientHelper.isEmpty(output), + () -> "output must not be empty").add( + IngredientHelper.isEmpty(input), + () -> "input must not be empty") + .error().postIfNotEmpty()) { return null; } - IMachineRecipeList.RecipeEntry entry = new IMachineRecipeList.RecipeEntry(new RecipeInput(input), new MachineOutput(null, output), String.valueOf(output.hashCode())); + IMachineRecipeList.RecipeEntry entry = new IMachineRecipeList.RecipeEntry(new RecipeInput(input), new MachineOutput(null, + output), + String.valueOf(output.hashCode())); ClassicRecipes.sawMill.addRecipe(entry.getInput(), entry.getOutput(), entry.getRecipeID()); addScripted(entry); return entry; } public IMachineRecipeList.RecipeEntry add(ItemStack output, IIngredient input, float xp) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Sawmill recipe") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Sawmill recipe").add(IngredientHelper.isEmpty(output), + () -> "output must not be empty").add( + IngredientHelper.isEmpty(input), + () -> "input must not be empty") + .error().postIfNotEmpty()) { return null; } if (xp < 0) { - GroovyLog.msg("Error adding Industrialcraft 2 Sawmill recipe") - .add("xp must not be negative, defaulting to zero") - .warn() - .post(); + GroovyLog.msg("Error adding Industrialcraft 2 Sawmill recipe").add("xp must not be negative, defaulting to zero") + .warn().post(); xp = 0.0F; } - IMachineRecipeList.RecipeEntry entry = new IMachineRecipeList.RecipeEntry(new RecipeInput(input), new MachineExpOutput(null, xp, output), String.valueOf(output.hashCode())); + IMachineRecipeList.RecipeEntry entry = new IMachineRecipeList.RecipeEntry(new RecipeInput(input), new MachineExpOutput( + null, + xp, + output), + String.valueOf(output.hashCode())); ClassicRecipes.sawMill.addRecipe(entry.getInput(), entry.getOutput(), entry.getRecipeID()); addScripted(entry); return entry; @@ -66,10 +73,7 @@ public boolean remove(IMachineRecipeList.RecipeEntry entry) { public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft Sawmill recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft Sawmill recipe").add("output must not be empty").error().post(); return; } for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.sawMill.getRecipeMap()) { @@ -81,10 +85,7 @@ public void removeByOutput(ItemStack output) { public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft Sawmill recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft Sawmill recipe").add("input must not be empty").error().post(); return; } for (IMachineRecipeList.RecipeEntry entry : ClassicRecipes.sawMill.getRecipeMap()) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/BlastFurnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/BlastFurnace.java index ee63a9064..5d6981adf 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/BlastFurnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/BlastFurnace.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.IC2; @@ -7,16 +15,10 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; public class BlastFurnace extends VirtualizedRegistry>> { @@ -31,11 +33,11 @@ public void add(MachineRecipe> recipe) { } public MachineRecipe> add(IIngredient input, List output) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Blast Furnace recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IC2.isNull(output), () -> "output must not be null") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Blast Furnace recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add(IC2 + .isNull(output), + () -> "output must not be null") + .error().postIfNotEmpty()) { return null; } MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), output); @@ -44,11 +46,11 @@ public MachineRecipe> add(IIngredient input, } public MachineRecipe> add(IIngredient input, List output, NBTTagCompound tag) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Blast Furnace recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IC2.isNull(output), () -> "output must not be null") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Blast Furnace recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add(IC2 + .isNull(output), + () -> "output must not be null") + .error().postIfNotEmpty()) { return null; } MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), output, tag); @@ -66,13 +68,12 @@ public boolean remove(MachineRecipe> recipe) public void removeByOutput(ItemStack... outputs) { if (outputs == null || outputs.length < 1) { - GroovyLog.msg("Error removing Industrialcraft 2 Blast Furnace recipe") - .add("outputs must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Blast Furnace recipe").add("outputs must not be empty").error() + .post(); return; } - for (Iterator>> iterator = Recipes.blastfurnace.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.blastfurnace.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> recipe = iterator.next(); if (recipe.getOutput().size() == outputs.length) { @@ -93,13 +94,11 @@ public void removeByOutput(ItemStack... outputs) { public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Blast Furnace recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Blast Furnace recipe").add("input must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.blastfurnace.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.blastfurnace.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(input)) { iterator.remove(); @@ -109,7 +108,8 @@ public void removeByInput(ItemStack input) { } public void removeAll() { - for (Iterator>> iterator = Recipes.blastfurnace.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.blastfurnace.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); iterator.remove(); addBackup(rec); @@ -117,7 +117,8 @@ public void removeAll() { } private boolean remove(MachineRecipe> recipe, boolean backup) { - for (Iterator>> iterator = Recipes.blastfurnace.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.blastfurnace.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(recipe.getInput().getInputs().get(0))) { iterator.remove(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/BlockCutter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/BlockCutter.java index 7fc48c947..dad3b392f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/BlockCutter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/BlockCutter.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.*; + +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; @@ -7,12 +11,10 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; - -import java.util.*; public class BlockCutter extends VirtualizedRegistry>> { @@ -31,14 +33,15 @@ public void add(MachineRecipe> recipe) { } public MachineRecipe> add(IIngredient input, ItemStack output) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Block Cutter recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Block Cutter recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); add(recipe); return recipe; } @@ -53,13 +56,11 @@ public boolean remove(MachineRecipe> recipe) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft 2 Block Cutter recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Block Cutter recipe").add("output must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.blockcutter.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.blockcutter.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (ItemStack.areItemStacksEqual((ItemStack) rec.getOutput().toArray()[0], output)) { iterator.remove(); @@ -70,13 +71,11 @@ public void removeByOutput(ItemStack output) { public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Block Cutter recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Block Cutter recipe").add("input must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.blockcutter.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.blockcutter.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(input)) { iterator.remove(); @@ -86,7 +85,8 @@ public void removeByInput(ItemStack input) { } public void removeAll() { - for (Iterator>> iterator = Recipes.blockcutter.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.blockcutter.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); iterator.remove(); addBackup(rec); @@ -94,7 +94,8 @@ public void removeAll() { } private boolean remove(MachineRecipe> recipe, boolean backup) { - for (Iterator>> iterator = Recipes.blockcutter.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.blockcutter.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(recipe.getInput().getInputs().get(0))) { iterator.remove(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Compressor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Compressor.java index f9e5f93e8..12ecea878 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Compressor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Compressor.java @@ -1,18 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.*; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.*; public class Compressor extends VirtualizedRegistry>> { @@ -27,27 +29,30 @@ public void add(MachineRecipe> recipe) { } public MachineRecipe> add(IIngredient input, ItemStack output) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Compressor recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Compressor recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); add(recipe); return recipe; } public MachineRecipe> add(IIngredient input, ItemStack output, NBTTagCompound tag) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Compressor recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Compressor recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output), tag); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output), + tag); add(recipe); return recipe; } @@ -62,13 +67,11 @@ public boolean remove(MachineRecipe> recipe) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft 2 Compressor recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Compressor recipe").add("output must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.compressor.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.compressor.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (ItemStack.areItemStacksEqual((ItemStack) rec.getOutput().toArray()[0], output)) { iterator.remove(); @@ -79,7 +82,8 @@ public void removeByOutput(ItemStack output) { public void removeByInput(ItemStack input) { if (!IngredientHelper.isEmpty(input)) { - for (Iterator>> iterator = Recipes.compressor.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.compressor.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(input)) { iterator.remove(); @@ -87,15 +91,13 @@ public void removeByInput(ItemStack input) { } } } else { - GroovyLog.msg("Error removing Industrialcraft 2 Compressor recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Compressor recipe").add("input must not be empty").error().post(); } } public void removeAll() { - for (Iterator>> iterator = Recipes.compressor.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.compressor.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); iterator.remove(); addBackup(rec); @@ -103,7 +105,8 @@ public void removeAll() { } private boolean remove(MachineRecipe> recipe, boolean backup) { - for (Iterator>> iterator = Recipes.compressor.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.compressor.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(recipe.getInput().getInputs().get(0))) { iterator.remove(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Electrolyzer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Electrolyzer.java index 700ccd75b..d3b624802 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Electrolyzer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Electrolyzer.java @@ -1,20 +1,23 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import net.minecraft.util.EnumFacing; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.core.mixin.ic2.ElectrolyzerRecipeManagerAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IElectrolyzerRecipeManager; import ic2.api.recipe.Recipes; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; public class Electrolyzer extends VirtualizedRegistry> { @@ -25,12 +28,14 @@ public void onReload() { restoreFromBackup().forEach(pair -> add(pair.getKey(), pair.getValue(), false)); } - public Pair add(String name, IElectrolyzerRecipeManager.ElectrolyzerRecipe recipe) { + public Pair add(String name, + IElectrolyzerRecipeManager.ElectrolyzerRecipe recipe) { return add(name, recipe, true); } public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(Recipes.electrolyzer.getRecipeMap().entrySet()).setRemover(r -> remove(r.getKey(), r.getValue())); + return new SimpleObjectStream<>(Recipes.electrolyzer.getRecipeMap().entrySet()).setRemover(r -> remove(r.getKey(), r + .getValue())); } public boolean remove(String name, IElectrolyzerRecipeManager.ElectrolyzerRecipe recipe) { @@ -43,32 +48,33 @@ public boolean remove(String name, IElectrolyzerRecipeManager.ElectrolyzerRecipe return false; } - public Pair add(FluidStack input, int euATick, int ticksNeeded, FluidStack... outputs) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Electrolyzer recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(euATick <= 0, () -> "energy per tick must be higher than zero") - .add(ticksNeeded <= 0, () -> "recipe time must be higher than zero") - .add(outputs == null || outputs.length <= 0, () -> "outputs must not be null") - .error() - .postIfNotEmpty()) { + public Pair add(FluidStack input, int euATick, int ticksNeeded, + FluidStack... outputs) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Electrolyzer recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + euATick <= 0, + () -> "energy per tick must be higher than zero") + .add(ticksNeeded <= 0, () -> "recipe time must be higher than zero").add( + outputs == null || outputs.length <= 0, + () -> "outputs must not be null") + .error().postIfNotEmpty()) { return null; } List list = new ArrayList<>(); for (int i = 0; i < outputs.length; i++) { FluidStack fs = outputs[i]; - if (fs != null) - list.add(new IElectrolyzerRecipeManager.ElectrolyzerOutput(fs.getFluid().getName(), fs.amount, EnumFacing.values()[i])); + if (fs != null) list.add(new IElectrolyzerRecipeManager.ElectrolyzerOutput(fs.getFluid().getName(), fs.amount, + EnumFacing.values()[i])); } - return add(input.getFluid().getName(), new IElectrolyzerRecipeManager.ElectrolyzerRecipe(input.amount, euATick, ticksNeeded, list.toArray(new IElectrolyzerRecipeManager.ElectrolyzerOutput[0]))); + return add(input.getFluid().getName(), new IElectrolyzerRecipeManager.ElectrolyzerRecipe(input.amount, euATick, + ticksNeeded, list.toArray( + new IElectrolyzerRecipeManager.ElectrolyzerOutput[0]))); } public void removeByOutput(FluidStack... outputs) { if (outputs == null || outputs.length < 1) { - GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe") - .add("outputs must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe").add("outputs must not be empty").error().post(); return; } Map fluidMap = ((ElectrolyzerRecipeManagerAccessor) Recipes.electrolyzer).getFluidMap(); @@ -87,10 +93,7 @@ public void removeByOutput(FluidStack... outputs) { public void removeByInput(FluidStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Electrolyzer recipe").add("input must not be empty").error().post(); return; } Map fluidMap = ((ElectrolyzerRecipeManagerAccessor) Recipes.electrolyzer).getFluidMap(); @@ -106,7 +109,9 @@ public void removeAll() { } } - private Pair add(String name, IElectrolyzerRecipeManager.ElectrolyzerRecipe recipe, boolean scripted) { + private Pair add(String name, + IElectrolyzerRecipeManager.ElectrolyzerRecipe recipe, + boolean scripted) { Pair pair = Pair.of(name, recipe); Recipes.electrolyzer.addRecipe(name, recipe.inputAmount, recipe.EUaTick, recipe.ticksNeeded, recipe.outputs); if (scripted) addScripted(pair); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Extractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Extractor.java index b93a4ac4f..6fe3eed7c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Extractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Extractor.java @@ -1,18 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.*; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.*; public class Extractor extends VirtualizedRegistry>> { @@ -27,27 +29,30 @@ public void add(MachineRecipe> recipe) { } public MachineRecipe> add(IIngredient input, ItemStack output) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Extractor recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Extractor recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); add(recipe); return recipe; } public MachineRecipe> add(IIngredient input, ItemStack output, NBTTagCompound tag) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Extractor recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Extractor recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output), tag); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output), + tag); add(recipe); return recipe; } @@ -62,13 +67,11 @@ public boolean remove(MachineRecipe> recipe) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft 2 Extractor recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Extractor recipe").add("output must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.extractor.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.extractor.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (ItemStack.areItemStacksEqual((ItemStack) rec.getOutput().toArray()[0], output)) { iterator.remove(); @@ -79,13 +82,11 @@ public void removeByOutput(ItemStack output) { public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Extractor recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Extractor recipe").add("input must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.extractor.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.extractor.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(input)) { iterator.remove(); @@ -95,7 +96,8 @@ public void removeByInput(ItemStack input) { } public void removeAll() { - for (Iterator>> iterator = Recipes.extractor.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.extractor.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); iterator.remove(); addBackup(rec); @@ -103,7 +105,8 @@ public void removeAll() { } private boolean remove(MachineRecipe> recipe, boolean backup) { - for (Iterator>> iterator = Recipes.extractor.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.extractor.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(recipe.getInput().getInputs().get(0))) { iterator.remove(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Fermenter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Fermenter.java index 0f74ee40e..ed89e3791 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Fermenter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Fermenter.java @@ -1,17 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.Map; + +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.core.mixin.ic2.FermenterRecipeManagerAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IFermenterRecipeManager; import ic2.api.recipe.Recipes; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.Map; public class Fermenter extends VirtualizedRegistry> { @@ -23,15 +26,18 @@ public void onReload() { } public Pair add(FluidStack input, int heat, FluidStack output) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Fermenter recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(heat <= 0, () -> "heat must be higher than zero") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Fermenter recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add(heat <= 0, + () -> "heat must be higher than zero") + .add(IngredientHelper.isEmpty(output), () -> "output must not be empty").error().postIfNotEmpty()) { return null; } - Pair pair = Pair.of(input.getFluid().getName(), new IFermenterRecipeManager.FermentationProperty(input.amount, heat, output.getFluid().getName(), output.amount)); + Pair pair = Pair.of(input.getFluid().getName(), + new IFermenterRecipeManager.FermentationProperty(input.amount, + heat, + output.getFluid() + .getName(), + output.amount)); Recipes.fermenter.addRecipe(input.getFluid().getName(), input.amount, heat, output.getFluid().getName(), output.amount); addScripted(pair); return pair; @@ -49,10 +55,7 @@ public SimpleObjectStream fluidMap = ((FermenterRecipeManagerAccessor) Recipes.fermenter).getFluidMap(); @@ -85,10 +85,7 @@ public void removeAll() { public boolean remove(String input) { if (StringUtils.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Fermenter recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Fermenter recipe").add("input must not be empty").error().post(); return false; } Map fluidMap = ((FermenterRecipeManagerAccessor) Recipes.fermenter).getFluidMap(); @@ -97,10 +94,7 @@ public boolean remove(String input) { addBackup(Pair.of(input, property)); return true; } - GroovyLog.msg("Error removing Industrialcraft 2 Fermenter recipe") - .add("no recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Fermenter recipe").add("no recipes found for {}", input).error().post(); return false; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidCanner.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidCanner.java index 2659bc4c0..cd574e592 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidCanner.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidCanner.java @@ -1,21 +1,23 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.ICannerEnrichRecipeManager; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; public class FluidCanner extends VirtualizedRegistry> { @@ -29,13 +31,13 @@ public void add(MachineRecipe reci add(recipe, true); } - public MachineRecipe add(FluidStack input, IIngredient input1, FluidStack output) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Fluid Canner recipe") - .add(IngredientHelper.isEmpty(input), () -> "input 1 must not be empty") - .add(IngredientHelper.isEmpty(input1), () -> "input 2 must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + public MachineRecipe add(FluidStack input, IIngredient input1, + FluidStack output) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Fluid Canner recipe").add(IngredientHelper.isEmpty(input), + () -> "input 1 must not be empty").add( + IngredientHelper.isEmpty(input1), + () -> "input 2 must not be empty") + .add(IngredientHelper.isEmpty(output), () -> "output must not be empty").error().postIfNotEmpty()) { return null; } MachineRecipe recipe = create(input, input1, output, null); @@ -43,13 +45,13 @@ public MachineRecipe add(FluidStac return recipe; } - public MachineRecipe add(FluidStack input, IIngredient input1, FluidStack output, NBTTagCompound tag) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Fluid Canner recipe") - .add(IngredientHelper.isEmpty(input), () -> "input 1 must not be empty") - .add(IngredientHelper.isEmpty(input1), () -> "input 2 must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + public MachineRecipe add(FluidStack input, IIngredient input1, + FluidStack output, NBTTagCompound tag) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Fluid Canner recipe").add(IngredientHelper.isEmpty(input), + () -> "input 1 must not be empty").add( + IngredientHelper.isEmpty(input1), + () -> "input 2 must not be empty") + .add(IngredientHelper.isEmpty(output), () -> "output must not be empty").error().postIfNotEmpty()) { return null; } MachineRecipe recipe = create(input, input1, output, tag); @@ -67,13 +69,11 @@ public boolean remove(MachineRecipe> iterator = Recipes.cannerEnrich.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator> iterator = Recipes.cannerEnrich.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe rec = iterator.next(); if (rec.getOutput().isFluidEqual(output) && rec.getOutput().amount == output.amount) { iterator.remove(); @@ -83,14 +83,15 @@ public void removeByOutput(FluidStack output) { } public void removeByInput(FluidStack input, ItemStack input1) { - if (GroovyLog.msg("Error removing Industrialcraft 2 Fluid Canning recipe") - .add(IngredientHelper.isEmpty(input), () -> "fluid input must not be empty") - .add(IngredientHelper.isEmpty(input1), () -> "input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Industrialcraft 2 Fluid Canning recipe").add(IngredientHelper.isEmpty(input), + () -> "fluid input must not be empty").add( + IngredientHelper.isEmpty(input1), + () -> "input must not be empty") + .error().postIfNotEmpty()) { return; } - for (Iterator> iterator = Recipes.cannerEnrich.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator> iterator = Recipes.cannerEnrich.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe rec = iterator.next(); if (rec.getInput().fluid.getFluid() == input.getFluid() && rec.getInput().additive.matches(input1)) { iterator.remove(); @@ -100,7 +101,8 @@ public void removeByInput(FluidStack input, ItemStack input1) { } public void removeAll() { - for (Iterator> iterator = Recipes.cannerEnrich.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator> iterator = Recipes.cannerEnrich.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe rec = iterator.next(); iterator.remove(); addBackup(rec); @@ -108,7 +110,8 @@ public void removeAll() { } private boolean remove(MachineRecipe recipe, boolean backup) { - for (Iterator> iterator = Recipes.cannerEnrich.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator> iterator = Recipes.cannerEnrich.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe rec = iterator.next(); if (recipe.getInput().matches(rec.getInput().fluid, rec.getInput().additive.getInputs().get(0))) { iterator.remove(); @@ -125,7 +128,8 @@ private void add(MachineRecipe rec if (scripted) addScripted(recipe); } - private static MachineRecipe create(FluidStack input, IIngredient input1, FluidStack output, NBTTagCompound tag) { + private static MachineRecipe create(FluidStack input, IIngredient input1, + FluidStack output, NBTTagCompound tag) { return new MachineRecipe<>(new ICannerEnrichRecipeManager.Input(input, new RecipeInput(input1)), output, tag); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidGenerator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidGenerator.java index 5bd32b4dc..88f75b37a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidGenerator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidGenerator.java @@ -1,17 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.Map; + +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.core.mixin.ic2.SemiFluidFuelManagerAccessor; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.ISemiFluidFuelManager; import ic2.api.recipe.Recipes; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.Map; public class FluidGenerator extends VirtualizedRegistry> { @@ -27,15 +30,16 @@ public void onReload() { } public Pair add(FluidStack input, long energyPerMb, long energyPerTick) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Semi Fluid Generator recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(energyPerMb <= 0, () -> "energy per mb must be higher than zero") - .add(energyPerTick <= 0, () -> "energy per tick must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Semi Fluid Generator recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + energyPerMb <= 0, + () -> "energy per mb must be higher than zero") + .add(energyPerTick <= 0, () -> "energy per tick must be higher than zero").error().postIfNotEmpty()) { return null; } - Pair pair = Pair.of(input.getFluid().getName(), new ISemiFluidFuelManager.FuelProperty(energyPerMb, energyPerTick)); + Pair pair = Pair.of(input.getFluid().getName(), + new ISemiFluidFuelManager.FuelProperty(energyPerMb, + energyPerTick)); Recipes.semiFluidGenerator.addFluid(input.getFluid().getName(), energyPerMb, energyPerTick); addScripted(pair); return pair; @@ -50,15 +54,14 @@ public Pair add(String name, ISemiFl } public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(Recipes.semiFluidGenerator.getFuelProperties().entrySet()).setRemover(r -> remove(r.getKey())); + return new SimpleObjectStream<>(Recipes.semiFluidGenerator.getFuelProperties().entrySet()).setRemover(r -> remove(r + .getKey())); } public boolean remove(FluidStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Semi Fluid Generator recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Semi Fluid Generator recipe").add("input must not be empty").error() + .post(); return false; } return remove(input.getFluid().getName()); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidHeater.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidHeater.java index 6236caaf2..d178ea2f6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidHeater.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/FluidHeater.java @@ -1,18 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.Map; + +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IFluidHeatManager; import ic2.api.recipe.Recipes; import ic2.core.block.heatgenerator.tileentity.TileEntityFluidHeatGenerator; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.Map; public class FluidHeater extends VirtualizedRegistry> { @@ -27,11 +30,11 @@ public void onReload() { } public Pair add(FluidStack input, int heat) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Fluid Heat Generator recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(heat <= 0, () -> "heat must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Fluid Heat Generator recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + heat <= 0, + () -> "heat must be higher than zero") + .error().postIfNotEmpty()) { return null; } return add(input.getFluid().getName(), new IFluidHeatManager.BurnProperty(input.amount, heat)); @@ -45,15 +48,14 @@ public Pair add(String name, IFluidHeatM } public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(Recipes.fluidHeatGenerator.getBurnProperties().entrySet()).setRemover(r -> remove(r.getKey())); + return new SimpleObjectStream<>(Recipes.fluidHeatGenerator.getBurnProperties().entrySet()).setRemover(r -> remove(r + .getKey())); } public boolean remove(FluidStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Liquid Fuel Firebox recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Liquid Fuel Firebox recipe").add("input must not be empty").error() + .post(); return false; } return remove(input.getFluid().getName()); @@ -67,10 +69,8 @@ public void removeAll() { public boolean remove(String name) { if (StringUtils.isEmpty(name)) { - GroovyLog.msg("Error removing Industrialcraft 2 Liquid Fuel Firebox recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Liquid Fuel Firebox recipe").add("input must not be empty").error() + .post(); return false; } IFluidHeatManager.BurnProperty property = Recipes.fluidHeatGenerator.getBurnProperties().remove(name); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/LiquidHeatExchanger.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/LiquidHeatExchanger.java index f0cc49f62..349b0e1aa 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/LiquidHeatExchanger.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/LiquidHeatExchanger.java @@ -1,18 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.ILiquidHeatExchangerManager; import ic2.api.recipe.Recipes; import ic2.core.block.machine.tileentity.TileEntityLiquidHeatExchanger; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; - -import java.util.Map; public class LiquidHeatExchanger extends VirtualizedRegistry { @@ -29,20 +31,18 @@ public void onReload() { else cooldownMap.remove(recipe.hot.getName()); }); restoreFromBackup().forEach(recipe -> { - if (recipe.type == 0) - TileEntityLiquidHeatExchanger.addHeatupRecipe(recipe.hot.getName(), recipe.cold.getName(), recipe.huPerMB); - else - TileEntityLiquidHeatExchanger.addCooldownRecipe(recipe.hot.getName(), recipe.cold.getName(), recipe.huPerMB); + if (recipe.type == 0) TileEntityLiquidHeatExchanger.addHeatupRecipe(recipe.hot.getName(), recipe.cold.getName(), + recipe.huPerMB); + else TileEntityLiquidHeatExchanger.addCooldownRecipe(recipe.hot.getName(), recipe.cold.getName(), recipe.huPerMB); }); } public HeatExchangerRecipe add(FluidStack hotFluid, FluidStack coldFluid, int huPerMB) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Liquid Heat Exchanger recipe") - .add(IngredientHelper.isEmpty(hotFluid), () -> "hot fluid must not be empty") - .add(IngredientHelper.isEmpty(coldFluid), () -> "cold fluid must not be empty") - .add(huPerMB <= 0, () -> "heat per mb must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Liquid Heat Exchanger recipe").add(IngredientHelper.isEmpty(hotFluid), + () -> "hot fluid must not be empty") + .add(IngredientHelper.isEmpty(coldFluid), () -> "cold fluid must not be empty").add(huPerMB <= 0, + () -> "heat per mb must be higher than zero") + .error().postIfNotEmpty()) { return null; } addCooldown(hotFluid, coldFluid, huPerMB); @@ -50,30 +50,32 @@ public HeatExchangerRecipe add(FluidStack hotFluid, FluidStack coldFluid, int hu } public HeatExchangerRecipe addHeatup(FluidStack coldFluid, FluidStack hotFluid, int huPerMB) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Liquid Heat Exchanger recipe") - .add(IngredientHelper.isEmpty(hotFluid), () -> "hot fluid must not be empty") - .add(IngredientHelper.isEmpty(coldFluid), () -> "cold fluid must not be empty") - .add(huPerMB <= 0, () -> "heat per mb must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Liquid Heat Exchanger recipe").add(IngredientHelper.isEmpty(hotFluid), + () -> "hot fluid must not be empty") + .add(IngredientHelper.isEmpty(coldFluid), () -> "cold fluid must not be empty").add(huPerMB <= 0, + () -> "heat per mb must be higher than zero") + .error().postIfNotEmpty()) { return null; } - Recipes.liquidHeatupManager.getHeatExchangeProperties().put(coldFluid.getFluid().getName(), new ILiquidHeatExchangerManager.HeatExchangeProperty(hotFluid.getFluid(), huPerMB)); + Recipes.liquidHeatupManager.getHeatExchangeProperties().put(coldFluid.getFluid().getName(), + new ILiquidHeatExchangerManager.HeatExchangeProperty(hotFluid.getFluid(), + huPerMB)); HeatExchangerRecipe recipe = new HeatExchangerRecipe(0, hotFluid, coldFluid, huPerMB); addScripted(recipe); return recipe; } public HeatExchangerRecipe addCooldown(FluidStack hotFluid, FluidStack coldFluid, int huPerMB) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Liquid Heat Exchanger recipe") - .add(IngredientHelper.isEmpty(hotFluid), () -> "hot fluid must not be empty") - .add(IngredientHelper.isEmpty(coldFluid), () -> "cold fluid must not be empty") - .add(huPerMB <= 0, () -> "heat per mb must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Liquid Heat Exchanger recipe").add(IngredientHelper.isEmpty(hotFluid), + () -> "hot fluid must not be empty") + .add(IngredientHelper.isEmpty(coldFluid), () -> "cold fluid must not be empty").add(huPerMB <= 0, + () -> "heat per mb must be higher than zero") + .error().postIfNotEmpty()) { return null; } - Recipes.liquidCooldownManager.getHeatExchangeProperties().put(hotFluid.getFluid().getName(), new ILiquidHeatExchangerManager.HeatExchangeProperty(coldFluid.getFluid(), huPerMB)); + Recipes.liquidCooldownManager.getHeatExchangeProperties().put(hotFluid.getFluid().getName(), + new ILiquidHeatExchangerManager.HeatExchangeProperty(coldFluid.getFluid(), + huPerMB)); HeatExchangerRecipe recipe = new HeatExchangerRecipe(1, hotFluid, coldFluid, huPerMB); addScripted(recipe); return recipe; @@ -81,10 +83,8 @@ public HeatExchangerRecipe addCooldown(FluidStack hotFluid, FluidStack coldFluid public boolean removeHeatup(FluidStack coldFluid) { if (IngredientHelper.isEmpty(coldFluid)) { - GroovyLog.msg("Error removing Industrialcraft 2 Liquid Heat Exchanger heatup recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Liquid Heat Exchanger heatup recipe").add("input must not be empty") + .error().post(); return false; } return removeHeatup(coldFluid.getFluid()); @@ -92,17 +92,16 @@ public boolean removeHeatup(FluidStack coldFluid) { public boolean removeCooldown(FluidStack hotFluid) { if (IngredientHelper.isEmpty(hotFluid)) { - GroovyLog.msg("Error removing Industrialcraft 2 Liquid Heat Exchanger cooldown recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Liquid Heat Exchanger cooldown recipe").add("input must not be empty") + .error().post(); return false; } return removeCooldown(hotFluid.getFluid()); } public boolean removeHeatup(Fluid coldFluid) { - ILiquidHeatExchangerManager.HeatExchangeProperty property = Recipes.liquidHeatupManager.getHeatExchangeProperties().remove(coldFluid.getName()); + ILiquidHeatExchangerManager.HeatExchangeProperty property = Recipes.liquidHeatupManager.getHeatExchangeProperties() + .remove(coldFluid.getName()); if (property != null) { addBackup(new HeatExchangerRecipe(0, property.outputFluid, coldFluid, property.huPerMB)); return true; @@ -112,7 +111,8 @@ public boolean removeHeatup(Fluid coldFluid) { } public boolean removeCooldown(Fluid hotFluid) { - ILiquidHeatExchangerManager.HeatExchangeProperty property = Recipes.liquidCooldownManager.getHeatExchangeProperties().remove(hotFluid.getName()); + ILiquidHeatExchangerManager.HeatExchangeProperty property = Recipes.liquidCooldownManager.getHeatExchangeProperties() + .remove(hotFluid.getName()); if (property != null) { addBackup(new HeatExchangerRecipe(1, hotFluid, property.outputFluid, property.huPerMB)); return true; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Macerator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Macerator.java index 939698794..5f8352d56 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Macerator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Macerator.java @@ -1,18 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.*; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.*; public class Macerator extends VirtualizedRegistry>> { @@ -27,27 +29,30 @@ public void add(MachineRecipe> recipe) { } public MachineRecipe> add(ItemStack output, IIngredient input) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Macerator recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Macerator recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output)); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output)); add(recipe); return recipe; } public MachineRecipe> add(ItemStack output, IIngredient input, NBTTagCompound tag) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Macerator recipe") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Macerator recipe").add(IngredientHelper.isEmpty(input), + () -> "input must not be empty").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return null; } - MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections.singleton(output), tag); + MachineRecipe> recipe = new MachineRecipe<>(new RecipeInput(input), Collections + .singleton(output), + tag); add(recipe); return recipe; } @@ -62,13 +67,11 @@ public boolean remove(MachineRecipe> recipe) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft 2 Macerator recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Macerator recipe").add("output must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.macerator.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.macerator.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> recipe = iterator.next(); if (ItemStack.areItemStacksEqual((ItemStack) recipe.getOutput().toArray()[0], output)) { iterator.remove(); @@ -79,13 +82,11 @@ public void removeByOutput(ItemStack output) { public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Industrialcraft 2 Macerator recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Macerator recipe").add("input must not be empty").error().post(); return; } - for (Iterator>> iterator = Recipes.macerator.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.macerator.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> recipe = iterator.next(); if (recipe.getInput().matches(input)) { iterator.remove(); @@ -95,7 +96,8 @@ public void removeByInput(ItemStack input) { } public void removeAll() { - for (Iterator>> iterator = Recipes.macerator.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.macerator.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); iterator.remove(); addBackup(rec); @@ -103,7 +105,8 @@ public void removeAll() { } private boolean remove(MachineRecipe> recipe, boolean backup) { - for (Iterator>> iterator = Recipes.macerator.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator>> iterator = Recipes.macerator.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe> rec = iterator.next(); if (rec.getInput().matches(recipe.getInput().getInputs().get(0))) { iterator.remove(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Recycler.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Recycler.java index ee9b6f458..8f68d5d3b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Recycler.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Recycler.java @@ -1,16 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.Iterator; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import java.util.Iterator; - public class Recycler extends VirtualizedRegistry { private int type; // 0 = Whitelist | 1 = Blacklist @@ -21,12 +22,12 @@ public class Recycler extends VirtualizedRegistry { public void onReload() { removeScripted().forEach(recipe -> { if (type == 0) { - for (Iterator iterator = Recipes.recyclerWhitelist.iterator(); iterator.hasNext(); ) { + for (Iterator iterator = Recipes.recyclerWhitelist.iterator(); iterator.hasNext();) { IRecipeInput input = iterator.next(); if (input == recipe) iterator.remove(); } } else { - for (Iterator iterator = Recipes.recyclerBlacklist.iterator(); iterator.hasNext(); ) { + for (Iterator iterator = Recipes.recyclerBlacklist.iterator(); iterator.hasNext();) { IRecipeInput input = iterator.next(); if (input == recipe) iterator.remove(); } @@ -35,11 +36,11 @@ public void onReload() { } public void addBlacklist(IIngredient ingredient) { - if (GroovyLog.msg("Error setting Recycler recipe") - .add(IngredientHelper.isEmpty(ingredient), () -> "ingredient must not be empty") - .add(!Recipes.recyclerWhitelist.isEmpty(), () -> "whitelist should be empty to set blacklist for Recycler") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error setting Recycler recipe").add(IngredientHelper.isEmpty(ingredient), + () -> "ingredient must not be empty").add( + !Recipes.recyclerWhitelist.isEmpty(), + () -> "whitelist should be empty to set blacklist for Recycler") + .error().postIfNotEmpty()) { return; } this.type = 1; @@ -49,11 +50,11 @@ public void addBlacklist(IIngredient ingredient) { } public void addWhitelist(IIngredient ingredient) { - if (GroovyLog.msg("Error setting Recycler recipe") - .add(IngredientHelper.isEmpty(ingredient), () -> "ingredient must not be empty") - .add(!Recipes.recyclerBlacklist.isEmpty(), () -> "blacklist should be empty to set whitelist for Recycler") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error setting Recycler recipe").add(IngredientHelper.isEmpty(ingredient), + () -> "ingredient must not be empty").add( + !Recipes.recyclerBlacklist.isEmpty(), + () -> "blacklist should be empty to set whitelist for Recycler") + .error().postIfNotEmpty()) { return; } this.type = 0; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Scrapbox.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Scrapbox.java index 5946319c8..bb38142a4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Scrapbox.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/Scrapbox.java @@ -1,31 +1,30 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.List; + +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.core.mixin.ic2.ScrapboxRecipeManagerAccessor; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; -import java.util.List; +import ic2.api.recipe.Recipes; public class Scrapbox extends VirtualizedRegistry { - @SuppressWarnings("all") - @GroovyBlacklist - @Override + @SuppressWarnings("all") @GroovyBlacklist @Override public void onReload() { removeScripted().forEach(recipe -> getDrops().remove(((Drop) recipe).id)); getDrops().addAll(restoreFromBackup()); } public void add(ItemStack stack, float chance) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Scrapbox recipe") - .add(IngredientHelper.isEmpty(stack), () -> "stack must not be emtpy") - .add(chance <= 0, () -> "chance must be higher than zero") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Scrapbox recipe").add(IngredientHelper.isEmpty(stack), + () -> "stack must not be emtpy").add(chance <= 0, + () -> "chance must be higher than zero") + .error().postIfNotEmpty()) { return; } Drop drop = new Drop(stack, chance).setId(getDrops().size()); @@ -44,9 +43,7 @@ public void removeAll() { } @GroovyBlacklist - public List getDrops() { - return ((ScrapboxRecipeManagerAccessor) Recipes.scrapboxDrops).getDrops(); - } + public List getDrops() { return ((ScrapboxRecipeManagerAccessor) Recipes.scrapboxDrops).getDrops(); } public static class Drop { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/SolidCanner.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/SolidCanner.java index 1aed4d846..189dec775 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/SolidCanner.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ic2/exp/SolidCanner.java @@ -1,20 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.ic2.exp; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ic2.RecipeInput; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ic2.api.recipe.ICannerBottleRecipeManager; import ic2.api.recipe.MachineRecipe; import ic2.api.recipe.Recipes; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; public class SolidCanner extends VirtualizedRegistry> { @@ -28,13 +30,13 @@ public void add(MachineRecipe recip add(recipe, true); } - public MachineRecipe add(IIngredient input, IIngredient input1, ItemStack output) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Solid Canner recipe") - .add(IngredientHelper.isEmpty(input), () -> "input 1 must not be emtpy") - .add(IngredientHelper.isEmpty(input1), () -> "input 2 must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + public MachineRecipe add(IIngredient input, IIngredient input1, + ItemStack output) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Solid Canner recipe").add(IngredientHelper.isEmpty(input), + () -> "input 1 must not be emtpy").add( + IngredientHelper.isEmpty(input1), + () -> "input 2 must not be empty") + .add(IngredientHelper.isEmpty(output), () -> "output must not be empty").error().postIfNotEmpty()) { return null; } MachineRecipe recipe = create(input, input1, output, null); @@ -42,13 +44,13 @@ public MachineRecipe add(IIngredien return recipe; } - public MachineRecipe add(IIngredient input, IIngredient input1, ItemStack output, NBTTagCompound tag) { - if (GroovyLog.msg("Error adding Industrialcraft 2 Solid Canner recipe") - .add(IngredientHelper.isEmpty(input), () -> "input 1 must not be emtpy") - .add(IngredientHelper.isEmpty(input1), () -> "input 2 must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + public MachineRecipe add(IIngredient input, IIngredient input1, ItemStack output, + NBTTagCompound tag) { + if (GroovyLog.msg("Error adding Industrialcraft 2 Solid Canner recipe").add(IngredientHelper.isEmpty(input), + () -> "input 1 must not be emtpy").add( + IngredientHelper.isEmpty(input1), + () -> "input 2 must not be empty") + .add(IngredientHelper.isEmpty(output), () -> "output must not be empty").error().postIfNotEmpty()) { return null; } MachineRecipe recipe = create(input, input1, output, tag); @@ -66,13 +68,11 @@ public boolean remove(MachineRecipe public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Industrialcraft 2 Solid Canning recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Industrialcraft 2 Solid Canning recipe").add("output must not be empty").error().post(); return; } - for (Iterator> iterator = Recipes.cannerBottle.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator> iterator = Recipes.cannerBottle.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe rec = iterator.next(); if (ItemStack.areItemStacksEqual(rec.getOutput(), output)) { iterator.remove(); @@ -82,14 +82,15 @@ public void removeByOutput(ItemStack output) { } public void removeByInput(ItemStack input, ItemStack input1) { - if (GroovyLog.msg("Error removing industrialcraft 2 Solid Canning recipe") - .add(IngredientHelper.isEmpty(input), () -> "input 1 must not be empty") - .add(IngredientHelper.isEmpty(input1), () -> "input 2 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing industrialcraft 2 Solid Canning recipe").add(IngredientHelper.isEmpty(input), + () -> "input 1 must not be empty").add( + IngredientHelper.isEmpty(input1), + () -> "input 2 must not be empty") + .error().postIfNotEmpty()) { return; } - for (Iterator> iterator = Recipes.cannerBottle.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator> iterator = Recipes.cannerBottle.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe rec = iterator.next(); if (rec.getInput().container.matches(input) && rec.getInput().fill.matches(input1)) { iterator.remove(); @@ -99,7 +100,8 @@ public void removeByInput(ItemStack input, ItemStack input1) { } public void removeAll() { - for (Iterator> iterator = Recipes.cannerBottle.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator> iterator = Recipes.cannerBottle.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe rec = iterator.next(); iterator.remove(); addBackup(rec); @@ -107,7 +109,8 @@ public void removeAll() { } private boolean remove(MachineRecipe recipe, boolean backup) { - for (Iterator> iterator = Recipes.cannerBottle.getRecipes().iterator(); iterator.hasNext(); ) { + for (Iterator> iterator = Recipes.cannerBottle.getRecipes() + .iterator(); iterator.hasNext();) { MachineRecipe rec = iterator.next(); if (recipe.getInput().matches(rec.getInput().container.getInputs().get(0), rec.getInput().fill.getInputs().get(0))) { iterator.remove(); @@ -124,8 +127,10 @@ private void add(MachineRecipe reci if (scripted) addScripted(recipe); } - private static MachineRecipe create(IIngredient input, IIngredient input1, ItemStack output, NBTTagCompound tag) { - return new MachineRecipe<>(new ICannerBottleRecipeManager.Input(new RecipeInput(input), new RecipeInput(input1)), output, tag); + private static MachineRecipe create(IIngredient input, IIngredient input1, + ItemStack output, NBTTagCompound tag) { + return new MachineRecipe<>(new ICannerBottleRecipeManager.Input(new RecipeInput(input), new RecipeInput(input1)), output, + tag); } private static List> asList() { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/AlloyKiln.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/AlloyKiln.java index 24eee8d9e..69b221663 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/AlloyKiln.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/AlloyKiln.java @@ -1,6 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.crafting.AlloyRecipe; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -10,11 +16,8 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.List; +import blusunrize.immersiveengineering.api.crafting.AlloyRecipe; @RegistryDescription public class AlloyKiln extends VirtualizedRegistry { @@ -24,9 +27,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> AlloyRecipe.recipeList.removeIf(r -> r == recipe)); AlloyRecipe.recipeList.addAll(restoreFromBackup()); @@ -41,7 +42,9 @@ public void add(AlloyRecipe recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION) public AlloyRecipe add(ItemStack output, IIngredient input0, IIngredient input1, int time) { - AlloyRecipe recipe = new AlloyRecipe(output, ImmersiveEngineering.toIngredientStack(input0), ImmersiveEngineering.toIngredientStack(input1), time); + AlloyRecipe recipe = new AlloyRecipe(output, ImmersiveEngineering.toIngredientStack(input0), ImmersiveEngineering + .toIngredientStack(input1), + time); add(recipe); return recipe; } @@ -57,17 +60,13 @@ public boolean remove(AlloyRecipe recipe) { @MethodDescription(example = @Example("item('immersiveengineering:metal:6')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Immersive Engineering Alloy Kiln recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Alloy Kiln recipe").add("output must not be empty").error() + .post(); } List recipes = AlloyRecipe.removeRecipes(output); if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Alloy Kiln recipe") - .add("no recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Alloy Kiln recipe").add("no recipes found for {}", output).error() + .post(); return; } recipes.forEach(this::addBackup); @@ -75,21 +74,19 @@ public void removeByOutput(ItemStack output) { @MethodDescription(example = @Example("item('minecraft:gold_ingot'), item('immersiveengineering:metal:3')")) public void removeByInput(ItemStack input, ItemStack input1) { - if (GroovyLog.msg("Error removing Immersive Engineering Alloy Kiln recipe") - .add(IngredientHelper.isEmpty(input), () -> "input 1 must not be empty") - .add(IngredientHelper.isEmpty(input1), () -> "input 2 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Immersive Engineering Alloy Kiln recipe").add(IngredientHelper.isEmpty(input), + () -> "input 1 must not be empty").add( + IngredientHelper.isEmpty(input1), + () -> "input 2 must not be empty") + .error().postIfNotEmpty()) { return; } AlloyRecipe recipe = AlloyRecipe.findRecipe(input, input1); if (recipe != null) { remove(recipe); } else { - GroovyLog.msg("Error removing Immersive Engineering Alloy Kiln recipe") - .add("no recipes found for {} and {}", input, input1) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Alloy Kiln recipe").add("no recipes found for {} and {}", input, + input1).error().post(); } } @@ -104,8 +101,7 @@ public void removeAll() { AlloyRecipe.recipeList.clear(); } - @Property(property = "input", valid = @Comp("2")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("2")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) @@ -118,9 +114,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Alloy Kiln recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Alloy Kiln recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -129,11 +123,11 @@ public void validate(GroovyLog.Msg msg) { if (time < 0) time = 200; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AlloyRecipe register() { if (!validate()) return null; - AlloyRecipe recipe = new AlloyRecipe(output.get(0), ImmersiveEngineering.toIngredientStack(input.get(0)), ImmersiveEngineering.toIngredientStack(input.get(1)), time); + AlloyRecipe recipe = new AlloyRecipe(output.get(0), ImmersiveEngineering.toIngredientStack(input.get(0)), + ImmersiveEngineering.toIngredientStack(input.get(1)), time); ModSupport.IMMERSIVE_ENGINEERING.get().alloyKiln.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ArcFurnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ArcFurnace.java index b2506e697..17cc27c3d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ArcFurnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ArcFurnace.java @@ -1,6 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -11,15 +22,8 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe; @RegistryDescription public class ArcFurnace extends VirtualizedRegistry { @@ -29,9 +33,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(r -> ArcFurnaceRecipe.recipeList.removeIf(recipe -> recipe == r)); ArcFurnaceRecipe.recipeList.addAll(restoreFromBackup()); @@ -45,9 +47,11 @@ public void add(ArcFurnaceRecipe recipe) { } @MethodDescription(type = MethodDescription.Type.ADDITION) - public ArcFurnaceRecipe add(ItemStack output, IIngredient input, List additives, @Nonnull ItemStack slag, int time, int energyPerTick) { + public ArcFurnaceRecipe add(ItemStack output, IIngredient input, List additives, @Nonnull ItemStack slag, + int time, int energyPerTick) { Object[] inputs = ArrayUtils.mapToArray(additives, ImmersiveEngineering::toIngredientStack); - ArcFurnaceRecipe recipe = ArcFurnaceRecipe.addRecipe(output, ImmersiveEngineering.toIngredientStack(input), slag, time, energyPerTick, inputs); + ArcFurnaceRecipe recipe = ArcFurnaceRecipe.addRecipe(output, ImmersiveEngineering.toIngredientStack(input), slag, time, + energyPerTick, inputs); addScripted(recipe); return recipe; } @@ -63,45 +67,43 @@ public boolean remove(ArcFurnaceRecipe recipe) { @MethodDescription(example = @Example("item('immersiveengineering:metal:7')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Immersive Engineering Arc Furnace recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Arc Furnace recipe").add("output must not be empty").error() + .post(); return; } - List recipes = ArcFurnaceRecipe.recipeList.stream().filter(r -> r.output != null && r.output.isItemEqual(output)).collect(Collectors.toList()); + List recipes = ArcFurnaceRecipe.recipeList.stream().filter(r -> r.output != null && r.output + .isItemEqual(output)) + .collect(Collectors.toList()); for (ArcFurnaceRecipe recipe : recipes) { remove(recipe); } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Arc Furnace recipe") - .add("no recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Arc Furnace recipe").add("no recipes found for {}", output) + .error().post(); } } @MethodDescription(example = @Example("item('immersiveengineering:metal:18'), item('immersiveengineering:material:17')")) public void removeByInput(IIngredient main, List inputAndAdditives) { if (main == null || main.isEmpty() || inputAndAdditives == null || inputAndAdditives.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Arc Furnace recipe") - .add("inputs must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Arc Furnace recipe").add("inputs must not be empty").error() + .post(); return; } - List recipes = ArcFurnaceRecipe.recipeList.stream() - .filter(r -> ImmersiveEngineering.areIngredientsEquals(r.input, main) && - (inputAndAdditives.stream().anyMatch(check -> Arrays.stream(r.additives).anyMatch(target -> ImmersiveEngineering.areIngredientsEquals(target, check))))) - .collect(Collectors.toList()); + List recipes = ArcFurnaceRecipe.recipeList.stream().filter(r -> ImmersiveEngineering + .areIngredientsEquals(r.input, + main) && (inputAndAdditives.stream() + .anyMatch(check -> Arrays.stream(r.additives) + .anyMatch(target -> ImmersiveEngineering.areIngredientsEquals(target, + check))))) + .collect(Collectors.toList()); for (ArcFurnaceRecipe recipe : recipes) { remove(recipe); } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Arc Furnace recipe") - .add("no recipes found with a main ingredient of {}, and additives of {}", main, inputAndAdditives) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Arc Furnace recipe").add( + "no recipes found with a main ingredient of {}, and additives of {}", + main, inputAndAdditives).error().post(); } } @@ -109,10 +111,8 @@ public void removeByInput(IIngredient main, List inputAndAdditives) @MethodDescription public void removeByInput(List inputAndAdditives) { if (inputAndAdditives == null || inputAndAdditives.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Arc Furnace recipe") - .add("inputs must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Arc Furnace recipe").add("inputs must not be empty").error() + .post(); return; } removeByInput(inputAndAdditives.remove(0), inputAndAdditives); @@ -199,9 +199,7 @@ public RecipeBuilder recycling() { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Arc Furnace recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Arc Furnace recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -216,12 +214,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(slag == null, "slag must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ArcFurnaceRecipe register() { if (!validate()) return null; Object[] additives = ArrayUtils.mapToArray(input, ImmersiveEngineering::toIngredientStack); - ArcFurnaceRecipe recipe = new ArcFurnaceRecipe(output.get(0), ImmersiveEngineering.toIngredientStack(mainInput), slag, time, energyPerTick, additives); + ArcFurnaceRecipe recipe = new ArcFurnaceRecipe(output.get(0), ImmersiveEngineering.toIngredientStack(mainInput), slag, + time, energyPerTick, additives); if (specialRecipeType != null) recipe.setSpecialRecipeType(specialRecipeType); ModSupport.IMMERSIVE_ENGINEERING.get().arcFurnace.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnace.java index 31f3240b0..700bef0f0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnace.java @@ -1,6 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.crafting.BlastFurnaceRecipe; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,11 +16,8 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import javax.annotation.Nonnull; -import java.util.List; +import blusunrize.immersiveengineering.api.crafting.BlastFurnaceRecipe; @RegistryDescription public class BlastFurnace extends VirtualizedRegistry { @@ -38,7 +42,8 @@ public void add(BlastFurnaceRecipe recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION) public BlastFurnaceRecipe add(ItemStack output, IIngredient input, int time, @Nonnull ItemStack slag) { - BlastFurnaceRecipe recipe = new BlastFurnaceRecipe(output.copy(), ImmersiveEngineering.toIEInput(input), time, IngredientHelper.copy(slag)); + BlastFurnaceRecipe recipe = new BlastFurnaceRecipe(output.copy(), ImmersiveEngineering.toIEInput(input), time, + IngredientHelper.copy(slag)); add(recipe); return recipe; } @@ -54,18 +59,14 @@ public boolean remove(BlastFurnaceRecipe recipe) { @MethodDescription(example = @Example("item('immersiveengineering:metal:8')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe").add("output must not be empty").error() + .post(); return; } List list = BlastFurnaceRecipe.removeRecipes(output); if (list.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe") - .add("no recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe").add("no recipes found for {}", output) + .error().post(); return; } list.forEach(this::addBackup); @@ -74,20 +75,16 @@ public void removeByOutput(ItemStack output) { @MethodDescription(example = @Example("item('minecraft:iron_block')")) public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe").add("input must not be empty").error() + .post(); return; } BlastFurnaceRecipe recipe = BlastFurnaceRecipe.findRecipe(input); if (recipe != null) { remove(recipe); } else { - GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe") - .add("no recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe").add("no recipes found for {}", input) + .error().post(); } } @@ -102,8 +99,7 @@ public void removeAll() { BlastFurnaceRecipe.recipeList.clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) @@ -124,9 +120,7 @@ public RecipeBuilder slag(ItemStack slag) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Blast Furnace recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Blast Furnace recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -136,8 +130,7 @@ public void validate(GroovyLog.Msg msg) { if (slag == null) slag = ItemStack.EMPTY; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable BlastFurnaceRecipe register() { if (!validate()) return null; return ModSupport.IMMERSIVE_ENGINEERING.get().blastFurnace.add(output.get(0), input.get(0), time, slag); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnaceFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnaceFuel.java index f2a871596..2131b8b1f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnaceFuel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnaceFuel.java @@ -1,6 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.crafting.BlastFurnaceRecipe; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,11 +15,8 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.List; -import java.util.stream.Collectors; +import blusunrize.immersiveengineering.api.crafting.BlastFurnaceRecipe; @RegistryDescription public class BlastFurnaceFuel extends VirtualizedRegistry { @@ -38,7 +41,8 @@ public void add(BlastFurnaceRecipe.BlastFurnaceFuel recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION) public BlastFurnaceRecipe.BlastFurnaceFuel add(IIngredient input, int time) { - BlastFurnaceRecipe.BlastFurnaceFuel recipe = new BlastFurnaceRecipe.BlastFurnaceFuel(ImmersiveEngineering.toIngredientStack(input), time); + BlastFurnaceRecipe.BlastFurnaceFuel recipe = new BlastFurnaceRecipe.BlastFurnaceFuel(ImmersiveEngineering.toIngredientStack(input), + time); add(recipe); return recipe; } @@ -54,21 +58,19 @@ public boolean remove(BlastFurnaceRecipe.BlastFurnaceFuel recipe) { @MethodDescription(example = @Example("item('immersiveengineering:material:6')")) public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe").add("input must not be empty").error() + .post(); return; } - List recipes = BlastFurnaceRecipe.blastFuels.stream().filter(r -> r.input.matches(input)).collect(Collectors.toList()); + List recipes = BlastFurnaceRecipe.blastFuels.stream().filter(r -> r.input.matches( + input)) + .collect(Collectors.toList()); for (BlastFurnaceRecipe.BlastFurnaceFuel recipe : recipes) { remove(recipe); } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe") - .add("no recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Blast Furnace recipe").add("no recipes found for {}", input) + .error().post(); } } @@ -96,9 +98,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Blast Furnace Fuel"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Blast Furnace Fuel"; } @Override public void validate(GroovyLog.Msg msg) { @@ -107,11 +107,11 @@ public void validate(GroovyLog.Msg msg) { if (time < 0) time = 200; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable BlastFurnaceRecipe.BlastFurnaceFuel register() { if (!validate()) return null; - BlastFurnaceRecipe.BlastFurnaceFuel recipe = new BlastFurnaceRecipe.BlastFurnaceFuel(ImmersiveEngineering.toIngredientStack(input.get(0)), time); + BlastFurnaceRecipe.BlastFurnaceFuel recipe = new BlastFurnaceRecipe.BlastFurnaceFuel(ImmersiveEngineering.toIngredientStack(input.get(0)), + time); ModSupport.IMMERSIVE_ENGINEERING.get().blastFurnaceFuel.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlueprintCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlueprintCrafting.java index df396541a..6553011d3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlueprintCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlueprintCrafting.java @@ -1,8 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.ApiUtils; -import blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe; -import blusunrize.immersiveengineering.api.crafting.IngredientStack; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -13,12 +18,10 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; +import blusunrize.immersiveengineering.api.ApiUtils; +import blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe; +import blusunrize.immersiveengineering.api.crafting.IngredientStack; @RegistryDescription public class BlueprintCrafting extends VirtualizedRegistry { @@ -72,10 +75,8 @@ public boolean remove(BlueprintCraftingRecipe recipe) { @MethodDescription(example = @Example("'electrode'")) public void removeByCategory(String blueprintCategory) { if (!BlueprintCraftingRecipe.recipeList.containsKey(blueprintCategory)) { - GroovyLog.msg("Error removing Immersive Engineering Blueprint Crafting recipe") - .add("category {} does not exist", blueprintCategory) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Blueprint Crafting recipe").add("category {} does not exist", + blueprintCategory).error().post(); return; } List list = BlueprintCraftingRecipe.recipeList.removeAll(blueprintCategory); @@ -86,11 +87,14 @@ public void removeByCategory(String blueprintCategory) { @MethodDescription(example = @Example("'components', item('immersiveengineering:material:8')")) public void removeByOutput(String blueprintCategory, ItemStack output) { - if (GroovyLog.msg("Error removing Immersive Engineering Blueprint Crafting recipe") - .add(!BlueprintCraftingRecipe.recipeList.containsKey(blueprintCategory), () -> "category " + blueprintCategory + " does not exist") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Immersive Engineering Blueprint Crafting recipe").add( + !BlueprintCraftingRecipe.recipeList.containsKey(blueprintCategory), + () -> "category " + + blueprintCategory + + " does not exist").add( + IngredientHelper.isEmpty(output), + () -> "output must not be empty") + .error().postIfNotEmpty()) { return; } if (!BlueprintCraftingRecipe.recipeList.get(blueprintCategory).removeIf(recipe -> { @@ -100,20 +104,21 @@ public void removeByOutput(String blueprintCategory, ItemStack output) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Blueprint Crafting recipe") - .add("no recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Blueprint Crafting recipe").add("no recipes found for {}", output) + .error().post(); } } @MethodDescription(example = @Example("'components', item('immersiveengineering:metal:38'), item('immersiveengineering:metal:38'), item('immersiveengineering:metal')")) public void removeByInput(String blueprintCategory, ItemStack... inputs) { - if (GroovyLog.msg("Error removing Immersive Engineering Blueprint Crafting recipe") - .add(!BlueprintCraftingRecipe.recipeList.containsKey(blueprintCategory), () -> "category " + blueprintCategory + " does not exist") - .add(inputs == null || inputs.length == 0, () -> "input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Immersive Engineering Blueprint Crafting recipe").add( + !BlueprintCraftingRecipe.recipeList.containsKey(blueprintCategory), + () -> "category " + + blueprintCategory + + " does not exist").add( + inputs == null || inputs.length == 0, + () -> "input must not be empty") + .error().postIfNotEmpty()) { return; } @@ -133,10 +138,9 @@ public void removeByInput(String blueprintCategory, ItemStack... inputs) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Blueprint Crafting recipe") - .add("no recipes found for {}", Arrays.toString(inputs)) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Blueprint Crafting recipe").add("no recipes found for {}", Arrays + .toString(inputs)) + .error().post(); } } @@ -163,7 +167,8 @@ public void removeAll() { BlueprintCraftingRecipe.recipeList.clear(); } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) + @Property(property = "input", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @@ -177,9 +182,7 @@ public RecipeBuilder category(String category) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Blueprint recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Blueprint recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -188,8 +191,7 @@ public void validate(GroovyLog.Msg msg) { if (this.category == null) this.category = BlueprintCraftingRecipe.blueprintCategories.get(0); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable BlueprintCraftingRecipe register() { if (!validate()) return null; Object[] inputs = ArrayUtils.mapToArray(input, ImmersiveEngineering::toIngredientStack); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BottlingMachine.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BottlingMachine.java index a3f9151b8..8ea22077b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BottlingMachine.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BottlingMachine.java @@ -1,7 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.ApiUtils; -import blusunrize.immersiveengineering.api.crafting.BottlingMachineRecipe; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -11,12 +17,9 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; -import java.util.List; -import java.util.stream.Collectors; +import blusunrize.immersiveengineering.api.ApiUtils; +import blusunrize.immersiveengineering.api.crafting.BottlingMachineRecipe; @RegistryDescription public class BottlingMachine extends VirtualizedRegistry { @@ -45,7 +48,8 @@ public void add(BottlingMachineRecipe recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION) public BottlingMachineRecipe add(ItemStack output, IIngredient input, FluidStack fluidInput) { - BottlingMachineRecipe recipe = new BottlingMachineRecipe(output.copy(), ImmersiveEngineering.toIngredientStack(input), fluidInput); + BottlingMachineRecipe recipe = new BottlingMachineRecipe(output.copy(), ImmersiveEngineering.toIngredientStack(input), + fluidInput); add(recipe); return recipe; } @@ -61,10 +65,8 @@ public boolean remove(BottlingMachineRecipe recipe) { @MethodDescription(example = @Example("item('minecraft:potion').withNbt([Potion:'minecraft:mundane'])")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Immersive Engineering Bottling Machine recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Bottling Machine recipe").add("output must not be empty").error() + .post(); return; } if (!BottlingMachineRecipe.recipeList.removeIf(recipe -> { @@ -74,31 +76,28 @@ public void removeByOutput(ItemStack output) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Bottling Machine recipe") - .add("no recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Bottling Machine recipe").add("no recipes found for {}", output) + .error().post(); } } @MethodDescription(example = @Example("item('minecraft:sponge'), fluid('water') * 1000")) public void removeByInput(ItemStack input, FluidStack inputFluid) { - if (GroovyLog.msg("Error removing Immersive Engineering Bottling Machine recipe") - .add(IngredientHelper.isEmpty(input), () -> "item input must not be empty") - .add(IngredientHelper.isEmpty(inputFluid), () -> "fluid input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Immersive Engineering Bottling Machine recipe").add(IngredientHelper.isEmpty(input), + () -> "item input must not be empty") + .add(IngredientHelper.isEmpty(inputFluid), () -> "fluid input must not be empty").error().postIfNotEmpty()) { return; } - List recipes = BottlingMachineRecipe.recipeList.stream().filter(r -> ApiUtils.stackMatchesObject(input, r.input) && inputFluid.isFluidEqual(r.fluidInput)).collect(Collectors.toList()); + List recipes = BottlingMachineRecipe.recipeList.stream().filter(r -> ApiUtils.stackMatchesObject( + input, + r.input) && inputFluid.isFluidEqual(r.fluidInput)) + .collect(Collectors.toList()); for (BottlingMachineRecipe recipe : recipes) { remove(recipe); } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Bottling Machine recipe") - .add("no recipes found for {} and {}", input, inputFluid) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Bottling Machine recipe").add("no recipes found for {} and {}", + input, inputFluid).error().post(); } } @@ -119,9 +118,7 @@ public void removeAll() { public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Bottling recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Bottling recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -129,11 +126,12 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 1, 1, 0, 0); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable BottlingMachineRecipe register() { if (!validate()) return null; - BottlingMachineRecipe recipe = new BottlingMachineRecipe(output.get(0), ImmersiveEngineering.toIngredientStack(input.get(0)), fluidInput.get(0)); + BottlingMachineRecipe recipe = new BottlingMachineRecipe(output.get(0), ImmersiveEngineering.toIngredientStack(input + .get(0)), + fluidInput.get(0)); ModSupport.IMMERSIVE_ENGINEERING.get().bottlingMachine.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/CokeOven.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/CokeOven.java index 07e46325d..cc56f2787 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/CokeOven.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/CokeOven.java @@ -1,7 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.ApiUtils; -import blusunrize.immersiveengineering.api.crafting.CokeOvenRecipe; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,10 +14,9 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.List; +import blusunrize.immersiveengineering.api.ApiUtils; +import blusunrize.immersiveengineering.api.crafting.CokeOvenRecipe; @RegistryDescription public class CokeOven extends VirtualizedRegistry { @@ -54,18 +57,13 @@ public boolean remove(CokeOvenRecipe recipe) { @MethodDescription(example = @Example("item('immersiveengineering:material:6')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Immersive Engineering Coke Oven recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Coke Oven recipe").add("output must not be empty").error().post(); return; } List list = CokeOvenRecipe.removeRecipes(output); if (list.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Crusher recipe") - .add("no recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Crusher recipe").add("no recipes found for {}", output).error() + .post(); return; } list.forEach(this::addBackup); @@ -74,10 +72,7 @@ public void removeByOutput(ItemStack output) { @MethodDescription(example = @Example("item('minecraft:log')")) public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Immersive Engineering Coke Oven recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Coke Oven recipe").add("output must not be empty").error().post(); return; } if (!CokeOvenRecipe.recipeList.removeIf(recipe -> { @@ -87,10 +82,8 @@ public void removeByInput(ItemStack input) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Crusher recipe") - .add("no recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Crusher recipe").add("no recipes found for {}", input).error() + .post(); } } @@ -105,8 +98,7 @@ public void removeAll() { CokeOvenRecipe.recipeList.clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) @@ -127,9 +119,7 @@ public RecipeBuilder creosote(int creosote) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Coke Oven recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Coke Oven recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -139,11 +129,11 @@ public void validate(GroovyLog.Msg msg) { if (creosote < 0) creosote = 0; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CokeOvenRecipe register() { if (!validate()) return null; - CokeOvenRecipe recipe = new CokeOvenRecipe(output.get(0), ImmersiveEngineering.toIEInput(input.get(0)), time, creosote); + CokeOvenRecipe recipe = new CokeOvenRecipe(output.get(0), ImmersiveEngineering.toIEInput(input.get(0)), time, + creosote); ModSupport.IMMERSIVE_ENGINEERING.get().cokeOven.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Crusher.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Crusher.java index a3875d24f..47ba0dbb8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Crusher.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Crusher.java @@ -1,6 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.crafting.CrusherRecipe; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,20 +15,15 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import it.unimi.dsi.fastutil.floats.FloatArrayList; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; +import blusunrize.immersiveengineering.api.crafting.CrusherRecipe; +import it.unimi.dsi.fastutil.floats.FloatArrayList; @RegistryDescription public class Crusher extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).energy(100)"), - @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:diamond')).secondaryOutput(item('minecraft:gold_ingot')).secondaryOutput(item('minecraft:gold_ingot'), 0.3).energy(100)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).energy(100)"), + @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:diamond')).secondaryOutput(item('minecraft:gold_ingot')).secondaryOutput(item('minecraft:gold_ingot'), 0.3).energy(100)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -58,17 +59,12 @@ public boolean remove(CrusherRecipe recipe) { @MethodDescription(example = @Example("item('minecraft:sand')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Immersive Engineering Crusher recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Crusher recipe").add("output must not be empty").error().post(); } List list = CrusherRecipe.removeRecipesForOutput(output); if (list.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Crusher recipe") - .add("no recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Crusher recipe").add("no recipes found for {}", output).error() + .post(); return; } list.forEach(this::addBackup); @@ -77,17 +73,12 @@ public void removeByOutput(ItemStack output) { @MethodDescription(example = @Example("item('immersiveengineering:material:7')")) public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Immersive Engineering Crusher recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Crusher recipe").add("input must not be empty").error().post(); } List list = CrusherRecipe.removeRecipesForInput(input); if (list.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Crusher recipe") - .add("no recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Crusher recipe").add("no recipes found for {}", input).error() + .post(); return; } list.forEach(this::addBackup); @@ -104,8 +95,7 @@ public void removeAll() { CrusherRecipe.recipeList.clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp("secondaryOutputChances")) @@ -134,21 +124,20 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Crusher recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Crusher recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); validateFluids(msg); secondaryOutputChances.trim(); - msg.add(secondaryOutputItems.size() != secondaryOutputChances.size(), "secondaryOutputItems and secondaryOutputChances must be of equal length, yet secondaryOutputItems was {} and secondaryOutputChances was {}", secondaryOutputItems.size(), secondaryOutputChances.size()); + msg.add(secondaryOutputItems.size() != secondaryOutputChances.size(), + "secondaryOutputItems and secondaryOutputChances must be of equal length, yet secondaryOutputItems was {} and secondaryOutputChances was {}", + secondaryOutputItems.size(), secondaryOutputChances.size()); if (energy < 0) energy = 200; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CrusherRecipe register() { if (!validate()) return null; CrusherRecipe recipe = new CrusherRecipe(output.get(0), ImmersiveEngineering.toIngredientStack(input.get(0)), energy); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Excavator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Excavator.java index 881599b64..4b566d10a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Excavator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Excavator.java @@ -1,6 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.tool.ExcavatorHandler; +import java.util.*; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -9,25 +14,18 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import it.unimi.dsi.fastutil.floats.FloatArrayList; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.stream.Collectors; +import blusunrize.immersiveengineering.api.tool.ExcavatorHandler; +import it.unimi.dsi.fastutil.floats.FloatArrayList; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - admonition = @Admonition(value = "groovyscript.wiki.immersiveengineering.excavator.note0", - type = Admonition.Type.WARNING, - format = Admonition.Format.STANDARD) -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES, + admonition = @Admonition(value = "groovyscript.wiki.immersiveengineering.excavator.note0", + type = Admonition.Type.WARNING, + format = Admonition.Format.STANDARD)) public class Excavator extends VirtualizedRegistry> { - @RecipeBuilderDescription(example = { - @Example(".name('demo').weight(20000).fail(0.5).ore(ore('blockDiamond'), 50).ore('blockGold', 10).dimension(0, 1)"), - @Example(".name('demo').weight(2000).fail(0.1).ore(ore('blockDiamond'), 50).dimension(-1, 1).blacklist()") - }) + @RecipeBuilderDescription(example = {@Example(".name('demo').weight(20000).fail(0.5).ore(ore('blockDiamond'), 50).ore('blockGold', 10).dimension(0, 1)"), + @Example(".name('demo').weight(2000).fail(0.1).ore(ore('blockDiamond'), 50).dimension(-1, 1).blacklist()")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -64,17 +62,15 @@ public boolean remove(ExcavatorHandler.MineralMix recipe) { @MethodDescription(example = @Example("'silt'")) public boolean removeByMineral(String key) { - List entries = ExcavatorHandler.mineralList.keySet().stream() - .filter(r -> r.name.equalsIgnoreCase(key)) - .collect(Collectors.toList()); + List entries = ExcavatorHandler.mineralList.keySet().stream().filter(r -> r.name + .equalsIgnoreCase(key)) + .collect(Collectors.toList()); for (ExcavatorHandler.MineralMix recipe : entries) { remove(recipe); } if (entries.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Excavator entry") - .add("no entries found for {}", key) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Excavator entry").add("no entries found for {}", key).error() + .post(); return false; } return true; @@ -83,46 +79,40 @@ public boolean removeByMineral(String key) { @MethodDescription(example = @Example("ore('oreAluminum')")) public void removeByOres(String... ores) { if (ores == null || ores.length == 0) { - GroovyLog.msg("Error removing Immersive Engineering Excavator entry") - .add("ores must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Excavator entry").add("ores must not be empty").error().post(); return; } - List entries = ExcavatorHandler.mineralList.keySet().stream() - .filter(r -> Arrays.stream(ores).anyMatch(check -> Arrays.stream(r.ores).anyMatch(target -> target.matches(check)))) - .collect(Collectors.toList()); + List entries = ExcavatorHandler.mineralList.keySet().stream().filter(r -> Arrays.stream(ores) + .anyMatch(check -> Arrays.stream(r.ores) + .anyMatch(target -> target.matches(check)))) + .collect(Collectors.toList()); for (ExcavatorHandler.MineralMix recipe : entries) { remove(recipe); } if (entries.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Excavator entry") - .add("no entries found for {}", Arrays.toString(ores)) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Excavator entry").add("no entries found for {}", Arrays.toString( + ores)) + .error().post(); } } @MethodDescription public void removeByOres(OreDictIngredient... ores) { if (IngredientHelper.isEmpty(ores)) { - GroovyLog.msg("Error removing Immersive Engineering Excavator entry") - .add("ores must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Excavator entry").add("ores must not be empty").error().post(); return; } - List entries = ExcavatorHandler.mineralList.keySet().stream() - .filter(r -> Arrays.stream(ores).anyMatch(check -> Arrays.stream(r.ores).anyMatch(target -> target.matches(check.getOreDict())))) - .collect(Collectors.toList()); + List entries = ExcavatorHandler.mineralList.keySet().stream().filter(r -> Arrays.stream(ores) + .anyMatch(check -> Arrays.stream(r.ores) + .anyMatch(target -> target.matches(check.getOreDict())))) + .collect(Collectors.toList()); for (ExcavatorHandler.MineralMix recipe : entries) { remove(recipe); } if (entries.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Excavator entry") - .add("no entries found for {}", Arrays.toString(ores)) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Excavator entry").add("no entries found for {}", Arrays.toString( + ores)) + .error().post(); } } @@ -155,8 +145,7 @@ public static class RecipeBuilder extends AbstractRecipeBuilder 1, "fail must be a float between 0 and 1, yet it was {}", fail); chances.trim(); - msg.add(ores.size() != chances.size(), "ores and chances must be of equal length, yet ores was {} and chances was {}", ores.size(), chances.size()); + msg.add(ores.size() != chances.size(), "ores and chances must be of equal length, yet ores was {} and chances was {}", + ores.size(), chances.size()); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ExcavatorHandler.MineralMix register() { if (!validate()) return null; - ExcavatorHandler.MineralMix recipe = new ExcavatorHandler.MineralMix(name, fail, ores.toArray(new String[0]), chances.elements()); + ExcavatorHandler.MineralMix recipe = new ExcavatorHandler.MineralMix(name, fail, ores.toArray(new String[0]), chances + .elements()); int[] dims = dimensions.stream().mapToInt(Integer::intValue).toArray(); if (dims != null) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Fermenter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Fermenter.java index 60305b379..d24425e6f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Fermenter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Fermenter.java @@ -1,6 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.crafting.FermenterRecipe; +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,11 +15,8 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; -import javax.annotation.Nonnull; +import blusunrize.immersiveengineering.api.crafting.FermenterRecipe; @RegistryDescription public class Fermenter extends VirtualizedRegistry { @@ -38,7 +41,9 @@ public void add(FermenterRecipe recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION) public FermenterRecipe add(FluidStack fluidOutput, @Nonnull ItemStack itemOutput, IIngredient input, int energy) { - FermenterRecipe recipe = new FermenterRecipe(fluidOutput.copy(), itemOutput.copy(), ImmersiveEngineering.toIngredientStack(input), energy); + FermenterRecipe recipe = new FermenterRecipe(fluidOutput.copy(), itemOutput.copy(), ImmersiveEngineering + .toIngredientStack(input), + energy); add(recipe); return recipe; } @@ -54,10 +59,8 @@ public boolean remove(FermenterRecipe recipe) { @MethodDescription(example = @Example("fluid('ethanol')")) public void removeByOutput(FluidStack fluidOutput) { if (IngredientHelper.isEmpty(fluidOutput)) { - GroovyLog.msg("Error removing Immersive Engineering Fermenter recipe") - .add("fluid output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Fermenter recipe").add("fluid output must not be empty").error() + .post(); } if (!FermenterRecipe.recipeList.removeIf(recipe -> { if (recipe.fluidOutput.isFluidEqual(fluidOutput)) { @@ -66,30 +69,23 @@ public void removeByOutput(FluidStack fluidOutput) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Fermenter recipe") - .add("no recipes found for {}", fluidOutput) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Fermenter recipe").add("no recipes found for {}", fluidOutput) + .error().post(); } } @MethodDescription(example = @Example("item('minecraft:reeds')")) public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Immersive Engineering Fermenter recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Fermenter recipe").add("input must not be empty").error().post(); } FermenterRecipe recipe = FermenterRecipe.findRecipe(input); if (recipe != null) { FermenterRecipe.recipeList.remove(recipe); addBackup(recipe); } else { - GroovyLog.msg("Error removing Immersive Engineering Fermenter recipe") - .add("no recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Fermenter recipe").add("no recipes found for {}", input).error() + .post(); } } @@ -119,9 +115,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Fermenter recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Fermenter recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -129,11 +123,12 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 0, 0, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable FermenterRecipe register() { if (!validate()) return null; - FermenterRecipe recipe = new FermenterRecipe(fluidOutput.get(0), output.getOrEmpty(0), ImmersiveEngineering.toIngredientStack(input.get(0)), energy); + FermenterRecipe recipe = new FermenterRecipe(fluidOutput.get(0), output.getOrEmpty(0), ImmersiveEngineering + .toIngredientStack(input.get(0)), + energy); ModSupport.IMMERSIVE_ENGINEERING.get().fermenter.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ImmersiveEngineering.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ImmersiveEngineering.java index 527d235db..99b76a57f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ImmersiveEngineering.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ImmersiveEngineering.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.crafting.IngredientStack; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import java.util.Arrays; +import blusunrize.immersiveengineering.api.crafting.IngredientStack; public class ImmersiveEngineering extends GroovyPropertyContainer { @@ -28,20 +30,17 @@ public class ImmersiveEngineering extends GroovyPropertyContainer { public final Squeezer squeezer = new Squeezer(); public static IngredientStack toIngredientStack(IIngredient ingredient) { - if (IngredientHelper.isItem(ingredient)) { - return new IngredientStack(IngredientHelper.toItemStack(ingredient).copy()); - } + if (IngredientHelper.isItem(ingredient)) { return new IngredientStack(IngredientHelper.toItemStack(ingredient).copy()); } if (ingredient instanceof OreDictIngredient) { return new IngredientStack(((OreDictIngredient) ingredient).getOreDict(), ingredient.getAmount()); } - if (ingredient instanceof FluidStack) { - return new IngredientStack(((FluidStack) ingredient).copy()); - } + if (ingredient instanceof FluidStack) { return new IngredientStack(((FluidStack) ingredient).copy()); } return new IngredientStack(Arrays.asList(ingredient.getMatchingStacks()), ingredient.getAmount()); } public static boolean areIngredientsEquals(IngredientStack target, IIngredient other) { - return other instanceof OreDictIngredient ? target.matches(((OreDictIngredient) other).getOreDict()) : target.matches(other.getMatchingStacks()); + return other instanceof OreDictIngredient ? target.matches(((OreDictIngredient) other).getOreDict()) : target.matches( + other.getMatchingStacks()); } public static boolean areIngredientsEquals(IIngredient target, IngredientStack other) { @@ -49,9 +48,7 @@ public static boolean areIngredientsEquals(IIngredient target, IngredientStack o } public static Object toIEInput(IIngredient ingredient) { - if (ingredient instanceof OreDictIngredient) { - return ((OreDictIngredient) ingredient).getOreDict(); - } + if (ingredient instanceof OreDictIngredient) { return ((OreDictIngredient) ingredient).getOreDict(); } ItemStack[] matchingStacks = ingredient.getMatchingStacks(); return matchingStacks.length == 0 ? ItemStack.EMPTY : matchingStacks[0]; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/MetalPress.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/MetalPress.java index badd397e3..fc659bcb8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/MetalPress.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/MetalPress.java @@ -1,8 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.ApiUtils; -import blusunrize.immersiveengineering.api.ComparableItemStack; -import blusunrize.immersiveengineering.api.crafting.MetalPressRecipe; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -11,11 +15,10 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; +import blusunrize.immersiveengineering.api.ApiUtils; +import blusunrize.immersiveengineering.api.ComparableItemStack; +import blusunrize.immersiveengineering.api.crafting.MetalPressRecipe; @RegistryDescription public class MetalPress extends VirtualizedRegistry { @@ -40,7 +43,10 @@ public void add(MetalPressRecipe recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION) public MetalPressRecipe add(ItemStack output, IIngredient input, ItemStack mold, int energy) { - MetalPressRecipe recipe = new MetalPressRecipe(output.copy(), ImmersiveEngineering.toIngredientStack(input), ApiUtils.createComparableItemStack(mold, true), energy); + MetalPressRecipe recipe = new MetalPressRecipe(output.copy(), ImmersiveEngineering.toIngredientStack(input), ApiUtils + .createComparableItemStack(mold, + true), + energy); add(recipe); return recipe; } @@ -53,20 +59,17 @@ public boolean remove(MetalPressRecipe recipe) { return false; } - @MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('immersiveengineering:material:2')")) + @MethodDescription(description = "groovyscript.wiki.removeByOutput", + example = @Example("item('immersiveengineering:material:2')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe").add("output must not be empty").error() + .post(); } List list = MetalPressRecipe.removeRecipes(output); if (list.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe") - .add("no recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe").add("no recipes found for {}", output) + .error().post(); return; } list.forEach(this::addBackup); @@ -75,10 +78,9 @@ public void removeByOutput(ItemStack output) { @MethodDescription(example = @Example("item('immersiveengineering:mold'), item('immersiveengineering:metal:31')")) public void removeByOutput(ItemStack mold, ItemStack output) { boolean moldEmpty = IngredientHelper.isEmpty(mold); - GroovyLog.Msg msg = GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe") - .add(moldEmpty, () -> "mold must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "output must not be empty") - .error(); + GroovyLog.Msg msg = GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe").add(moldEmpty, + () -> "mold must not be empty") + .add(IngredientHelper.isEmpty(output), () -> "output must not be empty").error(); if (moldEmpty) { msg.post(); return; @@ -93,20 +95,17 @@ public void removeByOutput(ItemStack mold, ItemStack output) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe") - .add("no recipes found for {} and {}", mold, output) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe").add("no recipes found for {} and {}", mold, + output).error().post(); } } @MethodDescription(example = @Example("item('immersiveengineering:mold'), item('immersiveengineering:metal:8')")) public void removeByInput(ItemStack mold, ItemStack input) { boolean moldEmpty = IngredientHelper.isEmpty(mold); - GroovyLog.Msg msg = GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe") - .add(moldEmpty, () -> "mold must not be empty") - .add(IngredientHelper.isEmpty(input), () -> "input must not be empty") - .error(); + GroovyLog.Msg msg = GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe").add(moldEmpty, + () -> "mold must not be empty") + .add(IngredientHelper.isEmpty(input), () -> "input must not be empty").error(); if (moldEmpty) { msg.post(); return; @@ -122,20 +121,15 @@ public void removeByInput(ItemStack mold, ItemStack input) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe") - .add("no recipes found for {} and {}", mold, input) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe").add("no recipes found for {} and {}", mold, + input).error().post(); } } @MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('minecraft:iron_ingot')")) public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Immersive Engineering Crusher recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Crusher recipe").add("input must not be empty").error().post(); } if (!MetalPressRecipe.recipeList.values().removeIf(recipe -> { if (ApiUtils.stackMatchesObject(input, recipe.input)) { @@ -144,19 +138,17 @@ public void removeByInput(ItemStack input) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe") - .add("no recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe").add("no recipes found for {}", input).error() + .post(); } } @MethodDescription(example = @Example("item('immersiveengineering:mold:4')")) public void removeByMold(ItemStack mold) { boolean moldEmpty = IngredientHelper.isEmpty(mold); - GroovyLog.Msg msg = GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe") - .add(moldEmpty, () -> "mold must not be empty") - .error(); + GroovyLog.Msg msg = GroovyLog.msg("Error removing Immersive Engineering Metal Press recipe").add(moldEmpty, + () -> "mold must not be empty") + .error(); if (moldEmpty) { msg.post(); return; @@ -180,8 +172,7 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(recipes).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -202,9 +193,7 @@ public RecipeBuilder mold(ItemStack mold) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Metal Press recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Metal Press recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -213,11 +202,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(mold.isEmpty(), "mold must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable MetalPressRecipe register() { if (!validate()) return null; - MetalPressRecipe recipe = new MetalPressRecipe(output.get(0), ImmersiveEngineering.toIngredientStack(input.get(0)), ApiUtils.createComparableItemStack(mold, true), energy); + MetalPressRecipe recipe = new MetalPressRecipe(output.get(0), ImmersiveEngineering.toIngredientStack(input.get(0)), + ApiUtils.createComparableItemStack(mold, true), energy); ModSupport.IMMERSIVE_ENGINEERING.get().metalPress.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Mixer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Mixer.java index d1d0ff9db..1a4668ccb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Mixer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Mixer.java @@ -1,6 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.crafting.MixerRecipe; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -10,12 +17,8 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import blusunrize.immersiveengineering.api.crafting.MixerRecipe; @RegistryDescription public class Mixer extends VirtualizedRegistry { @@ -56,10 +59,9 @@ public boolean remove(MixerRecipe recipe) { @MethodDescription(example = @Example("fluid('potion').withNbt([Potion:'minecraft:night_vision'])")) public void removeByOutput(FluidStack fluidOutput) { - if (GroovyLog.msg("Error removing Immersive Engineering Mixer recipe") - .add(IngredientHelper.isEmpty(fluidOutput), () -> "fluid output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Immersive Engineering Mixer recipe").add(IngredientHelper.isEmpty(fluidOutput), + () -> "fluid output must not be empty").error() + .postIfNotEmpty()) { return; } if (!MixerRecipe.recipeList.removeIf(recipe -> { @@ -69,56 +71,55 @@ public void removeByOutput(FluidStack fluidOutput) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Mixer recipe") - .add("no recipes found for {}", fluidOutput) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Mixer recipe").add("no recipes found for {}", fluidOutput).error() + .post(); } } @MethodDescription(example = @Example("item('minecraft:sand'), item('minecraft:sand'), item('minecraft:clay_ball'), item('minecraft:gravel')")) public void removeByInput(IIngredient... itemInputs) { - if (GroovyLog.msg("Error removing Immersive Engineering Mixer recipe") - .add(itemInputs == null || itemInputs.length == 0, () -> "item input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Immersive Engineering Mixer recipe").add(itemInputs == null || itemInputs.length == 0, + () -> "item input must not be empty").error() + .postIfNotEmpty()) { return; } - List recipes = MixerRecipe.recipeList.stream().filter(r -> r.itemInputs.length == itemInputs.length && - Arrays.stream(itemInputs).anyMatch(check -> Arrays.stream(r.itemInputs).anyMatch(target -> ImmersiveEngineering.areIngredientsEquals(target, check)))) - .collect(Collectors.toList()); + List recipes = MixerRecipe.recipeList.stream().filter(r -> r.itemInputs.length == itemInputs.length && Arrays + .stream(itemInputs) + .anyMatch(check -> Arrays.stream(r.itemInputs) + .anyMatch(target -> ImmersiveEngineering.areIngredientsEquals(target, + check)))) + .collect(Collectors.toList()); for (MixerRecipe recipe : recipes) { remove(recipe); } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Mixer recipe") - .add("no recipes found for {}", Arrays.toString(itemInputs)) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Mixer recipe").add("no recipes found for {}", Arrays.toString( + itemInputs)) + .error().post(); } } @MethodDescription(example = @Example("fluid('water'), item('minecraft:speckled_melon')")) public void removeByInput(FluidStack fluidInput, IIngredient... itemInput) { - if (GroovyLog.msg("Error removing Immersive Engineering Mixer recipe") - .add(IngredientHelper.isEmpty(fluidInput), () -> "fluid input must not be empty") - .add(itemInput == null || itemInput.length == 0, () -> "item input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Immersive Engineering Mixer recipe").add(IngredientHelper.isEmpty(fluidInput), + () -> "fluid input must not be empty").add( + itemInput == null || itemInput.length == 0, + () -> "item input must not be empty") + .error().postIfNotEmpty()) { return; } - List recipes = MixerRecipe.recipeList.stream().filter(r -> fluidInput.isFluidEqual(r.fluidInput) && - r.itemInputs.length == itemInput.length && - Arrays.stream(itemInput).anyMatch(check -> Arrays.stream(r.itemInputs).anyMatch(target -> ImmersiveEngineering.areIngredientsEquals(target, check)))) - .collect(Collectors.toList()); + List recipes = MixerRecipe.recipeList.stream().filter(r -> fluidInput.isFluidEqual( + r.fluidInput) && r.itemInputs.length == itemInput.length && Arrays.stream(itemInput) + .anyMatch(check -> Arrays.stream(r.itemInputs) + .anyMatch(target -> ImmersiveEngineering.areIngredientsEquals(target, + check)))) + .collect(Collectors.toList()); for (MixerRecipe recipe : recipes) { remove(recipe); } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Mixer recipe") - .add("no recipes found for {} and {}", fluidInput, Arrays.toString(itemInput)) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Mixer recipe").add("no recipes found for {} and {}", fluidInput, + Arrays.toString(itemInput)).error().post(); } } @@ -133,7 +134,8 @@ public void removeAll() { MixerRecipe.recipeList.clear(); } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) + @Property(property = "input", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) @Property(property = "output", valid = @Comp("1")) @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) @@ -149,9 +151,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Mixer recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Mixer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -159,8 +159,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 1, 1, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable MixerRecipe register() { if (!validate()) return null; Object[] inputs = ArrayUtils.mapToArray(input, ImmersiveEngineering::toIngredientStack); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Refinery.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Refinery.java index a046eded3..e8b74bcb7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Refinery.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Refinery.java @@ -1,6 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.crafting.RefineryRecipe; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -8,11 +14,8 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; -import java.util.List; -import java.util.stream.Collectors; +import blusunrize.immersiveengineering.api.crafting.RefineryRecipe; @RegistryDescription public class Refinery extends VirtualizedRegistry { @@ -53,10 +56,8 @@ public boolean remove(RefineryRecipe recipe) { @MethodDescription(example = @Example(value = "fluid('biodiesel')", commented = true)) public void removeByOutput(FluidStack fluidOutput) { if (IngredientHelper.isEmpty(fluidOutput)) { - GroovyLog.msg("Error removing Immersive Engineering Refinery recipe") - .add("fluid output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Refinery recipe").add("fluid output must not be empty").error() + .post(); return; } if (!RefineryRecipe.recipeList.removeIf(recipe -> { @@ -66,31 +67,27 @@ public void removeByOutput(FluidStack fluidOutput) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Refinery recipe") - .add("no recipes found for {}", fluidOutput) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Refinery recipe").add("no recipes found for {}", fluidOutput) + .error().post(); } } @MethodDescription(example = @Example("fluid('plantoil'), fluid('ethanol')")) public void removeByInput(FluidStack input0, FluidStack input1) { - if (GroovyLog.msg("Error removing Immersive Engineering Refinery recipe") - .add(IngredientHelper.isEmpty(input0), () -> "fluid input 1 must not be empty") - .add(IngredientHelper.isEmpty(input1), () -> "fluid input 2 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Immersive Engineering Refinery recipe").add(IngredientHelper.isEmpty(input0), + () -> "fluid input 1 must not be empty") + .add(IngredientHelper.isEmpty(input1), () -> "fluid input 2 must not be empty").error().postIfNotEmpty()) { return; } - List recipes = RefineryRecipe.recipeList.stream().filter(r -> (r.input0.isFluidEqual(input0) && r.input1.isFluidEqual(input1)) || (r.input0.isFluidEqual(input1) && r.input1.isFluidEqual(input0))).collect(Collectors.toList()); + List recipes = RefineryRecipe.recipeList.stream().filter(r -> (r.input0.isFluidEqual(input0) && r.input1 + .isFluidEqual(input1)) || (r.input0.isFluidEqual(input1) && r.input1.isFluidEqual(input0))) + .collect(Collectors.toList()); for (RefineryRecipe recipe : recipes) { remove(recipe); } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Refinery recipe") - .add("no recipes found for {} and {}", input0, input1) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Refinery recipe").add("no recipes found for {} and {}", input0, + input1).error().post(); } } @@ -105,8 +102,7 @@ public void removeAll() { RefineryRecipe.recipeList.clear(); } - @Property(property = "fluidInput", valid = @Comp("2")) - @Property(property = "fluidOutput", valid = @Comp("1")) + @Property(property = "fluidInput", valid = @Comp("2")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -119,9 +115,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Refinery recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Refinery recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -129,8 +123,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 2, 2, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RefineryRecipe register() { if (!validate()) return null; RefineryRecipe recipe = new RefineryRecipe(fluidOutput.get(0), fluidInput.get(0), fluidInput.get(1), energy); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Squeezer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Squeezer.java index 0643270e4..1bccffe5e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Squeezer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Squeezer.java @@ -1,6 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import blusunrize.immersiveengineering.api.crafting.SqueezerRecipe; +import java.util.List; +import java.util.stream.Collectors; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,22 +18,15 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; -import javax.annotation.Nonnull; -import java.util.List; -import java.util.stream.Collectors; +import blusunrize.immersiveengineering.api.crafting.SqueezerRecipe; @RegistryDescription public class Squeezer extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).fluidOutput(fluid('lava')).energy(100)"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).energy(100)"), - @Example(".input(item('minecraft:clay')).fluidOutput(fluid('water')).energy(100)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).fluidOutput(fluid('lava')).energy(100)"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).energy(100)"), + @Example(".input(item('minecraft:clay')).fluidOutput(fluid('water')).energy(100)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -44,7 +46,8 @@ public void add(SqueezerRecipe recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION) public SqueezerRecipe add(FluidStack fluidOutput, @Nonnull ItemStack itemOutput, IIngredient input, int energy) { - SqueezerRecipe recipe = new SqueezerRecipe(fluidOutput, itemOutput, ImmersiveEngineering.toIngredientStack(input), energy); + SqueezerRecipe recipe = new SqueezerRecipe(fluidOutput, itemOutput, ImmersiveEngineering.toIngredientStack(input), + energy); add(recipe); return recipe; } @@ -60,10 +63,8 @@ public boolean remove(SqueezerRecipe recipe) { @MethodDescription(example = @Example("fluid('plantoil')")) public void removeByOutput(FluidStack fluidOutput) { if (IngredientHelper.isEmpty(fluidOutput)) { - GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe") - .add("fluid output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe").add("fluid output must not be empty").error() + .post(); return; } if (!SqueezerRecipe.recipeList.removeIf(recipe -> { @@ -73,71 +74,62 @@ public void removeByOutput(FluidStack fluidOutput) { } return false; })) { - GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe") - .add("no recipes found for {}", fluidOutput) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe").add("no recipes found for {}", fluidOutput) + .error().post(); } } @MethodDescription public void removeByOutput(FluidStack fluidOutput, ItemStack itemOutput) { - if (GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe") - .add(IngredientHelper.isEmpty(fluidOutput), () -> "fluid output must not be empty") - .add(IngredientHelper.isEmpty(itemOutput), () -> "item input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe").add(IngredientHelper.isEmpty(fluidOutput), + () -> "fluid output must not be empty").add( + IngredientHelper.isEmpty(itemOutput), + () -> "item input must not be empty") + .error().postIfNotEmpty()) { return; } - List recipes = SqueezerRecipe.recipeList.stream().filter(r -> fluidOutput.isFluidEqual(r.fluidOutput) && r.itemOutput.isItemEqual(itemOutput)).collect(Collectors.toList()); + List recipes = SqueezerRecipe.recipeList.stream().filter(r -> fluidOutput.isFluidEqual( + r.fluidOutput) && r.itemOutput.isItemEqual(itemOutput)) + .collect(Collectors.toList()); for (SqueezerRecipe recipe : recipes) { remove(recipe); } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe") - .add("no recipes found for {} and {}", fluidOutput, itemOutput) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe").add("no recipes found for {} and {}", + fluidOutput, itemOutput).error().post(); } } @MethodDescription(example = @Example("item('immersiveengineering:material:18')")) public void removeByOutput(ItemStack itemOutput) { - if (GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe") - .add(IngredientHelper.isEmpty(itemOutput), () -> "item input must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe").add(IngredientHelper.isEmpty(itemOutput), + () -> "item input must not be empty") + .error().postIfNotEmpty()) { return; } // "Condition 'r.itemOutput != null' is always 'true'" is a lie. It can be null, and if it is it *will* throw an NPE if we don't check against it. - @SuppressWarnings("ConstantValue") - List recipes = SqueezerRecipe.recipeList.stream().filter(r -> r != null && r.itemOutput != null && r.itemOutput.isItemEqual(itemOutput)).collect(Collectors.toList()); + @SuppressWarnings("ConstantValue") List recipes = SqueezerRecipe.recipeList.stream().filter( + r -> r != null && r.itemOutput != null && r.itemOutput.isItemEqual(itemOutput)) + .collect(Collectors.toList()); for (SqueezerRecipe recipe : recipes) { remove(recipe); } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe") - .add("no recipes found for {}", itemOutput) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe").add("no recipes found for {}", itemOutput) + .error().post(); } } @MethodDescription(example = @Example("item('minecraft:wheat_seeds')")) public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { - GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe") - .add("input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe").add("input must not be empty").error().post(); return; } SqueezerRecipe recipe = SqueezerRecipe.findRecipe(input); if (recipe == null || !remove(recipe)) { - GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe") - .add("no recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Immersive Engineering Squeezer recipe").add("no recipes found for {}", input).error() + .post(); } } @@ -154,7 +146,8 @@ public void removeAll() { @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) - @Property(property = "fluidOutput", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) + @Property(property = "fluidOutput", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) private static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -167,9 +160,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Engineering Refinery recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Engineering Refinery recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -178,11 +169,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(fluidOutput.isEmpty() && output.isEmpty(), "Either a fluid output or an item output must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SqueezerRecipe register() { if (!validate()) return null; - SqueezerRecipe recipe = new SqueezerRecipe(fluidOutput.getOrEmpty(0), output.getOrEmpty(0), ImmersiveEngineering.toIngredientStack(input.get(0)), energy); + SqueezerRecipe recipe = new SqueezerRecipe(fluidOutput.getOrEmpty(0), output.getOrEmpty(0), ImmersiveEngineering + .toIngredientStack(input.get(0)), + energy); ModSupport.IMMERSIVE_ENGINEERING.get().squeezer.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/TimeRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/TimeRecipeBuilder.java index 4d37a7b91..792ed3ee7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/TimeRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/TimeRecipeBuilder.java @@ -1,10 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; -import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import org.jetbrains.annotations.ApiStatus; -@Deprecated -@ApiStatus.ScheduledForRemoval +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + +@Deprecated @ApiStatus.ScheduledForRemoval public abstract class TimeRecipeBuilder extends AbstractRecipeBuilder { protected int time; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Distillation.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Distillation.java index fdefd1174..747d77c0c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Distillation.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Distillation.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.immersivepetroleum; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,27 +14,20 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import flaxbeard.immersivepetroleum.api.crafting.DistillationRecipe; import it.unimi.dsi.fastutil.floats.FloatArrayList; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Distillation extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('water') * 100).fluidOutput(fluid('water') * 50, fluid('lava') * 30).output(item('minecraft:diamond'), 0.5).output(item('minecraft:clay'), 0.2).output(item('minecraft:diamond'), 0.1).output(item('minecraft:clay'), 0.5).output(item('minecraft:diamond') * 5, 0.01).time(5).energy(1000)"), - @Example(".fluidInput(fluid('lava') * 5).output(item('minecraft:diamond')).time(1)") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('water') * 100).fluidOutput(fluid('water') * 50, fluid('lava') * 30).output(item('minecraft:diamond'), 0.5).output(item('minecraft:clay'), 0.2).output(item('minecraft:diamond'), 0.1).output(item('minecraft:clay'), 0.5).output(item('minecraft:diamond') * 5, 0.01).time(5).energy(1000)"), + @Example(".fluidInput(fluid('lava') * 5).output(item('minecraft:diamond')).time(1)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> DistillationRecipe.recipeList.removeIf(r -> r == recipe)); DistillationRecipe.recipeList.addAll(restoreFromBackup()); @@ -49,10 +48,9 @@ public boolean remove(DistillationRecipe recipe) { return false; } - @MethodDescription(example = { - @Example(value = "item('immersivepetroleum:material')", commented = true), - @Example(value = "fluid('lubricant')", commented = true) - }) + @MethodDescription(example = {@Example(value = "item('immersivepetroleum:material')", commented = true), @Example( + value = "fluid('lubricant')", + commented = true)}) public void removeByOutput(IIngredient output) { DistillationRecipe.recipeList.removeIf(r -> { for (ItemStack itemstack : r.getItemOutputs()) { @@ -96,8 +94,10 @@ public void removeAll() { } @Property(property = "fluidInput", valid = @Comp("1")) - @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) - @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) + @Property(property = "output", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) + @Property(property = "fluidOutput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) @@ -114,8 +114,7 @@ public RecipeBuilder output(ItemStack output, float chance) { return this; } - @Override - @RecipeBuilderMethodDescription(field = {"output", "chance"}) + @Override @RecipeBuilderMethodDescription(field = {"output", "chance"}) public RecipeBuilder output(ItemStack output) { return this.output(output, 1); } @@ -133,25 +132,26 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Immersive Petroleum Distillation recipe"; - } + public String getErrorMsg() { return "Error adding Immersive Petroleum Distillation recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 0, 0, 0, Integer.MAX_VALUE); validateFluids(msg, 1, 1, 0, Integer.MAX_VALUE); chance.trim(); - msg.add(output.size() != chance.size(), "output and chance must be of equal length, yet output was {} and chance was {}", output.size(), chance.size()); + msg.add(output.size() != chance.size(), + "output and chance must be of equal length, yet output was {} and chance was {}", output.size(), chance + .size()); msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); msg.add(energy < 0, "energy must be a non negative integer, yet it was {}", energy); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable DistillationRecipe register() { if (!validate()) return null; - DistillationRecipe recipe = new DistillationRecipe(fluidOutput.toArray(new FluidStack[0]), output.toArray(new ItemStack[0]), fluidInput.get(0), energy, time, chance.elements()); + DistillationRecipe recipe = new DistillationRecipe(fluidOutput.toArray(new FluidStack[0]), output.toArray( + new ItemStack[0]), + fluidInput.get(0), energy, time, chance.elements()); ModSupport.IMMERSIVE_PETROLEUM.get().distillation.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Reservoir.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Reservoir.java index 5f41c2667..37efce7f8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Reservoir.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Reservoir.java @@ -1,34 +1,33 @@ package com.cleanroommc.groovyscript.compat.mods.immersivepetroleum; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import flaxbeard.immersivepetroleum.api.crafting.PumpjackHandler; import it.unimi.dsi.fastutil.ints.IntArrayList; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - admonition = @Admonition(value = "groovyscript.wiki.immersivepetroleum.reservoir.note0", - type = Admonition.Type.WARNING, - format = Admonition.Format.STANDARD) -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES, + admonition = @Admonition(value = "groovyscript.wiki.immersivepetroleum.reservoir.note0", + type = Admonition.Type.WARNING, + format = Admonition.Format.STANDARD)) public class Reservoir extends VirtualizedRegistry> { - @RecipeBuilderDescription(example = { - @Example(".name('demo').fluidOutput(fluid('water')).weight(20000).minSize(100).maxSize(100).dimension(0, 1).biome('hot')"), - @Example(".name('demo').fluidOutput(fluid('lava')).weight(2000).minSize(1000).maxSize(5000).replenishRate(100).dimension(-1, 1).dimensionBlacklist().biome('cold').biomeBlacklist()") - }) + @RecipeBuilderDescription(example = {@Example(".name('demo').fluidOutput(fluid('water')).weight(20000).minSize(100).maxSize(100).dimension(0, 1).biome('hot')"), + @Example(".name('demo').fluidOutput(fluid('lava')).weight(2000).minSize(1000).maxSize(5000).replenishRate(100).dimension(-1, 1).dimensionBlacklist().biome('cold').biomeBlacklist()")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -112,8 +111,7 @@ public static class RecipeBuilder extends AbstractRecipeBuilder { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { BioReactorEntry.BIO_REACTOR_ENTRIES.removeAll(removeScripted()); BioReactorEntry.BIO_REACTOR_ENTRIES.addAll(restoreFromBackup()); } - @MethodDescription(description = "groovyscript.wiki.industrialforegoing.bio_reactor.add0", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay')")) + @MethodDescription(description = "groovyscript.wiki.industrialforegoing.bio_reactor.add0", + type = MethodDescription.Type.ADDITION, + example = @Example("item('minecraft:clay')")) public IReactorEntry add(ItemStack input) { return add(input, null); } - @MethodDescription(description = "groovyscript.wiki.industrialforegoing.bio_reactor.add1", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.industrialforegoing.bio_reactor.add1", + type = MethodDescription.Type.ADDITION) public IReactorEntry add(ItemStack input, @Nullable Predicate nbtCheck) { IReactorEntry recipe = new BioReactorEntry(input, nbtCheck); add(recipe); @@ -68,8 +72,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BioReactorEntry.BIO_REACTOR_ENTRIES) - .setRemover(this::remove); + return new SimpleObjectStream<>(BioReactorEntry.BIO_REACTOR_ENTRIES).setRemover(this::remove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Extractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Extractor.java index b993e0ab5..1794091b7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Extractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Extractor.java @@ -1,5 +1,8 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + import com.buuz135.industrial.api.extractor.ExtractorEntry; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,8 +12,6 @@ import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; @RegistryDescription public class Extractor extends VirtualizedRegistry { @@ -19,19 +20,22 @@ public Extractor() { super(Alias.generateOfClass(Extractor.class).andGenerate("TreeFluidExtractor")); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { ExtractorEntry.EXTRACTOR_ENTRIES.removeAll(removeScripted()); ExtractorEntry.EXTRACTOR_ENTRIES.addAll(restoreFromBackup()); } - @MethodDescription(description = "groovyscript.wiki.industrialforegoing.extractor.add0", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay'), fluid('lava') * 50")) + @MethodDescription(description = "groovyscript.wiki.industrialforegoing.extractor.add0", + type = MethodDescription.Type.ADDITION, + example = @Example("item('minecraft:clay'), fluid('lava') * 50")) public ExtractorEntry add(ItemStack input, FluidStack output) { return add(input, output, 0.005F); } - @MethodDescription(description = "groovyscript.wiki.industrialforegoing.extractor.add1", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:stone'), fluid('water') * 100, 1")) + @MethodDescription(description = "groovyscript.wiki.industrialforegoing.extractor.add1", + type = MethodDescription.Type.ADDITION, + example = @Example("item('minecraft:stone'), fluid('water') * 100, 1")) public ExtractorEntry add(ItemStack input, FluidStack output, float breakChance) { ExtractorEntry recipe = new ExtractorEntry(input, output, breakChance); add(recipe); @@ -81,8 +85,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ExtractorEntry.EXTRACTOR_ENTRIES) - .setRemover(this::remove); + return new SimpleObjectStream<>(ExtractorEntry.EXTRACTOR_ENTRIES).setRemover(this::remove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/FluidDictionary.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/FluidDictionary.java index b1d602245..d2a15c87d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/FluidDictionary.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/FluidDictionary.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; +import net.minecraftforge.fluids.FluidStack; + import com.buuz135.industrial.api.recipe.FluidDictionaryEntry; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -7,35 +9,33 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraftforge.fluids.FluidStack; @RegistryDescription public class FluidDictionary extends VirtualizedRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES.removeAll(removeScripted()); FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES.addAll(restoreFromBackup()); } - @MethodDescription(description = "groovyscript.wiki.industrialforegoing.fluid_dictionary.add0", type = MethodDescription.Type.ADDITION, example = { - @Example("fluid('biofuel'), fluid('latex'),"), - @Example("fluid('latex'), fluid('biofuel'),") - }) + @MethodDescription(description = "groovyscript.wiki.industrialforegoing.fluid_dictionary.add0", + type = MethodDescription.Type.ADDITION, + example = {@Example("fluid('biofuel'), fluid('latex'),"), @Example("fluid('latex'), fluid('biofuel'),")}) public FluidDictionaryEntry add(FluidStack input, FluidStack output) { return add(input, output, 1); } - @MethodDescription(description = "groovyscript.wiki.industrialforegoing.fluid_dictionary.add1", type = MethodDescription.Type.ADDITION, example = { - @Example("fluid('essence'), fluid('latex'), 2"), - @Example("fluid('latex'), fluid('essence'), 0.5") - }) + @MethodDescription(description = "groovyscript.wiki.industrialforegoing.fluid_dictionary.add1", + type = MethodDescription.Type.ADDITION, + example = {@Example("fluid('essence'), fluid('latex'), 2"), + @Example("fluid('latex'), fluid('essence'), 0.5")}) public FluidDictionaryEntry add(FluidStack input, FluidStack output, double ratio) { return add(input.getFluid().getName(), output.getFluid().getName(), ratio); } - @MethodDescription(description = "groovyscript.wiki.industrialforegoing.fluid_dictionary.add1", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.industrialforegoing.fluid_dictionary.add1", + type = MethodDescription.Type.ADDITION) public FluidDictionaryEntry add(String input, String output, double ratio) { FluidDictionaryEntry recipe = new FluidDictionaryEntry(input, output, ratio); add(recipe); @@ -95,8 +95,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES) - .setRemover(this::remove); + return new SimpleObjectStream<>(FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES).setRemover(this::remove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/LaserDrill.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/LaserDrill.java index 915af19d6..8b875935e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/LaserDrill.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/LaserDrill.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.biome.Biome; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.buuz135.industrial.api.recipe.LaserDrillEntry; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; @@ -9,14 +19,6 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.world.biome.Biome; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; @RegistryDescription public class LaserDrill extends VirtualizedRegistry> { @@ -26,15 +28,15 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { - removeScripted().forEach(pair -> LaserDrillEntry.findForOre(pair.getKey().getStack(), pair.getKey()).getRarities().remove(pair.getValue())); - restoreFromBackup().forEach(pair -> LaserDrillEntry.findForOre(pair.getKey().getStack(), pair.getKey()).getRarities().add(pair.getValue())); + removeScripted().forEach(pair -> LaserDrillEntry.findForOre(pair.getKey().getStack(), pair.getKey()).getRarities().remove( + pair.getValue())); + restoreFromBackup().forEach(pair -> LaserDrillEntry.findForOre(pair.getKey().getStack(), pair.getKey()).getRarities().add( + pair.getValue())); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void afterScriptLoad() { // Clear any empty values to prevent JEI integration from causing an IndexOutOfBoundsException LaserDrillEntry.LASER_DRILL_UNIQUE_VALUES.removeIf(x -> x.getRarities().isEmpty()); @@ -47,7 +49,11 @@ public void afterScriptLoad() { for (LaserDrillEntry.LaserDrillEntryExtended entryExtended : LaserDrillEntry.LASER_DRILL_UNIQUE_VALUES) { for (LaserDrillEntry.OreRarity oreRarity : entryExtended.getRarities()) { for (int y = oreRarity.getMinY(); y <= oreRarity.getMaxY(); y++) { - LaserDrillEntry.LASER_DRILL_ENTRIES[y].add(new LaserDrillEntry(entryExtended.getLaserMeta(), entryExtended.getStack(), oreRarity.getWeight(), oreRarity.getWhitelist(), oreRarity.getBlacklist())); + LaserDrillEntry.LASER_DRILL_ENTRIES[y].add(new LaserDrillEntry(entryExtended.getLaserMeta(), entryExtended + .getStack(), + oreRarity.getWeight(), oreRarity + .getWhitelist(), + oreRarity.getBlacklist())); } } } @@ -143,8 +149,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(LaserDrillEntry.LASER_DRILL_UNIQUE_VALUES) - .setRemover(this::remove); + return new SimpleObjectStream<>(LaserDrillEntry.LASER_DRILL_UNIQUE_VALUES).setRemover(this::remove); } @Property(property = "output", valid = @Comp("1")) @@ -232,9 +237,7 @@ public RecipeBuilder maxY(int maxY) { } @Override - public String getErrorMsg() { - return "Error adding Industrial Foregoing Laser Drill Entry"; - } + public String getErrorMsg() { return "Error adding Industrial Foregoing Laser Drill Entry"; } @Override public void validate(GroovyLog.Msg msg) { @@ -246,11 +249,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(minY > maxY, "minY must be less than or equal to maxY, yet minY was {} and maxY was {}", minY, maxY); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable LaserDrillEntry.LaserDrillEntryExtended register() { if (!validate()) return null; - LaserDrillEntry.LaserDrillEntryExtended recipe = LaserDrillEntry.findForOre(output.get(0), new LaserDrillEntry.LaserDrillEntryExtended(lensMeta, output.get(0))); + LaserDrillEntry.LaserDrillEntryExtended recipe = LaserDrillEntry.findForOre(output.get(0), + new LaserDrillEntry.LaserDrillEntryExtended(lensMeta, + output.get(0))); LaserDrillEntry.OreRarity entry = new LaserDrillEntry.OreRarity(weight, whitelist, blacklist, maxY, minY); ModSupport.INDUSTRIAL_FOREGOING.get().laserDrill.add(recipe, entry); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreFermenter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreFermenter.java index 138dd619b..4db07a5e6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreFermenter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreFermenter.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; +import net.minecraftforge.fluids.FluidStack; + import com.buuz135.industrial.api.recipe.ore.OreFluidEntryFermenter; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,7 +11,6 @@ import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraftforge.fluids.FluidStack; @RegistryDescription public class OreFermenter extends VirtualizedRegistry { @@ -18,14 +19,14 @@ public OreFermenter() { super(Alias.generateOfClass(OreFermenter.class).andGenerate("Fermentation")); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { OreFluidEntryFermenter.ORE_FLUID_FERMENTER.removeAll(removeScripted()); OreFluidEntryFermenter.ORE_FLUID_FERMENTER.addAll(restoreFromBackup()); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("fluid('if.ore_fluid_raw').withNbt(['Ore': 'oreGold']), fluid('if.ore_fluid_fermented').withNbt(['Ore': 'oreGold']) * 2")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("fluid('if.ore_fluid_raw').withNbt(['Ore': 'oreGold']), fluid('if.ore_fluid_fermented').withNbt(['Ore': 'oreGold']) * 2")) public OreFluidEntryFermenter add(FluidStack input, FluidStack output) { OreFluidEntryFermenter recipe = new OreFluidEntryFermenter(input, output); add(recipe); @@ -56,7 +57,8 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(example = @Example(value = "fluid('if.ore_fluid_fermented').withNbt([Ore: 'oreRedstone'])", commented = true)) + @MethodDescription(example = @Example(value = "fluid('if.ore_fluid_fermented').withNbt([Ore: 'oreRedstone'])", + commented = true)) public boolean removeByOutput(IIngredient output) { return OreFluidEntryFermenter.ORE_FLUID_FERMENTER.removeIf(recipe -> { if (output.test(recipe.getOutput())) { @@ -75,8 +77,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(OreFluidEntryFermenter.ORE_FLUID_FERMENTER) - .setRemover(this::remove); + return new SimpleObjectStream<>(OreFluidEntryFermenter.ORE_FLUID_FERMENTER).setRemover(this::remove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreRaw.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreRaw.java index e9754ce8d..77f0136e3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreRaw.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreRaw.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; +import net.minecraftforge.fluids.FluidStack; + import com.buuz135.industrial.api.recipe.ore.OreFluidEntryRaw; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; @@ -10,7 +12,6 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraftforge.fluids.FluidStack; @RegistryDescription public class OreRaw extends VirtualizedRegistry { @@ -19,17 +20,15 @@ public OreRaw() { super(Alias.generateOfClass(OreRaw.class).andGenerate("Washing")); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { OreFluidEntryRaw.ORE_RAW_ENTRIES.removeAll(removeScripted()); OreFluidEntryRaw.ORE_RAW_ENTRIES.addAll(restoreFromBackup()); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = { - @Example("ore('oreGold'), fluid('meat') * 200, fluid('if.ore_fluid_raw').withNbt(['Ore': 'oreGold']) * 300"), - @Example("ore('stone'), fluid('water') * 1000, fluid('lava') * 50") - }) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = {@Example("ore('oreGold'), fluid('meat') * 200, fluid('if.ore_fluid_raw').withNbt(['Ore': 'oreGold']) * 300"), + @Example("ore('stone'), fluid('water') * 1000, fluid('lava') * 50")}) public OreFluidEntryRaw add(OreDictIngredient ore, FluidStack input, FluidStack output) { return add(ore.getOreDict(), input, output); } @@ -100,8 +99,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(OreFluidEntryRaw.ORE_RAW_ENTRIES) - .setRemover(this::remove); + return new SimpleObjectStream<>(OreFluidEntryRaw.ORE_RAW_ENTRIES).setRemover(this::remove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreSieve.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreSieve.java index 14c8df88c..7df9eff3d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreSieve.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreSieve.java @@ -1,5 +1,8 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + import com.buuz135.industrial.api.recipe.ore.OreFluidEntrySieve; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,8 +12,6 @@ import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; @RegistryDescription public class OreSieve extends VirtualizedRegistry { @@ -19,17 +20,15 @@ public OreSieve() { super(Alias.generateOfClass(OreSieve.class).andGenerate("FluidSieving")); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { OreFluidEntrySieve.ORE_FLUID_SIEVE.removeAll(removeScripted()); OreFluidEntrySieve.ORE_FLUID_SIEVE.addAll(restoreFromBackup()); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = { - @Example("fluid('if.ore_fluid_fermented').withNbt(['Ore': 'oreGold']) * 100, item('minecraft:nether_star') * 2, item('minecraft:clay')"), - @Example("fluid('lava') * 5, item('minecraft:gold_ingot'), item('minecraft:clay')") - }) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = {@Example("fluid('if.ore_fluid_fermented').withNbt(['Ore': 'oreGold']) * 100, item('minecraft:nether_star') * 2, item('minecraft:clay')"), + @Example("fluid('lava') * 5, item('minecraft:gold_ingot'), item('minecraft:clay')")}) public OreFluidEntrySieve add(FluidStack input, ItemStack output, ItemStack sieveItem) { OreFluidEntrySieve recipe = new OreFluidEntrySieve(input, output, sieveItem); add(recipe); @@ -49,10 +48,7 @@ public boolean remove(OreFluidEntrySieve recipe) { return true; } - @MethodDescription(example = { - @Example("item('minecraft:sand')"), - @Example("fluid('if.pink_slime')") - }) + @MethodDescription(example = {@Example("item('minecraft:sand')"), @Example("fluid('if.pink_slime')")}) public boolean removeByInput(IIngredient input) { return OreFluidEntrySieve.ORE_FLUID_SIEVE.removeIf(recipe -> { if (input.test(recipe.getInput()) || input.test(recipe.getSieveItem())) { @@ -82,8 +78,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(OreFluidEntrySieve.ORE_FLUID_SIEVE) - .setRemover(this::remove); + return new SimpleObjectStream<>(OreFluidEntrySieve.ORE_FLUID_SIEVE).setRemover(this::remove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/ProteinReactor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/ProteinReactor.java index 02c01784b..6b164c3a4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/ProteinReactor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/ProteinReactor.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import org.jetbrains.annotations.Nullable; + import com.buuz135.industrial.api.recipe.IReactorEntry; import com.buuz135.industrial.api.recipe.ProteinReactorEntry; import com.cleanroommc.groovyscript.api.GroovyBlacklist; @@ -10,26 +15,25 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.google.common.base.Predicate; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class ProteinReactor extends VirtualizedRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES.removeAll(removeScripted()); ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES.addAll(restoreFromBackup()); } - @MethodDescription(description = "groovyscript.wiki.industrialforegoing.protein_reactor.add0", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay')")) + @MethodDescription(description = "groovyscript.wiki.industrialforegoing.protein_reactor.add0", + type = MethodDescription.Type.ADDITION, + example = @Example("item('minecraft:clay')")) public IReactorEntry add(ItemStack input) { return add(input, null); } - @MethodDescription(description = "groovyscript.wiki.industrialforegoing.protein_reactor.add1", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.industrialforegoing.protein_reactor.add1", + type = MethodDescription.Type.ADDITION) public IReactorEntry add(ItemStack input, @Nullable Predicate nbtCheck) { IReactorEntry recipe = new ProteinReactorEntry(input, nbtCheck); add(recipe); @@ -68,8 +72,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES) - .setRemover(this::remove); + return new SimpleObjectStream<>(ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES).setRemover(this::remove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/SludgeRefiner.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/SludgeRefiner.java index 04e7419d5..58d921d7c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/SludgeRefiner.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/SludgeRefiner.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; +import net.minecraft.item.ItemStack; + import com.buuz135.industrial.api.recipe.SludgeEntry; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,20 +11,17 @@ import com.cleanroommc.groovyscript.core.mixin.industrialforegoing.SludgeRefinerBlockAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; @RegistryDescription public class SludgeRefiner extends VirtualizedRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { SludgeEntry.SLUDGE_RECIPES.removeAll(removeScripted()); SludgeEntry.SLUDGE_RECIPES.addAll(restoreFromBackup()); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void afterScriptLoad() { // Clear the list and cause the sludge refiner to recompute outputs SludgeRefinerBlockAccessor.setOutputs(null); @@ -67,8 +66,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SludgeEntry.SLUDGE_RECIPES) - .setRemover(this::remove); + return new SimpleObjectStream<>(SludgeEntry.SLUDGE_RECIPES).setRemover(this::remove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Straw.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Straw.java index 496890f4c..bf6e3569b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Straw.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Straw.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; +import java.util.ArrayList; +import java.util.Collection; + +import net.minecraft.potion.PotionEffect; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.buuz135.industrial.api.straw.StrawHandler; import com.buuz135.industrial.registry.IFRegistries; import com.buuz135.industrial.utils.apihandlers.straw.PotionStrawHandler; @@ -8,12 +16,6 @@ import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; -import net.minecraft.potion.PotionEffect; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; @RegistryDescription public class Straw extends ForgeRegistryWrapper { @@ -22,30 +24,23 @@ public Straw() { super(IFRegistries.STRAW_HANDLER_REGISTRY); } - @RecipeBuilderDescription(example = @Example(value = ".fluidInput(fluid('if.pink_slime')).effect(new PotionEffect(potion('minecraft:strength'), 1800, 3))", imports = "net.minecraft.potion.PotionEffect")) + @RecipeBuilderDescription(example = @Example(value = ".fluidInput(fluid('if.pink_slime')).effect(new PotionEffect(potion('minecraft:strength'), 1800, 3))", + imports = "net.minecraft.potion.PotionEffect")) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @MethodDescription(description = "groovyscript.wiki.industrialforegoing.straw.add0", type = MethodDescription.Type.ADDITION) public StrawHandler add(FluidStack fluidInput, Collection effect) { - return recipeBuilder() - .effect(effect) - .fluidInput(fluidInput) - .register(); + return recipeBuilder().effect(effect).fluidInput(fluidInput).register(); } @MethodDescription(description = "groovyscript.wiki.industrialforegoing.straw.add1", type = MethodDescription.Type.ADDITION) public StrawHandler add(String name, FluidStack fluidInput, Collection effect) { - return recipeBuilder() - .effect(effect) - .name(name) - .fluidInput(fluidInput) - .register(); + return recipeBuilder().effect(effect).name(name).fluidInput(fluidInput).register(); } - @Property(property = "fluidInput", valid = @Comp("1")) - @Property(property = "name") + @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "name") public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.GTE, value = "1")) @@ -74,14 +69,10 @@ public RecipeBuilder effect(Collection effects) { } @Override - public String getErrorMsg() { - return "Error adding Industrial Foregoing Straw Entry"; - } + public String getErrorMsg() { return "Error adding Industrial Foregoing Straw Entry"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_straw_entry_"; - } + public String getRecipeNamePrefix() { return "groovyscript_straw_entry_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -91,8 +82,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(effect.isEmpty(), "effect must have entries, yet it was empty"); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable StrawHandler register() { if (!validate()) return null; PotionStrawHandler recipe = new PotionStrawHandler(fluidInput.get(0).getFluid()); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/AnvilSmashing.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/AnvilSmashing.java index d2eeaf6cd..9c7b7769d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/AnvilSmashing.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/AnvilSmashing.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.inspirations; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -8,15 +18,8 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import knightminer.inspirations.library.InspirationsRegistry; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; -import java.util.Map; -import java.util.stream.Collectors; +import knightminer.inspirations.library.InspirationsRegistry; @RegistryDescription public class AnvilSmashing extends VirtualizedRegistry> { @@ -24,10 +27,8 @@ public class AnvilSmashing extends VirtualizedRegistry> blockStorage = new AbstractReloadableStorage<>(); private final AbstractReloadableStorage materialStorage = new AbstractReloadableStorage<>(); - @RecipeBuilderDescription(example = { - @Example(".input(blockstate('minecraft:diamond_block')).output(blockstate('minecraft:clay'))"), - @Example(".input(blockstate('minecraft:clay')).output(blockstate('minecraft:air'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(blockstate('minecraft:diamond_block')).output(blockstate('minecraft:clay'))"), + @Example(".input(blockstate('minecraft:clay')).output(blockstate('minecraft:air'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -36,8 +37,10 @@ public RecipeBuilder recipeBuilder() { public void onReload() { removeScripted().forEach(pair -> InspirationsRegistryAccessor.getAnvilSmashing().remove(pair.getKey(), pair.getValue())); restoreFromBackup().forEach(pair -> InspirationsRegistryAccessor.getAnvilSmashing().put(pair.getKey(), pair.getValue())); - blockStorage.removeScripted().forEach(pair -> InspirationsRegistryAccessor.getAnvilSmashingBlocks().remove(pair.getKey(), pair.getValue())); - blockStorage.restoreFromBackup().forEach(pair -> InspirationsRegistryAccessor.getAnvilSmashingBlocks().put(pair.getKey(), pair.getValue())); + blockStorage.removeScripted().forEach(pair -> InspirationsRegistryAccessor.getAnvilSmashingBlocks().remove(pair.getKey(), + pair.getValue())); + blockStorage.restoreFromBackup().forEach(pair -> InspirationsRegistryAccessor.getAnvilSmashingBlocks().put(pair.getKey(), + pair.getValue())); materialStorage.restoreFromBackup().forEach(mat -> InspirationsRegistryAccessor.getAnvilBreaking().add(mat)); } @@ -80,8 +83,8 @@ public boolean remove(Material material) { @MethodDescription public void removeByInput(IBlockState input) { for (Map.Entry recipe : InspirationsRegistryAccessor.getAnvilSmashing().entrySet().stream() - .filter(r -> r.getKey().equals(input)) - .collect(Collectors.toList())) { + .filter(r -> r.getKey().equals(input)) + .collect(Collectors.toList())) { addBackup(Pair.of(recipe.getKey(), recipe.getValue())); InspirationsRegistryAccessor.getAnvilSmashing().remove(recipe.getKey(), recipe.getValue()); } @@ -90,8 +93,8 @@ public void removeByInput(IBlockState input) { @MethodDescription(example = @Example("blockstate('minecraft:packed_ice')")) public void removeByInput(Block input) { for (Map.Entry recipe : InspirationsRegistryAccessor.getAnvilSmashingBlocks().entrySet().stream() - .filter(r -> r.getKey().equals(input)) - .collect(Collectors.toList())) { + .filter(r -> r.getKey().equals(input)).collect( + Collectors.toList())) { blockStorage.addBackup(Pair.of(recipe.getKey(), recipe.getValue())); InspirationsRegistryAccessor.getAnvilSmashingBlocks().remove(recipe.getKey(), recipe.getValue()); } @@ -100,14 +103,14 @@ public void removeByInput(Block input) { @MethodDescription(example = @Example("blockstate('minecraft:cobblestone')")) public void removeByOutput(IBlockState output) { for (Map.Entry recipe : InspirationsRegistryAccessor.getAnvilSmashing().entrySet().stream() - .filter(r -> r.getValue().equals(output)) - .collect(Collectors.toList())) { + .filter(r -> r.getValue().equals(output)) + .collect(Collectors.toList())) { addBackup(Pair.of(recipe.getKey(), recipe.getValue())); InspirationsRegistryAccessor.getAnvilSmashing().remove(recipe.getKey(), recipe.getValue()); } for (Map.Entry recipe : InspirationsRegistryAccessor.getAnvilSmashingBlocks().entrySet().stream() - .filter(r -> r.getValue().equals(output)) - .collect(Collectors.toList())) { + .filter(r -> r.getValue().equals(output)).collect( + Collectors.toList())) { blockStorage.addBackup(Pair.of(recipe.getKey(), recipe.getValue())); InspirationsRegistryAccessor.getAnvilSmashingBlocks().remove(recipe.getKey(), recipe.getValue()); } @@ -125,8 +128,9 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(InspirationsRegistryAccessor.getAnvilSmashing().entrySet()) - .setRemover(r -> remove(r.getKey(), r.getValue())); + return new SimpleObjectStream<>(InspirationsRegistryAccessor.getAnvilSmashing().entrySet()).setRemover(r -> remove(r + .getKey(), + r.getValue())); } public static class RecipeBuilder extends AbstractRecipeBuilder { @@ -158,9 +162,7 @@ public RecipeBuilder output(IBlockState output) { } @Override - public String getErrorMsg() { - return "Error adding Inspirations Anvil Smashing recipe"; - } + public String getErrorMsg() { return "Error adding Inspirations Anvil Smashing recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -168,8 +170,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(output == null, "output must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable Object register() { if (!validate()) return null; if (inputBlock == null) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/Cauldron.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/Cauldron.java index 95d1429b3..8afb90a16 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/Cauldron.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/Cauldron.java @@ -1,5 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.inspirations; +import java.util.Arrays; +import java.util.Locale; +import java.util.stream.Collectors; + +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionType; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvent; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.common.registry.ForgeRegistries; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,128 +23,97 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import knightminer.inspirations.library.InspirationsRegistry; import knightminer.inspirations.library.recipe.cauldron.*; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionType; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvent; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import org.jetbrains.annotations.Nullable; import slimeknights.mantle.util.RecipeMatch; -import java.util.Arrays; -import java.util.Locale; -import java.util.stream.Collectors; - -@RegistryDescription( - admonition = @Admonition("groovyscript.wiki.inspirations.cauldron.note") -) +@RegistryDescription(admonition = @Admonition("groovyscript.wiki.inspirations.cauldron.note")) public class Cauldron extends VirtualizedRegistry { - private static boolean checkRecipeMatches(ISimpleCauldronRecipe recipe, IIngredient input, ItemStack output, Object inputState, Object outputState) { + private static boolean checkRecipeMatches(ISimpleCauldronRecipe recipe, IIngredient input, ItemStack output, + Object inputState, Object outputState) { // Check all relevant parts to determine if we need to match them and if they do match. - return (inputState == null || compareFluids(inputState, recipe.getInputState())) - && (outputState == null || compareFluids(outputState, recipe.getState())) - && (output == null || output.isItemEqual(recipe.getResult())) - && (input == null || recipe.getInput().stream().anyMatch(input)); + return (inputState == null || compareFluids(inputState, recipe.getInputState())) && (outputState == null || compareFluids( + outputState, + recipe.getState())) && (output == null || output.isItemEqual(recipe.getResult())) && (input == null || recipe.getInput() + .stream() + .anyMatch(input)); } private static boolean compareFluids(Object first, Object second) { if (first == second) return true; - if (first instanceof Fluid && second instanceof Fluid) return ((Fluid) first).getName().equals(((Fluid) second).getName()); + if (first instanceof Fluid && second instanceof Fluid) return ((Fluid) first).getName().equals(((Fluid) second) + .getName()); return false; } - @RecipeBuilderDescription(example = @Example(".standard().input(item('minecraft:gold_ingot')).fluidInput(fluid('lava')).output(item('minecraft:clay')).boiling().sound(sound('minecraft:block.anvil.destroy')).levels(3)"), requirement = { - @Property(property = "type"), - @Property(property = "input"), - @Property(property = "output"), - @Property(property = "fluidInput"), - @Property(property = "fluidOutput"), - @Property(property = "inputPotion"), - @Property(property = "outputPotion"), - @Property(property = "dye"), - @Property(property = "boiling"), - @Property(property = "levels"), - @Property(property = "sound") - }) + @RecipeBuilderDescription(example = @Example(".standard().input(item('minecraft:gold_ingot')).fluidInput(fluid('lava')).output(item('minecraft:clay')).boiling().sound(sound('minecraft:block.anvil.destroy')).levels(3)"), + requirement = {@Property(property = "type"), @Property(property = "input"), @Property( + property = "output"), + @Property(property = "fluidInput"), @Property(property = "fluidOutput"), @Property( + property = "inputPotion"), + @Property(property = "outputPotion"), @Property(property = "dye"), @Property( + property = "boiling"), + @Property(property = "levels"), @Property(property = "sound")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).fluidInput(fluid('lava')).levels(3).sound(sound('minecraft:block.anvil.destroy'))"), requirement = { - @Property(property = "input"), - @Property(property = "output"), - @Property(property = "fluidInput"), - @Property(property = "boiling"), - @Property(property = "levels"), - @Property(property = "sound") - }) + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).fluidInput(fluid('lava')).levels(3).sound(sound('minecraft:block.anvil.destroy'))"), + requirement = {@Property(property = "input"), @Property(property = "output"), @Property( + property = "fluidInput"), + @Property(property = "boiling"), @Property(property = "levels"), @Property( + property = "sound")}) public RecipeBuilder recipeBuilderStandard() { return new RecipeBuilder().standard(); } - @RecipeBuilderDescription(example = @Example(".input(item('minecraft:stone:3')).fluidInput(fluid('water')).fluidOutput(fluid('milk')).levels(2)"), requirement = { - @Property(property = "input"), - @Property(property = "fluidInput"), - @Property(property = "fluidOutput"), - @Property(property = "boiling"), - @Property(property = "levels"), - @Property(property = "sound") - }) + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:stone:3')).fluidInput(fluid('water')).fluidOutput(fluid('milk')).levels(2)"), + requirement = {@Property(property = "input"), @Property(property = "fluidInput"), @Property( + property = "fluidOutput"), + @Property(property = "boiling"), @Property(property = "levels"), @Property( + property = "sound")}) public RecipeBuilder recipeBuilderTransform() { return new RecipeBuilder().transform(); } - @RecipeBuilderDescription(example = @Example(".output(item('minecraft:clay')).fluidInput(fluid('milk'), fluid('lava'))"), requirement = { - @Property(property = "fluidInput", valid = @Comp("2")), - @Property(property = "output") - }) + @RecipeBuilderDescription(example = @Example(".output(item('minecraft:clay')).fluidInput(fluid('milk'), fluid('lava'))"), + requirement = {@Property(property = "fluidInput", valid = @Comp("2")), @Property( + property = "output")}) public RecipeBuilder recipeBuilderMix() { return new RecipeBuilder().mix(); } - @RecipeBuilderDescription(example = @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).fluidInput(fluid('milk')).sound(sound('minecraft:block.anvil.destroy'))"), requirement = { - @Property(property = "input"), - @Property(property = "output"), - @Property(property = "fluidInput"), - @Property(property = "boiling"), - @Property(property = "sound") - }) + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).fluidInput(fluid('milk')).sound(sound('minecraft:block.anvil.destroy'))"), + requirement = {@Property(property = "input"), @Property(property = "output"), @Property( + property = "fluidInput"), + @Property(property = "boiling"), @Property(property = "sound")}) public RecipeBuilder recipeBuilderFill() { return new RecipeBuilder().fill(); } - @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond_block')).inputPotion(potionType('minecraft:fire_resistance')).outputPotion(potionType('minecraft:strength'))"), requirement = { - @Property(property = "input"), - @Property(property = "inputPotion"), - @Property(property = "outputPotion") - }) + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond_block')).inputPotion(potionType('minecraft:fire_resistance')).outputPotion(potionType('minecraft:strength'))"), + requirement = {@Property(property = "input"), @Property(property = "inputPotion"), @Property( + property = "outputPotion")}) public RecipeBuilder recipeBuilderBrewing() { return new RecipeBuilder().brewing(); } - @RecipeBuilderDescription(example = @Example(".input(item('minecraft:gold_block')).output(item('minecraft:diamond_block')).inputPotion(potionType('minecraft:fire_resistance')).levels(2)"), requirement = { - @Property(property = "input"), - @Property(property = "output"), - @Property(property = "inputPotion", valid = {@Comp("0"), @Comp("1")}), - @Property(property = "boiling"), - @Property(property = "levels") - }) + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:gold_block')).output(item('minecraft:diamond_block')).inputPotion(potionType('minecraft:fire_resistance')).levels(2)"), + requirement = {@Property(property = "input"), @Property(property = "output"), @Property( + property = "inputPotion", + valid = {@Comp("0"), + @Comp("1")}), + @Property(property = "boiling"), @Property(property = "levels")}) public RecipeBuilder recipeBuilderPotion() { return new RecipeBuilder().potion(); } - @RecipeBuilderDescription(example = @Example(".input(item('minecraft:gold_block')).output(item('minecraft:diamond_block')).dye('blue').levels(2)"), requirement = { - @Property(property = "input"), - @Property(property = "output"), - @Property(property = "dye"), - @Property(property = "levels") - }) + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:gold_block')).output(item('minecraft:diamond_block')).dye('blue').levels(2)"), + requirement = {@Property(property = "input"), @Property(property = "output"), @Property( + property = "dye"), + @Property(property = "levels")}) public RecipeBuilder recipeBuilderDye() { return new RecipeBuilder().dye(); } @@ -154,9 +138,13 @@ public boolean remove(ICauldronRecipe recipe) { @MethodDescription(example = @Example("item('minecraft:ghast_tear')")) public void removeByInput(IIngredient input) { - for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream() - .filter(r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, input, null, null, null)) - .collect(Collectors.toList())) { + for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream().filter( + r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, + input, + null, + null, + null)) + .collect(Collectors.toList())) { addBackup(recipe); InspirationsRegistryAccessor.getCauldronRecipes().remove(recipe); } @@ -164,9 +152,13 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('minecraft:piston')")) public void removeByOutput(ItemStack output) { - for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream() - .filter(r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, null, output, null, null)) - .collect(Collectors.toList())) { + for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream().filter( + r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, + null, + output, + null, + null)) + .collect(Collectors.toList())) { addBackup(recipe); InspirationsRegistryAccessor.getCauldronRecipes().remove(recipe); } @@ -174,9 +166,13 @@ public void removeByOutput(ItemStack output) { @MethodDescription public void removeByFluidInput(Fluid input) { - for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream() - .filter(r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, null, null, input, null)) - .collect(Collectors.toList())) { + for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream().filter( + r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, + null, + null, + input, + null)) + .collect(Collectors.toList())) { addBackup(recipe); InspirationsRegistryAccessor.getCauldronRecipes().remove(recipe); } @@ -189,9 +185,13 @@ public void removeByFluidInput(FluidStack input) { @MethodDescription public void removeByFluidOutput(Fluid output) { - for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream() - .filter(r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, null, null, null, output)) - .collect(Collectors.toList())) { + for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream().filter( + r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, + null, + null, + null, + output)) + .collect(Collectors.toList())) { addBackup(recipe); InspirationsRegistryAccessor.getCauldronRecipes().remove(recipe); } @@ -210,8 +210,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(InspirationsRegistryAccessor.getCauldronRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(InspirationsRegistryAccessor.getCauldronRecipes()).setRemover(this::remove); } @Property(property = "input", valid = @Comp("1"), needsOverride = true) @@ -230,8 +229,8 @@ public static class RecipeBuilder extends AbstractRecipeBuilder private EnumDyeColor dye; @Property(needsOverride = true) private Boolean boiling; - @Property(valid = {@Comp(value = "0", type = Comp.Type.GTE), - @Comp(value = "`InspirationsRegistry.getCauldronMax()`", type = Comp.Type.LTE)}, needsOverride = true) + @Property(valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "`InspirationsRegistry.getCauldronMax()`", + type = Comp.Type.LTE)}, needsOverride = true) private int levels; @Property(valid = @Comp(value = "null", type = Comp.Type.NOT), needsOverride = true) private SoundEvent sound; @@ -343,9 +342,7 @@ public RecipeBuilder sound(String sound) { } @Override - public String getErrorMsg() { - return "Error adding Inspirations Cauldron recipe"; - } + public String getErrorMsg() { return "Error adding Inspirations Cauldron recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -358,13 +355,19 @@ public void validate(GroovyLog.Msg msg) { case STANDARD -> { validateItems(msg, 1, 1, 1, 1); validateFluids(msg, 1, 1, 0, 0); - msg.add(levels <= 0 || levels > InspirationsRegistry.getCauldronMax(), "levels must be greater than 0 and less than {}, yet it was {}", InspirationsRegistry.getCauldronMax(), levels); + msg.add(levels <= 0 || levels > InspirationsRegistry.getCauldronMax(), + "levels must be greater than 0 and less than {}, yet it was {}", InspirationsRegistry + .getCauldronMax(), + levels); msg.add(sound == null, "sound must be defined"); } case TRANSFORM -> { validateItems(msg, 1, 1, 0, 0); validateFluids(msg, 1, 1, 1, 1); - msg.add(levels <= 0 || levels > InspirationsRegistry.getCauldronMax(), "levels must be greater than 0 and less than {}, yet it was {}", InspirationsRegistry.getCauldronMax(), levels); + msg.add(levels <= 0 || levels > InspirationsRegistry.getCauldronMax(), + "levels must be greater than 0 and less than {}, yet it was {}", InspirationsRegistry + .getCauldronMax(), + levels); } case MIX -> { validateItems(msg, 0, 0, 1, 1); @@ -385,30 +388,40 @@ public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); validateFluids(msg); msg.add(inputPotion == null, "inputPotion must be defined"); - msg.add(levels <= 0 || levels > InspirationsRegistry.getCauldronMax(), "levels must be greater than 0 and less than {}, yet it was {}", InspirationsRegistry.getCauldronMax(), levels); + msg.add(levels <= 0 || levels > InspirationsRegistry.getCauldronMax(), + "levels must be greater than 0 and less than {}, yet it was {}", InspirationsRegistry + .getCauldronMax(), + levels); } case DYE -> { validateItems(msg, 1, 1, 1, 1); validateFluids(msg); msg.add(dye == null, "dye must be defined"); - msg.add(levels <= 0 || levels > InspirationsRegistry.getCauldronMax(), "levels must be greater than 0 and less than {}, yet it was {}", InspirationsRegistry.getCauldronMax(), levels); + msg.add(levels <= 0 || levels > InspirationsRegistry.getCauldronMax(), + "levels must be greater than 0 and less than {}, yet it was {}", InspirationsRegistry + .getCauldronMax(), + levels); } } msg.add(msg.hasSubMessages(), "Note that validation changes based on the type requested"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ICauldronRecipe register() { if (!validate()) return null; ICauldronRecipe recipe = switch (type) { - case STANDARD -> new CauldronFluidRecipe(recipeMatchFromIngredient(input.get(0)), fluidInput.get(0).getFluid(), output.get(0), boiling, levels, sound); - case TRANSFORM -> new CauldronFluidTransformRecipe(recipeMatchFromIngredient(input.get(0)), fluidInput.get(0).getFluid(), fluidOutput.get(0).getFluid(), boiling, levels); + case STANDARD -> new CauldronFluidRecipe(recipeMatchFromIngredient(input.get(0)), fluidInput.get(0).getFluid(), + output.get(0), boiling, levels, sound); + case TRANSFORM -> new CauldronFluidTransformRecipe(recipeMatchFromIngredient(input.get(0)), fluidInput.get(0) + .getFluid(), + fluidOutput.get(0).getFluid(), boiling, levels); case MIX -> new CauldronMixRecipe(fluidInput.get(0).getFluid(), fluidInput.get(1).getFluid(), output.get(0)); - case FILL -> new FillCauldronRecipe(recipeMatchFromIngredient(input.get(0)), fluidInput.get(0).getFluid(), fluidInput.get(0).amount, output.get(0), boiling, sound); + case FILL -> new FillCauldronRecipe(recipeMatchFromIngredient(input.get(0)), fluidInput.get(0).getFluid(), + fluidInput.get(0).amount, output.get(0), boiling, sound); case BREWING -> new CauldronBrewingRecipe(inputPotion, input.get(0).toMcIngredient(), outputPotion); - case POTION -> new CauldronPotionRecipe(recipeMatchFromIngredient(input.get(0)), inputPotion, output.get(0), levels, boiling); + case POTION -> new CauldronPotionRecipe(recipeMatchFromIngredient(input.get(0)), inputPotion, output.get(0), + levels, boiling); case DYE -> new CauldronDyeRecipe(recipeMatchFromIngredient(input.get(0)), dye, output.get(0), levels); }; @@ -418,13 +431,7 @@ public void validate(GroovyLog.Msg msg) { private enum RecipeType { - STANDARD, - TRANSFORM, - MIX, - FILL, - BREWING, - POTION, - DYE + STANDARD, TRANSFORM, MIX, FILL, BREWING, POTION, DYE } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/DryingBasin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/DryingBasin.java index 398f62f4d..8d676a3ee 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/DryingBasin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/DryingBasin.java @@ -1,13 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.integrateddynamics; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; -import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import net.minecraft.item.ItemStack; + import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.cyclopscore.recipe.custom.component.DurationRecipeProperties; import org.cyclops.cyclopscore.recipe.custom.component.IngredientAndFluidStackRecipeComponent; @@ -17,18 +11,24 @@ import org.cyclops.integrateddynamics.block.BlockMechanicalDryingBasin; import org.jetbrains.annotations.Nullable; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + @RegistryDescription -public class DryingBasin extends VirtualizedRegistry> { +public class DryingBasin extends + VirtualizedRegistry> { @Override - public boolean isEnabled() { - return Configs.isEnabled(BlockDryingBasinConfig.class); - } + public boolean isEnabled() { return Configs.isEnabled(BlockDryingBasinConfig.class); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).fluidInput(fluid('water') * 500).fluidOutput(fluid('lava') * 2000).mechanical().duration(5)"), - @Example(".output(item('minecraft:clay')).fluidInput(fluid('water') * 2000)") - }, requirement = @Property(property = "basic", defaultValue = "true")) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).fluidInput(fluid('water') * 500).fluidOutput(fluid('lava') * 2000).mechanical().duration(5)"), + @Example(".output(item('minecraft:clay')).fluidInput(fluid('water') * 2000)")}, + requirement = @Property(property = "basic", defaultValue = "true")) public RecipeBuilder recipeBuilder() { return new RecipeBuilder().basic(); } @@ -43,7 +43,8 @@ public void add(IRecipe recipe, boolean add) { + public void add(IRecipe recipe, + boolean add) { if (recipe == null) return; addScripted(recipe); if (add) BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes().add(recipe); @@ -86,11 +87,11 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes()).setRemover(this::remove); } - public static class RecipeBuilder extends AbstractRecipeBuilder> { + public static class RecipeBuilder extends + AbstractRecipeBuilder> { @Property("groovyscript.wiki.integrateddynamics.drying_basin.basic.value") private boolean basic; @@ -130,44 +131,50 @@ public RecipeBuilder duration(int duration) { } @Override - public String getErrorMsg() { - return "Error adding Integrated Dynamics Drying Basin Recipe"; - } + public String getErrorMsg() { return "Error adding Integrated Dynamics Drying Basin Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 0, 1, 0, 1); validateFluids(msg, 0, 1, 0, 1); - msg.add(input.isEmpty() && fluidInput.isEmpty(), "either input or fluidInput must have an entry, yet both were empty"); - msg.add(output.isEmpty() && fluidOutput.isEmpty(), "either output or fluidOutput must have an entry, yet both were empty"); + msg.add(input.isEmpty() && fluidInput.isEmpty(), + "either input or fluidInput must have an entry, yet both were empty"); + msg.add(output.isEmpty() && fluidOutput.isEmpty(), + "either output or fluidOutput must have an entry, yet both were empty"); msg.add(duration < 0, "duration must be a non negative integer, yet it was {}", duration); msg.add(!basic && !mechanical, "either basic or mechanical must be true"); - msg.add(basic && !ModSupport.INTEGRATED_DYNAMICS.get().dryingBasin.isEnabled(), "basic is enabled, yet the Drying Basin is disabled via config"); - msg.add(mechanical && !ModSupport.INTEGRATED_DYNAMICS.get().mechanicalDryingBasin.isEnabled(), "mechanic is enabled, yet the Mechanical Drying Basin is disabled via config"); + msg.add(basic && !ModSupport.INTEGRATED_DYNAMICS.get().dryingBasin.isEnabled(), + "basic is enabled, yet the Drying Basin is disabled via config"); + msg.add(mechanical && !ModSupport.INTEGRATED_DYNAMICS.get().mechanicalDryingBasin.isEnabled(), + "mechanic is enabled, yet the Mechanical Drying Basin is disabled via config"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IRecipe register() { if (!validate()) return null; ItemStack itemInput = input.isEmpty() ? ItemStack.EMPTY : IngredientHelper.toItemStack(input.get(0)); if (basic) { - ModSupport.INTEGRATED_DYNAMICS.get().dryingBasin.add( - BlockDryingBasin.getInstance().getRecipeRegistry().registerRecipe( - new IngredientAndFluidStackRecipeComponent(itemInput, true, fluidInput.getOrEmpty(0)), - new IngredientAndFluidStackRecipeComponent(output.get(0), fluidOutput.getOrEmpty(0)), - new DurationRecipeProperties(duration) - ), false); + ModSupport.INTEGRATED_DYNAMICS.get().dryingBasin.add(BlockDryingBasin.getInstance().getRecipeRegistry() + .registerRecipe(new IngredientAndFluidStackRecipeComponent(itemInput, + true, + fluidInput.getOrEmpty(0)), + new IngredientAndFluidStackRecipeComponent(output.get(0), + fluidOutput.getOrEmpty(0)), + new DurationRecipeProperties(duration)), + false); } if (mechanical) { - ModSupport.INTEGRATED_DYNAMICS.get().mechanicalDryingBasin.add( - BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().registerRecipe( - new IngredientAndFluidStackRecipeComponent(itemInput, true, fluidInput.getOrEmpty(0)), - new IngredientAndFluidStackRecipeComponent(output.getOrEmpty(0), fluidOutput.getOrEmpty(0)), - new DurationRecipeProperties(duration) - ), false); + ModSupport.INTEGRATED_DYNAMICS.get().mechanicalDryingBasin.add(BlockMechanicalDryingBasin.getInstance() + .getRecipeRegistry() + .registerRecipe(new IngredientAndFluidStackRecipeComponent(itemInput, + true, + fluidInput.getOrEmpty(0)), + new IngredientAndFluidStackRecipeComponent(output.getOrEmpty(0), + fluidOutput.getOrEmpty(0)), + new DurationRecipeProperties(duration)), + false); } return null; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalDryingBasin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalDryingBasin.java index bc52ade5d..c2a2bed7f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalDryingBasin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalDryingBasin.java @@ -1,9 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.integrateddynamics; -import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import net.minecraft.item.ItemStack; + import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.cyclopscore.recipe.custom.component.DurationRecipeProperties; import org.cyclops.cyclopscore.recipe.custom.component.IngredientAndFluidStackRecipeComponent; @@ -11,15 +9,19 @@ import org.cyclops.integrateddynamics.block.BlockMechanicalDryingBasin; import org.cyclops.integrateddynamics.block.BlockMechanicalDryingBasinConfig; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + @RegistryDescription -public class MechanicalDryingBasin extends VirtualizedRegistry> { +public class MechanicalDryingBasin extends + VirtualizedRegistry> { @Override - public boolean isEnabled() { - return Configs.isEnabled(BlockMechanicalDryingBasinConfig.class); - } + public boolean isEnabled() { return Configs.isEnabled(BlockMechanicalDryingBasinConfig.class); } - @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 20000).duration(300)"), requirement = @Property(property = "mechanical", defaultValue = "true")) + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 20000).duration(300)"), + requirement = @Property(property = "mechanical", defaultValue = "true")) public DryingBasin.RecipeBuilder recipeBuilder() { return new DryingBasin.RecipeBuilder().mechanical(); } @@ -34,7 +36,8 @@ public void add(IRecipe recipe, boolean add) { + public void add(IRecipe recipe, + boolean add) { if (recipe == null) return; addScripted(recipe); if (add) BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes().add(recipe); @@ -77,7 +80,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes()).setRemover( + this::remove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalSqueezer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalSqueezer.java index 8f0d3c2ea..43a0f6a17 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalSqueezer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalSqueezer.java @@ -1,9 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.integrateddynamics; -import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import net.minecraft.item.ItemStack; + import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.cyclopscore.recipe.custom.component.DurationRecipeProperties; import org.cyclops.cyclopscore.recipe.custom.component.IngredientRecipeComponent; @@ -12,15 +10,19 @@ import org.cyclops.integrateddynamics.block.BlockMechanicalSqueezer; import org.cyclops.integrateddynamics.block.BlockMechanicalSqueezerConfig; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + @RegistryDescription -public class MechanicalSqueezer extends VirtualizedRegistry> { +public class MechanicalSqueezer extends + VirtualizedRegistry> { @Override - public boolean isEnabled() { - return Configs.isEnabled(BlockMechanicalSqueezerConfig.class); - } + public boolean isEnabled() { return Configs.isEnabled(BlockMechanicalSqueezerConfig.class); } - @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay') * 16, 0.9F)"), requirement = @Property(property = "mechanical", defaultValue = "true")) + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay') * 16, 0.9F)"), + requirement = @Property(property = "mechanical", defaultValue = "true")) public Squeezer.RecipeBuilder recipeBuilder() { return new Squeezer.RecipeBuilder().mechanical(); } @@ -35,7 +37,8 @@ public void add(IRecipe recipe, boolean add) { + public void add(IRecipe recipe, + boolean add) { if (recipe == null) return; addScripted(recipe); if (add) BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes().add(recipe); @@ -67,7 +70,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes()).setRemover( + this::remove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/Squeezer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/Squeezer.java index ef05a91e8..90cc26e64 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/Squeezer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/Squeezer.java @@ -1,12 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.integrateddynamics; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.item.ItemStack; + import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.cyclopscore.recipe.custom.component.DummyPropertiesComponent; import org.cyclops.cyclopscore.recipe.custom.component.DurationRecipeProperties; @@ -18,22 +16,24 @@ import org.cyclops.integrateddynamics.block.BlockSqueezerConfig; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; @RegistryDescription -public class Squeezer extends VirtualizedRegistry> { +public class Squeezer extends + VirtualizedRegistry> { @Override - public boolean isEnabled() { - return Configs.isEnabled(BlockSqueezerConfig.class); - } + public boolean isEnabled() { return Configs.isEnabled(BlockSqueezerConfig.class); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:clay_ball'), 1F).output(item('minecraft:clay_ball') * 2, 0.7F).output(item('minecraft:clay_ball') * 10, 0.2F).fluidOutput(fluid('lava') * 2000).mechanical().duration(5)"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay'), 0.5F)"), - @Example(".input(item('minecraft:diamond')).fluidOutput(fluid('lava') * 10)") - }, requirement = @Property(property = "basic", defaultValue = "true")) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:clay_ball'), 1F).output(item('minecraft:clay_ball') * 2, 0.7F).output(item('minecraft:clay_ball') * 10, 0.2F).fluidOutput(fluid('lava') * 2000).mechanical().duration(5)"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay'), 0.5F)"), + @Example(".input(item('minecraft:diamond')).fluidOutput(fluid('lava') * 10)")}, + requirement = @Property(property = "basic", defaultValue = "true")) public RecipeBuilder recipeBuilder() { return new RecipeBuilder().basic(); } @@ -48,7 +48,8 @@ public void add(IRecipe recipe, boolean add) { + public void add(IRecipe recipe, + boolean add) { if (recipe == null) return; addScripted(recipe); if (add) BlockSqueezer.getInstance().getRecipeRegistry().allRecipes().add(recipe); @@ -80,16 +81,18 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(BlockSqueezer.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(BlockSqueezer.getInstance().getRecipeRegistry().allRecipes()).setRemover(this::remove); } @Property(property = "input", valid = @Comp("1")) - @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) - public static class RecipeBuilder extends AbstractRecipeBuilder> { - - @Property(value = "groovyscript.wiki.integrateddynamics.squeezer.output.value", ignoresInheritedMethods = true, valid = { - @Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "3")}) + @Property(property = "fluidOutput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + public static class RecipeBuilder extends + AbstractRecipeBuilder> { + + @Property(value = "groovyscript.wiki.integrateddynamics.squeezer.output.value", + ignoresInheritedMethods = true, + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "3")}) private final List output = new ArrayList<>(); @Property(value = "groovyscript.wiki.integrateddynamics.squeezer.duration.value", defaultValue = "10") private int duration = 10; @@ -130,8 +133,7 @@ public RecipeBuilder output(ItemStack output, float chance) { return this; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public RecipeBuilder output(ItemStack output) { this.output.add(new IngredientRecipeComponent(output)); return this; @@ -144,42 +146,46 @@ public RecipeBuilder duration(int duration) { } @Override - public String getErrorMsg() { - return "Error adding Integrated Dynamics Squeezer Recipe"; - } + public String getErrorMsg() { return "Error adding Integrated Dynamics Squeezer Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 0, 3); validateFluids(msg, 0, 0, 0, 1); msg.add(output.size() > 3, "output can have a maximum of 3 entries, yet had {} entries", output.size()); - msg.add(mechanical && duration < 0, "duration must be a non negative integer if mechanical is true, yet it was {}", duration); - msg.add(output.isEmpty() && fluidOutput.isEmpty(), "either output or fluidOutput must have an entry, yet both were empty"); + msg.add(mechanical && duration < 0, "duration must be a non negative integer if mechanical is true, yet it was {}", + duration); + msg.add(output.isEmpty() && fluidOutput.isEmpty(), + "either output or fluidOutput must have an entry, yet both were empty"); msg.add(!basic && !mechanical, "either basic or mechanical must be true"); - msg.add(basic && !ModSupport.INTEGRATED_DYNAMICS.get().squeezer.isEnabled(), "basic is enabled, yet the Squeezer is disabled via config"); - msg.add(mechanical && !ModSupport.INTEGRATED_DYNAMICS.get().mechanicalSqueezer.isEnabled(), "mechanic is enabled, yet the Mechanical Squeezer is disabled via config"); + msg.add(basic && !ModSupport.INTEGRATED_DYNAMICS.get().squeezer.isEnabled(), + "basic is enabled, yet the Squeezer is disabled via config"); + msg.add(mechanical && !ModSupport.INTEGRATED_DYNAMICS.get().mechanicalSqueezer.isEnabled(), + "mechanic is enabled, yet the Mechanical Squeezer is disabled via config"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IRecipe register() { if (!validate()) return null; if (basic) { - ModSupport.INTEGRATED_DYNAMICS.get().squeezer.add( - BlockSqueezer.getInstance().getRecipeRegistry().registerRecipe( - new IngredientRecipeComponent(input.get(0).toMcIngredient()), - new IngredientsAndFluidStackRecipeComponent(output, fluidOutput.getOrEmpty(0)), - new DummyPropertiesComponent() - ), false); + ModSupport.INTEGRATED_DYNAMICS.get().squeezer.add(BlockSqueezer.getInstance().getRecipeRegistry().registerRecipe( + new IngredientRecipeComponent(input.get(0) + .toMcIngredient()), + new IngredientsAndFluidStackRecipeComponent(output, + fluidOutput.getOrEmpty(0)), + new DummyPropertiesComponent()), + false); } if (mechanical) { - ModSupport.INTEGRATED_DYNAMICS.get().mechanicalSqueezer.add( - BlockMechanicalSqueezer.getInstance().getRecipeRegistry().registerRecipe( - new IngredientRecipeComponent(input.get(0).toMcIngredient()), - new IngredientsAndFluidStackRecipeComponent(output, fluidOutput.getOrEmpty(0)), - new DurationRecipeProperties(duration) - ), false); + ModSupport.INTEGRATED_DYNAMICS.get().mechanicalSqueezer.add(BlockMechanicalSqueezer.getInstance() + .getRecipeRegistry() + .registerRecipe(new IngredientRecipeComponent(input.get(0) + .toMcIngredient()), + new IngredientsAndFluidStackRecipeComponent(output, + fluidOutput.getOrEmpty(0)), + new DurationRecipeProperties(duration)), + false); } return null; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/BaseCategory.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/BaseCategory.java index 5f48fc4ac..3f46e7f16 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/BaseCategory.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/BaseCategory.java @@ -1,6 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.jei; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.NotNull; + import com.cleanroommc.groovyscript.GroovyScript; + import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiIngredient; @@ -9,9 +15,6 @@ import mezz.jei.api.recipe.IRecipeCategory; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.gui.ingredients.GuiIngredient; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.NotNull; public abstract class BaseCategory implements IRecipeCategory { @@ -25,32 +28,23 @@ public BaseCategory(IGuiHelper guiHelper, String uid, int width, int height) { this.uid = uid; this.background = guiHelper.createBlankDrawable(width, height); if (slot == null) { - rightArrow = guiHelper.drawableBuilder(new ResourceLocation(GroovyScript.ID, "textures/jei/arrow_right.png"), 0, 0, 24, 15) - .setTextureSize(24, 15) - .build(); + rightArrow = guiHelper.drawableBuilder(new ResourceLocation(GroovyScript.ID, "textures/jei/arrow_right.png"), 0, 0, + 24, 15).setTextureSize(24, 15).build(); slot = guiHelper.getSlotDrawable(); } } @Override - public @NotNull String getUid() { - return this.uid; - } + public @NotNull String getUid() { return this.uid; } @Override - public @NotNull String getTitle() { - return I18n.format(GroovyScript.ID + ".jei.category." + this.uid + ".name"); - } + public @NotNull String getTitle() { return I18n.format(GroovyScript.ID + ".jei.category." + this.uid + ".name"); } @Override - public @NotNull String getModName() { - return GroovyScript.NAME; - } + public @NotNull String getModName() { return GroovyScript.NAME; } @Override - public @NotNull IDrawable getBackground() { - return this.background; - } + public @NotNull IDrawable getBackground() { return this.background; } public static void addItemSlot(IRecipeLayout recipeLayout, int index, boolean input, int x, int y) { recipeLayout.getItemStacks().init(index, input, x, y); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Catalyst.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Catalyst.java index 77242be32..bb1983070 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Catalyst.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Catalyst.java @@ -1,17 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.jei; +import java.util.Arrays; +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.jei.ModRegistryAccessor; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import mezz.jei.api.IModRegistry; -import net.minecraft.item.ItemStack; -import org.apache.commons.lang3.tuple.Pair; -import java.util.Arrays; -import java.util.Collection; +import mezz.jei.api.IModRegistry; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Catalyst extends VirtualizedRegistry> { @@ -22,10 +25,9 @@ public class Catalyst extends VirtualizedRegistry> { @GroovyBlacklist public void applyChanges(IModRegistry modRegistry) { for (var backupRecipe : getBackupRecipes()) { - ((ModRegistryAccessor) modRegistry).getRecipeCatalysts().get(backupRecipe.getKey()) - .removeIf(x -> backupRecipe.getValue() == null || - x instanceof ItemStack && - ItemStack.areItemStacksEqual((ItemStack) x, backupRecipe.getValue())); + ((ModRegistryAccessor) modRegistry).getRecipeCatalysts().get(backupRecipe.getKey()).removeIf(x -> backupRecipe + .getValue() == null || x instanceof ItemStack && ItemStack.areItemStacksEqual((ItemStack) x, + backupRecipe.getValue())); } for (var scriptedRecipe : getScriptedRecipes()) { modRegistry.addRecipeCatalyst(scriptedRecipe.getValue(), scriptedRecipe.getKey()); @@ -43,7 +45,8 @@ public void add(String category, ItemStack item) { addScripted(Pair.of(category, item)); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'minecraft.smelting', item('minecraft:clay') * 8, item('minecraft:cobblestone')")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'minecraft.smelting', item('minecraft:clay') * 8, item('minecraft:cobblestone')")) public void add(String category, ItemStack... item) { Arrays.stream(item).map(i -> Pair.of(category, i)).forEach(this::addScripted); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Category.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Category.java index c1e510ec9..9438bea54 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Category.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Category.java @@ -7,6 +7,7 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import mezz.jei.api.IRecipeRegistry; import mezz.jei.api.recipe.IRecipeCategory; @@ -21,7 +22,8 @@ public class Category extends VirtualizedRegistry { */ @GroovyBlacklist public void applyChanges(IRecipeRegistry recipeRegistry) { - if (hideAllCategories) recipeRegistry.getRecipeCategories().stream().map(IRecipeCategory::getUid).forEach(this::addBackup); + if (hideAllCategories) recipeRegistry.getRecipeCategories().stream().map(IRecipeCategory::getUid).forEach( + this::addBackup); getBackupRecipes().forEach(recipeRegistry::hideRecipeCategory); } @@ -34,10 +36,7 @@ public void onReload() { @MethodDescription(description = "groovyscript.wiki.jei.category.hideCategory") public void remove(String category) { if (category == null || category.isEmpty()) { - GroovyLog.msg("Error hiding category") - .add("category must not be empty") - .error() - .post(); + GroovyLog.msg("Error hiding category").add("category must not be empty").error().post(); return; } addBackup(category); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Description.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Description.java index 3ebe64179..9c2c59b47 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Description.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Description.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.jei; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import net.minecraft.item.ItemStack; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -7,19 +17,12 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.jei.IngredientInfoRecipeAccessor; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import mezz.jei.api.IModRegistry; import mezz.jei.api.IRecipeRegistry; import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; import mezz.jei.plugins.jei.info.IngredientInfoRecipeCategory; -import net.minecraft.item.ItemStack; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Description extends VirtualizedRegistry, List>> { @@ -30,10 +33,10 @@ public class Description extends VirtualizedRegistry, Lis @GroovyBlacklist public void applyAdditions(IModRegistry modRegistry) { for (Pair, List> entry : this.getScriptedRecipes()) { - modRegistry.addIngredientInfo(entry.getLeft().stream().flatMap(x -> Stream.of(x.getMatchingStacks())).collect(Collectors.toList()), + modRegistry.addIngredientInfo(entry.getLeft().stream().flatMap(x -> Stream.of(x.getMatchingStacks())).collect( + Collectors.toList()), // Currently, it is only possible to add VanillaTypes.ITEM. It may be desirable to add the ability to do other types. - VanillaTypes.ITEM, - entry.getRight().toArray(new String[0])); + VanillaTypes.ITEM, entry.getRight().toArray(new String[0])); } } @@ -51,7 +54,8 @@ public void applyRemovals(IRecipeRegistry recipeRegistry) { if (!VanillaTypes.ITEM.equals(accessor.getIngredientType())) return; for (Pair, List> entry : this.getBackupRecipes()) { - if (entry.getKey().stream().anyMatch(x -> accessor.getIngredients().stream().anyMatch(a -> a instanceof ItemStack && x.test((ItemStack) a)))) { + if (entry.getKey().stream().anyMatch(x -> accessor.getIngredients().stream().anyMatch( + a -> a instanceof ItemStack && x.test((ItemStack) a)))) { recipeRegistry.hideRecipe(wrapper, VanillaRecipeCategoryUid.INFORMATION); } } @@ -75,12 +79,14 @@ public void add(List target, String... description) { addScripted(Pair.of(target, Arrays.asList(description))); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay'), ['wow', 'this', 'is', 'neat']")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("item('minecraft:clay'), ['wow', 'this', 'is', 'neat']")) public void add(IIngredient target, List description) { addScripted(Pair.of(Collections.singletonList(target), description)); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:gold_ingot'), 'groovyscript.recipe.fluid_recipe'")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("item('minecraft:gold_ingot'), 'groovyscript.recipe.fluid_recipe'")) public void add(IIngredient target, String... description) { addScripted(Pair.of(Collections.singletonList(target), Arrays.asList(description))); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Ingredient.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Ingredient.java index 632efc5c3..5f9267984 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Ingredient.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/Ingredient.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.jei; +import java.util.*; + +import net.minecraft.item.crafting.IRecipe; +import net.minecraftforge.fml.common.registry.ForgeRegistries; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,14 +17,11 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import mezz.jei.api.ingredients.IIngredientRegistry; import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IIngredientType; -import net.minecraft.item.crafting.IRecipe; -import net.minecraftforge.fml.common.registry.ForgeRegistries; - -import java.util.*; @RegistryDescription(category = RegistryDescription.Category.ENTRIES, admonition = @Admonition("groovyscript.wiki.jei.ingredient.note0")) @@ -48,12 +50,14 @@ public void applyChanges(IIngredientRegistry ingredientRegistry) { for (var entry : hiddenIngredients.entrySet()) { if (entry.getValue().isEmpty()) continue; //noinspection unchecked,rawtypes - ingredientRegistry.removeIngredientsAtRuntime(entry.getKey(), ingredientRegistry.getIngredientHelper(entry.getKey()).expandSubtypes((List) entry.getValue())); + ingredientRegistry.removeIngredientsAtRuntime(entry.getKey(), ingredientRegistry.getIngredientHelper(entry.getKey()) + .expandSubtypes((List) entry.getValue())); } for (var entry : addedIngredients.entrySet()) { //noinspection unchecked,rawtypes - ingredientRegistry.addIngredientsAtRuntime(entry.getKey(), ingredientRegistry.getIngredientHelper(entry.getKey()).expandSubtypes((List) entry.getValue())); + ingredientRegistry.addIngredientsAtRuntime(entry.getKey(), ingredientRegistry.getIngredientHelper(entry.getKey()) + .expandSubtypes((List) entry.getValue())); } } @@ -66,10 +70,9 @@ public void onReload() { hideAllIngredients = false; } - @MethodDescription( - type = MethodDescription.Type.ADDITION, - example = @Example(value = "VanillaTypes.ITEM, item('minecraft:bed').withNbt([display:[Name:'Beds come in 16 different colors!']])", imports = "mezz.jei.api.ingredients.VanillaTypes") - ) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "VanillaTypes.ITEM, item('minecraft:bed').withNbt([display:[Name:'Beds come in 16 different colors!']])", + imports = "mezz.jei.api.ingredients.VanillaTypes")) public void add(IIngredientType type, Collection entries) { addedIngredients.computeIfAbsent(type, k -> new ArrayList<>()).addAll(entries); } @@ -79,24 +82,21 @@ public void add(IIngredientType type, Object... entries) { add(type, Arrays.asList(entries)); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:stone:1').withNbt([display:[Name:'Special Granite']])")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("item('minecraft:stone:1').withNbt([display:[Name:'Special Granite']])")) public void add(IIngredient ingredient) { if (IngredientHelper.isEmpty(ingredient)) { - GroovyLog.msg("Error adding items {}", ingredient) - .add("Items must not be empty") - .error() - .post(); + GroovyLog.msg("Error adding items {}", ingredient).add("Items must not be empty").error().post(); return; } if (IngredientHelper.isItem(ingredient)) { - addedIngredients.computeIfAbsent(VanillaTypes.ITEM, k -> new ArrayList<>()).addAll(Arrays.asList(ingredient.getMatchingStacks())); + addedIngredients.computeIfAbsent(VanillaTypes.ITEM, k -> new ArrayList<>()).addAll(Arrays.asList(ingredient + .getMatchingStacks())); } else if (IngredientHelper.isFluid(ingredient)) { - addedIngredients.computeIfAbsent(VanillaTypes.FLUID, k -> new ArrayList<>()).add(IngredientHelper.toFluidStack(ingredient)); + addedIngredients.computeIfAbsent(VanillaTypes.FLUID, k -> new ArrayList<>()).add(IngredientHelper.toFluidStack( + ingredient)); } else { - GroovyLog.msg("Error adding items {}", ingredient) - .add("Could not identify the type") - .error() - .post(); + GroovyLog.msg("Error adding items {}", ingredient).add("Could not identify the type").error().post(); } } @@ -114,7 +114,8 @@ public void add(Iterable ingredients) { } } - @MethodDescription(example = @Example(value = "VanillaTypes.ITEM, item('minecraft:bed:*')", imports = "mezz.jei.api.ingredients.VanillaTypes")) + @MethodDescription(example = @Example(value = "VanillaTypes.ITEM, item('minecraft:bed:*')", + imports = "mezz.jei.api.ingredients.VanillaTypes")) public void hide(IIngredientType type, Collection entries) { hiddenIngredients.computeIfAbsent(type, k -> new ArrayList<>()).addAll(entries); } @@ -124,27 +125,20 @@ public void hide(IIngredientType type, Object... entries) { hide(type, Arrays.asList(entries)); } - @MethodDescription(example = { - @Example("fluid('water')"), - @Example("item('minecraft:stone:1'), item('minecraft:stone:3')") - }) + @MethodDescription(example = {@Example("fluid('water')"), @Example("item('minecraft:stone:1'), item('minecraft:stone:3')")}) public void hide(IIngredient ingredient) { if (IngredientHelper.isEmpty(ingredient)) { - GroovyLog.msg("Error hiding items {}", ingredient) - .add("Items must not be empty") - .error() - .post(); + GroovyLog.msg("Error hiding items {}", ingredient).add("Items must not be empty").error().post(); return; } if (IngredientHelper.isItem(ingredient)) { - hiddenIngredients.computeIfAbsent(VanillaTypes.ITEM, k -> new ArrayList<>()).addAll(Arrays.asList(ingredient.getMatchingStacks())); + hiddenIngredients.computeIfAbsent(VanillaTypes.ITEM, k -> new ArrayList<>()).addAll(Arrays.asList(ingredient + .getMatchingStacks())); } else if (IngredientHelper.isFluid(ingredient)) { - hiddenIngredients.computeIfAbsent(VanillaTypes.FLUID, k -> new ArrayList<>()).add(IngredientHelper.toFluidStack(ingredient)); + hiddenIngredients.computeIfAbsent(VanillaTypes.FLUID, k -> new ArrayList<>()).add(IngredientHelper.toFluidStack( + ingredient)); } else { - GroovyLog.msg("Error hiding items {}", ingredient) - .add("Could not identify the type") - .error() - .post(); + GroovyLog.msg("Error hiding items {}", ingredient).add("Could not identify the type").error().post(); } } @@ -162,13 +156,16 @@ public void hide(Iterable ingredients) { } } - @MethodDescription(example = { - @Example(value = "com.buuz135.thaumicjei.ThaumcraftJEIPlugin.ASPECT_LIST", commented = true), - @Example(value = "mekanism.client.jei.MekanismJEI.TYPE_GAS", commented = true), - @Example(value = "VanillaTypes.ITEM", imports = "mezz.jei.api.ingredients.VanillaTypes", commented = true), - @Example(value = "VanillaTypes.ENCHANT", imports = "mezz.jei.api.ingredients.VanillaTypes", commented = true), - @Example(value = "VanillaTypes.FLUID", imports = "mezz.jei.api.ingredients.VanillaTypes", commented = true), - }) + @MethodDescription(example = {@Example(value = "com.buuz135.thaumicjei.ThaumcraftJEIPlugin.ASPECT_LIST", commented = true), + @Example(value = "mekanism.client.jei.MekanismJEI.TYPE_GAS", commented = true), @Example( + value = "VanillaTypes.ITEM", + imports = "mezz.jei.api.ingredients.VanillaTypes", + commented = true), + @Example(value = "VanillaTypes.ENCHANT", + imports = "mezz.jei.api.ingredients.VanillaTypes", + commented = true), @Example(value = "VanillaTypes.FLUID", + imports = "mezz.jei.api.ingredients.VanillaTypes", + commented = true),}) public void hideByType(IIngredientType type) { hiddenTypes.add(type); } @@ -181,10 +178,7 @@ public void hideAll() { @MethodDescription public void removeAndHide(IIngredient ingredient) { if (IngredientHelper.isEmpty(ingredient)) { - GroovyLog.msg("Error remove and hide items {}", ingredient) - .add("Items must not be empty") - .error() - .post(); + GroovyLog.msg("Error remove and hide items {}", ingredient).add("Items must not be empty").error().post(); return; } hide(ingredient); @@ -195,10 +189,7 @@ public void removeAndHide(IIngredient ingredient) { public void removeAndHide(IIngredient... ingredients) { for (IIngredient ingredient : ingredients) { if (IngredientHelper.isEmpty(ingredient)) { - GroovyLog.msg("Error remove and hide items {}", ingredient) - .add("Items must not be empty") - .error() - .post(); + GroovyLog.msg("Error remove and hide items {}", ingredient).add("Items must not be empty").error().post(); return; } hide(ingredient); @@ -219,10 +210,7 @@ public void removeAndHide(IIngredient... ingredients) { public void removeAndHide(Iterable ingredients) { for (IIngredient ingredient : ingredients) { if (IngredientHelper.isEmpty(ingredient)) { - GroovyLog.msg("Error remove and hide items {}", ingredient) - .add("Items must not be empty") - .error() - .post(); + GroovyLog.msg("Error remove and hide items {}", ingredient).add("Items must not be empty").error().post(); return; } hide(ingredient); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/JeiPlugin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/JeiPlugin.java index 88a9020b0..316aec7e8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/JeiPlugin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/JeiPlugin.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.jei; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.TextComponentString; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.command.GSCommand; @@ -13,6 +22,7 @@ import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; + import mezz.jei.Internal; import mezz.jei.api.*; import mezz.jei.api.ingredients.IIngredientHelper; @@ -22,19 +32,9 @@ import mezz.jei.api.recipe.*; import mezz.jei.ingredients.IngredientRegistry; import mezz.jei.plugins.vanilla.crafting.ShapelessRecipeWrapper; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextComponentString; -import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; -import java.util.List; - -@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") -@GroovyBlacklist -@JEIPlugin +@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod") @GroovyBlacklist @JEIPlugin public class JeiPlugin implements IModPlugin { public static IJeiHelpers jeiHelpers; @@ -47,9 +47,7 @@ public class JeiPlugin implements IModPlugin { public static IIngredientRenderer fluidRenderer; - public static boolean isLoaded() { - return jeiRuntime != null; - } + public static boolean isLoaded() { return jeiRuntime != null; } @Override public void registerCategories(IRecipeCategoryRegistration registry) { @@ -71,8 +69,10 @@ public void register(IModRegistry registry) { modRegistry = registry; // jei can't handle custom recipe classes on its own - registry.handleRecipes(ShapedCraftingRecipe.class, recipe -> new ShapedRecipeWrapper(jeiHelpers, recipe), VanillaRecipeCategoryUid.CRAFTING); - registry.handleRecipes(ShapelessCraftingRecipe.class, recipe -> new ShapelessRecipeWrapper<>(jeiHelpers, recipe), VanillaRecipeCategoryUid.CRAFTING); + registry.handleRecipes(ShapedCraftingRecipe.class, recipe -> new ShapedRecipeWrapper(jeiHelpers, recipe), + VanillaRecipeCategoryUid.CRAFTING); + registry.handleRecipes(ShapelessCraftingRecipe.class, recipe -> new ShapelessRecipeWrapper<>(jeiHelpers, recipe), + VanillaRecipeCategoryUid.CRAFTING); // register in world crafting recipes registry.addRecipeCatalyst(new ItemStack(Items.WATER_BUCKET), FluidRecipeCategory.UID); @@ -110,8 +110,11 @@ public static SimpleCommand getJeiCategoriesCommand() { for (IRecipeCategory category : recipeRegistry.getRecipeCategories()) { GroovyLog.get().getWriter().println(" - " + category.getUid()); } - sender.sendMessage(new TextComponentString("JEI Categories has been logged to the ") - .appendSibling(GSCommand.getTextForFile("Groovy Log", GroovyLog.get().getLogFilerPath().toString(), new TextComponentString("Click to open GroovyScript log")))); + sender.sendMessage(new TextComponentString("JEI Categories has been logged to the ").appendSibling(GSCommand.getTextForFile("Groovy Log", + GroovyLog.get() + .getLogFilerPath() + .toString(), + new TextComponentString("Click to open GroovyScript log")))); }); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/ShapedRecipeWrapper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/ShapedRecipeWrapper.java index 7ca32a8d2..5c67bd617 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/ShapedRecipeWrapper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/jei/ShapedRecipeWrapper.java @@ -1,9 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.jei; +import net.minecraftforge.common.crafting.IShapedRecipe; + import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper; import mezz.jei.plugins.vanilla.crafting.ShapelessRecipeWrapper; -import net.minecraftforge.common.crafting.IShapedRecipe; /** * Why does jei not a simple shaped wrapper like this? @@ -15,12 +16,8 @@ public ShapedRecipeWrapper(IJeiHelpers jeiHelpers, IShapedRecipe recipe) { } @Override - public int getWidth() { - return recipe.getRecipeWidth(); - } + public int getWidth() { return recipe.getRecipeWidth(); } @Override - public int getHeight() { - return recipe.getRecipeHeight(); - } + public int getHeight() { return recipe.getRecipeHeight(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Aggregator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Aggregator.java index 57b776748..0d0259985 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Aggregator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Aggregator.java @@ -1,26 +1,26 @@ package com.cleanroommc.groovyscript.compat.mods.lazyae2; +import java.util.Arrays; +import java.util.Collection; +import java.util.stream.Collectors; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import io.github.phantamanta44.libnine.LibNine; import io.github.phantamanta44.threng.recipe.AggRecipe; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.Collection; -import java.util.stream.Collectors; @RegistryDescription public class Aggregator extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(ore('blockGlass'), item('minecraft:diamond')).output(item('minecraft:diamond') * 4)"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(ore('blockGlass'), item('minecraft:diamond')).output(item('minecraft:diamond') * 4)"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -78,9 +78,7 @@ public void removeAll() { public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Lazy AE2 Aggregator recipe"; - } + public String getErrorMsg() { return "Error adding Lazy AE2 Aggregator recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -88,12 +86,12 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AggRecipe register() { if (!validate()) return null; - AggRecipe recipe = new AggRecipe(input.stream().map(LazyAE2::matchesIIngredient).collect(Collectors.toList()), output.get(0)); + AggRecipe recipe = new AggRecipe(input.stream().map(LazyAE2::matchesIIngredient).collect(Collectors.toList()), output + .get(0)); ModSupport.LAZYAE2.get().aggregator.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Centrifuge.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Centrifuge.java index f119040df..fcb7f14a7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Centrifuge.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Centrifuge.java @@ -1,25 +1,25 @@ package com.cleanroommc.groovyscript.compat.mods.lazyae2; +import java.util.Arrays; +import java.util.Collection; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import io.github.phantamanta44.libnine.LibNine; import io.github.phantamanta44.threng.recipe.PurifyRecipe; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.Collection; @RegistryDescription public class Centrifuge extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(ore('blockGlass')).output(item('minecraft:diamond'))"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(ore('blockGlass')).output(item('minecraft:diamond'))"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -72,14 +72,11 @@ public void removeAll() { recipes().clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Lazy AE2 Centrifuge recipe"; - } + public String getErrorMsg() { return "Error adding Lazy AE2 Centrifuge recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -87,8 +84,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable PurifyRecipe register() { if (!validate()) return null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Energizer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Energizer.java index 8ff391988..0f64b85ea 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Energizer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Energizer.java @@ -1,25 +1,25 @@ package com.cleanroommc.groovyscript.compat.mods.lazyae2; +import java.util.Arrays; +import java.util.Collection; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import io.github.phantamanta44.libnine.LibNine; import io.github.phantamanta44.threng.recipe.EnergizeRecipe; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.Collection; @RegistryDescription public class Energizer extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(ore('blockGlass')).energy(50).output(item('minecraft:diamond'))"), - @Example(".input(item('minecraft:gold_ingot')).energy(10000).output(item('minecraft:diamond'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(ore('blockGlass')).energy(50).output(item('minecraft:diamond'))"), + @Example(".input(item('minecraft:gold_ingot')).energy(10000).output(item('minecraft:diamond'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -72,8 +72,7 @@ public void removeAll() { recipes().clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.GT, value = "0")) @@ -86,9 +85,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Lazy AE2 Energizer recipe"; - } + public String getErrorMsg() { return "Error adding Lazy AE2 Energizer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -97,8 +94,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(energy <= 0, "energy must be greater than 0, yet it was {}", energy); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable EnergizeRecipe register() { if (!validate()) return null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Etcher.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Etcher.java index 575a440f9..94e0c8ced 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Etcher.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Etcher.java @@ -1,25 +1,25 @@ package com.cleanroommc.groovyscript.compat.mods.lazyae2; +import java.util.Arrays; +import java.util.Collection; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import io.github.phantamanta44.libnine.LibNine; import io.github.phantamanta44.threng.recipe.EtchRecipe; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.Collection; @RegistryDescription public class Etcher extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(ore('blockGlass')).top(item('minecraft:diamond')).bottom(item('minecraft:clay')).output(item('minecraft:diamond') * 5)"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(ore('blockGlass')).top(item('minecraft:diamond')).bottom(item('minecraft:clay')).output(item('minecraft:diamond') * 5)"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -72,8 +72,7 @@ public void removeAll() { recipes().clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "IIngredient.EMPTY") @@ -94,9 +93,7 @@ public RecipeBuilder bottom(IIngredient bottom) { } @Override - public String getErrorMsg() { - return "Error adding Lazy AE2 Etcher recipe"; - } + public String getErrorMsg() { return "Error adding Lazy AE2 Etcher recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -104,12 +101,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable EtchRecipe register() { if (!validate()) return null; - EtchRecipe recipe = new EtchRecipe(LazyAE2.matchesIIngredient(top), LazyAE2.matchesIIngredient(bottom), LazyAE2.matchesIIngredient(input.get(0)), output.get(0)); + EtchRecipe recipe = new EtchRecipe(LazyAE2.matchesIIngredient(top), LazyAE2.matchesIIngredient(bottom), LazyAE2 + .matchesIIngredient(input.get(0)), + output.get(0)); ModSupport.LAZYAE2.get().etcher.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/LazyAE2.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/LazyAE2.java index b815e6fc3..997ff7744 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/LazyAE2.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/LazyAE2.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.lazyae2; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer; -import io.github.phantamanta44.libnine.util.IDisplayableMatcher; -import net.minecraft.item.ItemStack; -import java.util.Arrays; +import io.github.phantamanta44.libnine.util.IDisplayableMatcher; public class LazyAE2 extends ModPropertyContainer { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ChemicalInfuser.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ChemicalInfuser.java index 49cc124ba..54321604a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ChemicalInfuser.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ChemicalInfuser.java @@ -1,15 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.GasRecipeBuilder; import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; + import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.ChemicalPairInput; import mekanism.common.recipe.machines.ChemicalInfuserRecipe; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class ChemicalInfuser extends VirtualizedMekanismRegistry { @@ -23,7 +25,8 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "gas('copper') * 10, gas('iron'), gas('gold') * 15", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "gas('copper') * 10, gas('iron'), gas('gold') * 15", commented = true)) public ChemicalInfuserRecipe add(GasStack leftInput, GasStack rightInput, GasStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Chemical Infuser recipe").error(); msg.add(Mekanism.isEmpty(leftInput), () -> "left gas input must not be empty"); @@ -53,14 +56,11 @@ public boolean removeByInput(GasStack leftInput, GasStack rightInput) { return false; } - @Property(property = "gasInput", valid = @Comp("2")) - @Property(property = "gasOutput", valid = @Comp("1")) + @Property(property = "gasInput", valid = @Comp("2")) @Property(property = "gasOutput", valid = @Comp("1")) public static class RecipeBuilder extends GasRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Chemical Infuser recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Chemical Infuser recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -69,8 +69,7 @@ public void validate(GroovyLog.Msg msg) { validateGases(msg, 2, 2, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ChemicalInfuserRecipe register() { if (!validate()) return null; ChemicalInfuserRecipe recipe = new ChemicalInfuserRecipe(gasInput.get(0), gasInput.get(1), gasOutput.get(0)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ChemicalOxidizer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ChemicalOxidizer.java index 9fd569af5..da9a514ea 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ChemicalOxidizer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ChemicalOxidizer.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,12 +12,11 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.OxidationRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class ChemicalOxidizer extends VirtualizedMekanismRegistry { @@ -27,7 +30,8 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "ore('dustGold'), gas('gold')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "ore('dustGold'), gas('gold')", commented = true)) public OxidationRecipe add(IIngredient ingredient, GasStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Oxidizer recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -64,14 +68,11 @@ public boolean removeByInput(IIngredient ingredient) { return found; } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "gasOutput", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "gasOutput", valid = @Comp("1")) public static class RecipeBuilder extends GasRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Chemical Oxidizer recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Chemical Oxidizer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -80,8 +81,7 @@ public void validate(GroovyLog.Msg msg) { validateGases(msg, 0, 0, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable OxidationRecipe register() { if (!validate()) return null; OxidationRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Combiner.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Combiner.java index 84c8faaed..5ffc31899 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Combiner.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Combiner.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,11 +11,10 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.DoubleMachineInput; import mekanism.common.recipe.machines.CombinerRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Combiner extends VirtualizedMekanismRegistry { @@ -25,7 +28,9 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "ore('gemQuartz') * 8, item('minecraft:netherrack'), item('minecraft:quartz_ore')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "ore('gemQuartz') * 8, item('minecraft:netherrack'), item('minecraft:quartz_ore')", + commented = true)) public CombinerRecipe add(IIngredient ingredient, ItemStack extra, ItemStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Crusher recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -64,8 +69,7 @@ public boolean removeByInput(IIngredient ingredient, ItemStack extra) { return found; } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "new ItemStack(Blocks.COBBLESTONE)") @@ -78,9 +82,7 @@ public RecipeBuilder extra(ItemStack extra) { } @Override - public String getErrorMsg() { - return "Error adding Mekanism Combiner recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Combiner recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -88,8 +90,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CombinerRecipe register() { if (!validate()) return null; CombinerRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Crusher.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Crusher.java index 31b8bd2c8..89e7c92b5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Crusher.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Crusher.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,11 +11,10 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.CrusherRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Crusher extends VirtualizedMekanismRegistry { @@ -25,7 +28,8 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "item('minecraft:clay_ball'), item('minecraft:gold_ingot')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "item('minecraft:clay_ball'), item('minecraft:gold_ingot')", commented = true)) public CrusherRecipe add(IIngredient ingredient, ItemStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Crusher recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -62,14 +66,11 @@ public boolean removeByInput(IIngredient ingredient) { return found; } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Crusher recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Crusher recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -77,8 +78,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CrusherRecipe register() { if (!validate()) return null; CrusherRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Crystallizer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Crystallizer.java index be40cbfd8..e358b9364 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Crystallizer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Crystallizer.java @@ -1,17 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.GasRecipeBuilder; import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.GasInput; import mekanism.common.recipe.machines.CrystallizerRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Crystallizer extends VirtualizedMekanismRegistry { @@ -25,7 +28,8 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "gas('cleanGold'), item('minecraft:gold_ingot')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "gas('cleanGold'), item('minecraft:gold_ingot')", commented = true)) public CrystallizerRecipe add(GasStack input, ItemStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Crystallizer recipe").error(); msg.add(Mekanism.isEmpty(input), () -> "input must not be empty"); @@ -53,14 +57,11 @@ public boolean removeByInput(GasStack input) { return false; } - @Property(property = "output", valid = @Comp("1")) - @Property(property = "gasInput", valid = @Comp("1")) + @Property(property = "output", valid = @Comp("1")) @Property(property = "gasInput", valid = @Comp("1")) public static class RecipeBuilder extends GasRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Crystallizer recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Crystallizer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -69,8 +70,7 @@ public void validate(GroovyLog.Msg msg) { validateGases(msg, 1, 1, 0, 0); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CrystallizerRecipe register() { if (!validate()) return null; CrystallizerRecipe recipe = new CrystallizerRecipe(gasInput.get(0), output.get(0)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/DissolutionChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/DissolutionChamber.java index ac09717f8..db2ce56e7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/DissolutionChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/DissolutionChamber.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,12 +12,11 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.DissolutionRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class DissolutionChamber extends VirtualizedMekanismRegistry { @@ -27,7 +30,8 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "item('minecraft:packed_ice'), gas('water')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "item('minecraft:packed_ice'), gas('water')", commented = true)) public DissolutionRecipe add(IIngredient ingredient, GasStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Dissolution Chamber recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -64,14 +68,11 @@ public boolean removeByInput(IIngredient ingredient) { return found; } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "gasOutput", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "gasOutput", valid = @Comp("1")) public static class RecipeBuilder extends GasRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Dissolution Chamber recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Dissolution Chamber recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -80,8 +81,7 @@ public void validate(GroovyLog.Msg msg) { validateGases(msg, 0, 0, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable DissolutionRecipe register() { if (!validate()) return null; DissolutionRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ElectrolyticSeparator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ElectrolyticSeparator.java index 829d514bd..7459f8436 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ElectrolyticSeparator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ElectrolyticSeparator.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -7,12 +11,11 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.FluidInput; import mekanism.common.recipe.machines.SeparatorRecipe; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class ElectrolyticSeparator extends VirtualizedMekanismRegistry { @@ -26,7 +29,9 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "fluid('lava') * 10, gas('cleanGold') * 5, gas('cleanCopper') * 3, 3000", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "fluid('lava') * 10, gas('cleanGold') * 5, gas('cleanCopper') * 3, 3000", + commented = true)) public SeparatorRecipe add(FluidStack input, GasStack leftOutput, GasStack rightOutput, double energy) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Electrolytic Separator recipe").error(); msg.add(IngredientHelper.isEmpty(input), () -> "input must not be empty"); @@ -55,8 +60,7 @@ public boolean removeByInput(FluidStack input) { return false; } - @Property(property = "fluidInput", valid = @Comp("1")) - @Property(property = "gasOutput", valid = @Comp("2")) + @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "gasOutput", valid = @Comp("2")) public static class RecipeBuilder extends GasRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.GT, value = "0")) @@ -69,9 +73,7 @@ public RecipeBuilder energy(double energy) { } @Override - public String getErrorMsg() { - return "Error adding Mekanism Electrolytic Separator recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Electrolytic Separator recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -81,8 +83,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(energy <= 0, "energy must be a nonnegative integer, yet it was {}", energy); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SeparatorRecipe register() { if (!validate()) return null; SeparatorRecipe recipe = new SeparatorRecipe(fluidInput.get(0), energy, gasOutput.get(0), gasOutput.get(1)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/EnrichmentChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/EnrichmentChamber.java index e9e2629e6..a352e6edc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/EnrichmentChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/EnrichmentChamber.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,11 +12,10 @@ import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.EnrichmentRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class EnrichmentChamber extends VirtualizedMekanismRegistry { @@ -26,7 +29,8 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "item('minecraft:clay_ball'), item('minecraft:nether_star')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "item('minecraft:clay_ball'), item('minecraft:nether_star')", commented = true)) public EnrichmentRecipe add(IIngredient ingredient, ItemStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Enrichment Chamber recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -63,14 +67,11 @@ public boolean removeByInput(IIngredient ingredient) { return found; } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Enrichment Chamber recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Enrichment Chamber recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -78,8 +79,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable EnrichmentRecipe register() { if (!validate()) return null; EnrichmentRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Infusion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Infusion.java index fbac5cc6c..c4e605e67 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Infusion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Infusion.java @@ -1,5 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import java.util.Arrays; +import java.util.Collection; +import java.util.Locale; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; @@ -9,29 +21,18 @@ import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import mekanism.api.infuse.InfuseObject; import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; -import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Locale; -import java.util.Map; -import java.util.stream.Collectors; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES, - reloadability = RegistryDescription.Reloadability.FLAWED, - admonition = @Admonition(type = Admonition.Type.DANGER, - format = Admonition.Format.STANDARD, - hasTitle = true, - value = "groovyscript.wiki.mekanism.infusion.note0"), - priority = 100 -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES, + reloadability = RegistryDescription.Reloadability.FLAWED, + admonition = @Admonition(type = Admonition.Type.DANGER, + format = Admonition.Format.STANDARD, + hasTitle = true, + value = "groovyscript.wiki.mekanism.infusion.note0"), + priority = 100) public class Infusion extends VirtualizedRegistry> { private final AbstractReloadableStorage> objectStorage = new AbstractReloadableStorage<>(); @@ -62,7 +63,9 @@ public void onReload() { objectStorage.removeScripted().forEach(pair -> InfuseRegistry.getObjectMap().remove(pair.getKey())); } - @MethodDescription(example = @Example("'groovy_example', resource('placeholdername:blocks/mekanism_infusion_texture')"), type = MethodDescription.Type.ADDITION, priority = 500) + @MethodDescription(example = @Example("'groovy_example', resource('placeholdername:blocks/mekanism_infusion_texture')"), + type = MethodDescription.Type.ADDITION, + priority = 500) public void addType(String name, ResourceLocation resource) { InfuseType infuse = new InfuseType(name.toUpperCase(Locale.ROOT), resource); infuse.unlocalizedName = name.toLowerCase(Locale.ROOT); @@ -83,10 +86,9 @@ public boolean removeType(String name) { return true; } - @MethodDescription(example = { - @Example("infusionType('diamond'), 100, item('minecraft:clay')"), - @Example("infusionType('carbon'), 100, item('minecraft:gold_ingot')") - }, type = MethodDescription.Type.ADDITION) + @MethodDescription(example = {@Example("infusionType('diamond'), 100, item('minecraft:clay')"), + @Example("infusionType('carbon'), 100, item('minecraft:gold_ingot')")}, + type = MethodDescription.Type.ADDITION) public void add(InfuseType type, int amount, ItemStack item) { InfuseObject object = new InfuseObject(type, amount); objectStorage.addScripted(Pair.of(item, object)); @@ -95,22 +97,23 @@ public void add(InfuseType type, int amount, ItemStack item) { @MethodDescription(type = MethodDescription.Type.ADDITION) public void add(InfuseType type, int amount, IIngredient... ingredients) { - for (ItemStack item : Arrays.stream(ingredients).flatMap(g -> Arrays.stream(g.getMatchingStacks())).collect(Collectors.toList())) { + for (ItemStack item : Arrays.stream(ingredients).flatMap(g -> Arrays.stream(g.getMatchingStacks())).collect(Collectors + .toList())) { add(type, amount, item); } } - @MethodDescription(example = { - @Example("'groovy_example', 10, item('minecraft:ice')"), - @Example("'groovy_example', 20, item('minecraft:packed_ice')") - }, type = MethodDescription.Type.ADDITION) + @MethodDescription(example = {@Example("'groovy_example', 10, item('minecraft:ice')"), + @Example("'groovy_example', 20, item('minecraft:packed_ice')")}, + type = MethodDescription.Type.ADDITION) public void add(String type, int amount, IIngredient... ingredients) { add(InfuseRegistry.get(type.toUpperCase(Locale.ROOT)), amount, ingredients); } @MethodDescription(type = MethodDescription.Type.ADDITION) public void add(InfuseType type, int amount, Collection ingredients) { - for (ItemStack item : ingredients.stream().flatMap(g -> Arrays.stream(g.getMatchingStacks())).collect(Collectors.toList())) { + for (ItemStack item : ingredients.stream().flatMap(g -> Arrays.stream(g.getMatchingStacks())).collect(Collectors + .toList())) { add(type, amount, item); } } @@ -122,7 +125,9 @@ public void add(String type, int amount, Collection ingredients) { @MethodDescription(example = @Example("ore('dustDiamond')")) public void remove(IIngredient item) { - for (Map.Entry entry : InfuseRegistry.getObjectMap().entrySet().stream().filter(x -> item.test(x.getKey())).collect(Collectors.toList())) { + for (Map.Entry entry : InfuseRegistry.getObjectMap().entrySet().stream().filter(x -> item.test(x + .getKey())) + .collect(Collectors.toList())) { objectStorage.addBackup(Pair.of(entry.getKey(), entry.getValue())); InfuseRegistry.getObjectMap().remove(entry.getKey()); } @@ -142,12 +147,12 @@ public void remove(Collection ingredients) { } } - @MethodDescription(example = { - @Example("infusionType('carbon')"), - @Example(value = "infusionType('diamond')", commented = true) - }) + @MethodDescription(example = {@Example("infusionType('carbon')"), @Example(value = "infusionType('diamond')", + commented = true)}) public void removeByType(InfuseType type) { - for (Map.Entry entry : InfuseRegistry.getObjectMap().entrySet().stream().filter(x -> x.getValue().type == type).collect(Collectors.toList())) { + for (Map.Entry entry : InfuseRegistry.getObjectMap().entrySet().stream().filter(x -> x + .getValue().type == type) + .collect(Collectors.toList())) { objectStorage.addBackup(Pair.of(entry.getKey(), entry.getValue())); InfuseRegistry.getObjectMap().remove(entry.getKey()); } @@ -175,7 +180,8 @@ public InfusionItems(InfuseType type) { } public InfusionItems(String type, ResourceLocation resource) { - if (!InfuseRegistry.contains(type.toUpperCase(Locale.ROOT))) ModSupport.MEKANISM.get().infusion.addType(type, resource); + if (!InfuseRegistry.contains(type.toUpperCase(Locale.ROOT))) ModSupport.MEKANISM.get().infusion.addType(type, + resource); this.type = InfuseRegistry.get(type.toUpperCase(Locale.ROOT)); } @@ -184,11 +190,11 @@ public InfusionItems(String type, String resource) { } public InfusionItems(String type) { - if (InfuseRegistry.contains(type.toUpperCase(Locale.ROOT))) this.type = InfuseRegistry.get(type.toUpperCase(Locale.ROOT)); - else GroovyLog.msg("Error creating Mekansim Infusion type") - .add("No ResourceLocation was defined for requested infusion type {}", type) - .error() - .post(); + if (InfuseRegistry.contains(type.toUpperCase(Locale.ROOT))) this.type = InfuseRegistry.get(type.toUpperCase( + Locale.ROOT)); + else GroovyLog.msg("Error creating Mekansim Infusion type").add( + "No ResourceLocation was defined for requested infusion type {}", + type).error().post(); } public InfusionItems add(int amount, IIngredient item) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/InjectionChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/InjectionChamber.java index 7b9930393..1a12d227b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/InjectionChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/InjectionChamber.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,12 +12,11 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.machines.InjectionRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class InjectionChamber extends VirtualizedMekanismRegistry { @@ -22,12 +25,15 @@ public InjectionChamber() { super(RecipeHandler.Recipe.CHEMICAL_INJECTION_CHAMBER, Alias.generateOfClassAnd(InjectionChamber.class, "Injector")); } - @RecipeBuilderDescription(example = @Example(value = ".input(item('minecraft:diamond')).gasInput(gas('water'))/*()!*/.output(item('minecraft:nether_star'))", annotations = "groovyscript.wiki.mekanism.injection_chamber.annotation")) + @RecipeBuilderDescription(example = @Example(value = ".input(item('minecraft:diamond')).gasInput(gas('water'))/*()!*/.output(item('minecraft:nether_star'))", + annotations = "groovyscript.wiki.mekanism.injection_chamber.annotation")) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "item('minecraft:diamond'), gas('water'), item('minecraft:nether_star')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "item('minecraft:diamond'), gas('water'), item('minecraft:nether_star')", + commented = true)) public InjectionRecipe add(IIngredient ingredient, GasStack gasInput, ItemStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Injection Chamber recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -72,9 +78,7 @@ public boolean removeByInput(IIngredient ingredient, GasStack gasInput) { public static class RecipeBuilder extends GasRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Injection Chamber recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Injection Chamber recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -83,8 +87,7 @@ public void validate(GroovyLog.Msg msg) { validateGases(msg, 1, 1, 0, 0); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable InjectionRecipe register() { if (!validate()) return null; InjectionRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Mekanism.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Mekanism.java index b75fd36ef..0ba9f72e4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Mekanism.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Mekanism.java @@ -1,19 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.Optional; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.IObjectParser; import com.cleanroommc.groovyscript.api.Result; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; + import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.Optional; -import org.jetbrains.annotations.Nullable; public class Mekanism extends GroovyPropertyContainer { @@ -40,19 +43,13 @@ public class Mekanism extends GroovyPropertyContainer { @Override public void initialize(GroovyContainer container) { - container.objectMapperBuilder("gas", GasStack.class) - .parser((s, args) -> { - Gas gas = GasRegistry.getGas(s); - return gas == null ? Result.error() : Result.some(new GasStack(gas, 1)); - }) - .completerOfNamed(GasRegistry::getRegisteredGasses, Gas::getName) - .docOfType("gas stack") - .register(); - container.objectMapperBuilder("infusionType", InfuseType.class) - .parser(IObjectParser.wrapStringGetter(InfuseRegistry::get, true)) - .completerOfNames(InfuseRegistry.getInfuseMap()::keySet) - .docOfType("infusion type") - .register(); + container.objectMapperBuilder("gas", GasStack.class).parser((s, args) -> { + Gas gas = GasRegistry.getGas(s); + return gas == null ? Result.error() : Result.some(new GasStack(gas, 1)); + }).completerOfNamed(GasRegistry::getRegisteredGasses, Gas::getName).docOfType("gas stack").register(); + container.objectMapperBuilder("infusionType", InfuseType.class).parser(IObjectParser.wrapStringGetter(InfuseRegistry::get, + true)) + .completerOfNames(InfuseRegistry.getInfuseMap()::keySet).docOfType("infusion type").register(); } @Optional.Method(modid = "mekanism") diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/MetallurgicInfuser.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/MetallurgicInfuser.java index efa15c304..86dddfbcf 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/MetallurgicInfuser.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/MetallurgicInfuser.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,13 +11,12 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.InfusionInput; import mekanism.common.recipe.machines.MetallurgicInfuserRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class MetallurgicInfuser extends VirtualizedMekanismRegistry { @@ -27,7 +30,10 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(description = "groovyscript.wiki.mekanism.metallurgic_infuser.add0", type = MethodDescription.Type.ADDITION, example = @Example(value = "item('minecraft:nether_star'), infusionType('groovy_example'), 50, item('minecraft:clay')", commented = true)) + @MethodDescription(description = "groovyscript.wiki.mekanism.metallurgic_infuser.add0", + type = MethodDescription.Type.ADDITION, + example = @Example(value = "item('minecraft:nether_star'), infusionType('groovy_example'), 50, item('minecraft:clay')", + commented = true)) public MetallurgicInfuserRecipe add(IIngredient ingredient, InfuseType infuseType, int infuseAmount, ItemStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Metallurgic Infuser recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -38,7 +44,8 @@ public MetallurgicInfuserRecipe add(IIngredient ingredient, InfuseType infuseTyp MetallurgicInfuserRecipe recipe1 = null; for (ItemStack itemStack : ingredient.getMatchingStacks()) { - MetallurgicInfuserRecipe recipe = new MetallurgicInfuserRecipe(new InfusionInput(infuseType, infuseAmount, itemStack), output); + MetallurgicInfuserRecipe recipe = new MetallurgicInfuserRecipe(new InfusionInput(infuseType, infuseAmount, itemStack), + output); if (recipe1 == null) recipe1 = recipe; recipeRegistry.put(recipe); addScripted(recipe); @@ -78,8 +85,7 @@ public boolean removeByInput(IIngredient ingredient, String infuseType) { } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.NOT, value = "null")) @@ -105,9 +111,7 @@ public RecipeBuilder amount(int amount) { } @Override - public String getErrorMsg() { - return "Error adding Mekanism Metallurgic Infuser recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Metallurgic Infuser recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -117,13 +121,13 @@ public void validate(GroovyLog.Msg msg) { msg.add(amount <= 0, "amount must be an integer greater than 0, yet it was {}", amount); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable MetallurgicInfuserRecipe register() { if (!validate()) return null; MetallurgicInfuserRecipe recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { - MetallurgicInfuserRecipe r = new MetallurgicInfuserRecipe(new InfusionInput(infuse, amount, itemStack), output.get(0)); + MetallurgicInfuserRecipe r = new MetallurgicInfuserRecipe(new InfusionInput(infuse, amount, itemStack), output + .get(0)); if (recipe == null) recipe = r; ModSupport.MEKANISM.get().metallurgicInfuser.add(r); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/OsmiumCompressor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/OsmiumCompressor.java index 2e5889317..46f3d76d4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/OsmiumCompressor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/OsmiumCompressor.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,6 +11,7 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.GasRecipeBuilder; import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import mekanism.api.gas.Gas; import mekanism.api.gas.GasStack; import mekanism.common.MekanismFluids; @@ -14,8 +19,6 @@ import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.machines.OsmiumCompressorRecipe; import mekanism.common.recipe.outputs.ItemStackOutput; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class OsmiumCompressor extends VirtualizedMekanismRegistry { @@ -24,12 +27,15 @@ public OsmiumCompressor() { super(RecipeHandler.Recipe.OSMIUM_COMPRESSOR); } - @RecipeBuilderDescription(example = @Example(value = ".input(item('minecraft:diamond')).gasInput(gas('hydrogen'))/*()!*/.output(item('minecraft:nether_star'))", annotations = "groovyscript.wiki.mekanism.osmium_compressor.annotation")) + @RecipeBuilderDescription(example = @Example(value = ".input(item('minecraft:diamond')).gasInput(gas('hydrogen'))/*()!*/.output(item('minecraft:nether_star'))", + annotations = "groovyscript.wiki.mekanism.osmium_compressor.annotation")) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "item('minecraft:diamond'), gas('hydrogen'), item('minecraft:nether_star')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "item('minecraft:diamond'), gas('hydrogen'), item('minecraft:nether_star')", + commented = true)) public OsmiumCompressorRecipe add(IIngredient ingredient, GasStack gasInput, ItemStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Osmium Compressor recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -38,7 +44,8 @@ public OsmiumCompressorRecipe add(IIngredient ingredient, GasStack gasInput, Ite OsmiumCompressorRecipe recipe1 = null; for (ItemStack itemStack : ingredient.getMatchingStacks()) { - OsmiumCompressorRecipe recipe = new OsmiumCompressorRecipe(new AdvancedMachineInput(itemStack, gasInput.getGas()), new ItemStackOutput(output)); + OsmiumCompressorRecipe recipe = new OsmiumCompressorRecipe(new AdvancedMachineInput(itemStack, gasInput.getGas()), + new ItemStackOutput(output)); if (recipe1 == null) recipe1 = recipe; recipeRegistry.put(recipe); addScripted(recipe); @@ -69,13 +76,13 @@ public boolean removeByInput(IIngredient ingredient, GasStack gasInput) { @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) - @Property(property = "gasInput", defaultValue = "MekanismFluids.LiquidOsmium", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(property = "gasInput", + defaultValue = "MekanismFluids.LiquidOsmium", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) public static class RecipeBuilder extends GasRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Osmium Compressor recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Osmium Compressor recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -84,14 +91,14 @@ public void validate(GroovyLog.Msg msg) { validateGases(msg, 0, 1, 0, 0); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable OsmiumCompressorRecipe register() { if (!validate()) return null; Gas gas = gasInput.isEmpty() ? MekanismFluids.LiquidOsmium : gasInput.get(0).getGas(); OsmiumCompressorRecipe recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { - OsmiumCompressorRecipe r = new OsmiumCompressorRecipe(new AdvancedMachineInput(itemStack, gas), new ItemStackOutput(output.get(0))); + OsmiumCompressorRecipe r = new OsmiumCompressorRecipe(new AdvancedMachineInput(itemStack, gas), + new ItemStackOutput(output.get(0))); if (recipe == null) recipe = r; ModSupport.MEKANISM.get().osmiumCompressor.add(r); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/PressurizedReactionChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/PressurizedReactionChamber.java index 351666b02..8d506cdba 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/PressurizedReactionChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/PressurizedReactionChamber.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,20 +13,20 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.PressurizedInput; import mekanism.common.recipe.machines.PressurizedRecipe; import mekanism.common.recipe.outputs.PressurizedOutput; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class PressurizedReactionChamber extends VirtualizedMekanismRegistry { public PressurizedReactionChamber() { - super(RecipeHandler.Recipe.PRESSURIZED_REACTION_CHAMBER, Alias.generateOfClass(PressurizedReactionChamber.class).and("PRC", "prc")); + super(RecipeHandler.Recipe.PRESSURIZED_REACTION_CHAMBER, Alias.generateOfClass(PressurizedReactionChamber.class).and( + "PRC", + "prc")); } @RecipeBuilderDescription(example = @Example(".fluidInput(fluid('water')).gasInput(gas('water')).input(item('minecraft:clay_ball')).gasOutput(gas('ethene'))")) @@ -30,10 +35,12 @@ public RecipeBuilder recipeBuilder() { } @MethodDescription - public PressurizedRecipe add(IIngredient inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double energy, int duration) { + public PressurizedRecipe add(IIngredient inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, + GasStack outputGas, double energy, int duration) { PressurizedRecipe r = null; for (ItemStack item : inputSolid.getMatchingStacks()) { - PressurizedRecipe recipe = new PressurizedRecipe(item, inputFluid, inputGas, outputSolid, outputGas, energy, duration); + PressurizedRecipe recipe = new PressurizedRecipe(item, inputFluid, inputGas, outputSolid, outputGas, energy, + duration); if (r == null) r = recipe; recipeRegistry.put(recipe); addScripted(recipe); @@ -43,12 +50,13 @@ public PressurizedRecipe add(IIngredient inputSolid, FluidStack inputFluid, GasS @MethodDescription(example = @Example("ore('logWood'), fluid('water'), gas('oxygen')")) public boolean removeByInput(IIngredient inputSolid, FluidStack inputFluid, GasStack inputGas) { - if (GroovyLog.msg("Error removing Mekanism Pressurized Reaction Chamber recipe").error() - .add(IngredientHelper.isEmpty(inputSolid), () -> "item input must not be empty") - .add(IngredientHelper.isEmpty(inputFluid), () -> "fluid input must not be empty") - .add(Mekanism.isEmpty(inputGas), () -> "input gas must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing Mekanism Pressurized Reaction Chamber recipe").error().add(IngredientHelper.isEmpty( + inputSolid), + () -> "item input must not be empty") + .add(IngredientHelper.isEmpty(inputFluid), () -> "fluid input must not be empty").add(Mekanism.isEmpty( + inputGas), + () -> "input gas must not be empty") + .error().postIfNotEmpty()) { return false; } boolean found = false; @@ -90,9 +98,7 @@ public RecipeBuilder energy(double energy) { } @Override - public String getErrorMsg() { - return "Error adding Mekanism Pressurized Reaction Chamber recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Pressurized Reaction Chamber recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -103,18 +109,20 @@ public void validate(GroovyLog.Msg msg) { if (energy <= 0) energy = 8000; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable PressurizedRecipe register() { if (!validate()) return null; PressurizedOutput pressurizedOutput = new PressurizedOutput(output.getOrEmpty(0), gasOutput.get(0)); PressurizedRecipe recipe = null; if (input.isEmpty()) { - recipe = new PressurizedRecipe(new PressurizedInput(ItemStack.EMPTY, fluidInput.get(0), gasInput.get(0)), pressurizedOutput, energy, duration); + recipe = new PressurizedRecipe(new PressurizedInput(ItemStack.EMPTY, fluidInput.get(0), gasInput.get(0)), + pressurizedOutput, energy, duration); ModSupport.MEKANISM.get().pressurizedReactionChamber.add(recipe); } else { for (ItemStack itemStack : input.get(0).getMatchingStacks()) { - PressurizedRecipe r = new PressurizedRecipe(new PressurizedInput(itemStack, fluidInput.get(0), gasInput.get(0)), pressurizedOutput, energy, duration); + PressurizedRecipe r = new PressurizedRecipe(new PressurizedInput(itemStack, fluidInput.get(0), gasInput.get( + 0)), + pressurizedOutput, energy, duration); if (recipe == null) recipe = r; ModSupport.MEKANISM.get().pressurizedReactionChamber.add(r); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/PurificationChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/PurificationChamber.java index a2e65b860..942e8319b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/PurificationChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/PurificationChamber.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,13 +12,12 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; + import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.machines.PurificationRecipe; import mekanism.common.recipe.outputs.ItemStackOutput; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class PurificationChamber extends VirtualizedMekanismRegistry { @@ -28,7 +31,9 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "item('minecraft:diamond'), gas('oxygen'), item('minecraft:nether_star')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "item('minecraft:diamond'), gas('oxygen'), item('minecraft:nether_star')", + commented = true)) public PurificationRecipe add(IIngredient ingredient, GasStack gasInput, ItemStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Purification Chamber recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -37,7 +42,8 @@ public PurificationRecipe add(IIngredient ingredient, GasStack gasInput, ItemSta PurificationRecipe recipe1 = null; for (ItemStack itemStack : ingredient.getMatchingStacks()) { - PurificationRecipe recipe = new PurificationRecipe(new AdvancedMachineInput(itemStack, gasInput.getGas()), new ItemStackOutput(output)); + PurificationRecipe recipe = new PurificationRecipe(new AdvancedMachineInput(itemStack, gasInput.getGas()), + new ItemStackOutput(output)); if (recipe1 == null) recipe1 = recipe; recipeRegistry.put(recipe); addScripted(recipe); @@ -72,9 +78,7 @@ public boolean removeByInput(IIngredient ingredient, GasStack gasInput) { public static class RecipeBuilder extends GasRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Purification Chamber recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Purification Chamber recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -83,13 +87,13 @@ public void validate(GroovyLog.Msg msg) { validateGases(msg, 1, 1, 0, 0); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable PurificationRecipe register() { if (!validate()) return null; PurificationRecipe recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { - PurificationRecipe r = new PurificationRecipe(new AdvancedMachineInput(itemStack, gasInput.get(0).getGas()), new ItemStackOutput(output.get(0))); + PurificationRecipe r = new PurificationRecipe(new AdvancedMachineInput(itemStack, gasInput.get(0).getGas()), + new ItemStackOutput(output.get(0))); if (recipe == null) recipe = r; ModSupport.MEKANISM.get().purificationChamber.add(r); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Sawmill.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Sawmill.java index c1504686d..f67688a32 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Sawmill.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Sawmill.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,12 +11,11 @@ import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.SawmillRecipe; import mekanism.common.recipe.outputs.ChanceOutput; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Sawmill extends VirtualizedMekanismRegistry { @@ -36,7 +39,10 @@ public SawmillRecipe add(IIngredient ingredient, ItemStack output, ItemStack sec return add(ingredient, output, secondary, 1.0); } - @MethodDescription(description = "groovyscript.wiki.mekanism.sawmill.add2", type = MethodDescription.Type.ADDITION, example = @Example(value = "item('minecraft:diamond_block'), item('minecraft:diamond') * 9, item('minecraft:clay_ball'), 0.7", commented = true)) + @MethodDescription(description = "groovyscript.wiki.mekanism.sawmill.add2", + type = MethodDescription.Type.ADDITION, + example = @Example(value = "item('minecraft:diamond_block'), item('minecraft:diamond') * 9, item('minecraft:clay_ball'), 0.7", + commented = true)) public SawmillRecipe add(IIngredient ingredient, ItemStack output, ItemStack secondary, double chance) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Sawmill recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -80,13 +86,13 @@ public boolean removeByInput(IIngredient ingredient) { return found; } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "ItemStack.EMPTY") private ItemStack extra = ItemStack.EMPTY; - @Property(defaultValue = "1.0", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(defaultValue = "1.0", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) private double chance = 1.0; @RecipeBuilderMethodDescription @@ -102,9 +108,7 @@ public RecipeBuilder chance(double chance) { } @Override - public String getErrorMsg() { - return "Error adding Mekanism Sawmill recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Sawmill recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -113,13 +117,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(chance < 0 || chance > 1, "chance must be between 0 and 1.0, yet it was {}", chance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SawmillRecipe register() { if (!validate()) return null; - ChanceOutput chanceOutput = extra.isEmpty() - ? new ChanceOutput(output.get(0)) - : new ChanceOutput(output.get(0), extra, chance); + ChanceOutput chanceOutput = extra.isEmpty() ? new ChanceOutput(output.get(0)) : new ChanceOutput(output.get(0), extra, + chance); SawmillRecipe recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { SawmillRecipe r = new SawmillRecipe(new ItemStackInput(itemStack), chanceOutput); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Smelting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Smelting.java index d94d2d2e0..6316178fb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Smelting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Smelting.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,18 +12,16 @@ import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.SmeltingRecipe; import mekanism.common.recipe.outputs.ItemStackOutput; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -@RegistryDescription( - admonition = @Admonition(value = "groovyscript.wiki.mekanism.smelting.note0", - type = Admonition.Type.DANGER, - format = Admonition.Format.STANDARD, - hasTitle = true)) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.mekanism.smelting.note0", + type = Admonition.Type.DANGER, + format = Admonition.Format.STANDARD, + hasTitle = true)) public class Smelting extends VirtualizedMekanismRegistry { public Smelting() { @@ -31,7 +33,8 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "item('minecraft:diamond_block'), item('minecraft:clay')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "item('minecraft:diamond_block'), item('minecraft:clay')", commented = true)) public SmeltingRecipe add(IIngredient ingredient, ItemStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Smelter recipe").error(); msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty"); @@ -68,14 +71,11 @@ public boolean removeByInput(IIngredient ingredient) { return found; } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Smelting recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Smelting recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -83,8 +83,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SmeltingRecipe register() { if (!validate()) return null; SmeltingRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/SolarNeutronActivator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/SolarNeutronActivator.java index 294da9d35..bd34eb284 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/SolarNeutronActivator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/SolarNeutronActivator.java @@ -1,16 +1,18 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.GasRecipeBuilder; import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.Alias; + import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.GasInput; import mekanism.common.recipe.machines.SolarNeutronRecipe; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class SolarNeutronActivator extends VirtualizedMekanismRegistry { @@ -24,7 +26,8 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "gas('water'), gas('hydrogen')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "gas('water'), gas('hydrogen')", commented = true)) public SolarNeutronRecipe add(GasStack input, GasStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Solar Neutron Activator recipe").error(); msg.add(Mekanism.isEmpty(input), () -> "input must not be empty"); @@ -52,14 +55,11 @@ public boolean removeByInput(GasStack input) { return false; } - @Property(property = "gasInput", valid = @Comp("1")) - @Property(property = "gasOutput", valid = @Comp("1")) + @Property(property = "gasInput", valid = @Comp("1")) @Property(property = "gasOutput", valid = @Comp("1")) public static class RecipeBuilder extends GasRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Solar Neutron Activator recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Solar Neutron Activator recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -68,8 +68,7 @@ public void validate(GroovyLog.Msg msg) { validateGases(msg, 1, 1, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SolarNeutronRecipe register() { if (!validate()) return null; SolarNeutronRecipe recipe = new SolarNeutronRecipe(gasInput.get(0), gasOutput.get(0)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ThermalEvaporationPlant.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ThermalEvaporationPlant.java index f3c8525ef..6b3a21e9d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ThermalEvaporationPlant.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/ThermalEvaporationPlant.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -7,17 +11,17 @@ import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.FluidInput; import mekanism.common.recipe.machines.ThermalEvaporationRecipe; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class ThermalEvaporationPlant extends VirtualizedMekanismRegistry { public ThermalEvaporationPlant() { - super(RecipeHandler.Recipe.THERMAL_EVAPORATION_PLANT, Alias.generateOfClassAnd(ThermalEvaporationPlant.class, "ThermalEvaporation").and("TEP", "tep")); + super(RecipeHandler.Recipe.THERMAL_EVAPORATION_PLANT, Alias.generateOfClassAnd(ThermalEvaporationPlant.class, + "ThermalEvaporation").and("TEP", "tep")); } @RecipeBuilderDescription(example = @Example(".fluidInput(fluid('water')).fluidOutput(fluid('steam'))")) @@ -25,7 +29,8 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "fluid('water'), fluid('steam')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "fluid('water'), fluid('steam')", commented = true)) public ThermalEvaporationRecipe add(FluidStack input, FluidStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Solar Neutron Activator recipe").error(); msg.add(IngredientHelper.isEmpty(input), () -> "input must not be empty"); @@ -53,14 +58,11 @@ public boolean removeByInput(FluidStack input) { return false; } - @Property(property = "fluidInput", valid = @Comp("1")) - @Property(property = "fluidOutput", valid = @Comp("1")) + @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Thermal Evaporation Plant recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Thermal Evaporation Plant recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -68,8 +70,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 1, 1, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ThermalEvaporationRecipe register() { if (!validate()) return null; ThermalEvaporationRecipe recipe = new ThermalEvaporationRecipe(fluidInput.get(0), fluidOutput.get(0)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Washer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Washer.java index 874ac3363..d80950953 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Washer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/Washer.java @@ -1,16 +1,18 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.GasRecipeBuilder; import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry; import com.cleanroommc.groovyscript.helper.Alias; + import mekanism.api.gas.GasStack; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.GasInput; import mekanism.common.recipe.machines.WasherRecipe; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Washer extends VirtualizedMekanismRegistry { @@ -24,7 +26,8 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "gas('water'), gas('hydrogen')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "gas('water'), gas('hydrogen')", commented = true)) public WasherRecipe add(GasStack input, GasStack output) { GroovyLog.Msg msg = GroovyLog.msg("Error adding Mekanism Washer recipe").error(); msg.add(Mekanism.isEmpty(input), () -> "input must not be empty"); @@ -52,14 +55,11 @@ public boolean removeByInput(GasStack input) { return false; } - @Property(property = "gasInput", valid = @Comp("1")) - @Property(property = "gasOutput", valid = @Comp("1")) + @Property(property = "gasInput", valid = @Comp("1")) @Property(property = "gasOutput", valid = @Comp("1")) public static class RecipeBuilder extends GasRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Mekanism Washer recipe"; - } + public String getErrorMsg() { return "Error adding Mekanism Washer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -68,8 +68,7 @@ public void validate(GroovyLog.Msg msg) { validateGases(msg, 1, 1, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable WasherRecipe register() { if (!validate()) return null; WasherRecipe recipe = new WasherRecipe(gasInput.get(0), gasOutput.get(0)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/GasRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/GasRecipeBuilder.java index 05bcc0245..ced31b59e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/GasRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/GasRecipeBuilder.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism.recipe; +import java.util.Collection; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Property; import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderMethodDescription; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import mekanism.api.gas.GasStack; -import java.util.Collection; +import mekanism.api.gas.GasStack; public abstract class GasRecipeBuilder extends AbstractRecipeBuilder { @@ -63,8 +64,12 @@ public GasRecipeBuilder gasOutput(GasStack... gases) { public void validateGases(GroovyLog.Msg msg, int minInput, int maxInput, int minOutput, int maxOutput) { gasInput.trim(); gasOutput.trim(); - msg.add(gasInput.size() < minInput || gasInput.size() > maxInput, () -> getRequiredString(minInput, maxInput, "gas input") + ", but found " + gasInput.size()); - msg.add(gasOutput.size() < minOutput || gasOutput.size() > maxOutput, () -> getRequiredString(minOutput, maxOutput, "gas output") + ", but found " + gasOutput.size()); + msg.add(gasInput.size() < minInput || gasInput.size() > maxInput, () -> getRequiredString(minInput, maxInput, + "gas input") + ", but found " + + gasInput.size()); + msg.add(gasOutput.size() < minOutput || gasOutput.size() > maxOutput, () -> getRequiredString(minOutput, maxOutput, + "gas output") + + ", but found " + gasOutput.size()); } public void validateGases(GroovyLog.Msg msg) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/GasStackList.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/GasStackList.java index 8c9779007..e6e509b95 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/GasStackList.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/GasStackList.java @@ -1,24 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism.recipe; -import com.cleanroommc.groovyscript.compat.mods.mekanism.Mekanism; -import mekanism.api.gas.GasStack; - import java.util.ArrayList; import java.util.Collection; +import com.cleanroommc.groovyscript.compat.mods.mekanism.Mekanism; + +import mekanism.api.gas.GasStack; + public class GasStackList extends ArrayList { - public GasStackList() { - } + public GasStackList() {} public GasStackList(Collection collection) { super(collection); } public GasStack getOrEmpty(int i) { - if (i < 0 || i >= size()) { - return null; - } + if (i < 0 || i >= size()) { return null; } return get(i); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/IngredientWrapper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/IngredientWrapper.java index 88622135a..9a86e34de 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/IngredientWrapper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/IngredientWrapper.java @@ -31,25 +31,15 @@ public IngredientWrapper(IIngredient ingredient, String infuseType) { this.infuseType = infuseType == null ? "" : infuseType; } - public String getInfuseType() { - return this.infuseType; - } + public String getInfuseType() { return this.infuseType; } - public IIngredient getIngredient() { - return this.left; - } + public IIngredient getIngredient() { return this.left; } - public IIngredient getLeft() { - return this.left; - } + public IIngredient getLeft() { return this.left; } - public IIngredient getMiddle() { - return this.middle; - } + public IIngredient getMiddle() { return this.middle; } - public IIngredient getRight() { - return this.right; - } + public IIngredient getRight() { return this.right; } public int getAmount() { //TODO: Make this method actually do something if we ever need to use IntegerInput as an input type diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/MekanismIngredientHelper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/MekanismIngredientHelper.java index 55c409e0d..ca5544654 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/MekanismIngredientHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/MekanismIngredientHelper.java @@ -1,9 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism.recipe; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; + import mekanism.api.gas.Gas; import mekanism.api.gas.GasStack; import mekanism.common.recipe.ingredients.IMekanismIngredient; @@ -12,14 +17,10 @@ import mekanism.common.recipe.ingredients.OredictMekIngredient; import mekanism.common.recipe.inputs.*; import mekanism.common.recipe.outputs.*; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; public class MekanismIngredientHelper { - private MekanismIngredientHelper() { - } + private MekanismIngredientHelper() {} public static IIngredient optionalIngredient(IIngredient ingredient) { return ingredient != null ? ingredient : IIngredient.ANY; @@ -36,30 +37,18 @@ public static boolean checkNotNull(String name, IIngredient... ingredients) { } private static IIngredient getIngredient(Object ingredient) { - if (ingredient instanceof IIngredient) { - return (IIngredient) ingredient; - } + if (ingredient instanceof IIngredient) { return (IIngredient) ingredient; } - if (ingredient instanceof Gas) { - return (IIngredient) new GasStack((Gas) ingredient, 1); - } - if (ingredient instanceof Fluid) { - return (IIngredient) new FluidStack((Fluid) ingredient, 1); - } + if (ingredient instanceof Gas) { return (IIngredient) new GasStack((Gas) ingredient, 1); } + if (ingredient instanceof Fluid) { return (IIngredient) new FluidStack((Fluid) ingredient, 1); } //TODO: Support other types of things like ore dict return IIngredient.ANY; } public static boolean matches(IIngredient input, IIngredient toMatch) { - if (input instanceof GasStack) { - return matches(toMatch, (GasStack) input); - } - if (IngredientHelper.isItem(input)) { - return toMatch != null && toMatch.test(IngredientHelper.toItemStack(input)); - } - if (input instanceof FluidStack) { - return toMatch != null && toMatch.test((FluidStack) input); - } + if (input instanceof GasStack) { return matches(toMatch, (GasStack) input); } + if (IngredientHelper.isItem(input)) { return toMatch != null && toMatch.test(IngredientHelper.toItemStack(input)); } + if (input instanceof FluidStack) { return toMatch != null && toMatch.test((FluidStack) input); } //TODO: Support other types of things like ore dict return false; } @@ -89,10 +78,14 @@ public static > boolean matches(INPUT in, Ingr return matches(input.itemStack, toMatch.getLeft()) && matches(input.extraStack, toMatch.getRight()); } else if (in instanceof PressurizedInput) { PressurizedInput input = (PressurizedInput) in; - return matches(input.getSolid(), toMatch.getLeft()) && matches(input.getFluid(), toMatch.getMiddle()) && matches(input.getGas(), toMatch.getRight()); + return matches(input.getSolid(), toMatch.getLeft()) && matches(input.getFluid(), toMatch.getMiddle()) && matches(input + .getGas(), + toMatch.getRight()); } else if (in instanceof InfusionInput) { InfusionInput input = (InfusionInput) in; - return matches(input.inputStack, toMatch.getIngredient()) && (toMatch.getInfuseType().isEmpty() || toMatch.getInfuseType().equalsIgnoreCase(input.infuse.getType().name)); + return matches(input.inputStack, toMatch.getIngredient()) && (toMatch.getInfuseType().isEmpty() || toMatch + .getInfuseType() + .equalsIgnoreCase(input.infuse.getType().name)); } else if (in instanceof IntegerInput) { IntegerInput input = (IntegerInput) in; return input.ingredient == toMatch.getAmount(); @@ -132,22 +125,14 @@ public static IMekanismIngredient getMekanismIngredient(IIngredient i if (ingredient instanceof OreDictIngredient) { return new OredictMekIngredient(((OreDictIngredient) ingredient).getOreDict()); } - if (IngredientHelper.isItem(ingredient)) { - return new ItemStackMekIngredient(IngredientHelper.toItemStack(ingredient)); - } + if (IngredientHelper.isItem(ingredient)) { return new ItemStackMekIngredient(IngredientHelper.toItemStack(ingredient)); } return new IngredientMekIngredientWrapper(ingredient.toMcIngredient()); } public static boolean matches(IIngredient ingredient, GasStack gasStack) { - if (ingredient == null) { - return false; - } - if (ingredient == IIngredient.ANY) { - return true; - } - if (ingredient instanceof GasStack) { - return ((GasStack) ingredient).isGasEqual(gasStack); - } + if (ingredient == null) { return false; } + if (ingredient == IIngredient.ANY) { return true; } + if (ingredient instanceof GasStack) { return ((GasStack) ingredient).isGasEqual(gasStack); } return false; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/VirtualizedMekanismRegistry.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/VirtualizedMekanismRegistry.java index f9a12cfa5..b0b606198 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/VirtualizedMekanismRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mekanism/recipe/VirtualizedMekanismRegistry.java @@ -1,17 +1,19 @@ package com.cleanroommc.groovyscript.compat.mods.mekanism.recipe; +import java.util.Collection; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.machines.MachineRecipe; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - -import java.util.Collection; public abstract class VirtualizedMekanismRegistry> extends VirtualizedRegistry { @@ -26,9 +28,7 @@ public VirtualizedMekanismRegistry(RecipeHandler.Recipe recipeRegistry, this.recipeRegistry = recipeRegistry; } - @GroovyBlacklist - @ApiStatus.Internal - @Override + @GroovyBlacklist @ApiStatus.Internal @Override public void onReload() { removeScripted().forEach(recipeRegistry::remove); restoreFromBackup().forEach(recipeRegistry::put); @@ -49,8 +49,7 @@ public boolean remove(R recipe) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(recipeRegistry.get().values()) - .setRemover(this::remove); + return new SimpleObjectStream<>(recipeRegistry.get().values()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -61,9 +60,6 @@ public void removeAll() { @GroovyBlacklist public void removeError(String reason, Object... data) { - GroovyLog.msg("Error removing Mekanism " + getAliases().get(0) + " recipe") - .add(reason, data) - .error() - .post(); + GroovyLog.msg("Error removing Mekanism " + getAliases().get(0) + " recipe").add(reason, data).error().post(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Altar.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Altar.java index dc0700581..3502e12f1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Altar.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Altar.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.naturesaura; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,12 +14,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.recipes.AltarRecipe; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription public class Altar extends VirtualizedRegistry { @@ -22,11 +25,9 @@ public Altar() { super(Alias.generateOfClass(Altar.class).andGenerate("Infusion")); } - @RecipeBuilderDescription(example = { - @Example(".name('demo').input(item('minecraft:clay')).catalyst(item('minecraft:clay')).output(item('minecraft:diamond')).aura(100).time(100)"), - @Example(".name(resource('example:demo')).input(item('minecraft:clay')).output(item('minecraft:gold_ingot') * 8).aura(30).time(5)"), - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).catalyst(item('minecraft:clay')).aura(50).time(100)") - }) + @RecipeBuilderDescription(example = {@Example(".name('demo').input(item('minecraft:clay')).catalyst(item('minecraft:clay')).output(item('minecraft:diamond')).aura(100).time(100)"), + @Example(".name(resource('example:demo')).input(item('minecraft:clay')).output(item('minecraft:gold_ingot') * 8).aura(30).time(5)"), + @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).catalyst(item('minecraft:clay')).aura(50).time(100)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -106,8 +107,7 @@ public SimpleObjectStream> streamRecipe return new SimpleObjectStream<>(NaturesAuraAPI.ALTAR_RECIPES.entrySet()).setRemover(x -> remove(x.getValue())); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "null", type = Comp.Type.NOT), defaultValue = "IIngredient.EMPTY") @@ -136,14 +136,10 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Nature's Aura Altar Recipe"; - } + public String getErrorMsg() { return "Error adding Nature's Aura Altar Recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_altar_"; - } + public String getRecipeNamePrefix() { return "groovyscript_altar_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -155,11 +151,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AltarRecipe register() { if (!validate()) return null; - AltarRecipe recipe = new AltarRecipe(super.name, input.get(0).toMcIngredient(), output.get(0), catalyst.toMcIngredient(), aura, time); + AltarRecipe recipe = new AltarRecipe(super.name, input.get(0).toMcIngredient(), output.get(0), catalyst + .toMcIngredient(), + aura, time); ModSupport.NATURES_AURA.get().altar.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Offering.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Offering.java index aa51c6901..00011b210 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Offering.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Offering.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.naturesaura; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,21 +14,16 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.recipes.OfferingRecipe; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription(admonition = @Admonition("groovyscript.wiki.naturesaura.offering.note0")) public class Offering extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('demo').input(item('minecraft:diamond')).catalyst(item('minecraft:clay')).output(item('minecraft:gold_ingot') * 8)"), - @Example(".name(resource('example:demo')).input(item('minecraft:clay')).catalyst(item('minecraft:gold_ingot')).output(item('minecraft:diamond') * 8)"), - @Example(".input(item('minecraft:gold_ingot') * 10).catalyst(item('minecraft:diamond')).output(item('minecraft:clay'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('demo').input(item('minecraft:diamond')).catalyst(item('minecraft:clay')).output(item('minecraft:gold_ingot') * 8)"), + @Example(".name(resource('example:demo')).input(item('minecraft:clay')).catalyst(item('minecraft:gold_ingot')).output(item('minecraft:diamond') * 8)"), + @Example(".input(item('minecraft:gold_ingot') * 10).catalyst(item('minecraft:diamond')).output(item('minecraft:clay'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -102,8 +103,7 @@ public SimpleObjectStream> streamRec return new SimpleObjectStream<>(NaturesAuraAPI.OFFERING_RECIPES.entrySet()).setRemover(x -> remove(x.getValue())); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) @@ -116,14 +116,10 @@ public RecipeBuilder catalyst(IIngredient catalyst) { } @Override - public String getErrorMsg() { - return "Error adding Nature's Aura Offering Recipe"; - } + public String getErrorMsg() { return "Error adding Nature's Aura Offering Recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_offering_"; - } + public String getRecipeNamePrefix() { return "groovyscript_offering_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -133,11 +129,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(IngredientHelper.isEmpty(catalyst), "catalyst must not be empty"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable OfferingRecipe register() { if (!validate()) return null; - OfferingRecipe recipe = new OfferingRecipe(super.name, input.get(0).toMcIngredient(), catalyst.toMcIngredient(), output.get(0)); + OfferingRecipe recipe = new OfferingRecipe(super.name, input.get(0).toMcIngredient(), catalyst.toMcIngredient(), + output.get(0)); ModSupport.NATURES_AURA.get().offering.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Ritual.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Ritual.java index 15f1b520d..7716f1cd9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Ritual.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Ritual.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.naturesaura; +import java.util.Map; + +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,22 +15,17 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; -@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.naturesaura.ritual.note0", type = Admonition.Type.WARNING)) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.naturesaura.ritual.note0", + type = Admonition.Type.WARNING)) public class Ritual extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('demo').input(item('minecraft:clay')).output(item('minecraft:diamond')).time(100).sapling(item('minecraft:sapling:1'))"), - @Example(".name(resource('example:demo')).input(item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:gold_ingot')).time(15).sapling(item('minecraft:sapling:1'))"), - @Example(".input(item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay')).output(item('minecraft:diamond') * 16).time(20).sapling(item('minecraft:sapling:3'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('demo').input(item('minecraft:clay')).output(item('minecraft:diamond')).time(100).sapling(item('minecraft:sapling:1'))"), + @Example(".name(resource('example:demo')).input(item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:gold_ingot')).time(15).sapling(item('minecraft:sapling:1'))"), + @Example(".input(item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:clay')).output(item('minecraft:diamond') * 16).time(20).sapling(item('minecraft:sapling:3'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -55,7 +57,7 @@ public boolean removeByName(ResourceLocation name) { return true; } - @MethodDescription( example = @Example("item('naturesaura:infused_stone')")) + @MethodDescription(example = @Example("item('naturesaura:infused_stone')")) public boolean removeByInput(IIngredient input) { return NaturesAuraAPI.TREE_RITUAL_RECIPES.entrySet().removeIf(r -> { for (var ingredient : r.getValue().ingredients) { @@ -83,7 +85,7 @@ public boolean removeBySapling(IIngredient catalyst) { }); } - @MethodDescription( example = @Example("item('naturesaura:eye')")) + @MethodDescription(example = @Example("item('naturesaura:eye')")) public boolean removeByOutput(IIngredient output) { return NaturesAuraAPI.TREE_RITUAL_RECIPES.entrySet().removeIf(r -> { if (output.test(r.getValue().result)) { @@ -127,14 +129,10 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Nature's Aura Ritual Recipe"; - } + public String getErrorMsg() { return "Error adding Nature's Aura Ritual Recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_ritual_"; - } + public String getRecipeNamePrefix() { return "groovyscript_ritual_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -145,11 +143,13 @@ public void validate(GroovyLog.Msg msg) { msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable TreeRitualRecipe register() { if (!validate()) return null; - TreeRitualRecipe recipe = new TreeRitualRecipe(super.name, sapling.toMcIngredient(), output.get(0), time, input.stream().map(IIngredient::toMcIngredient).toArray(Ingredient[]::new)); + TreeRitualRecipe recipe = new TreeRitualRecipe(super.name, sapling.toMcIngredient(), output.get(0), time, input + .stream() + .map(IIngredient::toMcIngredient) + .toArray(Ingredient[]::new)); ModSupport.NATURES_AURA.get().ritual.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Spawning.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Spawning.java index 0ead8f71b..b75fd2b01 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Spawning.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/naturesaura/Spawning.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.naturesaura; +import java.util.Map; + +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,23 +15,17 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.jetbrains.annotations.Nullable; -import java.util.Map; - -@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.naturesaura.spawning.note0", type = Admonition.Type.WARNING)) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.naturesaura.spawning.note0", + type = Admonition.Type.WARNING)) public class Spawning extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('demo').input(item('minecraft:clay')).entity(entity('minecraft:bat')).aura(100).time(100)"), - @Example(".name(resource('example:demo')).input(item('minecraft:mutton')).entity(entity('minecraft:wolf')).aura(30).time(5)"), - @Example(".input(item('minecraft:bone'), item('minecraft:dye:15') * 4).entity(resource('minecraft:skeleton')).aura(10).time(10)") - }) + @RecipeBuilderDescription(example = {@Example(".name('demo').input(item('minecraft:clay')).entity(entity('minecraft:bat')).aura(100).time(100)"), + @Example(".name(resource('example:demo')).input(item('minecraft:mutton')).entity(entity('minecraft:wolf')).aura(30).time(5)"), + @Example(".input(item('minecraft:bone'), item('minecraft:dye:15') * 4).entity(resource('minecraft:skeleton')).aura(10).time(10)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -103,7 +105,8 @@ public SimpleObjectStream> stre return new SimpleObjectStream<>(NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES.entrySet()).setRemover(x -> remove(x.getValue())); } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) + @Property(property = "input", + valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @@ -139,14 +142,10 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Nature's Aura Spawning Recipe"; - } + public String getErrorMsg() { return "Error adding Nature's Aura Spawning Recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_spawning_"; - } + public String getRecipeNamePrefix() { return "groovyscript_spawning_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -156,11 +155,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(entity == null, "entity must not be null"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AnimalSpawnerRecipe register() { if (!validate()) return null; - AnimalSpawnerRecipe recipe = new AnimalSpawnerRecipe(super.name, entity, aura, time, input.stream().map(IIngredient::toMcIngredient).toArray(Ingredient[]::new)); + AnimalSpawnerRecipe recipe = new AnimalSpawnerRecipe(super.name, entity, aura, time, input.stream().map( + IIngredient::toMcIngredient) + .toArray(Ingredient[]::new)); ModSupport.NATURES_AURA.get().spawning.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Amadron.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Amadron.java index d687b464a..9f0c02d7a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Amadron.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Amadron.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,27 +16,19 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import me.desht.pneumaticcraft.common.recipes.AmadronOffer; import me.desht.pneumaticcraft.common.recipes.AmadronOfferManager; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -@RegistryDescription( - admonition = @Admonition(value = "groovyscript.wiki.pneumaticcraft.amadron.note0", type = Admonition.Type.WARNING) -) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.pneumaticcraft.amadron.note0", + type = Admonition.Type.WARNING)) public class Amadron extends VirtualizedRegistry { private final AbstractReloadableStorage periodicStorage = new AbstractReloadableStorage<>(); - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay') * 3).output(item('minecraft:gold_ingot'))"), - @Example(".fluidInput(fluid('water') * 50).output(item('minecraft:clay') * 3)"), - @Example(".fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 10).periodic()") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay') * 3).output(item('minecraft:gold_ingot'))"), + @Example(".fluidInput(fluid('water') * 50).output(item('minecraft:clay') * 3)"), + @Example(".fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 10).periodic()")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -138,8 +138,10 @@ public SimpleObjectStream streamRecipes() { @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) - @Property(property = "fluidInput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) - @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(property = "fluidInput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(property = "fluidOutput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -158,16 +160,16 @@ public RecipeBuilder periodic(boolean periodic) { } @Override - public String getErrorMsg() { - return "Error adding PneumaticCraft Amadron recipe"; - } + public String getErrorMsg() { return "Error adding PneumaticCraft Amadron recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 0, 1, 0, 1); validateFluids(msg, 0, 1, 0, 1); - msg.add(input.isEmpty() && fluidInput.isEmpty(), "either input or fluidInput must contain an entry, but both were empty"); - msg.add(output.isEmpty() && fluidOutput.isEmpty(), "either output or fluidOutput must contain an entry, but both were empty"); + msg.add(input.isEmpty() && fluidInput.isEmpty(), + "either input or fluidInput must contain an entry, but both were empty"); + msg.add(output.isEmpty() && fluidOutput.isEmpty(), + "either output or fluidOutput must contain an entry, but both were empty"); } private static void register(boolean periodic, AmadronOffer recipe) { @@ -175,8 +177,7 @@ private static void register(boolean periodic, AmadronOffer recipe) { else ModSupport.PNEUMATIC_CRAFT.get().amadron.addStatic(recipe); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AmadronOffer register() { if (!validate()) return null; AmadronOffer recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/AssemblyController.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/AssemblyController.java index c9c092926..dd10c0a33 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/AssemblyController.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/AssemblyController.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,25 +18,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import me.desht.pneumaticcraft.common.item.ItemAssemblyProgram; import me.desht.pneumaticcraft.common.recipes.AssemblyRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; @RegistryDescription public class AssemblyController extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay') * 3).output(item('minecraft:gold_ingot') * 6).drill()"), - @Example(".input(item('minecraft:gold_ingot') * 6).output(item('minecraft:diamond')).laser()"), - @Example(".input(item('minecraft:stone')).output(item('minecraft:clay') * 5).laser()") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay') * 3).output(item('minecraft:gold_ingot') * 6).drill()"), + @Example(".input(item('minecraft:gold_ingot') * 6).output(item('minecraft:diamond')).laser()"), + @Example(".input(item('minecraft:stone')).output(item('minecraft:clay') * 5).laser()")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -34,10 +35,9 @@ public static RecipeBuilder recipeBuilder() { private List map(AssemblyRecipe recipe) { int type = recipe.getProgramStack().getMetadata(); if (type < 0 || type > AssemblyType.values().length) { - GroovyLog.msg("Error getting the recipe map for PneumaticCraft Assembly Controller") - .add("type was {}, which is not one of the expected values of 0, 1, or 2", type) - .error() - .post(); + GroovyLog.msg("Error getting the recipe map for PneumaticCraft Assembly Controller").add( + "type was {}, which is not one of the expected values of 0, 1, or 2", + type).error().post(); return new ArrayList<>(); } return map(AssemblyType.values()[type]); @@ -50,15 +50,13 @@ private List map(AssemblyType type) { }; } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(recipe -> map(recipe).remove(recipe)); restoreFromBackup().forEach(recipe -> map(recipe).add(recipe)); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void afterScriptLoad() { AssemblyRecipe.drillLaserRecipes.clear(); AssemblyRecipe.calculateAssemblyChain(); @@ -126,17 +124,15 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(Arrays.stream(AssemblyType.values()).map(this::map).flatMap(Collection::stream).collect(Collectors.toList())) - .setRemover(this::remove); + return new SimpleObjectStream<>(Arrays.stream(AssemblyType.values()).map(this::map).flatMap(Collection::stream).collect( + Collectors.toList())).setRemover(this::remove); } public enum AssemblyType { - DRILL, - LASER + DRILL, LASER } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) @@ -155,9 +151,7 @@ public RecipeBuilder laser() { } @Override - public String getErrorMsg() { - return "Error adding PneumaticCraft Assembly Controller recipe"; - } + public String getErrorMsg() { return "Error adding PneumaticCraft Assembly Controller recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -166,8 +160,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(programStack == null, "programStack cannot be null"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AssemblyRecipe register() { if (!validate()) return null; AssemblyRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Explosion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Explosion.java index 4d8d96779..4ea6cbd87 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Explosion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Explosion.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,19 +12,15 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import me.desht.pneumaticcraft.common.recipes.ExplosionCraftingRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; -@RegistryDescription( - admonition = @Admonition(value = "groovyscript.wiki.pneumaticcraft.explosion.note0", type = Admonition.Type.TIP) -) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.pneumaticcraft.explosion.note0", + type = Admonition.Type.TIP)) public class Explosion extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot')).lossRate(40)"), - @Example(".input(item('minecraft:diamond')).output(item('minecraft:obsidian'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot')).lossRate(40)"), + @Example(".input(item('minecraft:diamond')).output(item('minecraft:obsidian'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -55,7 +55,8 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example(value = "item('minecraft:iron_block')", commented = true)) public boolean removeByInput(IIngredient input) { return ExplosionCraftingRecipe.recipes.removeIf(entry -> { - if (input.test(entry.getInput()) || input instanceof OreDictIngredient oreDictIngredient && oreDictIngredient.getOreDict().equals(entry.getOreDictKey())) { + if (input.test(entry.getInput()) || input instanceof OreDictIngredient oreDictIngredient && oreDictIngredient.getOreDict() + .equals(entry.getOreDictKey())) { addBackup(entry); return true; } @@ -74,8 +75,7 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(ExplosionCraftingRecipe.recipes).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.GTE, value = "0")) @@ -88,9 +88,7 @@ public RecipeBuilder lossRate(int lossRate) { } @Override - public String getErrorMsg() { - return "Error adding PneumaticCraft Explosion recipe"; - } + public String getErrorMsg() { return "Error adding PneumaticCraft Explosion recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,8 +97,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(lossRate < 0, "lossRate must be a non negative integer, yet it was {}", lossRate); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ExplosionCraftingRecipe register() { if (!validate()) return null; ExplosionCraftingRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/HeatFrameCooling.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/HeatFrameCooling.java index 3a76f5bfa..dcf393260 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/HeatFrameCooling.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/HeatFrameCooling.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,16 +9,14 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import me.desht.pneumaticcraft.common.recipes.HeatFrameCoolingRecipe; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class HeatFrameCooling extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot'))"), - @Example(".input(item('minecraft:diamond')).output(item('minecraft:obsidian'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot'))"), + @Example(".input(item('minecraft:diamond')).output(item('minecraft:obsidian'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -70,14 +70,11 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(HeatFrameCoolingRecipe.recipes).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding PneumaticCraft Heat Frame Cooling recipe"; - } + public String getErrorMsg() { return "Error adding PneumaticCraft Heat Frame Cooling recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -85,11 +82,11 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable HeatFrameCoolingRecipe register() { if (!validate()) return null; - HeatFrameCoolingRecipe recipe = new HeatFrameCoolingRecipe(PneumaticCraft.toItemIngredient(input.get(0)), output.get(0)); + HeatFrameCoolingRecipe recipe = new HeatFrameCoolingRecipe(PneumaticCraft.toItemIngredient(input.get(0)), output.get( + 0)); ModSupport.PNEUMATIC_CRAFT.get().heatFrameCooling.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/LiquidFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/LiquidFuel.java index 4b81c3917..38caf8768 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/LiquidFuel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/LiquidFuel.java @@ -1,17 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import java.util.Map; + +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import me.desht.pneumaticcraft.common.PneumaticCraftAPIHandler; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; -import java.util.Map; +import me.desht.pneumaticcraft.common.PneumaticCraftAPIHandler; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class LiquidFuel extends VirtualizedRegistry> { @@ -24,7 +27,8 @@ public static RecipeBuilder recipeBuilder() { @Override public void onReload() { removeScripted().forEach(recipe -> PneumaticCraftAPIHandler.getInstance().liquidFuels.remove(recipe.getKey())); - restoreFromBackup().forEach(recipe -> PneumaticCraftAPIHandler.getInstance().liquidFuels.put(recipe.getKey(), recipe.getValue())); + restoreFromBackup().forEach(recipe -> PneumaticCraftAPIHandler.getInstance().liquidFuels.put(recipe.getKey(), recipe + .getValue())); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -59,11 +63,11 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(PneumaticCraftAPIHandler.getInstance().liquidFuels.entrySet()) - .setRemover(x -> remove(x.getKey())); + return new SimpleObjectStream<>(PneumaticCraftAPIHandler.getInstance().liquidFuels.entrySet()).setRemover(x -> remove(x.getKey())); } - @Property(property = "fluidInput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(property = "fluidInput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) public static class RecipeBuilder extends AbstractRecipeBuilder> { @Property @@ -76,9 +80,7 @@ public RecipeBuilder pressure(int pressure) { } @Override - public String getErrorMsg() { - return "Error adding PneumaticCraft Liquid Fuel entry"; - } + public String getErrorMsg() { return "Error adding PneumaticCraft Liquid Fuel entry"; } @Override public void validate(GroovyLog.Msg msg) { @@ -87,8 +89,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(pressure <= 0, "pressure must be greater than 0, yet it was {}", pressure); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable Pair register() { if (!validate()) return null; ModSupport.PNEUMATIC_CRAFT.get().liquidFuel.add(fluidInput.get(0), pressure); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PlasticMixer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PlasticMixer.java index f7f170fa0..da8954db6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PlasticMixer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PlasticMixer.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,21 +11,17 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import me.desht.pneumaticcraft.common.recipes.PlasticMixerRegistry; -import org.jetbrains.annotations.Nullable; -@RegistryDescription( - admonition = { - @Admonition(value = "groovyscript.wiki.pneumaticcraft.plastic_mixer.note0", type = Admonition.Type.WARNING), - @Admonition(value = "groovyscript.wiki.pneumaticcraft.plastic_mixer.note1", type = Admonition.Type.DANGER) - } -) +@RegistryDescription(admonition = {@Admonition(value = "groovyscript.wiki.pneumaticcraft.plastic_mixer.note0", + type = Admonition.Type.WARNING), @Admonition( + value = "groovyscript.wiki.pneumaticcraft.plastic_mixer.note1", + type = Admonition.Type.DANGER)}) public class PlasticMixer extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('lava') * 100).output(item('minecraft:clay')).allowMelting().allowSolidifying().requiredTemperature(323)"), - @Example(".fluidInput(fluid('water') * 50).output(item('minecraft:sapling')).allowSolidifying().requiredTemperature(298).meta(-1)") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('lava') * 100).output(item('minecraft:clay')).allowMelting().allowSolidifying().requiredTemperature(323)"), + @Example(".fluidInput(fluid('water') * 50).output(item('minecraft:sapling')).allowSolidifying().requiredTemperature(298).meta(-1)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -91,8 +89,7 @@ public SimpleObjectStream streamRecipes return new SimpleObjectStream<>(getInstance().getRecipes()).setRemover(this::remove); } - @Property(property = "output", valid = @Comp("1")) - @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "output", valid = @Comp("1")) @Property(property = "fluidInput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -155,22 +152,25 @@ public RecipeBuilder useDye(boolean useDye) { } @Override - public String getErrorMsg() { - return "Error adding PneumaticCraft Plastic Mixer recipe"; - } + public String getErrorMsg() { return "Error adding PneumaticCraft Plastic Mixer recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 0, 0, 1, 1); validateFluids(msg, 1, 1, 0, 0); - msg.add(!allowMelting && !allowSolidifying, "neither allowMelting or allowSolidifying are enabled, one of the two must be enabled"); + msg.add(!allowMelting && !allowSolidifying, + "neither allowMelting or allowSolidifying are enabled, one of the two must be enabled"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable PlasticMixerRegistry.PlasticMixerRecipe register() { if (!validate()) return null; - PlasticMixerRegistry.PlasticMixerRecipe recipe = PlasticMixerRecipeAccessor.createPlasticMixerRecipe(fluidInput.get(0), output.get(0), requiredTemperature, allowMelting, allowSolidifying, useDye, meta); + PlasticMixerRegistry.PlasticMixerRecipe recipe = PlasticMixerRecipeAccessor.createPlasticMixerRecipe(fluidInput.get(0), + output.get(0), + requiredTemperature, + allowMelting, + allowSolidifying, + useDye, meta); ModSupport.PNEUMATIC_CRAFT.get().plasticMixer.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PneumaticCraft.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PneumaticCraft.java index a59622170..32cb9e746 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PneumaticCraft.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PneumaticCraft.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; -import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; + import me.desht.pneumaticcraft.api.recipe.ItemIngredient; -import net.minecraft.item.ItemStack; public class PneumaticCraft extends GroovyPropertyContainer { @@ -22,7 +23,8 @@ public class PneumaticCraft extends GroovyPropertyContainer { public final XpFluid xpFluid = new XpFluid(); public static ItemIngredient toItemIngredient(IIngredient ingredient) { - if (ingredient instanceof OreDictIngredient oreDictIngredient) return new ItemIngredient(oreDictIngredient.getOreDict(), ingredient.getAmount()); + if (ingredient instanceof OreDictIngredient oreDictIngredient) return new ItemIngredient(oreDictIngredient.getOreDict(), + ingredient.getAmount()); if (IngredientHelper.isItem(ingredient)) return new ItemIngredient(IngredientHelper.toItemStack(ingredient).copy()); return new ItemIngredient(ItemStack.EMPTY); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PressureChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PressureChamber.java index 08d177e10..242407a38 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PressureChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PressureChamber.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import java.util.Collection; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,21 +13,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import me.desht.pneumaticcraft.api.recipe.IPressureChamberRecipe; import me.desht.pneumaticcraft.api.recipe.ItemIngredient; import me.desht.pneumaticcraft.common.recipes.PressureChamberRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.Collection; @RegistryDescription public class PressureChamber extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay') * 3).output(item('minecraft:gold_ingot')).pressure(4)"), - @Example(".input(item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:gold_block'), item('minecraft:gold_nugget'), item('minecraft:diamond'), item('minecraft:diamond_block'), item('minecraft:obsidian'), item('minecraft:stone'), item('minecraft:stone:1'), item('minecraft:stone:2'), item('minecraft:stone:3'), item('minecraft:stone:4'), item('minecraft:stone:5'), item('minecraft:stone:6')).output(item('minecraft:cobblestone')).pressure(4)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay') * 3).output(item('minecraft:gold_ingot')).pressure(4)"), + @Example(".input(item('minecraft:clay'), item('minecraft:gold_ingot'), item('minecraft:gold_block'), item('minecraft:gold_nugget'), item('minecraft:diamond'), item('minecraft:diamond_block'), item('minecraft:obsidian'), item('minecraft:stone'), item('minecraft:stone:1'), item('minecraft:stone:2'), item('minecraft:stone:3'), item('minecraft:stone:4'), item('minecraft:stone:5'), item('minecraft:stone:6')).output(item('minecraft:cobblestone')).pressure(4)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -75,8 +76,10 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(PressureChamberRecipe.recipes).setRemover(this::remove); } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) - @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) + @Property(property = "input", + valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) + @Property(property = "output", + valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -89,9 +92,7 @@ public RecipeBuilder pressure(float pressure) { } @Override - public String getErrorMsg() { - return "Error adding PneumaticCraft Pressure Chamber recipe"; - } + public String getErrorMsg() { return "Error adding PneumaticCraft Pressure Chamber recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -99,11 +100,13 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IPressureChamberRecipe register() { if (!validate()) return null; - IPressureChamberRecipe recipe = new PressureChamberRecipe.SimpleRecipe(input.stream().map(PneumaticCraft::toItemIngredient).toArray(ItemIngredient[]::new), pressure, output.toArray(new ItemStack[0])); + IPressureChamberRecipe recipe = new PressureChamberRecipe.SimpleRecipe(input.stream().map( + PneumaticCraft::toItemIngredient) + .toArray(ItemIngredient[]::new), pressure, + output.toArray(new ItemStack[0])); ModSupport.PNEUMATIC_CRAFT.get().pressureChamber.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Refinery.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Refinery.java index 5f304f8a6..71605acda 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Refinery.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Refinery.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import java.util.Arrays; + +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,19 +13,14 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import me.desht.pneumaticcraft.common.recipes.RefineryRecipe; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; +import me.desht.pneumaticcraft.common.recipes.RefineryRecipe; @RegistryDescription public class Refinery extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('water') * 1000).fluidOutput(fluid('lava') * 750, fluid('lava') * 250, fluid('lava') * 100, fluid('lava') * 50)"), - @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('water') * 50, fluid('kerosene') * 25)") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('water') * 1000).fluidOutput(fluid('lava') * 750, fluid('lava') * 250, fluid('lava') * 100, fluid('lava') * 50)"), + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('water') * 50, fluid('kerosene') * 25)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -74,7 +75,8 @@ public SimpleObjectStream streamRecipes() { } @Property(property = "fluidInput", valid = @Comp("1")) - @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "2"), @Comp(type = Comp.Type.LTE, value = "4")}) + @Property(property = "fluidOutput", + valid = {@Comp(type = Comp.Type.GTE, value = "2"), @Comp(type = Comp.Type.LTE, value = "4")}) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "373") @@ -87,9 +89,7 @@ public RecipeBuilder requiredTemperature(int requiredTemperature) { } @Override - public String getErrorMsg() { - return "Error adding PneumaticCraft Refinery recipe"; - } + public String getErrorMsg() { return "Error adding PneumaticCraft Refinery recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -97,11 +97,11 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 1, 1, 2, 4); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RefineryRecipe register() { if (!validate()) return null; - RefineryRecipe recipe = new RefineryRecipe(requiredTemperature, fluidInput.get(0), fluidOutput.toArray(new FluidStack[0])); + RefineryRecipe recipe = new RefineryRecipe(requiredTemperature, fluidInput.get(0), fluidOutput.toArray( + new FluidStack[0])); ModSupport.PNEUMATIC_CRAFT.get().refinery.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/ThermopneumaticProcessingPlant.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/ThermopneumaticProcessingPlant.java index e9b3299d3..6d076e639 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/ThermopneumaticProcessingPlant.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/ThermopneumaticProcessingPlant.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,18 +11,15 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import me.desht.pneumaticcraft.api.recipe.IThermopneumaticProcessingPlantRecipe; import me.desht.pneumaticcraft.common.recipes.BasicThermopneumaticProcessingPlantRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class ThermopneumaticProcessingPlant extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay') * 3).fluidInput(fluid('water') * 100).fluidOutput(fluid('kerosene') * 100).pressure(4).requiredTemperature(323)"), - @Example(".fluidInput(fluid('water') * 100).fluidOutput(fluid('lava') * 100).pressure(4).requiredTemperature(323)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay') * 3).fluidInput(fluid('water') * 100).fluidOutput(fluid('kerosene') * 100).pressure(4).requiredTemperature(323)"), + @Example(".fluidInput(fluid('water') * 100).fluidOutput(fluid('lava') * 100).pressure(4).requiredTemperature(323)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -95,9 +96,7 @@ public RecipeBuilder requiredTemperature(double requiredTemperature) { } @Override - public String getErrorMsg() { - return "Error adding PneumaticCraft Thermopneumatic Processing Plant recipe"; - } + public String getErrorMsg() { return "Error adding PneumaticCraft Thermopneumatic Processing Plant recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -105,17 +104,21 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 1, 1, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IThermopneumaticProcessingPlantRecipe register() { if (!validate()) return null; IThermopneumaticProcessingPlantRecipe recipe = null; if (input.isEmpty()) { - recipe = new BasicThermopneumaticProcessingPlantRecipe(fluidInput.get(0), ItemStack.EMPTY, fluidOutput.get(0), requiredTemperature, pressure); + recipe = new BasicThermopneumaticProcessingPlantRecipe(fluidInput.get(0), ItemStack.EMPTY, fluidOutput.get(0), + requiredTemperature, pressure); ModSupport.PNEUMATIC_CRAFT.get().thermopneumaticProcessingPlant.add(recipe); } else { for (ItemStack stack : input.get(0).getMatchingStacks()) { - IThermopneumaticProcessingPlantRecipe recipe1 = new BasicThermopneumaticProcessingPlantRecipe(fluidInput.get(0), stack, fluidOutput.get(0), requiredTemperature, pressure); + IThermopneumaticProcessingPlantRecipe recipe1 = new BasicThermopneumaticProcessingPlantRecipe(fluidInput.get(0), + stack, + fluidOutput.get(0), + requiredTemperature, + pressure); ModSupport.PNEUMATIC_CRAFT.get().thermopneumaticProcessingPlant.add(recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/XpFluid.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/XpFluid.java index cb7a310f6..8c7ee05c3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/XpFluid.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/XpFluid.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.pneumaticcraft; +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,13 +15,8 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import me.desht.pneumaticcraft.common.PneumaticCraftAPIHandler; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; -import java.util.Map; +import me.desht.pneumaticcraft.common.PneumaticCraftAPIHandler; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class XpFluid extends VirtualizedRegistry> { @@ -23,15 +26,14 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(recipe -> PneumaticCraftAPIHandler.getInstance().liquidXPs.remove(recipe.getKey())); - restoreFromBackup().forEach(recipe -> PneumaticCraftAPIHandler.getInstance().liquidXPs.put(recipe.getKey(), recipe.getValue())); + restoreFromBackup().forEach(recipe -> PneumaticCraftAPIHandler.getInstance().liquidXPs.put(recipe.getKey(), recipe + .getValue())); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void afterScriptLoad() { PneumaticCraftAPIHandler.getInstance().availableLiquidXPs.clear(); PneumaticCraftAPIHandler.getInstance().availableLiquidXPs.addAll(PneumaticCraftAPIHandler.getInstance().liquidXPs.keySet()); @@ -69,11 +71,11 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(PneumaticCraftAPIHandler.getInstance().liquidXPs.entrySet()) - .setRemover(x -> remove(x.getKey())); + return new SimpleObjectStream<>(PneumaticCraftAPIHandler.getInstance().liquidXPs.entrySet()).setRemover(x -> remove(x.getKey())); } - @Property(property = "fluidInput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(property = "fluidInput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) public static class RecipeBuilder extends AbstractRecipeBuilder> { @Property @@ -86,9 +88,7 @@ public RecipeBuilder ratio(int ratio) { } @Override - public String getErrorMsg() { - return "Error adding PneumaticCraft Liquid Fuel entry"; - } + public String getErrorMsg() { return "Error adding PneumaticCraft Liquid Fuel entry"; } @Override public void validate(GroovyLog.Msg msg) { @@ -97,8 +97,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(ratio <= 0, "ratio must be greater than 0, yet it was {}", ratio); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable Pair register() { if (!validate()) return null; ModSupport.PNEUMATIC_CRAFT.get().xpFluid.add(fluidInput.get(0), ratio); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/AtomicReshaper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/AtomicReshaper.java index 488d04065..06adb183f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/AtomicReshaper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/AtomicReshaper.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.prodigytech; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,22 +16,15 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import lykrast.prodigytech.common.recipe.AtomicReshaperManager; import lykrast.prodigytech.common.util.Config; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; @RegistryDescription public class AtomicReshaper extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:emerald_block')).primordium(10).time(50)"), - @Example(".input(item('minecraft:gold_block')).output(item('minecraft:diamond_block'), 10).output(item('minecraft:carrot'), 3).primordium(7)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:emerald_block')).primordium(10).time(50)"), + @Example(".input(item('minecraft:gold_block')).output(item('minecraft:diamond_block'), 10).output(item('minecraft:carrot'), 3).primordium(7)")}) public AtomicReshaper.RecipeBuilder recipeBuilder() { return new AtomicReshaper.RecipeBuilder(); } @@ -67,9 +68,7 @@ private boolean backupAndRemove(AtomicReshaperManager.AtomicReshaperRecipe recip } else { removed = AtomicReshaperManager.INSTANCE.removeRecipe(recipe.getInput()); } - if (removed == null) { - return false; - } + if (removed == null) { return false; } addBackup(removed); return true; } @@ -87,8 +86,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(AtomicReshaperManager.INSTANCE.getAllRecipes()) - .setRemover(this::backupAndRemove); + return new SimpleObjectStream<>(AtomicReshaperManager.INSTANCE.getAllRecipes()).setRemover(this::backupAndRemove); } @Property(property = "input", valid = @Comp("1")) @@ -142,9 +140,7 @@ public AtomicReshaper.RecipeBuilder output(ItemStack output, int weight) { } @Override - public String getErrorMsg() { - return "Error adding ProdigyTech Atomic Reshaper Recipe"; - } + public String getErrorMsg() { return "Error adding ProdigyTech Atomic Reshaper Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -154,11 +150,13 @@ public void validate(GroovyLog.Msg msg) { // I think this check is not possible to fail at all but still, adding it for consistency msg.add(output.size() != outputWeights.size(), "Outputs and output weights must be the same size!"); - msg.add(outputWeights.stream().anyMatch(x -> x <= 0), "all weighted outputs must be greater than 0, yet they were {}", outputWeights); + msg.add(outputWeights.stream().anyMatch(x -> x <= 0), "all weighted outputs must be greater than 0, yet they were {}", + outputWeights); msg.add(primordium <= 0, "primordium must be greater than or equal to 1, yet it was {}", primordium); // 100 is hardcoded in the source int capacity = Config.atomicReshaperMaxPrimordium * 100; - msg.add(primordium > capacity, "primordium must be less than or equal to the Reshaper's capacity {}, yet it was {}", capacity, primordium); + msg.add(primordium > capacity, "primordium must be less than or equal to the Reshaper's capacity {}, yet it was {}", + capacity, primordium); msg.add(time <= 0, "time must be greater than 0, got {}", time); } @@ -171,8 +169,7 @@ private Object[] getRecipeOutput() { return target.toArray(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AtomicReshaperManager.AtomicReshaperRecipe register() { if (!validate()) return null; AtomicReshaperManager.AtomicReshaperRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnace.java index 3d866ffe8..f88e45534 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnace.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.prodigytech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,17 +11,14 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import lykrast.prodigytech.common.recipe.ExplosionFurnaceManager; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class ExplosionFurnace extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(ore('ingotGold'), item('minecraft:diamond')).craftPerReagent(8).power(160).output(item('minecraft:emerald_block'))"), - @Example(".input(item('minecraft:stone')).power(160).output(item('minecraft:glowstone'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(ore('ingotGold'), item('minecraft:diamond')).craftPerReagent(8).power(160).output(item('minecraft:emerald_block'))"), + @Example(".input(item('minecraft:stone')).power(160).output(item('minecraft:glowstone'))")}) public ExplosionFurnace.RecipeBuilder recipeBuilder() { return new ExplosionFurnace.RecipeBuilder(); } @@ -62,8 +63,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ExplosionFurnaceManager.RECIPES) - .setRemover(this::backupAndRemove); + return new SimpleObjectStream<>(ExplosionFurnaceManager.RECIPES).setRemover(this::backupAndRemove); } @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) @@ -89,9 +89,7 @@ public ExplosionFurnace.RecipeBuilder power(int power) { } @Override - public String getErrorMsg() { - return "Error adding ProdigyTech Explosion Furnace Recipe"; - } + public String getErrorMsg() { return "Error adding ProdigyTech Explosion Furnace Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -101,8 +99,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(power <= 0, "power should be greater than 0!"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ExplosionFurnaceManager.ExplosionFurnaceRecipe register() { if (!validate()) return null; ExplosionFurnaceManager.ExplosionFurnaceRecipe recipe = null; @@ -116,7 +113,8 @@ public void validate(GroovyLog.Msg msg) { } else { for (ItemStack inp : inputItem.getMatchingStacks()) { for (ItemStack rea : input.get(1).getMatchingStacks()) { - recipe = new ExplosionFurnaceManager.ExplosionFurnaceRecipe(inp, output.get(0), power, rea, craftPerReagent); + recipe = new ExplosionFurnaceManager.ExplosionFurnaceRecipe(inp, output.get(0), power, rea, + craftPerReagent); ModSupport.PRODIGY_TECH.get().explosionFurnace.addRecipe(recipe); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnaceAdditives.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnaceAdditives.java index dd608329a..7ff6f18a8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnaceAdditives.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnaceAdditives.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.prodigytech; +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -8,8 +10,8 @@ import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; + import lykrast.prodigytech.common.recipe.ExplosionFurnaceManager; -import net.minecraft.item.ItemStack; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class ExplosionFurnaceAdditives extends VirtualizedRegistry { @@ -50,8 +52,9 @@ public boolean removeExplosive(IIngredient explosive) { @MethodDescription(example = @Example(priority = 2000, commented = true)) public void removeAllExplosives() { - ExplosionFurnaceManager.EXPLOSIVES.getAllContent().forEach(r -> - addBackup(new EFAdditiveExplosive(new ItemsIngredient(r.getMatchingStacks()), r.getPower()))); + ExplosionFurnaceManager.EXPLOSIVES.getAllContent().forEach(r -> addBackup(new EFAdditiveExplosive(new ItemsIngredient(r + .getMatchingStacks()), + r.getPower()))); ExplosionFurnaceManager.removeAllExplosives(); } @@ -75,8 +78,9 @@ public boolean removeDampener(IIngredient dampener) { @MethodDescription(example = @Example(priority = 2000, commented = true)) public void removeAllDampeners() { - ExplosionFurnaceManager.DAMPENERS.getAllContent().forEach(r -> - addBackup(new EFAdditiveDampener(new ItemsIngredient(r.getMatchingStacks()), r.getDampening()))); + ExplosionFurnaceManager.DAMPENERS.getAllContent().forEach(r -> addBackup(new EFAdditiveDampener(new ItemsIngredient(r + .getMatchingStacks()), + r.getDampening()))); ExplosionFurnaceManager.removeAllDampeners(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/PrimordialisReactor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/PrimordialisReactor.java index 923f57ea0..2dac74e61 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/PrimordialisReactor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/PrimordialisReactor.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.prodigytech; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -8,12 +14,8 @@ import com.cleanroommc.groovyscript.helper.ingredient.ItemsIngredient; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import lykrast.prodigytech.common.recipe.PrimordialisReactorManager; -import net.minecraft.item.ItemStack; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; +import lykrast.prodigytech.common.recipe.PrimordialisReactorManager; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class PrimordialisReactor extends VirtualizedRegistry { @@ -67,10 +69,8 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - Stream normalRecipes = PrimordialisReactorManager.getAllEntries().stream() - .map(ItemsIngredient::new); - Stream oreDictRecipes = PrimordialisReactorManager.getAllOreEntries().stream() - .map(OreDictIngredient::new); + Stream normalRecipes = PrimordialisReactorManager.getAllEntries().stream().map(ItemsIngredient::new); + Stream oreDictRecipes = PrimordialisReactorManager.getAllOreEntries().stream().map(OreDictIngredient::new); List items = Stream.concat(normalRecipes, oreDictRecipes).collect(Collectors.toList()); return new SimpleObjectStream<>(items).setRemover(this::remove); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandler.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandler.java index b8f4826e7..3e6076263 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandler.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandler.java @@ -1,24 +1,25 @@ package com.cleanroommc.groovyscript.compat.mods.prodigytech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import lykrast.prodigytech.common.recipe.MagneticReassemblerManager; import lykrast.prodigytech.common.recipe.RotaryGrinderManager; import lykrast.prodigytech.common.recipe.SimpleRecipe; import lykrast.prodigytech.common.recipe.SimpleRecipeManager; import lykrast.prodigytech.common.util.Config; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; public abstract class SimpleRecipeHandler extends SimpleRecipeHandlerAbstract { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).time(50)"), - @Example(".input(item('minecraft:iron_ingot')).output(item('minecraft:coal'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).time(50)"), + @Example(".input(item('minecraft:iron_ingot')).output(item('minecraft:coal'))")}) public SimpleRecipeHandler.RecipeBuilder recipeBuilder() { return new SimpleRecipeHandler.RecipeBuilder(); } @@ -27,11 +28,11 @@ public SimpleRecipeHandler.RecipeBuilder recipeBuilder() { super(name, instance); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { - @Property(valid = @Comp(value = "1", type = Comp.Type.GTE), defaultValue = "(default time for this machine in the mod's config)") + @Property(valid = @Comp(value = "1", type = Comp.Type.GTE), + defaultValue = "(default time for this machine in the mod's config)") private int time = getDefaultTime(); @RecipeBuilderMethodDescription @@ -48,12 +49,9 @@ public void validate(GroovyLog.Msg msg) { } @Override - public String getErrorMsg() { - return String.format("Error adding ProdigyTech %s Recipe", SimpleRecipeHandler.this.name); - } + public String getErrorMsg() { return String.format("Error adding ProdigyTech %s Recipe", SimpleRecipeHandler.this.name); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SimpleRecipe register() { if (!validate()) return null; SimpleRecipe recipe = null; @@ -79,12 +77,9 @@ public static class RotaryGrinder extends SimpleRecipeHandler { } @Override - protected int getDefaultTime() { - return Config.rotaryGrinderProcessTime; - } + protected int getDefaultTime() { return Config.rotaryGrinderProcessTime; } - @Override - @MethodDescription(example = @Example("item('minecraft:gravel')")) + @Override @MethodDescription(example = @Example("item('minecraft:gravel')")) public boolean removeByInput(IIngredient input) { return super.removeByInput(input); } @@ -98,12 +93,9 @@ public static class MagneticReassembler extends SimpleRecipeHandler { } @Override - protected int getDefaultTime() { - return Config.magneticReassemblerProcessTime; - } + protected int getDefaultTime() { return Config.magneticReassemblerProcessTime; } - @Override - @MethodDescription(example = @Example("item('minecraft:gravel')")) + @Override @MethodDescription(example = @Example("item('minecraft:gravel')")) public boolean removeByInput(IIngredient input) { return super.removeByInput(input); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandlerAbstract.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandlerAbstract.java index 8120fd786..5f82da4e8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandlerAbstract.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandlerAbstract.java @@ -1,15 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.prodigytech; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import lykrast.prodigytech.common.recipe.SimpleRecipe; import lykrast.prodigytech.common.recipe.SimpleRecipeManagerAbstract; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; public abstract class SimpleRecipeHandlerAbstract extends VirtualizedRegistry { @@ -84,16 +86,13 @@ private boolean backupAndRemove(T recipe) { } else { removed = instance.removeRecipe(recipe.getInput()); } - if (removed == null) { - return false; - } + if (removed == null) { return false; } addBackup(removed); return true; } @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(instance.getAllRecipes()) - .setRemover(this::backupAndRemove); + return new SimpleObjectStream<>(instance.getAllRecipes()).setRemover(this::backupAndRemove); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandlerSecondaryOutput.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandlerSecondaryOutput.java index 24277a811..7e0094e6a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandlerSecondaryOutput.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/SimpleRecipeHandlerSecondaryOutput.java @@ -1,23 +1,24 @@ package com.cleanroommc.groovyscript.compat.mods.prodigytech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; + import lykrast.prodigytech.common.recipe.*; import lykrast.prodigytech.common.util.Config; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; public abstract class SimpleRecipeHandlerSecondaryOutput extends SimpleRecipeHandlerAbstract { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).time(50)"), - @Example(".input(item('minecraft:iron_ingot')).output(item('minecraft:coal'))"), - @Example(".input(item('minecraft:iron_block')).output(item('minecraft:emerald'), item('minecraft:clay'))"), - @Example(".input(item('minecraft:gold_block')).output(item('minecraft:emerald'), item('minecraft:nether_star')).secondaryChance(0.25).time(50)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).time(50)"), + @Example(".input(item('minecraft:iron_ingot')).output(item('minecraft:coal'))"), + @Example(".input(item('minecraft:iron_block')).output(item('minecraft:emerald'), item('minecraft:clay'))"), + @Example(".input(item('minecraft:gold_block')).output(item('minecraft:emerald'), item('minecraft:nether_star')).secondaryChance(0.25).time(50)")}) public SimpleRecipeHandlerSecondaryOutput.RecipeBuilder recipeBuilder() { return new SimpleRecipeHandlerSecondaryOutput.RecipeBuilder(); } @@ -53,7 +54,8 @@ public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 2); validateFluids(msg); msg.add(time <= 0, "time must be greater than 0, got {}", time); - msg.add(secondaryChance > 1.0f || secondaryChance < 0.0f, "secondary output has to be between 0 and 1, got {}", secondaryChance); + msg.add(secondaryChance > 1.0f || secondaryChance < 0.0f, "secondary output has to be between 0 and 1, got {}", + secondaryChance); } @Override @@ -61,15 +63,15 @@ public String getErrorMsg() { return String.format("Error adding ProdigyTech %s Recipe", SimpleRecipeHandlerSecondaryOutput.this.name); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SimpleRecipeSecondaryOutput register() { if (!validate()) return null; SimpleRecipeSecondaryOutput recipe = null; IIngredient input1 = input.get(0); ItemStack secondaryOutput = output.size() == 1 ? ItemStack.EMPTY : output.get(1); if (input1 instanceof OreDictIngredient) { - recipe = new SimpleRecipeSecondaryOutput(((OreDictIngredient) input1).getOreDict(), output.get(0), secondaryOutput, time, secondaryChance); + recipe = new SimpleRecipeSecondaryOutput(((OreDictIngredient) input1).getOreDict(), output.get(0), + secondaryOutput, time, secondaryChance); addRecipe(recipe); } else { for (ItemStack input : input1.getMatchingStacks()) { @@ -89,12 +91,9 @@ public static class HeatSawmill extends SimpleRecipeHandlerSecondaryOutput { } @Override - protected int getDefaultTime() { - return Config.heatSawmillProcessTime; - } + protected int getDefaultTime() { return Config.heatSawmillProcessTime; } - @Override - @MethodDescription(example = @Example("ore('plankWood')")) + @Override @MethodDescription(example = @Example("ore('plankWood')")) public boolean removeByInput(IIngredient input) { return super.removeByInput(input); } @@ -108,12 +107,9 @@ public static class OreRefinery extends SimpleRecipeHandlerSecondaryOutput { } @Override - protected int getDefaultTime() { - return Config.oreRefineryProcessTime; - } + protected int getDefaultTime() { return Config.oreRefineryProcessTime; } - @Override - @MethodDescription(example = @Example("ore('oreLapis')")) + @Override @MethodDescription(example = @Example("ore('oreLapis')")) public boolean removeByInput(IIngredient input) { return super.removeByInput(input); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/Solderer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/Solderer.java index 5610f3a1c..4da3db806 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/Solderer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/Solderer.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.prodigytech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,18 +12,15 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import lykrast.prodigytech.common.recipe.SoldererManager; import lykrast.prodigytech.common.util.Config; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Solderer extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".pattern(item('minecraft:clay')).input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).gold(5).time(100)"), - @Example(".pattern(item('minecraft:coal_block')).output(item('minecraft:nether_star')).gold(75)"), - }) + @RecipeBuilderDescription(example = {@Example(".pattern(item('minecraft:clay')).input(item('minecraft:gold_ingot')).output(item('minecraft:diamond')).gold(5).time(100)"), + @Example(".pattern(item('minecraft:coal_block')).output(item('minecraft:nether_star')).gold(75)"),}) public Solderer.RecipeBuilder recipeBuilder() { return new Solderer.RecipeBuilder(); } @@ -92,8 +93,7 @@ public void removeWithoutAdditive() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SoldererManager.RECIPES) - .setRemover(this::remove); + return new SimpleObjectStream<>(SoldererManager.RECIPES).setRemover(this::remove); } @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) @@ -128,9 +128,7 @@ public Solderer.RecipeBuilder pattern(IIngredient pattern) { } @Override - public String getErrorMsg() { - return "Error adding ProdigyTech Solderer Recipe"; - } + public String getErrorMsg() { return "Error adding ProdigyTech Solderer Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -139,23 +137,27 @@ public void validate(GroovyLog.Msg msg) { msg.add(gold <= 0, "gold must be greater than or equal to 1, yet it was {}", gold); msg.add(IngredientHelper.isEmpty(pattern), "pattern cannot be empty"); int capacity = Config.soldererMaxGold; - msg.add(gold > capacity, "gold must be less than or equal to the Solderer's capacity {}, yet it was {}", capacity, gold); + msg.add(gold > capacity, "gold must be less than or equal to the Solderer's capacity {}, yet it was {}", capacity, + gold); msg.add(time <= 0, "time must be greater than 0, got {}", time); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SoldererManager.SoldererRecipe register() { if (!validate()) return null; SoldererManager.SoldererRecipe recipe = null; for (ItemStack pat : pattern.getMatchingStacks()) { if (input.isEmpty()) { - SoldererManager.SoldererRecipe theRecipe = new SoldererManager.SoldererRecipe(pat, ItemStack.EMPTY, output.get(0), gold, time); + SoldererManager.SoldererRecipe theRecipe = new SoldererManager.SoldererRecipe(pat, ItemStack.EMPTY, output + .get(0), + gold, time); ModSupport.PRODIGY_TECH.get().solderer.add(theRecipe); if (recipe == null) recipe = theRecipe; } else { for (ItemStack additive : input.get(0).getMatchingStacks()) { - SoldererManager.SoldererRecipe theRecipe = new SoldererManager.SoldererRecipe(pat, additive, output.get(0), gold, time); + SoldererManager.SoldererRecipe theRecipe = new SoldererManager.SoldererRecipe(pat, additive, output.get( + 0), + gold, time); ModSupport.PRODIGY_TECH.get().solderer.add(theRecipe); if (recipe == null) recipe = theRecipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ZorraAltar.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ZorraAltar.java index e466df44a..9c610a126 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ZorraAltar.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ZorraAltar.java @@ -1,17 +1,19 @@ package com.cleanroommc.groovyscript.compat.mods.prodigytech; +import java.util.Map; + +import net.minecraft.enchantment.Enchantment; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; + import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import lykrast.prodigytech.common.recipe.ZorraAltarManager; import lykrast.prodigytech.common.util.Config; -import net.minecraft.enchantment.Enchantment; - -import java.util.Map; @RegistryDescription @@ -51,10 +53,8 @@ private void removeEnchantment(ZorraRecipeData recipe) { managers.get(recipe.registry).removeEnchant(recipe.enchantment); } - @MethodDescription(example = { - @Example("'sword', enchantment('minecraft:power'), 10"), - @Example("'stick', enchantment('minecraft:knockback'), 20") - }) + @MethodDescription(example = {@Example("'sword', enchantment('minecraft:power'), 10"), + @Example("'stick', enchantment('minecraft:knockback'), 20")}) public void addEnchantment(String registry, Enchantment enchantment, int maxLevel) { if (!managers.containsKey(registry)) return; managers.get(registry).addEnchant(enchantment, maxLevel); @@ -65,8 +65,7 @@ public void addEnchantment(String registry, Enchantment enchantment, int maxLeve public boolean removeEnchantment(String registry, Enchantment enchantment) { if (!managers.containsKey(registry)) return false; int maxLevel = enchantment.getMaxLevel(); - if (maxLevel > 1) - maxLevel += Config.altarBonusLvl; + if (maxLevel > 1) maxLevel += Config.altarBonusLvl; addBackup(new ZorraRecipeData(registry, enchantment, maxLevel)); return managers.get(registry).removeEnchant(enchantment); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/EntityRandomizer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/EntityRandomizer.java index 7eb754768..77929b024 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/EntityRandomizer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/EntityRandomizer.java @@ -1,5 +1,8 @@ package com.cleanroommc.groovyscript.compat.mods.projecte; +import net.minecraft.entity.EntityLiving; +import net.minecraftforge.fml.common.registry.EntityEntry; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -8,16 +11,13 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.entity.EntityLiving; -import net.minecraftforge.fml.common.registry.EntityEntry; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class EntityRandomizer extends VirtualizedRegistry> { private final AbstractReloadableStorage> peacefulStorage = new AbstractReloadableStorage<>(); - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { WorldHelperAccessor.getMobs().removeAll(removeScripted()); WorldHelperAccessor.getMobs().addAll(restoreFromBackup()); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/Transmutation.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/Transmutation.java index ecc968631..5d5f42baa 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/Transmutation.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/Transmutation.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.projecte; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,26 +13,20 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import moze_intel.projecte.utils.WorldTransmutations; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Transmutation extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(blockstate('minecraft:end_stone')).output(blockstate('minecraft:diamond_block'), blockstate('minecraft:gold_block'))"), - @Example(".input(blockstate('minecraft:diamond_block')).output(blockstate('minecraft:end_stone')).altOutput(blockstate('minecraft:gold_block'))"), - @Example(".input(blockstate('minecraft:gold_block')).output(blockstate('minecraft:diamond_block'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(blockstate('minecraft:end_stone')).output(blockstate('minecraft:diamond_block'), blockstate('minecraft:gold_block'))"), + @Example(".input(blockstate('minecraft:diamond_block')).output(blockstate('minecraft:end_stone')).altOutput(blockstate('minecraft:gold_block'))"), + @Example(".input(blockstate('minecraft:gold_block')).output(blockstate('minecraft:diamond_block'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { WorldTransmutations.getWorldTransmutations().removeAll(removeScripted()); WorldTransmutations.getWorldTransmutations().addAll(restoreFromBackup()); @@ -138,9 +138,7 @@ public RecipeBuilder output(Block output, Block altOutput) { } @Override - public String getErrorMsg() { - return "Error adding ProjectE Transmutation recipe"; - } + public String getErrorMsg() { return "Error adding ProjectE Transmutation recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -150,8 +148,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(output == null, "output must not be null"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable WorldTransmutations.Entry register() { if (!validate()) return null; WorldTransmutations.Entry recipe = new WorldTransmutations.Entry(input, ImmutablePair.of(output, altOutput)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Anvil.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Anvil.java index ee7973268..456b595db 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Anvil.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Anvil.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,10 +15,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.AnvilRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; @RegistryDescription public class Anvil extends ForgeRegistryWrapper { @@ -21,43 +23,37 @@ public Anvil() { super(ModuleTechBasic.Registries.ANVIL_RECIPE); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond') * 4).output(item('minecraft:emerald') * 2).hits(5).typeHammer().tierGranite().name('diamond_to_emerald_granite_anvil')"), - @Example(".input(item('minecraft:diamond') * 8).output(item('minecraft:nether_star') * 1).hits(10).typePickaxe().tierIronclad().name('diamond_to_nether_star_ironclad_anvil')"), - @Example(".input(item('minecraft:diamond') * 4).output(item('minecraft:gold_ingot') * 16).hits(5).typePickaxe().tierObsidian().name('diamond_to_gold_obsidian_anvil')") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond') * 4).output(item('minecraft:emerald') * 2).hits(5).typeHammer().tierGranite().name('diamond_to_emerald_granite_anvil')"), + @Example(".input(item('minecraft:diamond') * 8).output(item('minecraft:nether_star') * 1).hits(10).typePickaxe().tierIronclad().name('diamond_to_nether_star_ironclad_anvil')"), + @Example(".input(item('minecraft:diamond') * 4).output(item('minecraft:gold_ingot') * 16).hits(5).typePickaxe().tierObsidian().name('diamond_to_gold_obsidian_anvil')")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'iron_to_clay', ore('ingotIron') * 5, item('minecraft:clay_ball') * 20, 9, 'granite', 'hammer'")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'iron_to_clay', ore('ingotIron') * 5, item('minecraft:clay_ball') * 20, 9, 'granite', 'hammer'")) public AnvilRecipe add(String name, IIngredient input, ItemStack output, int hits, String tier, String type) { AnvilRecipe.EnumTier enumTier = EnumHelper.valueOfNullable(AnvilRecipe.EnumTier.class, tier, false); AnvilRecipe.EnumType enumType = EnumHelper.valueOfNullable(AnvilRecipe.EnumType.class, type, false); if (enumTier == null || enumType == null) { - GroovyLog.msg("Error adding pyrotech anvil recipe") - .add(enumTier == null, "tier with name {} does not exist. Valid values are {}.", tier, Arrays.toString(AnvilRecipe.EnumTier.values())) - .add(enumTier == null, "type with name {} does not exist. Valid values are {}.", tier, Arrays.toString(AnvilRecipe.EnumType.values())) - .error() - .post(); + GroovyLog.msg("Error adding pyrotech anvil recipe").add(enumTier == null, + "tier with name {} does not exist. Valid values are {}.", + tier, Arrays.toString(AnvilRecipe.EnumTier.values())).add( + enumTier == null, + "type with name {} does not exist. Valid values are {}.", + tier, + Arrays.toString(AnvilRecipe.EnumType.values())) + .error().post(); return null; } - return recipeBuilder() - .hits(hits) - .tier(enumTier) - .type(enumType) - .name(name) - .input(input) - .output(output) - .register(); + return recipeBuilder().hits(hits).tier(enumTier).type(enumType).name(name).input(input).output(output).register(); } @MethodDescription(example = @Example("item('minecraft:stone_slab', 3)")) public void removeByOutput(ItemStack output) { - if (GroovyLog.msg("Error removing pyrotech anvil recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing pyrotech anvil recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error() + .postIfNotEmpty()) { return; } for (AnvilRecipe recipe : getRegistry()) { @@ -126,9 +122,7 @@ public RecipeBuilder tierObsidian() { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Anvil Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Anvil Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -137,15 +131,16 @@ public void validate(GroovyLog.Msg msg) { msg.add(type == null, "type cannot be null. "); msg.add(tier == null, "tier cannot be null."); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.ANVIL_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.ANVIL_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AnvilRecipe register() { if (!validate()) return null; - AnvilRecipe recipe = new AnvilRecipe(output.get(0), input.get(0).toMcIngredient(), hits, type, tier).setRegistryName(super.name); + AnvilRecipe recipe = new AnvilRecipe(output.get(0), input.get(0).toMcIngredient(), hits, type, tier).setRegistryName( + super.name); PyroTech.anvil.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Barrel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Barrel.java index 8f8a65cd1..5db462989 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Barrel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Barrel.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import net.minecraft.item.crafting.Ingredient; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,9 +13,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.BarrelRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Barrel extends ForgeRegistryWrapper { @@ -19,30 +21,24 @@ public Barrel() { super(ModuleTechBasic.Registries.BARREL_RECIPE); } - @RecipeBuilderDescription(example = @Example( - ".input(item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:emerald')).fluidInput(fluid('water') * 1000).fluidOutput(fluid('amongium') * 1000).duration(1000).name('diamond_emerald_and_water_to_amongium')") - ) + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:diamond'), item('minecraft:emerald')).fluidInput(fluid('water') * 1000).fluidOutput(fluid('amongium') * 1000).duration(1000).name('diamond_emerald_and_water_to_amongium')")) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'iron_dirt_water_to_lava', ore('ingotIron'), ore('ingotIron'), item('minecraft:dirt'), item('minecraft:dirt'), fluid('water'), fluid('lava'), 1000")) - public BarrelRecipe add(String name, IIngredient input1, IIngredient input2, IIngredient input3, IIngredient input4, FluidStack fInput, FluidStack fOutput, int duration) { - return recipeBuilder() - .duration(duration) - .name(name) - .input(input1, input2, input3, input4) - .fluidInput(fInput) - .fluidOutput(fOutput) - .register(); + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'iron_dirt_water_to_lava', ore('ingotIron'), ore('ingotIron'), item('minecraft:dirt'), item('minecraft:dirt'), fluid('water'), fluid('lava'), 1000")) + public BarrelRecipe add(String name, IIngredient input1, IIngredient input2, IIngredient input3, IIngredient input4, + FluidStack fInput, FluidStack fOutput, int duration) { + return recipeBuilder().duration(duration).name(name).input(input1, input2, input3, input4).fluidInput(fInput).fluidOutput( + fOutput) + .register(); } @MethodDescription(example = @Example("fluid('freckleberry_wine') * 1000")) public void removeByOutput(FluidStack output) { - if (GroovyLog.msg("Error removing barrel recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing barrel recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error().postIfNotEmpty()) { return; } for (BarrelRecipe recipe : getRegistry()) { @@ -68,9 +64,7 @@ public RecipeBuilder duration(int time) { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Barrel Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Barrel Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -78,18 +72,19 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 1, 1, 1, 1); msg.add(duration < 0, "duration must be a non negative integer, yet it was {}", duration); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.BARREL_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.BARREL_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable BarrelRecipe register() { if (!validate()) return null; // Because you need Ingredient[] to register a recipe Ingredient[] inputIngredient = input.stream().map(IIngredient::toMcIngredient).toArray(Ingredient[]::new); - BarrelRecipe recipe = new BarrelRecipe(fluidOutput.get(0), inputIngredient, fluidInput.get(0), duration).setRegistryName(super.name); + BarrelRecipe recipe = new BarrelRecipe(fluidOutput.get(0), inputIngredient, fluidInput.get(0), duration) + .setRegistryName(super.name); PyroTech.barrel.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Campfire.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Campfire.java index 450fc7cb6..faedf1825 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Campfire.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Campfire.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,8 +12,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.CampfireRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Campfire extends ForgeRegistryWrapper { @@ -23,22 +25,16 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'apple_to_dirt', item('minecraft:apple'), item('minecraft:dirt'), 1000")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'apple_to_dirt', item('minecraft:apple'), item('minecraft:dirt'), 1000")) public CampfireRecipe add(String name, IIngredient input, ItemStack output, int duration) { - return recipeBuilder() - .duration(duration) - .name(name) - .input(input) - .output(output) - .register(); + return recipeBuilder().duration(duration).name(name).input(input).output(output).register(); } @MethodDescription(example = @Example("item('minecraft:porkchop')")) public void removeByInput(ItemStack input) { - if (GroovyLog.msg("Error removing campfire recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing campfire recipe").add(IngredientHelper.isEmpty(input), + () -> "Input 1 must not be empty").error().postIfNotEmpty()) { return; } for (CampfireRecipe recipe : getRegistry()) { @@ -50,10 +46,8 @@ public void removeByInput(ItemStack input) { @MethodDescription(example = @Example("item('minecraft:cooked_porkchop')")) public void removeByOutput(IIngredient output) { - if (GroovyLog.msg("Error removing campfire recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing campfire recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error().postIfNotEmpty()) { return; } for (CampfireRecipe recipe : getRegistry()) { @@ -78,23 +72,22 @@ public RecipeBuilder duration(int time) { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Campfire Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Campfire Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); msg.add(duration < 0, "duration must be a non negative integer, yet it was {}", duration); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.CAMPFIRE_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.CAMPFIRE_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable CampfireRecipe register() { if (!validate()) return null; - CampfireRecipe recipe = new CampfireRecipe(output.get(0), input.get(0).toMcIngredient(), duration).setRegistryName(super.name); + CampfireRecipe recipe = new CampfireRecipe(output.get(0), input.get(0).toMcIngredient(), duration).setRegistryName( + super.name); PyroTech.campfire.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/ChoppingBlock.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/ChoppingBlock.java index 4cedd4bdd..e9a925e92 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/ChoppingBlock.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/ChoppingBlock.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,10 +12,9 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.ChoppingBlockRecipe; + import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class ChoppingBlock extends ForgeRegistryWrapper { @@ -28,10 +31,9 @@ public RecipeBuilder recipeBuilder() { @MethodDescription(example = @Example("item('minecraft:log2')")) public void removeByInput(ItemStack input) { - if (GroovyLog.msg("Error removing chopping block recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing chopping block recipe").add(IngredientHelper.isEmpty(input), + () -> "Input 1 must not be empty").error() + .postIfNotEmpty()) { return; } for (ChoppingBlockRecipe recipe : getRegistry()) { @@ -43,10 +45,9 @@ public void removeByInput(ItemStack input) { @MethodDescription(example = @Example("item('minecraft:planks', 4)")) public void removeByOutput(IIngredient output) { - if (GroovyLog.msg("Error removing chopping block recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing chopping block recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error() + .postIfNotEmpty()) { return; } for (ChoppingBlockRecipe recipe : getRegistry()) { @@ -74,23 +75,22 @@ public RecipeBuilder chops(int chops, int quantities) { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Chopping Block Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Chopping Block Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); msg.add(quantities.isEmpty(), "cops and quantities must be a non negative integer, yet it was {}", quantities.size()); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.CHOPPING_BLOCK_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.CHOPPING_BLOCK_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable ChoppingBlockRecipe register() { if (!validate()) return null; - ChoppingBlockRecipe recipe = new ChoppingBlockRecipe(output.get(0), input.get(0).toMcIngredient(), chops.toIntArray(), quantities.toIntArray()).setRegistryName(super.name); + ChoppingBlockRecipe recipe = new ChoppingBlockRecipe(output.get(0), input.get(0).toMcIngredient(), chops.toIntArray(), + quantities.toIntArray()).setRegistryName(super.name); PyroTech.choppingBlock.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CompactingBin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CompactingBin.java index dfc96b042..ae5cd42c7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CompactingBin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CompactingBin.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,8 +12,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.CompactingBinRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class CompactingBin extends ForgeRegistryWrapper { @@ -24,22 +26,17 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'iron_to_clay', ore('ingotIron') * 5, item('minecraft:clay_ball') * 20, 9")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'iron_to_clay', ore('ingotIron') * 5, item('minecraft:clay_ball') * 20, 9")) public CompactingBinRecipe add(String name, IIngredient input, ItemStack output, int hits) { - return recipeBuilder() - .toolUses(hits) - .name(name) - .input(input) - .output(output) - .register(); + return recipeBuilder().toolUses(hits).name(name).input(input).output(output).register(); } @MethodDescription(example = @Example("item('minecraft:snowball')")) public void removeByInput(ItemStack input) { - if (GroovyLog.msg("Error removing compacting bin recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing compacting bin recipe").add(IngredientHelper.isEmpty(input), + () -> "Input 1 must not be empty").error() + .postIfNotEmpty()) { return; } for (CompactingBinRecipe recipe : getRegistry()) { @@ -51,10 +48,9 @@ public void removeByInput(ItemStack input) { @MethodDescription(example = @Example("item('minecraft:bone_block')")) public void removeByOutput(IIngredient output) { - if (GroovyLog.msg("Error removing compacting bin recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing compacting bin recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error() + .postIfNotEmpty()) { return; } for (CompactingBinRecipe recipe : getRegistry()) { @@ -79,23 +75,22 @@ public RecipeBuilder toolUses(int toolUses) { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Compacting Bin Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Compacting Bin Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); msg.add(toolUses < 0, "toolUses must be a non negative integer, yet it was {}", toolUses); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.COMPACTING_BIN_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.COMPACTING_BIN_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable CompactingBinRecipe register() { if (!validate()) return null; - CompactingBinRecipe recipe = new CompactingBinRecipe(output.get(0), input.get(0).toMcIngredient(), toolUses).setRegistryName(super.name); + CompactingBinRecipe recipe = new CompactingBinRecipe(output.get(0), input.get(0).toMcIngredient(), toolUses) + .setRegistryName(super.name); PyroTech.compactingBin.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CompostBin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CompostBin.java index 479cc181b..33aa9e823 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CompostBin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CompostBin.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,9 +13,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.CompostBinRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class CompostBin extends ForgeRegistryWrapper { @@ -25,22 +27,16 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'iron_to_clay2', ore('ingotIron') * 5, item('minecraft:clay_ball') * 20, 2")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'iron_to_clay2', ore('ingotIron') * 5, item('minecraft:clay_ball') * 20, 2")) public CompostBinRecipe add(String name, IIngredient input, ItemStack output, int compostValue) { - return recipeBuilder() - .compostValue(compostValue) - .name(name) - .input(input) - .output(output) - .register(); + return recipeBuilder().compostValue(compostValue).name(name).input(input).output(output).register(); } @MethodDescription(example = @Example("item('minecraft:golden_carrot')")) public void removeByInput(ItemStack input) { - if (GroovyLog.msg("Error removing compost bin recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing compost bin recipe").add(IngredientHelper.isEmpty(input), + () -> "Input 1 must not be empty").error().postIfNotEmpty()) { return; } for (CompostBinRecipe recipe : getRegistry()) { @@ -52,10 +48,8 @@ public void removeByInput(ItemStack input) { @MethodDescription public void removeByOutput(IIngredient output) { - if (GroovyLog.msg("Error removing compost bin recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing compost bin recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error().postIfNotEmpty()) { return; } for (CompostBinRecipe recipe : getRegistry()) { @@ -80,20 +74,18 @@ public RecipeBuilder compostValue(int compostValue) { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Compost Bin Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Compost Bin Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); msg.add(compostValue < 0, "compostValue must be a non negative integer, yet it was {}", compostValue); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.COMPACTING_BIN_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.COMPACTING_BIN_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable CompostBinRecipe register() { if (!validate()) return null; ItemStack[] in = input.get(0).getMatchingStacks(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CrudeDryingRack.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CrudeDryingRack.java index 207a5b06b..9569f8ab4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CrudeDryingRack.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/CrudeDryingRack.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,8 +12,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.CrudeDryingRackRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class CrudeDryingRack extends ForgeRegistryWrapper { @@ -24,22 +26,17 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'apple_to_dirt', item('minecraft:apple'), item('minecraft:dirt'), 1200")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'apple_to_dirt', item('minecraft:apple'), item('minecraft:dirt'), 1200")) public CrudeDryingRackRecipe add(String name, IIngredient input, ItemStack output, int dryTime) { - return recipeBuilder() - .dryTime(dryTime) - .name(name) - .input(input) - .output(output) - .register(); + return recipeBuilder().dryTime(dryTime).name(name).input(input).output(output).register(); } @MethodDescription(example = @Example("item('minecraft:wheat')")) public void removeByInput(ItemStack input) { - if (GroovyLog.msg("Error removing crude drying rack recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing crude drying rack recipe").add(IngredientHelper.isEmpty(input), + () -> "Input 1 must not be empty").error() + .postIfNotEmpty()) { return; } for (CrudeDryingRackRecipe recipe : getRegistry()) { @@ -51,10 +48,9 @@ public void removeByInput(ItemStack input) { @MethodDescription public void removeByOutput(IIngredient output) { - if (GroovyLog.msg("Error removing crude drying rack recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing crude drying rack recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error() + .postIfNotEmpty()) { return; } for (CrudeDryingRackRecipe recipe : getRegistry()) { @@ -79,23 +75,22 @@ public RecipeBuilder dryTime(int time) { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Crude Drying Rack Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Crude Drying Rack Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); msg.add(dryTime < 0, "dryTime must be a non negative integer, yet it was {}", dryTime); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.CRUDE_DRYING_RACK_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.CRUDE_DRYING_RACK_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable CrudeDryingRackRecipe register() { if (!validate()) return null; - CrudeDryingRackRecipe recipe = new CrudeDryingRackRecipe(output.get(0), input.get(0).toMcIngredient(), dryTime).setRegistryName(super.name); + CrudeDryingRackRecipe recipe = new CrudeDryingRackRecipe(output.get(0), input.get(0).toMcIngredient(), dryTime) + .setRegistryName(super.name); PyroTech.crudeDryingRack.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/DryingRack.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/DryingRack.java index a765613cd..b5f781a77 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/DryingRack.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/DryingRack.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,8 +12,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.DryingRackRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class DryingRack extends ForgeRegistryWrapper { @@ -24,22 +26,16 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'apple_to_dirt', item('minecraft:apple'), item('minecraft:dirt'), 1200")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'apple_to_dirt', item('minecraft:apple'), item('minecraft:dirt'), 1200")) public DryingRackRecipe add(String name, IIngredient input, ItemStack output, int dryTime) { - return recipeBuilder() - .dryTime(dryTime) - .name(name) - .input(input) - .output(output) - .register(); + return recipeBuilder().dryTime(dryTime).name(name).input(input).output(output).register(); } @MethodDescription(example = @Example("item('minecraft:wheat')")) public void removeByInput(ItemStack input) { - if (GroovyLog.msg("Error removing drying rack recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing drying rack recipe").add(IngredientHelper.isEmpty(input), + () -> "Input 1 must not be empty").error().postIfNotEmpty()) { return; } for (DryingRackRecipe recipe : getRegistry()) { @@ -51,10 +47,8 @@ public void removeByInput(ItemStack input) { @MethodDescription public void removeByOutput(IIngredient output) { - if (GroovyLog.msg("Error removing drying rack recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing drying rack recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error().postIfNotEmpty()) { return; } for (DryingRackRecipe recipe : getRegistry()) { @@ -79,23 +73,22 @@ public RecipeBuilder dryTime(int time) { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Drying Rack Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Drying Rack Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); msg.add(dryTime < 0, "dryTime must be a non negative integer, yet it was {}", dryTime); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.DRYING_RACK_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.DRYING_RACK_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable DryingRackRecipe register() { if (!validate()) return null; - DryingRackRecipe recipe = new DryingRackRecipe(output.get(0), input.get(0).toMcIngredient(), dryTime).setRegistryName(super.name); + DryingRackRecipe recipe = new DryingRackRecipe(output.get(0), input.get(0).toMcIngredient(), dryTime).setRegistryName( + super.name); PyroTech.dryingRack.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Kiln.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Kiln.java index 6fe0e7586..3803536eb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Kiln.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/Kiln.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,8 +13,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.KilnPitRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class Kiln extends ForgeRegistryWrapper { @@ -24,24 +26,19 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'clay_to_iron', item('minecraft:clay_ball') * 5, item('minecraft:iron_ingot'), 1200, 0.5f, [item('minecraft:dirt'), item('minecraft:cobblestone')]")) - public KilnPitRecipe add(String name, IIngredient input, ItemStack output, int burnTime, float failureChance, Iterable failureOutput) { - return recipeBuilder() - .burnTime(burnTime) - .failureChance(failureChance) - .failureOutput(failureOutput) - .name(name) - .input(input) - .output(output) - .register(); + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'clay_to_iron', item('minecraft:clay_ball') * 5, item('minecraft:iron_ingot'), 1200, 0.5f, [item('minecraft:dirt'), item('minecraft:cobblestone')]")) + public KilnPitRecipe add(String name, IIngredient input, ItemStack output, int burnTime, float failureChance, + Iterable failureOutput) { + return recipeBuilder().burnTime(burnTime).failureChance(failureChance).failureOutput(failureOutput).name(name).input( + input) + .output(output).register(); } @MethodDescription public void removeByInput(ItemStack input) { - if (GroovyLog.msg("Error removing pit kiln recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing pit kiln recipe").add(IngredientHelper.isEmpty(input), + () -> "Input 1 must not be empty").error().postIfNotEmpty()) { return; } for (KilnPitRecipe recipe : getRegistry()) { @@ -53,10 +50,8 @@ public void removeByInput(ItemStack input) { @MethodDescription(example = @Example("item('pyrotech:bucket_clay')")) public void removeByOutput(IIngredient output) { - if (GroovyLog.msg("Error removing pit kiln recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing pit kiln recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error().postIfNotEmpty()) { return; } for (KilnPitRecipe recipe : getRegistry()) { @@ -111,9 +106,7 @@ public RecipeBuilder failureOutput(Iterable failureOutputs) { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Pit Kiln Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Pit Kiln Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -123,14 +116,15 @@ public void validate(GroovyLog.Msg msg) { msg.add(burnTime < 0, "burnTime must be a non negative integer, yet it was {}", burnTime); msg.add(failureChance < 0, "failureChance must be a non negative float, yet it was {}", failureChance); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.KILN_PIT_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.KILN_PIT_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } - @RecipeBuilderRegistrationMethod - @Override + @RecipeBuilderRegistrationMethod @Override public @Nullable KilnPitRecipe register() { if (!validate()) return null; - KilnPitRecipe recipe = new KilnPitRecipe(output.get(0), input.get(0).toMcIngredient(), burnTime, failureChance, failureOutput.toArray(new ItemStack[0])).setRegistryName(super.name); + KilnPitRecipe recipe = new KilnPitRecipe(output.get(0), input.get(0).toMcIngredient(), burnTime, failureChance, + failureOutput.toArray(new ItemStack[0])).setRegistryName(super.name); PyroTech.kiln.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/SoakingPot.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/SoakingPot.java index 2624a6eb0..3bed42d0a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/SoakingPot.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/SoakingPot.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,9 +13,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.SoakingPotRecipe; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class SoakingPot extends ForgeRegistryWrapper { @@ -24,23 +26,16 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'dirt_to_apple', item('minecraft:dirt'), fluid('water'), item('minecraft:apple'), 1200")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'dirt_to_apple', item('minecraft:dirt'), fluid('water'), item('minecraft:apple'), 1200")) public SoakingPotRecipe add(String name, IIngredient input, FluidStack fluidInput, ItemStack output, int time) { - return recipeBuilder() - .time(time) - .name(name) - .input(input) - .fluidInput(fluidInput) - .output(output) - .register(); + return recipeBuilder().time(time).name(name).input(input).fluidInput(fluidInput).output(output).register(); } @MethodDescription public void removeByInput(ItemStack input) { - if (GroovyLog.msg("Error removing soaking pot recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing soaking pot recipe").add(IngredientHelper.isEmpty(input), + () -> "Input 1 must not be empty").error().postIfNotEmpty()) { return; } for (SoakingPotRecipe recipe : getRegistry()) { @@ -52,10 +47,8 @@ public void removeByInput(ItemStack input) { @MethodDescription(example = @Example("item('pyrotech:material', 54)")) public void removeByOutput(IIngredient output) { - if (GroovyLog.msg("Error removing soaking pot recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing soaking pot recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error().postIfNotEmpty()) { return; } for (SoakingPotRecipe recipe : getRegistry()) { @@ -90,23 +83,22 @@ public RecipeBuilder campfireRequired(boolean campfireRequired) { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Soaking Pot Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Soaking Pot Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); validateFluids(msg, 1, 1, 0, 0); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.SOAKING_POT_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.SOAKING_POT_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SoakingPotRecipe register() { if (!validate()) return null; - SoakingPotRecipe recipe = new SoakingPotRecipe(output.get(0), input.get(0).toMcIngredient(), fluidInput.get(0), campfireRequired, time).setRegistryName(super.name); + SoakingPotRecipe recipe = new SoakingPotRecipe(output.get(0), input.get(0).toMcIngredient(), fluidInput.get(0), + campfireRequired, time).setRegistryName(super.name); PyroTech.soakingPot.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/TanningRack.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/TanningRack.java index 28f91f05a..194cfffd5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/TanningRack.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pyrotech/TanningRack.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.pyrotech; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,8 +12,6 @@ import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.codetaylor.mc.pyrotech.modules.tech.basic.ModuleTechBasic; import com.codetaylor.mc.pyrotech.modules.tech.basic.recipe.TanningRackRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; @RegistryDescription public class TanningRack extends ForgeRegistryWrapper { @@ -24,23 +26,16 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("'apple_to_dirt', item('minecraft:apple'), item('minecraft:dirt'), 1200, item('minecraft:clay_ball')")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("'apple_to_dirt', item('minecraft:apple'), item('minecraft:dirt'), 1200, item('minecraft:clay_ball')")) public TanningRackRecipe add(String name, IIngredient input, ItemStack output, int dryTime, ItemStack failureItem) { - return recipeBuilder() - .dryTime(dryTime) - .failureItem(failureItem) - .name(name) - .input(input) - .output(output) - .register(); + return recipeBuilder().dryTime(dryTime).failureItem(failureItem).name(name).input(input).output(output).register(); } @MethodDescription(example = @Example("item('minecraft:wheat')")) public void removeByInput(ItemStack input) { - if (GroovyLog.msg("Error removing tanning rack recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing tanning rack recipe").add(IngredientHelper.isEmpty(input), + () -> "Input 1 must not be empty").error().postIfNotEmpty()) { return; } for (TanningRackRecipe recipe : getRegistry()) { @@ -52,10 +47,9 @@ public void removeByInput(ItemStack input) { @MethodDescription public void removeByOutput(IIngredient output) { - if (GroovyLog.msg("Error removing tanning rack recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output 1 must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing tanning rack recipe").add(IngredientHelper.isEmpty(output), + () -> "Output 1 must not be empty").error() + .postIfNotEmpty()) { return; } for (TanningRackRecipe recipe : getRegistry()) { @@ -88,16 +82,15 @@ public RecipeBuilder dryTime(int time) { } @Override - public String getErrorMsg() { - return "Error adding Pyrotech Tanning Rack Recipe"; - } + public String getErrorMsg() { return "Error adding Pyrotech Tanning Rack Recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); msg.add(dryTime < 0, "dryTime must be a non negative integer, yet it was {}", dryTime); msg.add(super.name == null, "name cannot be null."); - msg.add(ModuleTechBasic.Registries.TANNING_RACK_RECIPE.getValue(super.name) != null, "tried to register {}, but it already exists.", super.name); + msg.add(ModuleTechBasic.Registries.TANNING_RACK_RECIPE.getValue(super.name) != null, + "tried to register {}, but it already exists.", super.name); } @RecipeBuilderRegistrationMethod @@ -105,7 +98,8 @@ public void validate(GroovyLog.Msg msg) { @Override public @Nullable TanningRackRecipe register() { if (!validate()) return null; - TanningRackRecipe recipe = new TanningRackRecipe(output.get(0), input.get(0).toMcIngredient(), failureItem, dryTime).setRegistryName(super.name); + TanningRackRecipe recipe = new TanningRackRecipe(output.get(0), input.get(0).toMcIngredient(), failureItem, dryTime) + .setRegistryName(super.name); PyroTech.tanningRack.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/AnimalHarvest.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/AnimalHarvest.java index ca70238a9..03037bebd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/AnimalHarvest.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/AnimalHarvest.java @@ -1,27 +1,28 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Map; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.AnimalHarvestRecipe; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription public class AnimalHarvest extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('wither_skeleton_harvest').entity(entity('minecraft:wither_skeleton'))"), - @Example(".entity(entity('minecraft:enderman'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('wither_skeleton_harvest').entity(entity('minecraft:wither_skeleton'))"), + @Example(".entity(entity('minecraft:enderman'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -77,8 +78,8 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getAnimalHarvestRecipes().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipes.getAnimalHarvestRecipes().entrySet()).setRemover(r -> this.removeByName(r + .getKey())); } @Property(property = "name") @@ -94,14 +95,10 @@ public RecipeBuilder entity(EntityEntry entity) { } @Override - public String getErrorMsg() { - return "Error adding Roots Animal Harvest recipe"; - } + public String getErrorMsg() { return "Error adding Roots Animal Harvest recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_animal_harvest_"; - } + public String getRecipeNamePrefix() { return "groovyscript_animal_harvest_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -111,8 +108,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(entity == null, "entity must be defined and extended EntityLivingBase, instead it was {}", entity); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AnimalHarvestRecipe register() { if (!validate()) return null; AnimalHarvestRecipe recipe = new AnimalHarvestRecipe(super.name, entity); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/AnimalHarvestFish.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/AnimalHarvestFish.java index d37b53937..f31c19e3f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/AnimalHarvestFish.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/AnimalHarvestFish.java @@ -1,26 +1,27 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.AnimalHarvestFishRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription public class AnimalHarvestFish extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('clay_fish').weight(50).output(item('minecraft:clay'))"), - @Example(".weight(13).fish(item('minecraft:gold_ingot'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('clay_fish').weight(50).output(item('minecraft:clay'))"), + @Example(".weight(13).fish(item('minecraft:gold_ingot'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -81,12 +82,11 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getAnimalHarvestFishRecipes().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipes.getAnimalHarvestFishRecipes().entrySet()).setRemover(r -> this.removeByName(r + .getKey())); } - @Property(property = "name") - @Property(property = "output", valid = @Comp("1")) + @Property(property = "name") @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "0", type = Comp.Type.GT)) @@ -105,14 +105,10 @@ public RecipeBuilder fish(ItemStack fish) { } @Override - public String getErrorMsg() { - return "Error adding Roots Animal Harvest Fish recipe"; - } + public String getErrorMsg() { return "Error adding Roots Animal Harvest Fish recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_animal_harvest_fish_"; - } + public String getRecipeNamePrefix() { return "groovyscript_animal_harvest_fish_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -122,8 +118,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(weight <= 0, "weight must be a nonnegative integer greater than 0, instead it was {}", weight); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AnimalHarvestFishRecipe register() { if (!validate()) return null; AnimalHarvestFishRecipe recipe = new AnimalHarvestFishRecipe(super.name, output.get(0), weight); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/BarkCarving.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/BarkCarving.java index 16efc730d..611f0fd14 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/BarkCarving.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/BarkCarving.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Map; + +import net.minecraft.block.BlockPlanks; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -8,15 +17,9 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.BarkRecipe; -import net.minecraft.block.BlockPlanks; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription public class BarkCarving extends VirtualizedRegistry { @@ -25,11 +28,9 @@ public BarkCarving() { super(Alias.generateOfClassAnd(BarkCarving.class, "Bark")); } - @RecipeBuilderDescription(example = { - @Example(".name('gold_bark').input(item('minecraft:clay')).output(item('minecraft:gold_ingot'))"), - @Example(".blockstate(blockstate('minecraft:gold_block')).output(item('minecraft:diamond'))"), - @Example(".input(blockstate('minecraft:diamond_block')).output(item('minecraft:clay') * 10)") - }) + @RecipeBuilderDescription(example = {@Example(".name('gold_bark').input(item('minecraft:clay')).output(item('minecraft:gold_ingot'))"), + @Example(".blockstate(blockstate('minecraft:gold_block')).output(item('minecraft:diamond'))"), + @Example(".input(blockstate('minecraft:diamond_block')).output(item('minecraft:clay') * 10)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -120,8 +121,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getBarkRecipes()) - .setRemover(r -> this.removeByName(r.getName())); + return new SimpleObjectStream<>(ModRecipes.getBarkRecipes()).setRemover(r -> this.removeByName(r.getName())); } @Property(property = "name") @@ -136,19 +136,16 @@ public RecipeBuilder blockstate(IBlockState blockstate) { @RecipeBuilderMethodDescription public RecipeBuilder input(IBlockState blockstate) { - this.input.add(IngredientHelper.toIIngredient(new ItemStack(blockstate.getBlock(), 1, blockstate.getBlock().damageDropped(blockstate)))); + this.input.add(IngredientHelper.toIIngredient(new ItemStack(blockstate.getBlock(), 1, blockstate.getBlock() + .damageDropped(blockstate)))); return this; } @Override - public String getErrorMsg() { - return "Error adding Roots Bark Carving recipe"; - } + public String getErrorMsg() { return "Error adding Roots Bark Carving recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_bark_carving_"; - } + public String getRecipeNamePrefix() { return "groovyscript_bark_carving_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -157,8 +154,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable BarkRecipe register() { if (!validate()) return null; BarkRecipe recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Chrysopoeia.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Chrysopoeia.java index f165d592f..45865cc7d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Chrysopoeia.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Chrysopoeia.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -8,21 +15,15 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.recipe.ChrysopoeiaRecipe; import epicsquid.roots.util.IngredientWithStack; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription public class Chrysopoeia extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('clay_transmute').input(item('minecraft:gold_ingot')).output(item('minecraft:clay'))"), - @Example(".input(item('minecraft:diamond') * 3).output(item('minecraft:gold_ingot') * 3)") - }) + @RecipeBuilderDescription(example = {@Example(".name('clay_transmute').input(item('minecraft:gold_ingot')).output(item('minecraft:clay'))"), + @Example(".input(item('minecraft:diamond') * 3).output(item('minecraft:gold_ingot') * 3)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -97,8 +98,8 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipesAccessor.getChrysopoeiaRecipes().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipesAccessor.getChrysopoeiaRecipes().entrySet()).setRemover(r -> this.removeByName(r + .getKey())); } @Property(property = "name") @@ -106,50 +107,46 @@ public SimpleObjectStream> stream @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { -// overload, byproductChance, and byproduct are all unused -// private float overload = 0.0F; -// private float byproductChance = 0.0F; -// private ItemStack byproduct = ItemStack.EMPTY; + // overload, byproductChance, and byproduct are all unused + // private float overload = 0.0F; + // private float byproductChance = 0.0F; + // private ItemStack byproduct = ItemStack.EMPTY; -// public RecipeBuilder overload(float overload) { -// this.overload = overload; -// return this; -// } + // public RecipeBuilder overload(float overload) { + // this.overload = overload; + // return this; + // } -// public RecipeBuilder byproductChance(float byproductChance) { -// this.byproductChance = byproductChance; -// return this; -// } + // public RecipeBuilder byproductChance(float byproductChance) { + // this.byproductChance = byproductChance; + // return this; + // } -// public RecipeBuilder byproduct(IIngredient byproduct) { -// this.byproduct = IngredientHelper.toItemStack(byproduct); -// return this; -// } + // public RecipeBuilder byproduct(IIngredient byproduct) { + // this.byproduct = IngredientHelper.toItemStack(byproduct); + // return this; + // } @Override - public String getErrorMsg() { - return "Error adding Roots Chrysopoeia conversion recipe"; - } + public String getErrorMsg() { return "Error adding Roots Chrysopoeia conversion recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_chrysopoeia_"; - } + public String getRecipeNamePrefix() { return "groovyscript_chrysopoeia_"; } @Override public void validate(GroovyLog.Msg msg) { validateName(); validateItems(msg, 1, 1, 1, 1); validateFluids(msg); -// msg.add(overload < 0, "overload must be a nonnegative float, yet it was {}", overload); -// msg.add(byproductChance < 0, "byproductChance must be a nonnegative float, yet it was {}", byproductChance); + // msg.add(overload < 0, "overload must be a nonnegative float, yet it was {}", overload); + // msg.add(byproductChance < 0, "byproductChance must be a nonnegative float, yet it was {}", byproductChance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ChrysopoeiaRecipe register() { if (!validate()) return null; - ChrysopoeiaRecipe recipe = new ChrysopoeiaRecipe(new IngredientWithStack(IngredientHelper.toItemStack(input.get(0))), output.get(0)/*, byproduct, overload, byproductChance*/); + ChrysopoeiaRecipe recipe = new ChrysopoeiaRecipe(new IngredientWithStack(IngredientHelper.toItemStack(input.get(0))), + output.get(0)/*, byproduct, overload, byproductChance*/); recipe.setRegistryName(super.name); ModSupport.ROOTS.get().chrysopoeia.add(super.name, recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/FeyCrafter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/FeyCrafter.java index 2d4a75030..fa5f10f12 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/FeyCrafter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/FeyCrafter.java @@ -1,23 +1,26 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.FeyCraftingRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; -import java.util.Map; - -@RegistryDescription( - admonition = @Admonition(value = "groovyscript.wiki.roots.fey_crafter.note", type = Admonition.Type.DANGER, format = Admonition.Format.STANDARD) -) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.roots.fey_crafter.note", + type = Admonition.Type.DANGER, + format = Admonition.Format.STANDARD)) public class FeyCrafter extends VirtualizedRegistry> { @RecipeBuilderDescription(example = @Example(".name('clay_craft').input(item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone')) // Must be exactly 5.output(item('minecraft:clay')).xp(100)")) @@ -32,7 +35,9 @@ public void onReload() { } public void add(FeyCraftingRecipe recipe) { - add(recipe.getName().contains(":") ? new ResourceLocation(recipe.getName()) : new ResourceLocation("roots", recipe.getName()), recipe); + add(recipe.getName().contains(":") ? new ResourceLocation(recipe.getName()) : new ResourceLocation("roots", recipe + .getName()), + recipe); } public void add(ResourceLocation name, FeyCraftingRecipe recipe) { @@ -83,8 +88,8 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getFeyCraftingRecipes().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipes.getFeyCraftingRecipes().entrySet()).setRemover(r -> this.removeByName(r + .getKey())); } @Property(property = "name") @@ -102,14 +107,10 @@ public RecipeBuilder xp(int xp) { } @Override - public String getErrorMsg() { - return "Error adding Roots Fey Crafter recipe"; - } + public String getErrorMsg() { return "Error adding Roots Fey Crafter recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_fey_crafter_"; - } + public String getRecipeNamePrefix() { return "groovyscript_fey_crafter_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -119,8 +120,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(xp < 0, "xp must be a nonnegative integer, yet it was {}", xp); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable FeyCraftingRecipe register() { if (!validate()) return null; FeyCraftingRecipe recipe = new FeyCraftingRecipe(output.get(0), xp); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/FlowerGeneration.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/FlowerGeneration.java index d9b5118e6..f52d67f8a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/FlowerGeneration.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/FlowerGeneration.java @@ -1,5 +1,19 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,30 +21,15 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.FlowerRecipe; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class FlowerGeneration extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('clay_flower').flower(blockstate('minecraft:clay'))"), - @Example(".flower(blockstate('minecraft:gold_block')).allowedSoils(item('minecraft:dirt'), item('minecraft:sandstone'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('clay_flower').flower(blockstate('minecraft:clay'))"), + @Example(".flower(blockstate('minecraft:gold_block')).allowedSoils(item('minecraft:dirt'), item('minecraft:sandstone'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -66,7 +65,8 @@ public boolean removeByName(ResourceLocation name) { return true; } - @MethodDescription(description = "groovyscript.wiki.roots.flower_generation.removeByFlower0", example = @Example("blockstate('minecraft:red_flower:2')")) + @MethodDescription(description = "groovyscript.wiki.roots.flower_generation.removeByFlower0", + example = @Example("blockstate('minecraft:red_flower:2')")) public boolean removeByFlower(IBlockState flower) { for (Map.Entry x : ModRecipes.getFlowerRecipes().entrySet()) { if (x.getValue().getFlower() == flower) { @@ -78,12 +78,14 @@ public boolean removeByFlower(IBlockState flower) { return false; } - @MethodDescription(description = "groovyscript.wiki.roots.flower_generation.removeByFlower1", example = @Example("block('minecraft:red_flower'), 1")) + @MethodDescription(description = "groovyscript.wiki.roots.flower_generation.removeByFlower1", + example = @Example("block('minecraft:red_flower'), 1")) public boolean removeByFlower(Block flower, int meta) { return removeByFlower(flower.getStateFromMeta(meta)); } - @MethodDescription(description = "groovyscript.wiki.roots.flower_generation.removeByFlower2", example = @Example("block('minecraft:red_flower')")) + @MethodDescription(description = "groovyscript.wiki.roots.flower_generation.removeByFlower2", + example = @Example("block('minecraft:red_flower')")) public boolean removeByFlower(Block flower) { boolean found = false; for (IBlockState state : flower.getBlockState().getValidStates()) { @@ -92,7 +94,8 @@ public boolean removeByFlower(Block flower) { return found; } - @MethodDescription(description = "groovyscript.wiki.roots.flower_generation.removeByFlower3", example = @Example("item('minecraft:red_flower:3')")) + @MethodDescription(description = "groovyscript.wiki.roots.flower_generation.removeByFlower3", + example = @Example("item('minecraft:red_flower:3')")) public boolean removeByFlower(ItemStack output) { return removeByFlower(((ItemBlock) output.getItem()).getBlock().getStateFromMeta(output.getMetadata())); } @@ -105,8 +108,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getFlowerRecipes().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipes.getFlowerRecipes().entrySet()).setRemover(r -> this.removeByName(r.getKey())); } @Property(property = "name") @@ -152,14 +154,10 @@ public RecipeBuilder allowedSoils(Collection allowedSoilss) { } @Override - public String getErrorMsg() { - return "Error adding Roots Flower Generation recipe"; - } + public String getErrorMsg() { return "Error adding Roots Flower Generation recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_flower_generation_recipe_"; - } + public String getRecipeNamePrefix() { return "groovyscript_flower_generation_recipe_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -169,8 +167,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(flower == null, "flower must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable FlowerRecipe register() { if (!validate()) return null; FlowerRecipe recipe = new FlowerRecipe(super.name, flower, allowedSoils); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/LifeEssence.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/LifeEssence.java index 8de952f11..c957b1d30 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/LifeEssence.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/LifeEssence.java @@ -1,17 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import net.minecraft.entity.EntityLivingBase; +import net.minecraftforge.fml.common.registry.EntityEntry; + import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; -import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.fml.common.registry.EntityEntry; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class LifeEssence extends VirtualizedRegistry> { @Override diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Modifiers.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Modifiers.java index 82ec31241..f73c67ed9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Modifiers.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Modifiers.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import net.minecraft.util.ResourceLocation; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -7,14 +9,12 @@ import com.cleanroommc.groovyscript.core.mixin.roots.ModifierRegistryAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.modifiers.Modifier; import epicsquid.roots.modifiers.ModifierRegistry; import epicsquid.roots.spell.SpellBase; -import net.minecraft.util.ResourceLocation; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Modifiers extends VirtualizedRegistry { @Override @@ -61,12 +61,16 @@ public boolean disable(SpellBase spell) { return true; } - @MethodDescription(description = "groovyscript.wiki.roots.modifiers.enable0", example = @Example("'extended_geas'"), type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.roots.modifiers.enable0", + example = @Example("'extended_geas'"), + type = MethodDescription.Type.ADDITION) public boolean enable(String name) { return enable(name.contains(":") ? new ResourceLocation(name) : new ResourceLocation("roots", name)); } - @MethodDescription(description = "groovyscript.wiki.roots.modifiers.enable1", example = @Example("resource('roots:animal_savior')"), type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.roots.modifiers.enable1", + example = @Example("resource('roots:animal_savior')"), + type = MethodDescription.Type.ADDITION) public boolean enable(ResourceLocation rl) { Modifier modifier = ModifierRegistry.get(rl); if (modifier == null) { @@ -79,7 +83,9 @@ public boolean enable(ResourceLocation rl) { return false; } - @MethodDescription(description = "groovyscript.wiki.roots.modifiers.enable2", example = @Example("modifier('roots:weakened_response')"), type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.roots.modifiers.enable2", + example = @Example("modifier('roots:weakened_response')"), + type = MethodDescription.Type.ADDITION) public boolean enable(Modifier modifier) { if (ModifierRegistry.get(modifier) == null) { GroovyLog.msg("Error enabling modifier {}", modifier).error().post(); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Mortar.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Mortar.java index ec7a48f44..706a637ca 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Mortar.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Mortar.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,15 +18,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.MortarRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; @RegistryDescription public class Mortar extends VirtualizedRegistry { @@ -26,11 +29,9 @@ public Mortar() { super(Alias.generateOfClassAnd(Mortar.class, "MortarAndPestle")); } - @RecipeBuilderDescription(example = { - @Example(".name('clay_mortar').input(item('minecraft:stone'),item('minecraft:gold_ingot'),item('minecraft:stone'),item('minecraft:gold_ingot'),item('minecraft:stone')).generate(false).output(item('minecraft:clay')).color(1, 0, 0.1, 1, 0, 0.1)"), - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).color(0, 0, 0.1)"), - @Example(".input(item('minecraft:diamond'), item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16).red(0).green1(0.5).green2(1)") - }) + @RecipeBuilderDescription(example = {@Example(".name('clay_mortar').input(item('minecraft:stone'),item('minecraft:gold_ingot'),item('minecraft:stone'),item('minecraft:gold_ingot'),item('minecraft:stone')).generate(false).output(item('minecraft:clay')).color(1, 0, 0.1, 1, 0, 0.1)"), + @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).color(0, 0, 0.1)"), + @Example(".input(item('minecraft:diamond'), item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16).red(0).green1(0.5).green2(1)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -96,8 +97,7 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getMortarRecipes()) - .setRemover(r -> this.removeByName(r.getRegistryName())); + return new SimpleObjectStream<>(ModRecipes.getMortarRecipes()).setRemover(r -> this.removeByName(r.getRegistryName())); } @Property(property = "name") @@ -105,17 +105,23 @@ public SimpleObjectStream streamRecipes() { @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "1.0f", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) + @Property(defaultValue = "1.0f", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) private float red1 = 1.0F; - @Property(defaultValue = "1.0f", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) + @Property(defaultValue = "1.0f", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) private float green1 = 1.0F; - @Property(defaultValue = "1.0f", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) + @Property(defaultValue = "1.0f", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) private float blue1 = 1.0F; - @Property(defaultValue = "1.0f", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) + @Property(defaultValue = "1.0f", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) private float red2 = 1.0F; - @Property(defaultValue = "1.0f", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) + @Property(defaultValue = "1.0f", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) private float green2 = 1.0F; - @Property(defaultValue = "1.0f", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) + @Property(defaultValue = "1.0f", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) private float blue2 = 1.0F; @Property(defaultValue = "true") private boolean generate = true; @@ -233,14 +239,10 @@ public RecipeBuilder generate() { } @Override - public String getErrorMsg() { - return "Error adding Roots Mortar recipe"; - } + public String getErrorMsg() { return "Error adding Roots Mortar recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_mortar_recipe_"; - } + public String getRecipeNamePrefix() { return "groovyscript_mortar_recipe_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -255,8 +257,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(blue2 < 0 || blue2 > 1, "blue2 must be a float between 0 and 1, yet it was {}", blue2); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable MortarRecipe register() { if (!validate()) return null; @@ -268,14 +269,17 @@ public void validate(GroovyLog.Msg msg) { ingredients.add(input.get(0).toMcIngredient()); ItemStack copy = output.get(0).copy(); copy.setCount(i * count); - MortarRecipe recipe = new MortarRecipe(copy, ingredients.toArray(new Ingredient[0]), red1, green1, blue1, red2, green2, blue2); + MortarRecipe recipe = new MortarRecipe(copy, ingredients.toArray(new Ingredient[0]), red1, green1, blue1, + red2, green2, blue2); recipe.setRegistryName(new ResourceLocation(super.name.toString() + "_" + i)); ModSupport.ROOTS.get().mortar.add(recipe.getRegistryName(), recipe); } return null; } - MortarRecipe recipe = new MortarRecipe(output.get(0), input.stream().map(IIngredient::toMcIngredient).toArray(Ingredient[]::new), red1, red2, green1, green2, blue1, blue2); + MortarRecipe recipe = new MortarRecipe(output.get(0), input.stream().map(IIngredient::toMcIngredient).toArray( + Ingredient[]::new), + red1, red2, green1, green2, blue1, blue2); recipe.setRegistryName(super.name); ModSupport.ROOTS.get().mortar.add(super.name, recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Moss.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Moss.java index acafcc08b..c8800407c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Moss.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Moss.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -7,14 +16,8 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import epicsquid.roots.config.MossConfig; -import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; -import java.util.Map; +import epicsquid.roots.config.MossConfig; @RegistryDescription public class Moss extends VirtualizedRegistry> { @@ -52,13 +55,15 @@ public static void reload() { if (in.getMetadata() == 0 && out.getMetadata() == 0) { MossConfigAccessor.getMossyBlocks().put(blockIn, blockOut); } else { - MossConfigAccessor.getMossyStates().put(blockIn.getStateFromMeta(in.getMetadata()), blockOut.getStateFromMeta(out.getMetadata())); + MossConfigAccessor.getMossyStates().put(blockIn.getStateFromMeta(in.getMetadata()), blockOut.getStateFromMeta(out + .getMetadata())); } } } - @MethodDescription(example = @Example("item('minecraft:stained_glass:3'), item('minecraft:stained_glass:4')"), type = MethodDescription.Type.ADDITION) + @MethodDescription(example = @Example("item('minecraft:stained_glass:3'), item('minecraft:stained_glass:4')"), + type = MethodDescription.Type.ADDITION) public void add(ItemStack in, ItemStack out) { MossConfigAccessor.getMossyCobblestones().put(in, out); addScripted(Pair.of(in, out)); @@ -95,28 +100,26 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(MossConfigAccessor.getMossyCobblestones().entrySet()).setRemover(r -> this.remove(r.getKey())); + return new SimpleObjectStream<>(MossConfigAccessor.getMossyCobblestones().entrySet()).setRemover(r -> this.remove(r + .getKey())); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder> { @Override - public String getErrorMsg() { - return "Error adding Roots Moss conversion"; - } + public String getErrorMsg() { return "Error adding Roots Moss conversion"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 1, 1); validateFluids(msg); - msg.add(!(input.get(0).getMatchingStacks()[0].getItem() instanceof ItemBlock), "input must be an instance of ItemBlock"); + msg.add(!(input.get(0).getMatchingStacks()[0].getItem() instanceof ItemBlock), + "input must be an instance of ItemBlock"); msg.add(!(output.get(0).getItem() instanceof ItemBlock), "output must be an instance of ItemBlock"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable Pair register() { if (!validate()) return null; ModSupport.ROOTS.get().moss.add(input.get(0).getMatchingStacks()[0], output.get(0)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Pacifist.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Pacifist.java index ac9bded2e..ec226b975 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Pacifist.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Pacifist.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Map; + +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -7,18 +15,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.PacifistEntry; -import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.jetbrains.annotations.Nullable; -import java.util.Map; - -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES -) +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Pacifist extends VirtualizedRegistry { @RecipeBuilderDescription(example = @Example(".name('wither_skeleton_pacifist').entity(entity('minecraft:wither_skeleton'))")) @@ -81,8 +82,8 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getPacifistEntities().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipes.getPacifistEntities().entrySet()).setRemover(r -> this.removeByName(r + .getKey())); } @Property(property = "name") @@ -98,14 +99,10 @@ public RecipeBuilder entity(EntityEntry entity) { } @Override - public String getErrorMsg() { - return "Error adding Roots Runic Shear Entity recipe"; - } + public String getErrorMsg() { return "Error adding Roots Runic Shear Entity recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_pacifist_"; - } + public String getRecipeNamePrefix() { return "groovyscript_pacifist_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -115,8 +112,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(entity == null, "entity must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable PacifistEntry register() { if (!validate()) return null; PacifistEntry recipe = new PacifistEntry(entity, super.name.toString()); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Predicates.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Predicates.java index d5ed05246..4931e8565 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Predicates.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Predicates.java @@ -1,21 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.roots; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.NamedRegistry; -import epicsquid.roots.recipe.transmutation.*; +import java.util.*; +import java.util.stream.Collectors; + import net.minecraft.block.Block; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; + import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.stream.Collectors; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.NamedRegistry; -@RegistryDescription( - category = RegistryDescription.Category.ENTRIES -) +import epicsquid.roots.recipe.transmutation.*; + +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Predicates extends NamedRegistry { public WorldBlockStatePredicate ANY = WorldBlockStatePredicate.TRUE; @@ -24,13 +25,11 @@ public class Predicates extends NamedRegistry { public BlocksPredicate WATER = new WaterPredicate(); public LeavesPredicate LEAVES = new LeavesPredicate(); - @RecipeBuilderDescription(example = { - @Example(".blockstate(blockstate('minecraft:red_flower'))"), - @Example(".block(block('minecraft:red_flower'))"), - @Example(".blockstate(blockstate('minecraft:red_flower:type=poppy')).properties('type')"), - @Example(".blockstate(blockstate('minecraft:log:axis=z:variant=oak')).properties('axis').above()"), - @Example(".blockstate(blockstate('minecraft:log')).below()") - }) + @RecipeBuilderDescription(example = {@Example(".blockstate(blockstate('minecraft:red_flower'))"), + @Example(".block(block('minecraft:red_flower'))"), + @Example(".blockstate(blockstate('minecraft:red_flower:type=poppy')).properties('type')"), + @Example(".blockstate(blockstate('minecraft:log:axis=z:variant=oak')).properties('axis').above()"), + @Example(".blockstate(blockstate('minecraft:log')).below()")}) public StateBuilder stateBuilder() { return new StateBuilder(); } @@ -40,11 +39,16 @@ StatePredicate create(IBlockState blockState) { } PropertyPredicate create(IBlockState blockState, String... properties) { - return new PropertyPredicate(blockState, Arrays.stream(properties).map(x -> blockState.getBlock().getBlockState().getProperty(x)).filter(Objects::nonNull).collect(Collectors.toList())); + return new PropertyPredicate(blockState, Arrays.stream(properties).map(x -> blockState.getBlock().getBlockState() + .getProperty(x)).filter( + Objects::nonNull) + .collect(Collectors.toList())); } PropertyPredicate create(IBlockState blockState, Collection properties) { - return new PropertyPredicate(blockState, properties.stream().map(x -> blockState.getBlock().getBlockState().getProperty(x)).filter(Objects::nonNull).collect(Collectors.toList())); + return new PropertyPredicate(blockState, properties.stream().map(x -> blockState.getBlock().getBlockState().getProperty( + x)) + .filter(Objects::nonNull).collect(Collectors.toList())); } WorldBlockStatePredicate above(BlockStatePredicate blockState) { @@ -103,9 +107,7 @@ public StateBuilder below() { } @Override - public String getErrorMsg() { - return "Error creating Roots Predicate"; - } + public String getErrorMsg() { return "Error creating Roots Predicate"; } @Override public void validate(GroovyLog.Msg msg) { @@ -122,15 +124,16 @@ public void validate(GroovyLog.Msg msg) { }); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable MatchingStates register() { if (!validate()) return null; BlockStateContainer container = blockstate.getBlock().getBlockState(); - BlockStatePredicate predicate = properties.isEmpty() - ? new StatePredicate(blockstate) - : new PropertyPredicate(blockstate, properties.stream().map(container::getProperty).collect(Collectors.toList())); + BlockStatePredicate predicate = properties.isEmpty() ? new StatePredicate(blockstate) : new PropertyPredicate( + blockstate, + properties.stream() + .map(container::getProperty) + .collect(Collectors.toList())); if (above) return new BlockStateAbove(predicate); if (below) return new BlockStateBelow(predicate); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Pyre.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Pyre.java index 75ad0a9ac..4e4297db2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Pyre.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Pyre.java @@ -1,26 +1,27 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.PyreCraftingRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription public class Pyre extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('clay_from_fire').input(item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone')).output(item('minecraft:clay')).xp(5).time(1)"), - @Example(".input(item('minecraft:gold_ingot'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:stone'),item('minecraft:stone')).output(item('minecraft:diamond') * 32).levels(5).burnTime(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".name('clay_from_fire').input(item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone'),item('minecraft:stone')).output(item('minecraft:clay')).xp(5).time(1)"), + @Example(".input(item('minecraft:gold_ingot'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:stone'),item('minecraft:stone')).output(item('minecraft:diamond') * 32).levels(5).burnTime(1000)")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -83,8 +84,8 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getPyreCraftingRecipes().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipes.getPyreCraftingRecipes().entrySet()).setRemover(r -> this.removeByName(r + .getKey())); } @Property(property = "name") @@ -121,14 +122,10 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Roots Pyre recipe"; - } + public String getErrorMsg() { return "Error adding Roots Pyre recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_pyre_recipe_"; - } + public String getRecipeNamePrefix() { return "groovyscript_pyre_recipe_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -138,8 +135,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(xp < 0, "xp must be a nonnegative integer, yet it was {}", xp); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable PyreCraftingRecipe register() { if (!validate()) return null; PyreCraftingRecipe recipe = new PyreCraftingRecipe(output.get(0), xp); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Rituals.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Rituals.java index fa95585eb..399204313 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Rituals.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Rituals.java @@ -1,22 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Collection; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.core.mixin.roots.RitualBaseAccessor; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.properties.Property; import epicsquid.roots.properties.PropertyTable; import epicsquid.roots.ritual.RitualBase; import epicsquid.roots.ritual.RitualRegistry; -import org.jetbrains.annotations.Nullable; -import java.util.Collection; - -@RegistryDescription( - reloadability = RegistryDescription.Reloadability.FLAWED, - isFullyDocumented = false // TODO fully document Roots Rituals +@RegistryDescription(reloadability = RegistryDescription.Reloadability.FLAWED, isFullyDocumented = false // TODO fully document Roots Rituals ) public class Rituals extends VirtualizedRegistry { @@ -59,7 +59,8 @@ public RitualWrapper(RitualBase ritual) { public RitualWrapper recipe(IIngredient... input) { if (ritual == null) { - GroovyLog.msg("Error modifying Roots Ritual recipe").add("No ritual specified when recipe change requested.").error().post(); + GroovyLog.msg("Error modifying Roots Ritual recipe").add("No ritual specified when recipe change requested.") + .error().post(); } else { new RecipeBuilder(ritual).input(input).register(); } @@ -68,7 +69,8 @@ public RitualWrapper recipe(IIngredient... input) { public RitualWrapper recipe(Collection input) { if (ritual == null) { - GroovyLog.msg("Error modifying Roots Ritual recipe").add("No ritual specified when recipe change requested.").error().post(); + GroovyLog.msg("Error modifying Roots Ritual recipe").add("No ritual specified when recipe change requested.") + .error().post(); } else { new RecipeBuilder(ritual).input(input).register(); } @@ -117,11 +119,11 @@ public RitualWrapper setDuration(int value) { @com.cleanroommc.groovyscript.api.documentation.annotations.Property(property = "input", valid = @Comp("5")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @com.cleanroommc.groovyscript.api.documentation.annotations.Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) + @com.cleanroommc.groovyscript.api.documentation.annotations.Property(valid = @Comp(value = "null", + type = Comp.Type.NOT)) private RitualBase ritual; - public RecipeBuilder() { - } + public RecipeBuilder() {} public RecipeBuilder(RitualBase ritual) { this.ritual = ritual; @@ -134,9 +136,7 @@ public RecipeBuilder ritual(RitualBase ritual) { } @Override - public String getErrorMsg() { - return "Error creating Roots Ritual Recipe"; - } + public String getErrorMsg() { return "Error creating Roots Ritual Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -145,11 +145,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(ritual == null, "ritual must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RitualBase.RitualRecipe register() { if (!validate()) return null; - RitualBase.RitualRecipe recipe = new RitualBase.RitualRecipe(ritual, input.stream().map(IIngredient::toMcIngredient).toArray()); + RitualBase.RitualRecipe recipe = new RitualBase.RitualRecipe(ritual, input.stream().map( + IIngredient::toMcIngredient) + .toArray()); this.ritual.setRecipe(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Roots.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Roots.java index 282b870a6..005b28257 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Roots.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Roots.java @@ -1,10 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import net.minecraft.util.ResourceLocation; + import com.cleanroommc.groovyscript.api.IObjectParser; import com.cleanroommc.groovyscript.api.Result; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; import com.cleanroommc.groovyscript.mapper.ObjectMappers; + import epicsquid.roots.api.Herb; import epicsquid.roots.init.HerbRegistry; import epicsquid.roots.modifiers.CostType; @@ -15,7 +18,6 @@ import epicsquid.roots.spell.FakeSpell; import epicsquid.roots.spell.SpellBase; import epicsquid.roots.spell.SpellRegistry; -import net.minecraft.util.ResourceLocation; public class Roots extends GroovyPropertyContainer { @@ -41,32 +43,22 @@ public class Roots extends GroovyPropertyContainer { @Override public void initialize(GroovyContainer container) { - container.objectMapperBuilder("ritual", RitualBase.class) - .parser(IObjectParser.wrapStringGetter(RitualRegistry::getRitual)) - .completerOfNames(() -> RitualRegistry.ritualRegistry.keySet()) - .docOfType("ritual") - .register(); - container.objectMapperBuilder("herb", Herb.class) - .parser(IObjectParser.wrapStringGetter(HerbRegistry::getHerbByName)) - .completerOfNames(HerbRegistry.registry::keySet) - .docOfType("herb") - .register(); - container.objectMapperBuilder("cost", CostType.class) - .parser(IObjectParser.wrapEnum(CostType.class, false)) - .completerOfEnum(CostType.class, false) - .docOfType("cost") - .register(); - container.objectMapperBuilder("spell", SpellBase.class) - .parser(Roots::getSpell) - .completer(SpellRegistry.spellRegistry::keySet) - .defaultValueSup(() -> Result.some(FakeSpell.INSTANCE)) // crashes otherwise - .docOfType("spell") - .register(); - container.objectMapperBuilder("modifier", Modifier.class) - .parser(Roots::getModifier) - .completerOfNamed(ModifierRegistry::getModifiers, v -> v.getRegistryName().toString()) - .docOfType("modifier") - .register(); + container.objectMapperBuilder("ritual", RitualBase.class).parser(IObjectParser.wrapStringGetter( + RitualRegistry::getRitual)) + .completerOfNames(() -> RitualRegistry.ritualRegistry.keySet()).docOfType("ritual").register(); + container.objectMapperBuilder("herb", Herb.class).parser(IObjectParser.wrapStringGetter(HerbRegistry::getHerbByName)) + .completerOfNames(HerbRegistry.registry::keySet).docOfType("herb").register(); + container.objectMapperBuilder("cost", CostType.class).parser(IObjectParser.wrapEnum(CostType.class, false)) + .completerOfEnum(CostType.class, false).docOfType("cost").register(); + container.objectMapperBuilder("spell", SpellBase.class).parser(Roots::getSpell).completer( + SpellRegistry.spellRegistry::keySet) + .defaultValueSup(() -> Result.some(FakeSpell.INSTANCE)) // crashes otherwise + .docOfType("spell").register(); + container.objectMapperBuilder("modifier", Modifier.class).parser(Roots::getModifier).completerOfNamed( + ModifierRegistry::getModifiers, + v -> v.getRegistryName() + .toString()) + .docOfType("modifier").register(); } private static Result getSpell(String s, Object... args) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/RunicShearBlock.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/RunicShearBlock.java index d391c9501..1863fb403 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/RunicShearBlock.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/RunicShearBlock.java @@ -1,29 +1,30 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Map; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.RunicShearRecipe; import epicsquid.roots.recipe.transmutation.BlockStatePredicate; import epicsquid.roots.recipe.transmutation.StatePredicate; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription public class RunicShearBlock extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('clay_from_runic_diamond').state(blockstate('minecraft:diamond_block')).replacementState(blockstate('minecraft:air')).output(item('minecraft:clay') * 64).displayItem(item('minecraft:diamond') * 9)"), - @Example(".state(mods.roots.predicates.stateBuilder().blockstate(blockstate('minecraft:yellow_flower:type=dandelion')).properties('type').register()).replacementState(blockstate('minecraft:red_flower:type=poppy')).output(item('minecraft:gold_ingot'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('clay_from_runic_diamond').state(blockstate('minecraft:diamond_block')).replacementState(blockstate('minecraft:air')).output(item('minecraft:clay') * 64).displayItem(item('minecraft:diamond') * 9)"), + @Example(".state(mods.roots.predicates.stateBuilder().blockstate(blockstate('minecraft:yellow_flower:type=dandelion')).properties('type').register()).replacementState(blockstate('minecraft:red_flower:type=poppy')).output(item('minecraft:gold_ingot'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -91,12 +92,11 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getRunicShearRecipes().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipes.getRunicShearRecipes().entrySet()).setRemover(r -> this.removeByName(r + .getKey())); } - @Property(property = "name") - @Property(property = "output", valid = @Comp("1")) + @Property(property = "name") @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -131,14 +131,10 @@ public RecipeBuilder replacementState(IBlockState replacementState) { } @Override - public String getErrorMsg() { - return "Error adding Roots Runic Shear Block recipe"; - } + public String getErrorMsg() { return "Error adding Roots Runic Shear Block recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_runic_shear_block_"; - } + public String getRecipeNamePrefix() { return "groovyscript_runic_shear_block_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -152,8 +148,7 @@ public void validate(GroovyLog.Msg msg) { } } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RunicShearRecipe register() { if (!validate()) return null; RunicShearRecipe recipe = new RunicShearRecipe(super.name, state, replacementState, output.get(0), displayItem); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/RunicShearEntity.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/RunicShearEntity.java index f4f8153e9..fbc0265ab 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/RunicShearEntity.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/RunicShearEntity.java @@ -1,32 +1,33 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.HashSet; +import java.util.Map; +import java.util.function.Function; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.RunicShearConditionalEntityRecipe; import epicsquid.roots.recipe.RunicShearEntityRecipe; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.jetbrains.annotations.Nullable; - -import java.util.HashSet; -import java.util.Map; -import java.util.function.Function; @RegistryDescription public class RunicShearEntity extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('clay_from_wither_skeletons').entity(entity('minecraft:wither_skeleton')).output(item('minecraft:clay')).cooldown(1000)"), - @Example(".name('creeper_at_the_last_moment').entity(entity('minecraft:creeper')).output(item('minecraft:diamond'), item('minecraft:nether_star')).functionMap({ entityLivingBase -> entityLivingBase.hasIgnited() ? item('minecraft:nether_star') : item('minecraft:dirt') })"), - @Example(".entity(entity('minecraft:witch')).output(item('minecraft:clay'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('clay_from_wither_skeletons').entity(entity('minecraft:wither_skeleton')).output(item('minecraft:clay')).cooldown(1000)"), + @Example(".name('creeper_at_the_last_moment').entity(entity('minecraft:creeper')).output(item('minecraft:diamond'), item('minecraft:nether_star')).functionMap({ entityLivingBase -> entityLivingBase.hasIgnited() ? item('minecraft:nether_star') : item('minecraft:dirt') })"), + @Example(".entity(entity('minecraft:witch')).output(item('minecraft:clay'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -99,12 +100,11 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getRunicShearEntityRecipes().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipes.getRunicShearEntityRecipes().entrySet()).setRemover(r -> this.removeByName(r + .getKey())); } - @Property(property = "name") - @Property(property = "output", valid = @Comp(type = Comp.Type.GTE, value = "1")) + @Property(property = "name") @Property(property = "output", valid = @Comp(type = Comp.Type.GTE, value = "1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) @@ -133,14 +133,10 @@ public RecipeBuilder functionMap(Function functionM } @Override - public String getErrorMsg() { - return "Error adding Roots Runic Shear Entity recipe"; - } + public String getErrorMsg() { return "Error adding Roots Runic Shear Entity recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_runic_shear_entity_"; - } + public String getRecipeNamePrefix() { return "groovyscript_runic_shear_entity_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -151,8 +147,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(entity == null, "entity must be defined and extended EntityLivingBase, instead it was {}", entity); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RunicShearEntityRecipe register() { if (!validate()) return null; RunicShearEntityRecipe recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Spells.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Spells.java index a825fc309..aff937745 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Spells.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Spells.java @@ -1,11 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.core.mixin.roots.ModifierAccessor; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.api.Herb; import epicsquid.roots.config.SpellConfig; import epicsquid.roots.modifiers.*; @@ -13,17 +23,8 @@ import epicsquid.roots.properties.PropertyTable; import epicsquid.roots.spell.SpellBase; import epicsquid.roots.spell.SpellRegistry; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -@RegistryDescription( - reloadability = RegistryDescription.Reloadability.FLAWED, - isFullyDocumented = false // TODO fully document Roots Spells +@RegistryDescription(reloadability = RegistryDescription.Reloadability.FLAWED, isFullyDocumented = false // TODO fully document Roots Spells ) public class Spells extends VirtualizedRegistry { @@ -44,11 +45,8 @@ public static SpellWrapper.RecipeBuilder recipeBuilder() { return new SpellWrapper.RecipeBuilder(); } - @RecipeBuilderDescription(example = { - @Example, - @Example(".cost(cost('additional_cost'), herb('dewgonia'), 0.25)"), - @Example(".cost(cost('additional_cost'), herb('spirit_herb'), 0.1).cost(cost('all_cost_multiplier'), null, -0.125)") - }) + @RecipeBuilderDescription(example = {@Example, @Example(".cost(cost('additional_cost'), herb('dewgonia'), 0.25)"), + @Example(".cost(cost('additional_cost'), herb('spirit_herb'), 0.1).cost(cost('all_cost_multiplier'), null, -0.125)")}) public static CostBuilder costBuilder() { return new CostBuilder(); } @@ -88,7 +86,8 @@ public static RecipeBuilder recipe() { public SpellWrapper recipe(IIngredient... input) { if (spell == null) { - GroovyLog.msg("Error modifying Roots Spell recipe").add("No spell specified when recipe change requested.").error().post(); + GroovyLog.msg("Error modifying Roots Spell recipe").add("No spell specified when recipe change requested.") + .error().post(); } else { new RecipeBuilder(spell).input(input).register(); } @@ -97,7 +96,8 @@ public SpellWrapper recipe(IIngredient... input) { public SpellWrapper recipe(Collection input) { if (spell == null) { - GroovyLog.msg("Error modifying Roots Spell recipe").add("No spell specified when recipe change requested.").error().post(); + GroovyLog.msg("Error modifying Roots Spell recipe").add("No spell specified when recipe change requested.") + .error().post(); } else { new RecipeBuilder(spell).input(input).register(); } @@ -146,7 +146,8 @@ public SpellWrapper setSound(boolean enabled, double volume) { public SpellWrapper set(String propertyName, T value) { PropertyTable table = this.spell.getProperties(); Property prop = table.get(propertyName); - if (prop == null) GroovyLog.msg("Property {} was undefined for spell {}", propertyName, spell.getName()).error().post(); + if (prop == null) GroovyLog.msg("Property {} was undefined for spell {}", propertyName, spell.getName()).error() + .post(); else table.set(prop, value); return this; } @@ -220,15 +221,16 @@ public SpellWrapper clearModifierCost(Modifier mod) { } @com.cleanroommc.groovyscript.api.documentation.annotations.Property(property = "name") - @com.cleanroommc.groovyscript.api.documentation.annotations.Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), - @Comp(type = Comp.Type.LTE, value = "5")}) + @com.cleanroommc.groovyscript.api.documentation.annotations.Property(property = "input", + valid = {@Comp(type = Comp.Type.GTE, value = "1"), + @Comp(type = Comp.Type.LTE, value = "5")}) public static class RecipeBuilder extends AbstractRecipeBuilder { - @com.cleanroommc.groovyscript.api.documentation.annotations.Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) + @com.cleanroommc.groovyscript.api.documentation.annotations.Property(valid = @Comp(value = "null", + type = Comp.Type.NOT)) private SpellBase spell; - public RecipeBuilder() { - } + public RecipeBuilder() {} public RecipeBuilder(SpellBase spell) { this.spell = spell; @@ -241,9 +243,7 @@ public RecipeBuilder spell(SpellBase spell) { } @Override - public String getErrorMsg() { - return "Error creating Roots Spell Recipe"; - } + public String getErrorMsg() { return "Error creating Roots Spell Recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -251,11 +251,11 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SpellBase.SpellRecipe register() { if (!validate()) return null; - SpellBase.SpellRecipe recipe = new SpellBase.SpellRecipe(input.stream().map(IIngredient::toMcIngredient).toArray()); + SpellBase.SpellRecipe recipe = new SpellBase.SpellRecipe(input.stream().map(IIngredient::toMcIngredient) + .toArray()); this.spell.setRecipe(recipe); return recipe; } @@ -294,9 +294,7 @@ public CostBuilder cost(CostType cost) { } @Override - public String getErrorMsg() { - return "Error creating Roots Spell Cost"; - } + public String getErrorMsg() { return "Error creating Roots Spell Cost"; } @Override public void validate(GroovyLog.Msg msg) { @@ -304,12 +302,11 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable Map register() { if (!validate()) return null; if (list.isEmpty()) return epicsquid.roots.modifiers.Cost.noCost(); return epicsquid.roots.modifiers.Cost.of(list.toArray(new IModifierCost[0])); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/SummonCreature.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/SummonCreature.java index d85e34fb0..398ff8275 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/SummonCreature.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/SummonCreature.java @@ -1,5 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,17 +19,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.SummonCreatureRecipe; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; @RegistryDescription public class SummonCreature extends VirtualizedRegistry { @@ -85,8 +88,8 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipesAccessor.getSummonCreatureEntries().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipesAccessor.getSummonCreatureEntries().entrySet()).setRemover(r -> this + .removeByName(r.getKey())); } @Property(property = "name") @@ -103,14 +106,10 @@ public RecipeBuilder entity(EntityEntry entity) { } @Override - public String getErrorMsg() { - return "Error adding Roots Summon Creature recipe"; - } + public String getErrorMsg() { return "Error adding Roots Summon Creature recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_summon_creature_"; - } + public String getRecipeNamePrefix() { return "groovyscript_summon_creature_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -120,8 +119,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(entity == null, "entity must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SummonCreatureRecipe register() { if (!validate()) return null; List ingredients = input.stream().map(IIngredient::toMcIngredient).collect(Collectors.toList()); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Transmutation.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Transmutation.java index b9411c2be..6c5e99086 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Transmutation.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/Transmutation.java @@ -1,5 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.roots; +import java.util.Collection; +import java.util.Map; +import java.util.Optional; + +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -7,29 +18,19 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import epicsquid.roots.init.ModRecipes; import epicsquid.roots.recipe.TransmutationRecipe; import epicsquid.roots.recipe.transmutation.BlockStatePredicate; import epicsquid.roots.recipe.transmutation.StatePredicate; import epicsquid.roots.recipe.transmutation.WorldBlockStatePredicate; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.util.Collection; -import java.util.Map; -import java.util.Optional; @RegistryDescription public class Transmutation extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".name('clay_duping').start(blockstate('minecraft:clay')).output(item('minecraft:clay_ball') * 30).condition(mods.roots.predicates.stateBuilder().blockstate(blockstate('minecraft:gold_block')).below().register())"), - @Example(".start(mods.roots.predicates.stateBuilder().blockstate(blockstate('minecraft:yellow_flower:type=dandelion')).properties('type').register()).state(blockstate('minecraft:gold_block')).condition(mods.roots.predicates.above(mods.roots.predicates.LEAVES))"), - @Example(".start(blockstate('minecraft:diamond_block')).state(blockstate('minecraft:gold_block'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('clay_duping').start(blockstate('minecraft:clay')).output(item('minecraft:clay_ball') * 30).condition(mods.roots.predicates.stateBuilder().blockstate(blockstate('minecraft:gold_block')).below().register())"), + @Example(".start(mods.roots.predicates.stateBuilder().blockstate(blockstate('minecraft:yellow_flower:type=dandelion')).properties('type').register()).state(blockstate('minecraft:gold_block')).condition(mods.roots.predicates.above(mods.roots.predicates.LEAVES))"), + @Example(".start(blockstate('minecraft:diamond_block')).state(blockstate('minecraft:gold_block'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -76,7 +77,8 @@ public boolean removeByInput(IBlockState input) { }); } - @MethodDescription(description = "groovyscript.wiki.roots.transmutation.removeByOutput0", example = @Example("item('minecraft:dye:3')")) + @MethodDescription(description = "groovyscript.wiki.roots.transmutation.removeByOutput0", + example = @Example("item('minecraft:dye:3')")) public boolean removeByOutput(ItemStack output) { return ModRecipesAccessor.getTransmutationRecipes().entrySet().removeIf(x -> { if (ItemStack.areItemsEqual(x.getValue().getStack(), output)) { @@ -87,7 +89,8 @@ public boolean removeByOutput(ItemStack output) { }); } - @MethodDescription(description = "groovyscript.wiki.roots.transmutation.removeByOutput1", example = @Example("blockstate('minecraft:log:variant=jungle')")) + @MethodDescription(description = "groovyscript.wiki.roots.transmutation.removeByOutput1", + example = @Example("blockstate('minecraft:log:variant=jungle')")) public boolean removeByOutput(IBlockState output) { return ModRecipesAccessor.getTransmutationRecipes().entrySet().removeIf(x -> { Optional state = x.getValue().getState(); @@ -96,11 +99,10 @@ public boolean removeByOutput(IBlockState output) { Collection> incoming = output.getPropertyKeys(); Collection> current = state.get().getPropertyKeys(); - if (state.get().getBlock() == output.getBlock() && - output.getPropertyKeys().stream().allMatch(prop -> incoming.contains(prop) && - current.contains(prop) && - state.get().getValue(prop).equals(output.getValue(prop))) - ) { + if (state.get().getBlock() == output.getBlock() && output.getPropertyKeys().stream().allMatch(prop -> incoming + .contains(prop) && current.contains(prop) && state.get() + .getValue(prop) + .equals(output.getValue(prop)))) { addBackup(x.getValue()); return true; } @@ -116,8 +118,8 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipesAccessor.getTransmutationRecipes().entrySet()) - .setRemover(r -> this.removeByName(r.getKey())); + return new SimpleObjectStream<>(ModRecipesAccessor.getTransmutationRecipes().entrySet()).setRemover(r -> this + .removeByName(r.getKey())); } @Property(property = "name") @@ -162,14 +164,10 @@ public RecipeBuilder condition(WorldBlockStatePredicate condition) { } @Override - public String getErrorMsg() { - return "Error adding Roots Transmutation recipe"; - } + public String getErrorMsg() { return "Error adding Roots Transmutation recipe"; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_transmutation_"; - } + public String getRecipeNamePrefix() { return "groovyscript_transmutation_"; } @Override public void validate(GroovyLog.Msg msg) { @@ -177,11 +175,11 @@ public void validate(GroovyLog.Msg msg) { validateItems(msg, 0, 0, 0, 1); validateFluids(msg); msg.add(start == null, "start must be defined"); - msg.add(state == null && (output.size() != 1 || output.get(0).isEmpty()), "either state must be defined or recipe must have an output"); + msg.add(state == null && (output.size() != 1 || output.get(0).isEmpty()), + "either state must be defined or recipe must have an output"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable TransmutationRecipe register() { if (!validate()) return null; TransmutationRecipe recipe = new TransmutationRecipe(start); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/Alchemy.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/Alchemy.java index b1018f668..51b32c978 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/Alchemy.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/Alchemy.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.rustic; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,18 +17,12 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionEffect; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; + import rustic.common.crafting.ICondenserRecipe; import rustic.common.crafting.Recipes; import rustic.common.items.ModItems; import rustic.common.util.ElixirUtils; -import java.util.Collection; - @RegistryDescription public class Alchemy extends VirtualizedRegistry { @@ -27,12 +30,11 @@ public Alchemy() { super(Alias.generateOfClass(Alchemy.class).andGenerate("Condenser")); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:stone'), item('minecraft:gold_ingot')).output(item('minecraft:clay') * 4).time(20)"), - @Example(value = ".input(item('minecraft:stone'), item('minecraft:gold_ingot'), item('minecraft:diamond')).bottle(item('minecraft:torch')).advanced().effect(new PotionEffect(potion('minecraft:night_vision'), 3600, 1))", imports = "net.minecraft.potion.PotionEffect"), - @Example(".input(item('minecraft:stone'), item('minecraft:stone'), item('minecraft:stone')).modifier(item('minecraft:clay')).fluidInput(fluid('lava') * 500).advanced().output(item('minecraft:diamond'))"), - @Example(".input(item('minecraft:cobblestone'), item('minecraft:cobblestone')).fluidInput(fluid('lava') * 25).bottle(item('minecraft:bucket')).output(item('minecraft:lava_bucket'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:stone'), item('minecraft:gold_ingot')).output(item('minecraft:clay') * 4).time(20)"), + @Example(value = ".input(item('minecraft:stone'), item('minecraft:gold_ingot'), item('minecraft:diamond')).bottle(item('minecraft:torch')).advanced().effect(new PotionEffect(potion('minecraft:night_vision'), 3600, 1))", + imports = "net.minecraft.potion.PotionEffect"), + @Example(".input(item('minecraft:stone'), item('minecraft:stone'), item('minecraft:stone')).modifier(item('minecraft:clay')).fluidInput(fluid('lava') * 500).advanced().output(item('minecraft:diamond'))"), + @Example(".input(item('minecraft:cobblestone'), item('minecraft:cobblestone')).fluidInput(fluid('lava') * 25).bottle(item('minecraft:bucket')).output(item('minecraft:lava_bucket'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -86,8 +88,11 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(Recipes.condenserRecipes).setRemover(this::remove); } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "2 or 3", type = Comp.Type.LTE)}) - @Property(property = "fluidInput", defaultValue = "fluid('water') * 125", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) + @Property(property = "input", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "2 or 3", type = Comp.Type.LTE)}) + @Property(property = "fluidInput", + defaultValue = "fluid('water') * 125", + valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) @Property(property = "output", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { @@ -139,9 +144,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Rustic Alchemy recipe"; - } + public String getErrorMsg() { return "Error adding Rustic Alchemy recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -152,14 +155,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(time <= 0, "time must be an integer greater than 0, yet it was {}", time); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ICondenserRecipe register() { if (!validate()) return null; - ICondenserRecipe recipe = new CondenserRecipe(output.get(0), input, modifier, bottle, - fluidInput.isEmpty() ? new FluidStack(FluidRegistry.WATER, 125) : fluidInput.getOrEmpty(0), - time, advanced); + ICondenserRecipe recipe = new CondenserRecipe(output.get(0), input, modifier, bottle, fluidInput.isEmpty() ? + new FluidStack(FluidRegistry.WATER, 125) : fluidInput.getOrEmpty(0), time, advanced); ModSupport.RUSTIC.get().alchemy.add(recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/BrewingBarrel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/BrewingBarrel.java index 1b792a4df..61299d799 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/BrewingBarrel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/BrewingBarrel.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.rustic; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,7 +9,7 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import org.jetbrains.annotations.Nullable; + import rustic.common.crafting.BrewingBarrelRecipe; import rustic.common.crafting.IBrewingBarrelRecipe; import rustic.common.crafting.Recipes; @@ -15,10 +17,8 @@ @RegistryDescription public class BrewingBarrel extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('ironberryjuice')).fluidOutput(fluid('lava'))"), - @Example(".fluidInput(fluid('water')).fluidOutput(fluid('lava'))") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('ironberryjuice')).fluidOutput(fluid('lava'))"), + @Example(".fluidInput(fluid('water')).fluidOutput(fluid('lava'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -72,14 +72,11 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(Recipes.brewingRecipes).setRemover(this::remove); } - @Property(property = "fluidInput", valid = @Comp("1")) - @Property(property = "fluidOutput", valid = @Comp("1")) + @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Rustic Brewing Barrel recipe"; - } + public String getErrorMsg() { return "Error adding Rustic Brewing Barrel recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -87,8 +84,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 1, 1, 0, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IBrewingBarrelRecipe register() { if (!validate()) return null; IBrewingBarrelRecipe recipe = new BrewingBarrelRecipe(fluidOutput.get(0), fluidInput.get(0)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CondenserRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CondenserRecipe.java index acd266dab..ccdca0cdb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CondenserRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CondenserRecipe.java @@ -1,19 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.rustic; -import com.cleanroommc.groovyscript.api.IIngredient; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import javax.annotation.Nonnull; + import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import rustic.common.crafting.ICondenserRecipe; -import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; +import com.cleanroommc.groovyscript.api.IIngredient; + +import rustic.common.crafting.ICondenserRecipe; public class CondenserRecipe implements ICondenserRecipe { @@ -39,17 +42,18 @@ public CondenserRecipe(@Nonnull ItemStack output, List inputs, IIng this(output, inputs, modifier, bottle, new FluidStack(FluidRegistry.WATER, 125)); } - public CondenserRecipe(@Nonnull ItemStack output, List inputs, IIngredient modifier, IIngredient bottle, @Nonnull FluidStack fluid) { + public CondenserRecipe(@Nonnull ItemStack output, List inputs, IIngredient modifier, IIngredient bottle, + @Nonnull FluidStack fluid) { this(output, inputs, modifier, bottle, fluid, 400); } - public CondenserRecipe(@Nonnull ItemStack output, List inputs, IIngredient modifier, IIngredient bottle, @Nonnull FluidStack fluid, int time) { + public CondenserRecipe(@Nonnull ItemStack output, List inputs, IIngredient modifier, IIngredient bottle, + @Nonnull FluidStack fluid, int time) { this(output, inputs, modifier, bottle, fluid, time, modifier == null && inputs.size() <= 2); } - public CondenserRecipe( - @Nonnull ItemStack output, List inputs, IIngredient modifier, IIngredient bottle, - @Nonnull FluidStack fluid, int time, boolean advanced) { + public CondenserRecipe(@Nonnull ItemStack output, List inputs, IIngredient modifier, IIngredient bottle, + @Nonnull FluidStack fluid, int time, boolean advanced) { this.output = output; this.fluid = fluid; this.bottle = bottle; @@ -61,10 +65,7 @@ public CondenserRecipe( @Override public boolean matches(Fluid fluid, ItemStack modifier, ItemStack bottle, ItemStack[] inputs) { - if (fluid == this.fluid.getFluid() && - (this.modifier == null || this.modifier.test(modifier)) && - (this.modifier != null || modifier.isEmpty()) && - (this.bottle == null || this.bottle.test(bottle))) { + if (fluid == this.fluid.getFluid() && (this.modifier == null || this.modifier.test(modifier)) && (this.modifier != null || modifier.isEmpty()) && (this.bottle == null || this.bottle.test(bottle))) { List tempInputs = new ArrayList<>(this.inputs); for (ItemStack stack : inputs) { if (stack != null && !stack.isEmpty()) { @@ -80,9 +81,7 @@ public boolean matches(Fluid fluid, ItemStack modifier, ItemStack bottle, ItemSt } } - if (stackNotInput) { - return false; - } + if (stackNotInput) { return false; } } } return tempInputs.isEmpty(); @@ -91,29 +90,19 @@ public boolean matches(Fluid fluid, ItemStack modifier, ItemStack bottle, ItemSt } @Override - public boolean isBasic() { - return !this.advanced; - } + public boolean isBasic() { return !this.advanced; } @Override - public boolean isAdvanced() { - return this.advanced; - } + public boolean isAdvanced() { return this.advanced; } @Override - public FluidStack getFluid() { - return this.fluid; - } + public FluidStack getFluid() { return this.fluid; } @Override - public List getModifiers() { - return modifier == null ? EMPTY_LIST : Arrays.asList(modifier.getMatchingStacks()); - } + public List getModifiers() { return modifier == null ? EMPTY_LIST : Arrays.asList(modifier.getMatchingStacks()); } @Override - public List getBottles() { - return bottle == null ? EMPTY_LIST : Arrays.asList(bottle.getMatchingStacks()); - } + public List getBottles() { return bottle == null ? EMPTY_LIST : Arrays.asList(bottle.getMatchingStacks()); } @Override public List> getInputs() { @@ -121,9 +110,7 @@ public List> getInputs() { } @Override - public int getTime() { - return this.time; - } + public int getTime() { return this.time; } @Override public int getModifierConsumption(ItemStack modifier) { @@ -153,7 +140,5 @@ public int[] getInputConsumption(ItemStack[] inputs) { } @Override - public ItemStack getResult() { - return this.output.copy(); - } + public ItemStack getResult() { return this.output.copy(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CrushingTub.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CrushingTub.java index a0e899536..3baaf4698 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CrushingTub.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CrushingTub.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.rustic; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,8 +11,7 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; + import rustic.common.crafting.CrushingTubRecipe; import rustic.common.crafting.ICrushingTubRecipe; import rustic.common.crafting.Recipes; @@ -16,10 +19,8 @@ @RegistryDescription public class CrushingTub extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:stone')).fluidOutput(fluid('lava') * 50)"), - @Example(".input(item('minecraft:clay')).fluidOutput(fluid('lava') * 20).byproduct(item('minecraft:gold_ingot') * 4)"), - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:stone')).fluidOutput(fluid('lava') * 50)"), + @Example(".input(item('minecraft:clay')).fluidOutput(fluid('lava') * 20).byproduct(item('minecraft:gold_ingot') * 4)"),}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -73,8 +74,7 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(Recipes.crushingTubRecipes).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "fluidOutput", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -87,9 +87,7 @@ public RecipeBuilder byproduct(ItemStack byproduct) { } @Override - public String getErrorMsg() { - return "Error adding Rustic Crushing Tub recipe"; - } + public String getErrorMsg() { return "Error adding Rustic Crushing Tub recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -97,8 +95,7 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg, 0, 0, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ICrushingTubRecipe register() { if (!validate()) return null; ICrushingTubRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/EvaporatingBasin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/EvaporatingBasin.java index 034cbbcff..dc5886f35 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/EvaporatingBasin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/EvaporatingBasin.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.rustic; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,7 +10,7 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import org.jetbrains.annotations.Nullable; + import rustic.common.crafting.IEvaporatingBasinRecipe; import rustic.common.crafting.Recipes; @@ -19,10 +21,8 @@ public EvaporatingBasin() { super(Alias.generateOfClass(EvaporatingBasin.class).andGenerate("DryingBasin")); } - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('water') * 200).output(item('minecraft:clay'))"), - @Example(".fluidInput(fluid('lava') * 50).output(item('minecraft:iron_ingot'))") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('water') * 200).output(item('minecraft:clay'))"), + @Example(".fluidInput(fluid('lava') * 50).output(item('minecraft:iron_ingot'))")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -82,8 +82,7 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(Recipes.evaporatingRecipes).setRemover(this::remove); } - @Property(property = "output", valid = @Comp("1")) - @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "output", valid = @Comp("1")) @Property(property = "fluidInput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "fluidInput amount") @@ -96,9 +95,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Rustic Evaporating Basin recipe"; - } + public String getErrorMsg() { return "Error adding Rustic Evaporating Basin recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -107,8 +104,7 @@ public void validate(GroovyLog.Msg msg) { if (time <= 0) time = fluidInput.get(0).amount; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IEvaporatingBasinRecipe register() { if (!validate()) return null; IEvaporatingBasinRecipe recipe = new ExtendedEvaporatingBasinRecipe(output.get(0), fluidInput.get(0), time); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/ExtendedEvaporatingBasinRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/ExtendedEvaporatingBasinRecipe.java index 458c4acdc..088d052ce 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/ExtendedEvaporatingBasinRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/ExtendedEvaporatingBasinRecipe.java @@ -2,6 +2,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import rustic.common.crafting.EvaporatingBasinRecipe; public class ExtendedEvaporatingBasinRecipe extends EvaporatingBasinRecipe { @@ -14,8 +15,6 @@ public ExtendedEvaporatingBasinRecipe(ItemStack out, FluidStack in, int time) { } @Override - public int getTime() { - return time; - } + public int getTime() { return time; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/HighOven.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/HighOven.java index 6e2133ec0..d428a0825 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/HighOven.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/HighOven.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.tcomplement; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -11,16 +19,11 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.google.common.collect.ImmutableMap; + import knightminer.tcomplement.library.steelworks.*; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; import slimeknights.mantle.util.RecipeMatch; import slimeknights.tconstruct.library.smeltery.MeltingRecipe; -import java.util.Map; - public class HighOven extends MeltingRecipeRegistry { public final Fuel fuel = new Fuel(); @@ -31,8 +34,7 @@ public MeltingRecipeBuilder recipeBuilder() { return new MeltingRecipeBuilder(this, "Tinkers Complement High Oven override"); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(TCompRegistryAccessor.getHighOvenOverrides()::remove); restoreFromBackup().forEach(TCompRegistryAccessor.getHighOvenOverrides()::add); @@ -42,7 +44,8 @@ public void onReload() { } public MeltingRecipe add(IIngredient input, FluidStack output, int temp) { - MeltingRecipe recipe = new MeltingRecipe(MeltingRecipeBuilder.recipeMatchFromIngredient(input, output.amount), output, temp); + MeltingRecipe recipe = new MeltingRecipe(MeltingRecipeBuilder.recipeMatchFromIngredient(input, output.amount), output, + temp); add(recipe); return recipe; } @@ -68,10 +71,8 @@ public boolean removeByOutput(FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Complement High Oven override") - .add("could not find override with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven override").add("could not find override with output {}", + output).error().post(); return false; } @@ -85,10 +86,8 @@ public boolean removeByInput(IIngredient input) { })) return true; list.clear(); - GroovyLog.msg("Error removing Tinkers Complement High Oven override") - .add("could not find override with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven override").add("could not find override with input {}", input) + .error().post(); return false; } @@ -102,10 +101,9 @@ public boolean removeByInputAndOutput(IIngredient input, FluidStack output) { })) return true; list.clear(); - GroovyLog.msg("Error removing Tinkers Complement High Oven override") - .add("could not find override with input {} and output {]", input, output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven override").add( + "could not find override with input {} and output {]", + input, output).error().post(); return false; } @@ -150,10 +148,8 @@ public boolean removeByOutput(FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Complement High Oven Mixing recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven Mixing recipe").add("could not find recipe with output {}", + output).error().post(); return false; } @@ -165,25 +161,23 @@ public boolean removeByInput(FluidStack input) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Complement High Oven Mixing recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven Mixing recipe").add("could not find recipe with input {}", + input).error().post(); return false; } public boolean removeByInputAndOutput(FluidStack input, FluidStack output) { if (TCompRegistryAccessor.getMixRegistry().removeIf(recipe -> { HighOvenFilter recipe1 = (recipe instanceof HighOvenFilter) ? (HighOvenFilter) recipe : null; - boolean found = recipe1 != null && recipe1.getInput().isFluidEqual(input) && recipe1.getOutput().isFluidEqual(output); + boolean found = recipe1 != null && recipe1.getInput().isFluidEqual(input) && recipe1.getOutput().isFluidEqual( + output); if (found) addBackup(recipe); return found; })) return true; - GroovyLog.msg("Error removing Tinkers Complement High Oven Mixing recipe") - .add("could not find recipe with input {} and output {}", input, output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven Mixing recipe").add( + "could not find recipe with input {} and output {}", + input, output).error().post(); return false; } @@ -201,10 +195,9 @@ public boolean removeByAdditives(Map additives) { return false; })) return true; - GroovyLog.msg("Error removing Tinkers Complement High Oven Mixing recipe") - .add("could not find override with additives {}", additives.values()) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven Mixing recipe").add( + "could not find override with additives {}", + additives.values()).error().post(); return false; } @@ -268,14 +261,13 @@ public RecipeBuilder purifier(IIngredient ingredient) { } @Override - public String getErrorMsg() { - return "Error adding Tinkers Complement High Oven Mixing recipe"; - } + public String getErrorMsg() { return "Error adding Tinkers Complement High Oven Mixing recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateFluids(msg, 1, 1, 1, 1); - msg.add(oxidizer == null && reducer == null && purifier == null, "Expected at least one additive, but found none!"); + msg.add(oxidizer == null && reducer == null && purifier == null, + "Expected at least one additive, but found none!"); } @Override @@ -329,10 +321,8 @@ public boolean removeByInput(FluidStack input) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Complement High Oven Heating recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven Heating recipe").add("could not find recipe with input {}", + input).error().post(); return false; } @@ -343,10 +333,9 @@ public boolean removeByOutput(FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Complement High Oven Heating recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven Heating recipe").add( + "could not find recipe with output {}", + output).error().post(); return false; } @@ -357,10 +346,9 @@ public boolean removeByInputAndOutput(FluidStack input, FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Complement High Oven Heating recipe") - .add("could not find recipe with input {} and output {}", input, output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven Heating recipe").add( + "could not find recipe with input {} and output {}", + input, output).error().post(); return false; } @@ -389,9 +377,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Tinkers Complement High Oven Heating recipe"; - } + public String getErrorMsg() { return "Error adding Tinkers Complement High Oven Heating recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -414,8 +400,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(TCompRegistryAccessor.getHighOvenFuels()::remove); restoreFromBackup().forEach(TCompRegistryAccessor.getHighOvenFuels()::add); @@ -447,10 +432,8 @@ public boolean removeByItem(IIngredient item) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Complement High Oven fuel") - .add("could not find override with item {}", item) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement High Oven fuel").add("could not find override with item {}", item) + .error().post(); return false; } @@ -479,9 +462,7 @@ public RecipeBuilder rate(int rate) { } @Override - public String getErrorMsg() { - return "Error adding Tinkers Complement High Oven fuel"; - } + public String getErrorMsg() { return "Error adding Tinkers Complement High Oven fuel"; } @Override public void validate(GroovyLog.Msg msg) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/Melter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/Melter.java index b60b96e9e..2850d67a5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/Melter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/Melter.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.tcomplement; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,10 +13,8 @@ import com.cleanroommc.groovyscript.core.mixin.tcomplement.TCompRegistryAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; + import knightminer.tcomplement.library.IBlacklist; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.fluids.FluidStack; import slimeknights.tconstruct.library.smeltery.MeltingRecipe; public class Melter extends MeltingRecipeRegistry { @@ -24,8 +26,7 @@ public MeltingRecipeBuilder recipeBuilder() { return new MeltingRecipeBuilder(this, "Tinkers Complement Melter override"); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(TCompRegistryAccessor.getMeltingOverrides()::remove); backupStorage.removeScripted().forEach(TCompRegistryAccessor.getMeltingBlacklist()::remove); @@ -40,7 +41,8 @@ public IBlacklist addBlacklist(IIngredient ingredient) { } public MeltingRecipe add(IIngredient input, FluidStack output, int temp) { - MeltingRecipe recipe = new MeltingRecipe(MeltingRecipeBuilder.recipeMatchFromIngredient(input, output.amount), output, temp); + MeltingRecipe recipe = new MeltingRecipe(MeltingRecipeBuilder.recipeMatchFromIngredient(input, output.amount), output, + temp); add(recipe); return recipe; } @@ -79,10 +81,8 @@ public boolean removeFromBlacklist(ItemStack item) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Complement Melter blacklist") - .add("could not find a blacklist for item {}", item) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement Melter blacklist").add("could not find a blacklist for item {}", item) + .error().post(); return false; } @@ -96,10 +96,8 @@ public boolean removeByInput(IIngredient input) { })) return true; list.clear(); - GroovyLog.msg("Error removing Tinkers Complement Melter override") - .add("could not find a override for input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement Melter override").add("could not find a override for input {}", input) + .error().post(); return false; } @@ -110,10 +108,8 @@ public boolean removeByOutput(FluidStack stack) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Complement Melter override") - .add("could not find a override for output {}", stack) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement Melter override").add("could not find a override for output {}", stack) + .error().post(); return false; } @@ -127,10 +123,9 @@ public boolean removeByInputAndOutput(IIngredient input, FluidStack output) { })) return true; list.clear(); - GroovyLog.msg("Error removing Tinkers Complement Melter override") - .add("could not find a override for input {} and output {}", input, output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Complement Melter override").add( + "could not find a override for input {} and output {}", + input, output).error().post(); return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/recipe/IngredientBlacklist.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/recipe/IngredientBlacklist.java index d189f6183..b8c0623f5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/recipe/IngredientBlacklist.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/recipe/IngredientBlacklist.java @@ -1,8 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.tcomplement.recipe; +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.IIngredient; + import knightminer.tcomplement.library.IBlacklist; -import net.minecraft.item.ItemStack; public class IngredientBlacklist implements IBlacklist { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Crucible.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Crucible.java index 0b9992657..e91a87a66 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Crucible.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Crucible.java @@ -1,5 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -10,10 +22,7 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; + import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; @@ -21,12 +30,6 @@ import thaumcraft.api.crafting.IThaumcraftRecipe; import thaumcraft.common.config.ConfigRecipes; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - @RegistryDescription public class Crucible extends VirtualizedRegistry { @@ -35,14 +38,14 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> ThaumcraftApi.getCraftingRecipes().values().remove(recipe)); restoreFromBackup().forEach(recipe -> { - if (!ThaumcraftApi.getCraftingRecipes().containsValue(recipe)) - ThaumcraftApi.addCrucibleRecipe(new ResourceLocation(recipe.getRecipeOutput().toString()), recipe); + if (!ThaumcraftApi.getCraftingRecipes().containsValue(recipe)) ThaumcraftApi.addCrucibleRecipe(new ResourceLocation( + recipe.getRecipeOutput() + .toString()), + recipe); }); ConfigRecipes.compileGroups(); } @@ -68,9 +71,7 @@ public boolean remove(CrucibleRecipe recipe) { Object r; do { - if (!recipeIterator.hasNext()) { - return false; - } + if (!recipeIterator.hasNext()) { return false; } r = recipeIterator.next(); } while (!(r instanceof CrucibleRecipe) || !((CrucibleRecipe) r).getRecipeOutput().isItemEqual(recipe.getRecipeOutput())); @@ -84,10 +85,7 @@ public boolean remove(CrucibleRecipe recipe) { @MethodDescription(example = @Example("item('minecraft:gunpowder')")) public void removeByOutput(IIngredient output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Thaumcraft Crucible recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Thaumcraft Crucible recipe").add("output must not be empty").error().post(); } Object r; List recipes = new ArrayList<>(); @@ -98,10 +96,7 @@ public void removeByOutput(IIngredient output) { } } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Thaumcraft Crucible recipe") - .add("no recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Thaumcraft Crucible recipe").add("no recipes found for {}", output).error().post(); return; } recipes.forEach(recipe -> { @@ -112,14 +107,17 @@ public void removeByOutput(IIngredient output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - List> recipes = ThaumcraftApi.getCraftingRecipes().entrySet().stream().filter(x -> x.getValue() instanceof CrucibleRecipe).collect(Collectors.toList()); - return new SimpleObjectStream<>(recipes) - .setRemover(x -> remove((CrucibleRecipe) x)); + List> recipes = ThaumcraftApi.getCraftingRecipes().entrySet().stream() + .filter(x -> x.getValue() instanceof CrucibleRecipe) + .collect(Collectors.toList()); + return new SimpleObjectStream<>(recipes).setRemover(x -> remove((CrucibleRecipe) x)); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - List> recipes = ThaumcraftApi.getCraftingRecipes().entrySet().stream().filter(x -> x.getValue() instanceof CrucibleRecipe).collect(Collectors.toList()); + List> recipes = ThaumcraftApi.getCraftingRecipes().entrySet().stream() + .filter(x -> x.getValue() instanceof CrucibleRecipe) + .collect(Collectors.toList()); for (Map.Entry recipe : recipes) { addBackup((CrucibleRecipe) recipe.getValue()); ThaumcraftApi.getCraftingRecipes().remove(recipe.getKey(), recipe.getValue()); @@ -161,9 +159,7 @@ public RecipeBuilder catalyst(IIngredient catalyst) { } @Override - public String getErrorMsg() { - return "Error adding Thaumcraft Crucible recipe"; - } + public String getErrorMsg() { return "Error adding Thaumcraft Crucible recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -173,8 +169,7 @@ public void validate(GroovyLog.Msg msg) { if (researchKey == null) researchKey = ""; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CrucibleRecipe register() { if (!validate()) return null; return ModSupport.THAUMCRAFT.get().crucible.add(researchKey, this.output.get(0), catalyst, aspects); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/DustTrigger.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/DustTrigger.java index 2e3720383..2b04816d6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/DustTrigger.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/DustTrigger.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft; +import java.lang.reflect.Field; +import java.util.Iterator; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,22 +15,15 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + import thaumcraft.api.crafting.IDustTrigger; import thaumcraft.common.lib.crafting.DustTriggerOre; import thaumcraft.common.lib.crafting.DustTriggerSimple; -import java.lang.reflect.Field; -import java.util.Iterator; - @RegistryDescription public class DustTrigger extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(this::remove); restoreFromBackup().forEach(this::add); @@ -59,17 +60,16 @@ public boolean remove(IDustTrigger trigger) { boolean found = false; while (it.hasNext()) { final IDustTrigger registeredTrigger = it.next(); - if (trigger instanceof DustTriggerSimple && registeredTrigger instanceof DustTriggerSimple - && trigger.equals(registeredTrigger)) { - it.remove(); - addBackup(trigger); - found = true; - } else if (trigger instanceof DustTriggerOre && registeredTrigger instanceof DustTriggerOre - && trigger.equals(registeredTrigger)) { + if (trigger instanceof DustTriggerSimple && registeredTrigger instanceof DustTriggerSimple && trigger.equals(registeredTrigger)) { it.remove(); addBackup(trigger); found = true; - } + } else if (trigger instanceof DustTriggerOre && registeredTrigger instanceof DustTriggerOre && trigger.equals( + registeredTrigger)) { + it.remove(); + addBackup(trigger); + found = true; + } } return found; } @@ -81,15 +81,14 @@ public void removeByOutput(ItemStack output) { while (it.hasNext()) { final IDustTrigger trigger = it.next(); try { - if (trigger instanceof DustTriggerSimple && simpleTriggerResult != null - && output.isItemEqual((ItemStack) simpleTriggerResult.get(trigger))) { - it.remove(); - addBackup(trigger); - } else if (trigger instanceof DustTriggerOre && oreTriggerResult != null - && output.isItemEqual((ItemStack) oreTriggerResult.get(trigger))) { + if (trigger instanceof DustTriggerSimple && simpleTriggerResult != null && output.isItemEqual((ItemStack) simpleTriggerResult.get(trigger))) { it.remove(); addBackup(trigger); - } + } else if (trigger instanceof DustTriggerOre && oreTriggerResult != null && output.isItemEqual( + (ItemStack) oreTriggerResult.get(trigger))) { + it.remove(); + addBackup(trigger); + } } catch (IllegalAccessException e) { GroovyLog.msg("Error while applying Salis Mundus effect: " + e).error().post(); } @@ -98,14 +97,11 @@ public void removeByOutput(ItemStack output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(IDustTrigger.triggers) - .setRemover(this::remove); + return new SimpleObjectStream<>(IDustTrigger.triggers).setRemover(this::remove); } - @RecipeBuilderDescription(example = { - @Example(".researchKey('UNLOCKALCHEMY@3').target(block('minecraft:obsidian')).output(item('minecraft:enchanting_table'))"), - @Example(".researchKey('UNLOCKALCHEMY@3').target(ore('cropPumpkin')).output(item('minecraft:lit_pumpkin'))") - }) + @RecipeBuilderDescription(example = {@Example(".researchKey('UNLOCKALCHEMY@3').target(block('minecraft:obsidian')).output(item('minecraft:enchanting_table'))"), + @Example(".researchKey('UNLOCKALCHEMY@3').target(ore('cropPumpkin')).output(item('minecraft:lit_pumpkin'))")}) public TriggerBuilder triggerBuilder() { return new TriggerBuilder(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/InfusionCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/InfusionCrafting.java index 988af94f8..f238a6476 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/InfusionCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/InfusionCrafting.java @@ -1,5 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft; +import static thaumcraft.common.config.ConfigRecipes.compileGroups; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.util.ResourceLocation; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,26 +28,13 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.helper.recipe.RecipeName; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; + import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.crafting.IThaumcraftRecipe; import thaumcraft.api.crafting.InfusionRecipe; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static thaumcraft.common.config.ConfigRecipes.compileGroups; - @RegistryDescription public class InfusionCrafting extends VirtualizedRegistry> { @@ -40,9 +43,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> ThaumcraftApi.getCraftingRecipes().remove(recipe.getKey(), recipe.getValue())); restoreFromBackup().forEach(recipe -> ThaumcraftApi.addInfusionCraftingRecipe(recipe.getKey(), recipe.getValue())); @@ -58,9 +59,11 @@ public void add(ResourceLocation rl, InfusionRecipe recipe) { } @MethodDescription(type = MethodDescription.Type.ADDITION) - public InfusionRecipe add(String research, ItemStack outputResult, int inst, Collection aspects, IIngredient centralItem, IIngredient... input) { + public InfusionRecipe add(String research, ItemStack outputResult, int inst, Collection aspects, + IIngredient centralItem, IIngredient... input) { Object[] inputs = ArrayUtils.map(input, IIngredient::toMcIngredient, new Ingredient[0]); - InfusionRecipe infusionRecipe = new InfusionRecipe(research, outputResult, inst, Thaumcraft.makeAspectList(aspects), centralItem.toMcIngredient(), inputs); + InfusionRecipe infusionRecipe = new InfusionRecipe(research, outputResult, inst, Thaumcraft.makeAspectList(aspects), + centralItem.toMcIngredient(), inputs); add(RecipeName.generateRl("infusion_matrix_recipe"), infusionRecipe); return infusionRecipe; } @@ -68,8 +71,7 @@ public InfusionRecipe add(String research, ItemStack outputResult, int inst, Col public boolean remove(InfusionRecipe recipe) { List recipes = new ArrayList<>(); for (IThaumcraftRecipe r : ThaumcraftApi.getCraftingRecipes().values()) { - if (r instanceof InfusionRecipe && r.equals(recipe)) - recipes.add((InfusionRecipe) r); + if (r instanceof InfusionRecipe && r.equals(recipe)) recipes.add((InfusionRecipe) r); } recipes.forEach(rec -> { if ("".equals(rec.getGroup())) { @@ -85,10 +87,7 @@ public boolean remove(InfusionRecipe recipe) { @MethodDescription(example = @Example("item('thaumcraft:crystal_terra')")) public void removeByOutput(IIngredient output) { if (IngredientHelper.isEmpty(output)) { - GroovyLog.msg("Error removing Thaumcraft Infusion Crafting recipe") - .add("output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Thaumcraft Infusion Crafting recipe").add("output must not be empty").error().post(); return; } List recipes = new ArrayList<>(); @@ -100,15 +99,14 @@ public void removeByOutput(IIngredient output) { } } if (recipes.isEmpty()) { - GroovyLog.msg("Error removing Thaumcraft Infusion Crafting recipe") - .add("no recipes found for {}", output.toString()) - .error() - .post(); + GroovyLog.msg("Error removing Thaumcraft Infusion Crafting recipe").add("no recipes found for {}", output.toString()) + .error().post(); return; } recipes.forEach(recipe -> { if ("".equals(recipe.getGroup())) { - this.addBackup(Pair.of(new ResourceLocation("thaumcraft:" + ((ItemStack) recipe.recipeOutput).getItem()), recipe)); + this.addBackup(Pair.of(new ResourceLocation("thaumcraft:" + ((ItemStack) recipe.recipeOutput).getItem()), + recipe)); } else { this.addBackup(Pair.of(new ResourceLocation(recipe.getGroup()), recipe)); } @@ -118,14 +116,17 @@ public void removeByOutput(IIngredient output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - List> recipes = ThaumcraftApi.getCraftingRecipes().entrySet().stream().filter(x -> x.getValue() instanceof InfusionRecipe).collect(Collectors.toList()); - return new SimpleObjectStream<>(recipes) - .setRemover(x -> remove((InfusionRecipe) x.getValue())); + List> recipes = ThaumcraftApi.getCraftingRecipes().entrySet().stream() + .filter(x -> x.getValue() instanceof InfusionRecipe) + .collect(Collectors.toList()); + return new SimpleObjectStream<>(recipes).setRemover(x -> remove((InfusionRecipe) x.getValue())); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - List> recipes = ThaumcraftApi.getCraftingRecipes().entrySet().stream().filter(x -> x.getValue() instanceof InfusionRecipe).collect(Collectors.toList()); + List> recipes = ThaumcraftApi.getCraftingRecipes().entrySet().stream() + .filter(x -> x.getValue() instanceof InfusionRecipe) + .collect(Collectors.toList()); for (Map.Entry recipe : recipes) { addBackup(Pair.of(recipe.getKey(), (InfusionRecipe) recipe.getValue())); ThaumcraftApi.getCraftingRecipes().remove(recipe.getKey(), recipe.getValue()); @@ -175,9 +176,7 @@ public RecipeBuilder instability(int instability) { } @Override - public String getErrorMsg() { - return "Error adding Thaumcraft Infusion Crafting recipe"; - } + public String getErrorMsg() { return "Error adding Thaumcraft Infusion Crafting recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -191,13 +190,14 @@ public void validate(GroovyLog.Msg msg) { } } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable InfusionRecipe register() { if (!validate()) return null; Object[] inputs = this.input.stream().map(IIngredient::toMcIngredient).toArray(); - InfusionRecipe recipe = new InfusionRecipe(researchKey, output.get(0), instability, aspects, mainInput.toMcIngredient(), inputs); + InfusionRecipe recipe = new InfusionRecipe(researchKey, output.get(0), instability, aspects, mainInput + .toMcIngredient(), + inputs); ModSupport.THAUMCRAFT.get().infusionCrafting.add(RecipeName.generateRl("infusion_matrix_recipe"), recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/LootBag.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/LootBag.java index b5931557f..de11fb752 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/LootBag.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/LootBag.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; @@ -8,39 +15,27 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.internal.WeightedRandomLoot; -import java.util.ArrayList; -import java.util.List; - -@RegistryDescription( - isFullyDocumented = false, - admonition = @Admonition(value = "groovyscript.wiki.thaumcraft.loot_bag.note", type = Admonition.Type.BUG, format = Admonition.Format.STANDARD) -) +@RegistryDescription(isFullyDocumented = false, + admonition = @Admonition(value = "groovyscript.wiki.thaumcraft.loot_bag.note", + type = Admonition.Type.BUG, + format = Admonition.Format.STANDARD)) public class LootBag extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(bag -> getLootbag(bag.getRarity()).removeIf(x -> x.item == bag.getItem() && x.itemWeight == bag.weight)); restoreFromBackup().forEach(bag -> ThaumcraftApi.addLootBagItem(bag.getItem(), bag.getWeight(), bag.getRarity())); } - public static LootBagHelper getCommon() { - return new LootBagHelper(0); - } + public static LootBagHelper getCommon() { return new LootBagHelper(0); } - public static LootBagHelper getUncommon() { - return new LootBagHelper(1); - } + public static LootBagHelper getUncommon() { return new LootBagHelper(1); } - public static LootBagHelper getRare() { - return new LootBagHelper(2); - } + public static LootBagHelper getRare() { return new LootBagHelper(2); } private static ArrayList getLootbag(int rarity) { return switch (rarity) { @@ -48,16 +43,16 @@ private static ArrayList getLootbag(int rarity) { case 1 -> WeightedRandomLoot.lootBagUncommon; case 2 -> WeightedRandomLoot.lootBagRare; default -> { - GroovyLog.msg("Error: Thaumcraft Lootbag type not specified. Please use Lootbag.getCommon(), Lootbag.getUncommon(), or Lootbag.getRare().").error().post(); + GroovyLog.msg("Error: Thaumcraft Lootbag type not specified. Please use Lootbag.getCommon(), Lootbag.getUncommon(), or Lootbag.getRare().") + .error().post(); yield new ArrayList<>(); } }; } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = { - @Example("item('minecraft:diamond_block'), 100, 2"), - @Example("item('minecraft:dirt'), 100, 0") - }) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = {@Example("item('minecraft:diamond_block'), 100, 2"), + @Example("item('minecraft:dirt'), 100, 0")}) public void add(ItemStack item, int chance, int rarity) { ThaumcraftApi.addLootBagItem(item, chance, rarity); addScripted(new InternalLootbag(item, chance, rarity)); @@ -120,17 +115,11 @@ private InternalLootbag(ItemStack item, int weight, int rarity) { this.rarity = rarity; } - public ItemStack getItem() { - return item; - } + public ItemStack getItem() { return item; } - public int getWeight() { - return weight; - } + public int getWeight() { return weight; } - public int getRarity() { - return rarity; - } + public int getRarity() { return rarity; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Research.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Research.java index db63c5e99..f7df3eb0b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Research.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Research.java @@ -1,16 +1,18 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft; -import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect.AspectStack; -import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.util.ResourceLocation; + +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect.AspectStack; +import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; @@ -45,12 +47,15 @@ private void removeCategory(ResearchCategory category) { @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addCategory0", type = MethodDescription.Type.ADDITION) public void addCategory(String key, String researchkey, AspectList formula, String icon, String background) { - addCategory(new ResearchCategory(key, researchkey, formula, new ResourceLocation(icon), new ResourceLocation(background))); + addCategory(new ResearchCategory(key, researchkey, formula, new ResourceLocation(icon), new ResourceLocation( + background))); } @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addCategory1", type = MethodDescription.Type.ADDITION) - public void addCategory(String key, String researchkey, AspectList formula, String icon, String background, String background2) { - addCategory(new ResearchCategory(key, researchkey, formula, new ResourceLocation(icon), new ResourceLocation(background), new ResourceLocation(background2))); + public void addCategory(String key, String researchkey, AspectList formula, String icon, String background, + String background2) { + addCategory(new ResearchCategory(key, researchkey, formula, new ResourceLocation(icon), new ResourceLocation(background), + new ResourceLocation(background2))); } private void addScannable(IScanThing scanThing) { @@ -58,52 +63,64 @@ private void addScannable(IScanThing scanThing) { ScanningManager.addScannableThing(scanThing); } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable0", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable0", + type = MethodDescription.Type.ADDITION) public void addScannable(String researchKey, Class entityClass, boolean inheritedClasses) { addScannable(new ScanEntity(researchKey, entityClass, inheritedClasses)); } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable1", type = MethodDescription.Type.ADDITION) - public void addScannable(String researchKey, Class entityClass, boolean inheritedClasses, ThaumcraftApi.EntityTagsNBT tags) { + @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable1", + type = MethodDescription.Type.ADDITION) + public void addScannable(String researchKey, Class entityClass, boolean inheritedClasses, + ThaumcraftApi.EntityTagsNBT tags) { addScannable(new ScanEntity(researchKey, entityClass, inheritedClasses, tags)); } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable2", type = MethodDescription.Type.ADDITION, example = @Example("'KNOWLEDGETYPEHUMOR', item('minecraft:pumpkin')")) + @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable2", + type = MethodDescription.Type.ADDITION, + example = @Example("'KNOWLEDGETYPEHUMOR', item('minecraft:pumpkin')")) public void addScannable(String researchKey, ItemStack item) { addScannable(new ScanItem(researchKey, item)); } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable3", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable3", + type = MethodDescription.Type.ADDITION) public void addScannable(Block block) { addScannable(new ScanBlock(block)); } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable4", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable4", + type = MethodDescription.Type.ADDITION) public void addScannable(String researchKey, Block block) { addScannable(new ScanBlock(researchKey, block)); } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable5", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable5", + type = MethodDescription.Type.ADDITION) public void addScannable(Material material) { addScannable(new ScanMaterial(material)); } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable6", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable6", + type = MethodDescription.Type.ADDITION) public void addScannable(String researchKey, Material material) { addScannable(new ScanMaterial(researchKey, material)); } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable7", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable7", + type = MethodDescription.Type.ADDITION) public void addScannable(Enchantment enchantment) { addScannable(new ScanEnchantment(enchantment)); } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable8", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.thaumcraft.research.addScannable8", + type = MethodDescription.Type.ADDITION) public void addScannable(Potion potion) { addScannable(new ScanPotion(potion)); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "resource('thaumcraft:research/new.json')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "resource('thaumcraft:research/new.json')", commented = true)) public void addResearchLocation(ResourceLocation location) { ThaumcraftApi.registerResearchLocation(location); ResearchManager.parseAllResearch(); @@ -233,9 +250,8 @@ public ResearchCategoryBuilder background2(String mod, String background2) { @RecipeBuilderRegistrationMethod public ResearchCategory register() { - ResearchCategory category = background2 == null - ? new ResearchCategory(key, researchKey, formula, icon, background) - : new ResearchCategory(key, researchKey, formula, icon, background, background2); + ResearchCategory category = background2 == null ? new ResearchCategory(key, researchKey, formula, icon, background) : + new ResearchCategory(key, researchKey, formula, icon, background, background2); ModSupport.THAUMCRAFT.get().research.addCategory(category); return category; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/SmeltingBonus.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/SmeltingBonus.java index 48e0eb9c9..bb99d8d5f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/SmeltingBonus.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/SmeltingBonus.java @@ -1,5 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -8,21 +16,14 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.internal.CommonInternals; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - @RegistryDescription public class SmeltingBonus extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(this::remove); restoreFromBackup().forEach(this::add); @@ -85,10 +86,8 @@ public void removeAll() { CommonInternals.smeltingBonus.clear(); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:cobblestone')).output(item('minecraft:stone_button')).chance(0.2F)"), - @Example(".input(ore('stone')).output(item('minecraft:obsidian'))") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:cobblestone')).output(item('minecraft:stone_button')).chance(0.2F)"), + @Example(".input(ore('stone')).output(item('minecraft:obsidian'))")}) public SmeltingBonusBuilder recipeBuilder() { return new SmeltingBonusBuilder(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Thaumcraft.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Thaumcraft.java index 8486e1e30..ebd9a9273 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Thaumcraft.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Thaumcraft.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft; +import java.util.Collection; + +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IObjectParser; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; @@ -12,12 +16,10 @@ import com.cleanroommc.groovyscript.compat.mods.thaumcraft.warp.Warp; import com.cleanroommc.groovyscript.compat.mods.thaumcraft.warp.WarpItemStackExpansion; import com.cleanroommc.groovyscript.sandbox.expand.ExpansionHelper; -import net.minecraft.item.ItemStack; + import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.aspects.AspectList; -import java.util.Collection; - public class Thaumcraft extends GroovyPropertyContainer { public final Crucible crucible = new Crucible(); @@ -34,17 +36,14 @@ public class Thaumcraft extends GroovyPropertyContainer { @Override public void initialize(GroovyContainer container) { - container.objectMapperBuilder("aspect", AspectStack.class) - .parser(IObjectParser.wrapStringGetter(Thaumcraft::getAspect, AspectStack::new)) - .completerOfNames(thaumcraft.api.aspects.Aspect.aspects::keySet) - .docOfType("aspect stack") - .register(); - container.objectMapperBuilder("crystal", ItemStack.class) - .parser(IObjectParser.wrapStringGetter(Thaumcraft::getAspect, ThaumcraftApiHelper::makeCrystal)) - .completerOfNames(thaumcraft.api.aspects.Aspect.aspects::keySet) - .defaultValue(() -> ItemStack.EMPTY) - .docOfType("aspect crystal as item stack") - .register(); + container.objectMapperBuilder("aspect", AspectStack.class).parser(IObjectParser.wrapStringGetter(Thaumcraft::getAspect, + AspectStack::new)) + .completerOfNames(thaumcraft.api.aspects.Aspect.aspects::keySet).docOfType("aspect stack").register(); + container.objectMapperBuilder("crystal", ItemStack.class).parser(IObjectParser.wrapStringGetter(Thaumcraft::getAspect, + ThaumcraftApiHelper::makeCrystal)) + .completerOfNames(thaumcraft.api.aspects.Aspect.aspects::keySet).defaultValue(() -> ItemStack.EMPTY).docOfType( + "aspect crystal as item stack") + .register(); ExpansionHelper.mixinClass(ItemStack.class, AspectItemStackExpansion.class); ExpansionHelper.mixinClass(ItemStack.class, WarpItemStackExpansion.class); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneRecipeBuilder.java index 5b04d4b94..56322d2da 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneRecipeBuilder.java @@ -1,5 +1,8 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.arcane; +import net.minecraft.item.crafting.IRecipe; +import net.minecraftforge.fml.common.registry.ForgeRegistries; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Property; import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderMethodDescription; @@ -9,8 +12,7 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.AbstractCraftingRecipeBuilder; import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; -import net.minecraft.item.crafting.IRecipe; -import net.minecraftforge.fml.common.registry.ForgeRegistries; + import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; @@ -51,46 +53,61 @@ public Shaped() { super(3, 3); } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public ArcaneRecipeBuilder researchKey(String researchKey) { this.researchKey = researchKey; return this; } - @Override - @RecipeBuilderMethodDescription(field = "aspects") + @Override @RecipeBuilderMethodDescription(field = "aspects") public ArcaneRecipeBuilder aspect(AspectStack aspect) { this.aspects.add(aspect.getAspect(), aspect.getAmount()); return this; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public ArcaneRecipeBuilder vis(int vis) { this.vis = vis; return this; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_shaped_arcane_"; - } + public String getRecipeNamePrefix() { return "groovyscript_shaped_arcane_"; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IRecipe register() { - GroovyLog.Msg msg = GroovyLog.msg("Error creating Thaumcraft Arcane Workbench recipe").error() - .add((keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), () -> "No matrix was defined") - .add(keyBasedMatrix != null && ingredientMatrix != null, () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!"); + GroovyLog.Msg msg = GroovyLog.msg("Error creating Thaumcraft Arcane Workbench recipe").error().add( + (keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), + () -> "No matrix was defined") + .add(keyBasedMatrix != null && ingredientMatrix != null, + () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!"); if (msg.postIfNotEmpty()) return null; msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); ShapedArcaneCR recipe = null; if (keyBasedMatrix != null) { - recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> new ShapedArcaneCR(output, ingredients, width1, height1, mirrored, recipeFunction, recipeAction, researchKey, vis, aspects))); + recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> new ShapedArcaneCR( + output, + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction, + researchKey, + vis, + aspects))); } else if (ingredientMatrix != null) { - recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> new ShapedArcaneCR(output.copy(), ingredients, width1, height1, mirrored, recipeFunction, recipeAction, researchKey, vis, aspects))); + recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> new ShapedArcaneCR(output.copy(), + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction, + researchKey, + vis, + aspects))); } if (recipe != null) { @@ -118,46 +135,44 @@ public Shapeless() { super(3, 3); } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public ArcaneRecipeBuilder researchKey(String researchKey) { this.researchKey = researchKey; return this; } - @Override - @RecipeBuilderMethodDescription(field = "aspects") + @Override @RecipeBuilderMethodDescription(field = "aspects") public ArcaneRecipeBuilder aspect(AspectStack aspect) { this.aspects.add(aspect.getAspect(), aspect.getAmount()); return this; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public ArcaneRecipeBuilder vis(int vis) { this.vis = vis; return this; } @Override - public String getRecipeNamePrefix() { - return "groovyscript_shapeless_arcane_"; - } + public String getRecipeNamePrefix() { return "groovyscript_shapeless_arcane_"; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IRecipe register() { IngredientHelper.trim(ingredients); - GroovyLog.Msg msg = GroovyLog.msg("Error adding Minecraft Shapeless Crafting recipe") - .add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty") - .add(ingredients.isEmpty(), () -> "inputs must not be empty") - .add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + ingredients.size()) - .error(); - if (msg.postIfNotEmpty()) { - return null; - } + GroovyLog.Msg msg = GroovyLog.msg("Error adding Minecraft Shapeless Crafting recipe").add(IngredientHelper.isEmpty( + this.output), + () -> "Output must not be empty") + .add(ingredients.isEmpty(), () -> "inputs must not be empty").add(ingredients + .size() > width * height, + () -> "maximum inputs are " + + (width * height) + + " but found " + + ingredients.size()) + .error(); + if (msg.postIfNotEmpty()) { return null; } handleReplace(); - ShapelessArcaneCR recipe = new ShapelessArcaneCR(output.copy(), ingredients, recipeFunction, recipeAction, researchKey, vis, aspects); + ShapelessArcaneCR recipe = new ShapelessArcaneCR(output.copy(), ingredients, recipeFunction, recipeAction, + researchKey, vis, aspects); validateName(); ReloadableRegistryManager.addRegistryEntry(ForgeRegistries.RECIPES, name, recipe); return recipe; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneWorkbench.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneWorkbench.java index fbdb781e1..991da0a92 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneWorkbench.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneWorkbench.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.arcane; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.ForgeRegistries; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -8,13 +15,8 @@ import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.registry.NamedRegistry; import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import thaumcraft.api.crafting.IArcaneRecipe; -import java.util.List; -import java.util.stream.Collectors; +import thaumcraft.api.crafting.IArcaneRecipe; @RegistryDescription public class ArcaneWorkbench extends NamedRegistry { @@ -35,10 +37,8 @@ public void removeByOutput(IIngredient output) { VanillaModule.crafting.removeByOutput(output, true); } - @RecipeBuilderDescription(example = { - @Example(".researchKey('UNLOCKALCHEMY@3').output(item('minecraft:pumpkin')).row('SS ').row(' ').row(' ').key('S', item('minecraft:pumpkin_seeds')).aspect('terra').vis(5)"), - @Example(".researchKey('UNLOCKALCHEMY@3').output(item('minecraft:clay')).matrix('SS ',' ',' ').key('S', item('minecraft:pumpkin')).aspect(aspect('terra')).vis(5)") - }) + @RecipeBuilderDescription(example = {@Example(".researchKey('UNLOCKALCHEMY@3').output(item('minecraft:pumpkin')).row('SS ').row(' ').row(' ').key('S', item('minecraft:pumpkin_seeds')).aspect('terra').vis(5)"), + @Example(".researchKey('UNLOCKALCHEMY@3').output(item('minecraft:clay')).matrix('SS ',' ',' ').key('S', item('minecraft:pumpkin')).aspect(aspect('terra')).vis(5)")}) public ArcaneRecipeBuilder.Shaped shapedBuilder() { return new ArcaneRecipeBuilder.Shaped(); } @@ -50,14 +50,12 @@ public ArcaneRecipeBuilder.Shapeless shapelessBuilder() { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - List recipes = ForgeRegistries.RECIPES.getValuesCollection().stream() - .filter(recipe -> recipe instanceof IArcaneRecipe) - .map(recipe -> (IArcaneRecipe) recipe) - .collect(Collectors.toList()); + List recipes = ForgeRegistries.RECIPES.getValuesCollection().stream().filter( + recipe -> recipe instanceof IArcaneRecipe) + .map(recipe -> (IArcaneRecipe) recipe).collect(Collectors.toList()); for (IRecipe recipe : recipes) { ReloadableRegistryManager.removeRegistryEntry(ForgeRegistries.RECIPES, recipe.getRegistryName()); } } } - diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ShapedArcaneCR.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ShapedArcaneCR.java index fda069210..38a956586 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ShapedArcaneCR.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ShapedArcaneCR.java @@ -1,17 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.arcane; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.compat.vanilla.ICraftingRecipe; -import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; -import groovy.lang.Closure; +import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.common.crafting.CraftingHelper; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.compat.vanilla.ICraftingRecipe; +import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; + +import groovy.lang.Closure; import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; @@ -20,8 +25,6 @@ import thaumcraft.api.crafting.ShapedArcaneRecipe; import thaumcraft.api.items.ItemsTC; -import java.util.List; - /** * A thaum shaped recipe wrapping a groovy recipe * Yes this needs to be done @@ -31,32 +34,24 @@ public class ShapedArcaneCR extends ShapedArcaneRecipe implements ICraftingRecip private static final CraftingHelper.ShapedPrimer DEF_PRIMER = new CraftingHelper.ShapedPrimer(); private final ShapedCraftingRecipe craftingRecipe; - public ShapedArcaneCR(ItemStack output, List input, int width, int height, boolean mirrored, @Nullable Closure recipeFunction, @Nullable Closure recipeAction, String research, int vis, AspectList crystals) { + public ShapedArcaneCR(ItemStack output, List input, int width, int height, boolean mirrored, + @Nullable Closure recipeFunction, @Nullable Closure recipeAction, String research, + int vis, AspectList crystals) { super(ArcaneWorkbench.DEFAULT, research, vis, crystals, output, DEF_PRIMER); this.craftingRecipe = new ShapedCraftingRecipe(output, input, width, height, mirrored, recipeFunction, recipeAction); } @Override - public int getRecipeWidth() { - return craftingRecipe.getRecipeWidth(); - } + public int getRecipeWidth() { return craftingRecipe.getRecipeWidth(); } - @Override - @SuppressWarnings("deprecation") - public int getWidth() { - return craftingRecipe.getRecipeWidth(); - } + @Override @SuppressWarnings("deprecation") + public int getWidth() { return craftingRecipe.getRecipeWidth(); } @Override - public int getRecipeHeight() { - return craftingRecipe.getRecipeHeight(); - } + public int getRecipeHeight() { return craftingRecipe.getRecipeHeight(); } - @Override - @SuppressWarnings("deprecation") - public int getHeight() { - return craftingRecipe.getRecipeHeight(); - } + @Override @SuppressWarnings("deprecation") + public int getHeight() { return craftingRecipe.getRecipeHeight(); } @Override public boolean canFit(int width, int height) { @@ -64,9 +59,7 @@ public boolean canFit(int width, int height) { } @Override - public boolean isDynamic() { - return craftingRecipe.isDynamic(); - } + public boolean isDynamic() { return craftingRecipe.isDynamic(); } @Override public @NotNull ItemStack getCraftingResult(@NotNull InventoryCrafting inv) { @@ -74,26 +67,16 @@ public boolean isDynamic() { } @Override - public @NotNull ItemStack getRecipeOutput() { - return craftingRecipe.getRecipeOutput(); - } + public @NotNull ItemStack getRecipeOutput() { return craftingRecipe.getRecipeOutput(); } - @Override - @Nullable - public Closure getRecipeAction() { - return craftingRecipe.getRecipeAction(); - } + @Override @Nullable + public Closure getRecipeAction() { return craftingRecipe.getRecipeAction(); } - @Override - @Nullable - public Closure getRecipeFunction() { - return craftingRecipe.getRecipeFunction(); - } + @Override @Nullable + public Closure getRecipeFunction() { return craftingRecipe.getRecipeFunction(); } @Override - public @NotNull NonNullList getIngredients() { - return craftingRecipe.getIngredients(); - } + public @NotNull NonNullList getIngredients() { return craftingRecipe.getIngredients(); } @Override public @NotNull NonNullList getRemainingItems(@NotNull InventoryCrafting inv) { @@ -102,9 +85,7 @@ public Closure getRecipeFunction() { @Override public boolean matches(@NotNull InventoryCrafting inv, @NotNull World worldIn) { - if (!(inv instanceof IArcaneWorkbench) || inv.getSizeInventory() < 15) { - return false; - } + if (!(inv instanceof IArcaneWorkbench) || inv.getSizeInventory() < 15) { return false; } InventoryCrafting dummy = new InventoryCrafting(new ContainerDummy(), 3, 3); for (int a = 0; a < 9; ++a) { @@ -122,14 +103,13 @@ public boolean matches(@NotNull InventoryCrafting inv, @NotNull World worldIn) { for (int i = 0; i < 6; ++i) { ItemStack itemstack1 = inv.getStackInSlot(9 + i); - if (itemstack1 != null && itemstack1.getItem() == ItemsTC.crystalEssence && itemstack1.getCount() >= cs.getCount() && ItemStack.areItemStackTagsEqual(cs, itemstack1)) { + if (itemstack1 != null && itemstack1.getItem() == ItemsTC.crystalEssence && itemstack1.getCount() >= cs.getCount() && ItemStack.areItemStackTagsEqual(cs, + itemstack1)) { b = true; } } - if (!b) { - return false; - } + if (!b) { return false; } } } return craftingRecipe.matches(dummy, worldIn); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ShapelessArcaneCR.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ShapelessArcaneCR.java index 433c1510b..0120f4a4d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ShapelessArcaneCR.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ShapelessArcaneCR.java @@ -1,16 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.arcane; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.compat.vanilla.ICraftingRecipe; -import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; -import groovy.lang.Closure; +import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.NonNullList; import net.minecraft.world.World; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.compat.vanilla.ICraftingRecipe; +import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; + +import groovy.lang.Closure; import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; @@ -19,8 +24,6 @@ import thaumcraft.api.crafting.ShapelessArcaneRecipe; import thaumcraft.api.items.ItemsTC; -import java.util.List; - /** * A thaum shaped recipe wrapping a groovy recipe * Yes this needs to be done @@ -29,7 +32,8 @@ public class ShapelessArcaneCR extends ShapelessArcaneRecipe implements ICraftin private final ShapelessCraftingRecipe craftingRecipe; - public ShapelessArcaneCR(ItemStack output, List input, @Nullable Closure recipeFunction, @Nullable Closure recipeAction, String research, int vis, AspectList crystals) { + public ShapelessArcaneCR(ItemStack output, List input, @Nullable Closure recipeFunction, + @Nullable Closure recipeAction, String research, int vis, AspectList crystals) { super(ArcaneWorkbench.DEFAULT, research, vis, crystals, output, new Object[]{Ingredient.EMPTY}); this.craftingRecipe = new ShapelessCraftingRecipe(output, input, recipeFunction, recipeAction); } @@ -40,9 +44,7 @@ public boolean canFit(int width, int height) { } @Override - public boolean isDynamic() { - return craftingRecipe.isDynamic(); - } + public boolean isDynamic() { return craftingRecipe.isDynamic(); } @Override public @NotNull ItemStack getCraftingResult(@NotNull InventoryCrafting inv) { @@ -50,26 +52,16 @@ public boolean isDynamic() { } @Override - public @NotNull ItemStack getRecipeOutput() { - return craftingRecipe.getRecipeOutput(); - } + public @NotNull ItemStack getRecipeOutput() { return craftingRecipe.getRecipeOutput(); } - @Override - @Nullable - public Closure getRecipeAction() { - return craftingRecipe.getRecipeAction(); - } + @Override @Nullable + public Closure getRecipeAction() { return craftingRecipe.getRecipeAction(); } - @Override - @Nullable - public Closure getRecipeFunction() { - return craftingRecipe.getRecipeFunction(); - } + @Override @Nullable + public Closure getRecipeFunction() { return craftingRecipe.getRecipeFunction(); } @Override - public @NotNull NonNullList getIngredients() { - return craftingRecipe.getIngredients(); - } + public @NotNull NonNullList getIngredients() { return craftingRecipe.getIngredients(); } @Override public @NotNull NonNullList getRemainingItems(@NotNull InventoryCrafting inv) { @@ -100,14 +92,13 @@ public boolean matches(@NotNull InventoryCrafting inv, @NotNull World world) { for (int i = 0; i < 6; ++i) { ItemStack itemstack1 = inv.getStackInSlot(9 + i); - if (itemstack1 != null && itemstack1.getItem() == ItemsTC.crystalEssence && itemstack1.getCount() >= cs.getCount() && ItemStack.areItemStackTagsEqual(cs, itemstack1)) { + if (itemstack1 != null && itemstack1.getItem() == ItemsTC.crystalEssence && itemstack1.getCount() >= cs.getCount() && ItemStack.areItemStackTagsEqual(cs, + itemstack1)) { b = true; } } - if (!b) { - return false; - } + if (!b) { return false; } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/Aspect.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/Aspect.java index c56ed6919..ff6f1f587 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/Aspect.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/Aspect.java @@ -1,15 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.thaumcraft.Thaumcraft; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.util.ResourceLocation; -import thaumcraft.api.aspects.AspectList; -import java.util.Map; +import thaumcraft.api.aspects.AspectList; @RegistryDescription public class Aspect extends VirtualizedRegistry { @@ -37,8 +39,7 @@ public boolean remove(thaumcraft.api.aspects.Aspect aspect) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(thaumcraft.api.aspects.Aspect.aspects.entrySet()) - .setRemover(x -> remove(x.getValue())); + return new SimpleObjectStream<>(thaumcraft.api.aspects.Aspect.aspects.entrySet()).setRemover(x -> remove(x.getValue())); } @MethodDescription(priority = 2000, example = @Example(commented = true)) @@ -49,7 +50,8 @@ public void removeAll() { public static class AspectBuilder { - @Property(valid = @Comp(value = "null", type = Comp.Type.NOT), requirement = "groovyscript.wiki.thaumcraft.aspect.tag.required") + @Property(valid = @Comp(value = "null", type = Comp.Type.NOT), + requirement = "groovyscript.wiki.thaumcraft.aspect.tag.required") private String tag; @Property private int chatColor; @@ -117,14 +119,12 @@ public AspectBuilder blend(int blend) { @RecipeBuilderRegistrationMethod public thaumcraft.api.aspects.Aspect register() { try { - thaumcraft.api.aspects.Aspect aspect = new thaumcraft.api.aspects.Aspect(tag, chatColor, components.getAspects(), image, blend); + thaumcraft.api.aspects.Aspect aspect = new thaumcraft.api.aspects.Aspect(tag, chatColor, components.getAspects(), + image, blend); ModSupport.THAUMCRAFT.get().aspect.add(aspect); return aspect; } catch (IllegalArgumentException e) { - GroovyLog.msg("Error adding Thaumcraft Aspect: ") - .add(e.getMessage()) - .error() - .post(); + GroovyLog.msg("Error adding Thaumcraft Aspect: ").add(e.getMessage()).error().post(); } return null; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectHelper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectHelper.java index 8726d235c..fcfd870f2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectHelper.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,41 +18,26 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.jetbrains.annotations.ApiStatus; + import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.internal.CommonInternals; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - @RegistryDescription public class AspectHelper extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(aspectList -> { - if (aspectList.item != null) - for (AspectStack as : aspectList.aspects) - this.remove(aspectList.item, as, false); - else if (aspectList.entity != null) - for (AspectStack as : aspectList.aspects) - this.remove(aspectList.entity, as, false); + if (aspectList.item != null) for (AspectStack as : aspectList.aspects) this.remove(aspectList.item, as, false); + else if (aspectList.entity != null) for (AspectStack as : aspectList.aspects) this.remove(aspectList.entity, as, + false); }); restoreFromBackup().forEach(aspectList -> { - if (aspectList.item != null) - for (AspectStack as : aspectList.aspects) - this.add(aspectList.item, as, false); - else if (aspectList.entity != null) - for (AspectStack as : aspectList.aspects) - this.add(aspectList.entity, as, false); + if (aspectList.item != null) for (AspectStack as : aspectList.aspects) this.add(aspectList.item, as, false); + else if (aspectList.entity != null) for (AspectStack as : aspectList.aspects) this.add(aspectList.entity, as, false); }); } @@ -51,24 +45,22 @@ else if (aspectList.entity != null) public void addScripted(Object target, AspectStack aspect) { AtomicBoolean found = new AtomicBoolean(false); getScriptedRecipes().forEach(scriptedAspect -> { - if (target instanceof EntityEntry && scriptedAspect.entity != null - && ((EntityEntry) target).getName().equals(scriptedAspect.entity.getName())) { + if (target instanceof EntityEntry && scriptedAspect.entity != null && ((EntityEntry) target).getName().equals( + scriptedAspect.entity.getName())) { found.set(true); scriptedAspect.addAspect(aspect); - } else if (target instanceof ItemStack && scriptedAspect.item != null - && ((ItemStack) target).isItemEqual(scriptedAspect.item)) { - found.set(true); - scriptedAspect.addAspect(aspect); - } + } else if (target instanceof ItemStack && scriptedAspect.item != null && ((ItemStack) target).isItemEqual( + scriptedAspect.item)) { + found.set(true); + scriptedAspect.addAspect(aspect); + } }); if (!found.get()) { ArrayList aspectList = new ArrayList<>(); aspectList.add(aspect); - if (target instanceof ItemStack) - addScripted(new AspectListHelper((ItemStack) target, aspectList)); - else if (target instanceof EntityEntry) - addScripted(new AspectListHelper((EntityEntry) target, aspectList)); + if (target instanceof ItemStack) addScripted(new AspectListHelper((ItemStack) target, aspectList)); + else if (target instanceof EntityEntry) addScripted(new AspectListHelper((EntityEntry) target, aspectList)); } } @@ -76,28 +68,27 @@ else if (target instanceof EntityEntry) public void addBackup(Object target, AspectStack aspect) { AtomicBoolean found = new AtomicBoolean(false); getBackupRecipes().forEach(backupAspect -> { - if (target instanceof EntityEntry && backupAspect.entity != null - && ((EntityEntry) target).getName().equals(backupAspect.entity.getName())) { + if (target instanceof EntityEntry && backupAspect.entity != null && ((EntityEntry) target).getName().equals( + backupAspect.entity.getName())) { found.set(true); backupAspect.addAspect(aspect); - } else if (target instanceof ItemStack && backupAspect.item != null - && ((ItemStack) target).isItemEqual(backupAspect.item)) { - found.set(true); - backupAspect.addAspect(aspect); - } + } else if (target instanceof ItemStack && backupAspect.item != null && ((ItemStack) target).isItemEqual( + backupAspect.item)) { + found.set(true); + backupAspect.addAspect(aspect); + } }); if (!found.get()) { ArrayList aspectList = new ArrayList<>(); aspectList.add(aspect); - if (target instanceof ItemStack) - addBackup(new AspectListHelper((ItemStack) target, aspectList)); - else if (target instanceof EntityEntry) - addBackup(new AspectListHelper((EntityEntry) target, aspectList)); + if (target instanceof ItemStack) addBackup(new AspectListHelper((ItemStack) target, aspectList)); + else if (target instanceof EntityEntry) addBackup(new AspectListHelper((EntityEntry) target, aspectList)); } } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.aspect_helper.add_entity", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.thaumcraft.aspect_helper.add_entity", + type = MethodDescription.Type.ADDITION) public void add(EntityEntry entity, AspectStack aspect) { this.add(entity, aspect, true); } @@ -107,7 +98,8 @@ public void add(OreDictIngredient oreDict, AspectStack aspect) { this.add(oreDict, aspect, true); } - @MethodDescription(description = "groovyscript.wiki.thaumcraft.aspect_helper.add_item", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.thaumcraft.aspect_helper.add_item", + type = MethodDescription.Type.ADDITION) public void add(ItemStack item, AspectStack aspect) { this.add(item, aspect, true); } @@ -134,25 +126,19 @@ public void add(EntityEntry entity, AspectStack aspect, boolean doBackup) { CommonInternals.scanEntities.forEach(entityTags -> { if (entityTags.entityName.equals(entity.getName())) { entityTags.aspects.remove(aspect.getAspect()); - if (aspect.getAmount() != 0) - entityTags.aspects.add(aspect.getAspect(), aspect.getAmount()); + if (aspect.getAmount() != 0) entityTags.aspects.add(aspect.getAspect(), aspect.getAmount()); found.set(true); } }); if (!found.get()) { - ThaumcraftApi.registerEntityTag( - entity.getName(), - new AspectList().add(aspect.getAspect(), aspect.getAmount()) - ); + ThaumcraftApi.registerEntityTag(entity.getName(), new AspectList().add(aspect.getAspect(), aspect.getAmount())); } if (doBackup) addScripted(entity, aspect); return; } - GroovyLog.msg("Error adding Thaumcraft Aspects from item/entity") - .error() - .post(); + GroovyLog.msg("Error adding Thaumcraft Aspects from item/entity").error().post(); } public void add(OreDictIngredient oreDic, AspectStack aspect, boolean doBackup) { @@ -165,31 +151,27 @@ public void add(OreDictIngredient oreDic, AspectStack aspect, boolean doBackup) ItemStack oc = ore.copy(); oc.setCount(1); this.add(oc, aspect, doBackup); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } } return; } - GroovyLog.msg("Error adding Thaumcraft Aspects from item/entity") - .error() - .post(); + GroovyLog.msg("Error adding Thaumcraft Aspects from item/entity").error().post(); } public void add(ItemStack item, AspectStack aspect, boolean doBackup) { if (item != null && aspect != null) { CommonInternals.objectTags.get(CommonInternals.generateUniqueItemstackId(item)).remove(aspect.getAspect()); - if (aspect.getAmount() != 0) - CommonInternals.objectTags.get(CommonInternals.generateUniqueItemstackId(item)).add(aspect.getAspect(), aspect.getAmount()); + if (aspect.getAmount() != 0) CommonInternals.objectTags.get(CommonInternals.generateUniqueItemstackId(item)).add( + aspect.getAspect(), + aspect.getAmount()); if (doBackup) addScripted(item, aspect); return; } - GroovyLog.msg("Error adding Thaumcraft Aspects from item/entity") - .error() - .post(); + GroovyLog.msg("Error adding Thaumcraft Aspects from item/entity").error().post(); } public void remove(EntityEntry entity, AspectStack aspect, boolean doBackup) { @@ -209,9 +191,7 @@ public void remove(EntityEntry entity, AspectStack aspect, boolean doBackup) { return; } - GroovyLog.msg("Error removing Thaumcraft Aspects from item/entity") - .error() - .post(); + GroovyLog.msg("Error removing Thaumcraft Aspects from item/entity").error().post(); } public void remove(OreDictIngredient oreDic, AspectStack aspect, boolean doBackup) { @@ -224,21 +204,19 @@ public void remove(OreDictIngredient oreDic, AspectStack aspect, boolean doBacku ItemStack oc = ore.copy(); oc.setCount(1); this.remove(oc, aspect, doBackup); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } } return; } - GroovyLog.msg("Error removing Thaumcraft Aspects from item/entity") - .error() - .post(); + GroovyLog.msg("Error removing Thaumcraft Aspects from item/entity").error().post(); } public void remove(ItemStack item, AspectStack aspect, boolean doBackup) { if (item != null && aspect != null) { if (doBackup) { - aspect.setAmount(CommonInternals.objectTags.get(CommonInternals.generateUniqueItemstackId(item)).getAmount(aspect.getAspect())); + aspect.setAmount(CommonInternals.objectTags.get(CommonInternals.generateUniqueItemstackId(item)).getAmount(aspect + .getAspect())); addBackup(item, aspect); } @@ -246,9 +224,7 @@ public void remove(ItemStack item, AspectStack aspect, boolean doBackup) { return; } - GroovyLog.msg("Error adding Thaumcraft Aspects from item/entity") - .error() - .post(); + GroovyLog.msg("Error adding Thaumcraft Aspects from item/entity").error().post(); } @MethodDescription(description = "groovyscript.wiki.thaumcraft.aspect_helper.removeAll_entity") @@ -263,9 +239,7 @@ public void removeAll(EntityEntry entity) { } } } - GroovyLog.msg("Error removing Thaumcraft Aspects from item/entity") - .error() - .post(); + GroovyLog.msg("Error removing Thaumcraft Aspects from item/entity").error().post(); } @MethodDescription(description = "groovyscript.wiki.thaumcraft.aspect_helper.removeAll_ore") @@ -278,23 +252,23 @@ public void removeAll(OreDictIngredient oreDic) { ItemStack oc = ore.copy(); oc.setCount(1); this.removeAll(oc); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } } } @MethodDescription(description = "groovyscript.wiki.thaumcraft.aspect_helper.removeAll_item") public void removeAll(ItemStack target) { - for (Aspect a : CommonInternals.objectTags.get(CommonInternals.generateUniqueItemstackId(target)).getAspects()) - this.remove(target, new AspectStack(a, CommonInternals.objectTags.get(CommonInternals.generateUniqueItemstackId(target)).getAmount(a))); + for (Aspect a : CommonInternals.objectTags.get(CommonInternals.generateUniqueItemstackId(target)).getAspects()) this + .remove(target, + new AspectStack(a, + CommonInternals.objectTags.get(CommonInternals.generateUniqueItemstackId(target)) + .getAmount(a))); } - @RecipeBuilderDescription(example = { - @Example(".object(item('minecraft:stone')).stripAspects().aspect(aspect('ignis') * 20).aspect('ordo', 5)"), - @Example(".object(ore('cropPumpkin')).stripAspects().aspect(aspect('herba') * 20)"), - @Example(".entity(entity('minecraft:chicken')).stripAspects().aspect('bestia', 20)") - }) + @RecipeBuilderDescription(example = {@Example(".object(item('minecraft:stone')).stripAspects().aspect(aspect('ignis') * 20).aspect('ordo', 5)"), + @Example(".object(ore('cropPumpkin')).stripAspects().aspect(aspect('herba') * 20)"), + @Example(".entity(entity('minecraft:chicken')).stripAspects().aspect('bestia', 20)")}) public AspectHelperBuilder aspectBuilder() { return new AspectHelperBuilder(); } @@ -351,22 +325,17 @@ public void register() { } else if (object != null && IngredientHelper.isItem(object) && !IngredientHelper.isEmpty(object)) { ModSupport.THAUMCRAFT.get().aspectHelper.removeAll(IngredientHelper.toItemStack(object)); } else { - GroovyLog.msg("Error removing Thaumcraft Aspects from item/entity") - .error() - .post(); + GroovyLog.msg("Error removing Thaumcraft Aspects from item/entity").error().post(); } } aspects.forEach(aspectStack -> { - if (entity != null) - ModSupport.THAUMCRAFT.get().aspectHelper.add(entity, aspectStack); - else if (object != null && object instanceof OreDictIngredient) - ModSupport.THAUMCRAFT.get().aspectHelper.add(((OreDictIngredient) object), aspectStack); + if (entity != null) ModSupport.THAUMCRAFT.get().aspectHelper.add(entity, aspectStack); + else if (object != null && object instanceof OreDictIngredient) ModSupport.THAUMCRAFT.get().aspectHelper.add( + ((OreDictIngredient) object), + aspectStack); else if (object != null && IngredientHelper.isItem(object) && !IngredientHelper.isEmpty(object)) ModSupport.THAUMCRAFT.get().aspectHelper.add(IngredientHelper.toItemStack(object), aspectStack); - else - GroovyLog.msg("Error adding Thaumcraft Aspects to item/entity") - .error() - .post(); + else GroovyLog.msg("Error adding Thaumcraft Aspects to item/entity").error().post(); }); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectItemStackExpansion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectItemStackExpansion.java index 8ec344f00..634599fed 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectItemStackExpansion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectItemStackExpansion.java @@ -1,8 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; import net.minecraft.item.ItemStack; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; + public class AspectItemStackExpansion { public static void addAspect(ItemStack itemStack, AspectStack aspect) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectListHelper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectListHelper.java index 6d0404323..c258a74cf 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectListHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectListHelper.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; + import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.registry.EntityEntry; -import thaumcraft.api.aspects.AspectList; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicBoolean; +import thaumcraft.api.aspects.AspectList; public class AspectListHelper { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectStack.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectStack.java index 261bf947e..b265bf8b0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectStack.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectStack.java @@ -1,7 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect; -import com.cleanroommc.groovyscript.api.IResourceStack; import net.minecraft.item.ItemStack; + +import com.cleanroommc.groovyscript.api.IResourceStack; + import thaumcraft.api.ThaumcraftApiHelper; import thaumcraft.api.aspects.Aspect; import thaumcraft.common.items.consumables.ItemPhial; @@ -34,34 +36,22 @@ public AspectStack(Aspect aspect, int amount) { this.amount = amount; } - public Aspect getAspect() { - return this.aspect; - } + public Aspect getAspect() { return this.aspect; } - public void setAspect(Aspect aspect) { - this.aspect = aspect; - } + public void setAspect(Aspect aspect) { this.aspect = aspect; } @Override - public int getAmount() { - return amount; - } + public int getAmount() { return amount; } @Override - public void setAmount(int amount) { - this.amount = amount; - } + public void setAmount(int amount) { this.amount = amount; } @Override public AspectStack exactCopy() { return new AspectStack(this.aspect, this.amount); } - public ItemStack getCrystal() { - return ThaumcraftApiHelper.makeCrystal(this.aspect, this.amount); - } + public ItemStack getCrystal() { return ThaumcraftApiHelper.makeCrystal(this.aspect, this.amount); } - public ItemStack getPhial() { - return ItemPhial.makeFilledPhial(this.aspect); - } + public ItemStack getPhial() { return ItemPhial.makeFilledPhial(this.aspect); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/warp/Warp.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/warp/Warp.java index 99218714f..8d9709522 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/warp/Warp.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/warp/Warp.java @@ -1,23 +1,24 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.warp; +import java.util.Arrays; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.internal.CommonInternals; -import java.util.Arrays; - @RegistryDescription public class Warp extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> CommonInternals.warpMap.remove(recipe.getKey())); restoreFromBackup().forEach(recipe -> CommonInternals.warpMap.put(recipe.getKey(), recipe.getWarp())); @@ -53,13 +54,9 @@ private InternalWarp(Object key, int warp) { this.warp = warp; } - public Object getKey() { - return key; - } + public Object getKey() { return key; } - public int getWarp() { - return warp; - } + public int getWarp() { return warp; } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/warp/WarpItemStackExpansion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/warp/WarpItemStackExpansion.java index e644dcf6f..a4281e646 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/warp/WarpItemStackExpansion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/warp/WarpItemStackExpansion.java @@ -1,8 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.warp; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; import net.minecraft.item.ItemStack; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; + public class WarpItemStackExpansion { public static void addWarp(ItemStack itemStack, int warp) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/ThermalExpansion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/ThermalExpansion.java index e8920a661..990366dae 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/ThermalExpansion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/ThermalExpansion.java @@ -1,16 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion; -import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; -import cofh.thermalexpansion.util.managers.machine.CompactorManager; +import java.util.Arrays; +import java.util.Locale; + import com.cleanroommc.groovyscript.api.IObjectParser; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; +import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; import com.cleanroommc.groovyscript.compat.mods.thermalexpansion.device.*; import com.cleanroommc.groovyscript.compat.mods.thermalexpansion.dynamo.*; import com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine.*; import com.cleanroommc.groovyscript.mapper.ObjectMapper; -import java.util.Arrays; -import java.util.Locale; +import cofh.thermalexpansion.util.managers.machine.CompactorManager; public class ThermalExpansion extends GroovyPropertyContainer { @@ -52,10 +53,10 @@ public class ThermalExpansion extends GroovyPropertyContainer { @Override public void initialize(GroovyContainer owner) { - ObjectMapper.builder("compactorMode", CompactorManager.Mode.class) - .mod("thermalexpansion") - .parser(IObjectParser.wrapEnum(CompactorManager.Mode.class, false)) - .completerOfNamed(() -> Arrays.asList(CompactorManager.Mode.values()), v -> v.name().toUpperCase(Locale.ROOT)) - .register(); + ObjectMapper.builder("compactorMode", CompactorManager.Mode.class).mod("thermalexpansion").parser(IObjectParser.wrapEnum( + CompactorManager.Mode.class, + false)) + .completerOfNamed(() -> Arrays.asList(CompactorManager.Mode.values()), v -> v.name().toUpperCase(Locale.ROOT)) + .register(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Coolant.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Coolant.java index 33afd6014..96f9661db 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Coolant.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Coolant.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.device; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; @@ -10,17 +14,15 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; + import mezz.jei.api.IGuiHelper; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; @RegistryDescription(category = RegistryDescription.Category.ENTRIES, - admonition = @Admonition(value = "groovyscript.wiki.thermalexpansion.coolant.note0", type = Admonition.Type.WARNING)) + admonition = @Admonition(value = "groovyscript.wiki.thermalexpansion.coolant.note0", + type = Admonition.Type.WARNING)) public class Coolant extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> { CoolantManagerAccessor.getCoolantMap().keySet().removeIf(r -> r.equals(recipe.fluid())); @@ -33,12 +35,16 @@ public void onReload() { } /** - * This validation of rf is required because of {@link cofh.thermalexpansion.plugins.jei.device.coolant.CoolantWrapper#CoolantWrapper(IGuiHelper, FluidStack, int, int) CoolantWrapper} + * This validation of rf is required because of + * {@link cofh.thermalexpansion.plugins.jei.device.coolant.CoolantWrapper#CoolantWrapper(IGuiHelper, FluidStack, int, int) + * CoolantWrapper} * specifically, if the code {@code energy / (TileDynamoCompression.basePower * 10)} returns 0, JEI cannot display it. */ public void add(CoolantRecipe recipe) { if (recipe.rf < 4000) { - GroovyLog.get().error("cannot create a coolant entry with less than 4000 rf, yet tried to create an entry for fluid {} producing {}", recipe.fluid, recipe.rf); + GroovyLog.get().error( + "cannot create a coolant entry with less than 4000 rf, yet tried to create an entry for fluid {} producing {}", + recipe.fluid, recipe.rf); return; } CoolantManagerAccessor.getCoolantMap().put(recipe.fluid(), recipe.rf()); @@ -52,16 +58,21 @@ public void add(FluidStack fluid, int rf, int factor) { } public boolean remove(String fluid) { - if (CoolantManagerAccessor.getCoolantMap().containsKey(fluid) && CoolantManagerAccessor.getCoolantFactorMap().containsKey(fluid)) { - addBackup(new CoolantRecipe(fluid, CoolantManagerAccessor.getCoolantMap().removeInt(fluid), CoolantManagerAccessor.getCoolantFactorMap().removeInt(fluid))); + if (CoolantManagerAccessor.getCoolantMap().containsKey(fluid) && CoolantManagerAccessor.getCoolantFactorMap().containsKey( + fluid)) { + addBackup(new CoolantRecipe(fluid, CoolantManagerAccessor.getCoolantMap().removeInt(fluid), CoolantManagerAccessor + .getCoolantFactorMap() + .removeInt(fluid))); return true; } return false; } public boolean remove(CoolantRecipe recipe) { - if (CoolantManagerAccessor.getCoolantMap().containsKey(recipe.fluid()) && CoolantManagerAccessor.getCoolantFactorMap().containsKey(recipe.fluid())) { - addBackup(new CoolantRecipe(recipe.fluid(), CoolantManagerAccessor.getCoolantMap().removeInt(recipe.fluid()), CoolantManagerAccessor.getCoolantFactorMap().removeInt(recipe.fluid()))); + if (CoolantManagerAccessor.getCoolantMap().containsKey(recipe.fluid()) && CoolantManagerAccessor.getCoolantFactorMap() + .containsKey(recipe.fluid())) { + addBackup(new CoolantRecipe(recipe.fluid(), CoolantManagerAccessor.getCoolantMap().removeInt(recipe.fluid()), + CoolantManagerAccessor.getCoolantFactorMap().removeInt(recipe.fluid()))); return true; } return false; @@ -80,7 +91,8 @@ public SimpleObjectStream streamRecipes() { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { CoolantManagerAccessor.getCoolantMap().keySet().stream().filter(CoolantManagerAccessor.getCoolantFactorMap()::containsKey) - .forEach(x -> addBackup(new CoolantRecipe(x, CoolantManagerAccessor.getCoolantMap().getInt(x), CoolantManagerAccessor.getCoolantFactorMap().getInt(x)))); + .forEach(x -> addBackup(new CoolantRecipe(x, CoolantManagerAccessor.getCoolantMap().getInt(x), + CoolantManagerAccessor.getCoolantFactorMap().getInt(x)))); CoolantManagerAccessor.getCoolantMap().clear(); CoolantManagerAccessor.getCoolantFactorMap().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Diffuser.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Diffuser.java index 9c7b9f828..c0670fba3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Diffuser.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Diffuser.java @@ -1,6 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.device; -import cofh.core.inventory.ComparableItemStack; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -9,18 +15,13 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import java.util.List; -import java.util.stream.Collectors; +import cofh.core.inventory.ComparableItemStack; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Diffuser extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> { DiffuserManagerAccessor.getReagentAmpMap().keySet().removeIf(r -> r.equals(recipe.stack())); @@ -44,7 +45,8 @@ public void add(ItemStack stack, int amplifier, int duration) { } public boolean remove(ComparableItemStack stack) { - if (DiffuserManagerAccessor.getReagentAmpMap().containsKey(stack) && DiffuserManagerAccessor.getReagentDurMap().containsKey(stack)) { + if (DiffuserManagerAccessor.getReagentAmpMap().containsKey(stack) && DiffuserManagerAccessor.getReagentDurMap() + .containsKey(stack)) { addBackup(new DiffuserRecipe(stack)); DiffuserManagerAccessor.getReagentAmpMap().remove(stack); DiffuserManagerAccessor.getReagentDurMap().remove(stack); @@ -54,7 +56,8 @@ public boolean remove(ComparableItemStack stack) { } public boolean remove(DiffuserRecipe recipe) { - if (DiffuserManagerAccessor.getReagentAmpMap().containsKey(recipe.stack()) && DiffuserManagerAccessor.getReagentDurMap().containsKey(recipe.stack())) { + if (DiffuserManagerAccessor.getReagentAmpMap().containsKey(recipe.stack()) && DiffuserManagerAccessor.getReagentDurMap() + .containsKey(recipe.stack())) { addBackup(new DiffuserRecipe(recipe.stack())); DiffuserManagerAccessor.getReagentAmpMap().remove(recipe.stack()); DiffuserManagerAccessor.getReagentDurMap().remove(recipe.stack()); @@ -70,19 +73,17 @@ public boolean remove(ItemStack input) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - List list = DiffuserManagerAccessor.getReagentAmpMap().keySet().stream() - .filter(DiffuserManagerAccessor.getReagentDurMap()::containsKey) - .map(DiffuserRecipe::new) - .collect(Collectors.toList()); + List list = DiffuserManagerAccessor.getReagentAmpMap().keySet().stream().filter(DiffuserManagerAccessor + .getReagentDurMap()::containsKey) + .map(DiffuserRecipe::new).collect(Collectors.toList()); return new SimpleObjectStream<>(list).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - DiffuserManagerAccessor.getReagentAmpMap().keySet().stream() - .filter(DiffuserManagerAccessor.getReagentDurMap()::containsKey) - .map(DiffuserRecipe::new) - .forEach(this::addBackup); + DiffuserManagerAccessor.getReagentAmpMap().keySet().stream().filter(DiffuserManagerAccessor + .getReagentDurMap()::containsKey) + .map(DiffuserRecipe::new).forEach(this::addBackup); DiffuserManagerAccessor.getReagentAmpMap().clear(); DiffuserManagerAccessor.getReagentDurMap().clear(); } @@ -91,7 +92,8 @@ public void removeAll() { public record DiffuserRecipe(ComparableItemStack stack, int amplifier, int duration) { public DiffuserRecipe(ComparableItemStack stack) { - this(stack, DiffuserManagerAccessor.getReagentAmpMap().get(stack), DiffuserManagerAccessor.getReagentDurMap().get(stack)); + this(stack, DiffuserManagerAccessor.getReagentAmpMap().get(stack), DiffuserManagerAccessor.getReagentDurMap().get( + stack)); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Factorizer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Factorizer.java index cdb0dbce3..3f22ffbf6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Factorizer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Factorizer.java @@ -1,7 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.device; -import cofh.core.inventory.ComparableItemStackValidated; -import cofh.thermalexpansion.util.managers.device.FactorizerManager; +import java.util.Collection; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -13,32 +21,24 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.google.common.primitives.Booleans; -import net.minecraft.item.ItemStack; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.Map; -import java.util.stream.Collectors; +import cofh.core.inventory.ComparableItemStackValidated; +import cofh.thermalexpansion.util.managers.device.FactorizerManager; @RegistryDescription public class Factorizer extends VirtualizedRegistry> { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay') * 7).output(item('minecraft:book') * 2).combine().split()"), - @Example(".input(item('minecraft:planks:*') * 4).output(item('minecraft:crafting_table')).combine()") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay') * 7).output(item('minecraft:book') * 2).combine().split()"), + @Example(".input(item('minecraft:planks:*') * 4).output(item('minecraft:crafting_table')).combine()")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> map(recipe.getKey()).values().removeIf(r -> r.equals(recipe.getValue()))); - restoreFromBackup().forEach(r -> map(r.getKey()).put(new ComparableItemStackValidated(r.getValue().getInput()), r.getValue())); + restoreFromBackup().forEach(r -> map(r.getKey()).put(new ComparableItemStackValidated(r.getValue().getInput()), r + .getValue())); } private Map map(boolean isSplit) { @@ -52,12 +52,7 @@ public void add(boolean isSplit, FactorizerManager.FactorizerRecipe recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION) public FactorizerManager.FactorizerRecipe add(boolean combine, boolean split, IIngredient input, ItemStack output) { - return recipeBuilder() - .combine(combine) - .split(split) - .input(input) - .output(output) - .register(); + return recipeBuilder().combine(combine).split(split).input(input).output(output).register(); } public void add(FactorizerManager.FactorizerRecipe recipe) { @@ -121,8 +116,9 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(Booleans.asList(true, false).stream().map(this::map).map(Map::values).flatMap(Collection::stream).collect(Collectors.toList())) - .setRemover(this::remove); + return new SimpleObjectStream<>(Booleans.asList(true, false).stream().map(this::map).map(Map::values).flatMap( + Collection::stream) + .collect(Collectors.toList())).setRemover(this::remove); } @MethodDescription(example = @Example(value = "true", commented = true)) @@ -137,8 +133,7 @@ public void removeAll() { removeByType(false); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -171,9 +166,7 @@ public RecipeBuilder split() { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Factorizer recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Factorizer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -181,20 +174,21 @@ public void validate(GroovyLog.Msg msg) { validateFluids(msg); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable FactorizerManager.FactorizerRecipe register() { if (!validate()) return null; FactorizerManager.FactorizerRecipe recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { if (combine) { - FactorizerManager.FactorizerRecipe recipe1 = FactorizerRecipeAccessor.createFactorizerRecipe(itemStack, output.get(0)); + FactorizerManager.FactorizerRecipe recipe1 = FactorizerRecipeAccessor.createFactorizerRecipe(itemStack, output + .get(0)); ModSupport.THERMAL_EXPANSION.get().factorizer.add(false, recipe1); if (recipe == null) recipe = recipe1; } if (split) { - FactorizerManager.FactorizerRecipe recipe1 = FactorizerRecipeAccessor.createFactorizerRecipe(output.get(0), itemStack); + FactorizerManager.FactorizerRecipe recipe1 = FactorizerRecipeAccessor.createFactorizerRecipe(output.get(0), + itemStack); ModSupport.THERMAL_EXPANSION.get().factorizer.add(true, recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Fisher.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Fisher.java index d1f3e8517..6814097b4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Fisher.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Fisher.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.device; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -9,21 +13,18 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class Fisher extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { // not sure why this isn't stored as a Map, having to manage two lists is rather annoying. removeScripted().forEach(recipe -> { int index = FisherManagerAccessor.getFishList().indexOf(recipe.fish()); FisherManagerAccessor.getFishList().remove(index); - FisherManagerAccessor.setTotalWeight(FisherManagerAccessor.getTotalWeight() - FisherManagerAccessor.getWeightList().remove(index)); + FisherManagerAccessor.setTotalWeight(FisherManagerAccessor.getTotalWeight() - FisherManagerAccessor.getWeightList() + .remove(index)); }); restoreFromBackup().forEach(r -> { FisherManagerAccessor.getFishList().add(r.fish()); @@ -32,9 +33,7 @@ public void onReload() { }); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void afterScriptLoad() { // if the total weight is 0, then when `FisherManager.getFish()` calls `nextInt` we would implode FisherManagerAccessor.setTotalWeight(1); @@ -79,13 +78,14 @@ public boolean remove(IIngredient input) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(FisherManagerAccessor.getFishList()) - .setRemover(this::remove); + return new SimpleObjectStream<>(FisherManagerAccessor.getFishList()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - FisherManagerAccessor.getFishList().forEach(x -> addBackup(new FisherRecipe(x, FisherManagerAccessor.getWeightList().remove(FisherManagerAccessor.getFishList().indexOf(x))))); + FisherManagerAccessor.getFishList().forEach(x -> addBackup(new FisherRecipe(x, FisherManagerAccessor.getWeightList() + .remove(FisherManagerAccessor.getFishList() + .indexOf(x))))); FisherManagerAccessor.getFishList().clear(); FisherManagerAccessor.setTotalWeight(0); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/FisherBait.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/FisherBait.java index ce731a1ab..d67c0c1ab 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/FisherBait.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/FisherBait.java @@ -1,6 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.device; -import cofh.core.inventory.ComparableItemStack; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -10,17 +13,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + +import cofh.core.inventory.ComparableItemStack; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class FisherBait extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { - removeScripted().forEach(recipe -> FisherManagerAccessor.getBaitMap().keySet().removeIf(r -> r.isItemEqual(recipe.bait()))); + removeScripted().forEach(recipe -> FisherManagerAccessor.getBaitMap().keySet().removeIf(r -> r.isItemEqual(recipe + .bait()))); restoreFromBackup().forEach(r -> FisherManagerAccessor.getBaitMap().put(r.bait(), r.multiplier())); } @@ -57,13 +59,13 @@ public boolean remove(IIngredient input) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(FisherManagerAccessor.getBaitMap().keySet()) - .setRemover(this::remove); + return new SimpleObjectStream<>(FisherManagerAccessor.getBaitMap().keySet()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - FisherManagerAccessor.getBaitMap().keySet().forEach(x -> addBackup(new FisherRecipe(x, FisherManagerAccessor.getBaitMap().get(x)))); + FisherManagerAccessor.getBaitMap().keySet().forEach(x -> addBackup(new FisherRecipe(x, FisherManagerAccessor.getBaitMap() + .get(x)))); FisherManagerAccessor.getBaitMap().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Tapper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Tapper.java index 6ceb308b4..ce2b46144 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Tapper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/Tapper.java @@ -1,7 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.device; -import cofh.core.util.BlockWrapper; -import cofh.core.util.ItemWrapper; +import java.util.stream.Collectors; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -14,26 +21,20 @@ import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import java.util.stream.Collectors; +import cofh.core.util.BlockWrapper; +import cofh.core.util.ItemWrapper; -@RegistryDescription( - admonition = @Admonition("groovyscript.wiki.thermalexpansion.tapper.note0") -) +@RegistryDescription(admonition = @Admonition("groovyscript.wiki.thermalexpansion.tapper.note0")) public class Tapper extends VirtualizedRegistry { private final AbstractReloadableStorage blockStorage = new AbstractReloadableStorage<>(); - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { - removeScripted().forEach(recipe -> TapperManagerAccessor.getItemMap().entrySet().removeIf(r -> r.getKey().equals(recipe.itemWrapper()) && r.getValue().equals(recipe.fluidStack()))); + removeScripted().forEach(recipe -> TapperManagerAccessor.getItemMap().entrySet().removeIf(r -> r.getKey().equals(recipe + .itemWrapper()) && r.getValue() + .equals(recipe.fluidStack()))); restoreFromBackup().forEach(r -> TapperManagerAccessor.getItemMap().put(r.itemWrapper(), r.fluidStack())); blockStorage.removeScripted().forEach(r -> TapperManagerAccessor.getBlockMap().put(r.blockWrapper(), r.fluidStack())); blockStorage.restoreFromBackup().forEach(r -> TapperManagerAccessor.getBlockMap().remove(r.blockWrapper())); @@ -125,14 +126,18 @@ public boolean removeBlockByInput(IIngredient input) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TapperManagerAccessor.getItemMap().entrySet().stream().map(x -> new TapperItemRecipe(x.getKey(), x.getValue())).collect(Collectors.toList())) - .setRemover(this::removeItem); + return new SimpleObjectStream<>(TapperManagerAccessor.getItemMap().entrySet().stream().map(x -> new TapperItemRecipe(x + .getKey(), + x.getValue())) + .collect(Collectors.toList())).setRemover(this::removeItem); } @MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY) public SimpleObjectStream streamBlockRecipes() { - return new SimpleObjectStream<>(TapperManagerAccessor.getBlockMap().entrySet().stream().map(x -> new TapperBlockRecipe(x.getKey(), x.getValue())).collect(Collectors.toList())) - .setRemover(this::removeBlock); + return new SimpleObjectStream<>(TapperManagerAccessor.getBlockMap().entrySet().stream().map(x -> new TapperBlockRecipe(x + .getKey(), + x.getValue())) + .collect(Collectors.toList())).setRemover(this::removeBlock); } @MethodDescription(priority = 2000, example = @Example(commented = true)) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/TapperFertilizer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/TapperFertilizer.java index 55a765baa..dfc64f3c0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/TapperFertilizer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/TapperFertilizer.java @@ -1,6 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.device; -import cofh.core.inventory.ComparableItemStack; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -10,17 +13,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + +import cofh.core.inventory.ComparableItemStack; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class TapperFertilizer extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { - removeScripted().forEach(recipe -> TapperManagerAccessor.getFertilizerMap().keySet().removeIf(r -> r.isItemEqual(recipe.bait()))); + removeScripted().forEach(recipe -> TapperManagerAccessor.getFertilizerMap().keySet().removeIf(r -> r.isItemEqual(recipe + .bait()))); restoreFromBackup().forEach(r -> TapperManagerAccessor.getFertilizerMap().put(r.bait(), r.multiplier())); } @@ -57,13 +59,14 @@ public boolean remove(IIngredient input) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TapperManagerAccessor.getFertilizerMap().keySet()) - .setRemover(this::remove); + return new SimpleObjectStream<>(TapperManagerAccessor.getFertilizerMap().keySet()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - TapperManagerAccessor.getFertilizerMap().keySet().forEach(x -> addBackup(new TapperRecipe(x, TapperManagerAccessor.getFertilizerMap().get(x)))); + TapperManagerAccessor.getFertilizerMap().keySet().forEach(x -> addBackup(new TapperRecipe(x, TapperManagerAccessor + .getFertilizerMap() + .get(x)))); TapperManagerAccessor.getFertilizerMap().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/TapperTree.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/TapperTree.java index 36f2ff43f..7215c956d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/TapperTree.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/TapperTree.java @@ -1,6 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.device; -import cofh.core.util.BlockWrapper; +import java.util.Map; + +import net.minecraft.block.state.IBlockState; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -9,19 +14,17 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.block.state.IBlockState; -import org.jetbrains.annotations.ApiStatus; -import java.util.Map; +import cofh.core.util.BlockWrapper; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class TapperTree extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { - removeScripted().forEach(recipe -> TapperManagerAccessor.getLeafMap().entries().removeIf(r -> r.getKey().equals(recipe.log()) && r.getValue().equals(recipe.leaf()))); + removeScripted().forEach(recipe -> TapperManagerAccessor.getLeafMap().entries().removeIf(r -> r.getKey().equals(recipe + .log()) && r.getValue() + .equals(recipe.leaf()))); restoreFromBackup().forEach(r -> TapperManagerAccessor.getLeafMap().put(r.log(), r.leaf())); } @@ -30,7 +33,8 @@ public void add(TapperTreeEntry recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("blockstate('minecraft:clay'), blockstate('minecraft:gold_block')")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("blockstate('minecraft:clay'), blockstate('minecraft:gold_block')")) public void add(IBlockState log, IBlockState leaf) { add(new TapperTreeEntry(new BlockWrapper(log), new BlockWrapper(leaf))); } @@ -83,8 +87,8 @@ public boolean removeByLeaf(IBlockState output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(TapperManagerAccessor.getLeafMap().entries()) - .setRemover(x -> remove(x.getKey(), x.getValue())); + return new SimpleObjectStream<>(TapperManagerAccessor.getLeafMap().entries()).setRemover(x -> remove(x.getKey(), x + .getValue())); } @MethodDescription(priority = 2000, example = @Example(commented = true)) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/XpCollector.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/XpCollector.java index 41e2447ba..4bbde6dcb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/XpCollector.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/device/XpCollector.java @@ -1,6 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.device; -import cofh.core.inventory.ComparableItemStack; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -9,15 +12,13 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + +import cofh.core.inventory.ComparableItemStack; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class XpCollector extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> { XpCollectorManagerAccessor.getCatalystMap().keySet().removeIf(r -> r.equals(recipe.getComparableStack())); @@ -41,7 +42,9 @@ public void add(ItemStack catalyst, int xp, int factor) { } public boolean remove(ComparableItemStack comparableItemStack) { - if (XpCollectorManagerAccessor.getCatalystMap().containsKey(comparableItemStack) && XpCollectorManagerAccessor.getCatalystFactorMap().containsKey(comparableItemStack)) { + if (XpCollectorManagerAccessor.getCatalystMap().containsKey(comparableItemStack) && XpCollectorManagerAccessor + .getCatalystFactorMap() + .containsKey(comparableItemStack)) { addBackup(new XpCollectorRecipe(new ItemStack(comparableItemStack.item, comparableItemStack.metadata), XpCollectorManagerAccessor.getCatalystMap().remove(comparableItemStack), XpCollectorManagerAccessor.getCatalystFactorMap().remove(comparableItemStack))); @@ -53,16 +56,23 @@ public boolean remove(ComparableItemStack comparableItemStack) { @MethodDescription(example = @Example("item('minecraft:soul_sand')")) public boolean remove(ItemStack itemStack) { ComparableItemStack help = new ComparableItemStack(itemStack); - if (XpCollectorManagerAccessor.getCatalystMap().containsKey(help) && XpCollectorManagerAccessor.getCatalystFactorMap().containsKey(help)) { - addBackup(new XpCollectorRecipe(itemStack, XpCollectorManagerAccessor.getCatalystMap().remove(help), XpCollectorManagerAccessor.getCatalystFactorMap().remove(help))); + if (XpCollectorManagerAccessor.getCatalystMap().containsKey(help) && XpCollectorManagerAccessor.getCatalystFactorMap() + .containsKey(help)) { + addBackup(new XpCollectorRecipe(itemStack, XpCollectorManagerAccessor.getCatalystMap().remove(help), + XpCollectorManagerAccessor.getCatalystFactorMap().remove(help))); return true; } return false; } public boolean remove(XpCollectorRecipe recipe) { - if (XpCollectorManagerAccessor.getCatalystMap().containsKey(recipe.getComparableStack()) && XpCollectorManagerAccessor.getCatalystFactorMap().containsKey(recipe.getComparableStack())) { - addBackup(new XpCollectorRecipe(recipe.catalyst(), XpCollectorManagerAccessor.getCatalystMap().remove(recipe.getComparableStack()), XpCollectorManagerAccessor.getCatalystFactorMap().remove(recipe.getComparableStack()))); + if (XpCollectorManagerAccessor.getCatalystMap().containsKey(recipe.getComparableStack()) && XpCollectorManagerAccessor + .getCatalystFactorMap() + .containsKey(recipe.getComparableStack())) { + addBackup(new XpCollectorRecipe(recipe.catalyst(), XpCollectorManagerAccessor.getCatalystMap().remove(recipe + .getComparableStack()), + XpCollectorManagerAccessor.getCatalystFactorMap().remove(recipe + .getComparableStack()))); return true; } return false; @@ -70,14 +80,18 @@ public boolean remove(XpCollectorRecipe recipe) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(XpCollectorManagerAccessor.getCatalystMap().keySet()) - .setRemover(this::remove); + return new SimpleObjectStream<>(XpCollectorManagerAccessor.getCatalystMap().keySet()).setRemover(this::remove); } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - XpCollectorManagerAccessor.getCatalystMap().keySet().stream().filter(XpCollectorManagerAccessor.getCatalystFactorMap()::containsKey) - .forEach(x -> addBackup(new XpCollectorRecipe(new ItemStack(x.item, x.metadata), XpCollectorManagerAccessor.getCatalystMap().get(x), XpCollectorManagerAccessor.getCatalystFactorMap().get(x)))); + XpCollectorManagerAccessor.getCatalystMap().keySet().stream().filter(XpCollectorManagerAccessor + .getCatalystFactorMap()::containsKey) + .forEach(x -> addBackup(new XpCollectorRecipe(new ItemStack(x.item, x.metadata), + XpCollectorManagerAccessor.getCatalystMap().get( + x), + XpCollectorManagerAccessor.getCatalystFactorMap() + .get(x)))); XpCollectorManagerAccessor.getCatalystMap().clear(); XpCollectorManagerAccessor.getCatalystFactorMap().clear(); } @@ -85,9 +99,7 @@ public void removeAll() { @Desugar public record XpCollectorRecipe(ItemStack catalyst, int xp, int factor) { - public ComparableItemStack getComparableStack() { - return new ComparableItemStack(catalyst()); - } + public ComparableItemStack getComparableStack() { return new ComparableItemStack(catalyst()); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Compression.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Compression.java index 13e4caa44..3ac076367 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Compression.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Compression.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.dynamo; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -8,17 +12,14 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; @RegistryDescription public class Compression extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { - removeScripted().forEach(recipe -> CompressionManagerAccessor.getFuelMap().keySet().removeIf(r -> r.equals(recipe.fluid()))); + removeScripted().forEach(recipe -> CompressionManagerAccessor.getFuelMap().keySet().removeIf(r -> r.equals(recipe + .fluid()))); restoreFromBackup().forEach(r -> CompressionManagerAccessor.getFuelMap().put(r.fluid(), r.energy())); } @@ -75,7 +76,9 @@ public SimpleObjectStream streamRecipes() { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - CompressionManagerAccessor.getFuelMap().keySet().forEach(x -> addBackup(new CompressionRecipe(x, CompressionManagerAccessor.getFuelMap().getInt(x)))); + CompressionManagerAccessor.getFuelMap().keySet().forEach(x -> addBackup(new CompressionRecipe(x, + CompressionManagerAccessor.getFuelMap() + .getInt(x)))); CompressionManagerAccessor.getFuelMap().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Enervation.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Enervation.java index 90d961a72..9b7afd091 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Enervation.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Enervation.java @@ -1,6 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.dynamo; -import cofh.core.inventory.ComparableItemStack; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -10,17 +13,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + +import cofh.core.inventory.ComparableItemStack; @RegistryDescription public class Enervation extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { - removeScripted().forEach(recipe -> EnervationManagerAccessor.getFuelMap().keySet().removeIf(r -> r.equals(recipe.comparableItemStack()))); + removeScripted().forEach(recipe -> EnervationManagerAccessor.getFuelMap().keySet().removeIf(r -> r.equals(recipe + .comparableItemStack()))); restoreFromBackup().forEach(r -> EnervationManagerAccessor.getFuelMap().put(r.comparableItemStack(), r.energy())); } @@ -72,7 +74,9 @@ public SimpleObjectStream streamRecipes() { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - EnervationManagerAccessor.getFuelMap().keySet().forEach(x -> addBackup(new EnervationRecipe(x, EnervationManagerAccessor.getFuelMap().get(x)))); + EnervationManagerAccessor.getFuelMap().keySet().forEach(x -> addBackup(new EnervationRecipe(x, EnervationManagerAccessor + .getFuelMap() + .get(x)))); EnervationManagerAccessor.getFuelMap().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Lapidary.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Lapidary.java index e45d3408e..1979648ad 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Lapidary.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Lapidary.java @@ -1,6 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.dynamo; -import cofh.core.inventory.ComparableItemStack; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -10,17 +13,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + +import cofh.core.inventory.ComparableItemStack; @RegistryDescription public class Lapidary extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { - removeScripted().forEach(recipe -> NumismaticManagerAccessor.getGemFuelMap().keySet().removeIf(r -> r.equals(recipe.comparableItemStack()))); + removeScripted().forEach(recipe -> NumismaticManagerAccessor.getGemFuelMap().keySet().removeIf(r -> r.equals(recipe + .comparableItemStack()))); restoreFromBackup().forEach(r -> NumismaticManagerAccessor.getGemFuelMap().put(r.comparableItemStack(), r.energy())); } @@ -72,7 +74,9 @@ public SimpleObjectStream streamRecipes() { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - NumismaticManagerAccessor.getGemFuelMap().keySet().forEach(x -> addBackup(new LapidaryRecipe(x, NumismaticManagerAccessor.getGemFuelMap().get(x)))); + NumismaticManagerAccessor.getGemFuelMap().keySet().forEach(x -> addBackup(new LapidaryRecipe(x, NumismaticManagerAccessor + .getGemFuelMap() + .get(x)))); NumismaticManagerAccessor.getGemFuelMap().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Magmatic.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Magmatic.java index 1ff5c5ab1..d227f1e72 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Magmatic.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Magmatic.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.dynamo; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; @@ -8,15 +12,11 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; @RegistryDescription public class Magmatic extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> MagmaticManagerAccessor.getFuelMap().keySet().removeIf(r -> r.equals(recipe.fluid()))); restoreFromBackup().forEach(r -> MagmaticManagerAccessor.getFuelMap().put(r.fluid(), r.energy())); @@ -75,7 +75,9 @@ public SimpleObjectStream streamRecipes() { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - MagmaticManagerAccessor.getFuelMap().keySet().forEach(x -> addBackup(new MagmaticRecipe(x, MagmaticManagerAccessor.getFuelMap().getInt(x)))); + MagmaticManagerAccessor.getFuelMap().keySet().forEach(x -> addBackup(new MagmaticRecipe(x, MagmaticManagerAccessor + .getFuelMap() + .getInt(x)))); MagmaticManagerAccessor.getFuelMap().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Numismatic.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Numismatic.java index 0849bd46a..54d48ec79 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Numismatic.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Numismatic.java @@ -1,6 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.dynamo; -import cofh.core.inventory.ComparableItemStack; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -10,17 +13,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + +import cofh.core.inventory.ComparableItemStack; @RegistryDescription public class Numismatic extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { - removeScripted().forEach(recipe -> NumismaticManagerAccessor.getFuelMap().keySet().removeIf(r -> r.equals(recipe.comparableItemStack()))); + removeScripted().forEach(recipe -> NumismaticManagerAccessor.getFuelMap().keySet().removeIf(r -> r.equals(recipe + .comparableItemStack()))); restoreFromBackup().forEach(r -> NumismaticManagerAccessor.getFuelMap().put(r.comparableItemStack(), r.energy())); } @@ -72,7 +74,9 @@ public SimpleObjectStream streamRecipes() { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - NumismaticManagerAccessor.getFuelMap().keySet().forEach(x -> addBackup(new NumismaticRecipe(x, NumismaticManagerAccessor.getFuelMap().get(x)))); + NumismaticManagerAccessor.getFuelMap().keySet().forEach(x -> addBackup(new NumismaticRecipe(x, NumismaticManagerAccessor + .getFuelMap() + .get(x)))); NumismaticManagerAccessor.getFuelMap().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Reactant.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Reactant.java index 0a872f6eb..fcca18d7e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Reactant.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Reactant.java @@ -1,7 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.dynamo; -import cofh.core.inventory.ComparableItemStack; -import cofh.thermalexpansion.util.managers.dynamo.ReactantManager; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -14,15 +23,9 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import cofh.core.inventory.ComparableItemStack; +import cofh.thermalexpansion.util.managers.dynamo.ReactantManager; @RegistryDescription public class Reactant extends VirtualizedRegistry { @@ -30,34 +33,36 @@ public class Reactant extends VirtualizedRegistry { private final AbstractReloadableStorage elementalReactantStorage = new AbstractReloadableStorage<>(); private final AbstractReloadableStorage elementalFluidStorage = new AbstractReloadableStorage<>(); - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond')).fluidInput(fluid('steam'))"), - @Example(".input(item('minecraft:clay')).fluidInput(fluid('glowstone')).energy(100)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond')).fluidInput(fluid('steam'))"), + @Example(".input(item('minecraft:clay')).fluidInput(fluid('glowstone')).energy(100)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> ReactantManagerAccessor.getReactionMap().values().removeIf(r -> r == recipe)); restoreFromBackup().forEach(r -> ReactantManagerAccessor.getReactionMap().put(hash(r), r)); - elementalReactantStorage.removeScripted().forEach(recipe -> ReactantManagerAccessor.getValidReactantsElemental().removeIf(r -> r.equals(new ComparableItemStack(recipe)))); - elementalReactantStorage.restoreFromBackup().forEach(r -> ReactantManagerAccessor.getValidReactantsElemental().add(new ComparableItemStack(r))); - elementalFluidStorage.removeScripted().forEach(recipe -> ReactantManagerAccessor.getValidFluidsElemental().removeIf(r -> r.equals(recipe))); + elementalReactantStorage.removeScripted().forEach(recipe -> ReactantManagerAccessor.getValidReactantsElemental().removeIf( + r -> r.equals(new ComparableItemStack(recipe)))); + elementalReactantStorage.restoreFromBackup().forEach(r -> ReactantManagerAccessor.getValidReactantsElemental().add( + new ComparableItemStack(r))); + elementalFluidStorage.removeScripted().forEach(recipe -> ReactantManagerAccessor.getValidFluidsElemental().removeIf(r -> r + .equals(recipe))); elementalFluidStorage.restoreFromBackup().forEach(r -> ReactantManagerAccessor.getValidFluidsElemental().add(r)); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void afterScriptLoad() { ReactantManagerAccessor.getValidReactants().clear(); - ReactantManagerAccessor.getValidReactants().addAll(ReactantManagerAccessor.getReactionMap().values().stream().map(ReactantManager.Reaction::getReactant).map(ComparableItemStack::new).collect(Collectors.toList())); + ReactantManagerAccessor.getValidReactants().addAll(ReactantManagerAccessor.getReactionMap().values().stream().map( + ReactantManager.Reaction::getReactant) + .map(ComparableItemStack::new).collect( + Collectors.toList())); ReactantManagerAccessor.getValidFluids().clear(); - ReactantManagerAccessor.getValidFluids().addAll(ReactantManagerAccessor.getReactionMap().values().stream().map(ReactantManager.Reaction::getFluidName).collect(Collectors.toList())); + ReactantManagerAccessor.getValidFluids().addAll(ReactantManagerAccessor.getReactionMap().values().stream().map( + ReactantManager.Reaction::getFluidName) + .collect(Collectors.toList())); } private List hash(ReactantManager.Reaction recipe) { @@ -68,14 +73,17 @@ private List hash(ItemStack reactant, Fluid fluid) { return Arrays.asList((new ComparableItemStack(reactant)).hashCode(), fluid.getName().hashCode()); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = {@Example("item('minecraft:gunpowder')"), @Example("item('minecraft:clay')")}) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = {@Example("item('minecraft:gunpowder')"), @Example("item('minecraft:clay')")}) public boolean addElementalReactant(ItemStack itemStack) { - return ReactantManagerAccessor.getValidReactantsElemental().add(new ComparableItemStack(itemStack)) && elementalReactantStorage.addScripted(itemStack); + return ReactantManagerAccessor.getValidReactantsElemental().add(new ComparableItemStack( + itemStack)) && elementalReactantStorage.addScripted(itemStack); } @MethodDescription(example = @Example("item('thermalfoundation:material:1024')")) public boolean removeElementalReactant(ItemStack itemStack) { - return ReactantManagerAccessor.getValidReactantsElemental().removeIf(r -> r.equals(new ComparableItemStack(itemStack))) && elementalReactantStorage.addBackup(itemStack); + return ReactantManagerAccessor.getValidReactantsElemental().removeIf(r -> r.equals(new ComparableItemStack( + itemStack))) && elementalReactantStorage.addBackup(itemStack); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -90,7 +98,8 @@ public boolean addElementalFluid(FluidStack fluid) { @MethodDescription public boolean removeElementalFluid(String fluid) { - return ReactantManagerAccessor.getValidFluidsElemental().removeIf(r -> r.equals(fluid)) && elementalFluidStorage.addBackup(fluid); + return ReactantManagerAccessor.getValidFluidsElemental().removeIf(r -> r.equals(fluid)) && elementalFluidStorage + .addBackup(fluid); } @MethodDescription(example = @Example("fluid('cryotheum')")) @@ -105,11 +114,7 @@ public void add(ReactantManager.Reaction recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay'), fluid('steam'), 100")) public void add(IIngredient ingredient, FluidStack fluidStack, int energy) { - recipeBuilder() - .energy(energy) - .input(ingredient) - .fluidInput(fluidStack) - .register(); + recipeBuilder().energy(energy).input(ingredient).fluidInput(fluidStack).register(); } public boolean remove(ReactantManager.Reaction recipe) { @@ -122,12 +127,12 @@ public boolean remove(ReactantManager.Reaction recipe) { }); } - @MethodDescription(example = { - @Example("item('minecraft:blaze_powder')"), @Example("fluid('redstone')") - }) + @MethodDescription(example = {@Example("item('minecraft:blaze_powder')"), @Example("fluid('redstone')")}) public boolean removeByInput(IIngredient input) { return ReactantManagerAccessor.getReactionMap().values().removeIf(r -> { - if (input.test(r.getReactant()) || (input instanceof FluidStack && IngredientHelper.toFluidStack(input).getFluid().getName().equals(r.getFluidName()))) { + if (input.test(r.getReactant()) || (input instanceof FluidStack && IngredientHelper.toFluidStack(input).getFluid() + .getName().equals(r + .getFluidName()))) { addBackup(r); return true; } @@ -146,8 +151,7 @@ public void removeAll() { ReactantManagerAccessor.getReactionMap().clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "fluidInput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "ReactantManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT)) @@ -160,9 +164,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Reactant Dynamo recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Reactant Dynamo recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -171,14 +173,14 @@ public void validate(GroovyLog.Msg msg) { msg.add(energy <= 0, "energy must be greater than 0, yet it was {}", energy); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ReactantManager.Reaction register() { if (!validate()) return null; ReactantManager.Reaction recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { - ReactantManager.Reaction recipe1 = ReactionAccessor.createReaction(itemStack, fluidInput.get(0).getFluid(), energy); + ReactantManager.Reaction recipe1 = ReactionAccessor.createReaction(itemStack, fluidInput.get(0).getFluid(), + energy); ModSupport.THERMAL_EXPANSION.get().reactant.add(recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Steam.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Steam.java index 816361eac..5d9e4753a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Steam.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/dynamo/Steam.java @@ -1,6 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.dynamo; -import cofh.core.inventory.ComparableItemStack; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -10,17 +13,16 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.github.bsideup.jabel.Desugar; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + +import cofh.core.inventory.ComparableItemStack; @RegistryDescription public class Steam extends VirtualizedRegistry { - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { - removeScripted().forEach(recipe -> SteamManagerAccessor.getFuelMap().keySet().removeIf(r -> r.equals(recipe.comparableItemStack()))); + removeScripted().forEach(recipe -> SteamManagerAccessor.getFuelMap().keySet().removeIf(r -> r.equals(recipe + .comparableItemStack()))); restoreFromBackup().forEach(r -> SteamManagerAccessor.getFuelMap().put(r.comparableItemStack(), r.energy())); } @@ -72,7 +74,8 @@ public SimpleObjectStream streamRecipes() { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - SteamManagerAccessor.getFuelMap().keySet().forEach(x -> addBackup(new SteamRecipe(x, SteamManagerAccessor.getFuelMap().get(x)))); + SteamManagerAccessor.getFuelMap().keySet().forEach(x -> addBackup(new SteamRecipe(x, SteamManagerAccessor.getFuelMap() + .get(x)))); SteamManagerAccessor.getFuelMap().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Brewer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Brewer.java index 32b2da74f..6d11ea8aa 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Brewer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Brewer.java @@ -1,8 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.util.helpers.FluidHelper; -import cofh.thermalexpansion.util.managers.machine.BrewerManager; -import cofh.thermalexpansion.util.managers.machine.BrewerManager.BrewerRecipe; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -14,15 +22,10 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import cofh.core.util.helpers.FluidHelper; +import cofh.thermalexpansion.util.managers.machine.BrewerManager; +import cofh.thermalexpansion.util.managers.machine.BrewerManager.BrewerRecipe; @RegistryDescription public class Brewer extends VirtualizedRegistry { @@ -31,33 +34,30 @@ public Brewer() { super(Alias.generateOfClass(Brewer.class).andGenerate("Imbuer")); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).fluidInput(fluid('water') * 100).fluidOutput(fluid('lava') * 100)"), - @Example(".input(item('minecraft:diamond') * 2).fluidInput(fluid('water') * 1000).fluidOutput(fluid('steam') * 100).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).fluidInput(fluid('water') * 100).fluidOutput(fluid('lava') * 100)"), + @Example(".input(item('minecraft:diamond') * 2).fluidInput(fluid('water') * 1000).fluidOutput(fluid('steam') * 100).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> BrewerManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); restoreFromBackup().forEach(r -> BrewerManagerAccessor.getRecipeMap().put(hash(r), r)); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void afterScriptLoad() { BrewerManagerAccessor.getValidationSet().clear(); - BrewerManagerAccessor.getValidationSet().addAll( - BrewerManagerAccessor.getRecipeMap().values().stream().map(BrewerRecipe::getInput).map(BrewerManager::convertInput).collect(Collectors.toList()) - ); + BrewerManagerAccessor.getValidationSet().addAll(BrewerManagerAccessor.getRecipeMap().values().stream().map( + BrewerRecipe::getInput) + .map(BrewerManager::convertInput).collect(Collectors + .toList())); BrewerManagerAccessor.getValidationFluids().clear(); - BrewerManagerAccessor.getValidationFluids().addAll( - BrewerManagerAccessor.getRecipeMap().values().stream().map(BrewerRecipe::getInputFluid).map(FluidStack::getFluid).map(Fluid::getName).collect(Collectors.toList()) - ); + BrewerManagerAccessor.getValidationFluids().addAll(BrewerManagerAccessor.getRecipeMap().values().stream().map( + BrewerRecipe::getInputFluid) + .map(FluidStack::getFluid).map(Fluid::getName) + .collect(Collectors.toList())); } private List hash(BrewerRecipe recipe) { @@ -73,14 +73,11 @@ public void add(BrewerRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "1000, item('minecraft:obsidian') * 2, fluid('water') * 1000, fluid('steam') * 100", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "1000, item('minecraft:obsidian') * 2, fluid('water') * 1000, fluid('steam') * 100", + commented = true)) public BrewerRecipe add(int energy, IIngredient input, FluidStack fluidInput, FluidStack fluidOutput) { - return recipeBuilder() - .energy(energy) - .input(input) - .fluidInput(fluidInput) - .fluidOutput(fluidOutput) - .register(); + return recipeBuilder().energy(energy).input(input).fluidInput(fluidInput).fluidOutput(fluidOutput).register(); } public boolean remove(BrewerRecipe recipe) { @@ -93,10 +90,8 @@ public boolean remove(BrewerRecipe recipe) { }); } - @MethodDescription(example = { - @Example("fluid('potion').withNbt(['Potion': 'minecraft:leaping'])"), - @Example("item('minecraft:glowstone_dust')") - }) + @MethodDescription(example = {@Example("fluid('potion').withNbt(['Potion': 'minecraft:leaping'])"), + @Example("item('minecraft:glowstone_dust')")}) public boolean removeByInput(IIngredient input) { return BrewerManagerAccessor.getRecipeMap().values().removeIf(r -> { if (input.test(r.getInput()) || input.test(r.getInputFluid())) { @@ -134,7 +129,9 @@ public void removeAll() { @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "BrewerManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "BrewerManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = BrewerManager.DEFAULT_ENERGY; @RecipeBuilderMethodDescription @@ -144,9 +141,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Brewer recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Brewer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -155,14 +150,14 @@ public void validate(GroovyLog.Msg msg) { msg.add(energy <= 0, "energy must be greater than 0, yet it was {}", energy); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable BrewerRecipe register() { if (!validate()) return null; BrewerRecipe recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { - BrewerRecipe recipe1 = BrewerRecipeAccessor.createBrewerRecipe(itemStack, fluidInput.get(0), fluidOutput.get(0), energy); + BrewerRecipe recipe1 = BrewerRecipeAccessor.createBrewerRecipe(itemStack, fluidInput.get(0), fluidOutput.get(0), + energy); ModSupport.THERMAL_EXPANSION.get().brewer.add(recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Centrifuge.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Centrifuge.java index f9c12df36..723818b1a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Centrifuge.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Centrifuge.java @@ -1,7 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.thermalexpansion.util.managers.machine.CentrifugeManager; -import cofh.thermalexpansion.util.managers.machine.CentrifugeManager.CentrifugeRecipe; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,32 +20,25 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import cofh.thermalexpansion.util.managers.machine.CentrifugeManager; +import cofh.thermalexpansion.util.managers.machine.CentrifugeManager.CentrifugeRecipe; @RegistryDescription public class Centrifuge extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).fluidOutput(fluid('water') * 100).output(item('minecraft:diamond') * 2, item('minecraft:gold_ingot'), item('minecraft:gold_ingot')).chance(50, 100, 1)"), - @Example(".input(item('minecraft:diamond') * 3).output(item('minecraft:clay')).chance(100).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).fluidOutput(fluid('water') * 100).output(item('minecraft:diamond') * 2, item('minecraft:gold_ingot'), item('minecraft:gold_ingot')).chance(50, 100, 1)"), + @Example(".input(item('minecraft:diamond') * 3).output(item('minecraft:clay')).chance(100).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> CentrifugeManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); - restoreFromBackup().forEach(r -> CentrifugeManagerAccessor.getRecipeMap().put(CentrifugeManager.convertInput(r.getInput()), r)); + restoreFromBackup().forEach(r -> CentrifugeManagerAccessor.getRecipeMap().put(CentrifugeManager.convertInput(r + .getInput()), + r)); } public void add(CentrifugeRecipe recipe) { @@ -45,15 +46,12 @@ public void add(CentrifugeRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "1000, item('minecraft:obsidian') * 3, [item('minecraft:clay')], [100], null", commented = true)) - public CentrifugeRecipe add(int energy, IIngredient input, List output, List chance, FluidStack fluidOutput) { - return recipeBuilder() - .energy(energy) - .chance(chance) - .input(input) - .output(output) - .fluidOutput(fluidOutput) - .register(); + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "1000, item('minecraft:obsidian') * 3, [item('minecraft:clay')], [100], null", + commented = true)) + public CentrifugeRecipe add(int energy, IIngredient input, List output, List chance, + FluidStack fluidOutput) { + return recipeBuilder().energy(energy).chance(chance).input(input).output(output).fluidOutput(fluidOutput).register(); } public boolean remove(CentrifugeRecipe recipe) { @@ -101,12 +99,15 @@ public void removeAll() { @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "4")}) - @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(property = "fluidOutput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "100")}) private final List chance = new ArrayList<>(); - @Property(defaultValue = "CentrifugeManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "CentrifugeManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = CentrifugeManager.DEFAULT_ENERGY; @RecipeBuilderMethodDescription @@ -134,26 +135,26 @@ public RecipeBuilder chance(List chance) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Centrifuge recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Centrifuge recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 0, 4); validateFluids(msg, 0, 0, 0, 1); msg.add(energy <= 0, "energy must be greater than 0, yet it was {}", energy); - chance.forEach(x -> msg.add(x < 0 || x > 100, "all chance values must be non negative integers less than 100, yet one was {}", x)); + chance.forEach(x -> msg.add(x < 0 || x > 100, + "all chance values must be non negative integers less than 100, yet one was {}", x)); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CentrifugeRecipe register() { if (!validate()) return null; CentrifugeRecipe recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { - CentrifugeRecipe recipe1 = CentrifugeRecipeAccessor.createCentrifugeRecipe(itemStack, output, chance, fluidOutput.getOrEmpty(0), energy); + CentrifugeRecipe recipe1 = CentrifugeRecipeAccessor.createCentrifugeRecipe(itemStack, output, chance, fluidOutput + .getOrEmpty(0), + energy); ModSupport.THERMAL_EXPANSION.get().centrifuge.add(recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/CentrifugeMobs.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/CentrifugeMobs.java index 8322fdb33..1978cc958 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/CentrifugeMobs.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/CentrifugeMobs.java @@ -1,7 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.thermalexpansion.util.managers.machine.CentrifugeManager; -import cofh.thermalexpansion.util.managers.machine.CentrifugeManager.CentrifugeRecipe; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,32 +20,25 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import cofh.thermalexpansion.util.managers.machine.CentrifugeManager; +import cofh.thermalexpansion.util.managers.machine.CentrifugeManager.CentrifugeRecipe; @RegistryDescription public class CentrifugeMobs extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('thermalexpansion:morb').withNbt(['id': 'minecraft:slime'])).fluidOutput(fluid('water') * 100).output(item('minecraft:diamond') * 2, item('minecraft:gold_ingot'), item('minecraft:gold_ingot')).chance(50, 100, 1)"), - @Example(".input(item('minecraft:diamond') * 3).output(item('minecraft:clay')).chance(100).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('thermalexpansion:morb').withNbt(['id': 'minecraft:slime'])).fluidOutput(fluid('water') * 100).output(item('minecraft:diamond') * 2, item('minecraft:gold_ingot'), item('minecraft:gold_ingot')).chance(50, 100, 1)"), + @Example(".input(item('minecraft:diamond') * 3).output(item('minecraft:clay')).chance(100).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> CentrifugeManagerAccessor.getRecipeMapMobs().values().removeIf(r -> r == recipe)); - restoreFromBackup().forEach(r -> CentrifugeManagerAccessor.getRecipeMapMobs().put(CentrifugeManager.convertInput(r.getInput()), r)); + restoreFromBackup().forEach(r -> CentrifugeManagerAccessor.getRecipeMapMobs().put(CentrifugeManager.convertInput(r + .getInput()), + r)); } public void add(CentrifugeRecipe recipe) { @@ -45,15 +46,12 @@ public void add(CentrifugeRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "1000, item('minecraft:obsidian') * 3, item('minecraft:clay'), 100", commented = true)) - public CentrifugeRecipe add(int energy, IIngredient input, List output, List chance, FluidStack fluidOutput) { - return recipeBuilder() - .energy(energy) - .chance(chance) - .input(input) - .output(output) - .fluidOutput(fluidOutput) - .register(); + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "1000, item('minecraft:obsidian') * 3, item('minecraft:clay'), 100", + commented = true)) + public CentrifugeRecipe add(int energy, IIngredient input, List output, List chance, + FluidStack fluidOutput) { + return recipeBuilder().energy(energy).chance(chance).input(input).output(output).fluidOutput(fluidOutput).register(); } public boolean remove(CentrifugeRecipe recipe) { @@ -77,9 +75,7 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(example = { - @Example("item('minecraft:fish')"), @Example(value = "fluid('experience')", commented = true) - }) + @MethodDescription(example = {@Example("item('minecraft:fish')"), @Example(value = "fluid('experience')", commented = true)}) public boolean removeByOutput(IIngredient output) { return CentrifugeManagerAccessor.getRecipeMapMobs().values().removeIf(r -> { if (output.test(r.getFluid()) || r.getOutput().stream().anyMatch(output)) { @@ -103,12 +99,15 @@ public void removeAll() { @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "4")}) - @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + @Property(property = "fluidOutput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "100")}) private final List chance = new ArrayList<>(); - @Property(defaultValue = "CentrifugeManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "CentrifugeManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = CentrifugeManager.DEFAULT_ENERGY; @RecipeBuilderMethodDescription @@ -136,26 +135,27 @@ public RecipeBuilder chance(List chance) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Centrifuge recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Centrifuge recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 1, 1, 0, 4); validateFluids(msg, 0, 0, 0, 1); msg.add(energy <= 0, "energy must be greater than 0, yet it was {}", energy); - chance.forEach(x -> msg.add(x < 0 || x > 100, "all chance values must be greater than or equal to 0 and less than or equal to 100, yet a chance value was {}", x)); + chance.forEach(x -> msg.add(x < 0 || x > 100, + "all chance values must be greater than or equal to 0 and less than or equal to 100, yet a chance value was {}", + x)); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CentrifugeRecipe register() { if (!validate()) return null; CentrifugeRecipe recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { - CentrifugeRecipe recipe1 = CentrifugeRecipeAccessor.createCentrifugeRecipe(itemStack, output, chance, fluidOutput.getOrEmpty(0), energy); + CentrifugeRecipe recipe1 = CentrifugeRecipeAccessor.createCentrifugeRecipe(itemStack, output, chance, fluidOutput + .getOrEmpty(0), + energy); ModSupport.THERMAL_EXPANSION.get().centrifugeMob.add(recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Charger.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Charger.java index beea4f37c..d6a7898e1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Charger.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Charger.java @@ -1,8 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.inventory.ComparableItemStackValidated; -import cofh.thermalexpansion.util.managers.machine.ChargerManager; -import cofh.thermalexpansion.util.managers.machine.ChargerManager.ChargerRecipe; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,27 +14,25 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; + +import cofh.core.inventory.ComparableItemStackValidated; +import cofh.thermalexpansion.util.managers.machine.ChargerManager; +import cofh.thermalexpansion.util.managers.machine.ChargerManager.ChargerRecipe; @RegistryDescription public class Charger extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond') * 5).output(item('minecraft:clay'))"), - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 2).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond') * 5).output(item('minecraft:clay'))"), + @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 2).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> ChargerManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); - restoreFromBackup().forEach(r -> ChargerManagerAccessor.getRecipeMap().put(new ComparableItemStackValidated(r.getInput()), r)); + restoreFromBackup().forEach(r -> ChargerManagerAccessor.getRecipeMap().put(new ComparableItemStackValidated(r.getInput()), + r)); } public void add(ChargerRecipe recipe) { @@ -40,13 +40,11 @@ public void add(ChargerRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "1000, item('minecraft:obsidian'), item('minecraft:diamond') * 2", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "1000, item('minecraft:obsidian'), item('minecraft:diamond') * 2", + commented = true)) public ChargerRecipe add(int energy, IIngredient input, ItemStack output) { - return recipeBuilder() - .energy(energy) - .input(input) - .output(output) - .register(); + return recipeBuilder().energy(energy).input(input).output(output).register(); } public boolean remove(ChargerRecipe recipe) { @@ -92,11 +90,12 @@ public void removeAll() { ChargerManagerAccessor.getRecipeMap().clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "ChargerManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "ChargerManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = ChargerManager.DEFAULT_ENERGY; @RecipeBuilderMethodDescription @@ -106,9 +105,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Charger recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Charger recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -117,8 +114,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(energy <= 0, "energy must be greater than 0, yet it was {}", energy); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ChargerRecipe register() { if (!validate()) return null; ChargerRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Compactor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Compactor.java index bca5594e6..942b9bd38 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Compactor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Compactor.java @@ -1,8 +1,16 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.CompactorManager; -import cofh.thermalexpansion.util.managers.machine.CompactorManager.CompactorRecipe; +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -13,34 +21,26 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.stream.Collectors; +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.CompactorManager; +import cofh.thermalexpansion.util.managers.machine.CompactorManager.CompactorRecipe; @RegistryDescription public class Compactor extends VirtualizedRegistry> { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 2).mode(compactorMode('coin'))"), - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).mode(compactorMode('all'))"), - @Example(".input(item('minecraft:diamond') * 2).output(item('minecraft:gold_ingot')).mode(compactorMode('plate')).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 2).mode(compactorMode('coin'))"), + @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).mode(compactorMode('all'))"), + @Example(".input(item('minecraft:diamond') * 2).output(item('minecraft:gold_ingot')).mode(compactorMode('plate')).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> map(recipe.getKey()).values().removeIf(r -> r == recipe.getValue())); - restoreFromBackup().forEach(r -> map(r.getKey()).put(new ComparableItemStackValidatedNBT(r.getValue().getInput()), r.getValue())); + restoreFromBackup().forEach(r -> map(r.getKey()).put(new ComparableItemStackValidatedNBT(r.getValue().getInput()), r + .getValue())); } private Map map(CompactorManager.Mode mode) { @@ -57,14 +57,11 @@ public void add(CompactorManager.Mode mode, CompactorRecipe recipe) { addScripted(Pair.of(mode, recipe)); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "1000, compactorMode('plate'), item('minecraft:obsidian') * 2, item('minecraft:gold_ingot')", commented = true)) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "1000, compactorMode('plate'), item('minecraft:obsidian') * 2, item('minecraft:gold_ingot')", + commented = true)) public CompactorRecipe add(int energy, CompactorManager.Mode mode, IIngredient input, ItemStack output) { - return recipeBuilder() - .energy(energy) - .mode(mode) - .input(input) - .output(output) - .register(); + return recipeBuilder().energy(energy).mode(mode).input(input).output(output).register(); } public boolean remove(CompactorManager.Mode mode, CompactorRecipe recipe) { @@ -116,9 +113,7 @@ public boolean removeByOutput(CompactorManager.Mode mode, IIngredient output) { }); } - @MethodDescription(example = { - @Example("item('thermalfoundation:material:24')"), @Example("item('minecraft:blaze_rod')") - }) + @MethodDescription(example = {@Example("item('thermalfoundation:material:24')"), @Example("item('minecraft:blaze_rod')")}) public boolean removeByOutput(IIngredient output) { boolean hasRemoved = false; for (CompactorManager.Mode mode : CompactorManager.Mode.values()) { @@ -129,8 +124,9 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(Arrays.stream(CompactorManager.Mode.values()).map(this::map).map(Map::values).flatMap(Collection::stream).collect(Collectors.toList())) - .setRemover(this::remove); + return new SimpleObjectStream<>(Arrays.stream(CompactorManager.Mode.values()).map(this::map).map(Map::values).flatMap( + Collection::stream) + .collect(Collectors.toList())).setRemover(this::remove); } @MethodDescription(example = @Example(value = "compactorMode('plate')", commented = true)) @@ -144,13 +140,14 @@ public void removeAll() { Arrays.stream(CompactorManager.Mode.values()).forEach(this::removeByMode); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "CompactorManager.Mode.ALL") CompactorManager.Mode mode = CompactorManager.Mode.ALL; - @Property(defaultValue = "CompactorManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "CompactorManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = CompactorManager.DEFAULT_ENERGY; @RecipeBuilderMethodDescription @@ -166,9 +163,7 @@ public RecipeBuilder mode(CompactorManager.Mode mode) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Compactor recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Compactor recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -178,8 +173,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(mode == null, "mode must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CompactorRecipe register() { if (!validate()) return null; CompactorRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Crucible.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Crucible.java index e90219ff3..1cf88e895 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Crucible.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Crucible.java @@ -1,8 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.CrucibleManager; -import cofh.thermalexpansion.util.managers.machine.CrucibleManager.CrucibleRecipe; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -13,43 +19,37 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.stream.Collectors; +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.CrucibleManager; +import cofh.thermalexpansion.util.managers.machine.CrucibleManager.CrucibleRecipe; @RegistryDescription public class Crucible extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).fluidOutput(fluid('lava') * 25)"), - @Example(".input(item('minecraft:diamond')).fluidOutput(fluid('water') * 1000).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).fluidOutput(fluid('lava') * 25)"), + @Example(".input(item('minecraft:diamond')).fluidOutput(fluid('water') * 1000).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> CrucibleManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); - restoreFromBackup().forEach(r -> CrucibleManagerAccessor.getRecipeMap().put(new ComparableItemStackValidatedNBT(r.getInput()), r)); + restoreFromBackup().forEach(r -> CrucibleManagerAccessor.getRecipeMap().put(new ComparableItemStackValidatedNBT(r + .getInput()), + r)); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void afterScriptLoad() { CrucibleManagerAccessor.getLavaSet().clear(); - CrucibleManagerAccessor.getLavaSet().addAll(CrucibleManagerAccessor.getRecipeMap().values().stream() - .filter(x -> x.getOutput().getFluid() == FluidRegistry.LAVA) - .map(CrucibleRecipe::getInput) - .map(CrucibleManager::convertInput) - .collect(Collectors.toList())); + CrucibleManagerAccessor.getLavaSet().addAll(CrucibleManagerAccessor.getRecipeMap().values().stream().filter(x -> x + .getOutput() + .getFluid() == FluidRegistry.LAVA) + .map(CrucibleRecipe::getInput).map( + CrucibleManager::convertInput) + .collect(Collectors.toList())); } public void add(CrucibleRecipe recipe) { @@ -57,13 +57,10 @@ public void add(CrucibleRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, item('minecraft:obsidian'), fluid('water') * 1000")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, item('minecraft:obsidian'), fluid('water') * 1000")) public CrucibleRecipe add(int energy, IIngredient input, FluidStack fluidOutput) { - return recipeBuilder() - .energy(energy) - .input(input) - .fluidOutput(fluidOutput) - .register(); + return recipeBuilder().energy(energy).input(input).fluidOutput(fluidOutput).register(); } public boolean remove(CrucibleRecipe recipe) { @@ -109,11 +106,12 @@ public void removeAll() { CrucibleManagerAccessor.getRecipeMap().clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "fluidOutput", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "CrucibleManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "CrucibleManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = CrucibleManager.DEFAULT_ENERGY; @RecipeBuilderMethodDescription @@ -123,9 +121,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Crucible recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Crucible recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -134,8 +130,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(energy <= 0, "energy must be greater than 0, yet it was {}", energy); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable CrucibleRecipe register() { if (!validate()) return null; CrucibleRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Enchanter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Enchanter.java index c5e52e7dc..7ece738a0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Enchanter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Enchanter.java @@ -1,8 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.EnchanterManager; -import cofh.thermalexpansion.util.managers.machine.EnchanterManager.EnchanterRecipe; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -14,13 +20,10 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.EnchanterManager; +import cofh.thermalexpansion.util.managers.machine.EnchanterManager.EnchanterRecipe; @RegistryDescription public class Enchanter extends VirtualizedRegistry { @@ -28,22 +31,20 @@ public class Enchanter extends VirtualizedRegistry { private final AbstractReloadableStorage arcanaStorage = new AbstractReloadableStorage<>(); - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay'), item('minecraft:gold_ingot') * 4).output(item('minecraft:diamond'))"), - @Example(".input(item('minecraft:clay'), item('minecraft:gold_ingot')).output(item('minecraft:diamond')).experience(1000).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay'), item('minecraft:gold_ingot') * 4).output(item('minecraft:diamond'))"), + @Example(".input(item('minecraft:clay'), item('minecraft:gold_ingot')).output(item('minecraft:diamond')).experience(1000).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> EnchanterManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); restoreFromBackup().forEach(r -> EnchanterManagerAccessor.getRecipeMap().put(hash(r), r)); - arcanaStorage.removeScripted().forEach(recipe -> EnchanterManagerAccessor.getLockSet().removeIf(r -> r.equals(EnchanterManager.convertInput(recipe)))); - arcanaStorage.restoreFromBackup().forEach(r -> EnchanterManagerAccessor.getLockSet().add(EnchanterManager.convertInput(r))); + arcanaStorage.removeScripted().forEach(recipe -> EnchanterManagerAccessor.getLockSet().removeIf(r -> r.equals( + EnchanterManager.convertInput(recipe)))); + arcanaStorage.restoreFromBackup().forEach(r -> EnchanterManagerAccessor.getLockSet().add(EnchanterManager.convertInput( + r))); } private List hash(EnchanterRecipe recipe) { @@ -54,27 +55,29 @@ private List hash(ItemStack primaryInput, ItemS return Arrays.asList(EnchanterManager.convertInput(primaryInput), EnchanterManager.convertInput(secondaryInput)); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void afterScriptLoad() { EnchanterManagerAccessor.getValidationSet().clear(); - EnchanterManagerAccessor.getValidationSet().addAll( - EnchanterManagerAccessor.getRecipeMap().values().stream().map(EnchanterRecipe::getPrimaryInput).map(EnchanterManager::convertInput).collect(Collectors.toList()) - ); - EnchanterManagerAccessor.getValidationSet().addAll( - EnchanterManagerAccessor.getRecipeMap().values().stream().map(EnchanterRecipe::getSecondaryInput).map(EnchanterManager::convertInput).collect(Collectors.toList()) - ); + EnchanterManagerAccessor.getValidationSet().addAll(EnchanterManagerAccessor.getRecipeMap().values().stream().map( + EnchanterRecipe::getPrimaryInput) + .map(EnchanterManager::convertInput).collect( + Collectors.toList())); + EnchanterManagerAccessor.getValidationSet().addAll(EnchanterManagerAccessor.getRecipeMap().values().stream().map( + EnchanterRecipe::getSecondaryInput) + .map(EnchanterManager::convertInput).collect( + Collectors.toList())); } @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay')")) public boolean addArcana(ItemStack itemStack) { - return EnchanterManagerAccessor.getLockSet().add(EnchanterManager.convertInput(itemStack)) && arcanaStorage.addScripted(itemStack); + return EnchanterManagerAccessor.getLockSet().add(EnchanterManager.convertInput(itemStack)) && arcanaStorage.addScripted( + itemStack); } @MethodDescription public boolean removeArcana(ItemStack itemStack) { - return EnchanterManagerAccessor.getLockSet().removeIf(r -> r.equals(EnchanterManager.convertInput(itemStack))) && arcanaStorage.addBackup(itemStack); + return EnchanterManagerAccessor.getLockSet().removeIf(r -> r.equals(EnchanterManager.convertInput( + itemStack))) && arcanaStorage.addBackup(itemStack); } public void add(EnchanterRecipe recipe) { @@ -82,14 +85,12 @@ public void add(EnchanterRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, item('minecraft:obsidian'), item('minecraft:gold_ingot'), item('minecraft:diamond'), 1000")) - public EnchanterRecipe add(int energy, IIngredient primaryInput, IIngredient secondaryInput, ItemStack output, int experience) { - return recipeBuilder() - .energy(energy) - .experience(experience) - .input(primaryInput, secondaryInput) - .output(output) - .register(); + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, item('minecraft:obsidian'), item('minecraft:gold_ingot'), item('minecraft:diamond'), 1000")) + public EnchanterRecipe add(int energy, IIngredient primaryInput, IIngredient secondaryInput, ItemStack output, + int experience) { + return recipeBuilder().energy(energy).experience(experience).input(primaryInput, secondaryInput).output(output) + .register(); } public boolean remove(EnchanterRecipe recipe) { @@ -102,10 +103,8 @@ public boolean remove(EnchanterRecipe recipe) { }); } - @MethodDescription(example = { - @Example("item('minecraft:blaze_rod')"), - @Example(value = "item('minecraft:book')", commented = true) - }) + @MethodDescription(example = {@Example("item('minecraft:blaze_rod')"), @Example(value = "item('minecraft:book')", + commented = true)}) public boolean removeByInput(IIngredient input) { return EnchanterManagerAccessor.getRecipeMap().values().removeIf(r -> { if (input.test(r.getPrimaryInput()) || input.test(r.getSecondaryInput())) { @@ -138,11 +137,12 @@ public void removeAll() { EnchanterManagerAccessor.getRecipeMap().clear(); } - @Property(property = "input", valid = @Comp("2")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("2")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "EnchanterManager.DEFAULT_ENERGY[0]", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "EnchanterManager.DEFAULT_ENERGY[0]", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = EnchanterManager.DEFAULT_ENERGY[0]; @Property(defaultValue = "EnchanterManager.DEFAULT_EXPERIENCE[0]", valid = @Comp(value = "0", type = Comp.Type.GTE)) private int experience = EnchanterManager.DEFAULT_EXPERIENCE[0]; @@ -168,9 +168,7 @@ public RecipeBuilder type(EnchanterManager.Type type) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Enchanter recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Enchanter recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -180,15 +178,15 @@ public void validate(GroovyLog.Msg msg) { msg.add(experience < 0, "experience must be greater than or equal to 0, yet it was {}", experience); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable EnchanterRecipe register() { if (!validate()) return null; EnchanterRecipe recipe = null; for (ItemStack input0 : input.get(0).getMatchingStacks()) { for (ItemStack input1 : input.get(1).getMatchingStacks()) { - EnchanterRecipe recipe1 = EnchanterRecipeAccessor.createEnchanterRecipe(input0, input1, output.get(0), experience, energy, type); + EnchanterRecipe recipe1 = EnchanterRecipeAccessor.createEnchanterRecipe(input0, input1, output.get(0), + experience, energy, type); ModSupport.THERMAL_EXPANSION.get().enchanter.add(recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Extruder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Extruder.java index ea0e172ab..5f552a68a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Extruder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Extruder.java @@ -1,8 +1,17 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.util.ItemWrapper; -import cofh.thermalexpansion.util.managers.machine.ExtruderManager; -import cofh.thermalexpansion.util.managers.machine.ExtruderManager.ExtruderRecipe; +import java.util.Collection; +import java.util.Map; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -14,48 +23,36 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.google.common.primitives.Booleans; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.Map; -import java.util.stream.Collectors; +import cofh.core.util.ItemWrapper; +import cofh.thermalexpansion.util.managers.machine.ExtruderManager; +import cofh.thermalexpansion.util.managers.machine.ExtruderManager.ExtruderRecipe; @RegistryDescription public class Extruder extends VirtualizedRegistry> { - @RecipeBuilderDescription(example = { - @Example(".fluidHot(100).fluidCold(1000).output(item('minecraft:clay'))"), - @Example(".fluidHot(100).fluidCold(1000).output(item('minecraft:gold_ingot')).sedimentary().energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".fluidHot(100).fluidCold(1000).output(item('minecraft:clay'))"), + @Example(".fluidHot(100).fluidCold(1000).output(item('minecraft:gold_ingot')).sedimentary().energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> map(recipe.getKey()).values().removeIf(r -> r == recipe.getValue())); restoreFromBackup().forEach(r -> map(r.getKey()).put(new ItemWrapper(r.getValue().getOutput()), r.getValue())); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void afterScriptLoad() { ExtruderManagerAccessor.getOutputListIgneous().clear(); - ExtruderManagerAccessor.getOutputListIgneous().addAll( - ExtruderManagerAccessor.getRecipeMapIgneous().values().stream().map(ExtruderRecipe::getOutput).collect(Collectors.toList()) - ); + ExtruderManagerAccessor.getOutputListIgneous().addAll(ExtruderManagerAccessor.getRecipeMapIgneous().values().stream().map( + ExtruderRecipe::getOutput) + .collect(Collectors.toList())); ExtruderManagerAccessor.getOutputListSedimentary().clear(); - ExtruderManagerAccessor.getOutputListSedimentary().addAll( - ExtruderManagerAccessor.getRecipeMapSedimentary().values().stream().map(ExtruderRecipe::getOutput).collect(Collectors.toList()) - ); + ExtruderManagerAccessor.getOutputListSedimentary().addAll(ExtruderManagerAccessor.getRecipeMapSedimentary().values() + .stream().map(ExtruderRecipe::getOutput) + .collect(Collectors.toList())); } private Map map(boolean isSedimentary) { @@ -67,15 +64,11 @@ public void add(boolean sedimentary, ExtruderRecipe recipe) { addScripted(Pair.of(sedimentary, recipe)); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, item('minecraft:gold_block'), 100, 1000, false")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, item('minecraft:gold_block'), 100, 1000, false")) public ExtruderRecipe add(int energy, ItemStack output, int fluidHot, int fluidCold, boolean sedimentary) { - return recipeBuilder() - .energy(energy) - .fluidCold(fluidCold) - .fluidHot(fluidHot) - .sedimentary(sedimentary) - .output(output) - .register(); + return recipeBuilder().energy(energy).fluidCold(fluidCold).fluidHot(fluidHot).sedimentary(sedimentary).output(output) + .register(); } public boolean remove(boolean isSedimentary, ExtruderRecipe recipe) { @@ -135,8 +128,9 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(Booleans.asList(true, false).stream().map(this::map).map(Map::values).flatMap(Collection::stream).collect(Collectors.toList())) - .setRemover(this::remove); + return new SimpleObjectStream<>(Booleans.asList(true, false).stream().map(this::map).map(Map::values).flatMap( + Collection::stream) + .collect(Collectors.toList())).setRemover(this::remove); } @MethodDescription(example = @Example(value = "true", commented = true)) @@ -154,7 +148,9 @@ public void removeAll() { @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "ExtruderManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "ExtruderManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = ExtruderManager.DEFAULT_ENERGY; @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) private int fluidHot; @@ -195,9 +191,7 @@ public RecipeBuilder sedimentary(boolean sedimentary) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Extruder recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Extruder recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -208,11 +202,13 @@ public void validate(GroovyLog.Msg msg) { msg.add(fluidCold < 0, "fluidCold must be greater than or equal to 0, yet it was {}", fluidCold); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ExtruderRecipe register() { if (!validate()) return null; - ExtruderRecipe recipe = ExtruderRecipeAccessor.createExtruderRecipe(output.get(0), new FluidStack(FluidRegistry.LAVA, fluidHot), new FluidStack(FluidRegistry.WATER, fluidCold), energy); + ExtruderRecipe recipe = ExtruderRecipeAccessor.createExtruderRecipe(output.get(0), new FluidStack(FluidRegistry.LAVA, + fluidHot), + new FluidStack(FluidRegistry.WATER, fluidCold), + energy); ModSupport.THERMAL_EXPANSION.get().extruder.add(sedimentary, recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Furnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Furnace.java index a52a84aa8..fd08dba7a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Furnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Furnace.java @@ -1,7 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.thermalexpansion.util.managers.machine.FurnaceManager; -import cofh.thermalexpansion.util.managers.machine.FurnaceManager.FurnaceRecipe; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -13,26 +16,22 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; + +import cofh.thermalexpansion.util.managers.machine.FurnaceManager; +import cofh.thermalexpansion.util.managers.machine.FurnaceManager.FurnaceRecipe; @RegistryDescription public class Furnace extends VirtualizedRegistry { private final AbstractReloadableStorage foodStorage = new AbstractReloadableStorage<>(); - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay') * 2)"), - @Example(".input(item('minecraft:gold_ingot') * 2).output(item('minecraft:clay')).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay') * 2)"), + @Example(".input(item('minecraft:gold_ingot') * 2).output(item('minecraft:clay')).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> FurnaceManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); restoreFromBackup().forEach(r -> FurnaceManagerAccessor.getRecipeMap().put(FurnaceManager.convertInput(r.getInput()), r)); @@ -55,13 +54,10 @@ public void add(FurnaceRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, item('minecraft:obsidian') * 2, item('minecraft:clay')")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, item('minecraft:obsidian') * 2, item('minecraft:clay')")) public FurnaceRecipe add(int energy, IIngredient input, ItemStack output) { - return recipeBuilder() - .energy(energy) - .input(input) - .output(output) - .register(); + return recipeBuilder().energy(energy).input(input).output(output).register(); } public boolean remove(FurnaceRecipe recipe) { @@ -113,11 +109,12 @@ public void removeAll() { FurnaceManagerAccessor.getRecipeMap().clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "FurnaceManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "FurnaceManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = FurnaceManager.DEFAULT_ENERGY; @RecipeBuilderMethodDescription @@ -127,9 +124,7 @@ public RecipeBuilder energy(int energy) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Furnace recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Furnace recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -138,8 +133,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(energy <= 0, "energy must be greater than 0, yet it was {}", energy); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable FurnaceRecipe register() { if (!validate()) return null; FurnaceRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/FurnacePyrolysis.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/FurnacePyrolysis.java index 8a351b38e..dd5cc6b09 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/FurnacePyrolysis.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/FurnacePyrolysis.java @@ -1,7 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.thermalexpansion.util.managers.machine.FurnaceManager; -import cofh.thermalexpansion.util.managers.machine.FurnaceManager.FurnaceRecipe; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,27 +15,25 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; + +import cofh.thermalexpansion.util.managers.machine.FurnaceManager; +import cofh.thermalexpansion.util.managers.machine.FurnaceManager.FurnaceRecipe; @RegistryDescription public class FurnacePyrolysis extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 2).creosote(100)"), - @Example(".input(item('minecraft:gold_ingot') * 2).output(item('minecraft:clay')).creosote(1000).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 2).creosote(100)"), + @Example(".input(item('minecraft:gold_ingot') * 2).output(item('minecraft:clay')).creosote(1000).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> FurnaceManagerAccessor.getRecipeMapPyrolysis().values().removeIf(r -> r == recipe)); - restoreFromBackup().forEach(r -> FurnaceManagerAccessor.getRecipeMapPyrolysis().put(FurnaceManager.convertInput(r.getInput()), r)); + restoreFromBackup().forEach(r -> FurnaceManagerAccessor.getRecipeMapPyrolysis().put(FurnaceManager.convertInput(r + .getInput()), + r)); } public void add(FurnaceRecipe recipe) { @@ -40,14 +41,10 @@ public void add(FurnaceRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, item('minecraft:obsidian') * 2, item('minecraft:clay'), 1000")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, item('minecraft:obsidian') * 2, item('minecraft:clay'), 1000")) public FurnaceRecipe add(int energy, IIngredient input, ItemStack output, int creosote) { - return recipeBuilder() - .energy(energy) - .creosote(creosote) - .input(input) - .output(output) - .register(); + return recipeBuilder().energy(energy).creosote(creosote).input(input).output(output).register(); } public boolean remove(FurnaceRecipe recipe) { @@ -93,11 +90,12 @@ public void removeAll() { FurnaceManagerAccessor.getRecipeMapPyrolysis().clear(); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "FurnaceManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "FurnaceManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = FurnaceManager.DEFAULT_ENERGY; @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) private int creosote; @@ -115,9 +113,7 @@ public RecipeBuilder creosote(int creosote) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Furnace Pyrolysis recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Furnace Pyrolysis recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -127,8 +123,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(creosote < 0, "creosote must be greater than or equal to 0, yet it was {}", creosote); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable FurnaceRecipe register() { if (!validate()) return null; FurnaceRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Insolator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Insolator.java index e666ffdf2..b1cf5872c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Insolator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Insolator.java @@ -1,8 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.InsolatorManager; -import cofh.thermalexpansion.util.managers.machine.InsolatorManager.InsolatorRecipe; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -14,35 +20,30 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.InsolatorManager; +import cofh.thermalexpansion.util.managers.machine.InsolatorManager.InsolatorRecipe; @RegistryDescription public class Insolator extends VirtualizedRegistry { private final AbstractReloadableStorage fertilizerStorage = new AbstractReloadableStorage<>(); - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay'), item('minecraft:diamond')).output(item('minecraft:diamond') * 4)"), - @Example(".input(item('minecraft:clay'), item('minecraft:gold_ingot') * 2).output(item('minecraft:clay'), item('minecraft:diamond')).chance(5).water(100).tree().energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay'), item('minecraft:diamond')).output(item('minecraft:diamond') * 4)"), + @Example(".input(item('minecraft:clay'), item('minecraft:gold_ingot') * 2).output(item('minecraft:clay'), item('minecraft:diamond')).chance(5).water(100).tree().energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> InsolatorManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); restoreFromBackup().forEach(r -> InsolatorManagerAccessor.getRecipeMap().put(hash(r), r)); - fertilizerStorage.removeScripted().forEach(recipe -> InsolatorManagerAccessor.getLockSet().removeIf(r -> r.equals(InsolatorManager.convertInput(recipe)))); - fertilizerStorage.restoreFromBackup().forEach(r -> InsolatorManagerAccessor.getLockSet().add(InsolatorManager.convertInput(r))); + fertilizerStorage.removeScripted().forEach(recipe -> InsolatorManagerAccessor.getLockSet().removeIf(r -> r.equals( + InsolatorManager.convertInput(recipe)))); + fertilizerStorage.restoreFromBackup().forEach(r -> InsolatorManagerAccessor.getLockSet().add(InsolatorManager + .convertInput(r))); } private List hash(InsolatorRecipe recipe) { @@ -53,27 +54,29 @@ private List hash(ItemStack primaryInput, ItemS return Arrays.asList(InsolatorManager.convertInput(primaryInput), InsolatorManager.convertInput(secondaryInput)); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void afterScriptLoad() { InsolatorManagerAccessor.getValidationSet().clear(); - InsolatorManagerAccessor.getValidationSet().addAll( - InsolatorManagerAccessor.getRecipeMap().values().stream().map(InsolatorRecipe::getPrimaryInput).map(InsolatorManager::convertInput).collect(Collectors.toList()) - ); - InsolatorManagerAccessor.getValidationSet().addAll( - InsolatorManagerAccessor.getRecipeMap().values().stream().map(InsolatorRecipe::getSecondaryInput).map(InsolatorManager::convertInput).collect(Collectors.toList()) - ); + InsolatorManagerAccessor.getValidationSet().addAll(InsolatorManagerAccessor.getRecipeMap().values().stream().map( + InsolatorRecipe::getPrimaryInput) + .map(InsolatorManager::convertInput).collect( + Collectors.toList())); + InsolatorManagerAccessor.getValidationSet().addAll(InsolatorManagerAccessor.getRecipeMap().values().stream().map( + InsolatorRecipe::getSecondaryInput) + .map(InsolatorManager::convertInput).collect( + Collectors.toList())); } @MethodDescription(type = MethodDescription.Type.ADDITION) public boolean addFertilizer(ItemStack itemStack) { - return InsolatorManagerAccessor.getLockSet().add(InsolatorManager.convertInput(itemStack)) && fertilizerStorage.addScripted(itemStack); + return InsolatorManagerAccessor.getLockSet().add(InsolatorManager.convertInput(itemStack)) && fertilizerStorage + .addScripted(itemStack); } @MethodDescription public boolean removeFertilizer(ItemStack itemStack) { - return InsolatorManagerAccessor.getLockSet().removeIf(r -> r.equals(InsolatorManager.convertInput(itemStack))) && fertilizerStorage.addBackup(itemStack); + return InsolatorManagerAccessor.getLockSet().removeIf(r -> r.equals(InsolatorManager.convertInput( + itemStack))) && fertilizerStorage.addBackup(itemStack); } public void add(InsolatorRecipe recipe) { @@ -81,16 +84,14 @@ public void add(InsolatorRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "1000, 100, item('minecraft:obsidian'), item('minecraft:gold_ingot') * 2, item('minecraft:clay'), item('minecraft:diamond'), 5, InsolatorManager.Type.TREE", imports = "cofh.thermalexpansion.util.managers.machine.InsolatorManager")) - public InsolatorRecipe add(int energy, int water, IIngredient primaryInput, IIngredient secondaryInput, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance, InsolatorManager.Type type) { - return recipeBuilder() - .energy(energy) - .water(water) - .chance(secondaryChance) - .type(type) - .input(primaryInput, secondaryInput) - .output(primaryOutput, secondaryOutput) - .register(); + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "1000, 100, item('minecraft:obsidian'), item('minecraft:gold_ingot') * 2, item('minecraft:clay'), item('minecraft:diamond'), 5, InsolatorManager.Type.TREE", + imports = "cofh.thermalexpansion.util.managers.machine.InsolatorManager")) + public InsolatorRecipe add(int energy, int water, IIngredient primaryInput, IIngredient secondaryInput, + ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance, + InsolatorManager.Type type) { + return recipeBuilder().energy(energy).water(water).chance(secondaryChance).type(type).input(primaryInput, secondaryInput) + .output(primaryOutput, secondaryOutput).register(); } public boolean remove(InsolatorRecipe recipe) { @@ -103,9 +104,7 @@ public boolean remove(InsolatorRecipe recipe) { }); } - @MethodDescription(example = { - @Example("item('thermalfoundation:fertilizer')"), @Example("item('minecraft:double_plant:4')") - }) + @MethodDescription(example = {@Example("item('thermalfoundation:fertilizer')"), @Example("item('minecraft:double_plant:4')")}) public boolean removeByInput(IIngredient input) { return InsolatorManagerAccessor.getRecipeMap().values().removeIf(r -> { if (input.test(r.getPrimaryInput()) || input.test(r.getSecondaryInput())) { @@ -116,9 +115,7 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(example = { - @Example("item('minecraft:red_flower:6')"), @Example("item('minecraft:melon_seeds')") - }) + @MethodDescription(example = {@Example("item('minecraft:red_flower:6')"), @Example("item('minecraft:melon_seeds')")}) public boolean removeByOutput(IIngredient output) { return InsolatorManagerAccessor.getRecipeMap().values().removeIf(r -> { if (output.test(r.getPrimaryOutput()) || output.test(r.getSecondaryOutput())) { @@ -144,7 +141,9 @@ public void removeAll() { @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "InsolatorManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "InsolatorManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = InsolatorManager.DEFAULT_ENERGY; @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) private int water; @@ -190,9 +189,7 @@ public RecipeBuilder standard() { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Insolator recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Insolator recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -203,15 +200,16 @@ public void validate(GroovyLog.Msg msg) { msg.add(chance < 0, "chance must be greater than or equal to 0, yet it was {}", chance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable InsolatorRecipe register() { if (!validate()) return null; InsolatorRecipe recipe = null; for (ItemStack input0 : input.get(0).getMatchingStacks()) { for (ItemStack input1 : input.get(1).getMatchingStacks()) { - InsolatorRecipe recipe1 = InsolatorRecipeAccessor.createInsolatorRecipe(input1, input0, output.get(0), output.getOrEmpty(1), chance, energy, water, type); + InsolatorRecipe recipe1 = InsolatorRecipeAccessor.createInsolatorRecipe(input1, input0, output.get(0), output + .getOrEmpty(1), + chance, energy, water, type); ModSupport.THERMAL_EXPANSION.get().insolator.add(recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Precipitator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Precipitator.java index 58152144e..c59a9427c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Precipitator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Precipitator.java @@ -1,8 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.util.ItemWrapper; -import cofh.thermalexpansion.util.managers.machine.PrecipitatorManager; -import cofh.thermalexpansion.util.managers.machine.PrecipitatorManager.PrecipitatorRecipe; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -13,41 +19,32 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.stream.Collectors; +import cofh.core.util.ItemWrapper; +import cofh.thermalexpansion.util.managers.machine.PrecipitatorManager; +import cofh.thermalexpansion.util.managers.machine.PrecipitatorManager.PrecipitatorRecipe; @RegistryDescription public class Precipitator extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".output(item('minecraft:clay'))"), - @Example(".water(100).output(item('minecraft:clay')).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".output(item('minecraft:clay'))"), + @Example(".water(100).output(item('minecraft:clay')).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> PrecipitatorManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); restoreFromBackup().forEach(r -> PrecipitatorManagerAccessor.getRecipeMap().put(new ItemWrapper(r.getOutput()), r)); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void afterScriptLoad() { PrecipitatorManagerAccessor.getOutputList().clear(); - PrecipitatorManagerAccessor.getOutputList().addAll( - PrecipitatorManagerAccessor.getRecipeMap().values().stream().map(PrecipitatorManager.PrecipitatorRecipe::getOutput).collect(Collectors.toList()) - ); + PrecipitatorManagerAccessor.getOutputList().addAll(PrecipitatorManagerAccessor.getRecipeMap().values().stream().map( + PrecipitatorManager.PrecipitatorRecipe::getOutput) + .collect(Collectors.toList())); } public void add(PrecipitatorRecipe recipe) { @@ -57,11 +54,7 @@ public void add(PrecipitatorRecipe recipe) { @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, item('minecraft:obsidian'), 100")) public PrecipitatorRecipe add(int energy, ItemStack output, int water) { - return recipeBuilder() - .energy(energy) - .water(water) - .output(output) - .register(); + return recipeBuilder().energy(energy).water(water).output(output).register(); } public boolean remove(PrecipitatorRecipe recipe) { @@ -110,7 +103,9 @@ public void removeAll() { @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "PrecipitatorManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "PrecipitatorManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = PrecipitatorManager.DEFAULT_ENERGY; @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) private int water; @@ -128,9 +123,7 @@ public RecipeBuilder water(int water) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Precipitator recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Precipitator recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -140,11 +133,13 @@ public void validate(GroovyLog.Msg msg) { msg.add(water < 0, "water must be greater than or equal to 0, yet it was {}", water); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable PrecipitatorRecipe register() { if (!validate()) return null; - PrecipitatorRecipe recipe = PrecipitatorRecipeAccessor.createPrecipitatorRecipe(output.get(0), new FluidStack(FluidRegistry.WATER, water), energy); + PrecipitatorRecipe recipe = PrecipitatorRecipeAccessor.createPrecipitatorRecipe(output.get(0), new FluidStack( + FluidRegistry.WATER, + water), + energy); ModSupport.THERMAL_EXPANSION.get().precipitator.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Pulverizer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Pulverizer.java index 0c6686fad..62219092a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Pulverizer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Pulverizer.java @@ -1,7 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.thermalexpansion.util.managers.machine.PulverizerManager; -import cofh.thermalexpansion.util.managers.machine.PulverizerManager.PulverizerRecipe; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,27 +15,25 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; + +import cofh.thermalexpansion.util.managers.machine.PulverizerManager; +import cofh.thermalexpansion.util.managers.machine.PulverizerManager.PulverizerRecipe; @RegistryDescription public class Pulverizer extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay'), item('minecraft:diamond')).chance(1)"), - @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot'), item('minecraft:gold_ingot')).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay'), item('minecraft:diamond')).chance(1)"), + @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot'), item('minecraft:gold_ingot')).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> PulverizerManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); - restoreFromBackup().forEach(r -> PulverizerManagerAccessor.getRecipeMap().put(PulverizerManager.convertInput(r.getInput()), r)); + restoreFromBackup().forEach(r -> PulverizerManagerAccessor.getRecipeMap().put(PulverizerManager.convertInput(r + .getInput()), + r)); } public void add(PulverizerRecipe recipe) { @@ -40,14 +41,10 @@ public void add(PulverizerRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, item('minecraft:obsidian'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), 100")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, item('minecraft:obsidian'), item('minecraft:gold_ingot'), item('minecraft:gold_ingot'), 100")) public PulverizerRecipe add(int energy, IIngredient input, ItemStack primaryOutput, ItemStack secondaryOutput, int chance) { - return recipeBuilder() - .energy(energy) - .chance(chance) - .output(primaryOutput, secondaryOutput) - .input(input) - .register(); + return recipeBuilder().energy(energy).chance(chance).output(primaryOutput, secondaryOutput).input(input).register(); } public boolean remove(PulverizerRecipe recipe) { @@ -71,9 +68,7 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(example = { - @Example("item('thermalfoundation:material:772')"), @Example("item('minecraft:diamond')") - }) + @MethodDescription(example = {@Example("item('thermalfoundation:material:772')"), @Example("item('minecraft:diamond')")}) public boolean removeByOutput(IIngredient output) { return PulverizerManagerAccessor.getRecipeMap().values().removeIf(r -> { if (output.test(r.getPrimaryOutput()) || output.test(r.getSecondaryOutput())) { @@ -99,7 +94,9 @@ public void removeAll() { @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "PulverizerManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "PulverizerManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = PulverizerManager.DEFAULT_ENERGY; @Property(valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "100")}) private int chance; @@ -117,9 +114,7 @@ public RecipeBuilder chance(int chance) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Pulverizer recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Pulverizer recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -129,14 +124,15 @@ public void validate(GroovyLog.Msg msg) { msg.add(energy <= 0, "energy must be greater than 0, yet it was {}", energy); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable PulverizerRecipe register() { if (!validate()) return null; PulverizerRecipe recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { - PulverizerRecipe recipe1 = PulverizerRecipeAccessor.createPulverizerRecipe(itemStack, output.get(0), output.getOrEmpty(1), chance, energy); + PulverizerRecipe recipe1 = PulverizerRecipeAccessor.createPulverizerRecipe(itemStack, output.get(0), output + .getOrEmpty(1), + chance, energy); ModSupport.THERMAL_EXPANSION.get().pulverizer.add(recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Refinery.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Refinery.java index 2168446ee..231c66620 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Refinery.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Refinery.java @@ -1,8 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.util.helpers.FluidHelper; -import cofh.thermalexpansion.util.managers.machine.RefineryManager; -import cofh.thermalexpansion.util.managers.machine.RefineryManager.RefineryRecipe; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -14,31 +18,24 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -@RegistryDescription( - admonition = @Admonition("groovyscript.wiki.thermalexpansion.refinery.note0") -) +import cofh.core.util.helpers.FluidHelper; +import cofh.thermalexpansion.util.managers.machine.RefineryManager; +import cofh.thermalexpansion.util.managers.machine.RefineryManager.RefineryRecipe; + +@RegistryDescription(admonition = @Admonition("groovyscript.wiki.thermalexpansion.refinery.note0")) public class Refinery extends VirtualizedRegistry { private final AbstractReloadableStorage fossilFuelStorage = new AbstractReloadableStorage<>(); private final AbstractReloadableStorage bioFuelStorage = new AbstractReloadableStorage<>(); - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('water') * 100).fluidOutput(fluid('steam') * 80)"), - @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('steam') * 150).output(item('minecraft:clay')).chance(25).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('water') * 100).fluidOutput(fluid('steam') * 80)"), + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('steam') * 150).output(item('minecraft:clay')).chance(25).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> RefineryManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); restoreFromBackup().forEach(r -> RefineryManagerAccessor.getRecipeMap().put(FluidHelper.getFluidHash(r.getInput()), r)); @@ -113,15 +110,11 @@ public void add(RefineryRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, fluid('ender') * 100, fluid('steam') * 150, item('minecraft:clay'), 25")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, fluid('ender') * 100, fluid('steam') * 150, item('minecraft:clay'), 25")) public RefineryRecipe add(int energy, FluidStack fluidInput, FluidStack outputFluid, ItemStack outputItem, int chance) { - return recipeBuilder() - .energy(energy) - .chance(chance) - .fluidInput(fluidInput) - .fluidOutput(outputFluid) - .output(outputItem) - .register(); + return recipeBuilder().energy(energy).chance(chance).fluidInput(fluidInput).fluidOutput(outputFluid).output(outputItem) + .register(); } public boolean remove(RefineryRecipe recipe) { @@ -145,9 +138,8 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(example = { - @Example(value = "item('thermalfoundation:material:771')", commented = true), @Example("fluid('refined_biofuel')") - }) + @MethodDescription(example = {@Example(value = "item('thermalfoundation:material:771')", commented = true), + @Example("fluid('refined_biofuel')")}) public boolean removeByOutput(IIngredient output) { return RefineryManagerAccessor.getRecipeMap().values().removeIf(r -> { if (output.test(r.getOutputFluid()) || output.test(r.getOutputItem())) { @@ -186,7 +178,9 @@ public void removeAll() { @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "RefineryManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "RefineryManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = RefineryManager.DEFAULT_ENERGY; @Property(valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "100")}) private int chance; @@ -204,9 +198,7 @@ public RecipeBuilder chance(int chance) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Refinery recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Refinery recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -216,11 +208,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(chance < 0 || chance > 100, "chance must be a non negative integer less than 100, yet it was {}", chance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RefineryRecipe register() { if (!validate()) return null; - RefineryRecipe recipe = RefineryRecipeAccessor.createRefineryRecipe(fluidInput.get(0), fluidOutput.get(0), output.getOrEmpty(0), energy, chance); + RefineryRecipe recipe = RefineryRecipeAccessor.createRefineryRecipe(fluidInput.get(0), fluidOutput.get(0), output + .getOrEmpty(0), + energy, chance); ModSupport.THERMAL_EXPANSION.get().refinery.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/RefineryPotion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/RefineryPotion.java index 10f6c3a83..8036ee456 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/RefineryPotion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/RefineryPotion.java @@ -1,8 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.util.helpers.FluidHelper; -import cofh.thermalexpansion.util.managers.machine.RefineryManager; -import cofh.thermalexpansion.util.managers.machine.RefineryManager.RefineryRecipe; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -13,28 +16,25 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; + +import cofh.core.util.helpers.FluidHelper; +import cofh.thermalexpansion.util.managers.machine.RefineryManager; +import cofh.thermalexpansion.util.managers.machine.RefineryManager.RefineryRecipe; @RegistryDescription public class RefineryPotion extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".fluidInput(fluid('water') * 100).fluidOutput(fluid('steam') * 200)"), - @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('steam') * 30).output(item('minecraft:clay')).chance(75).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".fluidInput(fluid('water') * 100).fluidOutput(fluid('steam') * 200)"), + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('steam') * 30).output(item('minecraft:clay')).chance(75).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> RefineryManagerAccessor.getRecipeMapPotion().values().removeIf(r -> r == recipe)); - restoreFromBackup().forEach(r -> RefineryManagerAccessor.getRecipeMapPotion().put(FluidHelper.getFluidHash(r.getInput()), r)); + restoreFromBackup().forEach(r -> RefineryManagerAccessor.getRecipeMapPotion().put(FluidHelper.getFluidHash(r.getInput()), + r)); } public void add(RefineryRecipe recipe) { @@ -42,15 +42,11 @@ public void add(RefineryRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, fluid('ender') * 100, fluid('steam') * 30, item('minecraft:clay'), 75")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, fluid('ender') * 100, fluid('steam') * 30, item('minecraft:clay'), 75")) public RefineryRecipe add(int energy, FluidStack fluidInput, FluidStack outputFluid, ItemStack outputItem, int chance) { - return recipeBuilder() - .energy(energy) - .chance(chance) - .fluidInput(fluidInput) - .fluidOutput(outputFluid) - .output(outputItem) - .register(); + return recipeBuilder().energy(energy).chance(chance).fluidInput(fluidInput).fluidOutput(outputFluid).output(outputItem) + .register(); } public boolean remove(RefineryRecipe recipe) { @@ -101,7 +97,9 @@ public void removeAll() { @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "RefineryManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "RefineryManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = RefineryManager.DEFAULT_ENERGY; @Property(valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "100")}) private int chance; @@ -119,9 +117,7 @@ public RecipeBuilder chance(int chance) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Refinery recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Refinery recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -131,11 +127,12 @@ public void validate(GroovyLog.Msg msg) { msg.add(chance < 0 || chance > 100, "chance must be a non negative integer less than 100, yet it was {}", chance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable RefineryRecipe register() { if (!validate()) return null; - RefineryRecipe recipe = RefineryRecipeAccessor.createRefineryRecipe(fluidInput.get(0), fluidOutput.get(0), output.getOrEmpty(0), energy, chance); + RefineryRecipe recipe = RefineryRecipeAccessor.createRefineryRecipe(fluidInput.get(0), fluidOutput.get(0), output + .getOrEmpty(0), + energy, chance); ModSupport.THERMAL_EXPANSION.get().refineryPotion.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Sawmill.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Sawmill.java index 66e2da7c3..c0ad546c5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Sawmill.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Sawmill.java @@ -1,7 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.thermalexpansion.util.managers.machine.SawmillManager; -import cofh.thermalexpansion.util.managers.machine.SawmillManager.SawmillRecipe; +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,26 +15,20 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -@RegistryDescription( - admonition = @Admonition("groovyscript.wiki.thermalexpansion.sawmill.note0") -) +import cofh.thermalexpansion.util.managers.machine.SawmillManager; +import cofh.thermalexpansion.util.managers.machine.SawmillManager.SawmillRecipe; + +@RegistryDescription(admonition = @Admonition("groovyscript.wiki.thermalexpansion.sawmill.note0")) public class Sawmill extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 2)"), - @Example(".input(item('minecraft:clay') * 4).output(item('minecraft:gold_ingot'), item('minecraft:diamond')).chance(25).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 2)"), + @Example(".input(item('minecraft:clay') * 4).output(item('minecraft:gold_ingot'), item('minecraft:diamond')).chance(25).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> SawmillManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); restoreFromBackup().forEach(r -> SawmillManagerAccessor.getRecipeMap().put(SawmillManager.convertInput(r.getInput()), r)); @@ -42,14 +39,10 @@ public void add(SawmillRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, item('minecraft:obsidian') * 4, item('minecraft:gold_ingot'), item('minecraft:diamond'), 25")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, item('minecraft:obsidian') * 4, item('minecraft:gold_ingot'), item('minecraft:diamond'), 25")) public SawmillRecipe add(int energy, IIngredient input, ItemStack outputItem, ItemStack secondayOutput, int chance) { - return recipeBuilder() - .energy(energy) - .chance(chance) - .input(input) - .output(outputItem, secondayOutput) - .register(); + return recipeBuilder().energy(energy).chance(chance).input(input).output(outputItem, secondayOutput).register(); } public boolean remove(SawmillRecipe recipe) { @@ -73,9 +66,7 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(example = { - @Example("item('thermalfoundation:material:800')"), @Example("item('minecraft:leather')") - }) + @MethodDescription(example = {@Example("item('thermalfoundation:material:800')"), @Example("item('minecraft:leather')")}) public boolean removeByOutput(IIngredient output) { return SawmillManagerAccessor.getRecipeMap().values().removeIf(r -> { if (output.test(r.getPrimaryOutput()) || output.test(r.getSecondaryOutput())) { @@ -101,7 +92,9 @@ public void removeAll() { @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "SawmillManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "SawmillManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = SawmillManager.DEFAULT_ENERGY; @Property(valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "100")}) private int chance; @@ -119,9 +112,7 @@ public RecipeBuilder chance(int chance) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Sawmill recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Sawmill recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -131,14 +122,14 @@ public void validate(GroovyLog.Msg msg) { msg.add(chance < 0 || chance > 100, "chance must be a non negative integer less than 100, yet it was {}", chance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SawmillRecipe register() { if (!validate()) return null; SawmillRecipe recipe = null; for (ItemStack itemStack : input.get(0).getMatchingStacks()) { - SawmillRecipe recipe1 = SawmillRecipeAccessor.createSawmillRecipe(itemStack, output.get(0), output.getOrEmpty(1), chance, energy); + SawmillRecipe recipe1 = SawmillRecipeAccessor.createSawmillRecipe(itemStack, output.get(0), output.getOrEmpty(1), + chance, energy); ModSupport.THERMAL_EXPANSION.get().sawmill.add(recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Smelter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Smelter.java index df664c4ca..3f5067680 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Smelter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/Smelter.java @@ -1,8 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.SmelterManager; -import cofh.thermalexpansion.util.managers.machine.SmelterManager.SmelterRecipe; +import java.util.Arrays; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -14,33 +19,28 @@ import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.List; +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.SmelterManager; +import cofh.thermalexpansion.util.managers.machine.SmelterManager.SmelterRecipe; @RegistryDescription public class Smelter extends VirtualizedRegistry { private final AbstractReloadableStorage fluxStorage = new AbstractReloadableStorage<>(); - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:clay'), item('minecraft:diamond')).output(item('minecraft:diamond') * 4)"), - @Example(".input(item('minecraft:clay'), item('minecraft:gold_ingot') * 2).output(item('minecraft:clay'), item('minecraft:diamond')).chance(5).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:clay'), item('minecraft:diamond')).output(item('minecraft:diamond') * 4)"), + @Example(".input(item('minecraft:clay'), item('minecraft:gold_ingot') * 2).output(item('minecraft:clay'), item('minecraft:diamond')).chance(5).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> SmelterManagerAccessor.getRecipeMap().values().removeIf(r -> r == recipe)); restoreFromBackup().forEach(r -> SmelterManagerAccessor.getRecipeMap().put(hash(r), r)); - fluxStorage.removeScripted().forEach(recipe -> SmelterManagerAccessor.getLockSet().removeIf(r -> r.equals(SmelterManager.convertInput(recipe)))); + fluxStorage.removeScripted().forEach(recipe -> SmelterManagerAccessor.getLockSet().removeIf(r -> r.equals(SmelterManager + .convertInput(recipe)))); fluxStorage.restoreFromBackup().forEach(r -> SmelterManagerAccessor.getLockSet().add(SmelterManager.convertInput(r))); } @@ -54,12 +54,14 @@ private List hash(ItemStack primaryInput, ItemS @MethodDescription(type = MethodDescription.Type.ADDITION) public boolean addFlux(ItemStack itemStack) { - return SmelterManagerAccessor.getLockSet().add(SmelterManager.convertInput(itemStack)) && fluxStorage.addScripted(itemStack); + return SmelterManagerAccessor.getLockSet().add(SmelterManager.convertInput(itemStack)) && fluxStorage.addScripted( + itemStack); } @MethodDescription public boolean removeFlux(ItemStack itemStack) { - return SmelterManagerAccessor.getLockSet().removeIf(r -> r.equals(SmelterManager.convertInput(itemStack))) && fluxStorage.addBackup(itemStack); + return SmelterManagerAccessor.getLockSet().removeIf(r -> r.equals(SmelterManager.convertInput(itemStack))) && fluxStorage + .addBackup(itemStack); } public void add(SmelterRecipe recipe) { @@ -67,14 +69,12 @@ public void add(SmelterRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example(value = "1000, item('minecraft:obsidian'), item('minecraft:gold_ingot') * 2, item('minecraft:clay'), item('minecraft:diamond'), 5", commented = true)) - public SmelterRecipe add(int energy, IIngredient input0, IIngredient input1, ItemStack output0, ItemStack output1, int chance) { - return recipeBuilder() - .energy(energy) - .chance(chance) - .input(input0, input1) - .output(output0, output1) - .register(); + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example(value = "1000, item('minecraft:obsidian'), item('minecraft:gold_ingot') * 2, item('minecraft:clay'), item('minecraft:diamond'), 5", + commented = true)) + public SmelterRecipe add(int energy, IIngredient input0, IIngredient input1, ItemStack output0, ItemStack output1, + int chance) { + return recipeBuilder().energy(energy).chance(chance).input(input0, input1).output(output0, output1).register(); } public boolean remove(SmelterRecipe recipe) { @@ -87,9 +87,7 @@ public boolean remove(SmelterRecipe recipe) { }); } - @MethodDescription(example = { - @Example("ore('sand')"), @Example("item('minecraft:iron_ingot')") - }) + @MethodDescription(example = {@Example("ore('sand')"), @Example("item('minecraft:iron_ingot')")}) public boolean removeByInput(IIngredient input) { return SmelterManagerAccessor.getRecipeMap().values().removeIf(r -> { if (input.test(r.getPrimaryInput()) || input.test(r.getSecondaryInput())) { @@ -126,7 +124,9 @@ public void removeAll() { @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "SmelterManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "SmelterManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = SmelterManager.DEFAULT_ENERGY; @Property(valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "100")}) private int chance; @@ -144,9 +144,7 @@ public RecipeBuilder chance(int chance) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Smelter recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Smelter recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -156,14 +154,15 @@ public void validate(GroovyLog.Msg msg) { msg.add(chance < 0 || chance > 100, "chance must be a non negative integer less than 100, yet it was {}", chance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable SmelterRecipe register() { if (!validate()) return null; SmelterRecipe recipe = null; for (ItemStack input0 : input.get(0).getMatchingStacks()) { for (ItemStack input1 : input.get(1).getMatchingStacks()) { - SmelterRecipe recipe1 = SmelterRecipeAccessor.createSmelterRecipe(input0, input1, output.get(0), output.getOrEmpty(1), chance, energy); + SmelterRecipe recipe1 = SmelterRecipeAccessor.createSmelterRecipe(input0, input1, output.get(0), output + .getOrEmpty(1), + chance, energy); ModSupport.THERMAL_EXPANSION.get().smelter.add(recipe1); if (recipe == null) recipe = recipe1; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/TransposerExtract.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/TransposerExtract.java index 8495db7ee..8743c682f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/TransposerExtract.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/TransposerExtract.java @@ -1,7 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.thermalexpansion.util.managers.machine.TransposerManager; -import cofh.thermalexpansion.util.managers.machine.TransposerManager.TransposerRecipe; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -11,45 +17,39 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.stream.Collectors; +import cofh.thermalexpansion.util.managers.machine.TransposerManager; +import cofh.thermalexpansion.util.managers.machine.TransposerManager.TransposerRecipe; -@RegistryDescription( - admonition = @Admonition("groovyscript.wiki.thermalexpansion.transposer.note0") -) +@RegistryDescription(admonition = @Admonition("groovyscript.wiki.thermalexpansion.transposer.note0")) public class TransposerExtract extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond') * 2).fluidOutput(fluid('water') * 100)"), - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 2).fluidOutput(fluid('water') * 50).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond') * 2).fluidOutput(fluid('water') * 100)"), + @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 2).fluidOutput(fluid('water') * 50).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> TransposerManagerAccessor.getRecipeMapExtract().values().removeIf(r -> r == recipe)); - restoreFromBackup().forEach(r -> TransposerManagerAccessor.getRecipeMapExtract().put(TransposerManager.convertInput(r.getInput()), r)); + restoreFromBackup().forEach(r -> TransposerManagerAccessor.getRecipeMapExtract().put(TransposerManager.convertInput(r + .getInput()), + r)); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void afterScriptLoad() { TransposerManagerAccessor.getValidationSet().clear(); - TransposerManagerAccessor.getValidationSet().addAll( - TransposerManagerAccessor.getRecipeMapExtract().values().stream().map(TransposerManager.TransposerRecipe::getInput).map(TransposerManager::convertInput).collect(Collectors.toList()) - ); + TransposerManagerAccessor.getValidationSet().addAll(TransposerManagerAccessor.getRecipeMapExtract().values().stream().map( + TransposerManager.TransposerRecipe::getInput) + .map(TransposerManager::convertInput) + .collect(Collectors.toList())); TransposerManagerAccessor.getValidationSet().clear(); - TransposerManagerAccessor.getValidationSet().addAll( - TransposerManagerAccessor.getRecipeMapFill().values().stream().map(TransposerManager.TransposerRecipe::getInput).map(TransposerManager::convertInput).collect(Collectors.toList()) - ); + TransposerManagerAccessor.getValidationSet().addAll(TransposerManagerAccessor.getRecipeMapFill().values().stream().map( + TransposerManager.TransposerRecipe::getInput) + .map(TransposerManager::convertInput) + .collect(Collectors.toList())); } public void add(TransposerRecipe recipe) { @@ -57,15 +57,10 @@ public void add(TransposerRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, item('minecraft:obsidian'), fluid('water') * 50, item('minecraft:diamond') * 2, 100")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, item('minecraft:obsidian'), fluid('water') * 50, item('minecraft:diamond') * 2, 100")) public TransposerRecipe add(int energy, IIngredient input, FluidStack outputFluid, ItemStack outputItem, int chance) { - return recipeBuilder() - .energy(energy) - .chance(chance) - .input(input) - .fluidOutput(outputFluid) - .output(outputItem) - .register(); + return recipeBuilder().energy(energy).chance(chance).input(input).fluidOutput(outputFluid).output(outputItem).register(); } public boolean remove(TransposerRecipe recipe) { @@ -89,9 +84,7 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(example = { - @Example("fluid('seed_oil')"), @Example("item('minecraft:bowl')") - }) + @MethodDescription(example = {@Example("fluid('seed_oil')"), @Example("item('minecraft:bowl')")}) public boolean removeByOutput(IIngredient output) { return TransposerManagerAccessor.getRecipeMapExtract().values().removeIf(r -> { if (output.test(r.getOutput()) || output.test(r.getFluid())) { @@ -118,7 +111,9 @@ public void removeAll() { @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "TransposerManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "TransposerManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = TransposerManager.DEFAULT_ENERGY; @Property(valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "100")}) private int chance; @@ -136,9 +131,7 @@ public RecipeBuilder chance(int chance) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Transposer Extract recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Transposer Extract recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -148,8 +141,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(chance < 0 || chance > 100, "chance must be a non negative integer less than 100, yet it was {}", chance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable TransposerRecipe register() { if (!validate()) return null; TransposerRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/TransposerFill.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/TransposerFill.java index 2e8f9fa0c..fbc01fb56 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/TransposerFill.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thermalexpansion/machine/TransposerFill.java @@ -1,8 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.thermalexpansion.machine; -import cofh.core.util.helpers.FluidHelper; -import cofh.thermalexpansion.util.managers.machine.TransposerManager; -import cofh.thermalexpansion.util.managers.machine.TransposerManager.TransposerRecipe; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -12,47 +19,38 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import cofh.core.util.helpers.FluidHelper; +import cofh.thermalexpansion.util.managers.machine.TransposerManager; +import cofh.thermalexpansion.util.managers.machine.TransposerManager.TransposerRecipe; -@RegistryDescription( - admonition = @Admonition("groovyscript.wiki.thermalexpansion.transposer.note0") -) +@RegistryDescription(admonition = @Admonition("groovyscript.wiki.thermalexpansion.transposer.note0")) public class TransposerFill extends VirtualizedRegistry { - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond') * 2).fluidInput(fluid('water') * 100)"), - @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 2).fluidInput(fluid('water') * 50).energy(1000)") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond') * 2).fluidInput(fluid('water') * 100)"), + @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 2).fluidInput(fluid('water') * 50).energy(1000)")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(recipe -> TransposerManagerAccessor.getRecipeMapFill().values().removeIf(r -> r == recipe)); restoreFromBackup().forEach(r -> TransposerManagerAccessor.getRecipeMapFill().put(hash(r), r)); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void afterScriptLoad() { TransposerManagerAccessor.getValidationSet().clear(); - TransposerManagerAccessor.getValidationSet().addAll( - TransposerManagerAccessor.getRecipeMapExtract().values().stream().map(TransposerManager.TransposerRecipe::getInput).map(TransposerManager::convertInput).collect(Collectors.toList()) - ); + TransposerManagerAccessor.getValidationSet().addAll(TransposerManagerAccessor.getRecipeMapExtract().values().stream().map( + TransposerManager.TransposerRecipe::getInput) + .map(TransposerManager::convertInput) + .collect(Collectors.toList())); TransposerManagerAccessor.getValidationSet().clear(); - TransposerManagerAccessor.getValidationSet().addAll( - TransposerManagerAccessor.getRecipeMapFill().values().stream().map(TransposerManager.TransposerRecipe::getInput).map(TransposerManager::convertInput).collect(Collectors.toList()) - ); + TransposerManagerAccessor.getValidationSet().addAll(TransposerManagerAccessor.getRecipeMapFill().values().stream().map( + TransposerManager.TransposerRecipe::getInput) + .map(TransposerManager::convertInput) + .collect(Collectors.toList())); } private List hash(TransposerRecipe recipe) { @@ -68,15 +66,10 @@ public void add(TransposerRecipe recipe) { addScripted(recipe); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("1000, item('minecraft:obsidian'), fluid('water') * 50, item('minecraft:diamond') * 2, 100")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("1000, item('minecraft:obsidian'), fluid('water') * 50, item('minecraft:diamond') * 2, 100")) public TransposerRecipe add(int energy, IIngredient input, FluidStack fluidInput, ItemStack outputItem, int chance) { - return recipeBuilder() - .energy(energy) - .chance(chance) - .input(input) - .fluidInput(fluidInput) - .output(outputItem) - .register(); + return recipeBuilder().energy(energy).chance(chance).input(input).fluidInput(fluidInput).output(outputItem).register(); } public boolean remove(TransposerRecipe recipe) { @@ -89,9 +82,7 @@ public boolean remove(TransposerRecipe recipe) { }); } - @MethodDescription(example = { - @Example("fluid('glowstone')"), @Example("item('minecraft:concrete_powder:3')") - }) + @MethodDescription(example = {@Example("fluid('glowstone')"), @Example("item('minecraft:concrete_powder:3')")}) public boolean removeByInput(IIngredient input) { return TransposerManagerAccessor.getRecipeMapFill().values().removeIf(r -> { if (input.test(r.getInput()) || input.test(r.getFluid())) { @@ -129,7 +120,9 @@ public void removeAll() { @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) public static class RecipeBuilder extends AbstractRecipeBuilder { - @Property(defaultValue = "TransposerManager.DEFAULT_ENERGY", valid = @Comp(value = "0", type = Comp.Type.GT), value = "groovyscript.wiki.thermalexpansion.energy.value") + @Property(defaultValue = "TransposerManager.DEFAULT_ENERGY", + valid = @Comp(value = "0", type = Comp.Type.GT), + value = "groovyscript.wiki.thermalexpansion.energy.value") private int energy = TransposerManager.DEFAULT_ENERGY; @Property(valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "100")}) private int chance; @@ -147,9 +140,7 @@ public RecipeBuilder chance(int chance) { } @Override - public String getErrorMsg() { - return "Error adding Thermal Expansion Transposer Fill recipe"; - } + public String getErrorMsg() { return "Error adding Thermal Expansion Transposer Fill recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -159,8 +150,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(chance < 0 || chance > 100, "chance must be a non negative integer less than 100, yet it was {}", chance); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable TransposerRecipe register() { if (!validate()) return null; TransposerRecipe recipe = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Alloying.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Alloying.java index 0caf11fe2..17b223215 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Alloying.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Alloying.java @@ -1,5 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; +import java.util.Arrays; +import java.util.List; + +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,12 +14,8 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; -import slimeknights.tconstruct.library.smeltery.AlloyRecipe; -import java.util.Arrays; -import java.util.List; +import slimeknights.tconstruct.library.smeltery.AlloyRecipe; @RegistryDescription public class Alloying extends VirtualizedRegistry { @@ -22,14 +25,14 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(TinkerRegistryAccessor.getAlloyRegistry()::remove); restoreFromBackup().forEach(TinkerRegistryAccessor.getAlloyRegistry()::add); } - @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("fluid('lava') * 144, fluid('water') * 500, fluid('iron') * 5, fluid('clay') * 60")) + @MethodDescription(type = MethodDescription.Type.ADDITION, + example = @Example("fluid('lava') * 144, fluid('water') * 500, fluid('iron') * 5, fluid('clay') * 60")) public AlloyRecipe add(FluidStack output, FluidStack... inputs) { AlloyRecipe recipe = new AlloyRecipe(output, inputs); add(recipe); @@ -57,14 +60,13 @@ public boolean removeByOutput(FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Alloying recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Alloying recipe").add("could not find recipe with output {}", output) + .error().post(); return false; } - @MethodDescription(description = "groovyscript.wiki.tconstruct.alloying.removeByInputs", example = @Example("fluid('cobalt')*2,fluid('ardite')*2")) + @MethodDescription(description = "groovyscript.wiki.tconstruct.alloying.removeByInputs", + example = @Example("fluid('cobalt')*2,fluid('ardite')*2")) public boolean removeByInputs(FluidStack... inputs) { List list = Arrays.asList(inputs); if (TinkerRegistryAccessor.getAlloyRegistry().removeIf(recipe -> { @@ -73,10 +75,9 @@ public boolean removeByInputs(FluidStack... inputs) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Alloying recipe") - .add("could not find recipe with inputs {}", Arrays.asList(inputs)) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Alloying recipe").add("could not find recipe with inputs {}", Arrays + .asList(inputs)) + .error().post(); return false; } @@ -89,10 +90,9 @@ public boolean removeByInputsAndOutput(FluidStack output, FluidStack... inputs) return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Alloying recipe") - .add("could not find recipe with inputs {} and output {}", Arrays.asList(inputs), output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Alloying recipe").add( + "could not find recipe with inputs {} and output {}", + Arrays.asList(inputs), output).error().post(); return false; } @@ -107,22 +107,20 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(TinkerRegistryAccessor.getAlloyRegistry()).setRemover(this::remove); } - @Property(property = "fluidInput", valid = {@Comp(value = "2", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) + @Property(property = "fluidInput", + valid = {@Comp(value = "2", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) @Property(property = "fluidOutput", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { @Override - public String getErrorMsg() { - return "Error adding Tinkers Construct Alloying recipe"; - } + public String getErrorMsg() { return "Error adding Tinkers Construct Alloying recipe"; } @Override public void validate(GroovyLog.Msg msg) { validateFluids(msg, 2, fluidInput.size() + 2, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable AlloyRecipe register() { if (!validate()) return null; AlloyRecipe recipe = new AlloyRecipe(fluidOutput.get(0), fluidInput.toArray(new FluidStack[0])); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingBasin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingBasin.java index 8d0f29906..221444dea 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingBasin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingBasin.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -10,10 +16,7 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; + import slimeknights.tconstruct.library.smeltery.CastingRecipe; import slimeknights.tconstruct.library.smeltery.ICastingRecipe; @@ -29,8 +32,7 @@ public CastingBasin() { super(Alias.generateOfClass(CastingBasin.class).andGenerate("Basin")); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(TinkerRegistryAccessor.getBasinCastRegistry()::remove); restoreFromBackup().forEach(TinkerRegistryAccessor.getBasinCastRegistry()::add); @@ -57,10 +59,8 @@ public boolean removeByOutput(ItemStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Casting Basin recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Casting Basin recipe").add("could not find recipe with output {}", output) + .error().post(); return false; } @@ -72,10 +72,8 @@ public boolean removeByInput(FluidStack input) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Casting Basin recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Casting Basin recipe").add("could not find recipe with input {}", input) + .error().post(); return false; } @@ -88,10 +86,8 @@ public boolean removeByCast(IIngredient cast) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Casting Basin recipe") - .add("could not find recipe with cast {}", cast) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Casting Basin recipe").add("could not find recipe with cast {}", cast) + .error().post(); return false; } @@ -106,8 +102,7 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(TinkerRegistryAccessor.getBasinCastRegistry()).setRemover(this::remove); } - @Property(property = "fluidInput", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -141,9 +136,7 @@ public RecipeBuilder cast(IIngredient ingredient) { } @Override - public String getErrorMsg() { - return "Error adding Tinkers Construct Casting Basin recipe"; - } + public String getErrorMsg() { return "Error adding Tinkers Construct Casting Basin recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -151,12 +144,12 @@ public void validate(GroovyLog.Msg msg) { validateItems(msg, 0, 0, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ICastingRecipe register() { if (!validate()) return null; - CastingRecipe recipe = new CastingRecipe(output.get(0), cast != null ? MeltingRecipeBuilder.recipeMatchFromIngredient(cast) - : null, fluidInput.get(0), time, consumesCast, false); + CastingRecipe recipe = new CastingRecipe(output.get(0), cast != null ? MeltingRecipeBuilder.recipeMatchFromIngredient( + cast) : + null, fluidInput.get(0), time, consumesCast, false); add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingTable.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingTable.java index 3e15466d6..2f577c98f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingTable.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingTable.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -10,10 +16,7 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.Nullable; + import slimeknights.tconstruct.library.smeltery.CastingRecipe; import slimeknights.tconstruct.library.smeltery.ICastingRecipe; @@ -29,8 +32,7 @@ public CastingTable() { super(Alias.generateOfClass(CastingTable.class).andGenerate("Table")); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(TinkerRegistryAccessor.getTableCastRegistry()::remove); restoreFromBackup().forEach(TinkerRegistryAccessor.getTableCastRegistry()::add); @@ -57,10 +59,8 @@ public boolean removeByOutput(ItemStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Casting Table recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Casting Table recipe").add("could not find recipe with output {}", output) + .error().post(); return false; } @@ -72,25 +72,22 @@ public boolean removeByInput(FluidStack input) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Casting Table recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Casting Table recipe").add("could not find recipe with input {}", input) + .error().post(); return false; } @MethodDescription(example = @Example("item('minecraft:bucket')")) public boolean removeByCast(IIngredient cast) { if (TinkerRegistryAccessor.getTableCastRegistry().removeIf(recipe -> { - boolean found = recipe.matches(cast.getMatchingStacks()[0], recipe.getFluid(cast.getMatchingStacks()[0], FluidRegistry.WATER).getFluid()); + boolean found = recipe.matches(cast.getMatchingStacks()[0], recipe.getFluid(cast.getMatchingStacks()[0], + FluidRegistry.WATER).getFluid()); if (found) addBackup(recipe); return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Casting Table recipe") - .add("could not find recipe with cast {}", cast) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Casting Table recipe").add("could not find recipe with cast {}", cast) + .error().post(); return false; } @@ -105,8 +102,7 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(TinkerRegistryAccessor.getTableCastRegistry()).setRemover(this::remove); } - @Property(property = "fluidInput", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { @Property @@ -140,9 +136,7 @@ public RecipeBuilder cast(IIngredient ingredient) { } @Override - public String getErrorMsg() { - return "Error adding Tinkers Construct Casting Table recipe"; - } + public String getErrorMsg() { return "Error adding Tinkers Construct Casting Table recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -150,14 +144,14 @@ public void validate(GroovyLog.Msg msg) { validateItems(msg, 0, 0, 1, 1); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ICastingRecipe register() { if (!validate()) return null; - CastingRecipe recipe = new CastingRecipe(output.get(0), cast != null ? MeltingRecipeBuilder.recipeMatchFromIngredient(cast) - : null, fluidInput.get(0), time, consumesCast, false); + CastingRecipe recipe = new CastingRecipe(output.get(0), cast != null ? MeltingRecipeBuilder.recipeMatchFromIngredient( + cast) : + null, fluidInput.get(0), time, consumesCast, false); add(recipe); return recipe; } } -} \ No newline at end of file +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Drying.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Drying.java index 017be0918..8b820f1c4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Drying.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Drying.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -9,9 +14,7 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import org.jetbrains.annotations.Nullable; + import slimeknights.tconstruct.library.DryingRecipe; @RegistryDescription @@ -22,8 +25,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(TinkerRegistryAccessor.getDryingRegistry()::remove); restoreFromBackup().forEach(TinkerRegistryAccessor.getDryingRegistry()::add); @@ -58,10 +60,8 @@ public boolean removeByInput(IIngredient input) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Drying recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Drying recipe").add("could not find recipe with input {}", input).error() + .post(); return false; } @@ -73,10 +73,8 @@ public boolean removeByOutput(ItemStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Drying recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Drying recipe").add("could not find recipe with output {}", output) + .error().post(); return false; } @@ -89,10 +87,8 @@ public boolean removeByInputAndOutput(IIngredient input, ItemStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Drying recipe") - .add("could not find recipe with input {} and output {}", input, output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Drying recipe").add("could not find recipe with input {} and output {}", + input, output).error().post(); return false; } @@ -107,8 +103,7 @@ public SimpleObjectStream streamRecipes() { return new SimpleObjectStream<>(TinkerRegistryAccessor.getDryingRegistry()).setRemover(this::remove); } - @Property(property = "input", valid = @Comp("1")) - @Property(property = "output", valid = @Comp("1")) + @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "20", valid = @Comp(value = "1", type = Comp.Type.GTE)) @@ -121,9 +116,7 @@ public RecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding Tinkers Construct Drying recipe"; - } + public String getErrorMsg() { return "Error adding Tinkers Construct Drying recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -131,11 +124,11 @@ public void validate(GroovyLog.Msg msg) { msg.add(time < 1, "Recipe time must be at least 1, got " + time); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable DryingRecipe register() { if (!validate()) return null; - DryingRecipe recipe = new DryingRecipe(MeltingRecipeBuilder.recipeMatchFromIngredient(input.get(0)), output.get(0), time); + DryingRecipe recipe = new DryingRecipe(MeltingRecipeBuilder.recipeMatchFromIngredient(input.get(0)), output.get(0), + time); add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/EntityMelting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/EntityMelting.java index 6a4d44c3a..4d26419d8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/EntityMelting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/EntityMelting.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.entity.EntityList; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,14 +18,6 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.IRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.entity.EntityList; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.stream.Collectors; @RegistryDescription public class EntityMelting extends VirtualizedRegistry { @@ -25,8 +27,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(recipe -> TinkerRegistryAccessor.getEntityMeltingRegistry().remove(recipe.name, recipe.result)); restoreFromBackup().forEach(recipe -> TinkerRegistryAccessor.getEntityMeltingRegistry().put(recipe.name, recipe.result)); @@ -34,7 +35,8 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.QUERY) protected List getAllRecipes() { - return TinkerRegistryAccessor.getEntityMeltingRegistry().entrySet().stream().map(EntityMeltingRecipe::fromMapEntry).collect(Collectors.toList()); + return TinkerRegistryAccessor.getEntityMeltingRegistry().entrySet().stream().map(EntityMeltingRecipe::fromMapEntry) + .collect(Collectors.toList()); } public EntityMeltingRecipe add(EntityEntry entity, FluidStack output) { @@ -65,10 +67,8 @@ public boolean removeByInput(EntityEntry entity) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Entity Melting recipe") - .add("could not find recipe with input {}", name) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Entity Melting recipe").add("could not find recipe with input {}", name) + .error().post(); return false; } @@ -80,16 +80,15 @@ public boolean removeByOutput(FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Entity Melting recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Entity Melting recipe").add("could not find recipe with output {}", + output).error().post(); return false; } @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - TinkerRegistryAccessor.getEntityMeltingRegistry().forEach((name, result) -> addBackup(new EntityMeltingRecipe(name, result))); + TinkerRegistryAccessor.getEntityMeltingRegistry().forEach((name, result) -> addBackup(new EntityMeltingRecipe(name, + result))); TinkerRegistryAccessor.getEntityMeltingRegistry().clear(); } @@ -132,9 +131,7 @@ public RecipeBuilder input(EntityEntry entity) { return input(entity.getRegistryName()); } - private String getErrorMsg() { - return "Error adding Tinkers Construct Entity Melting recipe"; - } + private String getErrorMsg() { return "Error adding Tinkers Construct Entity Melting recipe"; } private void validate(GroovyLog.Msg msg) { msg.add(input == null || EntityList.getClass(input) == null, "Expected valid entity name, got " + input); @@ -148,8 +145,7 @@ public boolean validate() { return !msg.postIfNotEmpty(); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable EntityMeltingRecipe register() { if (!validate()) return null; EntityMeltingRecipe recipe = new EntityMeltingRecipe(input, output); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Materials.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Materials.java index 3e019c7d1..eab9b8866 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Materials.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Materials.java @@ -10,6 +10,7 @@ import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.NamedRegistry; + import slimeknights.tconstruct.library.TinkerRegistry; import slimeknights.tconstruct.library.materials.Material; import slimeknights.tconstruct.library.traits.ITrait; @@ -38,24 +39,23 @@ public void addMaterial(GroovyMaterial material) { public boolean removeMaterial(String material) { if (TinkerRegistryAccessor.getMaterials().entrySet().removeIf(entry -> entry.getKey().equals(material))) return true; - GroovyLog.msg("Error removing Tinkers Construct material") - .add("could not find material with name {}", material) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct material").add("could not find material with name {}", material).error() + .post(); return false; } public boolean removeTrait(String trait) { if (TinkerRegistryAccessor.getTraits().entrySet().removeIf(entry -> { boolean found = entry.getKey().equals(trait); - if (found) - TinkerRegistryAccessor.getMaterials().values().forEach(material -> ((MaterialAccessor) material).getTraits().values().forEach(l -> l.removeIf(t -> t.getIdentifier().equals(trait)))); + if (found) TinkerRegistryAccessor.getMaterials().values().forEach(material -> ((MaterialAccessor) material) + .getTraits() + .values() + .forEach(l -> l.removeIf(t -> t.getIdentifier() + .equals(trait)))); return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct material trait") - .add("could not find trait with name {}", trait) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct material trait").add("could not find trait with name {}", trait).error() + .post(); return false; } @@ -68,7 +68,9 @@ public boolean removeMaterial(Material material) { public boolean removeTrait(ITrait trait) { if (trait == null) return false; TinkerRegistryAccessor.getTraits().remove(trait.getIdentifier(), trait); - TinkerRegistryAccessor.getMaterials().values().forEach(material -> ((MaterialAccessor) material).getTraits().values().forEach(l -> l.removeIf(t -> t.getIdentifier().equals(trait.getIdentifier())))); + TinkerRegistryAccessor.getMaterials().values().forEach(material -> ((MaterialAccessor) material).getTraits().values() + .forEach(l -> l.removeIf(t -> t.getIdentifier() + .equals(trait.getIdentifier())))); return true; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Melting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Melting.java index 007ad223a..3a5d38fc3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Melting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Melting.java @@ -1,5 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -11,9 +15,7 @@ import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeRegistry; import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.fluids.FluidStack; + import slimeknights.tconstruct.library.smeltery.MeltingRecipe; @RegistryDescription @@ -24,8 +26,7 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(this); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(TinkerRegistryAccessor.getMeltingRegistry()::remove); restoreFromBackup().forEach(TinkerRegistryAccessor.getMeltingRegistry()::add); @@ -33,7 +34,8 @@ public void onReload() { @MethodDescription(type = MethodDescription.Type.ADDITION) public MeltingRecipe add(IIngredient input, FluidStack output, int temp) { - MeltingRecipe recipe = new MeltingRecipe(MeltingRecipeBuilder.recipeMatchFromIngredient(input, output.amount), output, temp); + MeltingRecipe recipe = new MeltingRecipe(MeltingRecipeBuilder.recipeMatchFromIngredient(input, output.amount), output, + temp); add(recipe); return recipe; } @@ -61,10 +63,8 @@ public boolean removeByInput(IIngredient input) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Melting recipe") - .add("could not find recipe with input {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Melting recipe").add("could not find recipe with input {}", input).error() + .post(); return false; } @@ -76,10 +76,8 @@ public boolean removeByOutput(FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Melting recipe") - .add("could not find recipe with output {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Melting recipe").add("could not find recipe with output {}", output) + .error().post(); return false; } @@ -92,10 +90,8 @@ public boolean removeByInputAndOutput(IIngredient input, FluidStack output) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Melting recipe") - .add("could not find recipe with input {} and output {}", input, output) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Melting recipe").add("could not find recipe with input {} and output {}", + input, output).error().post(); return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/SmelteryFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/SmelteryFuel.java index 8e35dcea0..f3f9f5f57 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/SmelteryFuel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/SmelteryFuel.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -10,35 +15,31 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraftforge.fluids.FluidStack; - -import java.util.List; -import java.util.stream.Collectors; @RegistryDescription(category = RegistryDescription.Category.ENTRIES) public class SmelteryFuel extends VirtualizedRegistry { - @Override - @GroovyBlacklist + @Override @GroovyBlacklist protected AbstractReloadableStorage createRecipeStorage() { - return new AbstractReloadableStorage<>() { - @Override - @GroovyBlacklist + return new AbstractReloadableStorage<>() + { + + @Override @GroovyBlacklist protected boolean compareRecipe(SmelteryFuelRecipe recipe, SmelteryFuelRecipe recipe2) { return recipe.equals(recipe2); } }; } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { removeScripted().forEach(recipe -> TinkerRegistryAccessor.getSmelteryFuels().remove(recipe.fluid, recipe.duration)); restoreFromBackup().forEach(recipe -> TinkerRegistryAccessor.getSmelteryFuels().put(recipe.fluid, recipe.duration)); } protected List getAllRecipes() { - return TinkerRegistryAccessor.getSmelteryFuels().entrySet().stream().map(SmelteryFuelRecipe::fromMapEntry).collect(Collectors.toList()); + return TinkerRegistryAccessor.getSmelteryFuels().entrySet().stream().map(SmelteryFuelRecipe::fromMapEntry).collect( + Collectors.toList()); } @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("fluid('water'), 250")) @@ -56,10 +57,8 @@ public boolean removeFuel(FluidStack fluid) { return found; })) return true; - GroovyLog.msg("Error removing Tinkers Construct Smeltery Fuel") - .add("could not find smeltery fuel entry for {}", fluid) - .error() - .post(); + GroovyLog.msg("Error removing Tinkers Construct Smeltery Fuel").add("could not find smeltery fuel entry for {}", fluid) + .error().post(); return false; } @@ -78,7 +77,8 @@ public boolean remove(SmelteryFuelRecipe recipe) { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - TinkerRegistryAccessor.getSmelteryFuels().forEach((fluid, duration) -> addBackup(new SmelteryFuelRecipe(fluid, duration))); + TinkerRegistryAccessor.getSmelteryFuels().forEach((fluid, duration) -> addBackup(new SmelteryFuelRecipe(fluid, + duration))); TinkerRegistryAccessor.getSmelteryFuels().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/TinkersConstruct.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/TinkersConstruct.java index 9a1ca846e..4ce8e9a19 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/TinkersConstruct.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/TinkersConstruct.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; +import net.minecraftforge.common.MinecraftForge; + import com.cleanroommc.groovyscript.api.IObjectParser; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; @@ -8,7 +10,7 @@ import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.material.ToolMaterialBuilder; import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.material.traits.TraitRegistryEvent; import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; -import net.minecraftforge.common.MinecraftForge; + import slimeknights.tconstruct.library.materials.Material; import slimeknights.tconstruct.library.traits.ITrait; @@ -25,22 +27,21 @@ public class TinkersConstruct extends GroovyPropertyContainer { @Override public void initialize(GroovyContainer container) { - container.objectMapperBuilder("toolMaterial", Material.class) - .parser(IObjectParser.wrapStringGetter(TinkerRegistryAccessor.getMaterials()::get)) - .completerOfNames(TinkerRegistryAccessor.getMaterials()::keySet) - .docOfType("tool material") - .register(); - container.objectMapperBuilder("toolTrait", ITrait.class) - .parser(IObjectParser.wrapStringGetter(TinkerRegistryAccessor.getTraits()::get)) - .completerOfNamed(TinkerRegistryAccessor.getTraits()::keySet, v -> v.endsWith("_armor") ? null : v) // only suggest non armor traits - .docOfType("tool trait") - .register(); - container.objectMapperBuilder("armorTrait", ITrait.class) - .parser(IObjectParser.wrapStringGetter(s -> TinkerRegistryAccessor.getTraits().get(s + "_armor"))) - .completerOfNamed(TinkerRegistryAccessor.getTraits()::keySet, - v -> v.endsWith("_armor") ? v.substring(0, v.length() - 6) : null) // only suggest armor traits - .docOfType("armor trait") - .register(); + container.objectMapperBuilder("toolMaterial", Material.class).parser(IObjectParser.wrapStringGetter(TinkerRegistryAccessor + .getMaterials()::get)) + .completerOfNames(TinkerRegistryAccessor.getMaterials()::keySet).docOfType("tool material").register(); + container.objectMapperBuilder("toolTrait", ITrait.class).parser(IObjectParser.wrapStringGetter(TinkerRegistryAccessor + .getTraits()::get)) + .completerOfNamed(TinkerRegistryAccessor.getTraits()::keySet, v -> v.endsWith("_armor") ? null : v) // only suggest non armor traits + .docOfType("tool trait").register(); + container.objectMapperBuilder("armorTrait", ITrait.class).parser(IObjectParser.wrapStringGetter( + s -> TinkerRegistryAccessor.getTraits() + .get(s + + "_armor"))) + .completerOfNamed(TinkerRegistryAccessor.getTraits()::keySet, v -> v.endsWith("_armor") ? v.substring(0, v + .length() - 6) : + null) // only suggest armor traits + .docOfType("armor trait").register(); } public static void init() { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/GroovyMaterial.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/GroovyMaterial.java index cb1ae9924..fd43e7bb4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/GroovyMaterial.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/GroovyMaterial.java @@ -1,22 +1,25 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.material; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.helper.ingredient.ItemsIngredient; -import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; +import java.util.List; +import java.util.Map; +import java.util.function.BiFunction; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; + import org.jetbrains.annotations.NotNull; + +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.helper.ingredient.ItemsIngredient; +import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; + import slimeknights.tconstruct.library.TinkerRegistry; import slimeknights.tconstruct.library.materials.Material; import slimeknights.tconstruct.library.traits.ITrait; -import java.util.List; -import java.util.Map; -import java.util.function.BiFunction; - public class GroovyMaterial extends Material { public boolean hidden; @@ -34,30 +37,23 @@ public GroovyMaterial(String identifier, int color, Map> tr } public GroovyMaterial addItem(IIngredient item, int amountNeeded, int amountMatched) { - if (item instanceof OreDictIngredient) addItem(((OreDictIngredient) item).getOreDict(), amountNeeded, amountMatched * 144); + if (item instanceof OreDictIngredient) addItem(((OreDictIngredient) item).getOreDict(), amountNeeded, + amountMatched * 144); else addItem(item.getMatchingStacks()[0], amountNeeded, amountMatched * 144); return this; } @Override - public boolean isHidden() { - return hidden; - } + public boolean isHidden() { return hidden; } @Override - public ItemStack getRepresentativeItem() { - return representativeItem.getMatchingStacks()[0]; - } + public ItemStack getRepresentativeItem() { return representativeItem.getMatchingStacks()[0]; } @Override - public ItemStack getShard() { - return shard != null ? shard.getMatchingStacks()[0] : ItemStack.EMPTY; - } + public ItemStack getShard() { return shard != null ? shard.getMatchingStacks()[0] : ItemStack.EMPTY; } @Override - public void setShard(@NotNull ItemStack stack) { - this.shard = new ItemsIngredient(stack); - } + public void setShard(@NotNull ItemStack stack) { this.shard = new ItemsIngredient(stack); } @Override public boolean hasFluid() { @@ -65,9 +61,7 @@ public boolean hasFluid() { } @Override - public Fluid getFluid() { - return fluidStack != null ? fluidStack.getFluid() : null; - } + public Fluid getFluid() { return fluidStack != null ? fluidStack.getFluid() : null; } @Override public Material setFluid(Fluid fluid) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/GroovyMaterialIntegration.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/GroovyMaterialIntegration.java index dfa952a2c..a303e0fbe 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/GroovyMaterialIntegration.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/GroovyMaterialIntegration.java @@ -11,8 +11,7 @@ public GroovyMaterialIntegration(Material material) { } @Override - public void preInit() { - } + public void preInit() {} @Override public void integrate() { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/ToolMaterialBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/ToolMaterialBuilder.java index ace063821..01a1251e4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/ToolMaterialBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/ToolMaterialBuilder.java @@ -1,26 +1,29 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.material; +import java.awt.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.BiFunction; + +import javax.annotation.Nullable; + +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.common.Loader; + +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; + import c4.conarm.lib.materials.ArmorMaterialType; import c4.conarm.lib.materials.CoreMaterialStats; import c4.conarm.lib.materials.PlatesMaterialStats; import c4.conarm.lib.materials.TrimMaterialStats; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.common.Loader; import slimeknights.tconstruct.library.TinkerRegistry; import slimeknights.tconstruct.library.materials.*; import slimeknights.tconstruct.library.traits.ITrait; -import javax.annotation.Nullable; -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.BiFunction; - public class ToolMaterialBuilder { public static final List addedMaterials = new ArrayList<>(); @@ -136,17 +139,11 @@ public ToolMaterialBuilder isCastable(boolean castable) { return this; } - public ToolMaterialBuilder isHidden() { - return isHidden(!hidden); - } + public ToolMaterialBuilder isHidden() { return isHidden(!hidden); } - public ToolMaterialBuilder isCraftable() { - return isCraftable(!craftable); - } + public ToolMaterialBuilder isCraftable() { return isCraftable(!craftable); } - public ToolMaterialBuilder isCastable() { - return isCastable(!castable); - } + public ToolMaterialBuilder isCastable() { return isCastable(!castable); } public ToolMaterialBuilder addHeadStats(int durability, float miningSpeed, float attackDamage, int harvestLevel) { this.stats.put(MaterialTypes.HEAD, new HeadMaterialStats(durability, miningSpeed, attackDamage, harvestLevel)); @@ -194,7 +191,8 @@ public ToolMaterialBuilder addCoreStats(float durability, float defense) { } public ToolMaterialBuilder addPlatesStats(float modifier, float durability, float toughness) { - if (Loader.isModLoaded("conarm")) this.stats.put(ArmorMaterialType.PLATES, new PlatesMaterialStats(modifier, durability, toughness)); + if (Loader.isModLoaded("conarm")) this.stats.put(ArmorMaterialType.PLATES, new PlatesMaterialStats(modifier, durability, + toughness)); return this; } @@ -203,9 +201,7 @@ public ToolMaterialBuilder addTrimStats(float durability) { return this; } - public String getErrorMsg() { - return "Error adding Tinkers' Construct Material"; - } + public String getErrorMsg() { return "Error adding Tinkers' Construct Material"; } public boolean validate() { GroovyLog.Msg msg = GroovyLog.msg(this.getErrorMsg()).error(); @@ -237,13 +233,15 @@ public Material register() { if (stat != null) material.addStats(stat); }); repairIngredients.forEach(repair -> { - if (repair.ingredient instanceof OreDictIngredient) - material.addItem(((OreDictIngredient) repair.ingredient).getOreDict(), repair.amountNeeded, repair.amountMatched * 144); + if (repair.ingredient instanceof OreDictIngredient) material.addItem(((OreDictIngredient) repair.ingredient) + .getOreDict(), + repair.amountNeeded, repair.amountMatched * 144); else material.addItem(repair.ingredient.getMatchingStacks()[0], repair.amountNeeded, repair.amountMatched * 144); }); if (representativeItem != null) { - if (representativeItem instanceof OreDictIngredient) material.setRepresentativeItem(((OreDictIngredient) representativeItem).getOreDict()); + if (representativeItem instanceof OreDictIngredient) material.setRepresentativeItem( + ((OreDictIngredient) representativeItem).getOreDict()); else material.representativeItem = representativeItem; } material.shard = shard; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/armory/GroovyArmorTrait.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/armory/GroovyArmorTrait.java index a5a1db4d6..93a69ca35 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/armory/GroovyArmorTrait.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/armory/GroovyArmorTrait.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.material.armory; -import c4.conarm.lib.modifiers.ArmorModifierTrait; -import c4.conarm.lib.traits.IArmorTrait; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; +import c4.conarm.lib.modifiers.ArmorModifierTrait; +import c4.conarm.lib.traits.IArmorTrait; + public class GroovyArmorTrait extends ArmorModifierTrait implements IArmorTrait { public GroovyArmorTrait(String identifier, int color) { @@ -16,7 +17,8 @@ public GroovyArmorTrait(String identifier, int color, int maxLevel, int countPer } public GroovyArmorTrait addItem(IIngredient ingredient, int amountNeeded, int amountMatched) { - if (ingredient instanceof OreDictIngredient) addItem(((OreDictIngredient) ingredient).getOreDict(), amountNeeded, amountMatched * 144); + if (ingredient instanceof OreDictIngredient) addItem(((OreDictIngredient) ingredient).getOreDict(), amountNeeded, + amountMatched * 144); else addItem(ingredient.getMatchingStacks()[0], amountNeeded, amountMatched * 144); return this; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/traits/GroovyTrait.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/traits/GroovyTrait.java index 3dc38405f..c22d3b15c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/traits/GroovyTrait.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/material/traits/GroovyTrait.java @@ -2,6 +2,7 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; + import slimeknights.tconstruct.library.modifiers.ModifierTrait; import slimeknights.tconstruct.library.traits.ITrait; @@ -16,7 +17,8 @@ public GroovyTrait(String identifier, int color) { } public GroovyTrait addItem(IIngredient ingredient, int amountNeeded, int amountMatched) { - if (ingredient instanceof OreDictIngredient) addItem(((OreDictIngredient) ingredient).getOreDict(), amountNeeded, amountMatched); + if (ingredient instanceof OreDictIngredient) addItem(((OreDictIngredient) ingredient).getOreDict(), amountNeeded, + amountMatched); else addItem(ingredient.getMatchingStacks()[0], amountNeeded, amountMatched); return this; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/EntityMeltingRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/EntityMeltingRecipe.java index 719c584e7..f3772f62d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/EntityMeltingRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/EntityMeltingRecipe.java @@ -1,11 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe; +import java.util.Map; + import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.registry.EntityEntry; -import java.util.Map; - public class EntityMeltingRecipe { public final FluidStack result; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeBuilder.java index 5c49a1bad..dc3bc2208 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeBuilder.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Comp; @@ -9,7 +11,7 @@ import com.cleanroommc.groovyscript.core.mixin.tconstruct.MeltingRecipeAccessor; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import org.jetbrains.annotations.Nullable; + import slimeknights.mantle.util.RecipeMatch; import slimeknights.tconstruct.library.smeltery.MeltingRecipe; @@ -22,8 +24,8 @@ public class MeltingRecipeBuilder extends AbstractRecipeBuilder { private final String recipeName; public static RecipeMatch recipeMatchFromIngredient(IIngredient ingredient, int amount) { - return (ingredient instanceof OreDictIngredient) ? RecipeMatch.of(((OreDictIngredient) ingredient).getOreDict(), amount) - : RecipeMatch.of(ingredient.getMatchingStacks()[0], amount); + return (ingredient instanceof OreDictIngredient) ? RecipeMatch.of(((OreDictIngredient) ingredient).getOreDict(), amount) : + RecipeMatch.of(ingredient.getMatchingStacks()[0], amount); } public static RecipeMatch recipeMatchFromIngredient(IIngredient ingredient) { @@ -49,9 +51,7 @@ public MeltingRecipeBuilder time(int time) { } @Override - public String getErrorMsg() { - return "Error adding " + recipeName; - } + public String getErrorMsg() { return "Error adding " + recipeName; } @Override public void validate(GroovyLog.Msg msg) { @@ -60,8 +60,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(temp < 1, "Recipe temperature must be at least 1, got " + temp); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable MeltingRecipe register() { if (!validate()) return null; int amount = fluidOutput.get(0).amount; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeRegistry.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeRegistry.java index 001e8f69a..6f4d44728 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeRegistry.java @@ -1,6 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import slimeknights.tconstruct.library.smeltery.MeltingRecipe; public abstract class MeltingRecipeRegistry extends VirtualizedRegistry { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/SmelteryFuelRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/SmelteryFuelRecipe.java index 9dc92ce91..3d7234581 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/SmelteryFuelRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/SmelteryFuelRecipe.java @@ -1,9 +1,9 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe; -import net.minecraftforge.fluids.FluidStack; - import java.util.Map; +import net.minecraftforge.fluids.FluidStack; + public class SmelteryFuelRecipe { public final FluidStack fluid; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Drops.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Drops.java index 0ad2d0fdf..e092f65bd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Drops.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Drops.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.compat.mods.woot; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Optional; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -8,16 +18,9 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ipsis.Woot; import ipsis.woot.util.WootMobName; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Optional; @RegistryDescription public class Drops extends VirtualizedRegistry { @@ -30,19 +33,22 @@ public RecipeBuilder recipeBuilder() { @Override public void onReload() { restoreFromBackup().forEach(drop -> ((CustomDropsRepositoryAccessor) Woot.customDropsRepository).getDrops().add(drop)); - removeScripted().forEach(drop -> ((CustomDropsRepositoryAccessor) Woot.customDropsRepository).getDrops() - .removeIf(d -> areCustomDropsEqual((CustomDropAccessor) d, (CustomDropAccessor) drop)) - ); + removeScripted().forEach(drop -> ((CustomDropsRepositoryAccessor) Woot.customDropsRepository).getDrops().removeIf( + d -> areCustomDropsEqual((CustomDropAccessor) d, + (CustomDropAccessor) drop))); } @MethodDescription(type = MethodDescription.Type.ADDITION) public void add(WootMobName wootMobName, ItemStack itemStack, List chances, List sizes) { Woot.customDropsRepository.addDrop(wootMobName, itemStack, chances, sizes); // get the drop we just added, but painfully - Optional recipe = ((CustomDropsRepositoryAccessor) Woot.customDropsRepository).getDrops() - .stream() - .filter(drop -> areCustomDropsEqual((CustomDropAccessor) drop, wootMobName, itemStack, chances, sizes)) - .findFirst(); + Optional recipe = ((CustomDropsRepositoryAccessor) Woot.customDropsRepository).getDrops().stream().filter( + drop -> areCustomDropsEqual((CustomDropAccessor) drop, + wootMobName, + itemStack, + chances, + sizes)) + .findFirst(); if (!recipe.isPresent()) { GroovyLog.msg("Error adding entry to Woot Custom Drops Repository with name {}", wootMobName).error().post(); return; @@ -60,7 +66,8 @@ public boolean remove(Object drop) { }); } - @MethodDescription(example = @Example(value = "new WootMobName('minecraft:ender_dragon')", imports = "ipsis.woot.util.WootMobName")) + @MethodDescription(example = @Example(value = "new WootMobName('minecraft:ender_dragon')", + imports = "ipsis.woot.util.WootMobName")) public boolean removeByEntity(WootMobName name) { return ((CustomDropsRepositoryAccessor) Woot.customDropsRepository).getDrops().removeIf(d -> { if (((CustomDropAccessor) d).getWootMobName().equals(name)) { @@ -105,22 +112,24 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((CustomDropsRepositoryAccessor) Woot.customDropsRepository).getDrops()) - .setRemover(this::remove); + return new SimpleObjectStream<>(((CustomDropsRepositoryAccessor) Woot.customDropsRepository).getDrops()).setRemover(this::remove); } private boolean areCustomDropsEqual(CustomDropAccessor target, CustomDropAccessor other) { - return target.getWootMobName().equals(other.getWootMobName()) && - ItemStack.areItemStacksEqual(target.getItemStack(), other.getItemStack()) && - target.getChanceMap().equals(other.getChanceMap()) && - target.getSizeMap().equals(other.getSizeMap()); + return target.getWootMobName().equals(other.getWootMobName()) && ItemStack.areItemStacksEqual(target.getItemStack(), other + .getItemStack()) && target.getChanceMap() + .equals(other.getChanceMap()) && target.getSizeMap() + .equals(other.getSizeMap()); } - private boolean areCustomDropsEqual(CustomDropAccessor target, WootMobName wootMobName, ItemStack itemStack, List chances, List sizes) { - return target.getWootMobName().equals(wootMobName) && - ItemStack.areItemStacksEqual(target.getItemStack(), itemStack) && - target.getChanceMap().values().containsAll(chances) && - target.getSizeMap().values().containsAll(sizes); + private boolean areCustomDropsEqual(CustomDropAccessor target, WootMobName wootMobName, ItemStack itemStack, + List chances, List sizes) { + return target.getWootMobName().equals(wootMobName) && ItemStack.areItemStacksEqual(target.getItemStack(), + itemStack) && target.getChanceMap() + .values() + .containsAll(chances) && target.getSizeMap() + .values() + .containsAll(sizes); } @Property(property = "output", valid = @Comp("1")) @@ -145,8 +154,7 @@ public RecipeBuilder name(EntityEntry entity) { return this; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public RecipeBuilder name(String name) { this.name = new WootMobName(name); return this; @@ -203,9 +211,7 @@ public RecipeBuilder size(Collection sizes) { } @Override - public String getErrorMsg() { - return "Error adding Woot custom drops"; - } + public String getErrorMsg() { return "Error adding Woot custom drops"; } @Override public void validate(GroovyLog.Msg msg) { @@ -216,8 +222,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(size.size() != 4, "size must have exactly 4 entries, but found {}", size.size()); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ItemStack register() { if (!validate()) return null; ModSupport.WOOT.get().drops.add(name, output.get(0), chance, size); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/MobConfig.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/MobConfig.java index 8f336e0e5..4aaff5471 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/MobConfig.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/MobConfig.java @@ -1,28 +1,34 @@ package com.cleanroommc.groovyscript.compat.mods.woot; +import java.util.Locale; +import java.util.Map; +import java.util.stream.Collectors; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.woot.WootConfigurationManagerAccessor; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ipsis.Woot; import ipsis.woot.configuration.EnumConfigKey; import ipsis.woot.util.WootMobName; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.Locale; -import java.util.Map; -import java.util.stream.Collectors; @RegistryDescription public class MobConfig extends VirtualizedRegistry> { @Override public void onReload() { - restoreFromBackup().forEach(pair -> ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMobMap().put(pair.getKey(), pair.getValue())); + restoreFromBackup().forEach(pair -> ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMobMap().put( + pair.getKey(), + pair.getValue())); removeScripted().forEach(pair -> { - if (pair.getKey().contains(":")) ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMobMap().remove(pair.getKey()); - else ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMap().put(EnumConfigKey.get(pair.getKey()), pair.getValue()); + if (pair.getKey().contains(":")) ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMobMap() + .remove(pair.getKey()); + else((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMap().put(EnumConfigKey.get(pair.getKey()), + pair.getValue()); }); } @@ -43,7 +49,9 @@ public void add(WootMobName name, String key, int value) { add(name, EnumConfigKey.get(key.toUpperCase(Locale.ROOT)), value); } - @MethodDescription(description = "groovyscript.wiki.woot.mob_config.add_normal", type = MethodDescription.Type.ADDITION, example = @Example("'minecraft:zombie', 'spawn_ticks', 1")) + @MethodDescription(description = "groovyscript.wiki.woot.mob_config.add_normal", + type = MethodDescription.Type.ADDITION, + example = @Example("'minecraft:zombie', 'spawn_ticks', 1")) public void add(String name, String key, int value) { add(new WootMobName(name), EnumConfigKey.get(key.toUpperCase(Locale.ROOT)), value); } @@ -55,7 +63,9 @@ public void add(EnumConfigKey key, int value) { ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMap().put(key, value); } - @MethodDescription(description = "groovyscript.wiki.woot.mob_config.add_global", type = MethodDescription.Type.ADDITION, example = @Example("'spawn_ticks', 100")) + @MethodDescription(description = "groovyscript.wiki.woot.mob_config.add_global", + type = MethodDescription.Type.ADDITION, + example = @Example("'spawn_ticks', 100")) public void add(String key, int value) { add(EnumConfigKey.get(key.toUpperCase(Locale.ROOT)), value); } @@ -77,16 +87,19 @@ public void remove(WootMobName name, String key) { remove(name, EnumConfigKey.get(key.toUpperCase(Locale.ROOT))); } - @MethodDescription(description = "groovyscript.wiki.woot.mob_config.remove", example = @Example("'minecraft:wither_skeleton', 'spawn_units'")) + @MethodDescription(description = "groovyscript.wiki.woot.mob_config.remove", + example = @Example("'minecraft:wither_skeleton', 'spawn_units'")) public void remove(String name, String key) { remove(new WootMobName(name), EnumConfigKey.get(key.toUpperCase(Locale.ROOT))); } @MethodDescription(description = "groovyscript.wiki.woot.mob_config.removeByEntity", example = @Example("'minecraft:wither'")) public void remove(WootMobName name) { - for (Map.Entry entry : ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMobMap().entrySet().stream() - .filter(x -> x.getKey().startsWith(name.toString())) - .collect(Collectors.toList())) { + for (Map.Entry entry : ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMobMap() + .entrySet().stream() + .filter(x -> x.getKey() + .startsWith(name.toString())) + .collect(Collectors.toList())) { addBackup(Pair.of(entry.getKey(), entry.getValue())); ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMobMap().remove(entry.getKey()); } @@ -100,7 +113,9 @@ public void remove(String name) { @MethodDescription(priority = 2000, example = @Example(commented = true)) public void removeAll() { - ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMobMap().forEach((key, value) -> addBackup(Pair.of(key, value))); + ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMobMap().forEach((key, value) -> addBackup(Pair.of( + key, + value))); ((WootConfigurationManagerAccessor) Woot.wootConfiguration).getIntegerMobMap().clear(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Policy.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Policy.java index dcc09f728..416cb5bbd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Policy.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Policy.java @@ -1,41 +1,54 @@ package com.cleanroommc.groovyscript.compat.mods.woot; +import net.minecraft.item.ItemStack; + +import org.apache.commons.lang3.tuple.Pair; + import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.woot.PolicyRepositoryAccessor; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ipsis.Woot; import ipsis.woot.util.WootMobName; -import net.minecraft.item.ItemStack; -import org.apache.commons.lang3.tuple.Pair; -@RegistryDescription( - admonition = @Admonition(value = "groovyscript.wiki.woot.policy.note", type = Admonition.Type.WARNING) -) +@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.woot.policy.note", type = Admonition.Type.WARNING)) public class Policy extends VirtualizedRegistry> { @Override public void onReload() { restoreFromBackup().forEach(pair -> { switch (pair.getKey()) { - case ENTITY_MOD_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalModBlacklist().add((String) pair.getValue()); - case ENTITY_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityBlacklist().add((WootMobName) pair.getValue()); - case ITEM_MOD_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemModBlacklist().add((String) pair.getValue()); - case ITEM_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemBlacklist().add((ItemStack) pair.getValue()); - case ENTITY_WHITELIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityWhitelist().add((WootMobName) pair.getValue()); - case GENERATE_ONLY_LIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalGenerateOnlyList().add((WootMobName) pair.getValue()); + case ENTITY_MOD_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalModBlacklist().add( + (String) pair.getValue()); + case ENTITY_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityBlacklist().add( + (WootMobName) pair.getValue()); + case ITEM_MOD_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemModBlacklist().add( + (String) pair.getValue()); + case ITEM_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemBlacklist().add( + (ItemStack) pair.getValue()); + case ENTITY_WHITELIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityWhitelist().add( + (WootMobName) pair.getValue()); + case GENERATE_ONLY_LIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalGenerateOnlyList().add( + (WootMobName) pair.getValue()); } }); removeScripted().forEach(pair -> { switch (pair.getKey()) { - case ENTITY_MOD_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalModBlacklist().remove((String) pair.getValue()); - case ENTITY_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityBlacklist().remove((WootMobName) pair.getValue()); - case ITEM_MOD_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemModBlacklist().remove((String) pair.getValue()); - case ITEM_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemBlacklist().remove((ItemStack) pair.getValue()); - case ENTITY_WHITELIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityWhitelist().remove((WootMobName) pair.getValue()); - case GENERATE_ONLY_LIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalGenerateOnlyList().remove((WootMobName) pair.getValue()); + case ENTITY_MOD_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalModBlacklist().remove( + (String) pair.getValue()); + case ENTITY_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityBlacklist().remove( + (WootMobName) pair.getValue()); + case ITEM_MOD_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemModBlacklist() + .remove((String) pair.getValue()); + case ITEM_BLACKLIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemBlacklist().remove( + (ItemStack) pair.getValue()); + case ENTITY_WHITELIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityWhitelist().remove( + (WootMobName) pair.getValue()); + case GENERATE_ONLY_LIST -> ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalGenerateOnlyList() + .remove((WootMobName) pair.getValue()); } }); } @@ -144,37 +157,49 @@ public void removeFromGenerateOnlyList(String name) { @MethodDescription(priority = 1500, example = @Example(commented = true)) public void removeAllFromEntityModBlacklist() { - ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalModBlacklist().forEach(x -> addBackup(Pair.of(PolicyType.ENTITY_MOD_BLACKLIST, x))); + ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalModBlacklist().forEach(x -> addBackup(Pair.of( + PolicyType.ENTITY_MOD_BLACKLIST, + x))); ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalModBlacklist().clear(); } @MethodDescription(priority = 1500, example = @Example(commented = true)) public void removeAllFromEntityBlacklist() { - ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityBlacklist().forEach(x -> addBackup(Pair.of(PolicyType.ENTITY_BLACKLIST, x))); + ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityBlacklist().forEach(x -> addBackup(Pair.of( + PolicyType.ENTITY_BLACKLIST, + x))); ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityBlacklist().clear(); } @MethodDescription(priority = 1500, example = @Example(commented = true)) public void removeAllFromItemModBlacklist() { - ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemModBlacklist().forEach(x -> addBackup(Pair.of(PolicyType.ITEM_MOD_BLACKLIST, x))); + ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemModBlacklist().forEach(x -> addBackup(Pair.of( + PolicyType.ITEM_MOD_BLACKLIST, + x))); ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemModBlacklist().clear(); } @MethodDescription(priority = 1500, example = @Example(commented = true)) public void removeAllFromItemBlacklist() { - ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemBlacklist().forEach(x -> addBackup(Pair.of(PolicyType.ITEM_BLACKLIST, x))); + ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemBlacklist().forEach(x -> addBackup(Pair.of( + PolicyType.ITEM_BLACKLIST, + x))); ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalItemBlacklist().clear(); } @MethodDescription(priority = 1500, example = @Example(commented = true)) public void removeAllFromEntityWhitelist() { - ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityWhitelist().forEach(x -> addBackup(Pair.of(PolicyType.ENTITY_WHITELIST, x))); + ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityWhitelist().forEach(x -> addBackup(Pair.of( + PolicyType.ENTITY_WHITELIST, + x))); ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalEntityWhitelist().clear(); } @MethodDescription(priority = 1500, example = @Example(commented = true)) public void removeAllFromGenerateOnlyList() { - ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalGenerateOnlyList().forEach(x -> addBackup(Pair.of(PolicyType.GENERATE_ONLY_LIST, x))); + ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalGenerateOnlyList().forEach(x -> addBackup(Pair.of( + PolicyType.GENERATE_ONLY_LIST, + x))); ((PolicyRepositoryAccessor) Woot.policyRepository).getExternalGenerateOnlyList().clear(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Spawning.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Spawning.java index c594f61b0..40d4258a8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Spawning.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/Spawning.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.mods.woot; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.common.registry.EntityEntry; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -8,33 +17,28 @@ import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ipsis.Woot; import ipsis.woot.farming.ISpawnRecipe; import ipsis.woot.farming.SpawnRecipe; import ipsis.woot.util.WootMobName; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.common.registry.EntityEntry; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.Nullable; - -import java.util.Map; @RegistryDescription public class Spawning extends VirtualizedRegistry> { - @RecipeBuilderDescription(example = { - @Example(".name('minecraft:zombie').input(item('minecraft:clay')).fluidInput(fluid('water'))"), - @Example(".defaultSpawnRecipe(true).input(item('minecraft:gold_ingot'), item('minecraft:diamond'))") - }) + @RecipeBuilderDescription(example = {@Example(".name('minecraft:zombie').input(item('minecraft:clay')).fluidInput(fluid('water'))"), + @Example(".defaultSpawnRecipe(true).input(item('minecraft:gold_ingot'), item('minecraft:diamond'))")}) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @Override public void onReload() { - restoreFromBackup().forEach(pair -> ((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getRecipes().put(pair.getKey(), pair.getValue())); - removeScripted().forEach(pair -> ((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getRecipes().remove(pair.getKey())); + restoreFromBackup().forEach(pair -> ((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getRecipes().put(pair + .getKey(), + pair.getValue())); + removeScripted().forEach(pair -> ((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getRecipes().remove(pair + .getKey())); //((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getDefaultSpawnRecipe().setEfficiency(true); ((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getDefaultSpawnRecipe().getItems().clear(); ((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getDefaultSpawnRecipe().getFluids().clear(); @@ -59,7 +63,8 @@ public void add(WootMobName name, SpawnRecipe recipe) { addScripted(Pair.of(name, recipe)); } - @MethodDescription(example = @Example(value = "new WootMobName('minecraft:ender_dragon')", imports = "ipsis.woot.util.WootMobName")) + @MethodDescription(example = @Example(value = "new WootMobName('minecraft:ender_dragon')", + imports = "ipsis.woot.util.WootMobName")) public boolean remove(WootMobName name) { SpawnRecipe recipe = ((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getRecipes().get(name); ((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getRecipes().remove(name); @@ -67,7 +72,8 @@ public boolean remove(WootMobName name) { return true; } - @MethodDescription(example = @Example(value = "new WootMobName('minecraft:ender_dragon')", imports = "ipsis.woot.util.WootMobName")) + @MethodDescription(example = @Example(value = "new WootMobName('minecraft:ender_dragon')", + imports = "ipsis.woot.util.WootMobName")) public boolean removeByEntity(WootMobName name) { return remove(name); } @@ -96,11 +102,12 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream> streamRecipes() { return new SimpleObjectStream<>(((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getRecipes().entrySet()) - .setRemover(x -> remove(x.getKey())); + .setRemover(x -> remove(x.getKey())); } @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "6")}) - @Property(property = "fluidInput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "6")}) + @Property(property = "fluidInput", + valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "6")}) public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(requirement = "groovyscript.wiki.woot.spawning.modifying.required") @@ -134,8 +141,7 @@ public RecipeBuilder name(EntityEntry entity) { return this; } - @Override - @RecipeBuilderMethodDescription + @Override @RecipeBuilderMethodDescription public RecipeBuilder name(String name) { this.name = new WootMobName(name); return this; @@ -148,25 +154,24 @@ public RecipeBuilder name(String name) { //} @Override - public String getErrorMsg() { - return "Error adding Woot custom spawning costs"; - } + public String getErrorMsg() { return "Error adding Woot custom spawning costs"; } @Override public void validate(GroovyLog.Msg msg) { validateItems(msg, 0, 6, 0, 0); validateFluids(msg, 0, 6, 0, 0); - msg.add(!defaultSpawnRecipe && (name == null || !name.isValid()), "if the recipe is not the defaultSpawnRecipe, the name must be defined and a valid name, yet it was {}", name); + msg.add(!defaultSpawnRecipe && (name == null || !name.isValid()), + "if the recipe is not the defaultSpawnRecipe, the name must be defined and a valid name, yet it was {}", + name); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable ISpawnRecipe register() { if (!validate()) return null; - SpawnRecipe recipe = defaultSpawnRecipe - ? ((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository).getDefaultSpawnRecipe() - : new SpawnRecipe(); + SpawnRecipe recipe = defaultSpawnRecipe ? ((SpawnRecipeRepositoryAccessor) Woot.spawnRecipeRepository) + .getDefaultSpawnRecipe() : + new SpawnRecipe(); for (IIngredient item : input) { recipe.addIngredient(item.getMatchingStacks()[0]); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/StygianIronAnvil.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/StygianIronAnvil.java index b6e9faa89..0571aa700 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/StygianIronAnvil.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/StygianIronAnvil.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.woot; +import java.util.stream.Collectors; + +import net.minecraft.item.ItemStack; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -9,30 +15,22 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; + import ipsis.Woot; import ipsis.woot.crafting.AnvilRecipe; import ipsis.woot.crafting.IAnvilRecipe; -import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; - -import java.util.stream.Collectors; -@RegistryDescription( - admonition = { - @Admonition("groovyscript.wiki.woot.stygian_iron_anvil.note0"), - @Admonition(value = "groovyscript.wiki.woot.stygian_iron_anvil.note1", type = Admonition.Type.WARNING) - } -) +@RegistryDescription(admonition = {@Admonition("groovyscript.wiki.woot.stygian_iron_anvil.note0"), @Admonition( + value = "groovyscript.wiki.woot.stygian_iron_anvil.note1", + type = Admonition.Type.WARNING)}) public class StygianIronAnvil extends VirtualizedRegistry { public StygianIronAnvil() { super(Alias.generateOfClassAnd(StygianIronAnvil.class, "Anvil")); } - @RecipeBuilderDescription(example = { - @Example(".input(item('minecraft:diamond'),item('minecraft:diamond'),item('minecraft:diamond')).base(item('minecraft:gold_ingot')).output(item('minecraft:clay')).preserveBase(true)"), - @Example(".input(item('minecraft:diamond'), item('minecraft:gold_ingot'), item('minecraft:iron_ingot'), item('minecraft:diamond_block'), item('minecraft:gold_block'), item('minecraft:iron_bars'), item('minecraft:magma')).base(item('minecraft:clay')).output(item('minecraft:clay')).preserveBase()") - }) + @RecipeBuilderDescription(example = {@Example(".input(item('minecraft:diamond'),item('minecraft:diamond'),item('minecraft:diamond')).base(item('minecraft:gold_ingot')).output(item('minecraft:clay')).preserveBase(true)"), + @Example(".input(item('minecraft:diamond'), item('minecraft:gold_ingot'), item('minecraft:iron_ingot'), item('minecraft:diamond_block'), item('minecraft:gold_block'), item('minecraft:iron_bars'), item('minecraft:magma')).base(item('minecraft:clay')).output(item('minecraft:clay')).preserveBase()")}) public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @@ -95,11 +93,11 @@ public void removeAll() { @MethodDescription(type = MethodDescription.Type.QUERY) public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(Woot.anvilManager.getRecipes()) - .setRemover(this::remove); + return new SimpleObjectStream<>(Woot.anvilManager.getRecipes()).setRemover(this::remove); } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) + @Property(property = "input", + valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { @@ -127,9 +125,7 @@ public RecipeBuilder preserveBase() { } @Override - public String getErrorMsg() { - return "Error adding Woot Stygian Iron Anvil recipe"; - } + public String getErrorMsg() { return "Error adding Woot Stygian Iron Anvil recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -140,8 +136,7 @@ public void validate(GroovyLog.Msg msg) { msg.add(IngredientHelper.isEmpty(base), "base must be defined"); } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public @Nullable IAnvilRecipe register() { if (!validate()) return null; @@ -149,7 +144,8 @@ public void validate(GroovyLog.Msg msg) { ((AnvilManagerAccessor) Woot.anvilManager).getValidBaseItems().add(base); IAnvilRecipe recipe = new AnvilRecipe(output.get(0), base, preserveBase); - recipe.getInputs().addAll(input.stream().map(x -> x.toMcIngredient().getMatchingStacks()[0]).collect(Collectors.toList())); + recipe.getInputs().addAll(input.stream().map(x -> x.toMcIngredient().getMatchingStacks()[0]).collect(Collectors + .toList())); ModSupport.WOOT.get().stygianIronAnvil.add(recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Crafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Crafting.java index c2f6b5964..11b3a3b65 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Crafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Crafting.java @@ -1,19 +1,21 @@ package com.cleanroommc.groovyscript.compat.vanilla; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.ForgeRegistries; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; -import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import java.util.ArrayList; -import java.util.List; +import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; public class Crafting extends ForgeRegistryWrapper { @@ -41,101 +43,51 @@ public void setFallback(String key, IIngredient ingredient) { } public void addShaped(ItemStack output, List> input) { - shapedBuilder() - .matrix(input) - .output(output) - .register(); + shapedBuilder().matrix(input).output(output).register(); } public void addShaped(String name, ItemStack output, List> input) { - shapedBuilder() - .matrix(input) - .output(output) - .name(name) - .register(); + shapedBuilder().matrix(input).output(output).name(name).register(); } public void addShaped(ResourceLocation name, ItemStack output, List> input) { - shapedBuilder() - .matrix(input) - .output(output) - .name(name) - .register(); + shapedBuilder().matrix(input).output(output).name(name).register(); } public void addShapeless(ItemStack output, List input) { - shapelessBuilder() - .input(input) - .output(output) - .register(); + shapelessBuilder().input(input).output(output).register(); } public void addShapeless(String name, ItemStack output, List input) { - shapelessBuilder() - .input(input) - .output(output) - .name(name) - .register(); + shapelessBuilder().input(input).output(output).name(name).register(); } public void addShapeless(ResourceLocation name, ItemStack output, List input) { - shapelessBuilder() - .input(input) - .output(output) - .name(name) - .register(); + shapelessBuilder().input(input).output(output).name(name).register(); } public void replaceShapeless(ItemStack output, List input) { - shapelessBuilder() - .input(input) - .output(output) - .replace() - .register(); + shapelessBuilder().input(input).output(output).replace().register(); } public void replaceShapeless(String name, ItemStack output, List input) { - shapelessBuilder() - .input(input) - .output(output) - .name(name) - .replaceByName() - .register(); + shapelessBuilder().input(input).output(output).name(name).replaceByName().register(); } public void replaceShapeless(ResourceLocation name, ItemStack output, List input) { - shapelessBuilder() - .input(input) - .output(output) - .name(name) - .replaceByName() - .register(); + shapelessBuilder().input(input).output(output).name(name).replaceByName().register(); } public void replaceShaped(ItemStack output, List> input) { - shapedBuilder() - .matrix(input) - .output(output) - .replace() - .register(); + shapedBuilder().matrix(input).output(output).replace().register(); } public void replaceShaped(String name, ItemStack output, List> input) { - shapedBuilder() - .matrix(input) - .output(output) - .name(name) - .replaceByName() - .register(); + shapedBuilder().matrix(input).output(output).name(name).replaceByName().register(); } public void replaceShaped(ResourceLocation name, ItemStack output, List> input) { - shapedBuilder() - .matrix(input) - .output(output) - .name(name) - .replaceByName() - .register(); + shapedBuilder().matrix(input).output(output).name(name).replaceByName().register(); } public void removeByOutput(IIngredient output) { @@ -145,10 +97,7 @@ public void removeByOutput(IIngredient output) { public void removeByOutput(IIngredient output, boolean log) { if (IngredientHelper.isEmpty(output)) { if (log) { - GroovyLog.msg("Error removing Minecraft Crafting recipe") - .add("Output must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Minecraft Crafting recipe").add("Output must not be empty").error().post(); } return; } @@ -160,10 +109,7 @@ public void removeByOutput(IIngredient output, boolean log) { } if (recipesToRemove.isEmpty()) { if (log) { - GroovyLog.msg("Error removing Minecraft Crafting recipe") - .add("No recipes found for {}", output) - .error() - .post(); + GroovyLog.msg("Error removing Minecraft Crafting recipe").add("No recipes found for {}", output).error().post(); } return; } @@ -179,25 +125,20 @@ public void removeByInput(IIngredient input) { public void removeByInput(IIngredient input, boolean log) { if (IngredientHelper.isEmpty(input)) { if (log) { - GroovyLog.msg("Error removing Minecraft Crafting recipe") - .add("Input must not be empty") - .error() - .post(); + GroovyLog.msg("Error removing Minecraft Crafting recipe").add("Input must not be empty").error().post(); } return; } List recipesToRemove = new ArrayList<>(); for (IRecipe recipe : ForgeRegistries.RECIPES) { - if (recipe.getRegistryName() != null && !recipe.getIngredients().isEmpty() && recipe.getIngredients().stream().anyMatch(i -> i.getMatchingStacks().length > 0 && input.test(i.getMatchingStacks()[0]))) { + if (recipe.getRegistryName() != null && !recipe.getIngredients().isEmpty() && recipe.getIngredients().stream() + .anyMatch(i -> i.getMatchingStacks().length > 0 && input.test(i.getMatchingStacks()[0]))) { recipesToRemove.add(recipe.getRegistryName()); } } if (recipesToRemove.isEmpty()) { if (log) { - GroovyLog.msg("Error removing Minecraft Crafting recipe") - .add("No recipes found for {}", input) - .error() - .post(); + GroovyLog.msg("Error removing Minecraft Crafting recipe").add("No recipes found for {}", input).error().post(); } return; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingInfo.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingInfo.java index 47fbce403..8bb7f84e8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingInfo.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingInfo.java @@ -3,6 +3,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.world.World; + import org.jetbrains.annotations.UnknownNullability; public class CraftingInfo { @@ -17,22 +18,14 @@ public CraftingInfo(InventoryCrafting inventory, @UnknownNullability EntityPlaye this.world = player == null ? null : player.world; } - public InventoryCrafting getInventory() { - return this.inventory; - } + public InventoryCrafting getInventory() { return this.inventory; } - public EntityPlayer getPlayer() { - return player; - } + public EntityPlayer getPlayer() { return player; } public int getDimension() { - if (this.world != null) { - return this.world.provider.getDimension(); - } + if (this.world != null) { return this.world.provider.getDimension(); } return 0; } - public World getWorld() { - return this.world; - } + public World getWorld() { return this.world; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingRecipe.java index 94733c3c3..70c5b1992 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingRecipe.java @@ -1,12 +1,8 @@ package com.cleanroommc.groovyscript.compat.vanilla; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.api.IMarkable; -import com.cleanroommc.groovyscript.core.mixin.InventoryCraftingAccess; -import com.cleanroommc.groovyscript.core.mixin.SlotCraftingAccess; -import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import groovy.lang.Closure; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryCrafting; @@ -17,11 +13,18 @@ import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.registries.IForgeRegistryEntry; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.IMarkable; +import com.cleanroommc.groovyscript.core.mixin.InventoryCraftingAccess; +import com.cleanroommc.groovyscript.core.mixin.SlotCraftingAccess; +import com.cleanroommc.groovyscript.sandbox.ClosureHelper; + +import groovy.lang.Closure; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; public abstract class CraftingRecipe extends IForgeRegistryEntry.Impl implements IRecipe, ICraftingRecipe { @@ -33,7 +36,8 @@ public abstract class CraftingRecipe extends IForgeRegistryEntry.Impl i @Nullable protected final Closure recipeAction; - public CraftingRecipe(ItemStack output, List input, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { + public CraftingRecipe(ItemStack output, List input, @Nullable Closure recipeFunction, + @Nullable Closure recipeAction) { this.output = output; this.input = input; this.recipeFunction = recipeFunction; @@ -69,30 +73,20 @@ public CraftingRecipe(ItemStack output, List input, @Nullable Closu } @Override - public @NotNull ItemStack getRecipeOutput() { - return output; - } + public @NotNull ItemStack getRecipeOutput() { return output; } - @Nullable - @Override - public Closure getRecipeAction() { - return recipeAction; - } + @Nullable @Override + public Closure getRecipeAction() { return recipeAction; } - @Nullable - @Override - public Closure getRecipeFunction() { - return recipeFunction; - } + @Nullable @Override + public Closure getRecipeFunction() { return recipeFunction; } public boolean matches(@Nullable IIngredient expectedInput, ItemStack givenInput) { return expectedInput == null || expectedInput.test(givenInput); } @Override - public @NotNull NonNullList getIngredients() { - return this.ingredients; - } + public @NotNull NonNullList getIngredients() { return this.ingredients; } @Override public @NotNull NonNullList getRemainingItems(@NotNull InventoryCrafting inv) { @@ -101,9 +95,11 @@ public boolean matches(@Nullable IIngredient expectedInput, ItemStack givenInput ItemStack input = matchResult.getGivenInput(); ItemStack remainder = matchResult.getRecipeIngredient().applyTransform(input.copy()); if (remainder == null) remainder = ItemStack.EMPTY; - else if (input.getCount() > 1 && !remainder.isEmpty() && ItemStack.areItemsEqual(input, remainder) && ItemStack.areItemStackTagsEqual(input, remainder)) { - remainder.setCount(1); - } + else if (input.getCount() > 1 && !remainder.isEmpty() && ItemStack.areItemsEqual(input, remainder) && ItemStack + .areItemStackTagsEqual(input, + remainder)) { + remainder.setCount(1); + } result.set(matchResult.getSlotIndex(), remainder); } return result; @@ -126,7 +122,9 @@ public boolean matches(@NotNull InventoryCrafting inv, @NotNull World worldIn) { */ public static class MatchList extends ArrayList { - public static final MatchList EMPTY = new MatchList() { + public static final MatchList EMPTY = new MatchList() + { + @Override public boolean add(SlotMatchResult slotMatchResult) { throw new UnsupportedOperationException(); @@ -150,17 +148,11 @@ public SlotMatchResult(IIngredient recipeIngredient, ItemStack givenInput, int s this.slotIndex = slotIndex; } - public IIngredient getRecipeIngredient() { - return recipeIngredient; - } + public IIngredient getRecipeIngredient() { return recipeIngredient; } - public ItemStack getGivenInput() { - return givenInput; - } + public ItemStack getGivenInput() { return givenInput; } - public int getSlotIndex() { - return slotIndex; - } + public int getSlotIndex() { return slotIndex; } } // TODO @@ -168,9 +160,7 @@ private static EntityPlayer getPlayerFromInventory(InventoryCrafting inventory) Container eventHandler = ((InventoryCraftingAccess) inventory).getEventHandler(); if (eventHandler != null) { for (Slot slot : eventHandler.inventorySlots) { - if (slot instanceof SlotCraftingAccess) { - return ((SlotCraftingAccess) slot).getPlayer(); - } + if (slot instanceof SlotCraftingAccess) { return ((SlotCraftingAccess) slot).getPlayer(); } } } return null; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingRecipeBuilder.java index b97fbe3fb..988ba69da 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/CraftingRecipeBuilder.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.compat.vanilla; +import net.minecraft.item.crafting.IRecipe; +import net.minecraftforge.fml.common.registry.ForgeRegistries; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.Property; import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderRegistrationMethod; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.registry.AbstractCraftingRecipeBuilder; import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; -import net.minecraft.item.crafting.IRecipe; -import net.minecraftforge.fml.common.registry.ForgeRegistries; public abstract class CraftingRecipeBuilder { @@ -19,30 +20,44 @@ public Shaped() { } @Override - public String getRecipeNamePrefix() { - return "groovyscript_shaped_"; - } + public String getRecipeNamePrefix() { return "groovyscript_shaped_"; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IRecipe register() { validateName(); - GroovyLog.Msg msg = GroovyLog.msg("Error adding Minecraft Shaped Crafting recipe '{}'", this.name).error() - .add((keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), () -> "No matrix was defined") - .add(keyBasedMatrix != null && ingredientMatrix != null, () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!") - .add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); + GroovyLog.Msg msg = GroovyLog.msg("Error adding Minecraft Shaped Crafting recipe '{}'", this.name).error().add( + (keyBasedMatrix == null || keyBasedMatrix.length == 0) && (ingredientMatrix == null || ingredientMatrix.isEmpty()), + () -> "No matrix was defined") + .add(keyBasedMatrix != null && ingredientMatrix != null, + () -> "A key based matrix AND a ingredient based matrix was defined. This is not allowed!") + .add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty"); if (msg.postIfNotEmpty()) return null; ShapedCraftingRecipe recipe = null; if (keyBasedMatrix != null) { - recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, ingredients) -> new ShapedCraftingRecipe(output, ingredients, width1, height1, mirrored, recipeFunction, recipeAction))); + recipe = validateShape(msg, errors, keyBasedMatrix, keyMap, ((width1, height1, + ingredients) -> new ShapedCraftingRecipe(output, + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction))); } else if (ingredientMatrix != null) { - recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> new ShapedCraftingRecipe(output.copy(), ingredients, width1, height1, mirrored, recipeFunction, recipeAction))); + recipe = validateShape(msg, ingredientMatrix, ((width1, height1, ingredients) -> new ShapedCraftingRecipe(output + .copy(), + ingredients, + width1, + height1, + mirrored, + recipeFunction, + recipeAction))); } if (recipe != null) { handleReplace(); - msg.add(ReloadableRegistryManager.hasNonDummyRecipe(this.name), () -> "a recipe with that name already exists! Either replace or remove the recipe first"); + msg.add(ReloadableRegistryManager.hasNonDummyRecipe(this.name), + () -> "a recipe with that name already exists! Either replace or remove the recipe first"); if (msg.postIfNotEmpty()) return null; ReloadableRegistryManager.addRegistryEntry(ForgeRegistries.RECIPES, name, recipe); } @@ -59,27 +74,25 @@ public Shapeless() { } @Override - public String getRecipeNamePrefix() { - return "groovyscript_shapeless_"; - } + public String getRecipeNamePrefix() { return "groovyscript_shapeless_"; } - @Override - @RecipeBuilderRegistrationMethod + @Override @RecipeBuilderRegistrationMethod public IRecipe register() { validateName(); IngredientHelper.trim(ingredients); GroovyLog.Msg msg = GroovyLog.msg("Error adding Minecraft Shapeless Crafting recipe '{}'", this.name); - if (msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty") - .add(ingredients.isEmpty(), () -> "inputs must not be empty") - .add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + ingredients.size()) - .error() - .postIfNotEmpty()) { + if (msg.add(IngredientHelper.isEmpty(this.output), () -> "Output must not be empty").add(ingredients.isEmpty(), + () -> "inputs must not be empty") + .add(ingredients.size() > width * height, () -> "maximum inputs are " + (width * height) + " but found " + + ingredients.size()).error().postIfNotEmpty()) { return null; } handleReplace(); - msg.add(ReloadableRegistryManager.hasNonDummyRecipe(this.name), () -> "a recipe with that name already exists! Either replace or remove the recipe first"); + msg.add(ReloadableRegistryManager.hasNonDummyRecipe(this.name), + () -> "a recipe with that name already exists! Either replace or remove the recipe first"); if (msg.postIfNotEmpty()) return null; - ShapelessCraftingRecipe recipe = new ShapelessCraftingRecipe(output.copy(), ingredients, recipeFunction, recipeAction); + ShapelessCraftingRecipe recipe = new ShapelessCraftingRecipe(output.copy(), ingredients, recipeFunction, + recipeAction); ReloadableRegistryManager.addRegistryEntry(ForgeRegistries.RECIPES, name, recipe); return recipe; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Furnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Furnace.java index 3ce4aeb92..e1a572067 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Furnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Furnace.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.compat.vanilla; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; + +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; @@ -7,13 +16,6 @@ import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.FurnaceRecipes; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; public class Furnace extends VirtualizedRegistry { @@ -26,11 +28,11 @@ public void add(IIngredient input, ItemStack output) { } public void add(IIngredient input, ItemStack output, float exp) { - if (GroovyLog.msg("Error adding Minecraft Furnace recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input must not be empty") - .add(IngredientHelper.isEmpty(output), () -> "Output must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding Minecraft Furnace recipe").add(IngredientHelper.isEmpty(input), + () -> "Input must not be empty").add(IngredientHelper + .isEmpty(output), + () -> "Output must not be empty") + .error().postIfNotEmpty()) { return; } if (exp < 0) { @@ -75,10 +77,9 @@ public boolean removeByInput(ItemStack input, boolean log) { public boolean removeByInput(ItemStack input, boolean log, boolean isScripted) { if (IngredientHelper.isEmpty(input)) { if (log) { - GroovyLog.msg("Error adding Minecraft Furnace recipe") - .add(IngredientHelper.isEmpty(input), () -> "Input must not be empty") - .error() - .postIfNotEmpty(); + GroovyLog.msg("Error adding Minecraft Furnace recipe").add(IngredientHelper.isEmpty(input), + () -> "Input must not be empty").error() + .postIfNotEmpty(); } return false; } @@ -86,10 +87,8 @@ public boolean removeByInput(ItemStack input, boolean log, boolean isScripted) { ItemStack trueInput = findTrueInput(input); if (trueInput == null) { if (log) { - GroovyLog.msg("Error removing Minecraft Furnace recipe") - .add("Can't find recipe for input " + input) - .error() - .post(); + GroovyLog.msg("Error removing Minecraft Furnace recipe").add("Can't find recipe for input " + input).error() + .post(); } return false; } @@ -101,10 +100,8 @@ public boolean removeByInput(ItemStack input, boolean log, boolean isScripted) { return true; } else { if (log) { - GroovyLog.msg("Error removing Minecraft Furnace recipe") - .add("Found input, but no output for " + input) - .error() - .post(); + GroovyLog.msg("Error removing Minecraft Furnace recipe").add("Found input, but no output for " + input).error() + .post(); } } @@ -123,10 +120,9 @@ public boolean removeByOutput(IIngredient output, boolean log) { public boolean removeByOutput(IIngredient output, boolean log, boolean isScripted) { if (IngredientHelper.isEmpty(output)) { if (log) { - GroovyLog.msg("Error adding Minecraft Furnace recipe") - .add(IngredientHelper.isEmpty(output), () -> "Output must not be empty") - .error() - .postIfNotEmpty(); + GroovyLog.msg("Error adding Minecraft Furnace recipe").add(IngredientHelper.isEmpty(output), + () -> "Output must not be empty").error() + .postIfNotEmpty(); } return false; } @@ -141,10 +137,8 @@ public boolean removeByOutput(IIngredient output, boolean log, boolean isScripte } if (recipesToRemove.isEmpty()) { if (log) { - GroovyLog.msg("Error removing Minecraft Furnace recipe") - .add("Can't find recipe for output " + output) - .error() - .post(); + GroovyLog.msg("Error removing Minecraft Furnace recipe").add("Can't find recipe for output " + output).error() + .post(); } return false; } @@ -175,11 +169,11 @@ public void removeAll() { }); } - @GroovyBlacklist - @Override + @GroovyBlacklist @Override public void onReload() { getScriptedRecipes().forEach(recipe -> remove(recipe, false)); - getBackupRecipes().forEach(recipe -> FurnaceRecipes.instance().addSmeltingRecipe(recipe.input, recipe.output, recipe.exp)); + getBackupRecipes().forEach(recipe -> FurnaceRecipes.instance().addSmeltingRecipe(recipe.input, recipe.output, + recipe.exp)); } public static class RecipeBuilder extends AbstractRecipeBuilder { @@ -206,9 +200,7 @@ public RecipeBuilder exp(float exp) { } @Override - public String getErrorMsg() { - return "Error adding Minecraft Furnace recipe"; - } + public String getErrorMsg() { return "Error adding Minecraft Furnace recipe"; } @Override public void validate(GroovyLog.Msg msg) { @@ -243,16 +235,10 @@ private Recipe(ItemStack input, ItemStack output, float exp) { this.exp = exp; } - public ItemStack getInput() { - return input.copy(); - } + public ItemStack getInput() { return input.copy(); } - public ItemStack getOutput() { - return output.copy(); - } + public ItemStack getOutput() { return output.copy(); } - public float getExp() { - return exp; - } + public float getExp() { return exp; } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/FurnaceRecipeManager.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/FurnaceRecipeManager.java index 9d97b7365..585f9d148 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/FurnaceRecipeManager.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/FurnaceRecipeManager.java @@ -1,17 +1,21 @@ package com.cleanroommc.groovyscript.compat.vanilla; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import it.unimi.dsi.fastutil.Hash; -import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet; +import java.util.Objects; + import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -import java.util.Objects; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; + +import it.unimi.dsi.fastutil.Hash; +import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet; @GroovyBlacklist public class FurnaceRecipeManager { - public static final ObjectOpenCustomHashSet inputMap = new ObjectOpenCustomHashSet<>(new Hash.Strategy<>() { + public static final ObjectOpenCustomHashSet inputMap = new ObjectOpenCustomHashSet<>(new Hash.Strategy<>() + { + @Override public int hashCode(ItemStack o) { return Objects.hash(o.getItem(), o.getMetadata()); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ICraftingRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ICraftingRecipe.java index c7728afee..810e5a06e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ICraftingRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ICraftingRecipe.java @@ -1,9 +1,11 @@ package com.cleanroommc.groovyscript.compat.vanilla; -import groovy.lang.Closure; import net.minecraft.item.ItemStack; + import org.jetbrains.annotations.Nullable; +import groovy.lang.Closure; + public interface ICraftingRecipe { @Nullable diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackExpansion.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackExpansion.java index 885eff559..04acedaf0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackExpansion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackExpansion.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.compat.vanilla; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import net.minecraft.item.ItemStack; import net.minecraft.util.text.TextFormatting; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; + public class ItemStackExpansion { public static ItemStack setRarity(ItemStack self, TextFormatting color) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java index a3992785d..690dc3334 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ItemStackMixinExpansion.java @@ -1,21 +1,23 @@ package com.cleanroommc.groovyscript.compat.vanilla; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.api.IMarkable; -import com.cleanroommc.groovyscript.api.INBTResourceStack; -import com.cleanroommc.groovyscript.api.INbtIngredient; -import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; -import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; + import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.oredict.OreDictionary; + import org.jetbrains.annotations.Nullable; -import java.util.function.Predicate; -import java.util.function.UnaryOperator; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.IMarkable; +import com.cleanroommc.groovyscript.api.INBTResourceStack; +import com.cleanroommc.groovyscript.api.INbtIngredient; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; public interface ItemStackMixinExpansion extends IIngredient, INbtIngredient, IMarkable { @@ -46,9 +48,7 @@ static ItemStackMixinExpansion of(ItemStack stack) { @Override default ItemStackMixinExpansion exactCopy() { - if (grs$isEmpty()) { - return (ItemStackMixinExpansion) (Object) ItemStack.EMPTY; - } + if (grs$isEmpty()) { return (ItemStackMixinExpansion) (Object) ItemStack.EMPTY; } ItemStackMixinExpansion copy = of(grs$getItemStack().copy()); copy.setMark(getMark()); copy.grs$setTransformer(grs$getTransformer()); @@ -59,8 +59,8 @@ default ItemStackMixinExpansion exactCopy() { @Override default boolean test(ItemStack stack) { - if (!OreDictionary.itemMatches(grs$getItemStack(), stack, false) && - (grs$getMatcher() == null || !grs$getMatcher().test(stack))) { + if (!OreDictionary.itemMatches(grs$getItemStack(), stack, false) && (grs$getMatcher() == null || !grs$getMatcher().test( + stack))) { return false; } if (grs$getNbtMatcher() != null) { @@ -133,14 +133,10 @@ default Ingredient toMcIngredient() { } @Override - default ItemStack[] getMatchingStacks() { - return new ItemStack[]{IngredientHelper.toItemStack(exactCopy())}; - } + default ItemStack[] getMatchingStacks() { return new ItemStack[]{IngredientHelper.toItemStack(exactCopy())}; } @Override - default int getAmount() { - return grs$getItemStack().getCount(); - } + default int getAmount() { return grs$getItemStack().getCount(); } @Override default void setAmount(int amount) { @@ -149,9 +145,7 @@ default void setAmount(int amount) { @Override - default @Nullable NBTTagCompound getNbt() { - return grs$getItemStack().getTagCompound(); - } + default @Nullable NBTTagCompound getNbt() { return grs$getItemStack().getTagCompound(); } @Override default void setNbt(NBTTagCompound nbt) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/OreDict.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/OreDict.java index fbb045e28..74973ba84 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/OreDict.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/OreDict.java @@ -1,20 +1,22 @@ package com.cleanroommc.groovyscript.compat.vanilla; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.core.mixin.OreDictionaryAccessor; -import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; + import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.ApiStatus; -import java.util.ArrayList; -import java.util.List; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.core.mixin.OreDictionaryAccessor; +import com.cleanroommc.groovyscript.helper.Alias; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; public class OreDict extends VirtualizedRegistry { @@ -22,9 +24,7 @@ public OreDict() { super(Alias.generateOfClass(OreDict.class).andGenerate("OreDictionary")); } - @Override - @GroovyBlacklist - @ApiStatus.Internal + @Override @GroovyBlacklist @ApiStatus.Internal public void onReload() { removeScripted().forEach(entry -> remove(entry.name, entry.stack, false)); restoreFromBackup().forEach(entry -> OreDictionary.registerOre(entry.name, entry.stack)); @@ -39,11 +39,10 @@ public void add(String name, Block block) { } public void add(String name, ItemStack stack) { - if (GroovyLog.msg("Error adding ore dictionary entry") - .add(StringUtils.isEmpty(name), () -> "Name must not be empty") - .add(IngredientHelper.isEmpty(stack), () -> "Item must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error adding ore dictionary entry").add(StringUtils.isEmpty(name), () -> "Name must not be empty").add( + IngredientHelper.isEmpty(stack), + () -> "Item must not be empty") + .error().postIfNotEmpty()) { return; } add(new OreDictEntry(name, stack)); @@ -74,11 +73,8 @@ public boolean isCase(String name) { } public boolean remove(String name, ItemStack stack) { - if (GroovyLog.msg("Error removing ore dictionary entry") - .add(StringUtils.isEmpty(name), () -> "Name must not be empty") - .add(IngredientHelper.isEmpty(stack), () -> "Item must not be empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing ore dictionary entry").add(StringUtils.isEmpty(name), () -> "Name must not be empty") + .add(IngredientHelper.isEmpty(stack), () -> "Item must not be empty").error().postIfNotEmpty()) { return false; } return remove(name, stack, true); @@ -117,10 +113,8 @@ public boolean clear(String name) { public boolean removeAll(String name) { List list = getItems(name); - if (GroovyLog.msg("Error removing from OreDictionary entry") - .add(list.isEmpty(), "OreDictionary Entry was empty") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error removing from OreDictionary entry").add(list.isEmpty(), "OreDictionary Entry was empty").error() + .postIfNotEmpty()) { return false; } list.forEach(stack -> remove(name, stack)); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/OreDictEntry.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/OreDictEntry.java index 93fdbb7bd..7e9e8f172 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/OreDictEntry.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/OreDictEntry.java @@ -1,8 +1,9 @@ package com.cleanroommc.groovyscript.compat.vanilla; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import net.minecraft.item.ItemStack; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; + public class OreDictEntry { public final String name; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Player.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Player.java index e2e01faf4..e35943010 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Player.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Player.java @@ -1,15 +1,17 @@ package com.cleanroommc.groovyscript.compat.vanilla; +import java.util.*; +import java.util.stream.Collectors; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IScriptReloadable; import com.cleanroommc.groovyscript.registry.NamedRegistry; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import java.util.*; -import java.util.stream.Collectors; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; public class Player extends NamedRegistry implements IScriptReloadable { @@ -32,10 +34,12 @@ public void addToInventory(InventoryPlayer playerInv) { } else { if (entry.getValue().isEmpty()) continue; - if (playerInv.getStackInSlot(entry.getKey()).isEmpty() || playerInv.getStackInSlot(entry.getKey()).equals(entry.getValue())) { + if (playerInv.getStackInSlot(entry.getKey()).isEmpty() || playerInv.getStackInSlot(entry.getKey()).equals(entry + .getValue())) { playerInv.add(entry.getKey(), entry.getValue().copy()); } else { - GroovyLog.msg("Could not set inventory slot {} to itemstack {}", entry.getKey(), entry.getValue()).error().post(); + GroovyLog.msg("Could not set inventory slot {} to itemstack {}", entry.getKey(), entry.getValue()).error() + .post(); } } } @@ -49,14 +53,13 @@ public void addStartingItem(ItemStack item) { public void addStartingItem(ItemStack item, int slot) { if (slot > 41) { GroovyLog.msg("Warning: assigning items to a player's inventory slot greater than 41 may cause some items to not be received by the player.") - .warn().post(); + .warn().post(); } if (slot <= -1) { givenItemsAnySlot.add(item == null ? ItemStack.EMPTY : item); } else { if (givenItemsSlots.get(slot) != null) { - GroovyLog.msg("Warning: slot {} has already been occupied by another item.", slot) - .error().post(); + GroovyLog.msg("Warning: slot {} has already been occupied by another item.", slot).error().post(); return; } givenItemsSlots.put(slot, item == null ? ItemStack.EMPTY : item); @@ -66,7 +69,7 @@ public void addStartingItem(ItemStack item, int slot) { public void setStartingItems(boolean isSlotSpecific, ItemStack... items) { if (items.length > 41) { GroovyLog.msg("Warning: assigning items to a player's inventory slot greater than 41 may cause some items to not be received by the player.") - .warn().post(); + .warn().post(); } if (isSlotSpecific) { givenItemsSlots.clear(); @@ -82,7 +85,7 @@ public void setStartingItems(boolean isSlotSpecific, ItemStack... items) { public void setStartingItems(boolean isSlotSpecific, List items) { if (items.size() > 41) { GroovyLog.msg("Warning: assigning items to a player's inventory slot greater than 41 may cause some items to not be received by the player.") - .warn().post(); + .warn().post(); } if (isSlotSpecific) { givenItemsSlots.clear(); @@ -95,16 +98,13 @@ public void setStartingItems(boolean isSlotSpecific, List items) { } } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { givenItemsAnySlot.clear(); givenItemsSlots.clear(); } - @Override - @GroovyBlacklist - public void afterScriptLoad() { - } + @Override @GroovyBlacklist + public void afterScriptLoad() {} } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Rarity.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Rarity.java index b05181932..e3d9d7371 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Rarity.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Rarity.java @@ -1,21 +1,24 @@ package com.cleanroommc.groovyscript.compat.vanilla; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.registry.NamedRegistry; -import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; -import groovy.lang.Closure; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Predicate; + import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.common.IRarity; + import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Predicate; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.registry.NamedRegistry; +import com.cleanroommc.groovyscript.sandbox.ClosureHelper; +import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; + +import groovy.lang.Closure; public class Rarity extends NamedRegistry { @@ -23,9 +26,7 @@ public class Rarity extends NamedRegistry { public IRarity check(ItemStack testStack) { for (Pair, IRarity> pair : this.rarities) { - if (ClosureHelper.call(false, pair.getKey(), testStack)) { - return pair.getValue(); - } + if (ClosureHelper.call(false, pair.getKey(), testStack)) { return pair.getValue(); } } return testStack.getItem().getRarity(testStack); } @@ -51,11 +52,9 @@ public void set(TextFormatting color, String rarityName, Closure predic } public void set(IRarity rarity, Closure predicate) { - if (GroovyLog.msg("Error setting Item Rarity") - .add(rarity == null, () -> "Rarity must not be null") - .add(predicate == null, () -> "Predicate must not be null") - .error() - .postIfNotEmpty()) { + if (GroovyLog.msg("Error setting Item Rarity").add(rarity == null, () -> "Rarity must not be null").add(predicate == null, + () -> "Predicate must not be null") + .error().postIfNotEmpty()) { return; } rarities.add(Pair.of(predicate, rarity)); @@ -87,14 +86,10 @@ private RarityImpl(TextFormatting color, String name) { } @Override - public TextFormatting getColor() { - return color; - } + public TextFormatting getColor() { return color; } @Override - public String getName() { - return name; - } + public String getName() { return name; } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ShapedCraftingRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ShapedCraftingRecipe.java index caf7930b8..806a89926 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ShapedCraftingRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ShapedCraftingRecipe.java @@ -1,14 +1,17 @@ package com.cleanroommc.groovyscript.compat.vanilla; -import com.cleanroommc.groovyscript.api.IIngredient; -import groovy.lang.Closure; +import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraftforge.common.crafting.IShapedRecipe; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; +import com.cleanroommc.groovyscript.api.IIngredient; + +import groovy.lang.Closure; public class ShapedCraftingRecipe extends CraftingRecipe implements IShapedRecipe { @@ -16,7 +19,8 @@ public class ShapedCraftingRecipe extends CraftingRecipe implements IShapedRecip private final int height; private final boolean mirrored; - public ShapedCraftingRecipe(ItemStack output, List input, int width, int height, boolean mirrored, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { + public ShapedCraftingRecipe(ItemStack output, List input, int width, int height, boolean mirrored, + @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { super(output, input, recipeFunction, recipeAction); this.width = width; this.height = height; @@ -29,18 +33,12 @@ public boolean canFit(int width, int height) { } @Override - public int getRecipeWidth() { - return width; - } + public int getRecipeWidth() { return width; } @Override - public int getRecipeHeight() { - return height; - } + public int getRecipeHeight() { return height; } - public boolean isMirrored() { - return mirrored; - } + public boolean isMirrored() { return mirrored; } @Override public @NotNull MatchList getMatchingList(InventoryCrafting inv) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ShapelessCraftingRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ShapelessCraftingRecipe.java index 0ae3c415e..6b264be9e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ShapelessCraftingRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/ShapelessCraftingRecipe.java @@ -1,20 +1,24 @@ package com.cleanroommc.groovyscript.compat.vanilla; -import com.cleanroommc.groovyscript.api.IIngredient; -import groovy.lang.Closure; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; + import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import com.cleanroommc.groovyscript.api.IIngredient; + +import groovy.lang.Closure; public class ShapelessCraftingRecipe extends CraftingRecipe { - public ShapelessCraftingRecipe(ItemStack output, List input, @Nullable Closure recipeFunction, @Nullable Closure recipeAction) { + public ShapelessCraftingRecipe(ItemStack output, List input, @Nullable Closure recipeFunction, + @Nullable Closure recipeAction) { super(output, input, recipeFunction, recipeAction); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/VanillaModule.java b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/VanillaModule.java index 08edb6574..f2bbb9a8c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/VanillaModule.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/VanillaModule.java @@ -1,5 +1,10 @@ package com.cleanroommc.groovyscript.compat.vanilla; +import java.util.Collection; +import java.util.Collections; + +import net.minecraft.item.ItemStack; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IScriptReloadable; @@ -8,10 +13,6 @@ import com.cleanroommc.groovyscript.compat.loot.Loot; import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; import com.cleanroommc.groovyscript.sandbox.expand.ExpansionHelper; -import net.minecraft.item.ItemStack; - -import java.util.Collection; -import java.util.Collections; public class VanillaModule extends GroovyPropertyContainer implements IScriptReloadable { @@ -39,8 +40,7 @@ public static void initializeBinding() { ExpansionHelper.mixinClass(ItemStack.class, ItemStackExpansion.class); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void onReload() { crafting.onReload(); furnace.onReload(); @@ -51,8 +51,7 @@ public void onReload() { inWorldCrafting.onReload(); } - @Override - @GroovyBlacklist + @Override @GroovyBlacklist public void afterScriptLoad() { furnace.afterScriptLoad(); loot.afterScriptLoad(); @@ -60,7 +59,5 @@ public void afterScriptLoad() { } @Override - public Collection getAliases() { - return Collections.emptyList(); - } + public Collection getAliases() { return Collections.emptyList(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/GroovyScriptCore.java b/src/main/java/com/cleanroommc/groovyscript/core/GroovyScriptCore.java index 593d07bf1..27783018f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/GroovyScriptCore.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/GroovyScriptCore.java @@ -1,36 +1,31 @@ package com.cleanroommc.groovyscript.core; -import com.google.common.collect.ImmutableList; -import net.minecraftforge.common.ForgeVersion; -import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; -import zone.rong.mixinbooter.IEarlyMixinLoader; - -import javax.annotation.Nullable; import java.io.File; import java.util.List; import java.util.Map; -@IFMLLoadingPlugin.Name("GroovyScript-Core") -@IFMLLoadingPlugin.MCVersion(ForgeVersion.mcVersion) +import javax.annotation.Nullable; + +import net.minecraftforge.common.ForgeVersion; +import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; + +import com.google.common.collect.ImmutableList; + +import zone.rong.mixinbooter.IEarlyMixinLoader; + +@IFMLLoadingPlugin.Name("GroovyScript-Core") @IFMLLoadingPlugin.MCVersion(ForgeVersion.mcVersion) public class GroovyScriptCore implements IFMLLoadingPlugin, IEarlyMixinLoader { public static File source; @Override - public String[] getASMTransformerClass() { - return new String[0]; - } + public String[] getASMTransformerClass() { return new String[0]; } @Override - public String getModContainerClass() { - return "com.cleanroommc.groovyscript.sandbox.ScriptModContainer"; - } + public String getModContainerClass() { return "com.cleanroommc.groovyscript.sandbox.ScriptModContainer"; } - @Nullable - @Override - public String getSetupClass() { - return null; - } + @Nullable @Override + public String getSetupClass() { return null; } @Override public void injectData(Map data) { @@ -38,12 +33,8 @@ public void injectData(Map data) { } @Override - public String getAccessTransformerClass() { - return "com.cleanroommc.groovyscript.core.GroovyScriptTransformer"; - } + public String getAccessTransformerClass() { return "com.cleanroommc.groovyscript.core.GroovyScriptTransformer"; } @Override - public List getMixinConfigs() { - return ImmutableList.of("mixin.groovyscript.json"); - } + public List getMixinConfigs() { return ImmutableList.of("mixin.groovyscript.json"); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/GroovyScriptTransformer.java b/src/main/java/com/cleanroommc/groovyscript/core/GroovyScriptTransformer.java index c7f77c830..cba7d0c4d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/GroovyScriptTransformer.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/GroovyScriptTransformer.java @@ -1,10 +1,12 @@ package com.cleanroommc.groovyscript.core; -import com.cleanroommc.groovyscript.core.visitors.*; import net.minecraft.launchwrapper.IClassTransformer; + import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; +import com.cleanroommc.groovyscript.core.visitors.*; + public class GroovyScriptTransformer implements IClassTransformer { @Override diff --git a/src/main/java/com/cleanroommc/groovyscript/core/LateMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/LateMixin.java index c05223cb9..9bfc468ec 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/LateMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/LateMixin.java @@ -1,44 +1,24 @@ package com.cleanroommc.groovyscript.core; +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraftforge.fml.common.Loader; + import com.cleanroommc.groovyscript.compat.mods.ic2.IC2; import com.google.common.collect.ImmutableList; -import net.minecraftforge.fml.common.Loader; -import zone.rong.mixinbooter.ILateMixinLoader; -import java.util.List; -import java.util.stream.Collectors; +import zone.rong.mixinbooter.ILateMixinLoader; public class LateMixin implements ILateMixinLoader { - public static final List modMixins = ImmutableList.of( - "advancedmortars", - "appliedenergistics2", - "astralsorcery", - "betterwithmods", - "bloodmagic", - "botania", - "calculator", - "draconicevolution", - "enderio", - "essentialcraft", - "extendedcrafting", - "extrautils2", - "forestry", - "ic2_classic", - "ic2_exp", - "industrialforegoing", - "inspirations", - "jei", - "mekanism", - "pneumaticcraft", - "projecte", - "pyrotech", - "roots", - "tcomplement", - "tconstruct", - "thermalexpansion", - "woot" - ); + public static final List modMixins = ImmutableList.of("advancedmortars", "appliedenergistics2", "astralsorcery", + "betterwithmods", "bloodmagic", "botania", "calculator", + "draconicevolution", "enderio", "essentialcraft", + "extendedcrafting", "extrautils2", "forestry", "ic2_classic", + "ic2_exp", "industrialforegoing", "inspirations", "jei", + "mekanism", "pneumaticcraft", "projecte", "pyrotech", "roots", + "tcomplement", "tconstruct", "thermalexpansion", "woot"); @Override public List getMixinConfigs() { @@ -52,9 +32,7 @@ public boolean shouldMixinConfigQueue(String mixinConfig) { } public boolean shouldEnableModMixin(String mod) { - if (mod.startsWith("ic2")) { - return Loader.isModLoaded("ic2") && mod.endsWith("exp") == IC2.isExp(); - } + if (mod.startsWith("ic2")) { return Loader.isModLoaded("ic2") && mod.endsWith("exp") == IC2.isExp(); } return Loader.isModLoaded(mod); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/CreativeTabsAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/CreativeTabsAccessor.java index 32518bc22..990a604dc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/CreativeTabsAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/CreativeTabsAccessor.java @@ -1,6 +1,7 @@ package com.cleanroommc.groovyscript.core.mixin; import net.minecraft.creativetab.CreativeTabs; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/DefaultResourcePackAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/DefaultResourcePackAccessor.java index be7ebda4f..86804398b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/DefaultResourcePackAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/DefaultResourcePackAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin; +import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.resources.IResourcePack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; - @Mixin(value = Minecraft.class) public interface DefaultResourcePackAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/EntityAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/EntityAccessor.java index ad88358ad..912181842 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/EntityAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/EntityAccessor.java @@ -1,6 +1,7 @@ package com.cleanroommc.groovyscript.core.mixin; import net.minecraft.entity.Entity; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/EntityItemMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/EntityItemMixin.java index 8ca59881f..9964f4f44 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/EntityItemMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/EntityItemMixin.java @@ -1,19 +1,21 @@ package com.cleanroommc.groovyscript.core.mixin; -import com.cleanroommc.groovyscript.compat.inworldcrafting.Burning; -import com.cleanroommc.groovyscript.compat.inworldcrafting.FluidRecipe; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.cleanroommc.groovyscript.compat.inworldcrafting.Burning; +import com.cleanroommc.groovyscript.compat.inworldcrafting.FluidRecipe; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; + @Mixin(EntityItem.class) public abstract class EntityItemMixin extends Entity { @@ -21,17 +23,18 @@ private EntityItemMixin(World worldIn) { super(worldIn); } - @Inject(method = "onUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityItem;handleWaterMovement()Z"), cancellable = true) + @Inject(method = "onUpdate", + at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityItem;handleWaterMovement()Z"), + cancellable = true) public void onUpdate(CallbackInfo ci) { EntityItem thisEntity = (EntityItem) (Object) this; if (!thisEntity.world.isRemote) { BlockPos pos = new BlockPos(thisEntity); IBlockState blockState = thisEntity.world.getBlockState(pos); Fluid fluid = FluidRecipe.getFluid(blockState); - if (fluid != null && - FluidRecipe.isSourceBlock(blockState) && - FluidRecipe.findAndRunRecipe(fluid, thisEntity.world, pos, blockState) && - thisEntity.isDead) { + if (fluid != null && FluidRecipe.isSourceBlock(blockState) && FluidRecipe.findAndRunRecipe(fluid, thisEntity.world, + pos, + blockState) && thisEntity.isDead) { ci.cancel(); return; } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/EventBusMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/EventBusMixin.java index 8c3eff0fa..2ede26ac6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/EventBusMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/EventBusMixin.java @@ -1,23 +1,24 @@ package com.cleanroommc.groovyscript.core.mixin; -import com.cleanroommc.groovyscript.event.EventBusExtended; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; + import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.EventBus; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.IEventListener; + import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; +import com.cleanroommc.groovyscript.event.EventBusExtended; @Mixin(value = EventBus.class, remap = false) public class EventBusMixin implements EventBusExtended { - @Shadow - @Final + @Shadow @Final private int busID; @Shadow diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/FluidStackMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/FluidStackMixin.java index 94896e184..6581562cc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/FluidStackMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/FluidStackMixin.java @@ -1,13 +1,5 @@ package com.cleanroommc.groovyscript.core.mixin; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.api.INBTResourceStack; -import com.cleanroommc.groovyscript.api.INbtIngredient; -import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; -import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; -import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; -import groovy.lang.Closure; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.NBTTagCompound; @@ -16,12 +8,23 @@ import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandlerItem; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.INBTResourceStack; +import com.cleanroommc.groovyscript.api.INbtIngredient; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import com.cleanroommc.groovyscript.helper.ingredient.NbtHelper; +import com.cleanroommc.groovyscript.sandbox.ClosureHelper; +import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; + +import groovy.lang.Closure; + @Mixin(value = FluidStack.class, remap = false) public abstract class FluidStackMixin implements IIngredient, INbtIngredient, INBTResourceStack { @@ -31,8 +34,7 @@ public abstract class FluidStackMixin implements IIngredient, INbtIngredient, IN @Shadow public NBTTagCompound tag; - @NotNull - @Shadow + @NotNull @Shadow public abstract FluidStack copy(); @Shadow @@ -63,14 +65,10 @@ public Ingredient toMcIngredient() { } @Override - public ItemStack[] getMatchingStacks() { - return new ItemStack[0]; - } + public ItemStack[] getMatchingStacks() { return new ItemStack[0]; } @Override - public boolean isEmpty() { - return getAmount() <= 0; - } + public boolean isEmpty() { return getAmount() <= 0; } @Override public boolean test(ItemStack stack) { @@ -89,9 +87,7 @@ public boolean test(ItemStack stack) { @Override public boolean test(FluidStack fluidStack) { - if (fluidStack == null) { - return false; - } + if (fluidStack == null) { return false; } if (nbtMatcher != null) { NBTTagCompound nbt = fluidStack.tag; return nbt != null && ClosureHelper.call(true, nbtMatcher, nbt); @@ -161,22 +157,14 @@ public INbtIngredient whenAnyNbt() { } @Override - public @Nullable NBTTagCompound getNbt() { - return tag; - } + public @Nullable NBTTagCompound getNbt() { return tag; } @Override - public void setNbt(NBTTagCompound nbt) { - this.tag = nbt; - } + public void setNbt(NBTTagCompound nbt) { this.tag = nbt; } @Override - public int getAmount() { - return amount; - } + public int getAmount() { return amount; } @Override - public void setAmount(int amount) { - this.amount = amount; - } + public void setAmount(int amount) { this.amount = amount; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ForgeRegistryMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ForgeRegistryMixin.java index 1ded6e32f..c5c27c92b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ForgeRegistryMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ForgeRegistryMixin.java @@ -1,33 +1,36 @@ package com.cleanroommc.groovyscript.core.mixin; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.IReloadableForgeRegistry; -import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; -import com.cleanroommc.groovyscript.registry.VirtualizedForgeRegistryEntry; -import com.google.common.collect.BiMap; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import java.util.BitSet; +import java.util.Locale; +import java.util.Objects; +import java.util.Set; +import java.util.function.Supplier; + import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.RegistryManager; + import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import java.util.BitSet; -import java.util.Locale; -import java.util.Objects; -import java.util.Set; -import java.util.function.Supplier; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IReloadableForgeRegistry; +import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; +import com.cleanroommc.groovyscript.registry.VirtualizedForgeRegistryEntry; +import com.google.common.collect.BiMap; + +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; @Mixin(value = ForgeRegistry.class, remap = false) -public abstract class ForgeRegistryMixin> implements IForgeRegistry, IReloadableForgeRegistry { +public abstract class ForgeRegistryMixin> implements IForgeRegistry, + IReloadableForgeRegistry { - @Override - @Shadow + @Override @Shadow public abstract void register(V value); @Shadow @@ -39,44 +42,42 @@ public abstract class ForgeRegistryMixin> imple @Shadow abstract int add(int id, V value, String owner); - @Shadow - @Final + @Shadow @Final private BiMap names; - @Shadow - @Final + @Shadow @Final private BiMap ids; - @Shadow - @Final + @Shadow @Final private BiMap owners; - @Shadow - @Final + @Shadow @Final private DummyFactory dummyFactory; - @Shadow - @Final + @Shadow @Final private BitSet availabilityMap; @Shadow public abstract V remove(ResourceLocation key); - @Shadow - @Final + @Shadow @Final private Class superType; - @Shadow - @Final + @Shadow @Final private RegistryManager stage; - @Unique private Set> groovyScript$backups; - @Unique private Set groovyScript$scripted; - @Unique private Supplier groovyScript$dummySupplier; @Unique - @Final + private Set> groovyScript$backups; + @Unique + private Set groovyScript$scripted; + @Unique + private Supplier groovyScript$dummySupplier; + @Unique @Final private final Set groovyScript$dummies = new ObjectOpenHashSet<>(); - @Unique private IReloadableForgeRegistry groovyScript$vanilla; - @Unique private IReloadableForgeRegistry groovyScript$frozen; + @Unique + private IReloadableForgeRegistry groovyScript$vanilla; + @Unique + private IReloadableForgeRegistry groovyScript$frozen; @Override public V groovyScript$registerEntry(V registryEntry) { - if (stage != RegistryManager.ACTIVE) throw new IllegalStateException("Do not modify VANILLA or FROZEN registry directly!"); + if (stage != RegistryManager.ACTIVE) throw new IllegalStateException( + "Do not modify VANILLA or FROZEN registry directly!"); Objects.requireNonNull(registryEntry); Objects.requireNonNull(registryEntry.getRegistryName()); int id = groovyScript$removeDummy(registryEntry.getRegistryName(), DummyContext.ADDITION); @@ -97,7 +98,8 @@ public abstract class ForgeRegistryMixin> imple @Override public void groovyScript$removeEntry(ResourceLocation name) { - if (stage != RegistryManager.ACTIVE) throw new IllegalStateException("Do not modify VANILLA or FROZEN registry directly!"); + if (stage != RegistryManager.ACTIVE) throw new IllegalStateException( + "Do not modify VANILLA or FROZEN registry directly!"); if (this.groovyScript$dummies.contains(name)) return; V entry = this.names.remove(name); if (entry != null) { @@ -121,7 +123,8 @@ public abstract class ForgeRegistryMixin> imple @Override public void groovyScript$onReload() { - if (stage != RegistryManager.ACTIVE) throw new IllegalStateException("Do not modify VANILLA or FROZEN registry directly!"); + if (stage != RegistryManager.ACTIVE) throw new IllegalStateException( + "Do not modify VANILLA or FROZEN registry directly!"); unfreeze(); groovyScript$initReg(); if (this.groovyScript$scripted != null) { @@ -152,8 +155,10 @@ public abstract class ForgeRegistryMixin> imple @Unique public V groovyScript$putDummy(V entry, ResourceLocation rl, Integer id, Object owner, DummyContext context) { if (entry == null || rl == null || id == null) { - GroovyLog.get().errorMC("Error putting dummy in forge registry for {} during {} at stage {}. Are null: entry-{}, name-{}, id-{}", - superType.getSimpleName(), context.name().toLowerCase(Locale.ROOT), stage.getName(), entry == null, rl == null, id == null); + GroovyLog.get().errorMC( + "Error putting dummy in forge registry for {} during {} at stage {}. Are null: entry-{}, name-{}, id-{}", + superType.getSimpleName(), context.name().toLowerCase(Locale.ROOT), stage.getName(), + entry == null, rl == null, id == null); return null; } V dummy = groovyScript$getDummy(rl); @@ -180,8 +185,8 @@ public abstract class ForgeRegistryMixin> imple if (dummy != null) { Integer id = this.ids.inverse().remove(dummy); if (id == null) { - GroovyLog.get().errorMC("No id found while removing a dummy with name '{}' from {} registry at stage {}.", - rl, superType.getSimpleName(), stage.getName()); + GroovyLog.get().errorMC("No id found while removing a dummy with name '{}' from {} registry at stage {}.", rl, + superType.getSimpleName(), stage.getName()); } else { this.availabilityMap.clear(id); id0 = id; @@ -192,12 +197,9 @@ public abstract class ForgeRegistryMixin> imple return id0; } - @Unique - @Nullable + @Unique @Nullable public V groovyScript$getDummy(ResourceLocation rl) { - if (dummyFactory != null) { - return dummyFactory.createDummy(rl); - } + if (dummyFactory != null) { return dummyFactory.createDummy(rl); } if (groovyScript$dummySupplier == null) { groovyScript$dummySupplier = ReloadableRegistryManager.getDummySupplier(getRegistrySuperType()); } @@ -214,8 +216,7 @@ public abstract class ForgeRegistryMixin> imple availabilityMap.set(id); } - @SuppressWarnings("unchecked") - @Unique + @SuppressWarnings("unchecked") @Unique private void groovyScript$initReg() { if (groovyScript$frozen == null || groovyScript$frozen.groovyScript$isDummy()) { groovyScript$frozen = (IReloadableForgeRegistry) RegistryManager.FROZEN.getRegistry(superType); @@ -227,4 +228,3 @@ public abstract class ForgeRegistryMixin> imple } } } - diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/FurnaceRecipeMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/FurnaceRecipeMixin.java index 85c5ef4ca..c06c8a648 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/FurnaceRecipeMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/FurnaceRecipeMixin.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin; -import com.cleanroommc.groovyscript.compat.vanilla.FurnaceRecipeManager; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.cleanroommc.groovyscript.compat.vanilla.FurnaceRecipeManager; + @Mixin(value = FurnaceRecipes.class) public abstract class FurnaceRecipeMixin { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/GuiCreateWorldMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/GuiCreateWorldMixin.java index bbfd0842d..45ebed001 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/GuiCreateWorldMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/GuiCreateWorldMixin.java @@ -1,13 +1,9 @@ package com.cleanroommc.groovyscript.core.mixin; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.packmode.Packmode; -import com.cleanroommc.groovyscript.packmode.PackmodeButton; -import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; -import com.cleanroommc.groovyscript.sandbox.LoadStage; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiCreateWorld; import net.minecraft.client.gui.GuiScreen; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; @@ -16,6 +12,12 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.packmode.Packmode; +import com.cleanroommc.groovyscript.packmode.PackmodeButton; +import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; +import com.cleanroommc.groovyscript.sandbox.LoadStage; + @Mixin(GuiCreateWorld.class) public class GuiCreateWorldMixin extends GuiScreen { @@ -25,11 +27,13 @@ public class GuiCreateWorldMixin extends GuiScreen { private String gameModeDesc1; @Shadow private String gameModeDesc2; - @Unique - @Mutable + @Unique @Mutable private PackmodeButton packmodeButton; - @Inject(method = "initGui", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiCreateWorld;showMoreWorldOptions(Z)V", shift = At.Shift.BEFORE)) + @Inject(method = "initGui", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/gui/GuiCreateWorld;showMoreWorldOptions(Z)V", + shift = At.Shift.BEFORE)) public void init(CallbackInfo ci) { if (Packmode.needsPackmode()) { GuiCreateWorld this$0 = (GuiCreateWorld) (Object) this; @@ -52,7 +56,10 @@ public void actionPerformed(GuiButton button, CallbackInfo ci) { } } - @Inject(method = "actionPerformed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;launchIntegratedServer(Ljava/lang/String;Ljava/lang/String;Lnet/minecraft/world/WorldSettings;)V", shift = At.Shift.BEFORE)) + @Inject(method = "actionPerformed", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/Minecraft;launchIntegratedServer(Ljava/lang/String;Ljava/lang/String;Lnet/minecraft/world/WorldSettings;)V", + shift = At.Shift.BEFORE)) public void actionPerformed2(GuiButton button, CallbackInfo ci) { if (Packmode.needsPackmode()) { Packmode.updatePackmode(this.packmodeButton.getPackmode()); @@ -61,7 +68,12 @@ public void actionPerformed2(GuiButton button, CallbackInfo ci) { } } - @Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiCreateWorld;drawString(Lnet/minecraft/client/gui/FontRenderer;Ljava/lang/String;III)V", ordinal = 6, shift = At.Shift.BEFORE), cancellable = true) + @Inject(method = "drawScreen", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/gui/GuiCreateWorld;drawString(Lnet/minecraft/client/gui/FontRenderer;Ljava/lang/String;III)V", + ordinal = 6, + shift = At.Shift.BEFORE), + cancellable = true) public void draw(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { if (Packmode.needsPackmode()) { GuiCreateWorld this$0 = (GuiCreateWorld) (Object) this; diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/InventoryCraftingAccess.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/InventoryCraftingAccess.java index ec9bc4041..457c53528 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/InventoryCraftingAccess.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/InventoryCraftingAccess.java @@ -2,6 +2,7 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryCrafting; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ItemMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ItemMixin.java index b6af180a1..28eb1211d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ItemMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ItemMixin.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.core.mixin; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.IRarity; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; + // Forge is stupid (again) @Mixin(Item.class) public class ItemMixin { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ItemStackMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ItemStackMixin.java index 96004614f..5b3638d52 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ItemStackMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ItemStackMixin.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.core.mixin; -import com.cleanroommc.groovyscript.compat.vanilla.ItemStackMixinExpansion; -import com.cleanroommc.groovyscript.compat.vanilla.ItemStackTransformer; +import java.util.function.Predicate; + import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; + import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; -import java.util.function.Predicate; +import com.cleanroommc.groovyscript.compat.vanilla.ItemStackMixinExpansion; +import com.cleanroommc.groovyscript.compat.vanilla.ItemStackTransformer; @Mixin(value = ItemStack.class) public abstract class ItemStackMixin implements ItemStackMixinExpansion { @@ -63,14 +65,9 @@ public abstract class ItemStackMixin implements ItemStackMixinExpansion { } } - @Nullable - @Override - public String getMark() { - return groovyScript$mark; - } + @Nullable @Override + public String getMark() { return groovyScript$mark; } @Override - public void setMark(String mark) { - this.groovyScript$mark = mark; - } + public void setMark(String mark) { this.groovyScript$mark = mark; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/LoaderControllerMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/LoaderControllerMixin.java index 2f9c836bf..56cb8f40f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/LoaderControllerMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/LoaderControllerMixin.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.core.mixin; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.sandbox.LoadStage; import net.minecraftforge.fml.common.LoadController; import net.minecraftforge.fml.common.LoaderState; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.sandbox.LoadStage; + @Mixin(value = LoadController.class, remap = false) public class LoaderControllerMixin { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/OreDictionaryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/OreDictionaryAccessor.java index ce7d0521d..5b2367a95 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/OreDictionaryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/OreDictionaryAccessor.java @@ -1,14 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin; +import java.util.List; +import java.util.Map; + import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraftforge.oredict.OreDictionary; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; -import java.util.Map; - @Mixin(value = OreDictionary.class, remap = false) public interface OreDictionaryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/SlotCraftingAccess.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/SlotCraftingAccess.java index d35e8df41..14fa8ae56 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/SlotCraftingAccess.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/SlotCraftingAccess.java @@ -2,6 +2,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.SlotCrafting; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/TileEntityPistonMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/TileEntityPistonMixin.java index a616a4c60..b03223431 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/TileEntityPistonMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/TileEntityPistonMixin.java @@ -1,11 +1,7 @@ package com.cleanroommc.groovyscript.core.mixin; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; -import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.Share; -import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; -import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; -import com.llamalad7.mixinextras.sugar.ref.LocalRef; +import java.util.List; + import net.minecraft.block.BlockPistonMoving; import net.minecraft.block.material.EnumPushReaction; import net.minecraft.block.material.Material; @@ -14,13 +10,19 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.tileentity.TileEntityPiston; import net.minecraft.util.EnumFacing; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.List; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; +import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.sugar.Share; +import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; +import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; +import com.llamalad7.mixinextras.sugar.ref.LocalRef; @Mixin(TileEntityPiston.class) public abstract class TileEntityPistonMixin { @@ -31,29 +33,36 @@ public abstract class TileEntityPistonMixin { @Shadow private boolean shouldHeadBeRendered; - @Inject(method = "moveCollidedEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;isStickyBlock(Lnet/minecraft/block/state/IBlockState;)Z", shift = At.Shift.AFTER), remap = false) - private void moveCollidedEntitiesPre(float f, CallbackInfo ci, @Local(ordinal = 0) EnumFacing facing, - @Local(ordinal = 1) List list1, + @Inject(method = "moveCollidedEntities", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/block/Block;isStickyBlock(Lnet/minecraft/block/state/IBlockState;)Z", + shift = At.Shift.AFTER), + remap = false) + private void moveCollidedEntitiesPre(float f, CallbackInfo ci, @Local(ordinal = 0) EnumFacing facing, @Local( + ordinal = 1) List list1, @Share("tryRecipesUntil") LocalIntRef tryRecipesUntil, @Share("pushingAgainst") LocalRef pushingAgainst, @Share("checkRecipes") LocalBooleanRef checkRecipes) { TileEntityPiston piston = (TileEntityPiston) (Object) this; tryRecipesUntil.set(list1.size()); - boolean b = !piston.getWorld().isRemote && - this.extending && - this.shouldHeadBeRendered && - f >= 1.0f; + boolean b = !piston.getWorld().isRemote && this.extending && this.shouldHeadBeRendered && f >= 1.0f; if (b) { pushingAgainst.set(piston.getWorld().getBlockState(piston.getPos().offset(facing))); - checkRecipes.set(!(pushingAgainst.get() instanceof BlockPistonMoving) && pushingAgainst.get().getMaterial() != Material.AIR); + checkRecipes.set(!(pushingAgainst.get() instanceof BlockPistonMoving) && pushingAgainst.get() + .getMaterial() != Material.AIR); } else { checkRecipes.set(false); } } - @Inject(method = "moveCollidedEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPushReaction()Lnet/minecraft/block/material/EnumPushReaction;", shift = At.Shift.AFTER)) - private void moveCollidedEntitiesPost(float p_184322_1_, CallbackInfo ci, @Local int index, @Local(ordinal = 1) List list1, - @Share("tryRecipesUntil") LocalIntRef tryRecipesUntil, @Share("pushingAgainst") LocalRef pushingAgainst, + @Inject(method = "moveCollidedEntities", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/entity/Entity;getPushReaction()Lnet/minecraft/block/material/EnumPushReaction;", + shift = At.Shift.AFTER)) + private void moveCollidedEntitiesPost(float p_184322_1_, CallbackInfo ci, @Local int index, @Local( + ordinal = 1) List list1, + @Share("tryRecipesUntil") LocalIntRef tryRecipesUntil, + @Share("pushingAgainst") LocalRef pushingAgainst, @Share("checkRecipes") LocalBooleanRef checkRecipes) { Entity entity = list1.get(index); if (entity.getPushReaction() == EnumPushReaction.IGNORE) return; diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/advancedmortars/RegistryRecipeMortarAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/advancedmortars/RegistryRecipeMortarAccessor.java index 5d0718e4e..9ecd99194 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/advancedmortars/RegistryRecipeMortarAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/advancedmortars/RegistryRecipeMortarAccessor.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.core.mixin.advancedmortars; -import com.codetaylor.mc.advancedmortars.modules.mortar.recipe.RecipeMortar; -import com.codetaylor.mc.advancedmortars.modules.mortar.recipe.RegistryRecipeMortar; -import com.codetaylor.mc.advancedmortars.modules.mortar.reference.EnumMortarType; +import java.util.EnumMap; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.EnumMap; -import java.util.List; +import com.codetaylor.mc.advancedmortars.modules.mortar.recipe.RecipeMortar; +import com.codetaylor.mc.advancedmortars.modules.mortar.recipe.RegistryRecipeMortar; +import com.codetaylor.mc.advancedmortars.modules.mortar.reference.EnumMortarType; @Mixin(value = RegistryRecipeMortar.class, remap = false) public interface RegistryRecipeMortarAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/MatterCannonAmmoRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/MatterCannonAmmoRegistryAccessor.java index 6a8ebb6fb..d3677a897 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/MatterCannonAmmoRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/MatterCannonAmmoRegistryAccessor.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.appliedenergistics2; -import appeng.core.features.registries.MatterCannonAmmoRegistry; +import java.util.HashMap; + import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.HashMap; +import appeng.core.features.registries.MatterCannonAmmoRegistry; @Mixin(value = MatterCannonAmmoRegistry.class, remap = false) public interface MatterCannonAmmoRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/MovableTileRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/MovableTileRegistryAccessor.java index 6d0637d26..a17fae202 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/MovableTileRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/MovableTileRegistryAccessor.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.appliedenergistics2; -import appeng.api.movable.IMovableHandler; -import appeng.core.features.registries.MovableTileRegistry; +import java.util.HashMap; +import java.util.List; + import net.minecraft.tileentity.TileEntity; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.HashMap; -import java.util.List; +import appeng.api.movable.IMovableHandler; +import appeng.core.features.registries.MovableTileRegistry; @Mixin(value = MovableTileRegistry.class, remap = false) public interface MovableTileRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/P2PTunnelRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/P2PTunnelRegistryAccessor.java index e9c739644..56fca0c80 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/P2PTunnelRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/appliedenergistics2/P2PTunnelRegistryAccessor.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.appliedenergistics2; -import appeng.api.config.TunnelType; -import appeng.core.features.registries.P2PTunnelRegistry; +import java.util.Map; + import net.minecraft.item.ItemStack; import net.minecraftforge.common.capabilities.Capability; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import appeng.api.config.TunnelType; +import appeng.core.features.registries.P2PTunnelRegistry; @Mixin(value = P2PTunnelRegistry.class, remap = false) public interface P2PTunnelRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationBaseAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationBaseAccessor.java index c7b19cf12..cb911ccc7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationBaseAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationBaseAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.constellation.ConstellationBase; -import hellfirepvp.astralsorcery.common.crafting.ItemHandle; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import hellfirepvp.astralsorcery.common.constellation.ConstellationBase; +import hellfirepvp.astralsorcery.common.crafting.ItemHandle; @Mixin(value = ConstellationBase.class, remap = false) public interface ConstellationBaseAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationMapEffectRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationMapEffectRegistryAccessor.java index d5f2f7c48..5ff0bfe0b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationMapEffectRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationMapEffectRegistryAccessor.java @@ -1,18 +1,17 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.constellation.IConstellation; -import hellfirepvp.astralsorcery.common.constellation.starmap.ConstellationMapEffectRegistry; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import hellfirepvp.astralsorcery.common.constellation.IConstellation; +import hellfirepvp.astralsorcery.common.constellation.starmap.ConstellationMapEffectRegistry; @Mixin(value = ConstellationMapEffectRegistry.class, remap = false) public interface ConstellationMapEffectRegistryAccessor { @Accessor - static Map getEffectRegistry() { - return null; - } + static Map getEffectRegistry() { return null; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationRegistryAccessor.java index 063b7c07c..1fbc0a02a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ConstellationRegistryAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.constellation.*; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import hellfirepvp.astralsorcery.common.constellation.*; @Mixin(value = ConstellationRegistry.class, remap = false) public interface ConstellationRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/FluidRarityEntryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/FluidRarityEntryAccessor.java index deca0db1e..2cd818065 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/FluidRarityEntryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/FluidRarityEntryAccessor.java @@ -1,20 +1,24 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.base.FluidRarityRegistry; import net.minecraftforge.fluids.Fluid; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import hellfirepvp.astralsorcery.common.base.FluidRarityRegistry; + @Mixin(FluidRarityRegistry.FluidRarityEntry.class) public interface FluidRarityEntryAccessor { @Invoker("") - static FluidRarityRegistry.FluidRarityEntry createFluidRarityEntry(String fluidNameTmp, int rarity, int guaranteedAmount, int additionalRandomAmount) { + static FluidRarityRegistry.FluidRarityEntry createFluidRarityEntry(String fluidNameTmp, int rarity, int guaranteedAmount, + int additionalRandomAmount) { throw new UnsupportedOperationException(); } @Invoker("") - static FluidRarityRegistry.FluidRarityEntry createFluidRarityEntry(Fluid fluid, int rarity, int guaranteedAmount, int additionalRandomAmount) { + static FluidRarityRegistry.FluidRarityEntry createFluidRarityEntry(Fluid fluid, int rarity, int guaranteedAmount, + int additionalRandomAmount) { throw new UnsupportedOperationException(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/FluidRarityRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/FluidRarityRegistryAccessor.java index 6005e03b8..5233f154e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/FluidRarityRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/FluidRarityRegistryAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.base.FluidRarityRegistry; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import hellfirepvp.astralsorcery.common.base.FluidRarityRegistry; @Mixin(value = FluidRarityRegistry.class, remap = false) public interface FluidRarityRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/LightOreTransmutationsAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/LightOreTransmutationsAccessor.java index 2c34795c3..c32e25d6b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/LightOreTransmutationsAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/LightOreTransmutationsAccessor.java @@ -1,17 +1,16 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.base.LightOreTransmutations; +import java.util.Collection; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Collection; +import hellfirepvp.astralsorcery.common.base.LightOreTransmutations; @Mixin(value = LightOreTransmutations.class, remap = false) public interface LightOreTransmutationsAccessor { @Accessor - static Collection getRegisteredTransmutations() { - return null; - } + static Collection getRegisteredTransmutations() { return null; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/LiquidInteractionAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/LiquidInteractionAccessor.java index 04a694511..c1223f5e8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/LiquidInteractionAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/LiquidInteractionAccessor.java @@ -1,18 +1,17 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.base.LiquidInteraction; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import hellfirepvp.astralsorcery.common.base.LiquidInteraction; @Mixin(value = LiquidInteraction.class, remap = false) public interface LiquidInteractionAccessor { @Accessor - static List getRegisteredInteractions() { - return null; - } + static List getRegisteredInteractions() { return null; } @Accessor("action") LiquidInteraction.FluidInteractionAction getFluidInteractionAction(); diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/OreTypesAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/OreTypesAccessor.java index 9727573af..fd9494cb5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/OreTypesAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/OreTypesAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.base.OreTypes; -import hellfirepvp.astralsorcery.common.base.sets.OreEntry; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; -import java.util.List; +import hellfirepvp.astralsorcery.common.base.OreTypes; +import hellfirepvp.astralsorcery.common.base.sets.OreEntry; @Mixin(value = OreTypes.class, remap = false) public interface OreTypesAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkLevelManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkLevelManagerAccessor.java index 248989895..53d04b07c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkLevelManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkLevelManagerAccessor.java @@ -1,18 +1,18 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.constellation.perk.PerkLevelManager; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; -import java.util.Map; +import hellfirepvp.astralsorcery.common.constellation.perk.PerkLevelManager; @Mixin(value = PerkLevelManager.class, remap = false) public interface PerkLevelManagerAccessor { @Accessor("LEVEL_CAP") - static void setLevelCap(int cap) { - } + static void setLevelCap(int cap) {} @Accessor("totalExpLevelRequired") Map getLevelMap(); @@ -20,4 +20,4 @@ static void setLevelCap(int cap) { @Invoker("ensureLevels") void generateLevelMap(); -} \ No newline at end of file +} diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkLevelManagerMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkLevelManagerMixin.java index 307ad01be..4d0945aca 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkLevelManagerMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkLevelManagerMixin.java @@ -1,16 +1,19 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import hellfirepvp.astralsorcery.common.constellation.perk.PerkLevelManager; +import java.util.Map; + import net.minecraft.util.math.MathHelper; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.Map; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.sandbox.ClosureHelper; + +import hellfirepvp.astralsorcery.common.constellation.perk.PerkLevelManager; @Mixin(value = PerkLevelManager.class, remap = false) public abstract class PerkLevelManagerMixin { @@ -26,13 +29,14 @@ public void ensureLevels(CallbackInfo ci) { if (this.totalExpLevelRequired.isEmpty()) { for (int i = 1; i <= LEVEL_CAP; ++i) { long prev = this.totalExpLevelRequired.getOrDefault(i - 1, 0L); - if (ModSupport.ASTRAL_SORCERY.get().perkTreeConfig.xpFunction != null) - this.totalExpLevelRequired.put(i, ClosureHelper.call(ModSupport.ASTRAL_SORCERY.get().perkTreeConfig.xpFunction, i, prev)); - else - this.totalExpLevelRequired.put(i, prev + 150L + MathHelper.lfloor(Math.pow(2.0, i / 2.0F + 3))); + if (ModSupport.ASTRAL_SORCERY.get().perkTreeConfig.xpFunction != null) this.totalExpLevelRequired.put(i, + ClosureHelper.call(ModSupport.ASTRAL_SORCERY.get().perkTreeConfig.xpFunction, + i, + prev)); + else this.totalExpLevelRequired.put(i, prev + 150L + MathHelper.lfloor(Math.pow(2.0, i / 2.0F + 3))); } } ci.cancel(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkTreeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkTreeAccessor.java index df2bd4400..a29394876 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkTreeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/PerkTreeAccessor.java @@ -1,15 +1,16 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.constellation.perk.AbstractPerk; -import hellfirepvp.astralsorcery.common.constellation.perk.tree.PerkTree; -import hellfirepvp.astralsorcery.common.util.data.Tuple; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - import java.util.Collection; import java.util.List; import java.util.Map; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import hellfirepvp.astralsorcery.common.constellation.perk.AbstractPerk; +import hellfirepvp.astralsorcery.common.constellation.perk.tree.PerkTree; +import hellfirepvp.astralsorcery.common.util.data.Tuple; + @Mixin(value = PerkTree.class, remap = false) public interface PerkTreeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ResearchNodeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ResearchNodeAccessor.java index af029138d..8a7b19579 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ResearchNodeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/ResearchNodeAccessor.java @@ -1,9 +1,10 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.data.research.ResearchNode; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import hellfirepvp.astralsorcery.common.data.research.ResearchNode; + @Mixin(value = ResearchNode.class, remap = false) public interface ResearchNodeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/TraitRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/TraitRecipeAccessor.java index 1afea5b9b..03001e754 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/TraitRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/TraitRecipeAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.crafting.ItemHandle; -import hellfirepvp.astralsorcery.common.crafting.altar.recipes.TraitRecipe; +import java.util.List; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; -import java.util.Map; +import hellfirepvp.astralsorcery.common.crafting.ItemHandle; +import hellfirepvp.astralsorcery.common.crafting.altar.recipes.TraitRecipe; @Mixin(value = TraitRecipe.class, remap = false) public interface TraitRecipeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/WellLiquefactionAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/WellLiquefactionAccessor.java index 214e6ff6f..1c3f1c0ad 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/WellLiquefactionAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/astralsorcery/WellLiquefactionAccessor.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.astralsorcery; -import hellfirepvp.astralsorcery.common.base.WellLiquefaction; +import java.util.Map; + import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import hellfirepvp.astralsorcery.common.base.WellLiquefaction; @Mixin(value = WellLiquefaction.class, remap = false) public interface WellLiquefactionAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/betterwithmods/BWMHeatRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/betterwithmods/BWMHeatRegistryAccessor.java index 5db2ceede..53017f419 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/betterwithmods/BWMHeatRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/betterwithmods/BWMHeatRegistryAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.betterwithmods; -import betterwithmods.common.registry.heat.BWMHeatRegistry; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import betterwithmods.common.registry.heat.BWMHeatRegistry; @Mixin(value = BWMHeatRegistry.class, remap = false) public interface BWMHeatRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/betterwithmods/HopperFiltersAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/betterwithmods/HopperFiltersAccessor.java index 977686b8b..74bb54081 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/betterwithmods/HopperFiltersAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/betterwithmods/HopperFiltersAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.betterwithmods; -import betterwithmods.api.tile.IHopperFilter; -import betterwithmods.common.registry.HopperFilters; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import betterwithmods.api.tile.IHopperFilter; +import betterwithmods.common.registry.HopperFilters; @Mixin(value = HopperFilters.class, remap = false) public interface HopperFiltersAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/bloodmagic/BloodMagicRecipeRegistrarAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/bloodmagic/BloodMagicRecipeRegistrarAccessor.java index 4176e39ca..e3e640847 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/bloodmagic/BloodMagicRecipeRegistrarAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/bloodmagic/BloodMagicRecipeRegistrarAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.bloodmagic; -import WayofTime.bloodmagic.api.impl.BloodMagicRecipeRegistrar; -import WayofTime.bloodmagic.api.impl.recipe.*; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Set; +import WayofTime.bloodmagic.api.impl.BloodMagicRecipeRegistrar; +import WayofTime.bloodmagic.api.impl.recipe.*; @Mixin(value = BloodMagicRecipeRegistrar.class, remap = false) public interface BloodMagicRecipeRegistrarAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/bloodmagic/BloodMagicValueManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/bloodmagic/BloodMagicValueManagerAccessor.java index 4de71959f..29b5670e0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/bloodmagic/BloodMagicValueManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/bloodmagic/BloodMagicValueManagerAccessor.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.bloodmagic; -import WayofTime.bloodmagic.api.impl.BloodMagicValueManager; -import WayofTime.bloodmagic.incense.TranquilityStack; +import java.util.Map; + import net.minecraft.block.state.IBlockState; import net.minecraft.util.ResourceLocation; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import WayofTime.bloodmagic.api.impl.BloodMagicValueManager; +import WayofTime.bloodmagic.incense.TranquilityStack; @Mixin(value = BloodMagicValueManager.class, remap = false) public interface BloodMagicValueManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/botania/BotaniaAPIAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/botania/BotaniaAPIAccessor.java index e78f7bc0c..8995f4e03 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/botania/BotaniaAPIAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/botania/BotaniaAPIAccessor.java @@ -2,8 +2,10 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; + import vazkii.botania.api.BotaniaAPI; @Mixin(value = BotaniaAPI.class, remap = false) diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/botania/PageCraftingRecipeMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/botania/PageCraftingRecipeMixin.java index 541ef7e61..62f7b7854 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/botania/PageCraftingRecipeMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/botania/PageCraftingRecipeMixin.java @@ -1,7 +1,5 @@ package com.cleanroommc.groovyscript.core.mixin.botania; -import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; -import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.Ingredient; @@ -12,9 +10,14 @@ import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; + +import com.cleanroommc.groovyscript.compat.vanilla.ShapedCraftingRecipe; +import com.cleanroommc.groovyscript.compat.vanilla.ShapelessCraftingRecipe; + import vazkii.botania.api.internal.IGuiLexiconEntry; import vazkii.botania.common.lexicon.page.PageCraftingRecipe; import vazkii.botania.common.lexicon.page.PageRecipe; @@ -37,8 +40,7 @@ public PageCraftingRecipeMixin(String unlocalizedName) { * @author Turing6 * @reason Groovyscript's recipe classes are ignored during ingredient render */ - @SideOnly(Side.CLIENT) - @Overwrite + @SideOnly(Side.CLIENT) @Overwrite public void renderCraftingRecipe(IGuiLexiconEntry gui, IRecipe recipe) { if (recipe != null) { int x; @@ -67,13 +69,14 @@ public void renderCraftingRecipe(IGuiLexiconEntry gui, IRecipe recipe) { } } else { this.oreDictRecipe = recipe instanceof ShapedOreRecipe; - int width = oreDictRecipe - ? ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe) recipe, "width") - : recipe instanceof ShapedCraftingRecipe ? ((ShapedCraftingRecipe) recipe).getRecipeWidth() : ((ShapedRecipes) recipe).getWidth(); - int height = oreDictRecipe - ? ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe) recipe, "height") - : recipe instanceof ShapedCraftingRecipe ? ((ShapedCraftingRecipe) recipe).getRecipeHeight() - : ((ShapedRecipes) recipe).getHeight(); + int width = oreDictRecipe ? ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe) recipe, + "width") : recipe instanceof ShapedCraftingRecipe ? + ((ShapedCraftingRecipe) recipe).getRecipeWidth() : + ((ShapedRecipes) recipe).getWidth(); + int height = oreDictRecipe ? ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe) recipe, + "height") : recipe instanceof ShapedCraftingRecipe ? + ((ShapedCraftingRecipe) recipe).getRecipeHeight() : + ((ShapedRecipes) recipe).getHeight(); for (index = 0; index < height; ++index) { for (x = 0; x < width; ++x) { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/calculator/DefinedRecipeHelperMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/calculator/DefinedRecipeHelperMixin.java index 48cc320d9..7c764173d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/calculator/DefinedRecipeHelperMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/calculator/DefinedRecipeHelperMixin.java @@ -1,19 +1,21 @@ package com.cleanroommc.groovyscript.core.mixin.calculator; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.calculator.mod.common.recipes.ResearchRecipeType; import sonar.core.recipes.DefinedRecipeHelper; import sonar.core.recipes.ISonarRecipeObject; -import java.util.List; - @Mixin(value = DefinedRecipeHelper.class, remap = false) public abstract class DefinedRecipeHelperMixin extends RecipeHelperV2Mixin { @Override - public void buildRecipe(List recipeInputs, List recipeOutputs, List additionals, boolean shapeless, CallbackInfoReturnable cir) { + public void buildRecipe(List recipeInputs, List recipeOutputs, List additionals, + boolean shapeless, CallbackInfoReturnable cir) { cir.setReturnValue(new CalculatorRecipe(recipeInputs, recipeOutputs, ResearchRecipeType.NONE, shapeless)); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/calculator/RecipeHelperV2Mixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/calculator/RecipeHelperV2Mixin.java index 494d5afd1..31d66e659 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/calculator/RecipeHelperV2Mixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/calculator/RecipeHelperV2Mixin.java @@ -1,20 +1,21 @@ package com.cleanroommc.groovyscript.core.mixin.calculator; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + import sonar.calculator.mod.common.recipes.CalculatorRecipe; import sonar.core.recipes.ISonarRecipeObject; import sonar.core.recipes.RecipeHelperV2; -import java.util.List; - @Mixin(value = RecipeHelperV2.class, remap = false) public class RecipeHelperV2Mixin { @Inject(method = "buildRecipe", at = @At("RETURN"), cancellable = true) - public void buildRecipe(List recipeInputs, List recipeOutputs, List additionals, boolean shapeless, CallbackInfoReturnable cir) { - } + public void buildRecipe(List recipeInputs, List recipeOutputs, List additionals, + boolean shapeless, CallbackInfoReturnable cir) {} } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/EnergyCoreStructureMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/EnergyCoreStructureMixin.java index 22cdef53e..65d2cd24e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/EnergyCoreStructureMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/EnergyCoreStructureMixin.java @@ -1,14 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.draconicevolution; -import com.brandon3055.draconicevolution.blocks.tileentity.TileEnergyStorageCore; -import com.brandon3055.draconicevolution.world.EnergyCoreStructure; -import com.cleanroommc.groovyscript.GroovyScriptConfig; -import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.BlockStateEnergyCoreStructure; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.brandon3055.draconicevolution.blocks.tileentity.TileEnergyStorageCore; +import com.brandon3055.draconicevolution.world.EnergyCoreStructure; +import com.cleanroommc.groovyscript.GroovyScriptConfig; +import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.BlockStateEnergyCoreStructure; + @Mixin(value = EnergyCoreStructure.class, remap = false) public abstract class EnergyCoreStructureMixin { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/FusionRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/FusionRegistryAccessor.java index 4f9b49fbc..dfb3e652a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/FusionRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/FusionRegistryAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.draconicevolution; -import com.brandon3055.draconicevolution.api.fusioncrafting.IFusionRecipe; -import com.brandon3055.draconicevolution.lib.FusionRecipeRegistry; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import com.brandon3055.draconicevolution.api.fusioncrafting.IFusionRecipe; +import com.brandon3055.draconicevolution.lib.FusionRecipeRegistry; @Mixin(value = FusionRecipeRegistry.class, remap = false) public interface FusionRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/InvisECoreBlockMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/InvisECoreBlockMixin.java index 17dc1bc1a..62a547130 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/InvisECoreBlockMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/InvisECoreBlockMixin.java @@ -1,25 +1,29 @@ package com.cleanroommc.groovyscript.core.mixin.draconicevolution; -import com.brandon3055.draconicevolution.blocks.InvisECoreBlock; -import com.cleanroommc.groovyscript.GroovyScriptConfig; -import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.InvisECoreBlockLogic; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.brandon3055.draconicevolution.blocks.InvisECoreBlock; +import com.cleanroommc.groovyscript.GroovyScriptConfig; +import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.InvisECoreBlockLogic; + @Mixin(value = InvisECoreBlock.class, remap = false) public class InvisECoreBlockMixin { @Inject(method = "onBlockHarvested(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/entity/player/EntityPlayer;)V", - at = @At("HEAD"), cancellable = true, remap = true) + at = @At("HEAD"), + cancellable = true, + remap = true) public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player, CallbackInfo ci) { if (GroovyScriptConfig.compat.draconicEvolutionEnergyCore) { InvisECoreBlockLogic.onBlockHarvested(world, pos, player); @@ -28,7 +32,8 @@ public void onBlockHarvested(World world, BlockPos pos, IBlockState state, Entit } @Inject(method = "getPickBlock", at = @At("HEAD"), cancellable = true) - public void getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player, CallbackInfoReturnable cir) { + public void getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player, + CallbackInfoReturnable cir) { if (GroovyScriptConfig.compat.draconicEvolutionEnergyCore) { cir.setReturnValue(InvisECoreBlockLogic.getPickBlock(world, pos)); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileEnergyCoreStabilizerMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileEnergyCoreStabilizerMixin.java index 4f0f38b03..87ced7194 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileEnergyCoreStabilizerMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileEnergyCoreStabilizerMixin.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.core.mixin.draconicevolution; -import com.brandon3055.draconicevolution.blocks.tileentity.TileEnergyCoreStabilizer; -import com.cleanroommc.groovyscript.GroovyScriptConfig; -import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.TileEnergyCoreStabilizerLogic; import net.minecraft.util.math.BlockPos; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.brandon3055.draconicevolution.blocks.tileentity.TileEnergyCoreStabilizer; +import com.cleanroommc.groovyscript.GroovyScriptConfig; +import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.TileEnergyCoreStabilizerLogic; + @Mixin(value = TileEnergyCoreStabilizer.class, remap = false) public abstract class TileEnergyCoreStabilizerMixin { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileEnergyStorageCoreMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileEnergyStorageCoreMixin.java index 5ec33f542..17ba330d7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileEnergyStorageCoreMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileEnergyStorageCoreMixin.java @@ -1,9 +1,7 @@ package com.cleanroommc.groovyscript.core.mixin.draconicevolution; -import com.brandon3055.draconicevolution.blocks.tileentity.TileEnergyStorageCore; -import com.cleanroommc.groovyscript.GroovyScriptConfig; -import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.BlockStateEnergyCoreStructure; import net.minecraft.util.math.BlockPos; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -11,6 +9,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.brandon3055.draconicevolution.blocks.tileentity.TileEnergyStorageCore; +import com.cleanroommc.groovyscript.GroovyScriptConfig; +import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.BlockStateEnergyCoreStructure; + @Mixin(value = TileEnergyStorageCore.class, remap = false) public abstract class TileEnergyStorageCoreMixin { @@ -37,9 +39,10 @@ public void validateStructure(CallbackInfoReturnable cir) { var helper = ((BlockStateEnergyCoreStructure) tile.coreStructure).getHelper(); if (!(tile.coreValid.value = tile.coreStructure.checkTier(tile.tier.value))) { BlockPos pos = helper.invalidBlock; - tile.invalidMessage.value = "Error At: x:" + pos.getX() + ", y:" + pos.getY() + ", z:" + pos.getZ() + - " Expected: " + helper.expectedBlockState.getBlock().getRegistryName() + ":" + - helper.expectedBlockState.getBlock().getMetaFromState(helper.expectedBlockState); + tile.invalidMessage.value = "Error At: x:" + pos.getX() + ", y:" + pos.getY() + ", z:" + pos.getZ() + " Expected: " + + helper.expectedBlockState.getBlock().getRegistryName() + ":" + helper.expectedBlockState + .getBlock() + .getMetaFromState(helper.expectedBlockState); valid = false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileInvisECoreBlockMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileInvisECoreBlockMixin.java index f69d349a1..c8aaaa59b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileInvisECoreBlockMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/draconicevolution/TileInvisECoreBlockMixin.java @@ -1,12 +1,9 @@ package com.cleanroommc.groovyscript.core.mixin.draconicevolution; -import com.brandon3055.draconicevolution.blocks.tileentity.TileInvisECoreBlock; -import com.cleanroommc.groovyscript.GroovyScriptConfig; -import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.TileInvisECoreBlockLogic; -import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.TileInvisECoreBlockState; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -14,8 +11,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@SuppressWarnings("AddedMixinMembersNamePattern") -@Mixin(value = TileInvisECoreBlock.class, remap = false) +import com.brandon3055.draconicevolution.blocks.tileentity.TileInvisECoreBlock; +import com.cleanroommc.groovyscript.GroovyScriptConfig; +import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.TileInvisECoreBlockLogic; +import com.cleanroommc.groovyscript.compat.mods.draconicevolution.helpers.TileInvisECoreBlockState; + +@SuppressWarnings("AddedMixinMembersNamePattern") @Mixin(value = TileInvisECoreBlock.class, remap = false) public class TileInvisECoreBlockMixin implements TileInvisECoreBlockState { @Unique @@ -24,9 +25,7 @@ public class TileInvisECoreBlockMixin implements TileInvisECoreBlockState { int metadata; @Override - public boolean getDefault() { - return isDefault; - } + public boolean getDefault() { return isDefault; } @Override public void setIsDefault() { @@ -35,9 +34,7 @@ public void setIsDefault() { } @Override - public int getMetadata() { - return metadata; - } + public int getMetadata() { return metadata; } @Override public void setMetadata(int metadata) { @@ -53,7 +50,10 @@ public void revert(CallbackInfo ci) { } } - @Inject(method = "getUpdatePacket()Lnet/minecraft/network/play/server/SPacketUpdateTileEntity;", at = @At("HEAD"), cancellable = true, remap = true) + @Inject(method = "getUpdatePacket()Lnet/minecraft/network/play/server/SPacketUpdateTileEntity;", + at = @At("HEAD"), + cancellable = true, + remap = true) public void getUpdatePacket(CallbackInfoReturnable cir) { if (GroovyScriptConfig.compat.draconicEvolutionEnergyCore) { cir.setReturnValue(TileInvisECoreBlockLogic.getUpdatePacket((TileInvisECoreBlock) (Object) this)); diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/AlloyRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/AlloyRecipeManagerAccessor.java index fc189111f..c80810e25 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/AlloyRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/AlloyRecipeManagerAccessor.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.core.mixin.enderio; -import crazypants.enderio.base.recipe.IManyToOneRecipe; -import crazypants.enderio.base.recipe.alloysmelter.AlloyRecipeManager; -import crazypants.enderio.base.recipe.lookup.TriItemLookup; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; +import crazypants.enderio.base.recipe.IManyToOneRecipe; +import crazypants.enderio.base.recipe.alloysmelter.AlloyRecipeManager; +import crazypants.enderio.base.recipe.lookup.TriItemLookup; + @Mixin(value = AlloyRecipeManager.class, remap = false) public interface AlloyRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/AlloyRecipeManagerMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/AlloyRecipeManagerMixin.java index 56d51cbb0..9683d571e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/AlloyRecipeManagerMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/AlloyRecipeManagerMixin.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.core.mixin.enderio; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import crazypants.enderio.base.recipe.IManyToOneRecipe; -import crazypants.enderio.base.recipe.alloysmelter.AlloyRecipeManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; + +import crazypants.enderio.base.recipe.IManyToOneRecipe; +import crazypants.enderio.base.recipe.alloysmelter.AlloyRecipeManager; + @Mixin(value = AlloyRecipeManager.class, remap = false) public class AlloyRecipeManagerMixin { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/FluidFuelRegisterAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/FluidFuelRegisterAccessor.java index 71f9ec662..6cd9da553 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/FluidFuelRegisterAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/FluidFuelRegisterAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.enderio; -import crazypants.enderio.base.fluid.FluidFuelRegister; -import crazypants.enderio.base.fluid.IFluidCoolant; -import crazypants.enderio.base.fluid.IFluidFuel; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import crazypants.enderio.base.fluid.FluidFuelRegister; +import crazypants.enderio.base.fluid.IFluidCoolant; +import crazypants.enderio.base.fluid.IFluidFuel; @Mixin(value = FluidFuelRegister.class, remap = false) public interface FluidFuelRegisterAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/ItemRecipeLeafNodeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/ItemRecipeLeafNodeAccessor.java index 82f2b6270..0a2e04c1f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/ItemRecipeLeafNodeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/ItemRecipeLeafNodeAccessor.java @@ -1,12 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.enderio; +import net.minecraft.item.Item; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + import com.enderio.core.common.util.NNList; + import crazypants.enderio.base.recipe.lookup.IRecipeNode; import crazypants.enderio.base.recipe.lookup.ItemRecipeLeafNode; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import net.minecraft.item.Item; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(value = ItemRecipeLeafNode.class, remap = false) public interface ItemRecipeLeafNodeAccessor extends IRecipeNode { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/ItemRecipeNodeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/ItemRecipeNodeAccessor.java index 05415a6d1..50603410f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/ItemRecipeNodeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/ItemRecipeNodeAccessor.java @@ -1,12 +1,14 @@ package com.cleanroommc.groovyscript.core.mixin.enderio; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + import com.enderio.core.common.util.NNList; + import crazypants.enderio.base.recipe.lookup.IRecipeNode; import crazypants.enderio.base.recipe.lookup.ItemRecipeNode; import crazypants.enderio.util.NNPair; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(value = ItemRecipeNode.class, remap = false) public interface ItemRecipeNodeAccessor> { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/SimpleRecipeGroupHolderAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/SimpleRecipeGroupHolderAccessor.java index 9e2c44057..52ca9f2f8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/SimpleRecipeGroupHolderAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/SimpleRecipeGroupHolderAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.enderio; -import crazypants.enderio.base.recipe.IMachineRecipe; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import crazypants.enderio.base.recipe.IMachineRecipe; @Mixin(targets = "crazypants.enderio.base.recipe.MachineRecipeRegistry$SimpleRecipeGroupHolder", remap = false) public interface SimpleRecipeGroupHolderAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/TriItemLookupAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/TriItemLookupAccessor.java index 8252fbb97..6e11e070c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/TriItemLookupAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/enderio/TriItemLookupAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.enderio; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + import crazypants.enderio.base.recipe.lookup.ItemRecipeLeafNode; import crazypants.enderio.base.recipe.lookup.ItemRecipeNode; import crazypants.enderio.base.recipe.lookup.TriItemLookup; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(value = TriItemLookup.class, remap = false) public interface TriItemLookupAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/OreSmeltingRecipeMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/OreSmeltingRecipeMixin.java index fa96ef1f0..382c09f8c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/OreSmeltingRecipeMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/OreSmeltingRecipeMixin.java @@ -1,26 +1,31 @@ package com.cleanroommc.groovyscript.core.mixin.essentialcraft; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; + import essentialcraft.api.OreSmeltingRecipe; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; @Mixin(value = OreSmeltingRecipe.class, remap = false) public abstract class OreSmeltingRecipeMixin { /** * @reason This mixin fixes a client crash when reloading recipes for Magmatic Smeltery, - * which happens when a deleted Magmatic Ore item is being rendered and the mod cannot determine the Alloy's overlay color. + * which happens when a deleted Magmatic Ore item is being rendered and the mod cannot determine the Alloy's overlay + * color. */ - @WrapOperation(method = "getColorFromItemStack", at = @At(value = "FIELD", target = "Lessentialcraft/api/OreSmeltingRecipe;color:I")) + @WrapOperation(method = "getColorFromItemStack", + at = @At(value = "FIELD", target = "Lessentialcraft/api/OreSmeltingRecipe;color:I")) private static int getColorFromItemStack(OreSmeltingRecipe recipe, Operation original) { if (recipe == null) return 16777215; return original.call(recipe); } - @WrapOperation(method = "getLocalizedOreName", at = @At(value = "FIELD", target = "Lessentialcraft/api/OreSmeltingRecipe;oreName:Ljava/lang/String;")) + @WrapOperation(method = "getLocalizedOreName", + at = @At(value = "FIELD", target = "Lessentialcraft/api/OreSmeltingRecipe;oreName:Ljava/lang/String;")) private static String getLocalizedOreName(OreSmeltingRecipe recipe, Operation original) { if (recipe == null) return ""; return original.call(recipe); diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/TileFurnaceMagicMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/TileFurnaceMagicMixin.java index 0d5f2986f..3ed10c35d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/TileFurnaceMagicMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/TileFurnaceMagicMixin.java @@ -1,16 +1,18 @@ package com.cleanroommc.groovyscript.core.mixin.essentialcraft; -import essentialcraft.api.OreSmeltingRecipe; -import essentialcraft.common.item.ItemsCore; -import essentialcraft.common.tile.TileFurnaceMagic; -import essentialcraft.common.tile.TileMRUGeneric; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import essentialcraft.api.OreSmeltingRecipe; +import essentialcraft.common.item.ItemsCore; +import essentialcraft.common.tile.TileFurnaceMagic; +import essentialcraft.common.tile.TileMRUGeneric; + @Mixin(value = TileFurnaceMagic.class, remap = false) public abstract class TileFurnaceMagicMixin extends TileMRUGeneric { @@ -19,8 +21,10 @@ public abstract class TileFurnaceMagicMixin extends TileMRUGeneric { /** * @reason This mixin fixes a server crash when an invalid Magmatic Ore is put into the Magmatic Furnace's input slot. - * Normally this causes an ArrayOutOfBoundsException when the recipe with index -1 (invalid input) is being read from the registry. - * The indices of its slots are as follows: Bound Gem (0), Ore/Magmatic Alloy input (1), Magmatic Alloy/Resource output (2). + * Normally this causes an ArrayOutOfBoundsException when the recipe with index -1 (invalid input) is being read from + * the registry. + * The indices of its slots are as follows: Bound Gem (0), Ore/Magmatic Alloy input (1), Magmatic Alloy/Resource + * output (2). */ @Inject(method = "update", at = @At("HEAD"), cancellable = true) public void onUpdate(CallbackInfo ci) { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/TileMagmaticSmelterMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/TileMagmaticSmelterMixin.java index 05cc519b2..108570444 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/TileMagmaticSmelterMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/essentialcraft/TileMagmaticSmelterMixin.java @@ -1,16 +1,18 @@ package com.cleanroommc.groovyscript.core.mixin.essentialcraft; -import essentialcraft.api.OreSmeltingRecipe; -import essentialcraft.common.item.ItemsCore; -import essentialcraft.common.tile.TileMRUGeneric; -import essentialcraft.common.tile.TileMagmaticSmelter; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import essentialcraft.api.OreSmeltingRecipe; +import essentialcraft.common.item.ItemsCore; +import essentialcraft.common.tile.TileMRUGeneric; +import essentialcraft.common.tile.TileMagmaticSmelter; + @Mixin(value = TileMagmaticSmelter.class, remap = false) public abstract class TileMagmaticSmelterMixin extends TileMRUGeneric { @@ -19,9 +21,10 @@ public abstract class TileMagmaticSmelterMixin extends TileMRUGeneric { /** * @reason This mixin fixes a server crash when an invalid Magmatic Ore is put into the Magmatic Smeltery's input slot. - * Normally this causes an ArrayOutOfBoundsException when the recipe with index -1 (invalid input) is being read from the registry. - * The indices of its slots are as follows: Bound Gem (0), Lava Bucket (1), Empty Bucket output (2), - * Ore input (3), Magmatic Alloy output (4), Magmatic Alloy input (5), Resource output (6), Magical Slag (7). + * Normally this causes an ArrayOutOfBoundsException when the recipe with index -1 (invalid input) is being read from + * the registry. + * The indices of its slots are as follows: Bound Gem (0), Lava Bucket (1), Empty Bucket output (2), + * Ore input (3), Magmatic Alloy output (4), Magmatic Alloy input (5), Resource output (6), Magical Slag (7). */ @Inject(method = "update", at = @At("HEAD"), cancellable = true) public void onUpdate(CallbackInfo ci) { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/extendedcrafting/ItemRecipeMakerMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/extendedcrafting/ItemRecipeMakerMixin.java index 8d00cf1d0..ffb21349f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/extendedcrafting/ItemRecipeMakerMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/extendedcrafting/ItemRecipeMakerMixin.java @@ -1,24 +1,26 @@ package com.cleanroommc.groovyscript.core.mixin.extendedcrafting; -import com.blakebr0.extendedcrafting.config.ModConfig; -import com.blakebr0.extendedcrafting.item.ItemRecipeMaker; -import com.blakebr0.extendedcrafting.lib.IExtendedTable; -import com.blakebr0.extendedcrafting.tile.TileEnderCrafter; -import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; -import com.google.common.base.Joiner; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.awt.*; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.StringSelection; -import java.util.ArrayList; -import java.util.List; +import com.blakebr0.extendedcrafting.config.ModConfig; +import com.blakebr0.extendedcrafting.item.ItemRecipeMaker; +import com.blakebr0.extendedcrafting.lib.IExtendedTable; +import com.blakebr0.extendedcrafting.tile.TileEnderCrafter; +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; +import com.google.common.base.Joiner; @Mixin(value = ItemRecipeMaker.class, remap = false) public abstract class ItemRecipeMakerMixin { @@ -30,7 +32,8 @@ public abstract class ItemRecipeMakerMixin { public void setClipboard(IExtendedTable table, ItemStack stack, CallbackInfoReturnable cir) { if (Desktop.isDesktopSupported()) { boolean ender = table instanceof TileEnderCrafter; - StringBuilder string = (new StringBuilder("mods.extendedcrafting.")).append(ender ? "EnderCrafting" : "TableCrafting"); + StringBuilder string = (new StringBuilder("mods.extendedcrafting.")).append(ender ? "EnderCrafting" : + "TableCrafting"); String inputs; if (isShapeless(stack)) { inputs = groovyscript$makeItemArrayShapeless(table); @@ -59,8 +62,7 @@ public void setClipboard(IExtendedTable table, ItemStack stack, CallbackInfoRetu boolean isEmpty = true; for (ItemStack stack : table.getMatrix()) { if (!stack.isEmpty()) { - builder.append(groovyscript$makeItem(stack)) - .append(", "); + builder.append(groovyscript$makeItem(stack)).append(", "); isEmpty = false; } } @@ -117,13 +119,9 @@ public void setClipboard(IExtendedTable table, ItemStack stack, CallbackInfoRetu private static String groovyscript$makeItem(ItemStack stack) { if (ModConfig.confRMOredict) { int[] oreIds = OreDictionary.getOreIDs(stack); - if (oreIds.length > 0) { - return IngredientHelper.asGroovyCode(OreDictionary.getOreName(oreIds[0]), false); - } - } - if (ModConfig.confRMNBT) { - return IngredientHelper.asGroovyCode(stack, false, false); + if (oreIds.length > 0) { return IngredientHelper.asGroovyCode(OreDictionary.getOreName(oreIds[0]), false); } } + if (ModConfig.confRMNBT) { return IngredientHelper.asGroovyCode(stack, false, false); } return IngredientHelper.asGroovyCode(stack, false); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/GeneratorTypeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/GeneratorTypeAccessor.java index 83f95d03f..4fb72b881 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/GeneratorTypeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/GeneratorTypeAccessor.java @@ -1,20 +1,21 @@ package com.cleanroommc.groovyscript.core.mixin.extrautils2; -import com.rwtema.extrautils2.blocks.BlockPassiveGenerator; -import com.rwtema.extrautils2.power.IWorldPowerMultiplier; +import java.util.TreeMap; + import net.minecraft.util.ResourceLocation; + import org.apache.commons.lang3.tuple.Pair; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.TreeMap; +import com.rwtema.extrautils2.blocks.BlockPassiveGenerator; +import com.rwtema.extrautils2.power.IWorldPowerMultiplier; @Mixin(value = BlockPassiveGenerator.GeneratorType.class, remap = false) public interface GeneratorTypeAccessor { - @Mutable - @Accessor + @Mutable @Accessor void setPowerMultiplier(IWorldPowerMultiplier powerMultiplier); @Accessor @@ -23,8 +24,7 @@ public interface GeneratorTypeAccessor { @Accessor TreeMap> getCaps(); - @Mutable - @Accessor + @Mutable @Accessor void setCaps(TreeMap> caps); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/GeneratorTypeMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/GeneratorTypeMixin.java index 95bfec445..5a7296fdf 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/GeneratorTypeMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/GeneratorTypeMixin.java @@ -1,8 +1,7 @@ package com.cleanroommc.groovyscript.core.mixin.extrautils2; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.rwtema.extrautils2.blocks.BlockPassiveGenerator; import net.minecraft.util.ResourceLocation; + import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -10,11 +9,13 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.rwtema.extrautils2.blocks.BlockPassiveGenerator; + @Mixin(value = BlockPassiveGenerator.GeneratorType.class, remap = false) public class GeneratorTypeMixin { - @Shadow - @Final + @Shadow @Final ResourceLocation key; @Inject(method = "basePowerGen", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/MachineInitAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/MachineInitAccessor.java index 5a91e2759..d52b9940c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/MachineInitAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/MachineInitAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.extrautils2; -import com.rwtema.extrautils2.api.machine.MachineSlotItem; -import com.rwtema.extrautils2.machine.MachineInit; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import com.rwtema.extrautils2.api.machine.MachineSlotItem; +import com.rwtema.extrautils2.machine.MachineInit; + @Mixin(value = MachineInit.class, remap = false) public interface MachineInitAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/PassiveBlockGeneratorMillMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/PassiveBlockGeneratorMillMixin.java index 184219998..f291d99c9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/PassiveBlockGeneratorMillMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/extrautils2/PassiveBlockGeneratorMillMixin.java @@ -1,26 +1,27 @@ package com.cleanroommc.groovyscript.core.mixin.extrautils2; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import com.rwtema.extrautils2.tile.TilePassiveGenerator; -import groovy.lang.Closure; import net.minecraft.world.World; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(targets = { - "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$1", - "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$2", - "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$3", - "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$4", - "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$5", - "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$6", - "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$7", - "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$8", - "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$9", -}, remap = false) +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.sandbox.ClosureHelper; +import com.rwtema.extrautils2.tile.TilePassiveGenerator; + +import groovy.lang.Closure; + +@Mixin(targets = {"com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$1", + "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$2", + "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$3", + "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$4", + "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$5", + "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$6", + "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$7", + "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$8", + "com/rwtema/extrautils2/blocks/BlockPassiveGenerator$GeneratorType$9",}, remap = false) public class PassiveBlockGeneratorMillMixin { @Inject(method = "basePowerGen", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/AlleleRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/AlleleRegistryAccessor.java index 8d0a96b84..ab4242e7f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/AlleleRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/AlleleRegistryAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.forestry; -import forestry.api.genetics.IAllele; -import forestry.core.genetics.alleles.AlleleRegistry; +import java.util.LinkedHashMap; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.LinkedHashMap; +import forestry.api.genetics.IAllele; +import forestry.core.genetics.alleles.AlleleRegistry; @Mixin(value = AlleleRegistry.class, remap = false) public interface AlleleRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/BeeRootAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/BeeRootAccessor.java index 3cf2599bf..4f5363aa3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/BeeRootAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/BeeRootAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.forestry; -import forestry.api.apiculture.IBeeMutation; -import forestry.apiculture.genetics.BeeRoot; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import forestry.api.apiculture.IBeeMutation; +import forestry.apiculture.genetics.BeeRoot; @Mixin(value = BeeRoot.class, remap = false) public interface BeeRootAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CarpenterRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CarpenterRecipeManagerAccessor.java index 3a3eb96c4..40618de16 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CarpenterRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CarpenterRecipeManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.forestry; -import forestry.api.recipes.ICarpenterRecipe; -import forestry.factory.recipes.CarpenterRecipeManager; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Set; +import forestry.api.recipes.ICarpenterRecipe; +import forestry.factory.recipes.CarpenterRecipeManager; @Mixin(value = CarpenterRecipeManager.class, remap = false) public interface CarpenterRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CentrifugeRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CentrifugeRecipeManagerAccessor.java index d986e36e4..f3ed100c1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CentrifugeRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CentrifugeRecipeManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.forestry; -import forestry.api.recipes.ICentrifugeRecipe; -import forestry.factory.recipes.CentrifugeRecipeManager; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Set; +import forestry.api.recipes.ICentrifugeRecipe; +import forestry.factory.recipes.CentrifugeRecipeManager; @Mixin(value = CentrifugeRecipeManager.class, remap = false) public interface CentrifugeRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CharcoalManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CharcoalManagerAccessor.java index b5456e900..ecda99377 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CharcoalManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/CharcoalManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.forestry; -import forestry.api.arboriculture.ICharcoalPileWall; -import forestry.arboriculture.charcoal.CharcoalManager; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import forestry.api.arboriculture.ICharcoalPileWall; +import forestry.arboriculture.charcoal.CharcoalManager; @Mixin(value = CharcoalManager.class, remap = false) public interface CharcoalManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/FabricatorRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/FabricatorRecipeManagerAccessor.java index 9be36f828..c430ba292 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/FabricatorRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/FabricatorRecipeManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.forestry; -import forestry.api.recipes.IFabricatorRecipe; -import forestry.factory.recipes.FabricatorRecipeManager; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Set; +import forestry.api.recipes.IFabricatorRecipe; +import forestry.factory.recipes.FabricatorRecipeManager; @Mixin(value = FabricatorRecipeManager.class, remap = false) public interface FabricatorRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/FermenterRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/FermenterRecipeManagerAccessor.java index 354a67daa..41bd5770d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/FermenterRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/FermenterRecipeManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.forestry; -import forestry.api.recipes.IFermenterRecipe; -import forestry.factory.recipes.FermenterRecipeManager; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Set; +import forestry.api.recipes.IFermenterRecipe; +import forestry.factory.recipes.FermenterRecipeManager; @Mixin(value = FermenterRecipeManager.class, remap = false) public interface FermenterRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/MoistenerRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/MoistenerRecipeManagerAccessor.java index ad6396f64..183742132 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/MoistenerRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/MoistenerRecipeManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.forestry; -import forestry.api.recipes.IMoistenerRecipe; -import forestry.factory.recipes.MoistenerRecipeManager; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Set; +import forestry.api.recipes.IMoistenerRecipe; +import forestry.factory.recipes.MoistenerRecipeManager; @Mixin(value = MoistenerRecipeManager.class, remap = false) public interface MoistenerRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/SqueezerRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/SqueezerRecipeManagerAccessor.java index 23affa82b..c51be87f9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/SqueezerRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/SqueezerRecipeManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.forestry; -import forestry.api.recipes.ISqueezerRecipe; -import forestry.factory.recipes.SqueezerRecipeManager; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Set; +import forestry.api.recipes.ISqueezerRecipe; +import forestry.factory.recipes.SqueezerRecipeManager; @Mixin(value = SqueezerRecipeManager.class, remap = false) public interface SqueezerRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/StillRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/StillRecipeManagerAccessor.java index 3c74c620a..f13f71da1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/StillRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/forestry/StillRecipeManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.forestry; -import forestry.api.recipes.IStillRecipe; -import forestry.factory.recipes.StillRecipeManager; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Set; +import forestry.api.recipes.IStillRecipe; +import forestry.factory.recipes.StillRecipeManager; @Mixin(value = StillRecipeManager.class, remap = false) public interface StillRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/AsmDecompilerMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/AsmDecompilerMixin.java index 23cfea5b7..2a1c2d399 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/AsmDecompilerMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/AsmDecompilerMixin.java @@ -1,7 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.groovy; -import com.cleanroommc.groovyscript.sandbox.transformer.AsmDecompileHelper; -import groovy.lang.GroovyRuntimeException; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.ref.SoftReference; +import java.lang.reflect.InvocationTargetException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Map; + import org.codehaus.groovy.ast.decompiled.AsmDecompiler; import org.codehaus.groovy.ast.decompiled.ClassStub; import org.codehaus.groovy.util.URLStreams; @@ -15,21 +23,14 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.ref.SoftReference; -import java.lang.reflect.InvocationTargetException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Map; +import com.cleanroommc.groovyscript.sandbox.transformer.AsmDecompileHelper; + +import groovy.lang.GroovyRuntimeException; @Mixin(value = AsmDecompiler.class, remap = false) public class AsmDecompilerMixin { - @Shadow - @Final + @Shadow @Final private static Map> stubCache; @Inject(method = "parseClass", at = @At("HEAD"), cancellable = true) @@ -61,13 +62,8 @@ private static void parseClass(URL url, CallbackInfoReturnable cir) { classReader2.accept(decompiler, ClassReader.SKIP_FRAMES); stub = AsmDecompileHelper.getDecompiledClass(decompiler); stubCache.put(uri, new SoftReference<>(stub)); - } catch (IOException | - ClassNotFoundException | - NoSuchFieldException | - NoSuchMethodException | - IllegalAccessException | - InvocationTargetException | - InstantiationException e) { + } catch (IOException | ClassNotFoundException | NoSuchFieldException | NoSuchMethodException | + IllegalAccessException | InvocationTargetException | InstantiationException e) { throw new RuntimeException(e); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ClassCollectorMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ClassCollectorMixin.java index 6d2757f76..55ee4551f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ClassCollectorMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ClassCollectorMixin.java @@ -1,7 +1,5 @@ package com.cleanroommc.groovyscript.core.mixin.groovy; -import com.cleanroommc.groovyscript.GroovyScript; -import groovy.lang.GroovyClassLoader; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.control.SourceUnit; import org.spongepowered.asm.mixin.Final; @@ -11,11 +9,14 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.cleanroommc.groovyscript.GroovyScript; + +import groovy.lang.GroovyClassLoader; + @Mixin(value = GroovyClassLoader.ClassCollector.class, remap = false) public class ClassCollectorMixin { - @Shadow - @Final + @Shadow @Final private SourceUnit su; @Inject(method = "createClass", at = @At("RETURN")) diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ClosureMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ClosureMixin.java index ef419ae6e..9e09c7dfe 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ClosureMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ClosureMixin.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.groovy; -import com.cleanroommc.groovyscript.GroovyScript; -import groovy.lang.Closure; -import groovy.lang.GroovyObjectSupport; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import com.cleanroommc.groovyscript.GroovyScript; + +import groovy.lang.Closure; +import groovy.lang.GroovyObjectSupport; + @Mixin(value = Closure.class, remap = false) public abstract class ClosureMixin extends GroovyObjectSupport { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/CompUnitClassGenMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/CompUnitClassGenMixin.java index 783ead055..991674597 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/CompUnitClassGenMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/CompUnitClassGenMixin.java @@ -1,6 +1,5 @@ package com.cleanroommc.groovyscript.core.mixin.groovy; -import com.cleanroommc.groovyscript.sandbox.transformer.GroovyCodeFactory; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.GroovyClassVisitor; import org.codehaus.groovy.classgen.GeneratorContext; @@ -12,8 +11,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -@Pseudo -@Mixin(targets = "org/codehaus/groovy/control/CompilationUnit$3", remap = false) +import com.cleanroommc.groovyscript.sandbox.transformer.GroovyCodeFactory; + +@Pseudo @Mixin(targets = "org/codehaus/groovy/control/CompilationUnit$3", remap = false) public class CompUnitClassGenMixin { @Inject(method = "call", @@ -21,7 +21,8 @@ public class CompUnitClassGenMixin { target = "Lorg/codehaus/groovy/ast/GroovyClassVisitor;visitClass(Lorg/codehaus/groovy/ast/ClassNode;)V", ordinal = 4), locals = LocalCapture.CAPTURE_FAILEXCEPTION) - public void call(SourceUnit source, GeneratorContext context, ClassNode classNode, CallbackInfo ci, GroovyClassVisitor visitor) { + public void call(SourceUnit source, GeneratorContext context, ClassNode classNode, CallbackInfo ci, + GroovyClassVisitor visitor) { GroovyCodeFactory.remapOverrides(classNode); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/GroovyClassLoaderMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/GroovyClassLoaderMixin.java index bc4a878a6..52f7568d9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/GroovyClassLoaderMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/GroovyClassLoaderMixin.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.groovy; -import com.cleanroommc.groovyscript.GroovyScript; -import groovy.lang.GroovyClassLoader; +import java.net.URL; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.net.URL; +import com.cleanroommc.groovyscript.GroovyScript; + +import groovy.lang.GroovyClassLoader; /** * If a script depends on another script and the there is a compiled cache for the script, it needs to be loaded manually. diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/Java8Mixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/Java8Mixin.java index 15f631f84..31d385a74 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/Java8Mixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/Java8Mixin.java @@ -1,9 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.groovy; -import com.cleanroommc.groovyscript.sandbox.mapper.GroovyDeobfMapper; +import java.lang.annotation.Annotation; +import java.lang.reflect.*; +import java.util.Map; + import net.minecraftforge.fml.relauncher.FMLLaunchHandler; -import org.codehaus.groovy.ast.Parameter; + import org.codehaus.groovy.ast.*; +import org.codehaus.groovy.ast.Parameter; import org.codehaus.groovy.ast.expr.ConstantExpression; import org.codehaus.groovy.ast.stmt.ReturnStatement; import org.codehaus.groovy.vmplugin.v8.Java8; @@ -11,9 +15,7 @@ import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import java.lang.annotation.Annotation; -import java.lang.reflect.*; -import java.util.Map; +import com.cleanroommc.groovyscript.sandbox.mapper.GroovyDeobfMapper; @Mixin(value = Java8.class, remap = false) public abstract class Java8Mixin { @@ -25,7 +27,8 @@ public abstract class Java8Mixin { protected abstract void setAnnotationMetaData(Annotation[] annotations, AnnotatedNode target); @Shadow - protected abstract Parameter[] makeParameters(CompileUnit cu, Type[] types, Class[] cls, Annotation[][] parameterAnnotations, Member member); + protected abstract Parameter[] makeParameters(CompileUnit cu, Type[] types, Class[] cls, + Annotation[][] parameterAnnotations, Member member); @Shadow protected abstract ClassNode[] makeClassNodes(CompileUnit cu, Type[] types, Class[] cls); @@ -53,7 +56,8 @@ public abstract class Java8Mixin { public void configureClassNode(final CompileUnit compileUnit, final ClassNode classNode) { try { Class clazz = classNode.getTypeClass(); - Map deobfFields = FMLLaunchHandler.isDeobfuscatedEnvironment() ? null : GroovyDeobfMapper.getDeobfFields(clazz); + Map deobfFields = FMLLaunchHandler.isDeobfuscatedEnvironment() ? null : GroovyDeobfMapper + .getDeobfFields(clazz); Field[] fields = clazz.getDeclaredFields(); for (Field f : fields) { ClassNode ret = makeClassNode(compileUnit, f.getGenericType(), f.getType()); @@ -62,11 +66,14 @@ public void configureClassNode(final CompileUnit compileUnit, final ClassNode cl setAnnotationMetaData(f.getAnnotations(), fn); classNode.addField(fn); } - Map deobfMethods = FMLLaunchHandler.isDeobfuscatedEnvironment() ? null : GroovyDeobfMapper.getDeobfMethods(clazz); + Map deobfMethods = FMLLaunchHandler.isDeobfuscatedEnvironment() ? null : GroovyDeobfMapper + .getDeobfMethods(clazz); Method[] methods = clazz.getDeclaredMethods(); for (Method m : methods) { ClassNode ret = makeClassNode(compileUnit, m.getGenericReturnType(), m.getReturnType()); - Parameter[] params = makeParameters(compileUnit, m.getGenericParameterTypes(), m.getParameterTypes(), m.getParameterAnnotations(), m); + Parameter[] params = makeParameters(compileUnit, m.getGenericParameterTypes(), m.getParameterTypes(), m + .getParameterAnnotations(), + m); ClassNode[] exceptions = makeClassNodes(compileUnit, m.getGenericExceptionTypes(), m.getExceptionTypes()); String name = deobfMethods != null ? deobfMethods.getOrDefault(m.getName(), m.getName()) : m.getName(); MethodNode mn = new MethodNode(name, m.getModifiers(), ret, params, exceptions, null); @@ -81,7 +88,8 @@ public void configureClassNode(final CompileUnit compileUnit, final ClassNode cl } Constructor[] constructors = clazz.getDeclaredConstructors(); for (Constructor ctor : constructors) { - Parameter[] params = makeParameters(compileUnit, ctor.getGenericParameterTypes(), ctor.getParameterTypes(), getConstructorParameterAnnotations(ctor), ctor); + Parameter[] params = makeParameters(compileUnit, ctor.getGenericParameterTypes(), ctor.getParameterTypes(), + getConstructorParameterAnnotations(ctor), ctor); ClassNode[] exceptions = makeClassNodes(compileUnit, ctor.getGenericExceptionTypes(), ctor.getExceptionTypes()); ConstructorNode cn = classNode.addConstructor(ctor.getModifiers(), params, exceptions, null); setAnnotationMetaData(ctor.getAnnotations(), cn); @@ -99,9 +107,11 @@ public void configureClassNode(final CompileUnit compileUnit, final ClassNode cl setAnnotationMetaData(clazz.getPackage().getAnnotations(), packageNode); } } catch (NoClassDefFoundError e) { - throw new NoClassDefFoundError("Unable to load class " + classNode.toString(false) + " due to missing dependency " + e.getMessage()); + throw new NoClassDefFoundError("Unable to load class " + classNode.toString(false) + " due to missing dependency " + e + .getMessage()); } catch (MalformedParameterizedTypeException e) { - throw new RuntimeException("Unable to configure class node for class " + classNode.toString(false) + " due to malformed parameterized types", e); + throw new RuntimeException("Unable to configure class node for class " + classNode.toString(false) + + " due to malformed parameterized types", e); } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/MetaClassImplMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/MetaClassImplMixin.java index d89a43bfd..70699b854 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/MetaClassImplMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/MetaClassImplMixin.java @@ -1,33 +1,36 @@ package com.cleanroommc.groovyscript.core.mixin.groovy; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.IDynamicGroovyProperty; -import com.cleanroommc.groovyscript.sandbox.security.GroovySecurityManager; -import groovy.lang.*; +import java.util.Arrays; +import java.util.Map; + import org.codehaus.groovy.reflection.CachedClass; import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; -import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.Arrays; -import java.util.Map; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.IDynamicGroovyProperty; +import com.cleanroommc.groovyscript.sandbox.security.GroovySecurityManager; + +import groovy.lang.*; @Mixin(value = MetaClassImpl.class, remap = false) public abstract class MetaClassImplMixin { @Shadow - protected abstract Object doInvokeMethod(Class sender, Object object, String methodName, Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass); + protected abstract Object doInvokeMethod(Class sender, Object object, String methodName, Object[] originalArguments, + boolean isCallToSuper, boolean fromInsideClass); @Shadow protected MetaClassRegistry registry; @Shadow - protected abstract Object invokeMissingMethod(Object instance, String methodName, Object[] arguments, RuntimeException original, boolean isCallToSuper); + protected abstract Object invokeMissingMethod(Object instance, String methodName, Object[] arguments, + RuntimeException original, boolean isCallToSuper); @Shadow protected abstract MetaProperty getMetaProperty(String name, boolean useStatic); @@ -38,14 +41,10 @@ public abstract class MetaClassImplMixin { @Shadow public abstract CachedClass getTheCachedClass(); - @Mutable - @Shadow - @Final + @Mutable @Shadow @Final private MetaMethod[] myNewMetaMethods; - @Mutable - @Shadow - @Final + @Mutable @Shadow @Final private MetaMethod[] additionalMetaMethods; @Inject(method = "(Ljava/lang/Class;[Lgroovy/lang/MetaMethod;)V", at = @At("TAIL")) @@ -76,8 +75,11 @@ public void removeBlacklistedAdditional(Class theClass, MetaMethod[] add, Cal } } - @Inject(method = "invokeMethod(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;ZZ)Ljava/lang/Object;", at = @At("HEAD"), cancellable = true) - public void invokeMethod(Class sender, Object object, String methodName, Object[] arguments, boolean isCallToSuper, boolean fromInsideClass, CallbackInfoReturnable cir) { + @Inject(method = "invokeMethod(Ljava/lang/Class;Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;ZZ)Ljava/lang/Object;", + at = @At("HEAD"), + cancellable = true) + public void invokeMethod(Class sender, Object object, String methodName, Object[] arguments, boolean isCallToSuper, + boolean fromInsideClass, CallbackInfoReturnable cir) { try { cir.setReturnValue(doInvokeMethod(sender, object, methodName, arguments, isCallToSuper, fromInsideClass)); } catch (MissingMethodException mme) { @@ -86,7 +88,8 @@ public void invokeMethod(Class sender, Object object, String methodName, Obje } @Inject(method = "invokeMissingProperty", at = @At("HEAD"), cancellable = true) - public void invokeMissingProperty(Object instance, String propertyName, Object optionalValue, boolean isGetter, CallbackInfoReturnable cir) { + public void invokeMissingProperty(Object instance, String propertyName, Object optionalValue, boolean isGetter, + CallbackInfoReturnable cir) { if (instance instanceof IDynamicGroovyProperty) { if (isGetter) { Object prop = ((IDynamicGroovyProperty) instance).getProperty(propertyName); @@ -100,14 +103,16 @@ public void invokeMissingProperty(Object instance, String propertyName, Object o } @Inject(method = "invokeStaticMissingMethod", at = @At("HEAD"), cancellable = true) - public void invokeStaticMissingMethod(Class sender, String methodName, Object[] arguments, CallbackInfoReturnable cir) { + public void invokeStaticMissingMethod(Class sender, String methodName, Object[] arguments, + CallbackInfoReturnable cir) { if (sender.getSuperclass() != Script.class && "main".equals(methodName)) { cir.setReturnValue(null); } } @Inject(method = "invokeStaticMissingProperty", at = @At("HEAD"), cancellable = true) - public void invokeStaticMissingProperty(Object instance, String propertyName, Object optionalValue, boolean isGetter, CallbackInfoReturnable cir) { + public void invokeStaticMissingProperty(Object instance, String propertyName, Object optionalValue, boolean isGetter, + CallbackInfoReturnable cir) { if (!isGetter) return; Object o = GroovyScript.getSandbox().getBindings().get(propertyName); if (o != null) cir.setReturnValue(o); @@ -118,8 +123,8 @@ public void invokeStaticMissingProperty(Object instance, String propertyName, Ob * @reason class scripts being unable to use bindings and this method calling closures improperly */ @Overwrite - private Object invokePropertyOrMissing(Object object, String methodName, Object[] originalArguments, - boolean fromInsideClass, boolean isCallToSuper) { + private Object invokePropertyOrMissing(Object object, String methodName, Object[] originalArguments, boolean fromInsideClass, + boolean isCallToSuper) { MetaProperty metaProperty = getMetaProperty(methodName, false); Object value = null; diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ModuleNodeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ModuleNodeAccessor.java index 0edf62b45..ffdeb4c21 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ModuleNodeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/groovy/ModuleNodeAccessor.java @@ -1,12 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.groovy; +import java.util.List; + import org.codehaus.groovy.ast.ImportNode; import org.codehaus.groovy.ast.ModuleNode; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; - @Mixin(value = ModuleNode.class, remap = false) public interface ModuleNodeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ClassicCanningMachineRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ClassicCanningMachineRegistryAccessor.java index 73863a858..c7f6ce61e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ClassicCanningMachineRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ClassicCanningMachineRegistryAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.ic2; -import ic2.core.block.machine.recipes.managers.CanningMachineRegistry; -import ic2.core.util.helpers.ItemWithMeta; +import java.util.List; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; -import java.util.Map; +import ic2.core.block.machine.recipes.managers.CanningMachineRegistry; +import ic2.core.util.helpers.ItemWithMeta; @Mixin(value = CanningMachineRegistry.class, remap = false) public interface ClassicCanningMachineRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ElectrolyzerRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ElectrolyzerRecipeManagerAccessor.java index 2bef79e90..6e57147ef 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ElectrolyzerRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ElectrolyzerRecipeManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.ic2; -import ic2.api.recipe.IElectrolyzerRecipeManager; -import ic2.core.recipe.ElectrolyzerRecipeManager; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import ic2.api.recipe.IElectrolyzerRecipeManager; +import ic2.core.recipe.ElectrolyzerRecipeManager; @Mixin(value = ElectrolyzerRecipeManager.class, remap = false) public interface ElectrolyzerRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/FermenterRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/FermenterRecipeManagerAccessor.java index 1feab7e0a..25d5a2364 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/FermenterRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/FermenterRecipeManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.ic2; -import ic2.api.recipe.IFermenterRecipeManager; -import ic2.core.recipe.FermenterRecipeManager; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import ic2.api.recipe.IFermenterRecipeManager; +import ic2.core.recipe.FermenterRecipeManager; @Mixin(value = FermenterRecipeManager.class, remap = false) public interface FermenterRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ScrapboxRecipeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ScrapboxRecipeManagerAccessor.java index 3272f8741..633036618 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ScrapboxRecipeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/ScrapboxRecipeManagerAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.ic2; -import ic2.core.recipe.ScrapboxRecipeManager; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import ic2.core.recipe.ScrapboxRecipeManager; @Mixin(value = ScrapboxRecipeManager.class, remap = false) public interface ScrapboxRecipeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/SemiFluidFuelManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/SemiFluidFuelManagerAccessor.java index 1d946e901..f4ee528ce 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/SemiFluidFuelManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/ic2/SemiFluidFuelManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.ic2; -import ic2.api.recipe.ISemiFluidFuelManager; -import ic2.core.SemiFluidFuelManager; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import ic2.api.recipe.ISemiFluidFuelManager; +import ic2.core.SemiFluidFuelManager; @Mixin(value = SemiFluidFuelManager.class, remap = false) public interface SemiFluidFuelManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/industrialforegoing/SludgeRefinerBlockAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/industrialforegoing/SludgeRefinerBlockAccessor.java index e2b4c65d9..0f0773ab6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/industrialforegoing/SludgeRefinerBlockAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/industrialforegoing/SludgeRefinerBlockAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.industrialforegoing; -import com.buuz135.industrial.tile.block.SludgeRefinerBlock; -import com.buuz135.industrial.utils.ItemStackWeightedItem; +import java.util.ArrayList; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.ArrayList; +import com.buuz135.industrial.tile.block.SludgeRefinerBlock; +import com.buuz135.industrial.utils.ItemStackWeightedItem; @Mixin(value = SludgeRefinerBlock.class, remap = false) public interface SludgeRefinerBlockAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/inspirations/InspirationsRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/inspirations/InspirationsRegistryAccessor.java index eec974500..18d46035f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/inspirations/InspirationsRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/inspirations/InspirationsRegistryAccessor.java @@ -1,16 +1,18 @@ package com.cleanroommc.groovyscript.core.mixin.inspirations; -import knightminer.inspirations.library.InspirationsRegistry; -import knightminer.inspirations.library.recipe.cauldron.ICauldronRecipe; +import java.util.List; +import java.util.Map; +import java.util.Set; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; -import java.util.Map; -import java.util.Set; +import knightminer.inspirations.library.InspirationsRegistry; +import knightminer.inspirations.library.recipe.cauldron.ICauldronRecipe; @Mixin(value = InspirationsRegistry.class, remap = false) public interface InspirationsRegistryAccessor { @@ -36,4 +38,3 @@ static List getCauldronRecipes() { } } - diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/IngredientInfoRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/IngredientInfoRecipeAccessor.java index 0a7a3cb7b..9dabdab31 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/IngredientInfoRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/IngredientInfoRecipeAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.jei; -import mezz.jei.api.recipe.IIngredientType; -import mezz.jei.plugins.jei.info.IngredientInfoRecipe; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import mezz.jei.api.recipe.IIngredientType; +import mezz.jei.plugins.jei.info.IngredientInfoRecipe; @Mixin(value = IngredientInfoRecipe.class, remap = false) public interface IngredientInfoRecipeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/JeiProxyAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/JeiProxyAccessor.java index 97d1398a2..3f75cfce3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/JeiProxyAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/JeiProxyAccessor.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.core.mixin.jei; +import java.util.List; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + import mezz.jei.api.IModPlugin; import mezz.jei.gui.textures.Textures; import mezz.jei.startup.JeiStarter; import mezz.jei.startup.ProxyCommonClient; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.List; @Mixin(value = ProxyCommonClient.class, remap = false) public interface JeiProxyAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/ModRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/ModRegistryAccessor.java index dcf560a5a..0a9241329 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/ModRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/jei/ModRegistryAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.jei; -import mezz.jei.collect.ListMultiMap; -import mezz.jei.startup.ModRegistry; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import mezz.jei.collect.ListMultiMap; +import mezz.jei.startup.ModRegistry; + @Mixin(value = ModRegistry.class, remap = false) public interface ModRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LoadTableEventMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LoadTableEventMixin.java index 4cbc8270f..514141c94 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LoadTableEventMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LoadTableEventMixin.java @@ -1,12 +1,10 @@ package com.cleanroommc.groovyscript.core.mixin.loot; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; -import com.cleanroommc.groovyscript.event.LootTablesLoadedEvent; -import com.google.common.cache.LoadingCache; import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.LootTable; import net.minecraft.world.storage.loot.LootTableManager; import net.minecraftforge.common.MinecraftForge; + import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -14,11 +12,14 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; +import com.cleanroommc.groovyscript.event.LootTablesLoadedEvent; +import com.google.common.cache.LoadingCache; + @Mixin(value = LootTableManager.class) public abstract class LoadTableEventMixin { - @Shadow - @Final + @Shadow @Final private LoadingCache registeredLootTables; @Inject(method = "reloadLootTables", at = @At("RETURN")) diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootPoolAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootPoolAccessor.java index ef91493a3..eaf26f3cb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootPoolAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootPoolAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.loot; +import java.util.List; + import net.minecraft.world.storage.loot.LootEntry; import net.minecraft.world.storage.loot.LootPool; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; - @Mixin(value = LootPool.class) public interface LootPoolAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootTableAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootTableAccessor.java index b25ec5f7b..a89a1ca4f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootTableAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootTableAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.loot; +import java.util.List; + import net.minecraft.world.storage.loot.LootPool; import net.minecraft.world.storage.loot.LootTable; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; - @Mixin(LootTable.class) public interface LootTableAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootTableMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootTableMixin.java index 68e5fdaf3..a794ac836 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootTableMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/loot/LootTableMixin.java @@ -1,6 +1,7 @@ package com.cleanroommc.groovyscript.core.mixin.loot; import net.minecraft.world.storage.loot.LootTable; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/mekanism/GasStackMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/mekanism/GasStackMixin.java index 0a65a1463..547f047b7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/mekanism/GasStackMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/mekanism/GasStackMixin.java @@ -1,13 +1,16 @@ package com.cleanroommc.groovyscript.core.mixin.mekanism; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.api.IResourceStack; -import mekanism.api.gas.GasStack; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.IResourceStack; + +import mekanism.api.gas.GasStack; + @Mixin(value = GasStack.class, remap = false) public abstract class GasStackMixin implements IIngredient, IResourceStack { @@ -18,14 +21,10 @@ public abstract class GasStackMixin implements IIngredient, IResourceStack { public abstract GasStack copy(); @Override - public int getAmount() { - return amount; - } + public int getAmount() { return amount; } @Override - public void setAmount(int amount) { - this.amount = amount; - } + public void setAmount(int amount) { this.amount = amount; } @Override public IIngredient exactCopy() { @@ -38,9 +37,7 @@ public Ingredient toMcIngredient() { } @Override - public ItemStack[] getMatchingStacks() { - return new ItemStack[0]; - } + public ItemStack[] getMatchingStacks() { return new ItemStack[0]; } @Override public boolean test(ItemStack stack) { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/pneumaticcraft/PlasticMixerRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/pneumaticcraft/PlasticMixerRecipeAccessor.java index f109549c7..17ad5de92 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/pneumaticcraft/PlasticMixerRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/pneumaticcraft/PlasticMixerRecipeAccessor.java @@ -1,16 +1,20 @@ package com.cleanroommc.groovyscript.core.mixin.pneumaticcraft; -import me.desht.pneumaticcraft.common.recipes.PlasticMixerRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import me.desht.pneumaticcraft.common.recipes.PlasticMixerRegistry; + @Mixin(value = PlasticMixerRegistry.PlasticMixerRecipe.class, remap = false) public interface PlasticMixerRecipeAccessor { @Invoker("") - static PlasticMixerRegistry.PlasticMixerRecipe createPlasticMixerRecipe(FluidStack fluidStack, ItemStack itemStack, int temperature, boolean allowMelting, boolean allowSolidifying, boolean useDye, int meta) { + static PlasticMixerRegistry.PlasticMixerRecipe createPlasticMixerRecipe(FluidStack fluidStack, ItemStack itemStack, + int temperature, boolean allowMelting, + boolean allowSolidifying, boolean useDye, int meta) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/pneumaticcraft/PlasticMixerRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/pneumaticcraft/PlasticMixerRegistryAccessor.java index c7f8fec14..a0c0ffab3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/pneumaticcraft/PlasticMixerRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/pneumaticcraft/PlasticMixerRegistryAccessor.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.pneumaticcraft; -import me.desht.pneumaticcraft.common.recipes.PlasticMixerRegistry; +import java.util.List; +import java.util.Map; +import java.util.Set; + import net.minecraft.item.Item; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; -import java.util.Map; -import java.util.Set; +import me.desht.pneumaticcraft.common.recipes.PlasticMixerRegistry; @Mixin(value = PlasticMixerRegistry.class, remap = false) public interface PlasticMixerRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/projecte/WorldHelperAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/projecte/WorldHelperAccessor.java index 7a24460b6..995c7b1c0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/projecte/WorldHelperAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/projecte/WorldHelperAccessor.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.projecte; -import moze_intel.projecte.utils.WorldHelper; +import java.util.List; + import net.minecraft.entity.EntityLiving; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import moze_intel.projecte.utils.WorldHelper; @Mixin(value = WorldHelper.class, remap = false) public interface WorldHelperAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/pyrotech/RegistryInitializerMixin.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/pyrotech/RegistryInitializerMixin.java index 61410b580..f30b94d79 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/pyrotech/RegistryInitializerMixin.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/pyrotech/RegistryInitializerMixin.java @@ -1,17 +1,21 @@ package com.cleanroommc.groovyscript.core.mixin.pyrotech; -import com.codetaylor.mc.pyrotech.modules.tech.basic.init.RegistryInitializer; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.RegistryBuilder; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; +import com.codetaylor.mc.pyrotech.modules.tech.basic.init.RegistryInitializer; + @Mixin(value = RegistryInitializer.class, remap = false) public class RegistryInitializerMixin { - @Redirect(method = "createRegistries", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/registries/RegistryBuilder;create()Lnet/minecraftforge/registries/IForgeRegistry;")) + @Redirect(method = "createRegistries", + at = @At(value = "INVOKE", + target = "Lnet/minecraftforge/registries/RegistryBuilder;create()Lnet/minecraftforge/registries/IForgeRegistry;")) private static > IForgeRegistry createRegistries(RegistryBuilder instance) { return instance.disableSaving().create(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModRecipesAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModRecipesAccessor.java index cb8c9f5ea..dfa9f0577 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModRecipesAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModRecipesAccessor.java @@ -1,17 +1,19 @@ package com.cleanroommc.groovyscript.core.mixin.roots; -import epicsquid.roots.init.ModRecipes; -import epicsquid.roots.recipe.ChrysopoeiaRecipe; -import epicsquid.roots.recipe.MortarRecipe; -import epicsquid.roots.recipe.SummonCreatureRecipe; -import epicsquid.roots.recipe.TransmutationRecipe; +import java.util.Map; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import epicsquid.roots.init.ModRecipes; +import epicsquid.roots.recipe.ChrysopoeiaRecipe; +import epicsquid.roots.recipe.MortarRecipe; +import epicsquid.roots.recipe.SummonCreatureRecipe; +import epicsquid.roots.recipe.TransmutationRecipe; @Mixin(value = ModRecipes.class, remap = false) public interface ModRecipesAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModifierAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModifierAccessor.java index 66c28ab49..e25285a1b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModifierAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModifierAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.roots; -import epicsquid.roots.modifiers.CostType; -import epicsquid.roots.modifiers.IModifierCost; -import epicsquid.roots.modifiers.Modifier; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import epicsquid.roots.modifiers.CostType; +import epicsquid.roots.modifiers.IModifierCost; +import epicsquid.roots.modifiers.Modifier; @Mixin(value = Modifier.class, remap = false) public interface ModifierAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModifierRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModifierRegistryAccessor.java index 3506867ed..bbba1bdcf 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModifierRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/ModifierRegistryAccessor.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.roots; -import epicsquid.roots.modifiers.ModifierRegistry; +import java.util.Set; + import net.minecraft.util.ResourceLocation; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Set; +import epicsquid.roots.modifiers.ModifierRegistry; @Mixin(value = ModifierRegistry.class, remap = false) public interface ModifierRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/MossConfigAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/MossConfigAccessor.java index 1e638ae9f..11a97c0f2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/MossConfigAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/MossConfigAccessor.java @@ -1,14 +1,17 @@ package com.cleanroommc.groovyscript.core.mixin.roots; -import com.google.common.collect.BiMap; -import epicsquid.roots.config.MossConfig; +import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import com.google.common.collect.BiMap; + +import epicsquid.roots.config.MossConfig; @Mixin(value = MossConfig.class, remap = false) public interface MossConfigAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/PacifistEntryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/PacifistEntryAccessor.java index c9da5c4bf..a07038e24 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/PacifistEntryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/PacifistEntryAccessor.java @@ -1,10 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.roots; -import epicsquid.roots.recipe.PacifistEntry; import net.minecraft.util.ResourceLocation; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import epicsquid.roots.recipe.PacifistEntry; + @Mixin(value = PacifistEntry.class, remap = false) public interface PacifistEntryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/RitualBaseAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/RitualBaseAccessor.java index 577628357..846216578 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/RitualBaseAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/roots/RitualBaseAccessor.java @@ -1,9 +1,10 @@ package com.cleanroommc.groovyscript.core.mixin.roots; -import epicsquid.roots.ritual.RitualBase; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import epicsquid.roots.ritual.RitualBase; + @Mixin(value = RitualBase.class, remap = false) public interface RitualBaseAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/MixRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/MixRecipeAccessor.java index a59b0c3b6..4879e2202 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/MixRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/MixRecipeAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.tcomplement; -import knightminer.tcomplement.library.steelworks.MixAdditive; -import knightminer.tcomplement.library.steelworks.MixRecipe; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import slimeknights.mantle.util.RecipeMatchRegistry; -import java.util.Map; +import knightminer.tcomplement.library.steelworks.MixAdditive; +import knightminer.tcomplement.library.steelworks.MixRecipe; +import slimeknights.mantle.util.RecipeMatchRegistry; @Mixin(value = MixRecipe.class, remap = false) public interface MixRecipeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/RecipeMatchRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/RecipeMatchRegistryAccessor.java index 85c269c84..d739db61b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/RecipeMatchRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/RecipeMatchRegistryAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.tcomplement; +import java.util.PriorityQueue; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; + import slimeknights.mantle.util.RecipeMatch; import slimeknights.mantle.util.RecipeMatchRegistry; -import java.util.PriorityQueue; - @Mixin(value = RecipeMatchRegistry.class, remap = false) public interface RecipeMatchRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/TCompRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/TCompRegistryAccessor.java index cab785ddb..9c517a1b1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/TCompRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tcomplement/TCompRegistryAccessor.java @@ -1,19 +1,20 @@ package com.cleanroommc.groovyscript.core.mixin.tcomplement; +import java.util.List; +import java.util.Map; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + import knightminer.tcomplement.library.IBlacklist; import knightminer.tcomplement.library.TCompRegistry; import knightminer.tcomplement.library.steelworks.HighOvenFuel; import knightminer.tcomplement.library.steelworks.IHeatRecipe; import knightminer.tcomplement.library.steelworks.IMixRecipe; import knightminer.tcomplement.library.steelworks.MixAdditive; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; import slimeknights.mantle.util.RecipeMatchRegistry; import slimeknights.tconstruct.library.smeltery.MeltingRecipe; -import java.util.List; -import java.util.Map; - @Mixin(value = TCompRegistry.class, remap = false) public interface TCompRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/MaterialAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/MaterialAccessor.java index 77b67368f..a3038d7d1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/MaterialAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/MaterialAccessor.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.core.mixin.tconstruct; +import java.util.List; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; + import slimeknights.tconstruct.library.materials.Material; import slimeknights.tconstruct.library.traits.ITrait; -import java.util.List; -import java.util.Map; - @Mixin(value = Material.class, remap = false) public interface MaterialAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/MeltingRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/MeltingRecipeAccessor.java index ed15f8e10..e494840aa 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/MeltingRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/MeltingRecipeAccessor.java @@ -2,6 +2,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; + import slimeknights.tconstruct.library.smeltery.MeltingRecipe; @Mixin(value = MeltingRecipe.class, remap = false) diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/TinkerRegistryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/TinkerRegistryAccessor.java index 13ac59b8d..3221f9e0c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/TinkerRegistryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/tconstruct/TinkerRegistryAccessor.java @@ -1,9 +1,14 @@ package com.cleanroommc.groovyscript.core.mixin.tconstruct; +import java.util.List; +import java.util.Map; + import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; + import slimeknights.tconstruct.library.DryingRecipe; import slimeknights.tconstruct.library.TinkerRegistry; import slimeknights.tconstruct.library.materials.Material; @@ -12,9 +17,6 @@ import slimeknights.tconstruct.library.smeltery.MeltingRecipe; import slimeknights.tconstruct.library.traits.ITrait; -import java.util.List; -import java.util.Map; - @Mixin(value = TinkerRegistry.class, remap = false) public interface TinkerRegistryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/BrewerManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/BrewerManagerAccessor.java index 38254bb70..9168a87b2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/BrewerManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/BrewerManagerAccessor.java @@ -1,14 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.BrewerManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - import java.util.List; import java.util.Map; import java.util.Set; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.BrewerManager; + @Mixin(value = BrewerManager.class, remap = false) public interface BrewerManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/BrewerRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/BrewerRecipeAccessor.java index 6ead0c54a..23de28c41 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/BrewerRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/BrewerRecipeAccessor.java @@ -1,16 +1,19 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.BrewerManager; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.BrewerManager; + @Mixin(value = BrewerManager.BrewerRecipe.class, remap = false) public interface BrewerRecipeAccessor { @Invoker("") - static BrewerManager.BrewerRecipe createBrewerRecipe(ItemStack input, FluidStack inputFluid, FluidStack outputFluid, int energy) { + static BrewerManager.BrewerRecipe createBrewerRecipe(ItemStack input, FluidStack inputFluid, FluidStack outputFluid, + int energy) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CentrifugeManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CentrifugeManagerAccessor.java index 346c8bc43..827f41c5b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CentrifugeManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CentrifugeManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.CentrifugeManager; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.CentrifugeManager; @Mixin(value = CentrifugeManager.class, remap = false) public interface CentrifugeManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CentrifugeRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CentrifugeRecipeAccessor.java index 2b15cb768..9da41f18c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CentrifugeRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CentrifugeRecipeAccessor.java @@ -1,21 +1,24 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.CentrifugeManager; +import java.util.List; + +import javax.annotation.Nullable; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; -import javax.annotation.Nullable; -import java.util.List; +import cofh.thermalexpansion.util.managers.machine.CentrifugeManager; @Mixin(value = CentrifugeManager.CentrifugeRecipe.class, remap = false) public interface CentrifugeRecipeAccessor { @Invoker("") - static CentrifugeManager.CentrifugeRecipe createCentrifugeRecipe(ItemStack input, - @Nullable List output, - @Nullable List chance, @Nullable FluidStack fluid, int energy) { + static CentrifugeManager.CentrifugeRecipe createCentrifugeRecipe(ItemStack input, @Nullable List output, + @Nullable List chance, @Nullable FluidStack fluid, + int energy) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ChargerManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ChargerManagerAccessor.java index 52d5c1e77..0282e6573 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ChargerManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ChargerManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidated; -import cofh.thermalexpansion.util.managers.machine.ChargerManager; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import cofh.core.inventory.ComparableItemStackValidated; +import cofh.thermalexpansion.util.managers.machine.ChargerManager; @Mixin(value = ChargerManager.class, remap = false) public interface ChargerManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompactorManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompactorManagerAccessor.java index a7fc024bf..2817c432d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompactorManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompactorManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.CompactorManager; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.CompactorManager; @Mixin(value = CompactorManager.class, remap = false) public interface CompactorManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompactorRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompactorRecipeAccessor.java index b234bffef..5e321b076 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompactorRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompactorRecipeAccessor.java @@ -1,10 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.CompactorManager; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.CompactorManager; + @Mixin(value = CompactorManager.CompactorRecipe.class, remap = false) public interface CompactorRecipeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompressionManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompressionManagerAccessor.java index 43e344bbd..b7196c0d0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompressionManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CompressionManagerAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.dynamo.CompressionManager; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import cofh.thermalexpansion.util.managers.dynamo.CompressionManager; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; + @Mixin(value = CompressionManager.class, remap = false) public interface CompressionManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CoolantManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CoolantManagerAccessor.java index d6b2162f5..2066e9e7c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CoolantManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CoolantManagerAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.device.CoolantManager; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import cofh.thermalexpansion.util.managers.device.CoolantManager; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; + @Mixin(value = CoolantManager.class, remap = false) public interface CoolantManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CrucibleManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CrucibleManagerAccessor.java index 6aa4826d0..9dd0de829 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CrucibleManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CrucibleManagerAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.CrucibleManager; +import java.util.Map; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; -import java.util.Set; +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.CrucibleManager; @Mixin(value = CrucibleManager.class, remap = false) public interface CrucibleManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CrucibleRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CrucibleRecipeAccessor.java index c38a29622..6bdbf1d05 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CrucibleRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/CrucibleRecipeAccessor.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.CrucibleManager; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.CrucibleManager; + @Mixin(value = CrucibleManager.CrucibleRecipe.class, remap = false) public interface CrucibleRecipeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/DiffuserManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/DiffuserManagerAccessor.java index dc7739f83..6e6e41b1f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/DiffuserManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/DiffuserManagerAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + import cofh.core.inventory.ComparableItemStack; import cofh.thermalexpansion.util.managers.device.DiffuserManager; import gnu.trove.map.hash.TObjectIntHashMap; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(value = DiffuserManager.class, remap = false) public interface DiffuserManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnchanterManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnchanterManagerAccessor.java index 7dc6227ed..b555c8d68 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnchanterManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnchanterManagerAccessor.java @@ -1,14 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.EnchanterManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - import java.util.List; import java.util.Map; import java.util.Set; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.EnchanterManager; + @Mixin(value = EnchanterManager.class, remap = false) public interface EnchanterManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnchanterRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnchanterRecipeAccessor.java index af70bf54c..4c33e6721 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnchanterRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnchanterRecipeAccessor.java @@ -1,15 +1,19 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.EnchanterManager; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.EnchanterManager; + @Mixin(value = EnchanterManager.EnchanterRecipe.class, remap = false) public interface EnchanterRecipeAccessor { @Invoker("") - static EnchanterManager.EnchanterRecipe createEnchanterRecipe(ItemStack primaryInput, ItemStack secondaryInput, ItemStack output, int experience, int energy, EnchanterManager.Type type) { + static EnchanterManager.EnchanterRecipe createEnchanterRecipe(ItemStack primaryInput, ItemStack secondaryInput, + ItemStack output, int experience, int energy, + EnchanterManager.Type type) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnervationManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnervationManagerAccessor.java index 090207415..08e23653a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnervationManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/EnervationManagerAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + import cofh.core.inventory.ComparableItemStack; import cofh.thermalexpansion.util.managers.dynamo.EnervationManager; import gnu.trove.map.hash.TObjectIntHashMap; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(value = EnervationManager.class, remap = false) public interface EnervationManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ExtruderManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ExtruderManagerAccessor.java index cafb68e30..8963808a4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ExtruderManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ExtruderManagerAccessor.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.util.ItemWrapper; -import cofh.thermalexpansion.util.managers.machine.ExtruderManager; +import java.util.List; +import java.util.Map; + import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; -import java.util.Map; +import cofh.core.util.ItemWrapper; +import cofh.thermalexpansion.util.managers.machine.ExtruderManager; @Mixin(value = ExtruderManager.class, remap = false) public interface ExtruderManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ExtruderRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ExtruderRecipeAccessor.java index cb36d1d0f..44e3484ce 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ExtruderRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ExtruderRecipeAccessor.java @@ -1,16 +1,19 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.ExtruderManager; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.ExtruderManager; + @Mixin(value = ExtruderManager.ExtruderRecipe.class, remap = false) public interface ExtruderRecipeAccessor { @Invoker("") - static ExtruderManager.ExtruderRecipe createExtruderRecipe(ItemStack output, FluidStack inputHot, FluidStack inputCold, int energy) { + static ExtruderManager.ExtruderRecipe createExtruderRecipe(ItemStack output, FluidStack inputHot, FluidStack inputCold, + int energy) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FactorizerManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FactorizerManagerAccessor.java index 133d640a1..50414ce75 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FactorizerManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FactorizerManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidated; -import cofh.thermalexpansion.util.managers.device.FactorizerManager; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import cofh.core.inventory.ComparableItemStackValidated; +import cofh.thermalexpansion.util.managers.device.FactorizerManager; @Mixin(value = FactorizerManager.class, remap = false) public interface FactorizerManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FactorizerRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FactorizerRecipeAccessor.java index 5c36f1844..bfefc23c9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FactorizerRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FactorizerRecipeAccessor.java @@ -1,10 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.device.FactorizerManager; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.device.FactorizerManager; + @Mixin(value = FactorizerManager.FactorizerRecipe.class, remap = false) public interface FactorizerRecipeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FisherManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FisherManagerAccessor.java index 1ff2631bf..8206981eb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FisherManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FisherManagerAccessor.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStack; -import cofh.thermalexpansion.util.managers.device.FisherManager; -import gnu.trove.map.hash.TObjectIntHashMap; +import java.util.List; + import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import cofh.core.inventory.ComparableItemStack; +import cofh.thermalexpansion.util.managers.device.FisherManager; +import gnu.trove.map.hash.TObjectIntHashMap; @Mixin(value = FisherManager.class, remap = false) public interface FisherManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FurnaceManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FurnaceManagerAccessor.java index 884cda3a0..1c460d8d0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FurnaceManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FurnaceManagerAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidated; -import cofh.thermalexpansion.util.managers.machine.FurnaceManager; +import java.util.Map; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; -import java.util.Set; +import cofh.core.inventory.ComparableItemStackValidated; +import cofh.thermalexpansion.util.managers.machine.FurnaceManager; @Mixin(value = FurnaceManager.class, remap = false) public interface FurnaceManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FurnaceRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FurnaceRecipeAccessor.java index 63d2f04f5..bc1ea141a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FurnaceRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/FurnaceRecipeAccessor.java @@ -1,10 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.FurnaceManager; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.FurnaceManager; + @Mixin(value = FurnaceManager.FurnaceRecipe.class, remap = false) public interface FurnaceRecipeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/InsolatorManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/InsolatorManagerAccessor.java index 1d4e0f2b3..668b8e149 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/InsolatorManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/InsolatorManagerAccessor.java @@ -1,14 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.InsolatorManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - import java.util.List; import java.util.Map; import java.util.Set; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.InsolatorManager; + @Mixin(value = InsolatorManager.class, remap = false) public interface InsolatorManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/InsolatorRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/InsolatorRecipeAccessor.java index d47f52c98..766191293 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/InsolatorRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/InsolatorRecipeAccessor.java @@ -1,15 +1,20 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.InsolatorManager; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.InsolatorManager; + @Mixin(value = InsolatorManager.InsolatorRecipe.class, remap = false) public interface InsolatorRecipeAccessor { @Invoker("") - static InsolatorManager.InsolatorRecipe createInsolatorRecipe(ItemStack secondaryInput, ItemStack primaryInput, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance, int energy, int water, InsolatorManager.Type type) { + static InsolatorManager.InsolatorRecipe createInsolatorRecipe(ItemStack secondaryInput, ItemStack primaryInput, + ItemStack primaryOutput, ItemStack secondaryOutput, + int secondaryChance, int energy, int water, + InsolatorManager.Type type) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/MagmaticManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/MagmaticManagerAccessor.java index 4b3031691..fcc3e1f54 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/MagmaticManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/MagmaticManagerAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.dynamo.MagmaticManager; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import cofh.thermalexpansion.util.managers.dynamo.MagmaticManager; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; + @Mixin(value = MagmaticManager.class, remap = false) public interface MagmaticManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/NumismaticManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/NumismaticManagerAccessor.java index cb498e77f..247093d6a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/NumismaticManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/NumismaticManagerAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + import cofh.core.inventory.ComparableItemStack; import cofh.thermalexpansion.util.managers.dynamo.NumismaticManager; import gnu.trove.map.hash.TObjectIntHashMap; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(value = NumismaticManager.class, remap = false) public interface NumismaticManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PrecipitatorManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PrecipitatorManagerAccessor.java index eef0fd9c9..dfcf8fb64 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PrecipitatorManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PrecipitatorManagerAccessor.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.util.ItemWrapper; -import cofh.thermalexpansion.util.managers.machine.PrecipitatorManager; +import java.util.List; +import java.util.Map; + import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; -import java.util.Map; +import cofh.core.util.ItemWrapper; +import cofh.thermalexpansion.util.managers.machine.PrecipitatorManager; @Mixin(value = PrecipitatorManager.class, remap = false) public interface PrecipitatorManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PrecipitatorRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PrecipitatorRecipeAccessor.java index 37b9202b3..a1be2a7c5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PrecipitatorRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PrecipitatorRecipeAccessor.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.PrecipitatorManager; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.PrecipitatorManager; + @Mixin(value = PrecipitatorManager.PrecipitatorRecipe.class, remap = false) public interface PrecipitatorRecipeAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PulverizerManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PulverizerManagerAccessor.java index 1c6ab1c81..1d0ba96d4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PulverizerManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PulverizerManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidated; -import cofh.thermalexpansion.util.managers.machine.PulverizerManager; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import cofh.core.inventory.ComparableItemStackValidated; +import cofh.thermalexpansion.util.managers.machine.PulverizerManager; @Mixin(value = PulverizerManager.class, remap = false) public interface PulverizerManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PulverizerRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PulverizerRecipeAccessor.java index f5f3addf0..d58b44eac 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PulverizerRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/PulverizerRecipeAccessor.java @@ -1,15 +1,18 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.PulverizerManager; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.PulverizerManager; + @Mixin(value = PulverizerManager.PulverizerRecipe.class, remap = false) public interface PulverizerRecipeAccessor { @Invoker("") - static PulverizerManager.PulverizerRecipe createPulverizerRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance, int energy) { + static PulverizerManager.PulverizerRecipe createPulverizerRecipe(ItemStack input, ItemStack primaryOutput, + ItemStack secondaryOutput, int secondaryChance, int energy) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ReactantManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ReactantManagerAccessor.java index ce32119ee..fc9ca92c7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ReactantManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ReactantManagerAccessor.java @@ -1,14 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStack; -import cofh.thermalexpansion.util.managers.dynamo.ReactantManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - import java.util.List; import java.util.Map; import java.util.Set; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import cofh.core.inventory.ComparableItemStack; +import cofh.thermalexpansion.util.managers.dynamo.ReactantManager; + @Mixin(value = ReactantManager.class, remap = false) public interface ReactantManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ReactionAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ReactionAccessor.java index f7527a697..f32a59df6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ReactionAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/ReactionAccessor.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.dynamo.ReactantManager; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.dynamo.ReactantManager; + @Mixin(value = ReactantManager.Reaction.class, remap = false) public interface ReactionAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/RefineryManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/RefineryManagerAccessor.java index 440550a38..592efd044 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/RefineryManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/RefineryManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.RefineryManager; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import java.util.Set; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Set; +import cofh.thermalexpansion.util.managers.machine.RefineryManager; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; @Mixin(value = RefineryManager.class, remap = false) public interface RefineryManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/RefineryRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/RefineryRecipeAccessor.java index d03317215..a86286439 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/RefineryRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/RefineryRecipeAccessor.java @@ -1,16 +1,19 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.RefineryManager; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.RefineryManager; + @Mixin(value = RefineryManager.RefineryRecipe.class, remap = false) public interface RefineryRecipeAccessor { @Invoker("") - static RefineryManager.RefineryRecipe createRefineryRecipe(FluidStack input, FluidStack outputFluid, ItemStack outputItem, int energy, int chance) { + static RefineryManager.RefineryRecipe createRefineryRecipe(FluidStack input, FluidStack outputFluid, ItemStack outputItem, + int energy, int chance) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SawmillManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SawmillManagerAccessor.java index 68d590b36..bdfb71e64 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SawmillManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SawmillManagerAccessor.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.SawmillManager; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.SawmillManager; @Mixin(value = SawmillManager.class, remap = false) public interface SawmillManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SawmillRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SawmillRecipeAccessor.java index b65abc2b3..8b3db34ba 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SawmillRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SawmillRecipeAccessor.java @@ -1,15 +1,18 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.SawmillManager; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.SawmillManager; + @Mixin(value = SawmillManager.SawmillRecipe.class, remap = false) public interface SawmillRecipeAccessor { @Invoker("") - static SawmillManager.SawmillRecipe createSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance, int energy) { + static SawmillManager.SawmillRecipe createSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, + int secondaryChance, int energy) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SmelterManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SmelterManagerAccessor.java index e98891792..cb62cd4a3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SmelterManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SmelterManagerAccessor.java @@ -1,14 +1,15 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.thermalexpansion.util.managers.machine.SmelterManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - import java.util.List; import java.util.Map; import java.util.Set; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.thermalexpansion.util.managers.machine.SmelterManager; + @Mixin(value = SmelterManager.class, remap = false) public interface SmelterManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SmelterRecipeAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SmelterRecipeAccessor.java index 4507f8301..a4ddfcebe 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SmelterRecipeAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SmelterRecipeAccessor.java @@ -1,15 +1,19 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.thermalexpansion.util.managers.machine.SmelterManager; import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import cofh.thermalexpansion.util.managers.machine.SmelterManager; + @Mixin(value = SmelterManager.SmelterRecipe.class, remap = false) public interface SmelterRecipeAccessor { @Invoker("") - static SmelterManager.SmelterRecipe createSmelterRecipe(ItemStack secondaryInput, ItemStack primaryInput, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance, int energy) { + static SmelterManager.SmelterRecipe createSmelterRecipe(ItemStack secondaryInput, ItemStack primaryInput, + ItemStack primaryOutput, ItemStack secondaryOutput, + int secondaryChance, int energy) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SteamManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SteamManagerAccessor.java index 8fdf62a64..fabe1e869 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SteamManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/SteamManagerAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + import cofh.core.inventory.ComparableItemStack; import cofh.thermalexpansion.util.managers.dynamo.SteamManager; import gnu.trove.map.hash.TObjectIntHashMap; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(value = SteamManager.class, remap = false) public interface SteamManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/TapperManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/TapperManagerAccessor.java index e38b2beee..bea5145a3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/TapperManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/TapperManagerAccessor.java @@ -1,16 +1,19 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; +import java.util.Map; + +import net.minecraftforge.fluids.FluidStack; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import com.google.common.collect.SetMultimap; + import cofh.core.inventory.ComparableItemStack; import cofh.core.util.BlockWrapper; import cofh.core.util.ItemWrapper; import cofh.thermalexpansion.util.managers.device.TapperManager; -import com.google.common.collect.SetMultimap; import gnu.trove.map.hash.TObjectIntHashMap; -import net.minecraftforge.fluids.FluidStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.Map; @Mixin(value = TapperManager.class, remap = false) public interface TapperManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/TransposerManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/TransposerManagerAccessor.java index 553512833..5fde41b41 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/TransposerManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/TransposerManagerAccessor.java @@ -1,15 +1,16 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; -import cofh.core.inventory.ComparableItemStackValidatedNBT; -import cofh.core.util.ItemWrapper; -import cofh.thermalexpansion.util.managers.machine.TransposerManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - import java.util.List; import java.util.Map; import java.util.Set; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +import cofh.core.inventory.ComparableItemStackValidatedNBT; +import cofh.core.util.ItemWrapper; +import cofh.thermalexpansion.util.managers.machine.TransposerManager; + @Mixin(value = TransposerManager.class, remap = false) public interface TransposerManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/XpCollectorManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/XpCollectorManagerAccessor.java index 9501aaaf6..1912971d2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/XpCollectorManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/thermalexpansion/XpCollectorManagerAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.thermalexpansion; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + import cofh.core.inventory.ComparableItemStack; import cofh.thermalexpansion.util.managers.device.XpCollectorManager; import gnu.trove.map.hash.TObjectIntHashMap; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(value = XpCollectorManager.class, remap = false) public interface XpCollectorManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/AnvilManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/AnvilManagerAccessor.java index afb118cff..587e9ed2f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/AnvilManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/AnvilManagerAccessor.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.woot; -import ipsis.woot.crafting.AnvilManager; +import java.util.List; + import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import ipsis.woot.crafting.AnvilManager; @Mixin(value = AnvilManager.class, remap = false) public interface AnvilManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/CustomDropAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/CustomDropAccessor.java index 2327914be..b046f1788 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/CustomDropAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/CustomDropAccessor.java @@ -1,12 +1,14 @@ package com.cleanroommc.groovyscript.core.mixin.woot; -import ipsis.woot.util.EnumEnchantKey; -import ipsis.woot.util.WootMobName; +import java.util.HashMap; + import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.HashMap; +import ipsis.woot.util.EnumEnchantKey; +import ipsis.woot.util.WootMobName; @Mixin(targets = "ipsis.woot.loot.customdrops.CustomDropsRepository$CustomDrop", remap = false) public interface CustomDropAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/CustomDropsRepositoryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/CustomDropsRepositoryAccessor.java index 13ab7fb7d..2d9ed77fa 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/CustomDropsRepositoryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/CustomDropsRepositoryAccessor.java @@ -1,10 +1,11 @@ package com.cleanroommc.groovyscript.core.mixin.woot; -import ipsis.woot.loot.customdrops.CustomDropsRepository; +import java.util.List; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import ipsis.woot.loot.customdrops.CustomDropsRepository; @Mixin(value = CustomDropsRepository.class, remap = false) public interface CustomDropsRepositoryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/PolicyRepositoryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/PolicyRepositoryAccessor.java index 612074309..2271d2f83 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/PolicyRepositoryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/PolicyRepositoryAccessor.java @@ -1,12 +1,14 @@ package com.cleanroommc.groovyscript.core.mixin.woot; -import ipsis.woot.policy.PolicyRepository; -import ipsis.woot.util.WootMobName; +import java.util.List; + import net.minecraft.item.ItemStack; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; +import ipsis.woot.policy.PolicyRepository; +import ipsis.woot.util.WootMobName; @Mixin(value = PolicyRepository.class, remap = false) public interface PolicyRepositoryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/SpawnRecipeRepositoryAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/SpawnRecipeRepositoryAccessor.java index aabf430a4..f38f141a6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/SpawnRecipeRepositoryAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/SpawnRecipeRepositoryAccessor.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.core.mixin.woot; -import ipsis.woot.farming.SpawnRecipe; -import ipsis.woot.farming.SpawnRecipeRepository; -import ipsis.woot.util.WootMobName; +import java.util.HashMap; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.HashMap; +import ipsis.woot.farming.SpawnRecipe; +import ipsis.woot.farming.SpawnRecipeRepository; +import ipsis.woot.util.WootMobName; @Mixin(value = SpawnRecipeRepository.class, remap = false) public interface SpawnRecipeRepositoryAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/WootConfigurationManagerAccessor.java b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/WootConfigurationManagerAccessor.java index 4670ac45e..db543e543 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/WootConfigurationManagerAccessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/mixin/woot/WootConfigurationManagerAccessor.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.core.mixin.woot; -import ipsis.woot.configuration.EnumConfigKey; -import ipsis.woot.configuration.WootConfigurationManager; -import ipsis.woot.util.WootMobName; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; -import java.util.Map; +import ipsis.woot.configuration.EnumConfigKey; +import ipsis.woot.configuration.WootConfigurationManager; +import ipsis.woot.util.WootMobName; @Mixin(value = WootConfigurationManager.class, remap = false) public interface WootConfigurationManagerAccessor { diff --git a/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassConstructorsVisitor.java b/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassConstructorsVisitor.java index 2e5dc5245..fef7a6981 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassConstructorsVisitor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassConstructorsVisitor.java @@ -18,9 +18,7 @@ public CachedClassConstructorsVisitor(ClassVisitor cv) { @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); - if (name.equals(METHOD_NAME)) { - return new InitConstructorVisitor(mv); - } + if (name.equals(METHOD_NAME)) { return new InitConstructorVisitor(mv); } return mv; } @@ -33,7 +31,8 @@ public InitConstructorVisitor(MethodVisitor mv) { @Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { mv.visitFieldInsn(GETFIELD, CLASS_NAME_2 + "$2", "this$0", "L" + CLASS_NAME_2 + ";"); - mv.visitMethodInsn(INVOKESTATIC, "com/cleanroommc/groovyscript/sandbox/transformer/GroovyCodeFactory", "makeConstructorsHook", "(L" + CLASS_NAME_2 + ";)Ljava/security/PrivilegedAction;", false); + mv.visitMethodInsn(INVOKESTATIC, "com/cleanroommc/groovyscript/sandbox/transformer/GroovyCodeFactory", + "makeConstructorsHook", "(L" + CLASS_NAME_2 + ";)Ljava/security/PrivilegedAction;", false); } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassFieldsVisitor.java b/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassFieldsVisitor.java index 8e185a5dd..866b8a34b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassFieldsVisitor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassFieldsVisitor.java @@ -18,9 +18,7 @@ public CachedClassFieldsVisitor(ClassVisitor cv) { @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); - if (name.equals(METHOD_NAME)) { - return new InitFieldVisitor(mv); - } + if (name.equals(METHOD_NAME)) { return new InitFieldVisitor(mv); } return mv; } @@ -33,7 +31,8 @@ public InitFieldVisitor(MethodVisitor mv) { @Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { mv.visitFieldInsn(GETFIELD, CLASS_NAME_2 + "$1", "this$0", "L" + CLASS_NAME_2 + ";"); - mv.visitMethodInsn(INVOKESTATIC, "com/cleanroommc/groovyscript/sandbox/transformer/GroovyCodeFactory", "makeFieldsHook", "(L" + CLASS_NAME_2 + ";)Ljava/security/PrivilegedAction;", false); + mv.visitMethodInsn(INVOKESTATIC, "com/cleanroommc/groovyscript/sandbox/transformer/GroovyCodeFactory", + "makeFieldsHook", "(L" + CLASS_NAME_2 + ";)Ljava/security/PrivilegedAction;", false); } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassMethodsVisitor.java b/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassMethodsVisitor.java index 6aff467cd..d4ed07e57 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassMethodsVisitor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/visitors/CachedClassMethodsVisitor.java @@ -18,9 +18,7 @@ public CachedClassMethodsVisitor(ClassVisitor cv) { @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); - if (name.equals(METHOD_NAME)) { - return new InitMethodVisitor(mv); - } + if (name.equals(METHOD_NAME)) { return new InitMethodVisitor(mv); } return mv; } @@ -33,7 +31,8 @@ public InitMethodVisitor(MethodVisitor mv) { @Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { mv.visitFieldInsn(GETFIELD, CLASS_NAME_2 + "$3", "this$0", "L" + CLASS_NAME_2 + ";"); - mv.visitMethodInsn(INVOKESTATIC, "com/cleanroommc/groovyscript/sandbox/transformer/GroovyCodeFactory", "makeMethodsHook", "(L" + CLASS_NAME_2 + ";)Ljava/security/PrivilegedAction;", false); + mv.visitMethodInsn(INVOKESTATIC, "com/cleanroommc/groovyscript/sandbox/transformer/GroovyCodeFactory", + "makeMethodsHook", "(L" + CLASS_NAME_2 + ";)Ljava/security/PrivilegedAction;", false); } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/visitors/InvokerHelperVisitor.java b/src/main/java/com/cleanroommc/groovyscript/core/visitors/InvokerHelperVisitor.java index 0eea73884..f23535ece 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/visitors/InvokerHelperVisitor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/visitors/InvokerHelperVisitor.java @@ -22,9 +22,7 @@ public InvokerHelperVisitor(ClassWriter writer) { @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor visitor = super.visitMethod(access, name, desc, signature, exceptions); - if (CREATE_MAP_METHOD.equals(name)) { - return new CreateMapVisitor(visitor); - } + if (CREATE_MAP_METHOD.equals(name)) { return new CreateMapVisitor(visitor); } return visitor; } diff --git a/src/main/java/com/cleanroommc/groovyscript/core/visitors/StaticVerifierVisitor.java b/src/main/java/com/cleanroommc/groovyscript/core/visitors/StaticVerifierVisitor.java index 75e965fec..4030ff775 100644 --- a/src/main/java/com/cleanroommc/groovyscript/core/visitors/StaticVerifierVisitor.java +++ b/src/main/java/com/cleanroommc/groovyscript/core/visitors/StaticVerifierVisitor.java @@ -17,9 +17,7 @@ public StaticVerifierVisitor(ClassVisitor cv) { @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); - if (name.equals(METHOD)) { - return new VisitVariableVisitor(mv); - } + if (name.equals(METHOD)) { return new VisitVariableVisitor(mv); } return mv; } @@ -42,12 +40,14 @@ public void visitCode() { mv.visitLabel(label0); mv.visitLineNumber(30, label0); mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getAccessedVariable", "()Lorg/codehaus/groovy/ast/Variable;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getAccessedVariable", + "()Lorg/codehaus/groovy/ast/Variable;", false); mv.visitTypeInsn(INSTANCEOF, "org/codehaus/groovy/ast/DynamicVariable"); Label label1 = new Label(); mv.visitJumpInsn(IFEQ, label1); mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "isInStaticContext", "()Z", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "isInStaticContext", "()Z", + false); Label label2 = new Label(); mv.visitJumpInsn(IFNE, label2); mv.visitVarInsn(ALOAD, 0); @@ -62,22 +62,29 @@ public void visitCode() { mv.visitLabel(label3); mv.visitLineNumber(32, label3); mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETFIELD, "org/codehaus/groovy/control/StaticVerifier", "methodNode", "Lorg/codehaus/groovy/ast/MethodNode;"); + mv.visitFieldInsn(GETFIELD, "org/codehaus/groovy/control/StaticVerifier", "methodNode", + "Lorg/codehaus/groovy/ast/MethodNode;"); Label label4 = new Label(); mv.visitJumpInsn(IFNULL, label4); mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETFIELD, "org/codehaus/groovy/control/StaticVerifier", "methodNode", "Lorg/codehaus/groovy/ast/MethodNode;"); + mv.visitFieldInsn(GETFIELD, "org/codehaus/groovy/control/StaticVerifier", "methodNode", + "Lorg/codehaus/groovy/ast/MethodNode;"); mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/MethodNode", "isStatic", "()Z", false); mv.visitJumpInsn(IFEQ, label4); Label label5 = new Label(); mv.visitLabel(label5); mv.visitLineNumber(33, label5); mv.visitVarInsn(ALOAD, 0); - mv.visitFieldInsn(GETFIELD, "org/codehaus/groovy/control/StaticVerifier", "methodNode", "Lorg/codehaus/groovy/ast/MethodNode;"); - mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/MethodNode", "getDeclaringClass", "()Lorg/codehaus/groovy/ast/ClassNode;", false); + mv.visitFieldInsn(GETFIELD, "org/codehaus/groovy/control/StaticVerifier", "methodNode", + "Lorg/codehaus/groovy/ast/MethodNode;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/MethodNode", "getDeclaringClass", + "()Lorg/codehaus/groovy/ast/ClassNode;", false); mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getName", "()Ljava/lang/String;", false); - mv.visitMethodInsn(INVOKESTATIC, "org/codehaus/groovy/control/StaticVerifier", "getDeclaredOrInheritedField", "(Lorg/codehaus/groovy/ast/ClassNode;Ljava/lang/String;)Lorg/codehaus/groovy/ast/FieldNode;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getName", + "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKESTATIC, "org/codehaus/groovy/control/StaticVerifier", "getDeclaredOrInheritedField", + "(Lorg/codehaus/groovy/ast/ClassNode;Ljava/lang/String;)Lorg/codehaus/groovy/ast/FieldNode;", + false); mv.visitVarInsn(ASTORE, 2); Label label6 = new Label(); mv.visitLabel(label6); @@ -91,10 +98,13 @@ public void visitCode() { mv.visitJumpInsn(IFNE, label8); mv.visitLabel(label7); mv.visitFrame(Opcodes.F_APPEND, 1, new Object[]{"org/codehaus/groovy/ast/FieldNode"}, 0, null); - mv.visitMethodInsn(INVOKESTATIC, "com/cleanroommc/groovyscript/GroovyScript", "getSandbox", "()Lcom/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox;", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox", "getBindings", "()Ljava/util/Map;", false); + mv.visitMethodInsn(INVOKESTATIC, "com/cleanroommc/groovyscript/GroovyScript", "getSandbox", + "()Lcom/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox", "getBindings", + "()Ljava/util/Map;", false); mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getName", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getName", + "()Ljava/lang/String;", false); mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "containsKey", "(Ljava/lang/Object;)Z", true); mv.visitJumpInsn(IFEQ, label4); mv.visitLabel(label8); @@ -104,10 +114,13 @@ public void visitCode() { mv.visitLabel(label4); mv.visitLineNumber(38, label4); mv.visitFrame(Opcodes.F_CHOP, 1, null, 0, null); - mv.visitMethodInsn(INVOKESTATIC, "com/cleanroommc/groovyscript/GroovyScript", "getSandbox", "()Lcom/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox;", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox", "getBindings", "()Ljava/util/Map;", false); + mv.visitMethodInsn(INVOKESTATIC, "com/cleanroommc/groovyscript/GroovyScript", "getSandbox", + "()Lcom/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox", "getBindings", + "()Ljava/util/Map;", false); mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getName", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getName", + "()Ljava/lang/String;", false); mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "containsKey", "(Ljava/lang/Object;)Z", true); Label label9 = new Label(); mv.visitJumpInsn(IFEQ, label9); @@ -123,26 +136,34 @@ public void visitCode() { mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "", "()V", false); mv.visitLdcInsn("Apparent variable '"); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", + "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitVarInsn(ALOAD, 1); - mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getName", "()Ljava/lang/String;", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getName", + "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", + "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitLdcInsn("' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:\nYou attempted to reference a variable in the binding or an instance variable from a static context.\nYou misspelled a classname or statically imported field. Please check the spelling.\nYou attempted to use a method '"); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", + "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitVarInsn(ALOAD, 1); Label label11 = new Label(); mv.visitLabel(label11); mv.visitLineNumber(44, label11); - mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getName", "()Ljava/lang/String;", false); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/ast/expr/VariableExpression", "getName", + "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", + "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitLdcInsn("' but left out brackets in a place not allowed by the grammar."); - mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", + "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); mv.visitVarInsn(ALOAD, 1); Label label12 = new Label(); mv.visitLabel(label12); mv.visitLineNumber(41, label12); - mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/control/StaticVerifier", "addError", "(Ljava/lang/String;Lorg/codehaus/groovy/ast/ASTNode;)V", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "org/codehaus/groovy/control/StaticVerifier", "addError", + "(Ljava/lang/String;Lorg/codehaus/groovy/ast/ASTNode;)V", false); mv.visitLabel(label1); mv.visitLineNumber(46, label1); mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/AdmonitionBuilder.java b/src/main/java/com/cleanroommc/groovyscript/documentation/AdmonitionBuilder.java index 75446f9e3..06aa773be 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/AdmonitionBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/AdmonitionBuilder.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.documentation; -import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; -import com.cleanroommc.groovyscript.documentation.format.IFormat; -import org.apache.commons.lang3.StringUtils; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.commons.lang3.StringUtils; + +import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; +import com.cleanroommc.groovyscript.documentation.format.IFormat; + public class AdmonitionBuilder { private final List note = new ArrayList<>(); diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/Builder.java b/src/main/java/com/cleanroommc/groovyscript/documentation/Builder.java index 9035ee13e..4eec778dd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/Builder.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/Builder.java @@ -1,14 +1,5 @@ package com.cleanroommc.groovyscript.documentation; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.google.common.collect.ComparisonChain; -import it.unimi.dsi.fastutil.chars.Char2CharArrayMap; -import it.unimi.dsi.fastutil.chars.Char2CharMap; -import net.minecraft.client.resources.I18n; -import org.apache.commons.lang3.StringUtils; -import org.jetbrains.annotations.NotNull; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.*; @@ -19,13 +10,29 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import net.minecraft.client.resources.I18n; + +import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.NotNull; + +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.google.common.collect.ComparisonChain; + +import it.unimi.dsi.fastutil.chars.Char2CharArrayMap; +import it.unimi.dsi.fastutil.chars.Char2CharMap; + public class Builder { - private static final Char2CharMap commaSeparatedParts = new Char2CharArrayMap() {{ - put(']', '['); - put('\'', '\''); - defaultReturnValue(Character.MIN_VALUE); - }}; + private static final Char2CharMap commaSeparatedParts = new Char2CharArrayMap() + { + + { + put(']', '['); + put('\'', '\''); + defaultReturnValue(Character.MIN_VALUE); + } + }; private final String reference; private final Method builderMethod; @@ -44,24 +51,32 @@ public Builder(Method builderMethod, String reference, String baseTranslationKey this.registrationMethods = gatherRegistrationMethods(builderClass); } - private static Map gatherFields(Class builderClass, RecipeBuilderDescription annotation, String langLocation) { + private static Map gatherFields(Class builderClass, RecipeBuilderDescription annotation, + String langLocation) { Map fields = new HashMap<>(); List allFields = getAllFields(builderClass); for (Field field : allFields) { List annotations = Stream.of( - // Attached to the builder method's requirements field, an uncommon location for specific overrides - Arrays.stream(annotation.requirement()).filter(r -> r.property().equals(field.getName())), - // Attached to the class, to create/override requirements set in the parent - Arrays.stream(builderClass.getAnnotationsByType(Property.class)).filter(r -> r.property().equals(field.getName())), - // Attached to the field, the typical place for property information to be created - Arrays.stream(field.getAnnotationsByType(Property.class)).filter(r -> { - if (r.property().isEmpty() || r.property().equals(field.getName())) return true; - GroovyLog.get().warn("Property Annotation had element property '{}' set to a value that wasn't empty or equal to field '{}' in class '{}'.", r.property(), field, builderClass); - return false; - })) - .flatMap(x -> x) - .sorted((left, right) -> ComparisonChain.start().compare(left.hierarchy(), right.hierarchy()).result()) - .collect(Collectors.toList()); + // Attached to the builder method's requirements field, an uncommon location for specific overrides + Arrays.stream(annotation.requirement()).filter(r -> r.property().equals(field + .getName())), + // Attached to the class, to create/override requirements set in the parent + Arrays.stream(builderClass.getAnnotationsByType(Property.class)).filter(r -> r + .property() + .equals(field.getName())), + // Attached to the field, the typical place for property information to be created + Arrays.stream(field.getAnnotationsByType(Property.class)).filter(r -> { + if (r.property().isEmpty() || r.property().equals(field.getName())) + return true; + GroovyLog.get().warn( + "Property Annotation had element property '{}' set to a value that wasn't empty or equal to field '{}' in class '{}'.", + r.property(), field, builderClass); + return false; + })).flatMap(x -> x).sorted((left, right) -> ComparisonChain.start().compare( + left.hierarchy(), + right.hierarchy()) + .result()).collect( + Collectors.toList()); if (!annotations.isEmpty()) { fields.putIfAbsent(field.getName(), new FieldDocumentation(field, annotations, langLocation)); @@ -71,44 +86,69 @@ private static Map gatherFields(Class builderClas return fields; } - private static Map> gatherMethods(Class builderClass, Map fields) { + private static Map> gatherMethods(Class builderClass, + Map fields) { Map> fieldToModifyingMethods = new HashMap<>(); for (Method method : builderClass.getMethods()) { if (!method.isAnnotationPresent(RecipeBuilderMethodDescription.class)) continue; RecipeBuilderMethod pair = new RecipeBuilderMethod(method); for (String target : pair.targetFields()) { - if (fields.get(target) != null && fields.get(target).isIgnoringInheritedMethods() && !Arrays.asList(builderClass.getDeclaredMethods()).contains(method)) { + if (fields.get(target) != null && fields.get(target).isIgnoringInheritedMethods() && !Arrays.asList(builderClass + .getDeclaredMethods()) + .contains(method)) { continue; } fieldToModifyingMethods.computeIfAbsent(target, k -> new ArrayList<>()).add(pair); } } - fieldToModifyingMethods.forEach((key, value) -> value.sort((left, right) -> ComparisonChain.start() - .compare(left.getAnnotation().priority(), right.getAnnotation().priority()) - .compare(left.getMethod().getName().length(), right.getMethod().getName().length()) - .compare(left.getMethod().getName(), right.getMethod().getName(), String::compareToIgnoreCase) - .result())); + fieldToModifyingMethods.forEach((key, value) -> value.sort((left, right) -> ComparisonChain.start().compare(left + .getAnnotation() + .priority(), + right.getAnnotation() + .priority()) + .compare(left.getMethod() + .getName() + .length(), right + .getMethod() + .getName() + .length()) + .compare(left.getMethod() + .getName(), right + .getMethod() + .getName(), + String::compareToIgnoreCase) + .result())); return fieldToModifyingMethods; } private static List gatherRegistrationMethods(Class builderClass) { - return Arrays.stream(builderClass.getMethods()) - .filter(x -> x.isAnnotationPresent(RecipeBuilderRegistrationMethod.class)) - .sorted((left, right) -> ComparisonChain.start() - .compare(left.getAnnotation(RecipeBuilderRegistrationMethod.class).hierarchy(), right.getAnnotation(RecipeBuilderRegistrationMethod.class).hierarchy()) - // Specifically de-prioritize Object classes - .compareFalseFirst(left.getReturnType() == Object.class, right.getReturnType() == Object.class) - .result()) - // Ensure only the first method with a given name is used - .filter(distinctByKey(Method::getName)) - .sorted((left, right) -> ComparisonChain.start() - .compare(left.getAnnotation(RecipeBuilderRegistrationMethod.class).priority(), right.getAnnotation(RecipeBuilderRegistrationMethod.class).priority()) - .compare(left.getName().length(), right.getName().length()) - .compare(left.getName(), right.getName(), String::compareToIgnoreCase) - .result()) - .collect(Collectors.toList()); + return Arrays.stream(builderClass.getMethods()).filter(x -> x.isAnnotationPresent(RecipeBuilderRegistrationMethod.class)) + .sorted((left, right) -> ComparisonChain.start().compare(left.getAnnotation( + RecipeBuilderRegistrationMethod.class) + .hierarchy(), right.getAnnotation( + RecipeBuilderRegistrationMethod.class) + .hierarchy()) + // Specifically de-prioritize Object classes + .compareFalseFirst(left.getReturnType() == Object.class, right + .getReturnType() == Object.class) + .result()) + // Ensure only the first method with a given name is used + .filter(distinctByKey(Method::getName)).sorted((left, right) -> ComparisonChain.start().compare(left + .getAnnotation(RecipeBuilderRegistrationMethod.class) + .priority(), + right.getAnnotation(RecipeBuilderRegistrationMethod.class) + .priority()) + .compare(left.getName() + .length(), right + .getName() + .length()) + .compare(left.getName(), right + .getName(), + String::compareToIgnoreCase) + .result()).collect(Collectors + .toList()); } private static Predicate distinctByKey(Function keyExtractor) { @@ -128,7 +168,8 @@ private static List getAllFields(Class clazz) { } /** - * Obtains the normal default value of a class, and allows for properties to avoid having to state the default value unless it is explicitly changed. + * Obtains the normal default value of a class, and allows for properties to avoid having to state the default value unless it + * is explicitly changed. */ private static String defaultValueConverter(Class clazz) { if (clazz.equals(Boolean.class) || clazz.equals(boolean.class)) return "false"; @@ -146,7 +187,8 @@ private static String defaultValueConverter(Class clazz) { /** * Converts a single string into an array of strings. * Groups of code surrounded by square braces (`[]`) or single quotes (`''`) are split onto separate lines. - * Otherwise, each line starts with a period (`.`) provided that it is not contained within any special zones (comment, string, brackets, etc) + * Otherwise, each line starts with a period (`.`) provided that it is not contained within any special zones (comment, + * string, brackets, etc) */ private static List generateParts(String content) { List parts = new ArrayList<>(); @@ -208,11 +250,9 @@ private static List getOutputs(List parts) { public String builderAdmonition() { if (annotation.example().length == 0) return ""; - return new AdmonitionBuilder() - .note(new CodeBlockBuilder().line(builder().split("\n")).annotation(annotations()).generate()) - .type(Admonition.Type.EXAMPLE) - .indentation(1) - .generate(); + return new AdmonitionBuilder().note(new CodeBlockBuilder().line(builder().split("\n")).annotation(annotations()) + .generate()).type(Admonition.Type.EXAMPLE).indentation(1) + .generate(); } public String builderExampleFile() { @@ -232,7 +272,9 @@ public String builder() { } public List annotations() { - return Arrays.stream(annotation.example()).flatMap(example -> Arrays.stream(example.annotations())).map(Documentation::translate).collect(Collectors.toList()); + return Arrays.stream(annotation.example()).flatMap(example -> Arrays.stream(example.annotations())).map( + Documentation::translate) + .collect(Collectors.toList()); } public String documentMethods() { @@ -240,7 +282,8 @@ public String documentMethods() { methods.keySet().forEach(target -> { if (fields.containsKey(target)) return; - GroovyLog.get().warn("Couldn't find field '{}' referenced in a method used for recipe builder '{}'", target, reference); + GroovyLog.get().warn("Couldn't find field '{}' referenced in a method used for recipe builder '{}'", target, + reference); }); if (fields.values().stream().anyMatch(FieldDocumentation::isUsed)) { @@ -258,7 +301,8 @@ public String documentMethods() { if ("void".equals(returnType) || "null".equals(returnType)) out.append(I18n.format("groovyscript.wiki.register")); else out.append(I18n.format("groovyscript.wiki.register_return", returnType)); out.append("\n\n"); - out.append(new CodeBlockBuilder().line(String.format("%s()", registerMethod.getName())).indentation(1).toString()); + out.append(new CodeBlockBuilder().line(String.format("%s()", registerMethod.getName())).indentation(1) + .toString()); } } @@ -267,42 +311,39 @@ public String documentMethods() { public StringBuilder documentFields() { StringBuilder out = new StringBuilder(); - fields.values().stream() - .sorted() - .filter(FieldDocumentation::isUsed) - .forEach(fieldDocumentation -> { - - out.append(fieldDocumentation.getDescription()); - - if (fieldDocumentation.hasComparison()) { - out.append(" ").append(I18n.format("groovyscript.wiki.requires", fieldDocumentation.getComparison())); - } - - if (fieldDocumentation.hasRequirement()) { - out.append(" ").append(I18n.format("groovyscript.wiki.requires", fieldDocumentation.getRequirement())); - } - - if (fieldDocumentation.hasDefaultValue()) { - out.append(" ").append(I18n.format("groovyscript.wiki.default", fieldDocumentation.getDefaultValue())); - } - - out.append("\n\n"); - - List recipeBuilderMethods = methods.get(fieldDocumentation.getField().getName()); - - if (recipeBuilderMethods == null || recipeBuilderMethods.isEmpty()) { - GroovyLog.get().warn("Couldn't find any methods targeting field '{}' in recipe builder '{}'", fieldDocumentation.getField().getName(), reference); - } else { - out.append(new CodeBlockBuilder() - .line(recipeBuilderMethods.stream() - .sorted() - .map(RecipeBuilderMethod::shortMethodSignature) - .distinct() - .collect(Collectors.toList())) - .indentation(1) - .toString()); - } - }); + fields.values().stream().sorted().filter(FieldDocumentation::isUsed).forEach(fieldDocumentation -> { + + out.append(fieldDocumentation.getDescription()); + + if (fieldDocumentation.hasComparison()) { + out.append(" ").append(I18n.format("groovyscript.wiki.requires", fieldDocumentation.getComparison())); + } + + if (fieldDocumentation.hasRequirement()) { + out.append(" ").append(I18n.format("groovyscript.wiki.requires", fieldDocumentation.getRequirement())); + } + + if (fieldDocumentation.hasDefaultValue()) { + out.append(" ").append(I18n.format("groovyscript.wiki.default", fieldDocumentation.getDefaultValue())); + } + + out.append("\n\n"); + + List recipeBuilderMethods = methods.get(fieldDocumentation.getField().getName()); + + if (recipeBuilderMethods == null || recipeBuilderMethods.isEmpty()) { + GroovyLog.get().warn("Couldn't find any methods targeting field '{}' in recipe builder '{}'", fieldDocumentation + .getField() + .getName(), + reference); + } else { + out.append(new CodeBlockBuilder().line(recipeBuilderMethods.stream().sorted().map( + RecipeBuilderMethod::shortMethodSignature) + .distinct().collect(Collectors.toList())).indentation( + 1) + .toString()); + } + }); return out; } @@ -319,7 +360,8 @@ private String createBuilder(Example example) { out.append(String.join("", getOutputs(generateParts(example.value())))); - if (!registrationMethods.isEmpty()) out.append(" .").append(String.format("%s()", registrationMethods.get(0).getName())); + if (!registrationMethods.isEmpty()) out.append(" .").append(String.format("%s()", registrationMethods.get(0) + .getName())); if (example.commented()) out.append("*/"); @@ -342,24 +384,19 @@ public FieldDocumentation(Field field, List annotations, String langLo this.firstAnnotation = annotations.get(0); } - public Field getField() { - return field; - } + public Field getField() { return field; } - public Property getAnnotation() { - return firstAnnotation; - } + public Property getAnnotation() { return firstAnnotation; } public int priority() { return annotations.stream().map(Property::priority).filter(x -> x != 1000).findFirst().orElse(1000); } public String getLangKey() { - return annotations.stream() - .map(Property::value) - .filter(value -> !value.isEmpty()) - .findFirst() - .orElse(String.format("%s.%s.value", langLocation, field.getName())); + return annotations.stream().map(Property::value).filter(value -> !value.isEmpty()).findFirst().orElse(String.format( + "%s.%s.value", + langLocation, + field.getName())); } public boolean hasDefaultValue() { @@ -367,11 +404,8 @@ public boolean hasDefaultValue() { } public String getDefaultValue() { - return annotations.stream() - .filter(x -> !x.defaultValue().isEmpty()) - .findFirst() - .map(Property::defaultValue) - .orElse(defaultValueConverter(getField().getType())); + return annotations.stream().filter(x -> !x.defaultValue().isEmpty()).findFirst().map(Property::defaultValue).orElse( + defaultValueConverter(getField().getType())); } public String getValue() { @@ -383,12 +417,16 @@ public boolean hasComparison() { } public String getComparison() { - Optional comparison = annotations.stream().map(Property::valid).filter(valid -> valid.length != 0).findFirst(); + Optional comparison = annotations.stream().map(Property::valid).filter(valid -> valid.length != 0) + .findFirst(); if (!comparison.isPresent()) return ""; - return Arrays.stream(comparison.get()) - .sorted((left, right) -> ComparisonChain.start().compare(left.type(), right.type()).result()) - .map(x -> Documentation.translate(x.type().getKey(), x.value())) - .collect(Collectors.joining(String.format(" %s ", I18n.format("groovyscript.wiki.and")))); + return Arrays.stream(comparison.get()).sorted((left, right) -> ComparisonChain.start().compare(left.type(), right + .type()) + .result()).map(x -> Documentation + .translate(x.type() + .getKey(), + x.value())) + .collect(Collectors.joining(String.format(" %s ", I18n.format("groovyscript.wiki.and")))); } public boolean hasRequirement() { @@ -396,38 +434,28 @@ public boolean hasRequirement() { } public String getRequirement() { - return annotations.stream() - .map(Property::requirement) - .filter(x -> !x.isEmpty()) - .findFirst() - .map(Documentation::translate) - .orElse(""); + return annotations.stream().map(Property::requirement).filter(x -> !x.isEmpty()).findFirst().map( + Documentation::translate) + .orElse(""); } - public boolean isIgnoringInheritedMethods() { - return getAnnotation().ignoresInheritedMethods(); - } + public boolean isIgnoringInheritedMethods() { return getAnnotation().ignoresInheritedMethods(); } - public boolean isUsed() { - return !getAnnotation().needsOverride(); - } + public boolean isUsed() { return !getAnnotation().needsOverride(); } private String getFieldTypeInlineCode() { //return "`#!groovy " + Exporter.simpleSignature(getField().getAnnotatedType().getType().getTypeName()) + "`. "; return "`" + Exporter.simpleSignature(getField().getAnnotatedType().getType().getTypeName()) + "`. "; } - public String getDescription() { - return "- " + getFieldTypeInlineCode() + Documentation.translate(getLangKey()) + "."; - } + public String getDescription() { return "- " + getFieldTypeInlineCode() + Documentation.translate(getLangKey()) + "."; } @Override public int compareTo(@NotNull FieldDocumentation comp) { - return ComparisonChain.start() - .compare(this.priority(), comp.priority()) - .compare(this.getField().getName().length(), comp.getField().getName().length()) - .compare(this.getField().getName(), comp.getField().getName(), String::compareToIgnoreCase) - .result(); + return ComparisonChain.start().compare(this.priority(), comp.priority()).compare(this.getField().getName().length(), + comp.getField().getName().length()) + .compare(this.getField().getName(), comp.getField().getName(), String::compareToIgnoreCase) + .result(); } } @@ -443,16 +471,13 @@ public RecipeBuilderMethod(Method method) { this.annotation = method.getAnnotation(RecipeBuilderMethodDescription.class); } - public Method getMethod() { - return method; - } + public Method getMethod() { return method; } - public RecipeBuilderMethodDescription getAnnotation() { - return annotation; - } + public RecipeBuilderMethodDescription getAnnotation() { return annotation; } public List targetFields() { - return getAnnotation().field().length == 0 ? Collections.singletonList(getMethod().getName()) : Arrays.asList(getAnnotation().field()); + return getAnnotation().field().length == 0 ? Collections.singletonList(getMethod().getName()) : Arrays.asList( + getAnnotation().field()); } public String shortMethodSignature() { @@ -465,13 +490,12 @@ public int compareTo(@NotNull RecipeBuilderMethod comp) { String compSignature = comp.shortMethodSignature(); String thisPart = thisSignature.substring(0, thisSignature.indexOf("(")); String compPart = compSignature.substring(0, compSignature.indexOf("(")); - return ComparisonChain.start() - .compare(this.getAnnotation().priority(), comp.getAnnotation().priority()) - .compare(thisPart.length(), compPart.length()) - .compare(thisPart, compPart, String::compareToIgnoreCase) - .compare(thisSignature.length(), compSignature.length()) - .compare(thisSignature, compSignature, String::compareToIgnoreCase) - .result(); + return ComparisonChain.start().compare(this.getAnnotation().priority(), comp.getAnnotation().priority()).compare( + thisPart.length(), + compPart.length()) + .compare(thisPart, compPart, String::compareToIgnoreCase).compare(thisSignature.length(), + compSignature.length()) + .compare(thisSignature, compSignature, String::compareToIgnoreCase).result(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/CodeBlockBuilder.java b/src/main/java/com/cleanroommc/groovyscript/documentation/CodeBlockBuilder.java index 1c2dc6caa..d803061df 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/CodeBlockBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/CodeBlockBuilder.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.documentation; -import com.cleanroommc.groovyscript.documentation.format.IFormat; -import org.apache.commons.lang3.StringUtils; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; +import org.apache.commons.lang3.StringUtils; + +import com.cleanroommc.groovyscript.documentation.format.IFormat; + public class CodeBlockBuilder { private final List lines = new ArrayList<>(); diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/Documentation.java b/src/main/java/com/cleanroommc/groovyscript/documentation/Documentation.java index 3c13016ff..3c59913da 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/Documentation.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/Documentation.java @@ -1,5 +1,15 @@ package com.cleanroommc.groovyscript.documentation; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Set; +import java.util.regex.Pattern; + +import net.minecraft.client.resources.I18n; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.relauncher.FMLLaunchHandler; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; @@ -8,16 +18,8 @@ import com.cleanroommc.groovyscript.documentation.format.IFormat; import com.cleanroommc.groovyscript.documentation.format.OutputFormat; import com.cleanroommc.groovyscript.sandbox.LoadStage; -import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; -import net.minecraft.client.resources.I18n; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.relauncher.FMLLaunchHandler; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.util.Set; -import java.util.regex.Pattern; +import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; public class Documentation { @@ -116,4 +118,3 @@ public static String translate(String translateKey, Object... parameters) { } } - diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/Exporter.java b/src/main/java/com/cleanroommc/groovyscript/documentation/Exporter.java index 3121d26c4..fe4665422 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/Exporter.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/Exporter.java @@ -1,14 +1,5 @@ package com.cleanroommc.groovyscript.documentation; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.api.INamed; -import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; -import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; -import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; -import com.google.common.collect.ComparisonChain; -import net.minecraft.client.resources.I18n; - import java.io.File; import java.io.IOException; import java.lang.reflect.Method; @@ -19,6 +10,16 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import net.minecraft.client.resources.I18n; + +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.INamed; +import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; +import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; +import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; +import com.google.common.collect.ComparisonChain; + public class Exporter { private static final String INDEX_FILE_NAME = "index.md"; @@ -27,7 +28,8 @@ public class Exporter { private static final Pattern CLASS_NAME_PATTERN = Pattern.compile("(?>\\b)(?>[a-zA-Z0-9]+\\.)+([a-zA-Z0-9$]+)"); public static String simpleSignature(Method method) { - String signature = Arrays.stream(method.getAnnotatedParameterTypes()).map(x -> simpleSignature(x.getType().getTypeName())).collect(Collectors.joining(", ")); + String signature = Arrays.stream(method.getAnnotatedParameterTypes()).map(x -> simpleSignature(x.getType().getTypeName())) + .collect(Collectors.joining(", ")); return method.isVarArgs() ? convertVarArgs(signature) : signature; } @@ -43,14 +45,16 @@ private static String convertVarArgs(String name) { public static void generateWiki(File folder, GroovyContainer mod) { List fileLinks = new ArrayList<>(); - List registries = mod.get().getRegistries().stream() - .filter(x -> x.getClass().isAnnotationPresent(RegistryDescription.class)) - .distinct() - .sorted((left, right) -> ComparisonChain.start() - .compare(left.getClass().getAnnotation(RegistryDescription.class).priority(), right.getClass().getAnnotation(RegistryDescription.class).priority()) - .compare(left.getName(), right.getName()) - .result()) - .collect(Collectors.toList()); + List registries = mod.get().getRegistries().stream().filter(x -> x.getClass().isAnnotationPresent( + RegistryDescription.class)) + .distinct().sorted((left, right) -> ComparisonChain.start().compare(left.getClass() + .getAnnotation(RegistryDescription.class) + .priority(), right + .getClass() + .getAnnotation(RegistryDescription.class) + .priority()) + .compare(left.getName(), right.getName()) + .result()).collect(Collectors.toList()); if (registries.isEmpty()) return; @@ -70,20 +74,21 @@ public static void generateWiki(File folder, GroovyContainer { index.append(line).append("\n\n"); @@ -114,24 +119,27 @@ public static void generateExamples(String target, GroovyContainer imports = new ArrayList<>(); // Preprocessor to only run script if the mod is loaded - header.append("\n").append("// Auto generated groovyscript example file").append("\n") - .append("// MODS_LOADED: ").append(mod.getModId()).append("\n"); + header.append("\n").append("// Auto generated groovyscript example file").append("\n").append("// MODS_LOADED: ").append( + mod.getModId()) + .append("\n"); // Iterate through every registry of the mod once, in alphabetical order. - List registries = mod.get().getRegistries().stream() - .distinct() - .filter(x -> x.getClass().isAnnotationPresent(RegistryDescription.class)) - .filter(x -> x.getClass().getAnnotation(RegistryDescription.class).location().equals(target)) - .sorted((left, right) -> ComparisonChain.start() - .compare(left.getClass().getAnnotation(RegistryDescription.class).priority(), right.getClass().getAnnotation(RegistryDescription.class).priority()) - .compare(left.getName(), right.getName()) - .result()) - .collect(Collectors.toList()); + List registries = mod.get().getRegistries().stream().distinct().filter(x -> x.getClass().isAnnotationPresent( + RegistryDescription.class)) + .filter(x -> x.getClass().getAnnotation(RegistryDescription.class).location().equals(target)) + .sorted((left, right) -> ComparisonChain.start().compare(left.getClass().getAnnotation( + RegistryDescription.class) + .priority(), right.getClass() + .getAnnotation(RegistryDescription.class) + .priority()) + .compare(left.getName(), right.getName()).result()) + .collect(Collectors.toList()); if (registries.isEmpty()) return; for (INamed registry : registries) { - GroovyLog.msg("Generating examples for the mod {} and registry '{}'.", mod.toString(), registry.getName()).debug().post(); + GroovyLog.msg("Generating examples for the mod {} and registry '{}'.", mod.toString(), registry.getName()).debug() + .post(); Registry example = new Registry(mod, registry); imports.addAll(example.getImports()); body.append(example.exampleBlock()); @@ -141,8 +149,7 @@ public static void generateExamples(String target, GroovyContainer header.append("import ").append(i).append("\n")); // Print that the script was loaded at the end of the header, after any imports have been added. - header.append("\n").append(String.format(PRINT_MOD_DETECTED, mod.getModId())).append("\n\n") - .append(body); + header.append("\n").append(String.format(PRINT_MOD_DETECTED, mod.getModId())).append("\n\n").append(body); try { File file = new File(new File(Documentation.EXAMPLES, target), mod.getModId() + ".groovy"); diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/Registry.java b/src/main/java/com/cleanroommc/groovyscript/documentation/Registry.java index b66f47aae..f33683f4a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/Registry.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/Registry.java @@ -1,5 +1,14 @@ package com.cleanroommc.groovyscript.documentation; +import java.lang.reflect.Method; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import net.minecraft.client.resources.I18n; + +import org.apache.commons.lang3.text.WordUtils; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.INamed; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -7,13 +16,6 @@ import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; import com.cleanroommc.groovyscript.documentation.linkgenerator.LinkGeneratorHooks; import com.google.common.collect.ComparisonChain; -import net.minecraft.client.resources.I18n; -import org.apache.commons.lang3.text.WordUtils; - -import java.lang.reflect.Method; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; public class Registry { @@ -64,56 +66,60 @@ public Registry(GroovyContainer mod, INamed r } private static List sortGrSRecipeBuilderDescriptionMethods(List methods) { - methods.sort((left, right) -> ComparisonChain.start() - .compareFalseFirst(left.isAnnotationPresent(RecipeBuilderDescription.class), right.isAnnotationPresent(RecipeBuilderDescription.class)) - .compare(left.getAnnotation(RecipeBuilderDescription.class).priority(), right.getAnnotation(RecipeBuilderDescription.class).priority()) - .compare(left.getName(), right.getName(), String::compareToIgnoreCase) - .compare(Exporter.simpleSignature(left), Exporter.simpleSignature(right), String::compareToIgnoreCase) - .result()); + methods.sort((left, right) -> ComparisonChain.start().compareFalseFirst(left.isAnnotationPresent( + RecipeBuilderDescription.class), + right.isAnnotationPresent(RecipeBuilderDescription.class)) + .compare(left.getAnnotation(RecipeBuilderDescription.class).priority(), right + .getAnnotation(RecipeBuilderDescription.class) + .priority()) + .compare(left.getName(), right.getName(), String::compareToIgnoreCase) + .compare(Exporter.simpleSignature(left), Exporter.simpleSignature(right), + String::compareToIgnoreCase).result()); return methods; } private static List sortGrSMethodDescriptionMethods(List methods) { - methods.sort((left, right) -> ComparisonChain.start() - .compareFalseFirst(left.isAnnotationPresent(MethodDescription.class), right.isAnnotationPresent(MethodDescription.class)) - .compare(left.getAnnotation(MethodDescription.class).priority(), right.getAnnotation(MethodDescription.class).priority()) - .compare(left.getName(), right.getName(), String::compareToIgnoreCase) - .compare(Exporter.simpleSignature(left), Exporter.simpleSignature(right), String::compareToIgnoreCase) - .result()); + methods.sort((left, right) -> ComparisonChain.start().compareFalseFirst(left.isAnnotationPresent(MethodDescription.class), + right.isAnnotationPresent(MethodDescription.class)) + .compare(left.getAnnotation(MethodDescription.class).priority(), right + .getAnnotation(MethodDescription.class) + .priority()) + .compare(left.getName(), right.getName(), String::compareToIgnoreCase) + .compare(Exporter.simpleSignature(left), Exporter.simpleSignature(right), + String::compareToIgnoreCase).result()); return methods; } private static List getExamples(Method method) { - return method.isAnnotationPresent(MethodDescription.class) - ? new ArrayList<>(Arrays.asList(method.getAnnotation(MethodDescription.class).example())) - : new ArrayList<>(); + return method.isAnnotationPresent(MethodDescription.class) ? new ArrayList<>(Arrays.asList(method.getAnnotation( + MethodDescription.class) + .example())) : + new ArrayList<>(); } private static List sortExamples(List examples) { - examples.sort((left, right) -> ComparisonChain.start() - .compare(left.priority(), right.priority()) - .compareFalseFirst(left.commented(), right.commented()) - .compare(left.value().length(), right.value().length()) - .compare(left.value(), right.value()) - .result()); + examples.sort((left, right) -> ComparisonChain.start().compare(left.priority(), right.priority()).compareFalseFirst(left + .commented(), + right.commented()) + .compare(left.value().length(), right.value().length()).compare(left + .value(), + right.value()) + .result()); return examples; } - public List getImports() { - return this.imports; - } + public List getImports() { return this.imports; } - public String getFileSourceCodeLink() { - return LinkGeneratorHooks.convert(description.linkGenerator(), registryClass); - } + public String getFileSourceCodeLink() { return LinkGeneratorHooks.convert(description.linkGenerator(), registryClass); } public String getTitle() { - return Documentation.translate(description.title().isEmpty() ? String.format("%s.title", baseTranslationKey) : description.title()); + return Documentation.translate(description.title().isEmpty() ? String.format("%s.title", baseTranslationKey) : description + .title()); } public String getDescription() { - return Documentation.translate(description.description().isEmpty() ? String.format("%s.description", baseTranslationKey) : description.description()) - .replace("\"", "\\\""); + return Documentation.translate(description.description().isEmpty() ? String.format("%s.description", baseTranslationKey) : + description.description()).replace("\"", "\\\""); } public String exampleBlock() { @@ -121,7 +127,9 @@ public String exampleBlock() { out.append("// ").append(getTitle()).append(":").append("\n"); out.append("// ").append(WordUtils.wrap(getDescription(), Documentation.MAX_LINE_LENGTH, "\n// ", false)).append("\n\n"); out.append(documentMethodDescriptionType(MethodDescription.Type.REMOVAL)); - for (Method method : recipeBuilderMethods) out.append(new Builder(method, reference, baseTranslationKey).builderExampleFile()).append("\n"); + for (Method method : recipeBuilderMethods) out.append(new Builder(method, reference, baseTranslationKey) + .builderExampleFile()) + .append("\n"); if (!recipeBuilderMethods.isEmpty()) out.append("\n"); out.append(documentMethodDescriptionType(MethodDescription.Type.ADDITION)); out.append(documentMethodDescriptionType(MethodDescription.Type.VALUE)); @@ -138,7 +146,8 @@ private String documentMethodDescriptionType(MethodDescription.Type type) { private String generateHeader() { StringBuilder out = new StringBuilder(); out.append("---\n").append("title: \"").append(getTitle()).append("\"\n"); - if (Documentation.DEFAULT_FORMAT.hasTitleTemplate()) out.append("titleTemplate: \"").append(mod).append(" | CleanroomMC").append("\"\n"); + if (Documentation.DEFAULT_FORMAT.hasTitleTemplate()) out.append("titleTemplate: \"").append(mod).append(" | CleanroomMC") + .append("\"\n"); out.append("description: \"").append(getDescription()).append("\"\n"); String link = getFileSourceCodeLink(); if (!link.isEmpty()) out.append("source_code_link: \"").append(link).append("\"\n"); @@ -156,22 +165,17 @@ private String generateDescription() { out.append(getDescription()).append("\n\n"); if (!description.isFullyDocumented()) { - out.append(new AdmonitionBuilder() - .type(Admonition.Type.WARNING) - .note(I18n.format("groovyscript.wiki.not_fully_documented")) - .generate()); + out.append(new AdmonitionBuilder().type(Admonition.Type.WARNING).note(I18n.format( + "groovyscript.wiki.not_fully_documented")) + .generate()); out.append("\n\n"); } Admonition[] admonition = description.admonition(); for (Admonition note : admonition) { - out.append(new AdmonitionBuilder() - .type(note.type()) - .title(note.title()) - .hasTitle(note.hasTitle()) - .format(note.format()) - .note(Documentation.translate(note.value())) - .generate()); + out.append(new AdmonitionBuilder().type(note.type()).title(note.title()).hasTitle(note.hasTitle()).format(note + .format()) + .note(Documentation.translate(note.value())).generate()); out.append("\n\n"); } return out.toString(); @@ -179,43 +183,43 @@ private String generateDescription() { private String generateIdentifier() { StringBuilder out = new StringBuilder(); - out.append("## ").append(I18n.format("groovyscript.wiki.identifier")).append("\n\n").append(I18n.format("groovyscript.wiki.import_instructions")).append("\n\n"); + out.append("## ").append(I18n.format("groovyscript.wiki.identifier")).append("\n\n").append(I18n.format( + "groovyscript.wiki.import_instructions")) + .append("\n\n"); - List packages = mod.getAliases().stream() - .flatMap(modID -> registry.getAliases().stream().map(alias -> String.format("mods.%s.%s", modID, alias))) - .collect(Collectors.toList()); + List packages = mod.getAliases().stream().flatMap(modID -> registry.getAliases().stream().map(alias -> String + .format("mods.%s.%s", + modID, + alias))) + .collect(Collectors.toList()); int target = packages.indexOf(reference); packages.set(target, reference + "/*()!*/"); - out.append(new CodeBlockBuilder() - .line(packages) - .annotation(I18n.format("groovyscript.wiki.defaultPackage")) - // Highlighting and focusing are based on the line count, and is 1-indexed - .highlight(String.valueOf(1 + target)) - .focus(1 + target) - .toString()); + out.append(new CodeBlockBuilder().line(packages).annotation(I18n.format("groovyscript.wiki.defaultPackage")) + // Highlighting and focusing are based on the line count, and is 1-indexed + .highlight(String.valueOf(1 + target)).focus(1 + target).toString()); return out.toString(); } private String recipeBuilder() { StringBuilder out = new StringBuilder(); - out.append("### ").append(I18n.format("groovyscript.wiki.recipe_builder")).append("\n\n") - .append(I18n.format("groovyscript.wiki.uses_recipe_builder", getTitle())).append("\n\n") - .append(I18n.format("groovyscript.wiki.recipe_builder_note", Documentation.DEFAULT_FORMAT.linkToBuilder())).append("\n\n"); + out.append("### ").append(I18n.format("groovyscript.wiki.recipe_builder")).append("\n\n").append(I18n.format( + "groovyscript.wiki.uses_recipe_builder", + getTitle())) + .append("\n\n").append(I18n.format("groovyscript.wiki.recipe_builder_note", Documentation.DEFAULT_FORMAT + .linkToBuilder())) + .append("\n\n"); for (int i = 0; i < recipeBuilderMethods.size(); i++) { Builder builder = new Builder(recipeBuilderMethods.get(i), reference, baseTranslationKey); - out.append(new AdmonitionBuilder() - .type(Admonition.Type.ABSTRACT) - .hasTitle(true) - .title(methodExample(recipeBuilderMethods.get(i))) - .note(builder.documentMethods().split("\n")) - .note("\n") - .note(builder.builderAdmonition().split("\n")) - .note("\n") - .generate()); + out.append(new AdmonitionBuilder().type(Admonition.Type.ABSTRACT).hasTitle(true).title(methodExample( + recipeBuilderMethods.get(i))) + .note(builder.documentMethods().split("\n")).note("\n").note(builder + .builderAdmonition() + .split("\n")) + .note("\n").generate()); if (i < recipeBuilderMethods.size() - 1) out.append("\n\n"); } return out.toString(); @@ -230,7 +234,9 @@ public String documentationBlock() { out.append(generateIdentifier()); if (!methods.get(MethodDescription.Type.VALUE).isEmpty()) { - out.append("## ").append(I18n.format("groovyscript.wiki.editing_values")).append("\n\n").append(documentMethods(methods.get(MethodDescription.Type.VALUE))).append("\n"); + out.append("## ").append(I18n.format("groovyscript.wiki.editing_values")).append("\n\n").append(documentMethods( + methods.get(MethodDescription.Type.VALUE))) + .append("\n"); } if (!methods.get(MethodDescription.Type.ADDITION).isEmpty() || !recipeBuilderMethods.isEmpty()) { out.append("## ").append(Documentation.translate(description.category().adding())).append("\n\n"); @@ -242,10 +248,15 @@ public String documentationBlock() { } } if (!methods.get(MethodDescription.Type.REMOVAL).isEmpty()) { - out.append("## ").append(Documentation.translate(description.category().removing())).append("\n\n").append(documentMethods(methods.get(MethodDescription.Type.REMOVAL))).append("\n"); + out.append("## ").append(Documentation.translate(description.category().removing())).append("\n\n").append( + documentMethods(methods.get(MethodDescription.Type.REMOVAL))) + .append("\n"); } if (!methods.get(MethodDescription.Type.QUERY).isEmpty()) { - out.append("## ").append(Documentation.translate(description.category().query())).append("\n\n").append(documentMethods(methods.get(MethodDescription.Type.QUERY), true)).append("\n"); + out.append("## ").append(Documentation.translate(description.category().query())).append("\n\n").append( + documentMethods(methods.get(MethodDescription.Type.QUERY), + true)) + .append("\n"); } out.append("\n"); @@ -263,22 +274,27 @@ public String documentMethods(List methods, boolean preventExamples) { for (Method method : methods) { out.append(methodDescription(method)); - if (method.getAnnotation(MethodDescription.class).example().length > 0 && Arrays.stream(method.getAnnotation(MethodDescription.class).example()).anyMatch(x -> !x.value().isEmpty())) { - exampleLines.addAll(Arrays.stream(method.getAnnotation(MethodDescription.class).example()).flatMap(example -> Stream.of(methodExample(method, example.value()))).collect(Collectors.toList())); + if (method.getAnnotation(MethodDescription.class).example().length > 0 && Arrays.stream(method.getAnnotation( + MethodDescription.class) + .example()).anyMatch( + x -> !x.value() + .isEmpty())) { + exampleLines.addAll(Arrays.stream(method.getAnnotation(MethodDescription.class).example()).flatMap( + example -> Stream.of(methodExample(method, + example.value()))) + .collect(Collectors.toList())); } else if (method.getParameterTypes().length == 0) { exampleLines.add(methodExample(method)); } - Arrays.stream(method.getAnnotation(MethodDescription.class).example()).map(Example::annotations).flatMap(Arrays::stream).forEach(annotations::add); + Arrays.stream(method.getAnnotation(MethodDescription.class).example()).map(Example::annotations).flatMap( + Arrays::stream) + .forEach(annotations::add); } if (!exampleLines.isEmpty() && !preventExamples) { - out.append(new AdmonitionBuilder() - .type(Admonition.Type.EXAMPLE) - .note(new CodeBlockBuilder() - .line(exampleLines) - .annotation(annotations) - .generate()) - .generate()); + out.append(new AdmonitionBuilder().type(Admonition.Type.EXAMPLE).note(new CodeBlockBuilder().line(exampleLines) + .annotation(annotations) + .generate()).generate()); out.append("\n"); } @@ -291,16 +307,12 @@ private String methodDescription(Method method) { String globalDefault = String.format("groovyscript.wiki.%s", method.getName()); // If `desc` isn't defined, check the `registryDefault` key. If it exists, use it. // Then, check the `globalDefault` key. If it exists use it. Otherwise, we want to still use the `registryDefault` for logging a missing key. - String lang = desc.isEmpty() - ? I18n.hasKey(registryDefault) || !I18n.hasKey(globalDefault) ? registryDefault : globalDefault - : desc; - - return String.format("- %s:\n\n%s", - Documentation.translate(lang), - new CodeBlockBuilder() - .line(methodExample(method, Exporter.simpleSignature(method))) - .indentation(1) - .toString()); + String lang = desc.isEmpty() ? I18n.hasKey(registryDefault) || !I18n.hasKey(globalDefault) ? registryDefault : + globalDefault : desc; + + return String.format("- %s:\n\n%s", Documentation.translate(lang), new CodeBlockBuilder().line(methodExample(method, + Exporter.simpleSignature(method))) + .indentation(1).toString()); } private String methodExample(Method method, String example) { diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/format/IFormat.java b/src/main/java/com/cleanroommc/groovyscript/documentation/format/IFormat.java index 1ed8efc3f..f8a8c878f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/format/IFormat.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/format/IFormat.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.documentation.format; -import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; - import java.util.List; +import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; + /** * An interface that adds the required methods for a format to operate properly. - * This is intended to be a private interface for GroovyScript to generate its documentation, and may be subject to sudden changes. + * This is intended to be a private interface for GroovyScript to generate its documentation, and may be subject to sudden + * changes. *

* This uses {@link OutputFormat} to register the format types. */ @@ -18,7 +19,8 @@ public interface IFormat { String linkToBuilder(); /** - * @param format what admonition format is being used, which controls if the box is static or expandable, and if it is expanded by default or not + * @param format what admonition format is being used, which controls if the box is static or expandable, and if it is + * expanded by default or not * @param type what color and symbol are used, and the fallback title if none is specified * @param indentation how much indentation is used * @param title the title of the admonition, if defined. otherwise, defaults to the type @@ -45,7 +47,8 @@ public interface IFormat { String removeTableOfContentsText(); /** - * @return if the format has a title template, which allows customizing additional values for the tab title without impacting the page title or navigation + * @return if the format has a title template, which allows customizing additional values for the tab title without impacting + * the page title or navigation */ boolean hasTitleTemplate(); diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/format/MKDocsMaterial.java b/src/main/java/com/cleanroommc/groovyscript/documentation/format/MKDocsMaterial.java index 35b18d8b6..86e7d96d9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/format/MKDocsMaterial.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/format/MKDocsMaterial.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.documentation.format; -import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; -import com.google.common.collect.Lists; -import org.apache.commons.lang3.StringUtils; - import java.util.List; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; + +import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; +import com.google.common.collect.Lists; + public class MKDocsMaterial implements IFormat { @Override diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/format/OutputFormat.java b/src/main/java/com/cleanroommc/groovyscript/documentation/format/OutputFormat.java index 6338088c3..6ce6f5943 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/format/OutputFormat.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/format/OutputFormat.java @@ -6,7 +6,6 @@ public class OutputFormat { public static final MKDocsMaterial MKDOCS_MATERIAL = new MKDocsMaterial(); public static final VitePress VITEPRESS = new VitePress(); - private OutputFormat() { - } + private OutputFormat() {} } diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/format/VitePress.java b/src/main/java/com/cleanroommc/groovyscript/documentation/format/VitePress.java index 3d1f31fad..60aa282e1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/format/VitePress.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/format/VitePress.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.documentation.format; -import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; -import com.google.common.collect.Lists; -import org.apache.commons.lang3.StringUtils; - import java.util.List; import java.util.Locale; import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; + +import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; +import com.google.common.collect.Lists; + public class VitePress implements IFormat { @Override diff --git a/src/main/java/com/cleanroommc/groovyscript/event/EventBusType.java b/src/main/java/com/cleanroommc/groovyscript/event/EventBusType.java index b46cbc6c0..245b319a0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/event/EventBusType.java +++ b/src/main/java/com/cleanroommc/groovyscript/event/EventBusType.java @@ -2,9 +2,7 @@ public enum EventBusType { - MAIN, - FORGE, // Unused right now, priming for @EventHandler - ORE_GENERATION, - TERRAIN_GENERATION + MAIN, FORGE, // Unused right now, priming for @EventHandler + ORE_GENERATION, TERRAIN_GENERATION } diff --git a/src/main/java/com/cleanroommc/groovyscript/event/EventHandler.java b/src/main/java/com/cleanroommc/groovyscript/event/EventHandler.java index f768bfcaa..818083760 100644 --- a/src/main/java/com/cleanroommc/groovyscript/event/EventHandler.java +++ b/src/main/java/com/cleanroommc/groovyscript/event/EventHandler.java @@ -1,24 +1,9 @@ package com.cleanroommc.groovyscript.event; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.command.CustomClickAction; -import com.cleanroommc.groovyscript.compat.WarningScreen; -import com.cleanroommc.groovyscript.compat.content.GroovyBlock; -import com.cleanroommc.groovyscript.compat.content.GroovyFluid; -import com.cleanroommc.groovyscript.compat.content.GroovyItem; -import com.cleanroommc.groovyscript.compat.vanilla.CraftingInfo; -import com.cleanroommc.groovyscript.compat.vanilla.ICraftingRecipe; -import com.cleanroommc.groovyscript.compat.vanilla.Player; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; -import com.cleanroommc.groovyscript.core.mixin.InventoryCraftingAccess; -import com.cleanroommc.groovyscript.core.mixin.SlotCraftingAccess; -import com.cleanroommc.groovyscript.network.NetworkHandler; -import com.cleanroommc.groovyscript.network.SReloadScripts; -import com.cleanroommc.groovyscript.packmode.Packmode; -import com.cleanroommc.groovyscript.packmode.PackmodeSaveData; -import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import groovy.lang.Closure; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.entity.Entity; @@ -46,9 +31,26 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.command.CustomClickAction; +import com.cleanroommc.groovyscript.compat.WarningScreen; +import com.cleanroommc.groovyscript.compat.content.GroovyBlock; +import com.cleanroommc.groovyscript.compat.content.GroovyFluid; +import com.cleanroommc.groovyscript.compat.content.GroovyItem; +import com.cleanroommc.groovyscript.compat.vanilla.CraftingInfo; +import com.cleanroommc.groovyscript.compat.vanilla.ICraftingRecipe; +import com.cleanroommc.groovyscript.compat.vanilla.Player; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; +import com.cleanroommc.groovyscript.core.mixin.InventoryCraftingAccess; +import com.cleanroommc.groovyscript.core.mixin.SlotCraftingAccess; +import com.cleanroommc.groovyscript.network.NetworkHandler; +import com.cleanroommc.groovyscript.network.SReloadScripts; +import com.cleanroommc.groovyscript.packmode.Packmode; +import com.cleanroommc.groovyscript.packmode.PackmodeSaveData; +import com.cleanroommc.groovyscript.sandbox.ClosureHelper; + +import groovy.lang.Closure; public class EventHandler { @@ -64,16 +66,14 @@ public static void registerBlocks(RegistryEvent.Register event) { GroovyFluid.initBlocks(event.getRegistry()); } - @SubscribeEvent - @SideOnly(Side.CLIENT) + @SubscribeEvent @SideOnly(Side.CLIENT) public static void registerModels(ModelRegistryEvent event) { GroovyItem.registerModels(); GroovyBlock.registerModels(); GroovyFluid.registerModels(); } - @SubscribeEvent - @SideOnly(Side.CLIENT) + @SubscribeEvent @SideOnly(Side.CLIENT) public static void registerTextures(TextureStitchEvent.Post event) { GroovyFluid.initTextures(event.getMap()); } @@ -90,7 +90,8 @@ public static void playerLogin(PlayerEvent.PlayerLoggedInEvent event) { PackmodeSaveData saveData = PackmodeSaveData.get(event.player.world); if (Packmode.hasPackmode() && saveData.isDedicatedServer()) { // if the world is a dedicated server or a lan server the packmode should be synced with each player - NetworkHandler.sendToPlayer(new SReloadScripts(saveData.getPackmode(), true, true), (EntityPlayerMP) event.player); + NetworkHandler.sendToPlayer(new SReloadScripts(saveData.getPackmode(), true, true), + (EntityPlayerMP) event.player); } else if (!Packmode.getPackmode().equals(saveData.getPackmode()) && !saveData.isDedicatedServer()) { // otherwise we are on a single player world, and we can just set and reload the packmode SReloadScripts.updatePackmode(event.player, saveData.getPackmode()); @@ -111,11 +112,11 @@ public static void playerLogin(PlayerEvent.PlayerLoggedInEvent event) { } } - @SubscribeEvent - @SideOnly(Side.CLIENT) + @SubscribeEvent @SideOnly(Side.CLIENT) public static void onClientChatEvent(ClientChatEvent event) { - if (event.getOriginalMessage().startsWith(CustomClickAction.PREFIX) && - CustomClickAction.runActionHook(event.getOriginalMessage().substring(CustomClickAction.PREFIX.length()))) { + if (event.getOriginalMessage().startsWith(CustomClickAction.PREFIX) && CustomClickAction.runActionHook(event + .getOriginalMessage() + .substring(CustomClickAction.PREFIX.length()))) { event.setCanceled(true); } } @@ -164,8 +165,7 @@ public static void onConfigChange(ConfigChangedEvent.OnConfigChangedEvent event) } } - @SubscribeEvent(priority = EventPriority.LOWEST) - @SideOnly(Side.CLIENT) + @SubscribeEvent(priority = EventPriority.LOWEST) @SideOnly(Side.CLIENT) public static void onGuiOpen(GuiOpenEvent event) { if (event.getGui() instanceof GuiMainMenu && !WarningScreen.wasOpened) { WarningScreen.wasOpened = true; diff --git a/src/main/java/com/cleanroommc/groovyscript/event/GroovyEventManager.java b/src/main/java/com/cleanroommc/groovyscript/event/GroovyEventManager.java index f6bff9f0d..7b53b34db 100644 --- a/src/main/java/com/cleanroommc/groovyscript/event/GroovyEventManager.java +++ b/src/main/java/com/cleanroommc/groovyscript/event/GroovyEventManager.java @@ -1,19 +1,21 @@ package com.cleanroommc.groovyscript.event; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.eventhandler.*; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.sandbox.ClosureHelper; import com.cleanroommc.groovyscript.sandbox.LoadStage; -import groovy.lang.Closure; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.eventhandler.*; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; +import groovy.lang.Closure; public enum GroovyEventManager { @@ -72,12 +74,14 @@ public void listen(EventBusType eventBusType, Class eventClass, listen(EventPriority.NORMAL, eventBusType, eventClass, eventListener); } - public void listen(EventPriority priority, EventBusType eventBusType, Class eventClass, Closure eventListener) { + public void listen(EventPriority priority, EventBusType eventBusType, Class eventClass, + Closure eventListener) { listen(priority, eventBusType, eventClass, event -> ClosureHelper.call(eventListener, event)); } @GroovyBlacklist - public void listen(EventPriority priority, EventBusType eventBusType, Class eventClass, Consumer eventListener) { + public void listen(EventPriority priority, EventBusType eventBusType, Class eventClass, + Consumer eventListener) { EventListener listener = new EventListener(eventBusType, priority, eventClass, eventListener); LoadStage loadStage = GroovyScript.getSandbox().getCurrentLoader(); if (loadStage != null && loadStage.isReloadable()) { diff --git a/src/main/java/com/cleanroommc/groovyscript/event/GroovyReloadEvent.java b/src/main/java/com/cleanroommc/groovyscript/event/GroovyReloadEvent.java index e22b63325..417ff863b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/event/GroovyReloadEvent.java +++ b/src/main/java/com/cleanroommc/groovyscript/event/GroovyReloadEvent.java @@ -6,5 +6,4 @@ * This event is invoked right after groovy is reloaded internally and right before scripts are being run. * Is not calling on first load! */ -public class GroovyReloadEvent extends Event { -} +public class GroovyReloadEvent extends Event {} diff --git a/src/main/java/com/cleanroommc/groovyscript/event/GsHandEvent.java b/src/main/java/com/cleanroommc/groovyscript/event/GsHandEvent.java index d280c4808..69ff7c277 100644 --- a/src/main/java/com/cleanroommc/groovyscript/event/GsHandEvent.java +++ b/src/main/java/com/cleanroommc/groovyscript/event/GsHandEvent.java @@ -1,5 +1,7 @@ package com.cleanroommc.groovyscript.event; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; @@ -8,11 +10,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.common.eventhandler.Event; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; - /** * Called when /gs hand is executed */ @@ -62,12 +63,8 @@ public class GsHandEvent extends Event { @Nullable public final TileEntity tileEntity; - public GsHandEvent(@NotNull MinecraftServer server, - @NotNull EntityPlayer player, - String[] commandArgs, - @NotNull List messages, - @NotNull ItemStack stack, - @Nullable IBlockState blockState, + public GsHandEvent(@NotNull MinecraftServer server, @NotNull EntityPlayer player, String[] commandArgs, + @NotNull List messages, @NotNull ItemStack stack, @Nullable IBlockState blockState, @Nullable Block block, @Nullable TileEntity tileEntity) { this.server = server; this.player = player; diff --git a/src/main/java/com/cleanroommc/groovyscript/event/LootTablesLoadedEvent.java b/src/main/java/com/cleanroommc/groovyscript/event/LootTablesLoadedEvent.java index 7531c4cb7..62ac9fff9 100644 --- a/src/main/java/com/cleanroommc/groovyscript/event/LootTablesLoadedEvent.java +++ b/src/main/java/com/cleanroommc/groovyscript/event/LootTablesLoadedEvent.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.event; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.storage.loot.LootPool; +import net.minecraft.world.storage.loot.LootTable; +import net.minecraft.world.storage.loot.conditions.LootCondition; +import net.minecraftforge.fml.common.eventhandler.Event; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.compat.loot.GroovyLootCondition; import com.cleanroommc.groovyscript.compat.loot.GroovyLootFunction; @@ -8,12 +14,8 @@ import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.core.mixin.loot.LootPoolAccessor; import com.cleanroommc.groovyscript.core.mixin.loot.LootTableAccessor; + import groovy.lang.Closure; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.loot.LootPool; -import net.minecraft.world.storage.loot.LootTable; -import net.minecraft.world.storage.loot.conditions.LootCondition; -import net.minecraftforge.fml.common.eventhandler.Event; public class LootTablesLoadedEvent extends Event { @@ -44,8 +46,7 @@ public LootEntryBuilder entryBuilder() { public void printTables() { GroovyLog.Msg out = GroovyLog.msg("GroovyScript found the following LootTable(s)"); VanillaModule.loot.tables.keySet().forEach(table -> out.add(table.toString())); - if (!out.postIfNotEmpty()) - GroovyLog.msg("GroovyScript found 0 LootTables :thonk:").error().post(); + if (!out.postIfNotEmpty()) GroovyLog.msg("GroovyScript found 0 LootTables :thonk:").error().post(); } public void printPools() { @@ -73,8 +74,7 @@ public void printPools(String tableName) { GroovyLog.Msg out = GroovyLog.msg("GroovyScript found the following LootPools(s)"); out.add(tableName); ((LootTableAccessor) table).getPools().forEach(pool -> out.add("\t - " + pool.getName())); - if (!out.postIfNotEmpty()) - GroovyLog.msg("GroovyScript found 0 LootPools in " + tableName).error().post(); + if (!out.postIfNotEmpty()) GroovyLog.msg("GroovyScript found 0 LootPools in " + tableName).error().post(); } public void printEntries() { @@ -113,8 +113,7 @@ public void printEntries(String tableName) { out.add("\t - " + pool.getName()); ((LootPoolAccessor) pool).getLootEntries().forEach(entry -> out.add("\t\t - " + entry.getEntryName())); }); - if (!out.postIfNotEmpty()) - GroovyLog.msg("GroovyScript found 0 LootEntries in LootTable " + tableName).error().post(); + if (!out.postIfNotEmpty()) GroovyLog.msg("GroovyScript found 0 LootEntries in LootTable " + tableName).error().post(); } public void printEntries(String tableName, String poolName) { @@ -130,8 +129,7 @@ public void printEntries(String tableName, String poolName) { out.add(tableName); out.add("\t - " + poolName); ((LootPoolAccessor) pool).getLootEntries().forEach(entry -> out.add("\t\t - " + entry.getEntryName())); - if (!out.postIfNotEmpty()) - GroovyLog.msg("GroovyScript found 0 LootEntries in LootPool " + poolName).error().post(); + if (!out.postIfNotEmpty()) GroovyLog.msg("GroovyScript found 0 LootEntries in LootPool " + poolName).error().post(); } public GroovyLootFunction function(Closure function) { diff --git a/src/main/java/com/cleanroommc/groovyscript/event/ScriptRunEvent.java b/src/main/java/com/cleanroommc/groovyscript/event/ScriptRunEvent.java index 8e89f0a19..f383680cf 100644 --- a/src/main/java/com/cleanroommc/groovyscript/event/ScriptRunEvent.java +++ b/src/main/java/com/cleanroommc/groovyscript/event/ScriptRunEvent.java @@ -1,8 +1,9 @@ package com.cleanroommc.groovyscript.event; -import com.cleanroommc.groovyscript.sandbox.LoadStage; import net.minecraftforge.fml.common.eventhandler.Event; +import com.cleanroommc.groovyscript.sandbox.LoadStage; + public class ScriptRunEvent extends Event { private final LoadStage loadStage; @@ -11,9 +12,7 @@ public ScriptRunEvent(LoadStage loadStage) { this.loadStage = loadStage; } - public LoadStage getLoadStage() { - return loadStage; - } + public LoadStage getLoadStage() { return loadStage; } /** * Called before anything on script run (first load and reload) diff --git a/src/main/java/com/cleanroommc/groovyscript/gameobjects/Completer.java b/src/main/java/com/cleanroommc/groovyscript/gameobjects/Completer.java index 165e6e968..57df7cf36 100644 --- a/src/main/java/com/cleanroommc/groovyscript/gameobjects/Completer.java +++ b/src/main/java/com/cleanroommc/groovyscript/gameobjects/Completer.java @@ -1,15 +1,13 @@ package com.cleanroommc.groovyscript.gameobjects; +import java.util.function.Function; +import java.util.function.Supplier; + import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.CompletionItemKind; import org.jetbrains.annotations.ApiStatus; -import java.util.function.Function; -import java.util.function.Supplier; - -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") -@FunctionalInterface +@Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") @FunctionalInterface public interface Completer extends com.cleanroommc.groovyscript.mapper.Completer { static Completer ofNamed(Supplier> values, Function toString, int preferredParamIndex) { @@ -24,7 +22,8 @@ static Completer ofNamed(Supplier> values, Function t }, preferredParamIndex); } - static Completer ofValues(Supplier> values, Function toCompletionItem, int preferredParamIndex) { + static Completer ofValues(Supplier> values, Function toCompletionItem, + int preferredParamIndex) { return (paramIndex, items) -> { if (preferredParamIndex < 0 || preferredParamIndex == paramIndex) { items.addAll(values.get(), toCompletionItem); diff --git a/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandler.java b/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandler.java index 63accdd2d..3fcb8fda4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandler.java +++ b/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandler.java @@ -1,21 +1,22 @@ package com.cleanroommc.groovyscript.gameobjects; +import java.util.function.Function; +import java.util.function.Supplier; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.registries.IForgeRegistry; +import net.minecraftforge.registries.IForgeRegistryEntry; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.api.IGameObjectParser; import com.cleanroommc.groovyscript.api.IObjectParser; import com.cleanroommc.groovyscript.api.Result; import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; import com.cleanroommc.groovyscript.mapper.Completer; import com.cleanroommc.groovyscript.mapper.ObjectMapper; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.IForgeRegistryEntry; -import org.jetbrains.annotations.ApiStatus; - -import java.util.function.Function; -import java.util.function.Supplier; -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") +@Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") public class GameObjectHandler { @ApiStatus.Internal diff --git a/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandlerManager.java b/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandlerManager.java index fde76dc38..dbfbeb894 100644 --- a/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandlerManager.java +++ b/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandlerManager.java @@ -1,22 +1,21 @@ package com.cleanroommc.groovyscript.gameobjects; -import com.cleanroommc.groovyscript.mapper.ObjectMapper; -import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; -import com.cleanroommc.groovyscript.server.Completions; +import java.util.Collection; +import java.util.List; + import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.List; +import com.cleanroommc.groovyscript.mapper.ObjectMapper; +import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; +import com.cleanroommc.groovyscript.server.Completions; -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") +@Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") public class GameObjectHandlerManager { public static final String EMPTY = "empty", WILDCARD = "*", SPLITTER = ":"; - public static void init() { - } + public static void init() {} @Nullable public static Object getGameObject(String name, String mainArg, Object... args) { @@ -39,9 +38,7 @@ public static ObjectMapper getGameObjectHandler(Class containerClass, Stri return ObjectMapperManager.getObjectMapper(containerClass, key); } - public static Collection> getGameObjectHandlers() { - return ObjectMapperManager.getObjectMappers(); - } + public static Collection> getGameObjectHandlers() { return ObjectMapperManager.getObjectMappers(); } public static Class getReturnTypeOf(String name) { return ObjectMapperManager.getReturnTypeOf(name); diff --git a/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandlers.java b/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandlers.java index fde0d50ce..849ea1c1b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandlers.java +++ b/src/main/java/com/cleanroommc/groovyscript/gameobjects/GameObjectHandlers.java @@ -1,9 +1,8 @@ package com.cleanroommc.groovyscript.gameobjects; -import com.cleanroommc.groovyscript.mapper.ObjectMappers; import org.jetbrains.annotations.ApiStatus; -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") -public class GameObjectHandlers extends ObjectMappers { -} +import com.cleanroommc.groovyscript.mapper.ObjectMappers; + +@Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") +public class GameObjectHandlers extends ObjectMappers {} diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/Alias.java b/src/main/java/com/cleanroommc/groovyscript/helper/Alias.java index 30c7846a9..c0d2d3b70 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/Alias.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/Alias.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.helper; -import com.google.common.base.CaseFormat; -import org.jetbrains.annotations.NotNull; - import java.util.*; import java.util.regex.Pattern; +import org.jetbrains.annotations.NotNull; + +import com.google.common.base.CaseFormat; + public class Alias extends ArrayList { public Alias and(Collection c) { diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ArrayUtils.java b/src/main/java/com/cleanroommc/groovyscript/helper/ArrayUtils.java index f4c7954a6..5dfd796f1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ArrayUtils.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ArrayUtils.java @@ -1,14 +1,14 @@ package com.cleanroommc.groovyscript.helper; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.function.Function; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + public class ArrayUtils { public static T[] map(V[] array, Function function, T[] newArray) { @@ -104,9 +104,7 @@ public static T[][] deepCopy2d(@NotNull T[][] src, @Nullable T[][] dest) { } public static T[] copy1d(@NotNull T[] src, @Nullable T[] dest) { - if (dest == null || dest.length < src.length) { - return Arrays.copyOf(src, src.length); - } + if (dest == null || dest.length < src.length) { return Arrays.copyOf(src, src.length); } System.arraycopy(src, 0, dest, 0, src.length); return dest; } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/BetterList.java b/src/main/java/com/cleanroommc/groovyscript/helper/BetterList.java index 520e9cc8b..eb21e4466 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/BetterList.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/BetterList.java @@ -1,9 +1,9 @@ package com.cleanroommc.groovyscript.helper; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; - import java.util.Objects; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; + public class BetterList extends ObjectArrayList { public void addFirst(K k) { @@ -30,13 +30,9 @@ public K pollLast() { return isEmpty() ? null : removeLast(); } - public K getFirst() { - return get(0); - } + public K getFirst() { return get(0); } - public K getLast() { - return get(size() - 1); - } + public K getLast() { return get(size() - 1); } public K peekFirst() { return isEmpty() ? null : get(0); diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/EnumHelper.java b/src/main/java/com/cleanroommc/groovyscript/helper/EnumHelper.java index 4d2c90cb1..c0c45ead7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/EnumHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/EnumHelper.java @@ -1,12 +1,14 @@ package com.cleanroommc.groovyscript.helper; -import com.cleanroommc.groovyscript.api.IObjectParser; -import com.cleanroommc.groovyscript.api.Result; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import java.util.Map; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Map; +import com.cleanroommc.groovyscript.api.IObjectParser; +import com.cleanroommc.groovyscript.api.Result; + +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; public class EnumHelper { diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/GroovyFile.java b/src/main/java/com/cleanroommc/groovyscript/helper/GroovyFile.java index 411da0f54..f6f04eb92 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/GroovyFile.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/GroovyFile.java @@ -1,25 +1,28 @@ package com.cleanroommc.groovyscript.helper; +import java.io.*; +import java.net.URI; +import java.util.List; +import java.util.Map; + +import net.minecraftforge.fml.relauncher.FMLLaunchHandler; + +import org.codehaus.groovy.runtime.DefaultGroovyMethods; +import org.codehaus.groovy.runtime.IOGroovyMethods; +import org.codehaus.groovy.runtime.ResourceGroovyMethods; +import org.jetbrains.annotations.NotNull; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.sandbox.FileUtil; import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; + import groovy.io.FileType; import groovy.lang.Closure; import groovy.transform.NamedParam; import groovy.transform.stc.ClosureParams; import groovy.transform.stc.SimpleType; -import net.minecraftforge.fml.relauncher.FMLLaunchHandler; -import org.codehaus.groovy.runtime.DefaultGroovyMethods; -import org.codehaus.groovy.runtime.IOGroovyMethods; -import org.codehaus.groovy.runtime.ResourceGroovyMethods; -import org.jetbrains.annotations.NotNull; - -import java.io.*; -import java.net.URI; -import java.util.List; -import java.util.Map; /** * Ad file wrapper which resolves its path to minecraft home and checks if the file really is in minecraft home. @@ -82,38 +85,27 @@ public GroovyFile(String... parts) { this(new File(FileUtil.makePath(parts))); } - public boolean isInvalid() { - return this.internal == INVALID; - } + public boolean isInvalid() { return this.internal == INVALID; } - public boolean isAccessible() { - return accessible; - } + public boolean isAccessible() { return accessible; } public void checkAccessible() { - if (isInvalid()) { - throw new IllegalStateException("Can't access a file which failed to resolve."); - } + if (isInvalid()) { throw new IllegalStateException("Can't access a file which failed to resolve."); } if (!this.accessible) { - throw new SecurityException("Only files in minecraft home and sub directories can be accessed from scripts! Tried to access " + this.internal.getPath()); + throw new SecurityException("Only files in minecraft home and sub directories can be accessed from scripts! Tried to access " + + this.internal.getPath()); } } - public String getPath() { - return this.internal.getPath(); - } + public String getPath() { return this.internal.getPath(); } public boolean exists() { return this.internal.exists(); } - public boolean isFile() { - return this.internal.isFile(); - } + public boolean isFile() { return this.internal.isFile(); } - public boolean isDirectory() { - return this.internal.isDirectory(); - } + public boolean isDirectory() { return this.internal.isDirectory(); } public boolean canRead() { return isAccessible() && this.internal.canRead(); @@ -167,9 +159,7 @@ public boolean mkdirs() { return this.internal.mkdirs(); } - public String getCanonicalPath() { - return getPath(); - } + public String getCanonicalPath() { return getPath(); } public GroovyFile getCanonicalFile() { return this; // is already canonical @@ -185,9 +175,7 @@ public boolean equals(Object obj) { if (obj.getClass() == GroovyFile.class) { return isInvalid() == ((GroovyFile) obj).isInvalid() || this.internal.equals(((GroovyFile) obj).internal); } - if (obj instanceof File file) { - return !isInvalid() && this.internal.equals(file); - } + if (obj instanceof File file) { return !isInvalid() && this.internal.equals(file); } return false; } @@ -248,7 +236,8 @@ public BufferedReader newReader(String charset) throws FileNotFoundException, Un * @return the value returned by the closure * @throws IOException if an IOException occurs. */ - public T withReader(@ClosureParams(value = SimpleType.class, options = "java.io.BufferedReader") Closure closure) throws IOException { + public T withReader(@ClosureParams(value = SimpleType.class, options = "java.io.BufferedReader") Closure closure) + throws IOException { checkAccessible(); return ResourceGroovyMethods.withReader(this.internal, "UTF-8", closure); } @@ -263,8 +252,8 @@ public T withReader(@ClosureParams(value = SimpleType.class, options = "java * @return the value returned by the closure * @throws IOException if an IOException occurs. */ - public T withReader(String charset, - @ClosureParams(value = SimpleType.class, options = "java.io.BufferedReader") Closure closure) throws IOException { + public T withReader(String charset, @ClosureParams(value = SimpleType.class, + options = "java.io.BufferedReader") Closure closure) throws IOException { checkAccessible(); return ResourceGroovyMethods.withReader(this.internal, charset, closure); } @@ -289,7 +278,8 @@ public BufferedOutputStream newOutputStream() throws IOException { * @throws IOException if an IOException occurs. * @see IOGroovyMethods#withStream(java.io.OutputStream, groovy.lang.Closure) */ - public Object withOutputStream(@ClosureParams(value = SimpleType.class, options = "java.io.OutputStream") Closure closure) throws IOException { + public Object withOutputStream(@ClosureParams(value = SimpleType.class, options = "java.io.OutputStream") Closure closure) + throws IOException { checkAccessible(); return ResourceGroovyMethods.withOutputStream(this.internal, closure); } @@ -303,7 +293,8 @@ public Object withOutputStream(@ClosureParams(value = SimpleType.class, options * @throws IOException if an IOException occurs. * @see IOGroovyMethods#withStream(java.io.InputStream, groovy.lang.Closure) */ - public Object withInputStream(@ClosureParams(value = SimpleType.class, options = "java.io.InputStream") Closure closure) throws IOException { + public Object withInputStream(@ClosureParams(value = SimpleType.class, options = "java.io.InputStream") Closure closure) + throws IOException { checkAccessible(); return ResourceGroovyMethods.withInputStream(this.internal, closure); } @@ -367,7 +358,8 @@ public BufferedWriter newWriter(String charset) throws IOException { * @return the value returned by the closure * @throws IOException if an IOException occurs. */ - public T withWriter(@ClosureParams(value = SimpleType.class, options = "java.io.BufferedWriter") Closure closure) throws IOException { + public T withWriter(@ClosureParams(value = SimpleType.class, options = "java.io.BufferedWriter") Closure closure) + throws IOException { checkAccessible(); return ResourceGroovyMethods.withWriter(this.internal, "UTF-8", closure); } @@ -375,7 +367,7 @@ public T withWriter(@ClosureParams(value = SimpleType.class, options = "java /** * Creates a new BufferedWriter for this file, passes it to the closure, and * ensures the stream is flushed and closed after the closure returns. - * The writer will use the given charset encoding. If the given charset is + * The writer will use the given charset encoding. If the given charset is * "UTF-16BE" or "UTF-16LE" (or an equivalent alias), the requisite byte * order mark is written to the stream when the writer is created. * @@ -384,17 +376,17 @@ public T withWriter(@ClosureParams(value = SimpleType.class, options = "java * @return the value returned by the closure * @throws IOException if an IOException occurs. */ - public T withWriter(String charset, - @ClosureParams(value = SimpleType.class, options = "java.io.BufferedWriter") Closure closure) throws IOException { + public T withWriter(String charset, @ClosureParams(value = SimpleType.class, + options = "java.io.BufferedWriter") Closure closure) throws IOException { checkAccessible(); return ResourceGroovyMethods.withWriter(this.internal, charset, closure); } /** - * Create a new BufferedWriter which will append to this file. If the + * Create a new BufferedWriter which will append to this file. If the * given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias), the * requisite byte order mark is written to the stream when the writer is - * created. The writer is passed to the closure and will be closed before + * created. The writer is passed to the closure and will be closed before * this method returns. * * @param charset the charset used @@ -402,21 +394,22 @@ public T withWriter(String charset, * @return the value returned by the closure * @throws IOException if an IOException occurs. */ - public T withWriterAppend(String charset, - @ClosureParams(value = SimpleType.class, options = "java.io.BufferedWriter") Closure closure) throws IOException { + public T withWriterAppend(String charset, @ClosureParams(value = SimpleType.class, + options = "java.io.BufferedWriter") Closure closure) throws IOException { checkAccessible(); return ResourceGroovyMethods.withWriterAppend(this.internal, charset, closure); } /** - * Create a new BufferedWriter for this file in append mode. The writer + * Create a new BufferedWriter for this file in append mode. The writer * is passed to the closure and is closed after the closure returns. * * @param closure a closure * @return the value returned by the closure * @throws IOException if an IOException occurs. */ - public T withWriterAppend(@ClosureParams(value = SimpleType.class, options = "java.io.BufferedWriter") Closure closure) throws IOException { + public T withWriterAppend(@ClosureParams(value = SimpleType.class, options = "java.io.BufferedWriter") Closure closure) + throws IOException { checkAccessible(); return ResourceGroovyMethods.withWriterAppend(this.internal, "UTF-8", closure); } @@ -589,7 +582,7 @@ public File leftShift(byte[] bytes) throws IOException { } /** - * Append binary data to the file. See {@link ResourceGroovyMethods#append(java.io.File, java.io.InputStream)} + * Append binary data to the file. See {@link ResourceGroovyMethods#append(java.io.File, java.io.InputStream)} * * @param data an InputStream of data to write to the file * @return the file @@ -647,7 +640,7 @@ public void append(Writer writer) throws IOException { } /** - * Append bytes to the end of a File. It will not be + * Append bytes to the end of a File. It will not be * interpreted as text. * * @param bytes the byte array to append to the end of the File @@ -659,7 +652,7 @@ public void append(byte[] bytes) throws IOException { } /** - * Append binary data to the file. It will not be + * Append binary data to the file. It will not be * interpreted as text. * * @param stream stream to read data from. @@ -719,11 +712,12 @@ public void append(Reader reader, String charset) throws IOException { * @throws FileNotFoundException if the given directory does not exist * @throws IllegalArgumentException if the provided File object does not represent a directory */ - public void eachFile(final FileType fileType, @ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure) - throws FileNotFoundException, IllegalArgumentException { + public void eachFile(final FileType fileType, @ClosureParams(value = SimpleType.class, + options = "java.io.File") final Closure closure) throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.eachFile(this.internal, fileType, wrapped); } @@ -737,11 +731,12 @@ public void eachFile(final FileType fileType, @ClosureParams(value = SimpleType. * @see java.io.File#listFiles() * @see ResourceGroovyMethods#eachFile(java.io.File, groovy.io.FileType, groovy.lang.Closure) */ - public void eachFile(@ClosureParams(value = SimpleType.class, options = "java.io.File") - final Closure closure) throws FileNotFoundException, IllegalArgumentException { + public void eachFile(@ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure) + throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.eachFile(this.internal, wrapped); } @@ -755,11 +750,12 @@ public void eachFile(@ClosureParams(value = SimpleType.class, options = "java.io * @see java.io.File#listFiles() * @see ResourceGroovyMethods#eachFile(java.io.File, groovy.io.FileType, groovy.lang.Closure) */ - public void eachDir( - @ClosureParams(value = SimpleType.class, options = "java.io.File") Closure closure) throws FileNotFoundException, IllegalArgumentException { + public void eachDir(@ClosureParams(value = SimpleType.class, options = "java.io.File") Closure closure) + throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.eachDir(this.internal, wrapped); } @@ -775,11 +771,12 @@ public void eachDir( * @throws FileNotFoundException if the given directory does not exist * @throws IllegalArgumentException if the provided File object does not represent a directory */ - public void eachFileRecurse(final FileType fileType, @ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure) - throws FileNotFoundException, IllegalArgumentException { + public void eachFileRecurse(final FileType fileType, @ClosureParams(value = SimpleType.class, + options = "java.io.File") final Closure closure) throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.eachFileRecurse(this.internal, fileType, wrapped); } @@ -792,25 +789,32 @@ public void eachFileRecurse(final FileType fileType, @ClosureParams(value = Simp * The traversal can be adapted by providing various options in the options Map according * to the following keys:
*
type
A {@link groovy.io.FileType} enum to determine if normal files or directories or both are processed
- *
preDir
A {@link groovy.lang.Closure} run before each directory is processed and optionally returning a {@link groovy.io.FileVisitResult} value + *
preDir
A {@link groovy.lang.Closure} run before each directory is processed and optionally returning a + * {@link groovy.io.FileVisitResult} value * which can be used to control subsequent processing.
*
preRoot
A boolean indicating that the 'preDir' closure should be applied at the root level
- *
postDir
A {@link groovy.lang.Closure} run after each directory is processed and optionally returning a {@link groovy.io.FileVisitResult} value + *
postDir
A {@link groovy.lang.Closure} run after each directory is processed and optionally returning a + * {@link groovy.io.FileVisitResult} value * which can be used to control subsequent processing. Particularly useful when strict depth-first traversal is required.
*
postRoot
A boolean indicating that the 'postDir' closure should be applied at the root level
*
visitRoot
A boolean indicating that the given closure should be applied for the root dir * (not applicable if the 'type' is set to {@link groovy.io.FileType#FILES})
*
maxDepth
The maximum number of directory levels when recursing * (default is -1 which means infinite, set to 0 for no recursion)
- *
filter
A filter to perform on traversed files/directories (using the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method). If set, + *
filter
A filter to perform on traversed files/directories (using the + * {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method). If set, * only files/dirs which match are candidates for visiting.
- *
nameFilter
A filter to perform on the name of traversed files/directories (using the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method). If set, + *
nameFilter
A filter to perform on the name of traversed files/directories (using the + * {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method). If set, * only files/dirs which match are candidates for visiting. (Must not be set if 'filter' is set)
- *
excludeFilter
A filter to perform on traversed files/directories (using the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method). + *
excludeFilter
A filter to perform on traversed files/directories (using the + * {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method). * If set, any candidates which match won't be visited.
- *
excludeNameFilter
A filter to perform on the names of traversed files/directories (using the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method). + *
excludeNameFilter
A filter to perform on the names of traversed files/directories (using the + * {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method). * If set, any candidates which match won't be visited. (Must not be set if 'excludeFilter' is set)
- *
sort
A {@link groovy.lang.Closure} which if set causes the files and subdirectories for each directory to be processed in sorted order. + *
sort
A {@link groovy.lang.Closure} which if set causes the files and subdirectories for each directory to be + * processed in sorted order. * Note that even when processing only files, the order of visited subdirectories will be affected by this parameter.
*
* This example prints out file counts and size aggregates for groovy source files within a directory tree: @@ -818,45 +822,44 @@ public void eachFileRecurse(final FileType fileType, @ClosureParams(value = Simp * def totalSize = 0 * def count = 0 * def sortByTypeThenName = { a, b {@code ->} - * a.isFile() != b.isFile() ? a.isFile() {@code <=>} b.isFile() : a.name {@code <=>} b.name + * a.isFile() != b.isFile() ? a.isFile() {@code <=>} b.isFile() : a.name {@code <=>} b.name * } * rootDir.traverse( - * type : FILES, - * nameFilter : ~/.*\.groovy/, - * preDir : { if (it.name == '.svn') return SKIP_SUBTREE }, - * postDir : { println "Found $count files in $it.name totalling $totalSize bytes" - * totalSize = 0; count = 0 }, - * postRoot : true - * sort : sortByTypeThenName + * type : FILES, + * nameFilter : ~/.*\.groovy/, + * preDir : { if (it.name == '.svn') return SKIP_SUBTREE }, + * postDir : { println "Found $count files in $it.name totalling $totalSize bytes" + * totalSize = 0; count = 0 }, + * postRoot : true + * sort : sortByTypeThenName * ) {it {@code ->} totalSize += it.size(); count++ } * * * @param options a Map of options to alter the traversal behavior - * @param closure the Closure to invoke on each file/directory and optionally returning a {@link groovy.io.FileVisitResult} value + * @param closure the Closure to invoke on each file/directory and optionally returning a {@link groovy.io.FileVisitResult} + * value * which can be used to control subsequent processing * @throws FileNotFoundException if the given directory does not exist - * @throws IllegalArgumentException if the provided File object does not represent a directory or illegal filter combinations are supplied + * @throws IllegalArgumentException if the provided File object does not represent a directory or illegal filter combinations + * are supplied * @see DefaultGroovyMethods#sort(Iterable, groovy.lang.Closure) * @see groovy.io.FileVisitResult * @see groovy.io.FileType */ - public void traverse(@NamedParam(value = "type", type = FileType.class) - @NamedParam(value = "preDir", type = Closure.class) - @NamedParam(value = "preRoot", type = Boolean.class) - @NamedParam(value = "postDir", type = Closure.class) - @NamedParam(value = "postRoot", type = Boolean.class) - @NamedParam(value = "visitRoot", type = Boolean.class) - @NamedParam(value = "maxDepth", type = Integer.class) - @NamedParam(value = "filter") - @NamedParam(value = "nameFilter") - @NamedParam(value = "excludeFilter") - @NamedParam(value = "excludeNameFilter") - @NamedParam(value = "sort", type = Closure.class) final Map options, + public void traverse(@NamedParam(value = "type", type = FileType.class) @NamedParam(value = "preDir", + type = Closure.class) @NamedParam(value = "preRoot", + type = Boolean.class) @NamedParam(value = "postDir", + type = Closure.class) @NamedParam(value = "postRoot", + type = Boolean.class) @NamedParam(value = "visitRoot", + type = Boolean.class) @NamedParam(value = "maxDepth", + type = Integer.class) @NamedParam(value = "filter") @NamedParam(value = "nameFilter") @NamedParam(value = "excludeFilter") @NamedParam(value = "excludeNameFilter") @NamedParam(value = "sort", + type = Closure.class) final Map options, @ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure) - throws FileNotFoundException, IllegalArgumentException { + throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.traverse(this.internal, options, wrapped); } @@ -865,17 +868,19 @@ public void traverse(@NamedParam(value = "type", type = FileType.class) * Convenience method for {@link ResourceGroovyMethods#traverse(java.io.File, java.util.Map, groovy.lang.Closure)} when * no options to alter the traversal behavior are required. * - * @param closure the Closure to invoke on each file/directory and optionally returning a {@link groovy.io.FileVisitResult} value + * @param closure the Closure to invoke on each file/directory and optionally returning a {@link groovy.io.FileVisitResult} + * value * which can be used to control subsequent processing * @throws FileNotFoundException if the given directory does not exist * @throws IllegalArgumentException if the provided File object does not represent a directory * @see ResourceGroovyMethods#traverse(java.io.File, java.util.Map, groovy.lang.Closure) */ public void traverse(@ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure) - throws FileNotFoundException, IllegalArgumentException { + throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.traverse(this.internal, wrapped); } @@ -887,22 +892,19 @@ public void traverse(@ClosureParams(value = SimpleType.class, options = "java.io * * @param options a Map of options to alter the traversal behavior * @throws FileNotFoundException if the given directory does not exist - * @throws IllegalArgumentException if the provided File object does not represent a directory or illegal filter combinations are supplied + * @throws IllegalArgumentException if the provided File object does not represent a directory or illegal filter combinations + * are supplied * @see ResourceGroovyMethods#traverse(java.io.File, java.util.Map, groovy.lang.Closure) */ - public void traverse(@NamedParam(value = "type", type = FileType.class) - @NamedParam(value = "preDir", type = Closure.class) - @NamedParam(value = "preRoot", type = Boolean.class) - @NamedParam(value = "postDir", type = Closure.class) - @NamedParam(value = "postRoot", type = Boolean.class) - @NamedParam(value = "visitRoot", type = Boolean.class) - @NamedParam(value = "maxDepth", type = Integer.class) - @NamedParam(value = "filter") - @NamedParam(value = "nameFilter") - @NamedParam(value = "excludeFilter") - @NamedParam(value = "excludeNameFilter") - @NamedParam(value = "sort", type = Closure.class) final Map options) - throws FileNotFoundException, IllegalArgumentException { + public void traverse(@NamedParam(value = "type", type = FileType.class) @NamedParam(value = "preDir", + type = Closure.class) @NamedParam(value = "preRoot", + type = Boolean.class) @NamedParam(value = "postDir", + type = Closure.class) @NamedParam(value = "postRoot", + type = Boolean.class) @NamedParam(value = "visitRoot", + type = Boolean.class) @NamedParam(value = "maxDepth", + type = Integer.class) @NamedParam(value = "filter") @NamedParam(value = "nameFilter") @NamedParam(value = "excludeFilter") @NamedParam(value = "excludeNameFilter") @NamedParam(value = "sort", + type = Closure.class) final Map options) throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); ResourceGroovyMethods.traverse(this.internal, options); } @@ -918,11 +920,12 @@ public void traverse(@NamedParam(value = "type", type = FileType.class) * @throws IllegalArgumentException if the provided File object does not represent a directory * @see ResourceGroovyMethods#eachFileRecurse(java.io.File, groovy.io.FileType, groovy.lang.Closure) */ - public void eachFileRecurse( - @ClosureParams(value = SimpleType.class, options = "java.io.File") Closure closure) throws FileNotFoundException, IllegalArgumentException { + public void eachFileRecurse(@ClosureParams(value = SimpleType.class, options = "java.io.File") Closure closure) + throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.eachFileRecurse(this.internal, wrapped); } @@ -937,18 +940,19 @@ public void eachFileRecurse( * @throws IllegalArgumentException if the provided File object does not represent a directory * @see ResourceGroovyMethods#eachFileRecurse(java.io.File, groovy.io.FileType, groovy.lang.Closure) */ - public void eachDirRecurse( - @ClosureParams(value = SimpleType.class, options = "java.io.File") - final Closure closure) throws FileNotFoundException, IllegalArgumentException { + public void eachDirRecurse(@ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure) + throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.eachDirRecurse(this.internal, wrapped); } /** * Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory - * - calling the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method to determine if a match occurs. This method can be used + * - calling the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method to determine if a match + * occurs. This method can be used * with different kinds of filters like regular expressions, classes, ranges etc. * Both regular files and subdirectories may be candidates for matching depending * on the value of fileType. @@ -958,66 +962,71 @@ public void eachDirRecurse( * def names = [] * baseDir.eachFileMatch FILES, ~/foo\d\.txt/, { names {@code <<} it.name } * assert names == ['foo1.txt', 'foo2.txt'] - * * // remove all *.bak files in baseDir * baseDir.eachFileMatch FILES, ~/.*\.bak/, { File bak {@code ->} bak.delete() } - * * // print out files > 4K in size from baseDir * baseDir.eachFileMatch FILES, { new File(baseDir, it).size() {@code >} 4096 }, { println "$it.name ${it.size()}" } * * * @param fileType whether normal files or directories or both should be processed - * @param nameFilter the filter to perform on the name of the file/directory (using the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method) + * @param nameFilter the filter to perform on the name of the file/directory (using the + * {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method) * @param closure the closure to invoke * @throws FileNotFoundException if the given directory does not exist * @throws IllegalArgumentException if the provided File object does not represent a directory */ - public void eachFileMatch(final FileType fileType, final Object nameFilter, - @ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure) - throws FileNotFoundException, IllegalArgumentException { + public void eachFileMatch(final FileType fileType, final Object nameFilter, @ClosureParams(value = SimpleType.class, + options = "java.io.File") final Closure closure) throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.eachFileMatch(this.internal, fileType, nameFilter, wrapped); } /** * Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory - * - calling the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method to determine if a match occurs. This method can be used + * - calling the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method to determine if a match + * occurs. This method can be used * with different kinds of filters like regular expressions, classes, ranges etc. * Both regular files and subdirectories are matched. * - * @param nameFilter the nameFilter to perform on the name of the file (using the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method) + * @param nameFilter the nameFilter to perform on the name of the file (using the + * {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method) * @param closure the closure to invoke * @throws FileNotFoundException if the given directory does not exist * @throws IllegalArgumentException if the provided File object does not represent a directory * @see ResourceGroovyMethods#eachFileMatch(java.io.File, groovy.io.FileType, java.lang.Object, groovy.lang.Closure) */ - public void eachFileMatch(final Object nameFilter, @ClosureParams(value = SimpleType.class, options = "java.io.File") final Closure closure) - throws FileNotFoundException, IllegalArgumentException { + public void eachFileMatch(final Object nameFilter, @ClosureParams(value = SimpleType.class, + options = "java.io.File") final Closure closure) throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.eachFileMatch(this.internal, nameFilter, wrapped); } /** * Invokes the closure for each subdirectory whose name (dir.name) matches the given nameFilter in the given directory - * - calling the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method to determine if a match occurs. This method can be used + * - calling the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method to determine if a match + * occurs. This method can be used * with different kinds of filters like regular expressions, classes, ranges etc. * Only subdirectories are matched; regular files are ignored. * - * @param nameFilter the nameFilter to perform on the name of the directory (using the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method) + * @param nameFilter the nameFilter to perform on the name of the directory (using the + * {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method) * @param closure the closure to invoke * @throws FileNotFoundException if the given directory does not exist * @throws IllegalArgumentException if the provided File object does not represent a directory * @see ResourceGroovyMethods#eachFileMatch(java.io.File, groovy.io.FileType, java.lang.Object, groovy.lang.Closure) */ - public void eachDirMatch(final Object nameFilter, @ClosureParams(value = SimpleType.class, options = "java.io.File") - final Closure closure) throws FileNotFoundException, IllegalArgumentException { + public void eachDirMatch(final Object nameFilter, @ClosureParams(value = SimpleType.class, + options = "java.io.File") final Closure closure) throws FileNotFoundException, + IllegalArgumentException { checkAccessible(); - Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), - args -> closure.call(new GroovyFile((File) args[0]))); + Closure wrapped = new LambdaClosure<>(closure.getOwner(), closure.getThisObject(), args -> closure.call(new GroovyFile( + (File) args[0]))); ResourceGroovyMethods.eachDirMatch(this.internal, nameFilter, wrapped); } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/GroovyHelper.java b/src/main/java/com/cleanroommc/groovyscript/helper/GroovyHelper.java index 82cfc5362..566b3823c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/GroovyHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/GroovyHelper.java @@ -1,92 +1,60 @@ package com.cleanroommc.groovyscript.helper; +import java.io.File; + +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.packmode.Packmode; import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; import com.cleanroommc.groovyscript.sandbox.LoadStage; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; - -import java.io.File; public class GroovyHelper { @GroovyBlacklist - private GroovyHelper() { - } + private GroovyHelper() {} public static boolean isLoaded(String mod) { return Loader.isModLoaded(mod); } - public static LoadStage getLoadStage() { - return GroovyScript.getSandbox().getCurrentLoader(); - } + public static LoadStage getLoadStage() { return GroovyScript.getSandbox().getCurrentLoader(); } - public static boolean isReloading() { - return getLoadStage().isReloadable() && !ReloadableRegistryManager.isFirstLoad(); - } + public static boolean isReloading() { return getLoadStage().isReloadable() && !ReloadableRegistryManager.isFirstLoad(); } - public static String getMinecraftVersion() { - return GroovyScript.MC_VERSION; - } + public static String getMinecraftVersion() { return GroovyScript.MC_VERSION; } - public static String getGroovyVersion() { - return GroovyScript.GROOVY_VERSION; - } + public static String getGroovyVersion() { return GroovyScript.GROOVY_VERSION; } - public static String getGroovyScriptVersion() { - return GroovyScript.VERSION; - } + public static String getGroovyScriptVersion() { return GroovyScript.VERSION; } - public static String getGrSVersion() { - return GroovyScript.VERSION; - } + public static String getGrSVersion() { return GroovyScript.VERSION; } - public static String getPackName() { - return GroovyScript.getRunConfig().getPackName(); - } + public static String getPackName() { return GroovyScript.getRunConfig().getPackName(); } - public static String getPackId() { - return GroovyScript.getRunConfig().getPackId(); - } + public static String getPackId() { return GroovyScript.getRunConfig().getPackId(); } - public static String getPackVersion() { - return GroovyScript.getRunConfig().getVersion(); - } + public static String getPackVersion() { return GroovyScript.getRunConfig().getVersion(); } - public static boolean isDebug() { - return GroovyScript.getRunConfig().isDebug(); - } + public static boolean isDebug() { return GroovyScript.getRunConfig().isDebug(); } - public static File getConfigDir() { - return Loader.instance().getConfigDir(); - } + public static File getConfigDir() { return Loader.instance().getConfigDir(); } - public static boolean isClient() { - return FMLCommonHandler.instance().getEffectiveSide().isClient(); - } + public static boolean isClient() { return FMLCommonHandler.instance().getEffectiveSide().isClient(); } - public static boolean isServer() { - return FMLCommonHandler.instance().getEffectiveSide().isServer(); - } + public static boolean isServer() { return FMLCommonHandler.instance().getEffectiveSide().isServer(); } - public static boolean isDedicatedServer() { - return FMLCommonHandler.instance().getSide().isServer(); - } + public static boolean isDedicatedServer() { return FMLCommonHandler.instance().getSide().isServer(); } - public static String getPackmode() { - return Packmode.getPackmode(); - } + public static String getPackmode() { return Packmode.getPackmode(); } public static boolean isPackmode(String packmode) { return getPackmode().equalsIgnoreCase(packmode); } - public static String getMinecraftHome() { - return GroovyScript.getMinecraftHome().getPath(); - } + public static String getMinecraftHome() { return GroovyScript.getMinecraftHome().getPath(); } public static GroovyFile file(String path) { return new GroovyFile(path); diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/JsonHelper.java b/src/main/java/com/cleanroommc/groovyscript/helper/JsonHelper.java index 03923a72f..0e58b8e5f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/JsonHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/JsonHelper.java @@ -1,15 +1,15 @@ package com.cleanroommc.groovyscript.helper; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.google.gson.*; -import com.google.gson.stream.JsonReader; - import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.function.Function; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.google.gson.*; +import com.google.gson.stream.JsonReader; + @GroovyBlacklist public class JsonHelper { @@ -22,9 +22,7 @@ public static float getFloat(JsonObject json, float defaultValue, String... keys for (String key : keys) { if (json.has(key)) { JsonElement jsonElement = json.get(key); - if (jsonElement.isJsonPrimitive()) { - return jsonElement.getAsFloat(); - } + if (jsonElement.isJsonPrimitive()) { return jsonElement.getAsFloat(); } return defaultValue; } } @@ -35,9 +33,7 @@ public static int getInt(JsonObject json, int defaultValue, String... keys) { for (String key : keys) { if (json.has(key)) { JsonElement jsonElement = json.get(key); - if (jsonElement.isJsonPrimitive()) { - return jsonElement.getAsInt(); - } + if (jsonElement.isJsonPrimitive()) { return jsonElement.getAsInt(); } return defaultValue; } } @@ -48,9 +44,7 @@ public static boolean getBoolean(JsonObject json, boolean defaultValue, String.. for (String key : keys) { if (json.has(key)) { JsonElement jsonElement = json.get(key); - if (jsonElement.isJsonPrimitive()) { - return jsonElement.getAsBoolean(); - } + if (jsonElement.isJsonPrimitive()) { return jsonElement.getAsBoolean(); } return defaultValue; } } @@ -61,9 +55,7 @@ public static String getString(JsonObject json, String defaultValue, String... k for (String key : keys) { if (json.has(key)) { JsonElement jsonElement = json.get(key); - if (jsonElement.isJsonPrimitive()) { - return jsonElement.getAsString(); - } + if (jsonElement.isJsonPrimitive()) { return jsonElement.getAsString(); } } } return defaultValue; @@ -73,9 +65,7 @@ public static T getObject(JsonObject json, T defaultValue, Function forEach(Closure closure) { public T findFirst() { T recipe = getFirst(); - if (recipe == null) { - throw new NoSuchElementException(); - } + if (recipe == null) { throw new NoSuchElementException(); } return recipe; } @Nullable public T getFirst() { for (T recipe : this.recipes) { - if (recipe != null) { - return recipe; - } + if (recipe != null) { return recipe; } } return null; } - public List getList() { - return new ArrayList<>(this.recipes); - } + public List getList() { return new ArrayList<>(this.recipes); } - public Set getSet() { - return new ObjectOpenHashSet<>(this.recipes); - } + public Set getSet() { return new ObjectOpenHashSet<>(this.recipes); } @Override public boolean removeIf(Predicate filter) { @@ -108,9 +102,7 @@ public int size() { } @Override - public boolean isEmpty() { - return this.recipes.isEmpty(); - } + public boolean isEmpty() { return this.recipes.isEmpty(); } @Override public T get(int index) { @@ -119,9 +111,7 @@ public T get(int index) { @Override public boolean remove(Object o) { - if (o != null && this.remover == null || this.remover.test((T) o)) { - return this.recipes.remove(o); - } + if (o != null && this.remover == null || this.remover.test((T) o)) { return this.recipes.remove(o); } return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/FluidStackList.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/FluidStackList.java index bb452de03..70cd5366b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/FluidStackList.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/FluidStackList.java @@ -1,23 +1,20 @@ package com.cleanroommc.groovyscript.helper.ingredient; -import net.minecraftforge.fluids.FluidStack; - import java.util.ArrayList; import java.util.Collection; +import net.minecraftforge.fluids.FluidStack; + public class FluidStackList extends ArrayList { - public FluidStackList() { - } + public FluidStackList() {} public FluidStackList(Collection collection) { super(collection); } public FluidStack getOrEmpty(int i) { - if (i < 0 || i >= size()) { - return null; - } + if (i < 0 || i >= size()) { return null; } return get(i); } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientBase.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientBase.java index b6aade381..73923146f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientBase.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientBase.java @@ -1,10 +1,12 @@ package com.cleanroommc.groovyscript.helper.ingredient; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.ForgeHooks; + import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.sandbox.ClosureHelper; + import groovy.lang.Closure; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeHooks; public abstract class IngredientBase implements IIngredient { @@ -40,9 +42,7 @@ public boolean test(ItemStack itemStack) { @Override public ItemStack applyTransform(ItemStack matchedInput) { - if (transformer != null) { - return ClosureHelper.call(ItemStack.EMPTY, transformer, matchedInput); - } + if (transformer != null) { return ClosureHelper.call(ItemStack.EMPTY, transformer, matchedInput); } return ForgeHooks.getContainerItem(matchedInput); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientHelper.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientHelper.java index 638770b67..f116848bf 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientHelper.java @@ -1,8 +1,9 @@ package com.cleanroommc.groovyscript.helper.ingredient; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; -import groovy.lang.Closure; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; @@ -11,13 +12,15 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fluids.FluidStack; + import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; + +import groovy.lang.Closure; public class IngredientHelper { @@ -96,10 +99,8 @@ public static boolean isEmpty(@Nullable NBTTagCompound nbt) { * @return true if the collection or the elements are empty */ public static boolean isEmptyItems(@Nullable Collection itemStacks) { - if (itemStacks == null || itemStacks.isEmpty()) - return true; - for (ItemStack item : itemStacks) - if (!isEmpty(item)) return false; + if (itemStacks == null || itemStacks.isEmpty()) return true; + for (ItemStack item : itemStacks) if (!isEmpty(item)) return false; return true; } @@ -110,10 +111,8 @@ public static boolean isEmptyItems(@Nullable Collection itemStacks) { * @return true if the collection or the elements are empty */ public static boolean isEmptyFluids(@Nullable Collection fluidStacks) { - if (fluidStacks == null || fluidStacks.isEmpty()) - return true; - for (FluidStack fluid : fluidStacks) - if (!isEmpty(fluid)) return false; + if (fluidStacks == null || fluidStacks.isEmpty()) return true; + for (FluidStack fluid : fluidStacks) if (!isEmpty(fluid)) return false; return true; } @@ -124,10 +123,8 @@ public static boolean isEmptyFluids(@Nullable Collection fluidStacks * @return true if the collection or all elements are empty */ public static boolean isEmpty(@Nullable Collection ingredients) { - if (ingredients == null || ingredients.isEmpty()) - return true; - for (IIngredient item : ingredients) - if (!isEmpty(item)) return false; + if (ingredients == null || ingredients.isEmpty()) return true; + for (IIngredient item : ingredients) if (!isEmpty(item)) return false; return true; } @@ -138,10 +135,8 @@ public static boolean isEmpty(@Nullable Collection ingredients) { * @return true if the collection or one element is empty */ public static boolean isAnyEmpty(@Nullable Collection ingredients) { - if (ingredients == null || ingredients.isEmpty()) - return true; - for (IIngredient item : ingredients) - if (isEmpty(item)) return true; + if (ingredients == null || ingredients.isEmpty()) return true; + for (IIngredient item : ingredients) if (isEmpty(item)) return true; return false; } @@ -152,26 +147,20 @@ public static boolean isAnyEmpty(@Nullable Collection ingredients) * @return true if the array or the elements are empty */ public static boolean isEmpty(@Nullable ItemStack[] itemStacks) { - if (itemStacks == null) - return true; - for (ItemStack item : itemStacks) - if (!isEmpty(item)) return false; + if (itemStacks == null) return true; + for (ItemStack item : itemStacks) if (!isEmpty(item)) return false; return true; } public static boolean isEmpty(@Nullable FluidStack[] fluidStacks) { - if (fluidStacks == null) - return true; - for (FluidStack fluid : fluidStacks) - if (!isEmpty(fluid)) return false; + if (fluidStacks == null) return true; + for (FluidStack fluid : fluidStacks) if (!isEmpty(fluid)) return false; return true; } public static boolean isEmpty(@Nullable IIngredient[] ingredients) { - if (ingredients == null) - return true; - for (IIngredient item : ingredients) - if (!isEmpty(item)) return false; + if (ingredients == null) return true; + for (IIngredient item : ingredients) if (!isEmpty(item)) return false; return true; } @@ -200,32 +189,23 @@ public static Collection trimFluids(@Nullable Collection } public static int getRealSize(@Nullable Collection ingredients) { - if (ingredients == null || ingredients.isEmpty()) - return 0; + if (ingredients == null || ingredients.isEmpty()) return 0; int size = 0; - for (IIngredient ingredient : ingredients) - if (!isEmpty(ingredient)) - size++; + for (IIngredient ingredient : ingredients) if (!isEmpty(ingredient)) size++; return size; } public static int getRealSizeItems(@Nullable Collection ingredients) { - if (ingredients == null || ingredients.isEmpty()) - return 0; + if (ingredients == null || ingredients.isEmpty()) return 0; int size = 0; - for (ItemStack ingredient : ingredients) - if (!isEmpty(ingredient)) - size++; + for (ItemStack ingredient : ingredients) if (!isEmpty(ingredient)) size++; return size; } public static int getRealSizeFluids(@Nullable Collection ingredients) { - if (ingredients == null || ingredients.isEmpty()) - return 0; + if (ingredients == null || ingredients.isEmpty()) return 0; int size = 0; - for (FluidStack ingredient : ingredients) - if (!isEmpty(ingredient)) - size++; + for (FluidStack ingredient : ingredients) if (!isEmpty(ingredient)) size++; return size; } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientList.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientList.java index 84e530ded..b7cc5e57a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientList.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/IngredientList.java @@ -1,9 +1,9 @@ package com.cleanroommc.groovyscript.helper.ingredient; -import com.cleanroommc.groovyscript.api.IIngredient; - import java.util.ArrayList; +import com.cleanroommc.groovyscript.api.IIngredient; + /** * A ingredient list with helpers to handle empty ingredients */ diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/ItemStackList.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/ItemStackList.java index e948c440f..bf534f96f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/ItemStackList.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/ItemStackList.java @@ -1,26 +1,23 @@ package com.cleanroommc.groovyscript.helper.ingredient; -import net.minecraft.item.ItemStack; - import java.util.ArrayList; import java.util.Collection; +import net.minecraft.item.ItemStack; + /** * A item stack list with helpers to handle empty stacks */ public class ItemStackList extends ArrayList { - public ItemStackList() { - } + public ItemStackList() {} public ItemStackList(Collection collection) { super(collection); } public ItemStack getOrEmpty(int i) { - if (i < 0 || i >= size()) { - return ItemStack.EMPTY; - } + if (i < 0 || i >= size()) { return ItemStack.EMPTY; } ItemStack item = get(i); return item == null ? ItemStack.EMPTY : item; } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/ItemsIngredient.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/ItemsIngredient.java index b99e6bdf5..caef8a9bd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/ItemsIngredient.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/ItemsIngredient.java @@ -1,16 +1,18 @@ package com.cleanroommc.groovyscript.helper.ingredient; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.google.common.collect.Iterators; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.oredict.OreDictionary; + import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.google.common.collect.Iterators; public class ItemsIngredient extends IngredientBase implements Iterable { @@ -55,31 +57,22 @@ public ItemStack[] getMatchingStacks() { } @Override - public int getAmount() { - return itemStacks.isEmpty() ? 0 : amount; - } + public int getAmount() { return itemStacks.isEmpty() ? 0 : amount; } @Override - public void setAmount(int amount) { - this.amount = Math.max(0, amount); - } + public void setAmount(int amount) { this.amount = Math.max(0, amount); } @Override public boolean matches(ItemStack itemStack) { for (ItemStack itemStack1 : itemStacks) { - if (OreDictionary.itemMatches(itemStack1, itemStack, false)) { - return true; - } + if (OreDictionary.itemMatches(itemStack1, itemStack, false)) { return true; } } return false; } - public List getItemStacks() { - return Collections.unmodifiableList(this.itemStacks); - } + public List getItemStacks() { return Collections.unmodifiableList(this.itemStacks); } - @NotNull - @Override + @NotNull @Override public Iterator iterator() { return Iterators.unmodifiableIterator(this.itemStacks.iterator()); } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/NbtHelper.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/NbtHelper.java index 11fa22791..e288c436a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/NbtHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/NbtHelper.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.helper.ingredient; -import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; -import groovy.lang.Closure; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + import net.minecraft.nbt.*; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.common.util.Constants; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; +import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; + +import groovy.lang.Closure; public class NbtHelper { @@ -23,9 +25,7 @@ public static boolean containsNbt(NBTTagCompound nbtContainer, NBTTagCompound nb NBTBase nbt1 = nbtContainer.getTag(key); if (nbt1 == null) return false; NBTBase nbt2 = nbtMatcher.getTag(key); - if (!matches(nbt1, nbt2, true)) { - return false; - } + if (!matches(nbt1, nbt2, true)) { return false; } } return true; } @@ -33,9 +33,7 @@ public static boolean containsNbt(NBTTagCompound nbtContainer, NBTTagCompound nb public static boolean matches(NBTBase nbt1, NBTBase nbt2, boolean contains) { if (!contains) return nbt1.equals(nbt2); if (nbt1.getId() != nbt2.getId()) return false; - if (nbt1.getId() == Constants.NBT.TAG_COMPOUND) { - return containsNbt((NBTTagCompound) nbt1, (NBTTagCompound) nbt2); - } + if (nbt1.getId() == Constants.NBT.TAG_COMPOUND) { return containsNbt((NBTTagCompound) nbt1, (NBTTagCompound) nbt2); } return nbt1.equals(nbt2); } @@ -49,9 +47,7 @@ public static NBTTagCompound ofMap(Map map) { } public static NBTBase toNbt(Object o) { - if (o instanceof Map) { - return ofMap((Map) o); - } + if (o instanceof Map) { return ofMap((Map) o); } if (o instanceof List) { NBTTagList list = new NBTTagList(); byte type = 0; diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OrIngredient.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OrIngredient.java index 7fbb71308..a7763a4bb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OrIngredient.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OrIngredient.java @@ -1,27 +1,24 @@ package com.cleanroommc.groovyscript.helper.ingredient; -import com.cleanroommc.groovyscript.api.IIngredient; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; - import java.util.ArrayList; import java.util.Collections; import java.util.List; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; + +import com.cleanroommc.groovyscript.api.IIngredient; + public class OrIngredient extends IngredientBase { private final List ingredients = new ArrayList<>(); private int amount = 1; @Override - public int getAmount() { - return amount; - } + public int getAmount() { return amount; } @Override - public void setAmount(int amount) { - this.amount = amount; - } + public void setAmount(int amount) { this.amount = amount; } @Override public IIngredient exactCopy() { @@ -50,9 +47,7 @@ public ItemStack[] getMatchingStacks() { @Override public boolean matches(ItemStack itemStack) { for (IIngredient ingredient : this.ingredients) { - if (ingredient.test(itemStack)) { - return true; - } + if (ingredient.test(itemStack)) { return true; } } return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OreDictIngredient.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OreDictIngredient.java index c06ca55ff..68cf9160e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OreDictIngredient.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OreDictIngredient.java @@ -1,17 +1,17 @@ package com.cleanroommc.groovyscript.helper.ingredient; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; +import java.util.Iterator; +import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.oredict.OreDictionary; -import com.google.common.collect.Iterators; import org.jetbrains.annotations.NotNull; -import java.util.Iterator; -import java.util.List; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; +import com.google.common.collect.Iterators; public class OreDictIngredient extends IngredientBase implements Iterable { @@ -22,19 +22,13 @@ public OreDictIngredient(String oreDict) { this.oreDict = oreDict; } - public String getOreDict() { - return oreDict; - } + public String getOreDict() { return oreDict; } @Override - public int getAmount() { - return count; - } + public int getAmount() { return count; } @Override - public void setAmount(int amount) { - count = Math.max(0, amount); - } + public void setAmount(int amount) { count = Math.max(0, amount); } @Override public OreDictIngredient exactCopy() { @@ -51,9 +45,7 @@ public boolean matches(ItemStack stack) { if (IngredientHelper.isEmpty(stack)) return false; for (int id : OreDictionary.getOreIDs(stack)) { String oreName = OreDictionary.getOreName(id); - if (oreDict.equals(oreName)) { - return true; - } + if (oreDict.equals(oreName)) { return true; } } return false; } @@ -75,13 +67,9 @@ private List prepareItemStacks() { } @Override - public ItemStack[] getMatchingStacks() { - return prepareItemStacks().toArray(new ItemStack[0]); - } + public ItemStack[] getMatchingStacks() { return prepareItemStacks().toArray(new ItemStack[0]); } - public ItemStack getFirst() { - return prepareItemStacks().get(0); - } + public ItemStack getFirst() { return prepareItemStacks().get(0); } public ItemStack getAt(int index) { return prepareItemStacks().get(index); @@ -128,8 +116,7 @@ public void remove(Iterable itemStacks) { } } - @NotNull - @Override + @NotNull @Override public Iterator iterator() { return Iterators.unmodifiableIterator(prepareItemStacks().listIterator()); } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OreDictWildcardIngredient.java b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OreDictWildcardIngredient.java index ca7dd62e4..17775224f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OreDictWildcardIngredient.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/ingredient/OreDictWildcardIngredient.java @@ -1,16 +1,17 @@ package com.cleanroommc.groovyscript.helper.ingredient; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.core.mixin.OreDictionaryAccessor; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.regex.Pattern; import java.util.stream.Collectors; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.core.mixin.OreDictionaryAccessor; + public class OreDictWildcardIngredient extends ItemsIngredient { private final String oreDict; @@ -39,13 +40,9 @@ public OreDictWildcardIngredient(String oreDict, List matchingOreDiction this.matchingOreDictionaries.addAll(matchingOreDictionaries); } - public String getOreDict() { - return oreDict; - } + public String getOreDict() { return oreDict; } - public List getMatchingOreDictionaries() { - return ores; - } + public List getMatchingOreDictionaries() { return ores; } public List getOres() { return this.ores.stream().map(OreDictIngredient::new).collect(Collectors.toList()); @@ -53,7 +50,8 @@ public List getOres() { @Override public IIngredient exactCopy() { - OreDictWildcardIngredient odwi = new OreDictWildcardIngredient(this.oreDict, this.matchingOreDictionaries, getItemStacks()); + OreDictWildcardIngredient odwi = new OreDictWildcardIngredient(this.oreDict, this.matchingOreDictionaries, + getItemStacks()); odwi.setAmount(getAmount()); odwi.transformer = transformer; odwi.matchCondition = matchCondition; diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/recipe/AbstractRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/helper/recipe/AbstractRecipeBuilder.java index a37f1b575..32113701f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/recipe/AbstractRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/recipe/AbstractRecipeBuilder.java @@ -1,5 +1,11 @@ package com.cleanroommc.groovyscript.helper.recipe; +import java.util.Collection; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; @@ -9,11 +15,6 @@ import com.cleanroommc.groovyscript.helper.ingredient.FluidStackList; import com.cleanroommc.groovyscript.helper.ingredient.IngredientList; import com.cleanroommc.groovyscript.helper.ingredient.ItemStackList; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidStack; - -import java.util.Collection; public abstract class AbstractRecipeBuilder implements IRecipeBuilder { @@ -28,9 +29,7 @@ public abstract class AbstractRecipeBuilder implements IRecipeBuilder { @Property(value = "groovyscript.wiki.fluidOutput.value", needsOverride = true, priority = 750, hierarchy = 20) protected final FluidStackList fluidOutput = new FluidStackList(); - public String getRecipeNamePrefix() { - return "groovyscript_"; - } + public String getRecipeNamePrefix() { return "groovyscript_"; } @RecipeBuilderMethodDescription public AbstractRecipeBuilder name(String name) { @@ -158,16 +157,27 @@ public void validateName() { public void validateFluids(GroovyLog.Msg msg, int minFluidInput, int maxFluidInput, int minFluidOutput, int maxFluidOutput) { fluidInput.trim(); fluidOutput.trim(); - msg.add(fluidInput.size() < minFluidInput || fluidInput.size() > maxFluidInput, () -> getRequiredString(minFluidInput, maxFluidInput, "fluid input") + ", but found " + fluidInput.size()); - msg.add(fluidOutput.size() < minFluidOutput || fluidOutput.size() > maxFluidOutput, () -> getRequiredString(minFluidOutput, maxFluidOutput, "fluid output") + ", but found " + fluidOutput.size()); + msg.add(fluidInput.size() < minFluidInput || fluidInput.size() > maxFluidInput, () -> getRequiredString(minFluidInput, + maxFluidInput, + "fluid input") + + ", but found " + fluidInput.size()); + msg.add(fluidOutput.size() < minFluidOutput || fluidOutput.size() > maxFluidOutput, () -> getRequiredString( + minFluidOutput, + maxFluidOutput, + "fluid output") + + ", but found " + fluidOutput + .size()); } @GroovyBlacklist public void validateItems(GroovyLog.Msg msg, int minInput, int maxInput, int minOutput, int maxOutput) { input.trim(); output.trim(); - msg.add(input.size() < minInput || input.size() > maxInput, () -> getRequiredString(minInput, maxInput, "item input") + ", but found " + input.size()); - msg.add(output.size() < minOutput || output.size() > maxOutput, () -> getRequiredString(minOutput, maxOutput, "item output") + ", but found " + output.size()); + msg.add(input.size() < minInput || input.size() > maxInput, () -> getRequiredString(minInput, maxInput, "item input") + + ", but found " + input.size()); + msg.add(output.size() < minOutput || output.size() > maxOutput, () -> getRequiredString(minOutput, maxOutput, + "item output") + ", but found " + + output.size()); } @GroovyBlacklist @@ -182,13 +192,12 @@ public void validateFluids(GroovyLog.Msg msg) { @GroovyBlacklist public void validateCustom(GroovyLog.Msg msg, Collection collection, int min, int max, String type) { - msg.add(collection.size() < min || collection.size() > max, () -> getRequiredString(min, max, type) + ", but found " + collection.size()); + msg.add(collection.size() < min || collection.size() > max, () -> getRequiredString(min, max, type) + ", but found " + + collection.size()); } protected static String getRequiredString(int min, int max, String type) { - if (max <= 0) { - return "No " + type + "s allowed"; - } + if (max <= 0) { return "No " + type + "s allowed"; } String out = "Must have "; if (min == max) { out += "exactly " + min + " " + type; diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/recipe/IRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/helper/recipe/IRecipeBuilder.java index 4d30a12cb..babd4eee4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/recipe/IRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/recipe/IRecipeBuilder.java @@ -1,8 +1,9 @@ package com.cleanroommc.groovyscript.helper.recipe; -import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderRegistrationMethod; import org.jetbrains.annotations.Nullable; +import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderRegistrationMethod; + /** * A groovy recipe builder template * @@ -23,7 +24,6 @@ public interface IRecipeBuilder { * * @return the built recipe or null if values are invalid */ - @Nullable - @RecipeBuilderRegistrationMethod + @Nullable @RecipeBuilderRegistrationMethod T register(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/helper/recipe/RecipeName.java b/src/main/java/com/cleanroommc/groovyscript/helper/recipe/RecipeName.java index 78982a52c..451ecf7f3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/helper/recipe/RecipeName.java +++ b/src/main/java/com/cleanroommc/groovyscript/helper/recipe/RecipeName.java @@ -1,16 +1,16 @@ package com.cleanroommc.groovyscript.helper.recipe; -import com.cleanroommc.groovyscript.GroovyScript; import net.minecraft.util.ResourceLocation; +import com.cleanroommc.groovyscript.GroovyScript; + public class RecipeName { private static int nextId = -1; private static String prefix = ""; public static String generate() { - if (prefix.isEmpty()) - prefix = GroovyScript.getRunConfig().getPackId() + "_"; + if (prefix.isEmpty()) prefix = GroovyScript.getRunConfig().getPackId() + "_"; return generate(prefix); } diff --git a/src/main/java/com/cleanroommc/groovyscript/mapper/Completer.java b/src/main/java/com/cleanroommc/groovyscript/mapper/Completer.java index e38aef925..cc9e6410c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/mapper/Completer.java +++ b/src/main/java/com/cleanroommc/groovyscript/mapper/Completer.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.mapper; -import com.cleanroommc.groovyscript.server.Completions; +import java.util.function.Function; +import java.util.function.Supplier; + import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.CompletionItemKind; -import java.util.function.Function; -import java.util.function.Supplier; +import com.cleanroommc.groovyscript.server.Completions; @FunctionalInterface public interface Completer { @@ -24,7 +25,8 @@ static Completer ofNamed(Supplier> values, Function t }, preferredParamIndex); } - static Completer ofValues(Supplier> values, Function toCompletionItem, int preferredParamIndex) { + static Completer ofValues(Supplier> values, Function toCompletionItem, + int preferredParamIndex) { return (paramIndex, items) -> { if (preferredParamIndex < 0 || preferredParamIndex == paramIndex) { items.addAll(values.get(), toCompletionItem); diff --git a/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapper.java b/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapper.java index 5f0d1c557..65e65a74c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapper.java +++ b/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapper.java @@ -1,16 +1,14 @@ package com.cleanroommc.groovyscript.mapper; -import com.cleanroommc.groovyscript.api.*; -import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.ArrayUtils; -import com.cleanroommc.groovyscript.sandbox.expand.IDocumented; -import groovy.lang.Closure; -import groovy.lang.groovydoc.Groovydoc; -import groovy.lang.groovydoc.GroovydocHolder; +import java.lang.reflect.Modifier; +import java.util.*; +import java.util.function.Function; +import java.util.function.Supplier; + import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistryEntry; + import org.apache.commons.lang3.StringUtils; import org.codehaus.groovy.ast.ClassHelper; import org.codehaus.groovy.ast.MethodNode; @@ -19,10 +17,15 @@ import org.eclipse.lsp4j.CompletionItemKind; import org.jetbrains.annotations.ApiStatus; -import java.lang.reflect.Modifier; -import java.util.*; -import java.util.function.Function; -import java.util.function.Supplier; +import com.cleanroommc.groovyscript.api.*; +import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.ArrayUtils; +import com.cleanroommc.groovyscript.sandbox.expand.IDocumented; + +import groovy.lang.Closure; +import groovy.lang.groovydoc.Groovydoc; +import groovy.lang.groovydoc.GroovydocHolder; /** * This class handles global getter functions like `item(...)` and `fluid(...)` @@ -55,7 +58,8 @@ public static Builder builder(String name, Class returnType) { private final String documentation; private List methodNodes; - private ObjectMapper(String name, GroovyContainer mod, IObjectParser handler, Supplier> defaultValue, Class returnType, List[]> paramTypes, Completer completer, String documentation) { + private ObjectMapper(String name, GroovyContainer mod, IObjectParser handler, Supplier> defaultValue, + Class returnType, List[]> paramTypes, Completer completer, String documentation) { super(null); this.name = name; this.mod = mod; @@ -89,31 +93,19 @@ T invokeDefault() { return t == null || t.hasError() ? null : t.getValue(); } - public GroovyContainer getMod() { - return mod; - } + public GroovyContainer getMod() { return mod; } @Override - public Collection getAliases() { - return Collections.singleton(this.name); - } + public Collection getAliases() { return Collections.singleton(this.name); } - public String getName() { - return name; - } + public String getName() { return name; } - public List[]> getParamTypes() { - return this.paramTypes; - } + public List[]> getParamTypes() { return this.paramTypes; } - public Class getReturnType() { - return returnType; - } + public Class getReturnType() { return returnType; } @GroovyBlacklist - public Completer getCompleter() { - return completer; - } + public Completer getCompleter() { return completer; } public T doCall(String s, Object... args) { return invoke(s, args); @@ -124,9 +116,7 @@ public T doCall() { } @Override - public String getDocumentation() { - return documentation; - } + public String getDocumentation() { return documentation; } public List getMethodNodes() { if (methodNodes == null) { @@ -134,11 +124,11 @@ public List getMethodNodes() { for (Class[] paramType : this.paramTypes) { Parameter[] params = ArrayUtils.map(paramType, c -> new Parameter(ClassHelper.makeCached(c), ""), new Parameter[paramType.length]); - MethodNode node = new MethodNode(this.name, Modifier.PUBLIC | Modifier.FINAL, - ClassHelper.makeCached(this.returnType), params, null, null); - node.setDeclaringClass(this.mod != null ? - ClassHelper.makeCached(this.mod.get().getClass()) : - ClassHelper.makeCached(ObjectMapperManager.class)); + MethodNode node = new MethodNode(this.name, Modifier.PUBLIC | Modifier.FINAL, ClassHelper.makeCached( + this.returnType), + params, null, null); + node.setDeclaringClass(this.mod != null ? ClassHelper.makeCached(this.mod.get().getClass()) : ClassHelper + .makeCached(ObjectMapperManager.class)); node.setNodeMetaData(GroovydocHolder.DOC_COMMENT, new Groovydoc(this.documentation, node)); this.methodNodes.add(node); } @@ -169,7 +159,8 @@ public Builder(String name, Class returnType) { } /** - * Sets the mod who creates this mapper. This is already done when {@link GroovyContainer#objectMapperBuilder(String, Class)} is used. + * Sets the mod who creates this mapper. This is already done when + * {@link GroovyContainer#objectMapperBuilder(String, Class)} is used. * * @param mod the creator mod * @return this builder @@ -180,7 +171,8 @@ public Builder mod(String mod) { } /** - * Sets the mod who creates this mapper. This is already done when {@link GroovyContainer#objectMapperBuilder(String, Class)} is used. + * Sets the mod who creates this mapper. This is already done when + * {@link GroovyContainer#objectMapperBuilder(String, Class)} is used. * * @param mod the creator mod * @return this builder @@ -193,7 +185,8 @@ public Builder mod(GroovyContainer mod) { } /** - * Sets the parser function. It receives a String and any amount of other arguments and returns an object of the specified type or an error. + * Sets the parser function. It receives a String and any amount of other arguments and returns an object of the specified + * type or an error. * * @param handler parser function * @return this builder @@ -248,7 +241,8 @@ public Builder completerOfNamed(Supplier> values, Function> Builder completerOfEnum(Class values, boolean caseSensitive) { - return completerOfNamed(() -> Arrays.asList(values.getEnumConstants()), s -> caseSensitive ? s.name() : s.name().toLowerCase(Locale.ROOT)); + return completerOfNamed(() -> Arrays.asList(values.getEnumConstants()), s -> caseSensitive ? s.name() : s.name() + .toLowerCase(Locale.ROOT)); } public Builder completer(Supplier> values) { @@ -270,7 +264,8 @@ public > Builder completer(IForgeRegistry } /** - * Sets a default value. This is what the mapper returns when no value could be found or an error occurred. Default is null. + * Sets a default value. This is what the mapper returns when no value could be found or an error occurred. Default is + * null. * * @param defaultValue default value * @return this builder @@ -280,7 +275,8 @@ public Builder defaultValue(Supplier defaultValue) { } /** - * Sets a default value. This is what the mapper returns when no value could be found or an error occurred. Default is null. + * Sets a default value. This is what the mapper returns when no value could be found or an error occurred. Default is + * null. * * @param defaultValue default value * @return this builder @@ -330,15 +326,16 @@ public Builder docOfType(String type) { */ public void register() { if (this.name == null || this.name.isEmpty()) throw new IllegalArgumentException("Name must not be empty"); - if (this.mod != null && !this.mod.isLoaded()) - throw new IllegalArgumentException("Tried to register ObjectMapper for mod " + this.mod + ", but it's not loaded"); + if (this.mod != null && !this.mod.isLoaded()) throw new IllegalArgumentException( + "Tried to register ObjectMapper for mod " + + this.mod + ", but it's not loaded"); Objects.requireNonNull(this.handler, () -> "The ObjectMapper function must no be null"); Objects.requireNonNull(this.returnType, () -> "The ObjectMapper return type must not be null"); if (this.paramTypes.isEmpty()) this.paramTypes.add(new Class[]{String.class}); if (this.defaultValue == null) this.defaultValue = () -> null; this.documentation = IDocumented.toJavaDoc(this.documentation); - ObjectMapper goh = new ObjectMapper<>(this.name, this.mod, this.handler, this.defaultValue, - this.returnType, this.paramTypes, this.completer, this.documentation); + ObjectMapper goh = new ObjectMapper<>(this.name, this.mod, this.handler, this.defaultValue, this.returnType, + this.paramTypes, this.completer, this.documentation); ObjectMapperManager.registerObjectMapper(this.mod, goh); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapperManager.java b/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapperManager.java index e095d8602..72593e326 100644 --- a/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapperManager.java +++ b/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapperManager.java @@ -1,18 +1,7 @@ package com.cleanroommc.groovyscript.mapper; -import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.api.IObjectParser; -import com.cleanroommc.groovyscript.api.Result; -import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; -import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; -import com.cleanroommc.groovyscript.core.mixin.CreativeTabsAccessor; -import com.cleanroommc.groovyscript.core.mixin.OreDictionaryAccessor; -import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; -import com.cleanroommc.groovyscript.helper.ingredient.OreDictWildcardIngredient; -import com.cleanroommc.groovyscript.sandbox.expand.ExpansionHelper; -import com.cleanroommc.groovyscript.server.Completions; -import groovy.lang.ExpandoMetaClass; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import java.util.*; + import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; @@ -30,9 +19,23 @@ import net.minecraftforge.fml.common.registry.EntityEntry; import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.common.registry.VillagerRegistry; + import org.jetbrains.annotations.Nullable; -import java.util.*; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.IObjectParser; +import com.cleanroommc.groovyscript.api.Result; +import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; +import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; +import com.cleanroommc.groovyscript.core.mixin.CreativeTabsAccessor; +import com.cleanroommc.groovyscript.core.mixin.OreDictionaryAccessor; +import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; +import com.cleanroommc.groovyscript.helper.ingredient.OreDictWildcardIngredient; +import com.cleanroommc.groovyscript.sandbox.expand.ExpansionHelper; +import com.cleanroommc.groovyscript.server.Completions; + +import groovy.lang.ExpandoMetaClass; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; public class ObjectMapperManager { @@ -65,103 +68,68 @@ static void registerObjectMapper(GroovyContainer container, ObjectMapper g GroovyPropertyContainer propertyContainer = container.get(); var map = modHandlers.computeIfAbsent(propertyContainer.getClass(), k -> new Object2ObjectOpenHashMap<>()); if (map.containsKey(key)) { - throw new IllegalStateException("There already is a ObjectMapper with name '" + key + "' in mod " + container.getContainerName()); + throw new IllegalStateException("There already is a ObjectMapper with name '" + key + "' in mod " + container + .getContainerName()); } map.put(key, goh); } } public static void init() { - ObjectMapper.builder("resource", ResourceLocation.class) - .parser(ObjectMappers::parseResourceLocation) - .addSignature(String.class) - .addSignature(String.class, String.class) - .docOfType("resource location") - .register(); - ObjectMapper.builder("ore", IIngredient.class) - .parser((s, args) -> s.contains(WILDCARD) ? Result.some(OreDictWildcardIngredient.of(s)) : Result.some(new OreDictIngredient(s))) - .completerOfNames(OreDictionaryAccessor::getIdToName) - .docOfType("ore dict entry") - .register(); - ObjectMapper.builder("item", ItemStack.class) - .parser(ObjectMappers::parseItemStack) - .addSignature(String.class) - .addSignature(String.class, int.class) - .defaultValue(() -> ItemStack.EMPTY) - .completer(ForgeRegistries.ITEMS) - .docOfType("item stack") - .register(); - ObjectMapper.builder("liquid", FluidStack.class) - .parser(ObjectMappers::parseFluidStack) - .completerOfNames(FluidRegistry.getRegisteredFluids()::keySet) - .docOfType("fluid stack") - .register(); - ObjectMapper.builder("fluid", FluidStack.class) - .parser(ObjectMappers::parseFluidStack) - .completerOfNames(FluidRegistry.getRegisteredFluids()::keySet) - .register(); - ObjectMapper.builder("block", Block.class) - .parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.BLOCKS)) - .completer(ForgeRegistries.BLOCKS) - .docOfType("block") - .register(); - ObjectMapper.builder("blockstate", IBlockState.class) - .parser(ObjectMappers::parseBlockState) - .addSignature(String.class) - .addSignature(String.class, int.class) - .addSignature(String.class, String[].class) - .completer(ForgeRegistries.BLOCKS) - .docOfType("block state") - .register(); - ObjectMapper.builder("enchantment", Enchantment.class) - .parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.ENCHANTMENTS)) - .completer(ForgeRegistries.ENCHANTMENTS) - .docOfType("enchantment") - .register(); - ObjectMapper.builder("potion", Potion.class) - .parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.POTIONS)) - .completer(ForgeRegistries.POTIONS) - .docOfType("potion") - .register(); - ObjectMapper.builder("potionType", PotionType.class) - .parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.POTION_TYPES)) - .completer(ForgeRegistries.POTION_TYPES) - .docOfType("potion type") - .register(); - ObjectMapper.builder("sound", SoundEvent.class) - .parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.SOUND_EVENTS)) - .completer(ForgeRegistries.SOUND_EVENTS) - .docOfType("sound") - .register(); - ObjectMapper.builder("entity", EntityEntry.class) - .parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.ENTITIES)) - .completer(ForgeRegistries.ENTITIES) - .docOfType("entity entry") - .register(); - ObjectMapper.builder("biome", Biome.class) - .parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.BIOMES)) - .completer(ForgeRegistries.BIOMES) - .docOfType("biome") - .register(); - ObjectMapper.builder("profession", VillagerRegistry.VillagerProfession.class) - .parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.VILLAGER_PROFESSIONS)) - .completer(ForgeRegistries.VILLAGER_PROFESSIONS) - .docOfType("villager profession") - .register(); - ObjectMapper.builder("creativeTab", CreativeTabs.class) - .parser(ObjectMappers::parseCreativeTab) - .completerOfNamed(() -> Arrays.asList(CreativeTabs.CREATIVE_TAB_ARRAY), v -> ((CreativeTabsAccessor) v).getTabLabel2()) - .docOfType("creative tab") - .register(); - ObjectMapper.builder("textformat", TextFormatting.class) - .parser(ObjectMappers::parseTextFormatting) - .completerOfNamed(() -> Arrays.asList(TextFormatting.values()), format -> format.name().toLowerCase(Locale.ROOT).replaceAll("[^a-z]", "")) - .docOfType("text format") - .register(); - ObjectMapper.builder("nbt", NBTTagCompound.class) - .parser(ObjectMappers::parseNBT) - .docOfType("nbt tag") - .register(); + ObjectMapper.builder("resource", ResourceLocation.class).parser(ObjectMappers::parseResourceLocation).addSignature( + String.class) + .addSignature(String.class, String.class).docOfType("resource location").register(); + ObjectMapper.builder("ore", IIngredient.class).parser((s, args) -> s.contains(WILDCARD) ? Result.some( + OreDictWildcardIngredient.of(s)) : + Result.some(new OreDictIngredient(s))).completerOfNames(OreDictionaryAccessor::getIdToName).docOfType( + "ore dict entry") + .register(); + ObjectMapper.builder("item", ItemStack.class).parser(ObjectMappers::parseItemStack).addSignature(String.class) + .addSignature(String.class, int.class).defaultValue(() -> ItemStack.EMPTY).completer(ForgeRegistries.ITEMS) + .docOfType("item stack").register(); + ObjectMapper.builder("liquid", FluidStack.class).parser(ObjectMappers::parseFluidStack).completerOfNames(FluidRegistry + .getRegisteredFluids()::keySet) + .docOfType("fluid stack").register(); + ObjectMapper.builder("fluid", FluidStack.class).parser(ObjectMappers::parseFluidStack).completerOfNames(FluidRegistry + .getRegisteredFluids()::keySet) + .register(); + ObjectMapper.builder("block", Block.class).parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.BLOCKS)).completer( + ForgeRegistries.BLOCKS) + .docOfType("block").register(); + ObjectMapper.builder("blockstate", IBlockState.class).parser(ObjectMappers::parseBlockState).addSignature(String.class) + .addSignature(String.class, int.class).addSignature(String.class, String[].class).completer( + ForgeRegistries.BLOCKS) + .docOfType("block state").register(); + ObjectMapper.builder("enchantment", Enchantment.class).parser(IObjectParser.wrapForgeRegistry( + ForgeRegistries.ENCHANTMENTS)) + .completer(ForgeRegistries.ENCHANTMENTS).docOfType("enchantment").register(); + ObjectMapper.builder("potion", Potion.class).parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.POTIONS)).completer( + ForgeRegistries.POTIONS) + .docOfType("potion").register(); + ObjectMapper.builder("potionType", PotionType.class).parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.POTION_TYPES)) + .completer(ForgeRegistries.POTION_TYPES).docOfType("potion type").register(); + ObjectMapper.builder("sound", SoundEvent.class).parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.SOUND_EVENTS)) + .completer(ForgeRegistries.SOUND_EVENTS).docOfType("sound").register(); + ObjectMapper.builder("entity", EntityEntry.class).parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.ENTITIES)) + .completer(ForgeRegistries.ENTITIES).docOfType("entity entry").register(); + ObjectMapper.builder("biome", Biome.class).parser(IObjectParser.wrapForgeRegistry(ForgeRegistries.BIOMES)).completer( + ForgeRegistries.BIOMES) + .docOfType("biome").register(); + ObjectMapper.builder("profession", VillagerRegistry.VillagerProfession.class).parser(IObjectParser.wrapForgeRegistry( + ForgeRegistries.VILLAGER_PROFESSIONS)) + .completer(ForgeRegistries.VILLAGER_PROFESSIONS).docOfType("villager profession").register(); + ObjectMapper.builder("creativeTab", CreativeTabs.class).parser(ObjectMappers::parseCreativeTab).completerOfNamed( + () -> Arrays.asList(CreativeTabs.CREATIVE_TAB_ARRAY), + v -> ((CreativeTabsAccessor) v).getTabLabel2()) + .docOfType("creative tab").register(); + ObjectMapper.builder("textformat", TextFormatting.class).parser(ObjectMappers::parseTextFormatting).completerOfNamed( + () -> Arrays.asList(TextFormatting.values()), + format -> format.name() + .toLowerCase(Locale.ROOT) + .replaceAll("[^a-z]", + "")) + .docOfType("text format").register(); + ObjectMapper.builder("nbt", NBTTagCompound.class).parser(ObjectMappers::parseNBT).docOfType("nbt tag").register(); } /** @@ -175,9 +143,7 @@ public static void init() { @Nullable public static Object getGameObject(String name, String mainArg, Object... args) { ObjectMapper objectMapper = handlers.get(name); - if (objectMapper != null) { - return objectMapper.invoke(mainArg, args); - } + if (objectMapper != null) { return objectMapper.invoke(mainArg, args); } return null; } @@ -199,9 +165,7 @@ public static ObjectMapper getObjectMapper(Class containerClass, String ke return map != null ? map.get(key) : null; } - public static Collection> getObjectMappers() { - return handlers.values(); - } + public static Collection> getObjectMappers() { return handlers.values(); } public static Class getReturnTypeOf(String name) { ObjectMapper goh = handlers.get(name); diff --git a/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapperMetaMethod.java b/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapperMetaMethod.java index 08e155e7a..b3bed02d3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapperMetaMethod.java +++ b/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMapperMetaMethod.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.mapper; -import com.cleanroommc.groovyscript.sandbox.expand.IDocumented; -import groovy.lang.MetaMethod; +import java.lang.reflect.Modifier; + import org.codehaus.groovy.reflection.CachedClass; import org.codehaus.groovy.reflection.ReflectionCache; -import java.lang.reflect.Modifier; +import com.cleanroommc.groovyscript.sandbox.expand.IDocumented; + +import groovy.lang.MetaMethod; public class ObjectMapperMetaMethod extends MetaMethod implements IDocumented { @@ -20,24 +22,16 @@ public class ObjectMapperMetaMethod extends MetaMethod implements IDocumented { } @Override - public int getModifiers() { - return Modifier.PUBLIC; - } + public int getModifiers() { return Modifier.PUBLIC; } @Override - public String getName() { - return this.closure.getName(); - } + public String getName() { return this.closure.getName(); } @Override - public Class getReturnType() { - return this.closure.getReturnType(); - } + public Class getReturnType() { return this.closure.getReturnType(); } @Override - public CachedClass getDeclaringClass() { - return ReflectionCache.getCachedClass(this.owner); - } + public CachedClass getDeclaringClass() { return ReflectionCache.getCachedClass(this.owner); } @Override public Object invoke(Object object, Object[] arguments) { @@ -46,7 +40,5 @@ public Object invoke(Object object, Object[] arguments) { } @Override - public String getDocumentation() { - return this.closure.getDocumentation(); - } + public String getDocumentation() { return this.closure.getDocumentation(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMappers.java b/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMappers.java index 5d2731b55..06f64de24 100644 --- a/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMappers.java +++ b/src/main/java/com/cleanroommc/groovyscript/mapper/ObjectMappers.java @@ -1,11 +1,15 @@ package com.cleanroommc.groovyscript.mapper; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.Result; -import com.cleanroommc.groovyscript.core.mixin.CreativeTabsAccessor; -import com.google.common.base.Optional; -import com.google.common.collect.Iterators; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import static com.cleanroommc.groovyscript.mapper.ObjectMapperManager.SPLITTER; +import static com.cleanroommc.groovyscript.mapper.ObjectMapperManager.WILDCARD; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; @@ -22,17 +26,16 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.registry.ForgeRegistries; + import org.jetbrains.annotations.NotNull; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.Result; +import com.cleanroommc.groovyscript.core.mixin.CreativeTabsAccessor; +import com.google.common.base.Optional; +import com.google.common.collect.Iterators; -import static com.cleanroommc.groovyscript.mapper.ObjectMapperManager.SPLITTER; -import static com.cleanroommc.groovyscript.mapper.ObjectMapperManager.WILDCARD; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; public class ObjectMappers { @@ -65,13 +68,9 @@ public class ObjectMappers { return Result.error("Arguments not valid for bracket handler. Use 'item(String)' or 'item(String, int meta)'"); } String[] parts = mainArg.split(SPLITTER); - if (parts.length < 2) { - return Result.error("must contain a ':' to separate mod and path"); - } + if (parts.length < 2) { return Result.error("must contain a ':' to separate mod and path"); } Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(parts[0], parts[1])); - if (item == null) { - return Result.error(); - } + if (item == null) { return Result.error(); } int meta = 0; if (parts.length > 2) { if (WILDCARD.equals(parts[2])) { @@ -79,14 +78,11 @@ public class ObjectMappers { } else { try { meta = Integer.parseInt(parts[2]); - } catch (NumberFormatException ignored) { - } + } catch (NumberFormatException ignored) {} } } if (args.length == 1) { - if (meta != 0) { - return Result.error("Defined meta value twice for item mapper"); - } + if (meta != 0) { return Result.error("Defined meta value twice for item mapper"); } meta = (int) args[0]; } return Result.some(new ItemStack(item, 1, meta)); @@ -112,9 +108,7 @@ public static Result parseFluidStack(String s, Object... args) { } } for (Object arg : args) { - if (!(arg instanceof String)) { - return Result.error("All arguments must be strings!"); - } + if (!(arg instanceof String)) { return Result.error("All arguments must be strings!"); } } String[] stringArgs = Arrays.stream(args).map(Object::toString).toArray(String[]::new); return parseBlockStates(blockState, Iterators.forArray(stringArgs)); @@ -124,13 +118,9 @@ public static Result parseFluidStack(String s, Object... args) { public static Result parseBlockState(String arg) { String[] parts = arg.split(SPLITTER); - if (parts.length < 2) { - return Result.error("Can't find block for '{}'", arg); - } + if (parts.length < 2) { return Result.error("Can't find block for '{}'", arg); } Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(parts[0], parts[1])); - if (block == null) { - return Result.error("Can't find block for '{}'", arg); - } + if (block == null) { return Result.error("Can't find block for '{}'", arg); } IBlockState blockState = block.getDefaultState(); if (parts.length > 2) { String[] states = parts[2].split(COMMA); @@ -138,8 +128,7 @@ public static Result parseBlockState(String arg) { try { int meta = Integer.parseInt(states[0]); return Result.some(blockState.getBlock().getStateFromMeta(meta)); - } catch (NumberFormatException ignored) { - } catch (Exception e) { + } catch (NumberFormatException ignored) {} catch (Exception e) { return Result.error("could not get block state from meta"); } } @@ -150,18 +139,20 @@ public static Result parseBlockState(String arg) { @SuppressWarnings("all") private static Result parseBlockStates(IBlockState defaultState, Iterator iterable) { - for (Iterator it = iterable; it.hasNext(); ) { + for (Iterator it = iterable; it.hasNext();) { String state = it.next(); String[] prop = state.split(EQUALS, 2); IProperty property = defaultState.getBlock().getBlockState().getProperty(prop[0]); if (property == null) { - return Result.error("Invalid property name '{}' for block '{}'", prop[0], defaultState.getBlock().getRegistryName()); + return Result.error("Invalid property name '{}' for block '{}'", prop[0], defaultState.getBlock() + .getRegistryName()); } Optional value = property.parseValue(prop[1]); if (value.isPresent()) { defaultState = defaultState.withProperty(property, value.get()); } else { - return Result.error("Invalid property value '{}' for block '{}:{}'", prop[1], defaultState.getBlock().getRegistryName()); + return Result.error("Invalid property value '{}' for block '{}:{}'", prop[1], defaultState.getBlock() + .getRegistryName()); } } return Result.some(defaultState); @@ -170,9 +161,7 @@ private static Result parseBlockStates(IBlockState defaultState, It public static Result parseCreativeTab(String mainArg, Object... args) { for (CreativeTabs tab : CreativeTabs.CREATIVE_TAB_ARRAY) { - if (tab != null && mainArg.equals(((CreativeTabsAccessor) tab).getTabLabel2())) { - return Result.some(tab); - } + if (tab != null && mainArg.equals(((CreativeTabsAccessor) tab).getTabLabel2())) { return Result.some(tab); } } return Result.error(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/network/CReload.java b/src/main/java/com/cleanroommc/groovyscript/network/CReload.java index b933490f2..8f010939a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/network/CReload.java +++ b/src/main/java/com/cleanroommc/groovyscript/network/CReload.java @@ -1,18 +1,17 @@ package com.cleanroommc.groovyscript.network; -import com.cleanroommc.groovyscript.command.GSCommand; import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.PacketBuffer; +import com.cleanroommc.groovyscript.command.GSCommand; + public class CReload implements IPacket { @Override - public void encode(PacketBuffer buf) { - } + public void encode(PacketBuffer buf) {} @Override - public void decode(PacketBuffer buf) { - } + public void decode(PacketBuffer buf) {} @Override public IPacket executeServer(NetHandlerPlayServer handler) { diff --git a/src/main/java/com/cleanroommc/groovyscript/network/IPacket.java b/src/main/java/com/cleanroommc/groovyscript/network/IPacket.java index 7d7e3ec6c..c8478c3a2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/network/IPacket.java +++ b/src/main/java/com/cleanroommc/groovyscript/network/IPacket.java @@ -1,6 +1,5 @@ package com.cleanroommc.groovyscript.network; -import io.netty.buffer.ByteBuf; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.PacketBuffer; @@ -8,6 +7,8 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; + /** * Joinked from Multiblocked */ diff --git a/src/main/java/com/cleanroommc/groovyscript/network/NetworkHandler.java b/src/main/java/com/cleanroommc/groovyscript/network/NetworkHandler.java index 8154b6e2d..790ec3d60 100644 --- a/src/main/java/com/cleanroommc/groovyscript/network/NetworkHandler.java +++ b/src/main/java/com/cleanroommc/groovyscript/network/NetworkHandler.java @@ -1,6 +1,5 @@ package com.cleanroommc.groovyscript.network; -import com.cleanroommc.groovyscript.GroovyScript; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.NetHandlerPlayServer; @@ -12,6 +11,8 @@ import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; +import com.cleanroommc.groovyscript.GroovyScript; + /** * Joinked from Multiblocked */ diff --git a/src/main/java/com/cleanroommc/groovyscript/network/NetworkUtils.java b/src/main/java/com/cleanroommc/groovyscript/network/NetworkUtils.java index 28399b7b8..65e319c0e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/network/NetworkUtils.java +++ b/src/main/java/com/cleanroommc/groovyscript/network/NetworkUtils.java @@ -1,28 +1,28 @@ package com.cleanroommc.groovyscript.network; -import com.cleanroommc.groovyscript.GroovyScript; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.function.Consumer; + import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.FMLCommonHandler; + import org.jetbrains.annotations.Nullable; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.function.Consumer; +import com.cleanroommc.groovyscript.GroovyScript; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; public class NetworkUtils { - public static final Consumer EMPTY_PACKET = buffer -> { - }; + public static final Consumer EMPTY_PACKET = buffer -> {}; - public static boolean isDedicatedClient() { - return FMLCommonHandler.instance().getSide().isClient(); - } + public static boolean isDedicatedClient() { return FMLCommonHandler.instance().getSide().isClient(); } public static boolean isClient(EntityPlayer player) { if (player == null) throw new NullPointerException("Can't get side of null player!"); @@ -53,9 +53,7 @@ public static void writeFluidStack(PacketBuffer buffer, @Nullable FluidStack flu @Nullable public static FluidStack readFluidStack(PacketBuffer buffer) throws IOException { - if (buffer.readBoolean()) { - return null; - } + if (buffer.readBoolean()) { return null; } return FluidStack.loadFluidStackFromNBT(buffer.readCompoundTag()); } diff --git a/src/main/java/com/cleanroommc/groovyscript/network/SCopy.java b/src/main/java/com/cleanroommc/groovyscript/network/SCopy.java index 87a7556c6..c0ceea238 100644 --- a/src/main/java/com/cleanroommc/groovyscript/network/SCopy.java +++ b/src/main/java/com/cleanroommc/groovyscript/network/SCopy.java @@ -3,6 +3,7 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.network.PacketBuffer; + import org.apache.commons.lang3.StringUtils; public class SCopy implements IPacket { @@ -13,8 +14,7 @@ public SCopy(String[] text) { this.text = text; } - public SCopy() { - } + public SCopy() {} @Override public void encode(PacketBuffer buf) { diff --git a/src/main/java/com/cleanroommc/groovyscript/network/SReloadScripts.java b/src/main/java/com/cleanroommc/groovyscript/network/SReloadScripts.java index 864d000a8..6d20bb4b4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/network/SReloadScripts.java +++ b/src/main/java/com/cleanroommc/groovyscript/network/SReloadScripts.java @@ -1,9 +1,5 @@ package com.cleanroommc.groovyscript.network; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.packmode.Packmode; -import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; -import com.cleanroommc.groovyscript.sandbox.LoadStage; import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.command.ICommandSender; @@ -11,14 +7,18 @@ import net.minecraft.util.text.TextComponentString; import net.minecraftforge.common.MinecraftForge; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.packmode.Packmode; +import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; +import com.cleanroommc.groovyscript.sandbox.LoadStage; + public class SReloadScripts implements IPacket { private String packmode; private boolean changePackmode; private boolean reloadJei; - public SReloadScripts() { - } + public SReloadScripts() {} public SReloadScripts(String packmode, boolean changePackmode, boolean reloadJei) { this.packmode = packmode; diff --git a/src/main/java/com/cleanroommc/groovyscript/packmode/Packmode.java b/src/main/java/com/cleanroommc/groovyscript/packmode/Packmode.java index f0e32be5e..9fb07b810 100644 --- a/src/main/java/com/cleanroommc/groovyscript/packmode/Packmode.java +++ b/src/main/java/com/cleanroommc/groovyscript/packmode/Packmode.java @@ -1,16 +1,19 @@ package com.cleanroommc.groovyscript.packmode; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.GroovyScriptConfig; -import com.cleanroommc.groovyscript.helper.Alias; -import com.google.common.base.CaseFormat; -import io.sommers.packmode.api.PackModeAPI; import net.minecraftforge.common.config.Config; import net.minecraftforge.common.config.ConfigManager; import net.minecraftforge.fml.common.eventhandler.Event; + import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.GroovyScriptConfig; +import com.cleanroommc.groovyscript.helper.Alias; +import com.google.common.base.CaseFormat; + +import io.sommers.packmode.api.PackModeAPI; + public class Packmode { private static String packmode; @@ -19,9 +22,7 @@ public class Packmode { public static String getPackmode() { if (GroovyScript.getRunConfig().isIntegratePackmodeMod()) return PackModeAPI.getInstance().getCurrentPackMode(); if (hasPackmode()) return Packmode.packmode; - if (needsPackmode()) { - throw new IllegalStateException("Tried to get packmode which is currently empty!"); - } + if (needsPackmode()) { throw new IllegalStateException("Tried to get packmode which is currently empty!"); } return StringUtils.EMPTY; } @@ -45,9 +46,7 @@ public static void updatePackmode(String packmode) { } public static boolean isValidPackmode(String mode) { - if (GroovyScript.getRunConfig().isIntegratePackmodeMod()) { - return PackModeAPI.getInstance().isValidPackMode(mode); - } + if (GroovyScript.getRunConfig().isIntegratePackmodeMod()) { return PackModeAPI.getInstance().isValidPackMode(mode); } return GroovyScript.getRunConfig().isValidPackmode(mode); } @@ -59,8 +58,6 @@ public ChangeEvent(String packmode) { this.packmode = packmode; } - public String getPackmode() { - return packmode; - } + public String getPackmode() { return packmode; } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/packmode/PackmodeButton.java b/src/main/java/com/cleanroommc/groovyscript/packmode/PackmodeButton.java index d57ffc3a0..43078f41d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/packmode/PackmodeButton.java +++ b/src/main/java/com/cleanroommc/groovyscript/packmode/PackmodeButton.java @@ -1,13 +1,15 @@ package com.cleanroommc.groovyscript.packmode; -import com.cleanroommc.groovyscript.GroovyScript; -import com.google.common.base.CaseFormat; +import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; + import org.jetbrains.annotations.NotNull; -import java.util.List; +import com.cleanroommc.groovyscript.GroovyScript; +import com.google.common.base.CaseFormat; public class PackmodeButton extends GuiButton { @@ -45,11 +47,7 @@ public void updatePackmode() { } } - public String getPackmode() { - return packmode; - } + public String getPackmode() { return packmode; } - public String getDesc() { - return desc; - } + public String getDesc() { return desc; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/packmode/PackmodeSaveData.java b/src/main/java/com/cleanroommc/groovyscript/packmode/PackmodeSaveData.java index 3e451c20d..940d12c88 100644 --- a/src/main/java/com/cleanroommc/groovyscript/packmode/PackmodeSaveData.java +++ b/src/main/java/com/cleanroommc/groovyscript/packmode/PackmodeSaveData.java @@ -1,23 +1,22 @@ package com.cleanroommc.groovyscript.packmode; +import java.util.Objects; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.storage.WorldSavedData; -import org.jetbrains.annotations.NotNull; -import java.util.Objects; +import org.jetbrains.annotations.NotNull; public class PackmodeSaveData extends WorldSavedData { public static final String ID = "groovyscript_packmode"; public static PackmodeSaveData get(World world) { - if (world instanceof WorldServer) { - return get(world.getMinecraftServer()); - } + if (world instanceof WorldServer) { return get(world.getMinecraftServer()); } return null; } @@ -55,18 +54,14 @@ public void readFromNBT(NBTTagCompound nbt) { return compound; } - public boolean isDedicatedServer() { - return dedicatedServer; - } + public boolean isDedicatedServer() { return dedicatedServer; } public void setPackmode(String packmode) { this.packmode = packmode; markDirty(); } - public String getPackmode() { - return packmode; - } + public String getPackmode() { return packmode; } public boolean hasPackmode() { return packmode != null && !packmode.isEmpty(); diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/AbstractCraftingRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/registry/AbstractCraftingRecipeBuilder.java index ccfbc8ef9..9ce09732b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/AbstractCraftingRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/AbstractCraftingRecipeBuilder.java @@ -1,5 +1,17 @@ package com.cleanroommc.groovyscript.registry; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.registry.ForgeRegistries; + +import org.apache.commons.lang3.ArrayUtils; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; @@ -12,24 +24,18 @@ import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.RecipeName; + import groovy.lang.Closure; import it.unimi.dsi.fastutil.chars.Char2ObjectMap; import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; import it.unimi.dsi.fastutil.chars.CharOpenHashSet; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import org.apache.commons.lang3.ArrayUtils; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; public abstract class AbstractCraftingRecipeBuilder { - @Property(value = "groovyscript.wiki.craftingrecipe.output.value", valid = @Comp(value = "null", type = Comp.Type.NOT), priority = 700, hierarchy = 20) + @Property(value = "groovyscript.wiki.craftingrecipe.output.value", + valid = @Comp(value = "null", type = Comp.Type.NOT), + priority = 700, + hierarchy = 20) protected ItemStack output; @Property(value = "groovyscript.wiki.name.value", priority = 100, hierarchy = 20) protected ResourceLocation name; @@ -49,9 +55,7 @@ public AbstractCraftingRecipeBuilder(int width, int height) { } private static IIngredient getIngredient(Char2ObjectMap keyMap, char c) { - if (keyMap.containsKey(c)) { - return keyMap.get(c); - } + if (keyMap.containsKey(c)) { return keyMap.get(c); } return Crafting.getFallback(c); } @@ -110,10 +114,8 @@ protected void handleReplace() { VanillaModule.crafting.removeByOutput(IngredientHelper.toIIngredient(output), false); } else if (replace == 2) { if (name == null) { - GroovyLog.msg("Error replacing Minecraft Crafting recipe") - .add("Name must not be null when replacing by name") - .error() - .post(); + GroovyLog.msg("Error replacing Minecraft Crafting recipe").add("Name must not be null when replacing by name") + .error().post(); return; } ReloadableRegistryManager.removeRegistryEntry(ForgeRegistries.RECIPES, name); @@ -121,9 +123,7 @@ protected void handleReplace() { } @GroovyBlacklist - public String getRecipeNamePrefix() { - return "groovyscript_"; - } + public String getRecipeNamePrefix() { return "groovyscript_"; } @GroovyBlacklist public void validateName() { @@ -132,9 +132,9 @@ public void validateName() { } } - @GroovyBlacklist - @Nullable - protected T validateShape(GroovyLog.Msg msg, List errors, String[] keyBasedMatrix, Char2ObjectOpenHashMap keyMap, IRecipeCreator recipeCreator) { + @GroovyBlacklist @Nullable + protected T validateShape(GroovyLog.Msg msg, List errors, String[] keyBasedMatrix, + Char2ObjectOpenHashMap keyMap, IRecipeCreator recipeCreator) { List ingredients = new ArrayList<>(); if (keyBasedMatrix.length > height) { msg.add("Defined matrix has %d rows, but should only have %d rows", keyBasedMatrix.length, height); @@ -180,8 +180,7 @@ protected T validateShape(GroovyLog.Msg msg, List errors, String[] k return recipeCreator.createRecipe(rowWidth, keyBasedMatrix.length, ingredients); } - @GroovyBlacklist - @Nullable + @GroovyBlacklist @Nullable protected T validateShape(GroovyLog.Msg msg, List> ingredientMatrix, IRecipeCreator recipeCreator) { List ingredients = new ArrayList<>(); if (ingredientMatrix.size() > height) { @@ -214,15 +213,24 @@ public interface IRecipeCreator { public abstract static class AbstractShaped extends AbstractCraftingRecipeBuilder { - @Property(value = "groovyscript.wiki.craftingrecipe.keyMap.value", defaultValue = "' ' = IIngredient.EMPTY", priority = 210, hierarchy = 20) + @Property(value = "groovyscript.wiki.craftingrecipe.keyMap.value", + defaultValue = "' ' = IIngredient.EMPTY", + priority = 210, + hierarchy = 20) protected final Char2ObjectOpenHashMap keyMap = new Char2ObjectOpenHashMap<>(); protected final List errors = new ArrayList<>(); @Property(value = "groovyscript.wiki.craftingrecipe.mirrored.value", hierarchy = 20) protected boolean mirrored; - @Property(value = "groovyscript.wiki.craftingrecipe.keyBasedMatrix.value", requirement = "groovyscript.wiki.craftingrecipe.matrix.required", priority = 200, hierarchy = 20) + @Property(value = "groovyscript.wiki.craftingrecipe.keyBasedMatrix.value", + requirement = "groovyscript.wiki.craftingrecipe.matrix.required", + priority = 200, + hierarchy = 20) protected String[] keyBasedMatrix; - @Property(value = "groovyscript.wiki.craftingrecipe.ingredientMatrix.value", requirement = "groovyscript.wiki.craftingrecipe.matrix.required", valid = { - @Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", type = Comp.Type.LTE)}, priority = 200, hierarchy = 20) + @Property(value = "groovyscript.wiki.craftingrecipe.ingredientMatrix.value", + requirement = "groovyscript.wiki.craftingrecipe.matrix.required", + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", type = Comp.Type.LTE)}, + priority = 200, + hierarchy = 20) protected List> ingredientMatrix; public AbstractShaped(int width, int height) { @@ -304,7 +312,9 @@ public AbstractShaped shape(List> matrix) { public abstract static class AbstractShapeless extends AbstractCraftingRecipeBuilder { @Property(value = "groovyscript.wiki.craftingrecipe.ingredients.value", - valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", type = Comp.Type.LTE)}, priority = 250, hierarchy = 20) + valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", type = Comp.Type.LTE)}, + priority = 250, + hierarchy = 20) protected final List ingredients = new ArrayList<>(); public AbstractShapeless(int width, int height) { @@ -319,17 +329,13 @@ public AbstractShapeless input(IIngredient ingredient) { @RecipeBuilderMethodDescription(field = "ingredients") public AbstractShapeless input(IIngredient... ingredients) { - if (ingredients != null) - for (IIngredient ingredient : ingredients) - input(ingredient); + if (ingredients != null) for (IIngredient ingredient : ingredients) input(ingredient); return this; } @RecipeBuilderMethodDescription(field = "ingredients") public AbstractShapeless input(Collection ingredients) { - if (ingredients != null && !ingredients.isEmpty()) - for (IIngredient ingredient : ingredients) - input(ingredient); + if (ingredients != null && !ingredients.isEmpty()) for (IIngredient ingredient : ingredients) input(ingredient); return this; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/AbstractReloadableStorage.java b/src/main/java/com/cleanroommc/groovyscript/registry/AbstractReloadableStorage.java index c0e35d62d..9f3055676 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/AbstractReloadableStorage.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/AbstractReloadableStorage.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.registry; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import org.jetbrains.annotations.ApiStatus; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import org.jetbrains.annotations.ApiStatus; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; + /** * Stores backup and scripted entries, typically for a {@link VirtualizedRegistry}. * @@ -23,23 +24,17 @@ public AbstractReloadableStorage() { } @GroovyBlacklist - public Collection getBackupRecipes() { - return Collections.unmodifiableCollection(backup); - } + public Collection getBackupRecipes() { return Collections.unmodifiableCollection(backup); } @GroovyBlacklist - public Collection getScriptedRecipes() { - return Collections.unmodifiableCollection(scripted); - } + public Collection getScriptedRecipes() { return Collections.unmodifiableCollection(scripted); } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal private void initBackup() { this.backup = new ArrayList<>(); } - @GroovyBlacklist - @ApiStatus.Internal + @GroovyBlacklist @ApiStatus.Internal private void initScripted() { this.scripted = new ArrayList<>(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/DummyRecipe.java b/src/main/java/com/cleanroommc/groovyscript/registry/DummyRecipe.java index 7a4f635ca..113c1dba1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/DummyRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/DummyRecipe.java @@ -1,13 +1,13 @@ package com.cleanroommc.groovyscript.registry; +import javax.annotation.Nonnull; + import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; import net.minecraftforge.registries.IForgeRegistryEntry; -import javax.annotation.Nonnull; - public class DummyRecipe extends IForgeRegistryEntry.Impl implements IRecipe { @Override @@ -15,8 +15,7 @@ public boolean matches(@Nonnull final InventoryCrafting inv, @Nonnull final Worl return false; } - @Nonnull - @Override + @Nonnull @Override public ItemStack getCraftingResult(@Nonnull final InventoryCrafting inv) { return ItemStack.EMPTY; } @@ -26,9 +25,6 @@ public boolean canFit(final int width, final int height) { return false; } - @Nonnull - @Override - public ItemStack getRecipeOutput() { - return ItemStack.EMPTY; - } + @Nonnull @Override + public ItemStack getRecipeOutput() { return ItemStack.EMPTY; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/ForgeRegistryWrapper.java b/src/main/java/com/cleanroommc/groovyscript/registry/ForgeRegistryWrapper.java index 565e67657..f94b42f48 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/ForgeRegistryWrapper.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/ForgeRegistryWrapper.java @@ -1,17 +1,18 @@ package com.cleanroommc.groovyscript.registry; +import java.util.Collection; +import java.util.Objects; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.registries.IForgeRegistry; +import net.minecraftforge.registries.IForgeRegistryEntry; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IReloadableForgeRegistry; import com.cleanroommc.groovyscript.api.IScriptReloadable; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.IForgeRegistryEntry; - -import java.util.Collection; -import java.util.Objects; public class ForgeRegistryWrapper> extends NamedRegistry implements IScriptReloadable { @@ -27,18 +28,14 @@ public ForgeRegistryWrapper(IForgeRegistry registry, Collection alias } @GroovyBlacklist - public IForgeRegistry getRegistry() { - return registry; - } + public IForgeRegistry getRegistry() { return registry; } - @GroovyBlacklist - @Override + @GroovyBlacklist @Override public final void onReload() { ((IReloadableForgeRegistry) registry).groovyScript$onReload(); } - @GroovyBlacklist - @Override + @GroovyBlacklist @Override public void afterScriptLoad() {} public void add(T entry) { diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/NamedRegistry.java b/src/main/java/com/cleanroommc/groovyscript/registry/NamedRegistry.java index 9fe4702aa..ced059135 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/NamedRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/NamedRegistry.java @@ -1,15 +1,16 @@ package com.cleanroommc.groovyscript.registry; -import com.cleanroommc.groovyscript.api.INamed; -import com.cleanroommc.groovyscript.helper.Alias; -import org.jetbrains.annotations.Nullable; - import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.stream.Collectors; +import org.jetbrains.annotations.Nullable; + +import com.cleanroommc.groovyscript.api.INamed; +import com.cleanroommc.groovyscript.helper.Alias; + public abstract class NamedRegistry implements INamed { protected final String name; @@ -21,21 +22,15 @@ public NamedRegistry() { public NamedRegistry(@Nullable Collection aliases) { Collection local = aliases == null ? Alias.generateOfClass(this) : aliases; - if (local.isEmpty()) { - throw new IllegalArgumentException("NamedRegistry must have at least one name!"); - } + if (local.isEmpty()) { throw new IllegalArgumentException("NamedRegistry must have at least one name!"); } this.aliases = Collections.unmodifiableList(local.stream().distinct().collect(Collectors.toList())); this.name = this.aliases.get(0).toLowerCase(Locale.ENGLISH); } @Override - public String getName() { - return name; - } + public String getName() { return name; } @Override - public List getAliases() { - return aliases; - } + public List getAliases() { return aliases; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/ReloadableRegistryManager.java b/src/main/java/com/cleanroommc/groovyscript/registry/ReloadableRegistryManager.java index 32889425f..ee1c48e39 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/ReloadableRegistryManager.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/ReloadableRegistryManager.java @@ -1,5 +1,24 @@ package com.cleanroommc.groovyscript.registry; +import java.lang.reflect.InvocationTargetException; +import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Supplier; + +import net.minecraft.client.Minecraft; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.TextComponentString; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.registry.ForgeRegistries; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.registries.ForgeRegistry; +import net.minecraftforge.registries.IForgeRegistry; +import net.minecraftforge.registries.IForgeRegistryEntry; + +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.INamed; @@ -10,29 +29,13 @@ import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.core.mixin.jei.JeiProxyAccessor; + import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import mezz.jei.Internal; import mezz.jei.JustEnoughItems; import mezz.jei.ingredients.IngredientFilter; -import net.minecraft.client.Minecraft; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextComponentString; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.registries.ForgeRegistry; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.IForgeRegistryEntry; -import org.jetbrains.annotations.ApiStatus; import sonar.core.integration.jei.JEISonarPlugin; -import java.lang.reflect.InvocationTargetException; -import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Supplier; - @GroovyBlacklist public class ReloadableRegistryManager { @@ -42,9 +45,7 @@ public class ReloadableRegistryManager { private static final Map, List> recipeRecovery = new Object2ObjectOpenHashMap<>(); private static final Map, List> scriptRecipes = new Object2ObjectOpenHashMap<>(); - public static boolean isFirstLoad() { - return firstLoad.get(); - } + public static boolean isFirstLoad() { return firstLoad.get(); } public static void setLoaded() { firstLoad.set(false); @@ -77,30 +78,18 @@ public static void init() { public static void onReload() { GroovyScript.reloadRunConfig(false); VanillaModule.INSTANCE.onReload(); - ModSupport.getAllContainers().stream() - .filter(GroovyContainer::isLoaded) - .map(GroovyContainer::get) - .map(GroovyPropertyContainer::getRegistries) - .flatMap(Collection::stream) - .distinct() - .filter(INamed::isEnabled) - .filter(IScriptReloadable.class::isInstance) - .map(IScriptReloadable.class::cast) - .forEach(IScriptReloadable::onReload); + ModSupport.getAllContainers().stream().filter(GroovyContainer::isLoaded).map(GroovyContainer::get).map( + GroovyPropertyContainer::getRegistries) + .flatMap(Collection::stream).distinct().filter(INamed::isEnabled).filter(IScriptReloadable.class::isInstance) + .map(IScriptReloadable.class::cast).forEach(IScriptReloadable::onReload); } @ApiStatus.Internal public static void afterScriptRun() { - ModSupport.getAllContainers().stream() - .filter(GroovyContainer::isLoaded) - .map(GroovyContainer::get) - .map(GroovyPropertyContainer::getRegistries) - .flatMap(Collection::stream) - .distinct() - .filter(INamed::isEnabled) - .filter(IScriptReloadable.class::isInstance) - .map(IScriptReloadable.class::cast) - .forEach(IScriptReloadable::afterScriptLoad); + ModSupport.getAllContainers().stream().filter(GroovyContainer::isLoaded).map(GroovyContainer::get).map( + GroovyPropertyContainer::getRegistries) + .flatMap(Collection::stream).distinct().filter(INamed::isEnabled).filter(IScriptReloadable.class::isInstance) + .map(IScriptReloadable.class::cast).forEach(IScriptReloadable::afterScriptLoad); VanillaModule.INSTANCE.afterScriptLoad(); unfreezeForgeRegistries(); } @@ -109,7 +98,8 @@ public static > void addRegistryEntry(IForgeReg addRegistryEntry(registry, new ResourceLocation(name), entry); } - public static > void addRegistryEntry(IForgeRegistry registry, ResourceLocation name, V entry) { + public static > void addRegistryEntry(IForgeRegistry registry, ResourceLocation name, + V entry) { ((IReloadableForgeRegistry) registry).groovyScript$registerEntry(entry.setRegistryName(name)); } @@ -140,8 +130,7 @@ public static boolean hasNonDummyRecipe(ResourceLocation rl) { /** * Reloads JEI completely. Is called after groovy scripts are ran. */ - @ApiStatus.Internal - @SideOnly(Side.CLIENT) + @ApiStatus.Internal @SideOnly(Side.CLIENT) public static void reloadJei(boolean msgPlayer) { if (ModSupport.JEI.isLoaded()) { JeiProxyAccessor jeiProxy = (JeiProxyAccessor) JustEnoughItems.getProxy(); diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedForgeRegistryEntry.java b/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedForgeRegistryEntry.java index 6e4e2a1af..6643a49e6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedForgeRegistryEntry.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedForgeRegistryEntry.java @@ -1,9 +1,9 @@ package com.cleanroommc.groovyscript.registry; -import net.minecraftforge.registries.IForgeRegistryEntry; - import java.util.Objects; +import net.minecraftforge.registries.IForgeRegistryEntry; + public class VirtualizedForgeRegistryEntry> { private final T value; @@ -16,17 +16,11 @@ public VirtualizedForgeRegistryEntry(T value, int id, Object override) { this.override = override; } - public T getValue() { - return value; - } + public T getValue() { return value; } - public int getId() { - return id; - } + public int getId() { return id; } - public Object getOverride() { - return override; - } + public Object getOverride() { return override; } @Override public boolean equals(Object o) { diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedRegistry.java b/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedRegistry.java index 546edecd4..e7e985038 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedRegistry.java @@ -1,11 +1,12 @@ package com.cleanroommc.groovyscript.registry; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.IScriptReloadable; +import java.util.Collection; + import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import java.util.Collection; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.IScriptReloadable; public abstract class VirtualizedRegistry extends NamedRegistry implements IScriptReloadable { @@ -20,16 +21,11 @@ public VirtualizedRegistry(@Nullable Collection aliases) { this.recipeStorage = createRecipeStorage(); } - @Override - @GroovyBlacklist - @ApiStatus.OverrideOnly + @Override @GroovyBlacklist @ApiStatus.OverrideOnly public abstract void onReload(); - @Override - @GroovyBlacklist - @ApiStatus.OverrideOnly - public void afterScriptLoad() { - } + @Override @GroovyBlacklist @ApiStatus.OverrideOnly + public void afterScriptLoad() {} @GroovyBlacklist protected AbstractReloadableStorage createRecipeStorage() { @@ -37,14 +33,10 @@ protected AbstractReloadableStorage createRecipeStorage() { } @GroovyBlacklist - public Collection getBackupRecipes() { - return recipeStorage.getBackupRecipes(); - } + public Collection getBackupRecipes() { return recipeStorage.getBackupRecipes(); } @GroovyBlacklist - public Collection getScriptedRecipes() { - return recipeStorage.getScriptedRecipes(); - } + public Collection getScriptedRecipes() { return recipeStorage.getScriptedRecipes(); } @GroovyBlacklist public void addBackup(R recipe) { diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/ClosureHelper.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/ClosureHelper.java index 275fd7112..ada70af27 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/ClosureHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/ClosureHelper.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.sandbox; +import java.lang.reflect.*; +import java.util.function.Function; + +import org.codehaus.groovy.runtime.ConvertedClosure; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; -import groovy.lang.Closure; -import org.codehaus.groovy.runtime.ConvertedClosure; -import org.jetbrains.annotations.Nullable; -import java.lang.reflect.*; -import java.util.function.Function; +import groovy.lang.Closure; public class ClosureHelper { @@ -23,17 +25,13 @@ public static T call(Closure closure, Object... args) { @Nullable public static T call(Class expectedType, Closure closure, Object... args) { Object o = call(closure, args); - if (o != null && expectedType.isAssignableFrom(o.getClass())) { - return (T) o; - } + if (o != null && expectedType.isAssignableFrom(o.getClass())) { return (T) o; } return null; } public static T call(T defaultValue, Closure closure, Object... args) { Object o = call(closure, args); - if (o != null && o.getClass().isInstance(defaultValue)) { - return (T) o; - } + if (o != null && o.getClass().isInstance(defaultValue)) { return (T) o; } return defaultValue; } @@ -72,8 +70,7 @@ public static Closure of(Object owner, Function function) { * @param functionalInterface a functional interface like {@link Function} * @return the underlying closure or null if there is no closure */ - @GroovyBlacklist - @Nullable + @GroovyBlacklist @Nullable public static Closure getUnderlyingClosure(Object functionalInterface) { if (!(functionalInterface instanceof Proxy)) return null; // not a closure if (h == null) { @@ -90,15 +87,11 @@ public static Closure getUnderlyingClosure(Object functionalInterface) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new RuntimeException(e); } - if (h == null) { - throw new IllegalStateException("Field h not found"); - } + if (h == null) { throw new IllegalStateException("Field h not found"); } } try { InvocationHandler handler = (InvocationHandler) h.get(functionalInterface); - if (handler instanceof ConvertedClosure convertedClosure) { - return (Closure) convertedClosure.getDelegate(); - } + if (handler instanceof ConvertedClosure convertedClosure) { return (Closure) convertedClosure.getDelegate(); } } catch (IllegalArgumentException | IllegalAccessException e) { GroovyLog.get().exception(e); } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledClass.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledClass.java index 117e4b606..0b23b5f70 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledClass.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledClass.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.sandbox; -import com.cleanroommc.groovyscript.api.GroovyLog; -import org.apache.commons.lang3.builder.ToStringBuilder; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.nio.file.Files; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import com.cleanroommc.groovyscript.api.GroovyLog; + class CompiledClass { public static final String CLASS_SUFFIX = ".clz"; @@ -71,18 +72,12 @@ protected File getDataFile(String basePath) { return FileUtil.makeFile(basePath, FileUtil.getParent(this.path), this.name + CLASS_SUFFIX); } - public String getName() { - return name; - } + public String getName() { return name; } - public String getPath() { - return path; - } + public String getPath() { return path; } @Override public String toString() { - return new ToStringBuilder(this) - .append("name", name) - .toString(); + return new ToStringBuilder(this).append("name", name).toString(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledScript.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledScript.java index 6b849d0c7..d98f09770 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledScript.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/CompiledScript.java @@ -1,17 +1,19 @@ package com.cleanroommc.groovyscript.sandbox; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.jetbrains.annotations.NotNull; + import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.helper.JsonHelper; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import groovy.lang.GroovyClassLoader; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.jetbrains.annotations.NotNull; -import java.io.File; -import java.util.ArrayList; -import java.util.List; +import groovy.lang.GroovyClassLoader; class CompiledScript extends CompiledClass { @@ -28,15 +30,11 @@ public CompiledScript(String path, String name, long lastEdited) { this.lastEdited = lastEdited; } - public boolean isClosure() { - return lastEdited < 0; - } + public boolean isClosure() { return lastEdited < 0; } public CompiledClass findInnerClass(String clazz) { for (CompiledClass comp : this.innerClasses) { - if (comp.name.equals(clazz)) { - return comp; - } + if (comp.name.equals(clazz)) { return comp; } } CompiledClass comp = new CompiledClass(this.path, clazz); this.innerClasses.add(comp); @@ -82,7 +80,9 @@ public JsonObject toJson() { } public static CompiledScript fromJson(JsonObject json, String scriptRoot, String cacheRoot) { - CompiledScript cs = new CompiledScript(json.get("path").getAsString(), JsonHelper.getString(json, null, "name"), json.get("lm").getAsLong()); + CompiledScript cs = new CompiledScript(json.get("path").getAsString(), JsonHelper.getString(json, null, "name"), json.get( + "lm") + .getAsLong()); if (new File(scriptRoot, cs.path).exists()) { if (json.has("inner")) { for (JsonElement element : json.getAsJsonArray("inner")) { @@ -111,18 +111,16 @@ public void deleteCache(String cachePath) { } public boolean checkPreprocessors(File basePath) { - return this.preprocessors == null || - this.preprocessors.isEmpty() || - Preprocessor.validatePreprocessor(new File(basePath, this.path), this.preprocessors); + return this.preprocessors == null || this.preprocessors.isEmpty() || Preprocessor.validatePreprocessor(new File(basePath, + this.path), + this.preprocessors); } @Override public String toString() { - return new ToStringBuilder(this) - .append("name", name) - .append("path", path) - .append("innerClasses", innerClasses) - .append("lastEdited", lastEdited) - .toString(); + return new ToStringBuilder(this).append("name", name).append("path", path).append("innerClasses", innerClasses).append( + "lastEdited", + lastEdited) + .toString(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/FileUtil.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/FileUtil.java index c1b39c494..be6862a7b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/FileUtil.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/FileUtil.java @@ -1,28 +1,29 @@ package com.cleanroommc.groovyscript.sandbox; -import net.minecraftforge.fml.common.Loader; -import org.apache.commons.lang3.StringUtils; - import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.nio.file.Files; +import net.minecraftforge.fml.common.Loader; + +import org.apache.commons.lang3.StringUtils; + public class FileUtil { public static String relativize(String rootPath, String longerThanRootPath) { try { longerThanRootPath = URLDecoder.decode(longerThanRootPath, "UTF-8"); - } catch (UnsupportedEncodingException ignored) { - } + } catch (UnsupportedEncodingException ignored) {} if (File.separatorChar != '/') { longerThanRootPath = longerThanRootPath.replace('/', File.separatorChar); } int index = longerThanRootPath.indexOf(rootPath); if (index < 0) { - throw new IllegalArgumentException("The path '" + longerThanRootPath + "' does not contain the root path '" + rootPath + "'"); + throw new IllegalArgumentException("The path '" + longerThanRootPath + "' does not contain the root path '" + + rootPath + "'"); } return longerThanRootPath.substring(index + rootPath.length() + 1); } @@ -54,22 +55,16 @@ public static String sanitizePath(String path) { return path.replace(getOtherSeparatorChar(), File.separatorChar); } - public static char getOtherSeparatorChar() { - return File.separatorChar == '/' ? '\\' : '/'; - } + public static char getOtherSeparatorChar() { return File.separatorChar == '/' ? '\\' : '/'; } public static File makeFile(String... pieces) { return new File(makePath(pieces)); } - public static String getMinecraftHome() { - return Loader.instance().getConfigDir().getParent(); - } + public static String getMinecraftHome() { return Loader.instance().getConfigDir().getParent(); } public static boolean mkdirs(File file) { - if (file.isDirectory()) { - return file.mkdirs(); - } + if (file.isDirectory()) { return file.mkdirs(); } return file.getParentFile().mkdirs(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyLogImpl.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyLogImpl.java index 0813e1e28..62caa3441 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyLogImpl.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyLogImpl.java @@ -1,18 +1,5 @@ package com.cleanroommc.groovyscript.sandbox; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.GroovyLog; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.intellij.lang.annotations.Flow; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.io.*; import java.nio.file.Files; import java.nio.file.Path; @@ -28,6 +15,21 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.intellij.lang.annotations.Flow; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; + public class GroovyLogImpl implements GroovyLog { public static final GroovyLogImpl LOG = new GroovyLogImpl(); @@ -39,8 +41,8 @@ public class GroovyLogImpl implements GroovyLog { private List errors = new ArrayList<>(); private GroovyLogImpl() { - File logFile = new File(Loader.instance().getConfigDir().toPath().getParent().toString() + - File.separator + "logs" + File.separator + getLogFileName()); + File logFile = new File(Loader.instance().getConfigDir().toPath().getParent().toString() + File.separator + "logs" + + File.separator + getLogFileName()); logFilePath = logFile.toPath(); PrintWriter tempWriter; try { @@ -51,7 +53,8 @@ private GroovyLogImpl() { // create file Files.createFile(logFilePath); // create writer which automatically flushes on write - tempWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(logFile.toPath()))), true); + tempWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(logFile.toPath()))), + true); } catch (IOException e) { e.printStackTrace(); tempWriter = new PrintWriter(System.out); @@ -74,19 +77,13 @@ public List collectErrors() { } @Override - public boolean isDebug() { - return GroovyScript.getRunConfig().isDebug(); - } + public boolean isDebug() { return GroovyScript.getRunConfig().isDebug(); } @Override - public PrintWriter getWriter() { - return printWriter; - } + public PrintWriter getWriter() { return printWriter; } @Override - public Path getLogFilerPath() { - return logFilePath; - } + public Path getLogFilerPath() { return logFilePath; } @Override public void log(GroovyLog.Msg msg) { @@ -131,9 +128,7 @@ public void log(GroovyLog.Msg msg) { } } - public Path getPath() { - return logFilePath; - } + public Path getPath() { return logFilePath; } /** * Logs a info msg to the groovy log AND Minecraft's log @@ -251,7 +246,8 @@ public void errorMC(String msg, Object... args) { public void exception(Throwable throwable) { String msg = throwable.toString(); this.errors.add(msg); - writeLogLine(formatLine("ERROR", "An exception occurred while running scripts. Look at latest.log for a full stacktrace:")); + writeLogLine(formatLine("ERROR", + "An exception occurred while running scripts. Look at latest.log for a full stacktrace:")); writeLogLine("\t" + msg); Pattern pattern = Pattern.compile("(\\w*).run\\(\\1(\\.\\w*):(\\d*)\\)"); for (String line : prepareStackTrace(throwable.getStackTrace())) { @@ -283,11 +279,8 @@ private List prepareStackTrace(StackTraceElement[] stackTrace) { } private String formatLine(String level, String msg) { - return timeFormat.format(new Date()) + - (FMLCommonHandler.instance().getEffectiveSide().isClient() ? " [CLIENT/" : " [SERVER/") + - level + "]" + - " [" + getSource() + "]: " + - msg; + return timeFormat.format(new Date()) + (FMLCommonHandler.instance().getEffectiveSide().isClient() ? " [CLIENT/" : + " [SERVER/") + level + "]" + " [" + getSource() + "]: " + msg; } private String getSource() { @@ -332,9 +325,7 @@ private MsgImpl(String msg, Object... data) { } @Flow(source = "this.level") - public boolean isValid() { - return level != null; - } + public boolean isValid() { return level != null; } @Override public Msg add(String msg, Object... data) { @@ -344,17 +335,13 @@ public Msg add(String msg, Object... data) { @Override public Msg add(boolean condition, String msg, Object... args) { - if (condition) { - return add(msg, args); - } + if (condition) { return add(msg, args); } return this; } @Override public Msg add(boolean condition, Supplier msg) { - if (condition) { - return add(msg.get()); - } + if (condition) { return add(msg.get()); } return this; } @@ -409,24 +396,16 @@ public Msg logToMc(boolean logToMC) { } @Override - public @NotNull String getMainMsg() { - return mainMsg; - } + public @NotNull String getMainMsg() { return mainMsg; } @Override - public @NotNull List getSubMessages() { - return messages; - } + public @NotNull List getSubMessages() { return messages; } @Override - public @Nullable Throwable getException() { - return throwable; - } + public @Nullable Throwable getException() { return throwable; } @Override - public Level getLevel() { - return level; - } + public Level getLevel() { return level; } @Override public boolean shouldLogToMc() { diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovySandbox.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovySandbox.java index 7c4abe4aa..d3913be56 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovySandbox.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovySandbox.java @@ -1,9 +1,25 @@ package com.cleanroommc.groovyscript.sandbox; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; + +import org.codehaus.groovy.control.CompilerConfiguration; +import org.codehaus.groovy.runtime.InvokerHelper; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.INamed; import com.cleanroommc.groovyscript.helper.Alias; + import groovy.lang.Binding; import groovy.lang.Closure; import groovy.lang.Script; @@ -11,20 +27,6 @@ import groovy.util.ResourceException; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import org.codehaus.groovy.control.CompilerConfiguration; -import org.codehaus.groovy.runtime.InvokerHelper; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; /** * @author brachy84 @@ -66,9 +68,7 @@ public void registerBinding(INamed named) { protected void registerStaticImports(Class... classes) { Objects.requireNonNull(classes); - if (classes.length == 0) { - throw new IllegalArgumentException("Static imports must not be empty!"); - } + if (classes.length == 0) { throw new IllegalArgumentException("Static imports must not be empty!"); } Collections.addAll(staticImports, classes); } @@ -131,7 +131,8 @@ protected void loadScripts(GroovyScriptEngine engine, Binding binding, Set continue; } if (clazz.getSuperclass() != Script.class) { - GroovyLog.get().errorMC("Class file '{}' should be defined in the runConfig in the classes property!", scriptFile); + GroovyLog.get().errorMC("Class file '{}' should be defined in the runConfig in the classes property!", + scriptFile); continue; } if (shouldRunFile(scriptFile)) { @@ -161,7 +162,7 @@ protected void loadClassScripts(GroovyScriptEngine engine, Binding binding, Set< } } - protected void runScript(Script script){ + protected void runScript(Script script) { setCurrentScript(script.getClass().getName()); script.run(); setCurrentScript(null); @@ -182,16 +183,13 @@ public T runClosure(Closure closure, Object... args) { } @ApiStatus.OverrideOnly - protected void postInitBindings(Binding binding) { - } + protected void postInitBindings(Binding binding) {} @ApiStatus.OverrideOnly - protected void initEngine(GroovyScriptEngine engine, CompilerConfiguration config) { - } + protected void initEngine(GroovyScriptEngine engine, CompilerConfiguration config) {} @ApiStatus.OverrideOnly - protected void preRun() { - } + protected void preRun() {} @ApiStatus.OverrideOnly protected boolean shouldRunFile(File file) { @@ -199,32 +197,21 @@ protected boolean shouldRunFile(File file) { } @ApiStatus.OverrideOnly - protected void postRun() { - } + protected void postRun() {} public abstract Collection getClassFiles(); public abstract Collection getScriptFiles(); - public boolean isRunning() { - return this.running.get(); - } + public boolean isRunning() { return this.running.get(); } - public Map getBindings() { - return bindings; - } + public Map getBindings() { return bindings; } - public Set> getStaticImports() { - return staticImports; - } + public Set> getStaticImports() { return staticImports; } - public String getCurrentScript() { - return currentScript; - } + public String getCurrentScript() { return currentScript; } - protected void setCurrentScript(String currentScript) { - this.currentScript = currentScript; - } + protected void setCurrentScript(String currentScript) { this.currentScript = currentScript; } public static String getRelativePath(String source) { try { diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java index ac97f4abb..603fee053 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java @@ -1,5 +1,24 @@ package com.cleanroommc.groovyscript.sandbox; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; + +import net.minecraft.util.math.MathHelper; +import net.minecraftforge.common.MinecraftForge; + +import org.apache.commons.io.FileUtils; +import org.apache.groovy.internal.util.UncheckedThrow; +import org.codehaus.groovy.control.CompilerConfiguration; +import org.codehaus.groovy.control.SourceUnit; +import org.codehaus.groovy.control.customizers.ImportCustomizer; +import org.codehaus.groovy.runtime.InvokerInvocationException; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; @@ -15,29 +34,13 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; + import groovy.lang.*; import groovy.util.GroovyScriptEngine; import groovy.util.ResourceException; import groovy.util.ScriptException; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import net.minecraft.util.math.MathHelper; -import net.minecraftforge.common.MinecraftForge; -import org.apache.commons.io.FileUtils; -import org.apache.groovy.internal.util.UncheckedThrow; -import org.codehaus.groovy.control.CompilerConfiguration; -import org.codehaus.groovy.control.SourceUnit; -import org.codehaus.groovy.control.customizers.ImportCustomizer; -import org.codehaus.groovy.runtime.InvokerInvocationException; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; public class GroovyScriptSandbox extends GroovySandbox { @@ -66,36 +69,22 @@ public GroovyScriptSandbox(File scriptRoot, File cacheRoot) throws MalformedURLE this.importCustomizer.addStaticStars(GroovyHelper.class.getName(), MathHelper.class.getName()); registerStaticImports(GroovyHelper.class, MathHelper.class); - this.importCustomizer.addImports("net.minecraft.world.World", - "net.minecraft.block.state.IBlockState", - "net.minecraft.block.Block", - "net.minecraft.block.SoundType", - "net.minecraft.enchantment.Enchantment", - "net.minecraft.entity.Entity", - "net.minecraft.entity.player.EntityPlayer", - "net.minecraft.init.Biomes", - "net.minecraft.init.Blocks", - "net.minecraft.init.Enchantments", - "net.minecraft.init.Items", - "net.minecraft.init.MobEffects", - "net.minecraft.init.PotionTypes", - "net.minecraft.init.SoundEvents", - "net.minecraft.item.EnumRarity", - "net.minecraft.item.Item", - "net.minecraft.item.ItemStack", - "net.minecraft.nbt.NBTTagCompound", - "net.minecraft.nbt.NBTTagList", - "net.minecraft.tileentity.TileEntity", - "net.minecraft.util.math.BlockPos", - "net.minecraft.util.DamageSource", - "net.minecraft.util.EnumHand", - "net.minecraft.util.EnumHandSide", - "net.minecraft.util.EnumFacing", - "net.minecraft.util.ResourceLocation", + this.importCustomizer.addImports("net.minecraft.world.World", "net.minecraft.block.state.IBlockState", + "net.minecraft.block.Block", "net.minecraft.block.SoundType", + "net.minecraft.enchantment.Enchantment", "net.minecraft.entity.Entity", + "net.minecraft.entity.player.EntityPlayer", "net.minecraft.init.Biomes", + "net.minecraft.init.Blocks", "net.minecraft.init.Enchantments", + "net.minecraft.init.Items", "net.minecraft.init.MobEffects", + "net.minecraft.init.PotionTypes", "net.minecraft.init.SoundEvents", + "net.minecraft.item.EnumRarity", "net.minecraft.item.Item", + "net.minecraft.item.ItemStack", "net.minecraft.nbt.NBTTagCompound", + "net.minecraft.nbt.NBTTagList", "net.minecraft.tileentity.TileEntity", + "net.minecraft.util.math.BlockPos", "net.minecraft.util.DamageSource", + "net.minecraft.util.EnumHand", "net.minecraft.util.EnumHandSide", + "net.minecraft.util.EnumFacing", "net.minecraft.util.ResourceLocation", "net.minecraftforge.fml.common.eventhandler.EventPriority", "com.cleanroommc.groovyscript.event.EventBusType", - "net.minecraftforge.fml.relauncher.Side", - "net.minecraftforge.fml.relauncher.SideOnly"); + "net.minecraftforge.fml.relauncher.Side", "net.minecraftforge.fml.relauncher.SideOnly"); this.storedExceptions = new Object2ObjectOpenHashMap<>(); readIndex(); } @@ -113,7 +102,8 @@ private void readIndex() { } for (JsonElement element : json.getAsJsonArray("index")) { if (element.isJsonObject()) { - CompiledScript cs = CompiledScript.fromJson(element.getAsJsonObject(), this.scriptRoot.getPath(), this.cacheRoot.getPath()); + CompiledScript cs = CompiledScript.fromJson(element.getAsJsonObject(), this.scriptRoot.getPath(), this.cacheRoot + .getPath()); if (cs != null) { this.index.put(cs.path, cs); } @@ -151,7 +141,8 @@ public void run(LoadStage currentLoadStage) { try { super.load(); } catch (IOException | ScriptException | ResourceException e) { - GroovyLog.get().errorMC("An exception occurred while trying to run groovy code! This is might be a internal groovy issue."); + GroovyLog.get().errorMC( + "An exception occurred while trying to run groovy code! This is might be a internal groovy issue."); GroovyLog.get().exception(e); } catch (Throwable t) { GroovyLog.get().exception(t); @@ -169,14 +160,12 @@ protected void runScript(Script script) { super.runScript(script); } - @ApiStatus.Internal - @Override + @ApiStatus.Internal @Override public void load() throws Exception { throw new UnsupportedOperationException("Use run(Loader loader) instead!"); } - @ApiStatus.Internal - @Override + @ApiStatus.Internal @Override public T runClosure(Closure closure, Object... args) { startRunning(); T result = null; @@ -226,9 +215,8 @@ public void onCompileClass(SourceUnit su, String path, Class clazz, byte[] co // we need to find the source unit of the compiled class SourceUnit trueSource = su.getAST().getUnit().getScriptSourceLocation(mainClassName(clazz.getName())); String truePath = trueSource == null ? shortPath : FileUtil.relativize(this.scriptRoot.getPath(), trueSource.getName()); - if (shortPath.equals(truePath) && - su.getAST().getMainClassName() != null && - !su.getAST().getMainClassName().equals(clazz.getName())) { + if (shortPath.equals(truePath) && su.getAST().getMainClassName() != null && !su.getAST().getMainClassName().equals(clazz + .getName())) { inner = true; } @@ -292,7 +280,8 @@ protected Class loadScriptClass(GroovyScriptEngine engine, File file) { Class clazz = super.loadScriptClass(engine, relativeFile); if (comp.clazz == null) { // should not happen - GroovyLog.get().errorMC("Class for {} was loaded, but didn't receive class created callback! Index: {}", relativeFile, this.index); + GroovyLog.get().errorMC("Class for {} was loaded, but didn't receive class created callback! Index: {}", + relativeFile, this.index); if (ENABLE_CACHE) comp.clazz = clazz; } } else { @@ -361,17 +350,11 @@ public Collection getScriptFiles() { } @Nullable - public LoadStage getCurrentLoader() { - return currentLoadStage; - } + public LoadStage getCurrentLoader() { return currentLoadStage; } - public ImportCustomizer getImportCustomizer() { - return importCustomizer; - } + public ImportCustomizer getImportCustomizer() { return importCustomizer; } - public File getScriptRoot() { - return scriptRoot; - } + public File getScriptRoot() { return scriptRoot; } @ApiStatus.Internal public boolean deleteScriptCache() { diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/LoadStage.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/LoadStage.java index a6fb20165..d2b8ffc8f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/LoadStage.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/LoadStage.java @@ -6,9 +6,7 @@ public enum LoadStage { - PRE_INIT("preInit", false, -1000000), - INIT("init", false, -1000), - POST_INIT("postInit", true, 0); + PRE_INIT("preInit", false, -1000000), INIT("init", false, -1000), POST_INIT("postInit", true, 0); private static List stages; @@ -30,17 +28,11 @@ public static List getLoadStages() { this.priority = priority; } - public String getName() { - return name; - } + public String getName() { return name; } - public boolean isReloadable() { - return reloadable; - } + public boolean isReloadable() { return reloadable; } - public int getPriority() { - return priority; - } + public int getPriority() { return priority; } @Override public String toString() { diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/Preprocessor.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/Preprocessor.java index 77577d253..fd3cd8184 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/Preprocessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/Preprocessor.java @@ -1,22 +1,24 @@ package com.cleanroommc.groovyscript.sandbox; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.*; +import java.util.function.BiPredicate; + +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.helper.Alias; import com.cleanroommc.groovyscript.packmode.Packmode; import com.cleanroommc.groovyscript.registry.ReloadableRegistryManager; import com.google.common.base.CaseFormat; + import io.sommers.packmode.api.PackModeAPI; import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.*; -import java.util.function.BiPredicate; public class Preprocessor { @@ -52,9 +54,7 @@ public static List parsePreprocessors(File file) { if (line.startsWith("//")) { line = line.substring(2).trim(); if (line.isEmpty()) continue; - } else if (!isComment) { - return preprocessors.isEmpty() ? Collections.emptyList() : preprocessors; - } + } else if (!isComment) { return preprocessors.isEmpty() ? Collections.emptyList() : preprocessors; } if (isComment && line.endsWith("*/")) { isComment = false; } @@ -71,9 +71,7 @@ public static List parsePreprocessors(File file) { public static boolean validatePreprocessor(File file, List preprocessors) { for (String pp : preprocessors) { - if (!processPreprocessor(file, pp)) { - return false; - } + if (!processPreprocessor(file, pp)) { return false; } } return true; } @@ -99,38 +97,35 @@ private static boolean processPreprocessor(File file, String line) { private static boolean checkModsLoaded(File file, String[] mods) { for (String mod : mods) { - if (!Loader.isModLoaded(mod)) { - return false; - } + if (!Loader.isModLoaded(mod)) { return false; } } return true; } private static boolean checkSide(File file, String[] sides) { if (sides.length != 1) { - GroovyLog.get().error("Side preprocessor in file '{}' should have exactly one argument, but found {}", file.getName(), Arrays.asList(sides)); + GroovyLog.get().error("Side preprocessor in file '{}' should have exactly one argument, but found {}", file.getName(), + Arrays.asList(sides)); return true; } String side = sides[0].toUpperCase(); - if ("CLIENT".equals(side)) { - return FMLCommonHandler.instance().getSide().isClient(); - } - if ("SERVER".equals(side)) { - return FMLCommonHandler.instance().getSide().isServer(); - } - GroovyLog.get().error("Side processor argument in file '{}' must be CLIENT or SERVER (lower case is allowed too)", file.getName()); + if ("CLIENT".equals(side)) { return FMLCommonHandler.instance().getSide().isClient(); } + if ("SERVER".equals(side)) { return FMLCommonHandler.instance().getSide().isServer(); } + GroovyLog.get().error("Side processor argument in file '{}' must be CLIENT or SERVER (lower case is allowed too)", file + .getName()); return true; } private static boolean checkPackmode(File file, String[] modes) { for (String mode : modes) { if (!Packmode.isValidPackmode(mode)) { - List valid = GroovyScript.getRunConfig().isIntegratePackmodeMod() ? PackModeAPI.getInstance().getPackModes() - : GroovyScript.getRunConfig().getPackmodeList(); - GroovyLog.get().error("The packmode '{}' specified in file '{}' does not exist. Valid values are {}", mode, file.getName(), valid); - } else if (Packmode.getPackmode().equals(Alias.autoConvertTo(mode, CaseFormat.LOWER_UNDERSCORE))) { - return true; - } + List valid = GroovyScript.getRunConfig().isIntegratePackmodeMod() ? PackModeAPI.getInstance() + .getPackModes() : + GroovyScript.getRunConfig().getPackmodeList(); + GroovyLog.get().error("The packmode '{}' specified in file '{}' does not exist. Valid values are {}", mode, file + .getName(), + valid); + } else if (Packmode.getPackmode().equals(Alias.autoConvertTo(mode, CaseFormat.LOWER_UNDERSCORE))) { return true; } } return false; } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java index e30b92a69..22e671295 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/RunConfig.java @@ -1,5 +1,21 @@ package com.cleanroommc.groovyscript.sandbox; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.*; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModMetadata; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.ApiStatus; + import com.cleanroommc.groovyscript.GroovyScript; import com.cleanroommc.groovyscript.GroovyScriptConfig; import com.cleanroommc.groovyscript.api.GroovyLog; @@ -10,23 +26,10 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; + import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModMetadata; -import org.apache.commons.lang3.tuple.Pair; -import org.jetbrains.annotations.ApiStatus; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; public class RunConfig { @@ -51,7 +54,8 @@ public static JsonObject createDefaultJson() { JsonObject packmode = new JsonObject(); packmode.add("values", new JsonArray()); packmode.addProperty("default", ""); - packmode.addProperty("_comment", "By default the packmode is not synced with the packmode mod. You can enable integration, but you can no longer change packmode on the fly."); + packmode.addProperty("_comment", + "By default the packmode is not synced with the packmode mod. You can enable integration, but you can no longer change packmode on the fly."); packmode.addProperty("integratePackmodeMod", false); json.add("packmode", packmode); return json; @@ -87,9 +91,7 @@ public static JsonObject createDefaultJson() { public static boolean isGroovyFile(String path) { for (String suffix : GROOVY_SUFFIXES) { - if (path.endsWith(suffix)) { - return true; - } + if (path.endsWith(suffix)) { return true; } } return false; } @@ -113,9 +115,7 @@ public RunConfig(JsonObject json) { @ApiStatus.Internal public void reload(JsonObject json, boolean init) { - if (GroovyScript.isSandboxLoaded() && GroovyScript.getSandbox().isRunning()) { - throw new RuntimeException(); - } + if (GroovyScript.isSandboxLoaded() && GroovyScript.getSandbox().isRunning()) { throw new RuntimeException(); } this.debug = JsonHelper.getBoolean(json, false, "debug"); this.classes.clear(); this.loaderPaths.clear(); @@ -155,7 +155,9 @@ public void reload(JsonObject json, boolean init) { JsonObject jsonLoaders = JsonHelper.getJsonObject(json, "loaders"); List> pathsList = new ArrayList<>(); - GroovyLog.Msg errorMsg = GroovyLog.msg("Fatal while parsing runConfig.json").add("Files should NOT be ran in multiple loaders!").logToMc().fatal(); + GroovyLog.Msg errorMsg = GroovyLog.msg("Fatal while parsing runConfig.json").add( + "Files should NOT be ran in multiple loaders!") + .logToMc().fatal(); for (Map.Entry entry : jsonLoaders.entrySet()) { JsonArray loader = (JsonArray) entry.getValue(); @@ -193,7 +195,8 @@ public void reload(JsonObject json, boolean init) { } if (this.integratePackmodeMod && arePackmodesConfigured()) { this.packmodeConfigState |= 2; - GroovyLog.get().error("Integration with the packmode mod is enabled, but packmodes are also configured in GroovyScript,"); + GroovyLog.get().error( + "Integration with the packmode mod is enabled, but packmodes are also configured in GroovyScript,"); GroovyLog.get().error("You should use the packmode mod to configure packmodes if integration is enabled,"); } if (arePackmodesConfigured() && !Packmode.hasPackmode()) { @@ -212,42 +215,29 @@ public void reload(JsonObject json, boolean init) { } } - public String getPackName() { - return packName; - } + public String getPackName() { return packName; } public String getPackId() { if (this.invalidPackId && !this.warnedAboutInvalidPackId) { - GroovyLog.msg("Fatal error while trying to use the pack id") - .add("specified pack id is invalid or empty ('{}')", this.packId) - .add("pack id must only contain lower case letters and underscores") - .add("see https://groovyscript-docs.readthedocs.io/en/latest/getting_started/#run-config for more info") - .fatal() - .post(); + GroovyLog.msg("Fatal error while trying to use the pack id").add("specified pack id is invalid or empty ('{}')", + this.packId).add( + "pack id must only contain lower case letters and underscores") + .add("see https://groovyscript-docs.readthedocs.io/en/latest/getting_started/#run-config for more info") + .fatal().post(); this.warnedAboutInvalidPackId = true; } return packId; } - public String getPackOrModId() { - return this.invalidPackId ? GroovyScript.ID : this.packId; - } + public String getPackOrModId() { return this.invalidPackId ? GroovyScript.ID : this.packId; } - public String getPackOrModName() { - return this.packName.isEmpty() ? GroovyScript.NAME : this.packName; - } + public String getPackOrModName() { return this.packName.isEmpty() ? GroovyScript.NAME : this.packName; } - public boolean isValidPackId() { - return !invalidPackId; - } + public boolean isValidPackId() { return !invalidPackId; } - public String getVersion() { - return version; - } + public String getVersion() { return version; } - public boolean isDebug() { - return debug; - } + public boolean isDebug() { return debug; } public boolean isValidPackmode(String packmode) { return this.packmodeSet.contains(packmode); @@ -257,9 +247,7 @@ public boolean arePackmodesConfigured() { return !this.packmodeSet.isEmpty(); } - public List getPackmodeList() { - return Collections.unmodifiableList(packmodeList); - } + public List getPackmodeList() { return Collections.unmodifiableList(packmodeList); } public ResourceLocation makeLoc(String name) { return new ResourceLocation(getPackId(), name); @@ -275,13 +263,9 @@ public void initPackmode() { } } - public boolean isIntegratePackmodeMod() { - return integratePackmodeMod; - } + public boolean isIntegratePackmodeMod() { return integratePackmodeMod; } - public int getPackmodeConfigState() { - return packmodeConfigState; - } + public int getPackmodeConfigState() { return packmodeConfigState; } public boolean isLoaderConfigured(String loader) { List path = this.classes.get(loader); @@ -316,19 +300,17 @@ private Collection getSortedFilesOf(File root, Collection paths) { } int pathSize = path.split(separator).length; try (Stream stream = Files.walk(rootFile.toPath())) { - stream.filter(path1 -> isGroovyFile(path1.toString())) - .map(Path::toFile) - //.filter(Preprocessor::validatePreprocessors) - .sorted(Comparator.comparing(File::getPath)) - .forEach(file -> { - if (files.containsKey(file)) { - if (pathSize > files.getInt(file)) { - files.put(file, pathSize); - } - } else { - files.put(file, pathSize); - } - }); + stream.filter(path1 -> isGroovyFile(path1.toString())).map(Path::toFile) + //.filter(Preprocessor::validatePreprocessors) + .sorted(Comparator.comparing(File::getPath)).forEach(file -> { + if (files.containsKey(file)) { + if (pathSize > files.getInt(file)) { + files.put(file, pathSize); + } + } else { + files.put(file, pathSize); + } + }); } catch (IOException e) { throw new RuntimeException(e); } @@ -343,9 +325,7 @@ private static String sanitizePath(String path) { return path; } - private static String getSeparator() { - return File.separatorChar == '\\' ? "\\\\" : File.separator; - } + private static String getSeparator() { return File.separatorChar == '\\' ? "\\\\" : File.separator; } private static boolean checkValid(GroovyLog.Msg errorMsg, List> paths, String loader, String path) { boolean valid = true; @@ -353,7 +333,8 @@ private static boolean checkValid(GroovyLog.Msg errorMsg, List path.length()) longPath = path1.getValue(); - String msg = String.format("files in '%s' are configured for multiple loaders: '%s' and '%s'", longPath, loader, path1.getKey()); + String msg = String.format("files in '%s' are configured for multiple loaders: '%s' and '%s'", longPath, loader, + path1.getKey()); if (!errorMsg.getSubMessages().contains(msg)) { errorMsg.add(msg); } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/ScriptModContainer.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/ScriptModContainer.java index 301760584..dd8191163 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/ScriptModContainer.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/ScriptModContainer.java @@ -1,13 +1,14 @@ package com.cleanroommc.groovyscript.sandbox; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.core.GroovyScriptCore; -import com.google.common.eventbus.EventBus; +import java.io.File; + import net.minecraftforge.fml.common.DummyModContainer; import net.minecraftforge.fml.common.LoadController; import net.minecraftforge.fml.relauncher.FMLInjectionData; -import java.io.File; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.core.GroovyScriptCore; +import com.google.common.eventbus.EventBus; public class ScriptModContainer extends DummyModContainer { @@ -17,9 +18,7 @@ public ScriptModContainer() { } @Override - public File getSource() { - return GroovyScriptCore.source; - } + public File getSource() { return GroovyScriptCore.source; } @Override public boolean registerBus(EventBus bus, LoadController controller) { diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/ClosureMetaMethod.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/ClosureMetaMethod.java index 3dfced0bc..89b4238e0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/ClosureMetaMethod.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/ClosureMetaMethod.java @@ -1,12 +1,13 @@ package com.cleanroommc.groovyscript.sandbox.expand; -import groovy.lang.Closure; -import groovy.lang.MetaMethod; +import java.lang.reflect.Modifier; + import org.codehaus.groovy.reflection.CachedClass; import org.codehaus.groovy.reflection.ReflectionCache; import org.codehaus.groovy.runtime.InvokerHelper; -import java.lang.reflect.Modifier; +import groovy.lang.Closure; +import groovy.lang.MetaMethod; public class ClosureMetaMethod extends MetaMethod { @@ -22,24 +23,16 @@ public ClosureMetaMethod(Closure closure, String name, Class declaringClas } @Override - public int getModifiers() { - return Modifier.PUBLIC; - } + public int getModifiers() { return Modifier.PUBLIC; } @Override - public String getName() { - return name; - } + public String getName() { return name; } @Override - public Class getReturnType() { - return Object.class; - } + public Class getReturnType() { return Object.class; } @Override - public CachedClass getDeclaringClass() { - return ReflectionCache.getCachedClass(declaringClass); - } + public CachedClass getDeclaringClass() { return ReflectionCache.getCachedClass(declaringClass); } @Override public Object invoke(Object object, Object[] arguments) { diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/ExpansionHelper.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/ExpansionHelper.java index 623863d98..a0c487e9b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/ExpansionHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/ExpansionHelper.java @@ -1,16 +1,5 @@ package com.cleanroommc.groovyscript.sandbox.expand; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.api.Hidden; -import com.cleanroommc.groovyscript.sandbox.ClosureHelper; -import groovy.lang.*; -import groovy.transform.Internal; -import org.apache.groovy.util.BeanUtils; -import org.codehaus.groovy.reflection.*; -import org.codehaus.groovy.runtime.HandleMetaClass; -import org.codehaus.groovy.runtime.metaclass.*; -import org.jetbrains.annotations.Nullable; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -21,6 +10,19 @@ import java.util.function.Function; import java.util.function.Supplier; +import org.apache.groovy.util.BeanUtils; +import org.codehaus.groovy.reflection.*; +import org.codehaus.groovy.runtime.HandleMetaClass; +import org.codehaus.groovy.runtime.metaclass.*; +import org.jetbrains.annotations.Nullable; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.Hidden; +import com.cleanroommc.groovyscript.sandbox.ClosureHelper; + +import groovy.lang.*; +import groovy.transform.Internal; + public class ExpansionHelper { public static ExpandoMetaClass getExpandoClass(Class clazz) { @@ -79,9 +81,7 @@ private static boolean isValidProperty(MetaProperty prop) { if (prop instanceof MethodMetaProperty && ((MethodMetaProperty) prop).getMetaMethod() instanceof CachedMethod) { return isValid((CachedMethod) ((MethodMetaProperty) prop).getMetaMethod()); } - if (prop instanceof CachedField) { - return isValid((CachedField) prop); - } + if (prop instanceof CachedField) { return isValid((CachedField) prop); } return false; } @@ -115,7 +115,8 @@ public static void mixinClosure(Class self, String name, Closure closure) public static void mixinMethod(Class self, Method method) { ExpandoMetaClass emc = getExpandoClass(self); - MixinInMetaClass mixin = Modifier.isStatic(method.getModifiers()) ? null : getMixinMetaClass(method.getDeclaringClass(), emc); + MixinInMetaClass mixin = Modifier.isStatic(method.getModifiers()) ? null : getMixinMetaClass(method.getDeclaringClass(), + emc); mixinMethod(emc, CachedMethod.find(method), mixin); } @@ -136,23 +137,19 @@ public static void mixinMethod(Class self, String name, Function private static void mixinMethod(ExpandoMetaClass self, CachedMethod method, MixinInMetaClass mixin) { final int mod = method.getModifiers(); - if (!isValid(method)) { - return; - } + if (!isValid(method)) { return; } CachedClass[] paramTypes = method.getParameterTypes(); MetaMethod metaMethod; if (Modifier.isStatic(mod)) { if (paramTypes.length > 0 && paramTypes[0].isAssignableFrom(self.getTheClass())) { // instance method disguised as static method - if (paramTypes[0].getTheClass() == self.getTheClass()) - metaMethod = new NewInstanceMetaMethod(method); - else - metaMethod = new NewInstanceMetaMethod(method) { - @Override - public CachedClass getDeclaringClass() { - return ReflectionCache.getCachedClass(self.getTheClass()); - } - }; + if (paramTypes[0].getTheClass() == self.getTheClass()) metaMethod = new NewInstanceMetaMethod(method); + else metaMethod = new NewInstanceMetaMethod(method) + { + + @Override + public CachedClass getDeclaringClass() { return ReflectionCache.getCachedClass(self.getTheClass()); } + }; } else { // true static method metaMethod = new NewStaticMetaMethod(self.getTheCachedClass(), method); @@ -171,24 +168,29 @@ public static void mixinConstProperty(Class self, String name, T obj, mixinProperty(self, name, type, s -> obj, null, hidden); } - public static void mixinProperty(Class self, String name, Class type, - @Nullable Supplier getter, @Nullable Consumer setter, boolean hidden) { - mixinProperty(self, name, type, getter != null ? s -> getter.get() : null, setter != null ? (s, t) -> setter.accept(t) : null, hidden); + public static void mixinProperty(Class self, String name, Class type, @Nullable Supplier getter, + @Nullable Consumer setter, boolean hidden) { + mixinProperty(self, name, type, getter != null ? s -> getter.get() : null, setter != null ? (s, t) -> setter.accept(t) : + null, hidden); } - public static void mixinProperty(Class self, String name, Class type, - @Nullable Function getter, @Nullable BiConsumer setter, boolean hidden) { + public static void mixinProperty(Class self, String name, Class type, @Nullable Function getter, + @Nullable BiConsumer setter, boolean hidden) { if (getter == null && setter == null) return; - if (name == null || name.isEmpty()) { - throw new IllegalArgumentException("Name for property must not be empty!"); - } + if (name == null || name.isEmpty()) { throw new IllegalArgumentException("Name for property must not be empty!"); } String upperName = name; if (!Character.isDigit(name.charAt(0))) upperName = BeanUtils.capitalize(name); if (getter == null) { - getter = so -> {throw new GroovyRuntimeException("Property '" + name + "' in " + self.getName() + " is writable, but not readable!");}; + getter = so -> { + throw new GroovyRuntimeException("Property '" + name + "' in " + self.getName() + + " is writable, but not readable!"); + }; } if (setter == null) { - setter = (so, t) -> {throw new GroovyRuntimeException("Property '" + name + "' in " + self.getName() + " is readable, but not writable!");}; + setter = (so, t) -> { + throw new GroovyRuntimeException("Property '" + name + "' in " + self.getName() + + " is readable, but not writable!"); + }; } MetaMethod g = new Getter<>("get" + upperName, type, self, getter); @@ -200,18 +202,14 @@ public static void mixinProperty(Class self, String name, Class typ private static boolean isValid(CachedMethod method) { final int mod = method.getModifiers(); - return Modifier.isPublic(mod) && !Modifier.isAbstract(mod) && !method.isSynthetic() && - method.getAnnotation(Internal.class) == null && - method.getAnnotation(GroovyBlacklist.class) == null; + return Modifier.isPublic(mod) && !Modifier.isAbstract(mod) && !method.isSynthetic() && method.getAnnotation(Internal.class) == null && method.getAnnotation(GroovyBlacklist.class) == null; } private static boolean isValid(CachedField cachedField) { if (cachedField == null) return true; final int mod = cachedField.getModifiers(); Field field = cachedField.getCachedField(); - return Modifier.isPublic(mod) && !field.isSynthetic() && - !field.isAnnotationPresent(Internal.class) && - !field.isAnnotationPresent(GroovyBlacklist.class); + return Modifier.isPublic(mod) && !field.isSynthetic() && !field.isAnnotationPresent(Internal.class) && !field.isAnnotationPresent(GroovyBlacklist.class); } /** @@ -227,24 +225,16 @@ public NewStaticMetaMethod(CachedClass owner, CachedMethod method) { } @Override - public boolean isStatic() { - return true; - } + public boolean isStatic() { return true; } @Override - public int getModifiers() { - return Modifier.PUBLIC; - } + public int getModifiers() { return Modifier.PUBLIC; } @Override - public CachedClass getDeclaringClass() { - return owner; - } + public CachedClass getDeclaringClass() { return owner; } @Override - public CachedClass getOwnerClass() { - return owner; - } + public CachedClass getOwnerClass() { return owner; } } private static class Property extends MetaBeanProperty implements Hidden { @@ -257,8 +247,6 @@ public Property(String name, Class type, MetaMethod getter, MetaMethod setter, b } @Override - public boolean isHidden() { - return hidden; - } + public boolean isHidden() { return hidden; } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/Getter.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/Getter.java index a68d31b6f..e50fdeb94 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/Getter.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/Getter.java @@ -1,12 +1,14 @@ package com.cleanroommc.groovyscript.sandbox.expand; -import com.cleanroommc.groovyscript.api.Hidden; -import groovy.lang.MetaMethod; +import java.lang.reflect.Modifier; +import java.util.function.Function; + import org.codehaus.groovy.reflection.CachedClass; import org.codehaus.groovy.reflection.ReflectionCache; -import java.lang.reflect.Modifier; -import java.util.function.Function; +import com.cleanroommc.groovyscript.api.Hidden; + +import groovy.lang.MetaMethod; public class Getter extends MetaMethod implements Hidden { @@ -28,24 +30,16 @@ public Getter(String name, Class returnType, Class owner, Function g } @Override - public int getModifiers() { - return Modifier.PUBLIC; - } + public int getModifiers() { return Modifier.PUBLIC; } @Override - public String getName() { - return this.name; - } + public String getName() { return this.name; } @Override - public Class getReturnType() { - return this.returnType; - } + public Class getReturnType() { return this.returnType; } @Override - public CachedClass getDeclaringClass() { - return ReflectionCache.getCachedClass(this.owner); - } + public CachedClass getDeclaringClass() { return ReflectionCache.getCachedClass(this.owner); } @Override public Object invoke(Object object, Object[] arguments) { @@ -54,7 +48,5 @@ public Object invoke(Object object, Object[] arguments) { } @Override - public boolean isHidden() { - return true; - } + public boolean isHidden() { return true; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/LambdaClosure.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/LambdaClosure.java index e23eab1ba..cb5d76716 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/LambdaClosure.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/LambdaClosure.java @@ -1,9 +1,9 @@ package com.cleanroommc.groovyscript.sandbox.expand; -import groovy.lang.Closure; - import java.util.function.Function; +import groovy.lang.Closure; + public class LambdaClosure extends Closure { private final Function function; diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/Setter.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/Setter.java index 53918204f..d44aff1bc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/Setter.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/expand/Setter.java @@ -1,12 +1,14 @@ package com.cleanroommc.groovyscript.sandbox.expand; -import com.cleanroommc.groovyscript.api.Hidden; -import groovy.lang.MetaMethod; +import java.lang.reflect.Modifier; +import java.util.function.BiConsumer; + import org.codehaus.groovy.reflection.CachedClass; import org.codehaus.groovy.reflection.ReflectionCache; -import java.lang.reflect.Modifier; -import java.util.function.BiConsumer; +import com.cleanroommc.groovyscript.api.Hidden; + +import groovy.lang.MetaMethod; public class Setter extends MetaMethod implements Hidden { @@ -23,24 +25,16 @@ public Setter(String name, Class paramType, Class owner, BiConsumer } @Override - public int getModifiers() { - return Modifier.PUBLIC; - } + public int getModifiers() { return Modifier.PUBLIC; } @Override - public String getName() { - return this.name; - } + public String getName() { return this.name; } @Override - public Class getReturnType() { - return void.class; - } + public Class getReturnType() { return void.class; } @Override - public CachedClass getDeclaringClass() { - return ReflectionCache.getCachedClass(this.owner); - } + public CachedClass getDeclaringClass() { return ReflectionCache.getCachedClass(this.owner); } @Override public Object invoke(Object object, Object[] arguments) { @@ -51,7 +45,5 @@ public Object invoke(Object object, Object[] arguments) { } @Override - public boolean isHidden() { - return true; - } + public boolean isHidden() { return true; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/GroovyDeobfMapper.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/GroovyDeobfMapper.java index 651591c29..fda7d7fae 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/GroovyDeobfMapper.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/GroovyDeobfMapper.java @@ -1,17 +1,5 @@ package com.cleanroommc.groovyscript.sandbox.mapper; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyLog; -import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import org.apache.commons.lang3.tuple.Pair; -import org.codehaus.groovy.ast.ClassHelper; -import org.codehaus.groovy.ast.ClassNode; -import org.codehaus.groovy.ast.Parameter; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; @@ -21,6 +9,20 @@ import java.util.Map; import java.util.stream.Collectors; +import org.apache.commons.lang3.tuple.Pair; +import org.codehaus.groovy.ast.ClassHelper; +import org.codehaus.groovy.ast.ClassNode; +import org.codehaus.groovy.ast.Parameter; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyLog; + +import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; + public class GroovyDeobfMapper { private static final Map> DEOBF_METHODS = new Object2ObjectOpenHashMap<>(); @@ -65,8 +67,10 @@ public static void init() { String fieldDeobf = parts[2].substring(index + 1); if (!fieldObf.equals(fieldDeobf)) { className = className.replace('/', '.'); - DEOBF_FIELDS.computeIfAbsent(className, key -> new Object2ObjectOpenHashMap<>()).put(fieldObf, fieldDeobf); - OBF_FIELD_NAMES.computeIfAbsent(className, key -> new Object2ObjectOpenHashMap<>()).put(fieldDeobf, fieldObf); + DEOBF_FIELDS.computeIfAbsent(className, key -> new Object2ObjectOpenHashMap<>()).put(fieldObf, + fieldDeobf); + OBF_FIELD_NAMES.computeIfAbsent(className, key -> new Object2ObjectOpenHashMap<>()).put(fieldDeobf, + fieldObf); } } else if (parts[0].equals(method)) { int index = parts[1].lastIndexOf("/"); @@ -76,8 +80,10 @@ public static void init() { String methodDeobf = parts[3].substring(index + 1); if (!methodObf.equals(methodDeobf)) { className = className.replace('/', '.'); - DEOBF_METHODS.computeIfAbsent(className, key -> new Object2ObjectOpenHashMap<>()).put(methodObf, methodDeobf); - Map map = OBF_METHOD_NAMES.computeIfAbsent(className, key -> new Object2ObjectOpenHashMap<>()); + DEOBF_METHODS.computeIfAbsent(className, key -> new Object2ObjectOpenHashMap<>()).put(methodObf, + methodDeobf); + Map map = OBF_METHOD_NAMES.computeIfAbsent(className, + key -> new Object2ObjectOpenHashMap<>()); MethodInfo info = map.get(methodDeobf); if (info == null) { info = new MethodInfo(methodDeobf, methodObf, methodArgs); @@ -174,22 +180,14 @@ public void registerOverloadedMethod(String obfName, String args) { } public String findMethod(Parameter[] args) { - if (this.obfNames == null) { - return this.defObfName; - } - List results = this.obfNames.stream() - .filter(pair -> pair.getKey().length == args.length) - .filter(pair -> { - for (int i = 0; i < args.length; i++) { - String origParam = pair.getKey()[i]; - if (!matches(origParam, args[i])) { - return false; - } - } - return true; - }) - .map(Pair::getValue) - .collect(Collectors.toList()); + if (this.obfNames == null) { return this.defObfName; } + List results = this.obfNames.stream().filter(pair -> pair.getKey().length == args.length).filter(pair -> { + for (int i = 0; i < args.length; i++) { + String origParam = pair.getKey()[i]; + if (!matches(origParam, args[i])) { return false; } + } + return true; + }).map(Pair::getValue).collect(Collectors.toList()); if (results.isEmpty()) return null; if (results.size() == 1) return results.get(0); GroovyLog.get().errorMC("Multiple methods match the name {} and params {}", this.deobfName, Arrays.toString(args)); @@ -197,15 +195,11 @@ public String findMethod(Parameter[] args) { } public static boolean matches(String original, Parameter param) { - if (original.equals(Object.class.getName())) { - return true; - } + if (original.equals(Object.class.getName())) { return true; } ClassNode possibleMatch = param.getOriginType(); while (possibleMatch != null) { - if (original.equals(possibleMatch.getName())) { - return true; - } + if (original.equals(possibleMatch.getName())) { return true; } possibleMatch = possibleMatch.getSuperClass(); } return false; diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/RemappedCachedField.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/RemappedCachedField.java index b741b7e09..cf6bb9ae2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/RemappedCachedField.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/RemappedCachedField.java @@ -1,9 +1,9 @@ package com.cleanroommc.groovyscript.sandbox.mapper; -import org.codehaus.groovy.reflection.CachedField; - import java.lang.reflect.Field; +import org.codehaus.groovy.reflection.CachedField; + public class RemappedCachedField extends CachedField { private final String deobfName; @@ -14,7 +14,5 @@ public RemappedCachedField(Field field, String deobfName) { } @Override - public String getName() { - return deobfName; - } + public String getName() { return deobfName; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/RemappedCachedMethod.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/RemappedCachedMethod.java index 60cc5c56f..73058e66d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/RemappedCachedMethod.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/mapper/RemappedCachedMethod.java @@ -1,10 +1,10 @@ package com.cleanroommc.groovyscript.sandbox.mapper; +import java.lang.reflect.Method; + import org.codehaus.groovy.reflection.CachedClass; import org.codehaus.groovy.reflection.CachedMethod; -import java.lang.reflect.Method; - public class RemappedCachedMethod extends CachedMethod { private final String deobfName; @@ -15,7 +15,5 @@ public RemappedCachedMethod(CachedClass clazz, Method method, String deobfName) } @Override - public String getName() { - return deobfName; - } + public String getName() { return deobfName; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/security/BlackListedMetaClass.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/security/BlackListedMetaClass.java index 8a646b663..6c55de2b2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/security/BlackListedMetaClass.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/security/BlackListedMetaClass.java @@ -1,15 +1,16 @@ package com.cleanroommc.groovyscript.sandbox.security; -import com.cleanroommc.groovyscript.sandbox.RunConfig; +import java.net.URL; +import java.util.Collections; +import java.util.List; -import groovy.lang.*; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.control.CompilationUnit; import org.codehaus.groovy.control.Phases; -import java.net.URL; -import java.util.Collections; -import java.util.List; +import com.cleanroommc.groovyscript.sandbox.RunConfig; + +import groovy.lang.*; /** * A {@link MetaClass} that rejects ANY interaction @@ -28,7 +29,8 @@ protected SandboxSecurityException makeSecurityError() { } @Override - public Object invokeMethod(Class sender, Object receiver, String methodName, Object[] arguments, boolean isCallToSuper, boolean fromInsideClass) { + public Object invokeMethod(Class sender, Object receiver, String methodName, Object[] arguments, boolean isCallToSuper, + boolean fromInsideClass) { throw makeSecurityError(); } @@ -38,7 +40,8 @@ public Object getProperty(Class sender, Object receiver, String property, boolea } @Override - public void setProperty(Class sender, Object receiver, String property, Object value, boolean isCallToSuper, boolean fromInsideClass) { + public void setProperty(Class sender, Object receiver, String property, Object value, boolean isCallToSuper, + boolean fromInsideClass) { throw makeSecurityError(); } @@ -58,23 +61,19 @@ public Object getAttribute(Class sender, Object receiver, String messageName, bo } @Override - public void setAttribute(Class sender, Object receiver, String messageName, Object messageValue, boolean useSuper, boolean fromInsideClass) { + public void setAttribute(Class sender, Object receiver, String messageName, Object messageValue, boolean useSuper, + boolean fromInsideClass) { throw makeSecurityError(); } @Override - public void initialize() { - } + public void initialize() {} @Override - public List getProperties() { - return Collections.emptyList(); - } + public List getProperties() { return Collections.emptyList(); } @Override - public List getMethods() { - return Collections.emptyList(); - } + public List getMethods() { return Collections.emptyList(); } @Override public List respondsTo(Object obj, String name, Object[] argTypes) { @@ -107,9 +106,7 @@ public MetaMethod getMetaMethod(String name, Object[] args) { } @Override - public Class getTheClass() { - return theClass; - } + public Class getTheClass() { return theClass; } @Override public Object invokeConstructor(Object[] arguments) { @@ -203,9 +200,7 @@ public ClassNode getClassNode() { } @Override - public List getMetaMethods() { - return Collections.emptyList(); - } + public List getMetaMethods() { return Collections.emptyList(); } @Override public int selectConstructorAndTransformArguments(int numberOfConstructors, Object[] arguments) { diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/security/GrSMetaClassCreationHandle.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/security/GrSMetaClassCreationHandle.java index 2d02278db..cd145d98e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/security/GrSMetaClassCreationHandle.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/security/GrSMetaClassCreationHandle.java @@ -10,14 +10,11 @@ public class GrSMetaClassCreationHandle extends MetaClassRegistry.MetaClassCreat public static final GrSMetaClassCreationHandle INSTANCE = new GrSMetaClassCreationHandle(); - private GrSMetaClassCreationHandle() { - } + private GrSMetaClassCreationHandle() {} @Override protected MetaClass createNormalMetaClass(Class theClass, MetaClassRegistry registry) { - if (!GroovySecurityManager.INSTANCE.isValid(theClass)) { - return new BlackListedMetaClass(theClass); - } + if (!GroovySecurityManager.INSTANCE.isValid(theClass)) { return new BlackListedMetaClass(theClass); } return super.createNormalMetaClass(theClass, registry); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/security/GroovySecurityManager.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/security/GroovySecurityManager.java index 7c81da7da..62058d753 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/security/GroovySecurityManager.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/security/GroovySecurityManager.java @@ -1,8 +1,17 @@ package com.cleanroommc.groovyscript.sandbox.security; +import java.io.PrintWriter; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.*; + +import org.apache.commons.io.FileUtils; +import org.codehaus.groovy.runtime.*; + import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.sandbox.GroovyLogImpl; import com.cleanroommc.groovyscript.sandbox.expand.LambdaClosure; + import groovy.lang.GroovyClassLoader; import groovy.lang.GroovyShell; import groovy.lang.MetaMethod; @@ -12,13 +21,6 @@ import groovy.util.GroovyScriptEngine; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import org.apache.commons.io.FileUtils; -import org.codehaus.groovy.runtime.*; - -import java.io.PrintWriter; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.*; public class GroovySecurityManager { @@ -57,7 +59,8 @@ public void initDefaults() { banPackage("org.spongepowered"); banPackage("zone.rong.mixinbooter"); banClasses(Runtime.class, ClassLoader.class, Scanner.class); - banClasses(GroovyScriptEngine.class, Eval.class, GroovyMain.class, GroovySocketServer.class, GroovyShell.class, GroovyClassLoader.class); + banClasses(GroovyScriptEngine.class, Eval.class, GroovyMain.class, GroovySocketServer.class, GroovyShell.class, + GroovyClassLoader.class); banMethods(System.class, "exit", "gc", "setSecurityManager"); banMethods(Class.class, "getResource", "getResourceAsStream"); banMethods(String.class, "execute"); @@ -105,8 +108,7 @@ public void banMethods(Class clazz, Collection method) { } public boolean isValid(Method method) { - return isValidMethod(method.getDeclaringClass(), method.getName()) && - !method.isAnnotationPresent(GroovyBlacklist.class); + return isValidMethod(method.getDeclaringClass(), method.getName()) && !method.isAnnotationPresent(GroovyBlacklist.class); } public boolean isValid(MetaMethod method) { @@ -118,16 +120,13 @@ public boolean isValid(Field field) { } public boolean isValid(Class clazz) { - return this.whiteListedClasses.contains(clazz) || - (isValidClass(clazz) && isValidPackage(clazz)); + return this.whiteListedClasses.contains(clazz) || (isValidClass(clazz) && isValidPackage(clazz)); } public boolean isValidPackage(Class clazz) { String className = clazz.getName(); for (String bannedPackage : bannedPackages) { - if (className.startsWith(bannedPackage)) { - return false; - } + if (className.startsWith(bannedPackage)) { return false; } } return true; } @@ -141,19 +140,11 @@ public boolean isValidMethod(Class receiver, String method) { return methods == null || !methods.contains(method); } - public List getBannedPackages() { - return Collections.unmodifiableList(bannedPackages); - } + public List getBannedPackages() { return Collections.unmodifiableList(bannedPackages); } - public Set> getBannedClasses() { - return Collections.unmodifiableSet(bannedClasses); - } + public Set> getBannedClasses() { return Collections.unmodifiableSet(bannedClasses); } - public Map, Set> getBannedMethods() { - return Collections.unmodifiableMap(bannedMethods); - } + public Map, Set> getBannedMethods() { return Collections.unmodifiableMap(bannedMethods); } - public Set> getWhiteListedClasses() { - return Collections.unmodifiableSet(whiteListedClasses); - } + public Set> getWhiteListedClasses() { return Collections.unmodifiableSet(whiteListedClasses); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/security/SandboxSecurityException.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/security/SandboxSecurityException.java index d8db4981d..5b3481635 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/security/SandboxSecurityException.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/security/SandboxSecurityException.java @@ -11,4 +11,4 @@ public SandboxSecurityException(String msg) { public static SandboxSecurityException format(String msg) { return new SandboxSecurityException(msg); } -} \ No newline at end of file +} diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/AsmDecompileHelper.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/AsmDecompileHelper.java index 70ab6a7e7..9a9894604 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/AsmDecompileHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/AsmDecompileHelper.java @@ -1,22 +1,23 @@ package com.cleanroommc.groovyscript.sandbox.transformer; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.launchwrapper.Launch; import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; import net.minecraftforge.fml.relauncher.FMLLaunchHandler; import net.minecraftforge.fml.relauncher.SideOnly; + import org.codehaus.groovy.ast.decompiled.ClassStub; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AnnotationNode; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - public class AsmDecompileHelper { public static final String SIDE = FMLLaunchHandler.side().name(); @@ -35,7 +36,9 @@ public class AsmDecompileHelper { transformerExceptions.add("net.minecraft.launchwrapper.injector."); } - public static groovyjarjarasm.asm.ClassVisitor makeGroovyDecompiler() throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { + public static groovyjarjarasm.asm.ClassVisitor makeGroovyDecompiler() throws ClassNotFoundException, InstantiationException, + IllegalAccessException, NoSuchMethodException, + InvocationTargetException { if (decompilerClass == null) { decompilerClass = Class.forName("org.codehaus.groovy.ast.decompiled.AsmDecompiler$DecompilingVisitor"); decompilerConstructor = decompilerClass.getDeclaredConstructors()[0]; @@ -44,7 +47,8 @@ public static groovyjarjarasm.asm.ClassVisitor makeGroovyDecompiler() throws Cla return (groovyjarjarasm.asm.ClassVisitor) decompilerConstructor.newInstance(); } - public static ClassStub getDecompiledClass(groovyjarjarasm.asm.ClassVisitor classVisitor) throws NoSuchFieldException, IllegalAccessException { + public static ClassStub getDecompiledClass(groovyjarjarasm.asm.ClassVisitor classVisitor) throws NoSuchFieldException, + IllegalAccessException { if (resultField == null) { resultField = decompilerClass.getDeclaredField("result"); resultField.setAccessible(true); @@ -54,9 +58,7 @@ public static ClassStub getDecompiledClass(groovyjarjarasm.asm.ClassVisitor clas public static byte[] transform(String className, byte[] bytes) { for (String s : transformerExceptions) { - if (className.startsWith(s)) { - return bytes; - } + if (className.startsWith(s)) { return bytes; } } String untransformed = FMLDeobfuscatingRemapper.INSTANCE.unmap(className.replace('.', '/')).replace('/', '.'); String transformed = FMLDeobfuscatingRemapper.INSTANCE.map(className.replace('.', '/')).replace('/', '.'); @@ -67,9 +69,7 @@ public static byte[] transform(String className, byte[] bytes) { } public static boolean remove(List anns, String side) { - if (anns == null) { - return false; - } + if (anns == null) { return false; } for (AnnotationNode ann : anns) { if (ann.desc.equals(Type.getDescriptor(SideOnly.class))) { if (ann.values != null) { @@ -78,9 +78,7 @@ public static boolean remove(List anns, String side) { Object value = ann.values.get(x + 1); if (key instanceof String && key.equals("value")) { if (value instanceof String[]) { - if (!((String[]) value)[1].equals(side)) { - return true; - } + if (!((String[]) value)[1].equals(side)) { return true; } } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyCodeFactory.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyCodeFactory.java index 48a58fb45..205ce1070 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyCodeFactory.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyCodeFactory.java @@ -1,21 +1,23 @@ package com.cleanroommc.groovyscript.sandbox.transformer; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; -import com.cleanroommc.groovyscript.sandbox.mapper.GroovyDeobfMapper; -import com.cleanroommc.groovyscript.sandbox.mapper.RemappedCachedField; -import com.cleanroommc.groovyscript.sandbox.mapper.RemappedCachedMethod; -import com.cleanroommc.groovyscript.sandbox.security.GroovySecurityManager; -import net.minecraftforge.fml.relauncher.FMLLaunchHandler; -import org.codehaus.groovy.ast.ClassNode; -import org.codehaus.groovy.ast.MethodNode; -import org.codehaus.groovy.reflection.*; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.security.PrivilegedAction; import java.util.Arrays; import java.util.List; +import net.minecraftforge.fml.relauncher.FMLLaunchHandler; + +import org.codehaus.groovy.ast.ClassNode; +import org.codehaus.groovy.ast.MethodNode; +import org.codehaus.groovy.reflection.*; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.sandbox.mapper.GroovyDeobfMapper; +import com.cleanroommc.groovyscript.sandbox.mapper.RemappedCachedField; +import com.cleanroommc.groovyscript.sandbox.mapper.RemappedCachedMethod; +import com.cleanroommc.groovyscript.sandbox.security.GroovySecurityManager; + /** * A helper class that filters blacklisted fields and methods and remaps their names if needed */ @@ -23,46 +25,42 @@ public class GroovyCodeFactory { public static final String MC_CLASS = "net.minecraft."; - private GroovyCodeFactory() { - } + private GroovyCodeFactory() {} public static PrivilegedAction makeFieldsHook(CachedClass cachedClass) { - return () -> Arrays.stream(cachedClass.getTheClass().getDeclaredFields()) - .filter(f -> ReflectionUtils.checkCanSetAccessible(f, CachedClass.class)) - .filter(GroovySecurityManager.INSTANCE::isValid) - .map(!FMLLaunchHandler.isDeobfuscatedEnvironment() && cachedClass.getName().startsWith(MC_CLASS) ? - f -> makeField(cachedClass, f) : - CachedField::new) - .toArray(CachedField[]::new); + return () -> Arrays.stream(cachedClass.getTheClass().getDeclaredFields()).filter(f -> ReflectionUtils + .checkCanSetAccessible(f, + CachedClass.class)) + .filter(GroovySecurityManager.INSTANCE::isValid).map(!FMLLaunchHandler + .isDeobfuscatedEnvironment() && cachedClass.getName() + .startsWith(MC_CLASS) ? + f -> makeField(cachedClass, + f) : + CachedField::new) + .toArray(CachedField[]::new); } private static CachedField makeField(CachedClass cachedClass, Field field) { String deobfName = GroovyDeobfMapper.getDeobfField(cachedClass.getTheClass(), field.getName()); - return deobfName == null ? - new CachedField(field) : - new RemappedCachedField(field, deobfName); + return deobfName == null ? new CachedField(field) : new RemappedCachedField(field, deobfName); } public static PrivilegedAction makeConstructorsHook(CachedClass cachedClass) { - return () -> Arrays.stream(cachedClass.getTheClass().getDeclaredConstructors()) - .filter(c -> !c.isSynthetic()) // GROOVY-9245: exclude inner class ctors - .filter(c -> ReflectionUtils.checkCanSetAccessible(c, CachedClass.class)) - .filter(c -> !c.isAnnotationPresent(GroovyBlacklist.class)) - .map(c -> new CachedConstructor(cachedClass, c)) - .toArray(CachedConstructor[]::new); + return () -> Arrays.stream(cachedClass.getTheClass().getDeclaredConstructors()).filter(c -> !c.isSynthetic()) // GROOVY-9245: exclude inner class ctors + .filter(c -> ReflectionUtils.checkCanSetAccessible(c, CachedClass.class)).filter(c -> !c + .isAnnotationPresent(GroovyBlacklist.class)) + .map(c -> new CachedConstructor(cachedClass, c)).toArray(CachedConstructor[]::new); } public static PrivilegedAction makeMethodsHook(CachedClass cachedClass) { return () -> { try { - return Arrays.stream(cachedClass.getTheClass().getDeclaredMethods()) - .filter(m -> m.getName().indexOf('+') < 0) // no synthetic JDK 5+ methods - .filter(m -> ReflectionUtils.checkCanSetAccessible(m, CachedClass.class)) - .filter(GroovySecurityManager.INSTANCE::isValid) - .map(!FMLLaunchHandler.isDeobfuscatedEnvironment() && cachedClass.getName().startsWith(MC_CLASS) ? - m -> makeMethod(cachedClass, m) : - m -> new CachedMethod(cachedClass, m)) - .toArray(CachedMethod[]::new); + return Arrays.stream(cachedClass.getTheClass().getDeclaredMethods()).filter(m -> m.getName().indexOf('+') < 0) // no synthetic JDK 5+ methods + .filter(m -> ReflectionUtils.checkCanSetAccessible(m, CachedClass.class)).filter( + GroovySecurityManager.INSTANCE::isValid) + .map(!FMLLaunchHandler.isDeobfuscatedEnvironment() && cachedClass.getName().startsWith(MC_CLASS) ? + m -> makeMethod(cachedClass, m) : m -> new CachedMethod(cachedClass, m)).toArray( + CachedMethod[]::new); } catch (LinkageError e) { return CachedMethod.EMPTY_ARRAY; } @@ -71,9 +69,8 @@ public static PrivilegedAction makeMethodsHook(CachedClass cache private static CachedMethod makeMethod(CachedClass cachedClass, Method method) { String deobfName = GroovyDeobfMapper.getDeobfMethod(cachedClass.getTheClass(), method.getName()); - return deobfName == null ? - new CachedMethod(cachedClass, method) : - new RemappedCachedMethod(cachedClass, method, deobfName); + return deobfName == null ? new CachedMethod(cachedClass, method) : new RemappedCachedMethod(cachedClass, method, + deobfName); } /** @@ -98,7 +95,8 @@ public static void remapOverrides(ClassNode classNode) { * Copies a method node with a new name */ private static MethodNode copyRemappedMethodNode(String name, MethodNode original) { - MethodNode copy = new MethodNode(name, original.getModifiers(), original.getReturnType(), original.getParameters(), original.getExceptions(), original.getCode()); + MethodNode copy = new MethodNode(name, original.getModifiers(), original.getReturnType(), original.getParameters(), + original.getExceptions(), original.getCode()); copy.setAnnotationDefault(original.hasDefaultValue()); copy.setColumnNumber(original.getColumnNumber()); copy.setDeclaringClass(original.getDeclaringClass()); diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptCompiler.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptCompiler.java index cc7e0e201..080aa0895 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptCompiler.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptCompiler.java @@ -44,8 +44,8 @@ private static boolean isBannedFromSide(AnnotatedNode node) { if (annotatedNode.getClassNode().getName().equals(SIDE_ONLY_CLASS)) { Expression expr = annotatedNode.getMember("value"); if (expr instanceof PropertyExpression prop) { - if (prop.getObjectExpression() instanceof ClassExpression && - prop.getObjectExpression().getType().getName().equals(SIDE_CLASS)) { + if (prop.getObjectExpression() instanceof ClassExpression && prop.getObjectExpression().getType().getName() + .equals(SIDE_CLASS)) { String elementSide = prop.getPropertyAsString(); return elementSide != null && !elementSide.equals(AsmDecompileHelper.SIDE); } @@ -64,9 +64,7 @@ public void forbidIfFinalizer(MethodNode m) { break; } } - if (!safe) { - throw new SecurityException("Sandboxed code may not override Object.finalize()"); - } + if (!safe) { throw new SecurityException("Sandboxed code may not override Object.finalize()"); } } } } diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptEarlyCompiler.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptEarlyCompiler.java index bf1bfc33b..14ceda76a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptEarlyCompiler.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptEarlyCompiler.java @@ -1,11 +1,8 @@ package com.cleanroommc.groovyscript.sandbox.transformer; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.core.mixin.groovy.ModuleNodeAccessor; -import com.cleanroommc.groovyscript.sandbox.FileUtil; +import java.io.File; +import java.util.List; + import org.codehaus.groovy.ast.ClassHelper; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.MethodNode; @@ -24,8 +21,12 @@ import org.codehaus.groovy.syntax.Token; import org.codehaus.groovy.syntax.Types; -import java.io.File; -import java.util.List; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.compat.mods.GroovyContainer; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.core.mixin.groovy.ModuleNodeAccessor; +import com.cleanroommc.groovyscript.sandbox.FileUtil; public class GroovyScriptEarlyCompiler extends CompilationCustomizer { @@ -44,7 +45,8 @@ public void call(SourceUnit source, GeneratorContext context, ClassNode classNod // inject correct package declaration into script String packageName = rel.substring(0, i).replace(File.separatorChar, '.') + '.'; if (module.getPackage() != null && !module.getPackage().getName().equals(packageName)) { - GroovyLog.get().error("Expected package {} but got {} in script {}", packageName, module.getPackage().getName(), rel); + GroovyLog.get().error("Expected package {} but got {} in script {}", packageName, module.getPackage().getName(), + rel); } module.setPackageName(packageName); } @@ -59,12 +61,14 @@ public void call(SourceUnit source, GeneratorContext context, ClassNode classNod if (!ModSupport.INSTANCE.hasCompatFor(parts[1]) || parts.length > 3) return false; GroovyContainer mpc = ModSupport.INSTANCE.getContainer(parts[1]); if (!mpc.isLoaded()) return true; // mod not loaded -> remove import - Expression prop = new PropertyExpression(new VariableExpression("mods", ClassHelper.makeCached(ModSupport.class)), parts[1]); + Expression prop = new PropertyExpression(new VariableExpression("mods", ClassHelper.makeCached(ModSupport.class)), + parts[1]); if (parts.length > 2) { prop = new PropertyExpression(prop, parts[2]); } - Expression expr = new DeclarationExpression(new VariableExpression(imp.getAlias()), - Token.newSymbol(Types.ASSIGN, imp.getLineNumber(), 5 + parts[1].length()), + Expression expr = new DeclarationExpression(new VariableExpression(imp.getAlias()), Token.newSymbol(Types.ASSIGN, + imp.getLineNumber(), + 5 + parts[1].length()), prop); scriptStatement.getStatements().add(0, new ExpressionStatement(expr)); return true; diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptTransformer.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptTransformer.java index cafbd923a..7d192bf47 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptTransformer.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/transformer/GroovyScriptTransformer.java @@ -1,9 +1,11 @@ package com.cleanroommc.groovyscript.sandbox.transformer; -import com.cleanroommc.groovyscript.api.GroovyLog; -import com.cleanroommc.groovyscript.helper.GroovyFile; -import com.cleanroommc.groovyscript.mapper.ObjectMapper; -import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; +import java.io.File; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + import org.codehaus.groovy.ast.ClassCodeExpressionTransformer; import org.codehaus.groovy.ast.ClassHelper; import org.codehaus.groovy.ast.ClassNode; @@ -12,11 +14,10 @@ import org.codehaus.groovy.control.SourceUnit; import org.codehaus.groovy.syntax.SyntaxException; -import java.io.File; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.helper.GroovyFile; +import com.cleanroommc.groovyscript.mapper.ObjectMapper; +import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; public class GroovyScriptTransformer extends ClassCodeExpressionTransformer { @@ -30,9 +31,7 @@ public GroovyScriptTransformer(SourceUnit source, ClassNode classNode) { } @Override - protected SourceUnit getSourceUnit() { - return source; - } + protected SourceUnit getSourceUnit() { return source; } private static Expression makeCheckedCall(ClassNode classNode, String name, List arguments) { return new StaticMethodCallExpression(classNode, name, new ArgumentListExpression(arguments)); @@ -65,12 +64,8 @@ public Expression transform(Expression expr) { } private Expression transformInternal(Expression expr) { - if (expr instanceof ClosureExpression ce) { - return transformClosure(ce); - } - if (expr instanceof MethodCallExpression mce) { - return transformMethodCall(mce); - } + if (expr instanceof ClosureExpression ce) { return transformClosure(ce); } + if (expr instanceof MethodCallExpression mce) { return transformMethodCall(mce); } if (expr instanceof ConstructorCallExpression cce) { if (cce.getType().getName().equals(File.class.getName())) { // redirect to file wrapper @@ -103,11 +98,15 @@ private Expression transformMethodCall(MethodCallExpression mce) { if (mce.isImplicitThis()) { List> conflicts = ObjectMapperManager.getConflicts(mce.getMethodAsString()); if (conflicts != null) { - List suggestions = conflicts.stream() - .map(goh -> goh.getMod() == null ? goh.getName() : "mods." + goh.getMod().getModId() + "." + goh.getName()) - .collect(Collectors.toList()); + List suggestions = conflicts.stream().map(goh -> goh.getMod() == null ? goh.getName() : "mods." + goh + .getMod() + .getModId() + + "." + goh + .getName()) + .collect(Collectors.toList()); String msg = GroovyLog.format("Can't infer ObjectMapper from name {}, since one is added by {} mods. " + - "Please choose one of the following: {}", mce.getMethodAsString(), conflicts.size(), suggestions); + "Please choose one of the following: {}", mce.getMethodAsString(), conflicts.size(), + suggestions); source.addError(new SyntaxException(msg, mce)); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/server/Completions.java b/src/main/java/com/cleanroommc/groovyscript/server/Completions.java index dd8da7420..06abcb3e2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/server/Completions.java +++ b/src/main/java/com/cleanroommc/groovyscript/server/Completions.java @@ -1,13 +1,13 @@ package com.cleanroommc.groovyscript.server; -import org.eclipse.lsp4j.CompletionItem; -import org.eclipse.lsp4j.CompletionList; -import org.eclipse.lsp4j.jsonrpc.messages.Either; - import java.util.ArrayList; import java.util.List; import java.util.function.Function; +import org.eclipse.lsp4j.CompletionItem; +import org.eclipse.lsp4j.CompletionList; +import org.eclipse.lsp4j.jsonrpc.messages.Either; + public class Completions extends ArrayList { private final int limit; @@ -16,9 +16,7 @@ public Completions(int limit) { this.limit = limit; } - public int getLimit() { - return limit; - } + public int getLimit() { return limit; } public boolean reachedLimit() { return size() >= this.limit; diff --git a/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptCompilationUnitFactory.java b/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptCompilationUnitFactory.java index f453ae3c7..bffe933f3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptCompilationUnitFactory.java +++ b/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptCompilationUnitFactory.java @@ -1,23 +1,26 @@ package com.cleanroommc.groovyscript.server; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.sandbox.LoadStage; -import com.cleanroommc.groovyscript.sandbox.transformer.GroovyScriptCompiler; -import com.cleanroommc.groovyscript.sandbox.transformer.GroovyScriptEarlyCompiler; -import groovy.lang.GroovyClassLoader; +import java.io.File; +import java.net.URI; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.stream.Stream; + import net.minecraft.launchwrapper.Launch; import net.prominic.groovyls.compiler.control.GroovyLSCompilationUnit; import net.prominic.groovyls.config.CompilationUnitFactoryBase; + import org.codehaus.groovy.control.CompilerConfiguration; import org.codehaus.groovy.control.SourceUnit; import org.jetbrains.annotations.Nullable; -import java.io.File; -import java.net.URI; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; -import java.util.stream.Stream; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.sandbox.LoadStage; +import com.cleanroommc.groovyscript.sandbox.transformer.GroovyScriptCompiler; +import com.cleanroommc.groovyscript.sandbox.transformer.GroovyScriptEarlyCompiler; + +import groovy.lang.GroovyClassLoader; public class GroovyScriptCompilationUnitFactory extends CompilationUnitFactoryBase { @@ -31,9 +34,7 @@ public GroovyScriptCompilationUnitFactory(File root, GroovyScriptLanguageServerC } @Override - protected GroovyClassLoader getClassLoader() { - return new GroovyClassLoader(Launch.classLoader, config, true); - } + protected GroovyClassLoader getClassLoader() { return new GroovyClassLoader(Launch.classLoader, config, true); } @Override protected CompilerConfiguration getConfiguration() { @@ -54,29 +55,27 @@ public GroovyLSCompilationUnit create(Path workspaceRoot, @Nullable URI context) context = null; // actions on classes are going into classes only unit } - var unit = compilationUnitsByScript.computeIfAbsent(context, uri -> new GroovyLSCompilationUnit(getConfiguration(), null, getClassLoader(), languageServerContext)); + var unit = compilationUnitsByScript.computeIfAbsent(context, uri -> new GroovyLSCompilationUnit(getConfiguration(), null, + getClassLoader(), + languageServerContext)); var changedUris = languageServerContext.getFileContentsTracker().getChangedURIs(); removeSources(unit, changedUris); // add open classes - languageServerContext.getFileContentsTracker().getOpenURIs().stream() - .filter(uri -> { - Path openPath = Paths.get(uri); - return openPath.normalize().startsWith(workspaceRoot.normalize()); - }) - .filter(this::isInClassesContext) - .forEach(uri -> { - addOpenFileToCompilationUnit(uri, languageServerContext.getFileContentsTracker().getContents(uri), unit); - }); + languageServerContext.getFileContentsTracker().getOpenURIs().stream().filter(uri -> { + Path openPath = Paths.get(uri); + return openPath.normalize().startsWith(workspaceRoot.normalize()); + }).filter(this::isInClassesContext).forEach(uri -> { + addOpenFileToCompilationUnit(uri, languageServerContext.getFileContentsTracker().getContents(uri), unit); + }); // add all other classes too - getAllClasses() - .filter(path -> !languageServerContext.getFileContentsTracker().isOpen(path.toUri())) - .forEach(path -> { - addOpenFileToCompilationUnit(path.toUri(), languageServerContext.getFileContentsTracker().getContents(path.toUri()), unit); - }); + getAllClasses().filter(path -> !languageServerContext.getFileContentsTracker().isOpen(path.toUri())).forEach(path -> { + addOpenFileToCompilationUnit(path.toUri(), languageServerContext.getFileContentsTracker().getContents(path.toUri()), + unit); + }); if (context != null) { var contents = languageServerContext.getFileContentsTracker().getContents(context); @@ -95,10 +94,12 @@ protected boolean isInClassesContext(URI uri) { } protected Stream getAllClasses() { - return LoadStage.getLoadStages().stream().map(LoadStage::getName) - .flatMap(loader -> GroovyScript.getRunConfig().getClassFiles(this.root, loader).stream()) - .map(File::toPath) - .map(path -> GroovyScript.getScriptFile().toPath().resolve(path)); + return LoadStage.getLoadStages().stream().map(LoadStage::getName).flatMap(loader -> GroovyScript.getRunConfig() + .getClassFiles(this.root, + loader) + .stream()).map( + File::toPath) + .map(path -> GroovyScript.getScriptFile().toPath().resolve(path)); } protected void removeSources(GroovyLSCompilationUnit unit, Set urisToRemove) { diff --git a/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptDocumentationProvider.java b/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptDocumentationProvider.java index 758960bc4..c229ba342 100644 --- a/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptDocumentationProvider.java +++ b/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptDocumentationProvider.java @@ -1,20 +1,22 @@ package com.cleanroommc.groovyscript.server; -import com.cleanroommc.groovyscript.api.IGroovyContainer; -import com.cleanroommc.groovyscript.api.IScriptReloadable; -import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; -import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.documentation.Registry; +import java.util.Collections; +import java.util.Objects; + import net.prominic.groovyls.compiler.ast.ASTContext; import net.prominic.groovyls.compiler.documentation.IDocumentationProvider; import net.prominic.groovyls.compiler.util.GroovyReflectionUtils; + import org.codehaus.groovy.ast.AnnotatedNode; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.MethodNode; import org.jetbrains.annotations.Nullable; -import java.util.Collections; -import java.util.Objects; +import com.cleanroommc.groovyscript.api.IGroovyContainer; +import com.cleanroommc.groovyscript.api.IScriptReloadable; +import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.documentation.Registry; public class GroovyScriptDocumentationProvider implements IDocumentationProvider { @@ -22,24 +24,26 @@ public class GroovyScriptDocumentationProvider implements IDocumentationProvider public @Nullable String getDocumentation(AnnotatedNode node, ASTContext context) { var builder = new StringBuilder(); - if (node instanceof MethodNode methodNode && methodNode.getDeclaringClass().implementsInterface(new ClassNode(IScriptReloadable.class))) { - ModSupport.getAllContainers().stream() - .filter(IGroovyContainer::isLoaded) - .map(groovyContainer -> { - var methodRegistry = groovyContainer.get().getRegistries().stream() - .filter(registry -> registry.getClass().equals(methodNode.getDeclaringClass().getTypeClass())) - .findFirst(); - - if (methodRegistry.isPresent()) { - var method = GroovyReflectionUtils.resolveMethodFromMethodNode(methodNode, context); - - if (method.isPresent() && method.get().isAnnotationPresent(MethodDescription.class)) { - return new Registry(groovyContainer, methodRegistry.get()).documentMethods(Collections.singletonList(method.get()), true); - } - } - - return null; - }).filter(Objects::nonNull).forEach(builder::append); + if (node instanceof MethodNode methodNode && methodNode.getDeclaringClass().implementsInterface(new ClassNode( + IScriptReloadable.class))) { + ModSupport.getAllContainers().stream().filter(IGroovyContainer::isLoaded).map(groovyContainer -> { + var methodRegistry = groovyContainer.get().getRegistries().stream().filter(registry -> registry.getClass().equals( + methodNode.getDeclaringClass() + .getTypeClass())) + .findFirst(); + + if (methodRegistry.isPresent()) { + var method = GroovyReflectionUtils.resolveMethodFromMethodNode(methodNode, context); + + if (method.isPresent() && method.get().isAnnotationPresent(MethodDescription.class)) { + return new Registry(groovyContainer, methodRegistry.get()).documentMethods(Collections.singletonList( + method.get()), + true); + } + } + + return null; + }).filter(Objects::nonNull).forEach(builder::append); } return builder.length() == 0 ? null : builder.toString(); diff --git a/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptLanguageServer.java b/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptLanguageServer.java index ad7ba34a3..c403f5069 100644 --- a/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptLanguageServer.java +++ b/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptLanguageServer.java @@ -1,14 +1,16 @@ package com.cleanroommc.groovyscript.server; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.GroovyScriptConfig; -import com.cleanroommc.groovyscript.api.GroovyLog; +import java.io.File; +import java.net.ServerSocket; + import net.prominic.groovyls.GroovyLanguageServer; + import org.eclipse.lsp4j.jsonrpc.Launcher; import org.eclipse.lsp4j.services.LanguageClient; -import java.io.File; -import java.net.ServerSocket; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.GroovyScriptConfig; +import com.cleanroommc.groovyscript.api.GroovyLog; public class GroovyScriptLanguageServer extends GroovyLanguageServer { @@ -19,12 +21,12 @@ public static void listen(File root) { while (true) { var server = new GroovyScriptLanguageServer(root, languageServerContext); - try (var serverSocket = new ServerSocket(GroovyScriptConfig.languageServerPort); - var socket = serverSocket.accept()) { + try (var serverSocket = new ServerSocket(GroovyScriptConfig.languageServerPort); var socket = serverSocket.accept()) { GroovyScript.LOGGER.info("Accepted connection from: {}", socket.getInetAddress()); - var launcher = Launcher.createLauncher(server, LanguageClient.class, socket.getInputStream(), socket.getOutputStream()); + var launcher = Launcher.createLauncher(server, LanguageClient.class, socket.getInputStream(), socket + .getOutputStream()); server.connect(launcher.getRemoteProxy()); launcher.startListening().get(); diff --git a/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptLanguageServerContext.java b/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptLanguageServerContext.java index cc21c2a17..a55fa0492 100644 --- a/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptLanguageServerContext.java +++ b/src/main/java/com/cleanroommc/groovyscript/server/GroovyScriptLanguageServerContext.java @@ -1,48 +1,45 @@ package com.cleanroommc.groovyscript.server; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.sandbox.GroovyScriptSandbox; -import com.cleanroommc.groovyscript.sandbox.security.GroovySecurityManager; -import io.github.classgraph.ClassGraph; -import io.github.classgraph.ScanResult; import net.minecraft.launchwrapper.Launch; import net.prominic.groovyls.compiler.ILanguageServerContext; import net.prominic.groovyls.compiler.documentation.DocumentationFactory; import net.prominic.groovyls.compiler.documentation.GroovydocProvider; import net.prominic.groovyls.util.FileContentsTracker; +import com.cleanroommc.groovyscript.GroovyScript; +import com.cleanroommc.groovyscript.sandbox.GroovyScriptSandbox; +import com.cleanroommc.groovyscript.sandbox.security.GroovySecurityManager; + +import io.github.classgraph.ClassGraph; +import io.github.classgraph.ScanResult; + public class GroovyScriptLanguageServerContext implements ILanguageServerContext { private final FileContentsTracker fileContentsTracker = new FileContentsTracker(); - private ScanResult scanResult = new ClassGraph() - .enableClassInfo() - .enableMethodInfo() - .enableSystemJarsAndModules() - .overrideClassLoaders(Launch.classLoader) - .acceptPaths("*") - .rejectClasses(GroovySecurityManager.INSTANCE.getBannedClasses().stream().map(Class::getName).toArray(String[]::new)) - .rejectPackages(GroovySecurityManager.INSTANCE.getBannedPackages().stream().toArray(String[]::new)) - .acceptClasses(GroovySecurityManager.INSTANCE.getWhiteListedClasses().stream().map(Class::getName).toArray(String[]::new)) - .scan(); + private ScanResult scanResult = new ClassGraph().enableClassInfo().enableMethodInfo().enableSystemJarsAndModules() + .overrideClassLoaders(Launch.classLoader).acceptPaths("*").rejectClasses( + GroovySecurityManager.INSTANCE.getBannedClasses() + .stream() + .map(Class::getName) + .toArray(String[]::new)) + .rejectPackages(GroovySecurityManager.INSTANCE.getBannedPackages().stream() + .toArray(String[]::new)) + .acceptClasses(GroovySecurityManager.INSTANCE.getWhiteListedClasses().stream() + .map(Class::getName).toArray( + String[]::new)) + .scan(); - private final DocumentationFactory documentationFactory = new DocumentationFactory(new GroovyScriptDocumentationProvider(), new GroovydocProvider()); + private final DocumentationFactory documentationFactory = new DocumentationFactory(new GroovyScriptDocumentationProvider(), + new GroovydocProvider()); - public GroovyScriptSandbox getSandbox() { - return GroovyScript.getSandbox(); - } + public GroovyScriptSandbox getSandbox() { return GroovyScript.getSandbox(); } - public ScanResult getScanResult() { - return this.scanResult; - } + public ScanResult getScanResult() { return this.scanResult; } @Override - public FileContentsTracker getFileContentsTracker() { - return fileContentsTracker; - } + public FileContentsTracker getFileContentsTracker() { return fileContentsTracker; } @Override - public DocumentationFactory getDocumentationFactory() { - return documentationFactory; - } + public DocumentationFactory getDocumentationFactory() { return documentationFactory; } } diff --git a/src/main/java/net/prominic/groovyls/GroovyLanguageServer.java b/src/main/java/net/prominic/groovyls/GroovyLanguageServer.java index 281f5ba43..5b4e5e43a 100644 --- a/src/main/java/net/prominic/groovyls/GroovyLanguageServer.java +++ b/src/main/java/net/prominic/groovyls/GroovyLanguageServer.java @@ -19,10 +19,6 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; -import java.net.ServerSocket; import java.net.URI; import java.nio.file.Path; import java.nio.file.Paths; @@ -30,20 +26,15 @@ import java.util.concurrent.CompletableFuture; import net.prominic.groovyls.compiler.ILanguageServerContext; +import net.prominic.groovyls.config.ICompilationUnitFactory; + import org.eclipse.lsp4j.*; -import org.eclipse.lsp4j.jsonrpc.Launcher; -import org.eclipse.lsp4j.launch.LSPLauncher; import org.eclipse.lsp4j.services.LanguageClient; import org.eclipse.lsp4j.services.LanguageClientAware; import org.eclipse.lsp4j.services.LanguageServer; import org.eclipse.lsp4j.services.TextDocumentService; import org.eclipse.lsp4j.services.WorkspaceService; -import com.cleanroommc.groovyscript.GroovyScript; -import com.cleanroommc.groovyscript.GroovyScriptConfig; - -import net.prominic.groovyls.config.CompilationUnitFactory; -import net.prominic.groovyls.config.ICompilationUnitFactory; public class GroovyLanguageServer implements LanguageServer, LanguageClientAware { @@ -91,14 +82,10 @@ public CompletableFuture shutdown() { public void exit() {} @Override - public TextDocumentService getTextDocumentService() { - return groovyServices; - } + public TextDocumentService getTextDocumentService() { return groovyServices; } @Override - public WorkspaceService getWorkspaceService() { - return groovyServices; - } + public WorkspaceService getWorkspaceService() { return groovyServices; } @Override public void setTrace(SetTraceParams params) { diff --git a/src/main/java/net/prominic/groovyls/GroovyServices.java b/src/main/java/net/prominic/groovyls/GroovyServices.java index 1fdd063fc..a0aefb721 100644 --- a/src/main/java/net/prominic/groovyls/GroovyServices.java +++ b/src/main/java/net/prominic/groovyls/GroovyServices.java @@ -19,9 +19,15 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls; -import com.cleanroommc.groovyscript.GroovyScript; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; +import java.net.URI; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + import net.prominic.groovyls.compiler.ILanguageServerContext; import net.prominic.groovyls.compiler.ast.ASTContext; import net.prominic.groovyls.compiler.ast.ASTNodeVisitor; @@ -31,6 +37,7 @@ import net.prominic.groovyls.util.GroovyLanguageServerUtils; import net.prominic.groovyls.util.URIUtils; import net.prominic.lsp.utils.Positions; + import org.codehaus.groovy.GroovyBugError; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.control.ErrorCollector; @@ -45,14 +52,9 @@ import org.eclipse.lsp4j.services.WorkspaceService; import org.jetbrains.annotations.Nullable; -import java.net.URI; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; +import com.cleanroommc.groovyscript.GroovyScript; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; public class GroovyServices implements TextDocumentService, WorkspaceService, LanguageClientAware { @@ -119,8 +121,8 @@ public void didSave(DidSaveTextDocumentParams params) { @Override public void didChangeWatchedFiles(DidChangeWatchedFilesParams params) { - Set urisWithChanges = params.getChanges().stream().map(fileEvent -> URIUtils.toUri(fileEvent.getUri())) - .collect(Collectors.toSet()); + Set urisWithChanges = params.getChanges().stream().map(fileEvent -> URIUtils.toUri(fileEvent.getUri())).collect( + Collectors.toSet()); for (URI uri : urisWithChanges) { var unit = compilationUnitFactory.create(workspaceRoot, uri); @@ -131,9 +133,7 @@ public void didChangeWatchedFiles(DidChangeWatchedFilesParams params) { @Override public void didChangeConfiguration(DidChangeConfigurationParams params) { - if (!(params.getSettings() instanceof JsonObject)) { - return; - } + if (!(params.getSettings() instanceof JsonObject)) { return; } JsonObject settings = (JsonObject) params.getSettings(); this.updateClasspath(settings); } @@ -165,9 +165,7 @@ public CompletableFuture hover(HoverParams params) { var visitor = compileAndVisitAST(unit, uri); - if (visitor == null) { - return CompletableFuture.completedFuture(null); - } + if (visitor == null) { return CompletableFuture.completedFuture(null); } HoverProvider provider = new HoverProvider(new ASTContext(visitor, languageServerContext)); return provider.provideHover(params.getTextDocument(), params.getPosition()); @@ -186,8 +184,7 @@ public CompletableFuture, CompletionList>> completio ASTNode offsetNode = visitor.getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter()); if (offsetNode == null) { originalSource = languageServerContext.getFileContentsTracker().getContents(uri); - VersionedTextDocumentIdentifier versionedTextDocument = new VersionedTextDocumentIdentifier( - textDocument.getUri(), 1); + VersionedTextDocumentIdentifier versionedTextDocument = new VersionedTextDocumentIdentifier(textDocument.getUri(), 1); int offset = Positions.getOffset(originalSource, position); String lineBeforeOffset = originalSource.substring(offset - position.getCharacter(), offset); Matcher matcher = PATTERN_CONSTRUCTOR_CALL.matcher(lineBeforeOffset); @@ -197,8 +194,8 @@ public CompletableFuture, CompletionList>> completio } else { changeEvent = new TextDocumentContentChangeEvent(new Range(position, position), 0, "a"); } - DidChangeTextDocumentParams didChangeParams = new DidChangeTextDocumentParams(versionedTextDocument, - Collections.singletonList(changeEvent)); + DidChangeTextDocumentParams didChangeParams = new DidChangeTextDocumentParams(versionedTextDocument, Collections + .singletonList(changeEvent)); // if the offset node is null, there is probably a syntax error. // a completion request is usually triggered by the . character, and // if there is no property name after the dot, it will cause a syntax @@ -216,12 +213,11 @@ public CompletableFuture, CompletionList>> completio result = provider.provideCompletion(params.getTextDocument(), params.getPosition(), params.getContext()); } finally { if (originalSource != null) { - VersionedTextDocumentIdentifier versionedTextDocument = new VersionedTextDocumentIdentifier( - textDocument.getUri(), 1); - TextDocumentContentChangeEvent changeEvent = new TextDocumentContentChangeEvent(null, 0, - originalSource); - DidChangeTextDocumentParams didChangeParams = new DidChangeTextDocumentParams(versionedTextDocument, - Collections.singletonList(changeEvent)); + VersionedTextDocumentIdentifier versionedTextDocument = new VersionedTextDocumentIdentifier(textDocument.getUri(), + 1); + TextDocumentContentChangeEvent changeEvent = new TextDocumentContentChangeEvent(null, 0, originalSource); + DidChangeTextDocumentParams didChangeParams = new DidChangeTextDocumentParams(versionedTextDocument, Collections + .singletonList(changeEvent)); didChange(didChangeParams); } } @@ -230,8 +226,7 @@ public CompletableFuture, CompletionList>> completio } @Override - public CompletableFuture, List>> definition( - DefinitionParams params) { + public CompletableFuture, List>> definition(DefinitionParams params) { URI uri = URIUtils.toUri(params.getTextDocument().getUri()); var unit = compilationUnitFactory.create(workspaceRoot, uri); @@ -254,12 +249,11 @@ public CompletableFuture signatureHelp(SignatureHelpParams params ASTNode offsetNode = visitor.getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter()); if (offsetNode == null) { originalSource = languageServerContext.getFileContentsTracker().getContents(uri); - VersionedTextDocumentIdentifier versionedTextDocument = new VersionedTextDocumentIdentifier( - textDocument.getUri(), 1); - TextDocumentContentChangeEvent changeEvent = new TextDocumentContentChangeEvent( - new Range(position, position), 0, ")"); - DidChangeTextDocumentParams didChangeParams = new DidChangeTextDocumentParams(versionedTextDocument, - Collections.singletonList(changeEvent)); + VersionedTextDocumentIdentifier versionedTextDocument = new VersionedTextDocumentIdentifier(textDocument.getUri(), 1); + TextDocumentContentChangeEvent changeEvent = new TextDocumentContentChangeEvent(new Range(position, position), 0, + ")"); + DidChangeTextDocumentParams didChangeParams = new DidChangeTextDocumentParams(versionedTextDocument, Collections + .singletonList(changeEvent)); // if the offset node is null, there is probably a syntax error. // a signature help request is usually triggered by the ( character, // and if there is no matching ), it will cause a syntax error. @@ -276,20 +270,18 @@ public CompletableFuture signatureHelp(SignatureHelpParams params return provider.provideSignatureHelp(params.getTextDocument(), params.getPosition()); } finally { if (originalSource != null) { - VersionedTextDocumentIdentifier versionedTextDocument = new VersionedTextDocumentIdentifier( - textDocument.getUri(), 1); - TextDocumentContentChangeEvent changeEvent = new TextDocumentContentChangeEvent(null, 0, - originalSource); - DidChangeTextDocumentParams didChangeParams = new DidChangeTextDocumentParams(versionedTextDocument, - Collections.singletonList(changeEvent)); + VersionedTextDocumentIdentifier versionedTextDocument = new VersionedTextDocumentIdentifier(textDocument.getUri(), + 1); + TextDocumentContentChangeEvent changeEvent = new TextDocumentContentChangeEvent(null, 0, originalSource); + DidChangeTextDocumentParams didChangeParams = new DidChangeTextDocumentParams(versionedTextDocument, Collections + .singletonList(changeEvent)); didChange(didChangeParams); } } } @Override - public CompletableFuture, List>> typeDefinition( - TypeDefinitionParams params) { + public CompletableFuture, List>> typeDefinition(TypeDefinitionParams params) { URI uri = URIUtils.toUri(params.getTextDocument().getUri()); var unit = compilationUnitFactory.create(workspaceRoot, uri); @@ -311,8 +303,7 @@ public CompletableFuture> references(ReferenceParams pa } @Override - public CompletableFuture>> documentSymbol( - DocumentSymbolParams params) { + public CompletableFuture>> documentSymbol(DocumentSymbolParams params) { URI uri = URIUtils.toUri(params.getTextDocument().getUri()); var unit = compilationUnitFactory.create(workspaceRoot, uri); @@ -339,7 +330,8 @@ public CompletableFuture rename(RenameParams params) { var visitor = compileAndVisitAST(unit, uri); - RenameProvider provider = new RenameProvider(new ASTContext(visitor, languageServerContext), languageServerContext.getFileContentsTracker()); + RenameProvider provider = new RenameProvider(new ASTContext(visitor, languageServerContext), languageServerContext + .getFileContentsTracker()); return provider.provideRename(params); } @@ -361,23 +353,24 @@ private Set handleErrorCollector(ErrorCollector collec List errors = collector.getErrors(); if (errors != null) { - errors.stream().filter((Object message) -> message instanceof SyntaxErrorMessage) - .forEach((Object message) -> { - SyntaxErrorMessage syntaxErrorMessage = (SyntaxErrorMessage) message; - SyntaxException cause = syntaxErrorMessage.getCause(); - Range range = GroovyLanguageServerUtils.syntaxExceptionToRange(cause); - Diagnostic diagnostic = new Diagnostic(); - diagnostic.setRange(range); - diagnostic.setSeverity(DiagnosticSeverity.Error); - diagnostic.setMessage(cause.getMessage()); - URI uri = Paths.get(cause.getSourceLocator()).toUri(); - diagnosticsByFile.computeIfAbsent(uri, (key) -> new ArrayList<>()).add(diagnostic); - }); + errors.stream().filter((Object message) -> message instanceof SyntaxErrorMessage).forEach((Object message) -> { + SyntaxErrorMessage syntaxErrorMessage = (SyntaxErrorMessage) message; + SyntaxException cause = syntaxErrorMessage.getCause(); + Range range = GroovyLanguageServerUtils.syntaxExceptionToRange(cause); + Diagnostic diagnostic = new Diagnostic(); + diagnostic.setRange(range); + diagnostic.setSeverity(DiagnosticSeverity.Error); + diagnostic.setMessage(cause.getMessage()); + URI uri = Paths.get(cause.getSourceLocator()).toUri(); + diagnosticsByFile.computeIfAbsent(uri, (key) -> new ArrayList<>()).add(diagnostic); + }); } - Set result = diagnosticsByFile.entrySet().stream() - .map(entry -> new PublishDiagnosticsParams(entry.getKey().toString(), entry.getValue())) - .collect(Collectors.toSet()); + Set result = diagnosticsByFile.entrySet().stream().map(entry -> new PublishDiagnosticsParams( + entry.getKey() + .toString(), + entry.getValue())) + .collect(Collectors.toSet()); if (prevDiagnosticsByFile != null) { for (URI key : prevDiagnosticsByFile.keySet()) { @@ -391,4 +384,4 @@ private Set handleErrorCollector(ErrorCollector collec prevDiagnosticsByFile = diagnosticsByFile; return result; } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/compiler/ILanguageServerContext.java b/src/main/java/net/prominic/groovyls/compiler/ILanguageServerContext.java index 60470c34d..3d080ff20 100644 --- a/src/main/java/net/prominic/groovyls/compiler/ILanguageServerContext.java +++ b/src/main/java/net/prominic/groovyls/compiler/ILanguageServerContext.java @@ -1,10 +1,12 @@ package net.prominic.groovyls.compiler; -import com.cleanroommc.groovyscript.sandbox.GroovySandbox; -import io.github.classgraph.ScanResult; import net.prominic.groovyls.compiler.documentation.DocumentationFactory; import net.prominic.groovyls.util.FileContentsTracker; +import com.cleanroommc.groovyscript.sandbox.GroovySandbox; + +import io.github.classgraph.ScanResult; + public interface ILanguageServerContext { GroovySandbox getSandbox(); diff --git a/src/main/java/net/prominic/groovyls/compiler/ast/ASTContext.java b/src/main/java/net/prominic/groovyls/compiler/ast/ASTContext.java index e973cb5c4..965f83297 100644 --- a/src/main/java/net/prominic/groovyls/compiler/ast/ASTContext.java +++ b/src/main/java/net/prominic/groovyls/compiler/ast/ASTContext.java @@ -12,11 +12,7 @@ public ASTContext(ASTNodeVisitor astVisitor, ILanguageServerContext languageServ this.languageServerContext = languageServerContext; } - public ASTNodeVisitor getVisitor() { - return astVisitor; - } + public ASTNodeVisitor getVisitor() { return astVisitor; } - public ILanguageServerContext getLanguageServerContext() { - return languageServerContext; - } + public ILanguageServerContext getLanguageServerContext() { return languageServerContext; } } diff --git a/src/main/java/net/prominic/groovyls/compiler/ast/ASTNodeVisitor.java b/src/main/java/net/prominic/groovyls/compiler/ast/ASTNodeVisitor.java index c1d974827..841bde0c6 100644 --- a/src/main/java/net/prominic/groovyls/compiler/ast/ASTNodeVisitor.java +++ b/src/main/java/net/prominic/groovyls/compiler/ast/ASTNodeVisitor.java @@ -19,11 +19,14 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls.compiler.ast; -import com.cleanroommc.groovyscript.helper.BetterList; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import java.net.URI; +import java.util.*; +import java.util.stream.Collectors; + import net.prominic.groovyls.util.GroovyLanguageServerUtils; import net.prominic.lsp.utils.Positions; import net.prominic.lsp.utils.Ranges; + import org.codehaus.groovy.ast.*; import org.codehaus.groovy.ast.expr.*; import org.codehaus.groovy.ast.stmt.*; @@ -33,9 +36,9 @@ import org.eclipse.lsp4j.Position; import org.eclipse.lsp4j.Range; -import java.net.URI; -import java.util.*; -import java.util.stream.Collectors; +import com.cleanroommc.groovyscript.helper.BetterList; + +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; public class ASTNodeVisitor extends ClassCodeVisitorSupport { @@ -69,9 +72,7 @@ private static class ASTNodeLookupData { private SourceUnit sourceUnit; @Override - protected SourceUnit getSourceUnit() { - return sourceUnit; - } + protected SourceUnit getSourceUnit() { return sourceUnit; } private final BetterList stack = new BetterList<>(); private final Map> nodesByURI = new Object2ObjectOpenHashMap<>(); @@ -113,9 +114,7 @@ public List getNodes() { public List getNodes(URI uri) { List nodes = nodesByURI.get(uri); - if (nodes == null) { - return Collections.emptyList(); - } + if (nodes == null) { return Collections.emptyList(); } return nodes; } @@ -123,9 +122,7 @@ public ASTNode getNodeAtLineAndColumn(URI uri, int line, int column) { Position position = new Position(line, column); Map nodeToRange = new HashMap<>(); List nodes = nodesByURI.get(uri); - if (nodes == null) { - return null; - } + if (nodes == null) { return null; } List foundNodes = nodes.stream().filter(node -> { if (node.getLineNumber() == -1) { // can't be the offset node if it has no position @@ -133,9 +130,7 @@ public ASTNode getNodeAtLineAndColumn(URI uri, int line, int column) { return false; } Range range = GroovyLanguageServerUtils.astNodeToRange(node); - if (range == null) { - return false; - } + if (range == null) { return false; } boolean result = Ranges.contains(range, position); if (result) { // save the range object to avoid creating it again when we @@ -144,52 +139,35 @@ public ASTNode getNodeAtLineAndColumn(URI uri, int line, int column) { } return result; }).sorted((n1, n2) -> { - int result = Positions.COMPARATOR.reversed().compare(nodeToRange.get(n1).getStart(), - nodeToRange.get(n2).getStart()); - if (result != 0) { - return result; - } + int result = Positions.COMPARATOR.reversed().compare(nodeToRange.get(n1).getStart(), nodeToRange.get(n2).getStart()); + if (result != 0) { return result; } result = Positions.COMPARATOR.compare(nodeToRange.get(n1).getEnd(), nodeToRange.get(n2).getEnd()); - if (result != 0) { - return result; - } + if (result != 0) { return result; } // n1 and n2 have the same range if (contains(n1, n2)) { - if (n1 instanceof ClassNode && n2 instanceof ConstructorNode) { - return -1; - } + if (n1 instanceof ClassNode && n2 instanceof ConstructorNode) { return -1; } return 1; } else if (contains(n2, n1)) { - if (n2 instanceof ClassNode && n1 instanceof ConstructorNode) { - return 1; - } + if (n2 instanceof ClassNode && n1 instanceof ConstructorNode) { return 1; } return -1; } return 0; }).collect(Collectors.toList()); - if (foundNodes.isEmpty()) { - return null; - } + if (foundNodes.isEmpty()) { return null; } return foundNodes.get(0); } public ASTNode getParent(ASTNode child) { - if (child == null) { - return null; - } + if (child == null) { return null; } ASTNodeLookupData data = lookup.get(new ASTLookupKey(child)); - if (data == null) { - return null; - } + if (data == null) { return null; } return data.parent; } public boolean contains(ASTNode ancestor, ASTNode descendant) { ASTNode current = getParent(descendant); while (current != null) { - if (current.equals(ancestor)) { - return true; - } + if (current.equals(ancestor)) { return true; } current = getParent(current); } return false; @@ -197,9 +175,7 @@ public boolean contains(ASTNode ancestor, ASTNode descendant) { public URI getURI(ASTNode node) { ASTNodeLookupData data = lookup.get(new ASTLookupKey(node)); - if (data == null) { - return null; - } + if (data == null) { return null; } return data.uri; } @@ -223,9 +199,7 @@ public void visitCompilationUnit(CompilationUnit unit, Collection uris) { }); unit.iterator().forEachRemaining(sourceUnit -> { URI uri = sourceUnit.getSource().getURI(); - if (!uris.contains(uri)) { - return; - } + if (!uris.contains(uri)) { return; } visitSourceUnit(sourceUnit); }); } @@ -827,4 +801,4 @@ public void visitBytecodeExpression(BytecodeExpression node) { popASTNode(); } } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/compiler/control/GroovyLSCompilationUnit.java b/src/main/java/net/prominic/groovyls/compiler/control/GroovyLSCompilationUnit.java index 10ccff0b1..25afa4507 100644 --- a/src/main/java/net/prominic/groovyls/compiler/control/GroovyLSCompilationUnit.java +++ b/src/main/java/net/prominic/groovyls/compiler/control/GroovyLSCompilationUnit.java @@ -19,22 +19,24 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls.compiler.control; -import groovy.lang.GroovyClassLoader; +import java.net.URI; +import java.security.CodeSource; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + import net.prominic.groovyls.compiler.ILanguageServerContext; import net.prominic.groovyls.compiler.ast.ASTNodeVisitor; + import org.codehaus.groovy.ast.CompileUnit; import org.codehaus.groovy.ast.ModuleNode; import org.codehaus.groovy.control.*; import org.codehaus.groovy.tools.GroovyClass; import org.jetbrains.annotations.Nullable; -import java.net.URI; -import java.security.CodeSource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; +import groovy.lang.GroovyClassLoader; public class GroovyLSCompilationUnit extends CompilationUnit { @@ -45,21 +47,21 @@ public class GroovyLSCompilationUnit extends CompilationUnit { @Nullable private URI previousContext; - public GroovyLSCompilationUnit(CompilerConfiguration config, CodeSource security, GroovyClassLoader loader, ILanguageServerContext languageServerContext) { + public GroovyLSCompilationUnit(CompilerConfiguration config, CodeSource security, GroovyClassLoader loader, + ILanguageServerContext languageServerContext) { super(config, security, loader); this.languageServerContext = languageServerContext; this.errorCollector = new LanguageServerErrorCollector(config); } - public void setErrorCollector(LanguageServerErrorCollector errorCollector) { - this.errorCollector = errorCollector; - } + public void setErrorCollector(LanguageServerErrorCollector errorCollector) { this.errorCollector = errorCollector; } public void removeSources(Collection sourceUnitsToRemove) { for (SourceUnit sourceUnit : sourceUnitsToRemove) { if (sourceUnit.getAST() != null) { - List sourceUnitClassNames = sourceUnit.getAST().getClasses().stream() - .map(classNode -> classNode.getName()).collect(Collectors.toList()); + List sourceUnitClassNames = sourceUnit.getAST().getClasses().stream().map(classNode -> classNode + .getName()) + .collect(Collectors.toList()); final List generatedClasses = getClasses(); generatedClasses.removeIf(groovyClass -> sourceUnitClassNames.contains(groovyClass.getName())); } @@ -112,9 +114,7 @@ private ASTNodeVisitor compileAndVisitAST() { } private ASTNodeVisitor compileAndVisitAST(@Nullable URI context) { - if (context == null) { - return compileAndVisitAST(); - } + if (context == null) { return compileAndVisitAST(); } previousContext = context; @@ -127,9 +127,7 @@ public ASTNodeVisitor recompileAndVisitASTIfContextChanged(@Nullable URI context languageServerContext.getFileContentsTracker().resetChangedFiles(); - if ((previousContext == null || previousContext.equals(context)) && visitor != null && !isChanged) { - return visitor; - } + if ((previousContext == null || previousContext.equals(context)) && visitor != null && !isChanged) { return visitor; } if (context != null) { languageServerContext.getFileContentsTracker().forceChanged(context); @@ -137,4 +135,4 @@ public ASTNodeVisitor recompileAndVisitASTIfContextChanged(@Nullable URI context return compileAndVisitAST(context); } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/compiler/control/LanguageServerErrorCollector.java b/src/main/java/net/prominic/groovyls/compiler/control/LanguageServerErrorCollector.java index ec137ebc8..5eef3b2d1 100644 --- a/src/main/java/net/prominic/groovyls/compiler/control/LanguageServerErrorCollector.java +++ b/src/main/java/net/prominic/groovyls/compiler/control/LanguageServerErrorCollector.java @@ -28,6 +28,7 @@ * does not throw exceptions. */ public class LanguageServerErrorCollector extends ErrorCollector { + private static final long serialVersionUID = 1L; public LanguageServerErrorCollector(CompilerConfiguration configuration) { diff --git a/src/main/java/net/prominic/groovyls/compiler/control/io/StringReaderSourceWithURI.java b/src/main/java/net/prominic/groovyls/compiler/control/io/StringReaderSourceWithURI.java index 1b1a96e0e..2963b5307 100644 --- a/src/main/java/net/prominic/groovyls/compiler/control/io/StringReaderSourceWithURI.java +++ b/src/main/java/net/prominic/groovyls/compiler/control/io/StringReaderSourceWithURI.java @@ -25,14 +25,13 @@ import org.codehaus.groovy.control.io.StringReaderSource; public class StringReaderSourceWithURI extends StringReaderSource { - private URI uri; - public StringReaderSourceWithURI(String string, URI uri, CompilerConfiguration configuration) { - super(string, configuration); - this.uri = uri; - } + private URI uri; - public URI getURI() { - return uri; - } -} \ No newline at end of file + public StringReaderSourceWithURI(String string, URI uri, CompilerConfiguration configuration) { + super(string, configuration); + this.uri = uri; + } + + public URI getURI() { return uri; } +} diff --git a/src/main/java/net/prominic/groovyls/compiler/documentation/DocumentationFactory.java b/src/main/java/net/prominic/groovyls/compiler/documentation/DocumentationFactory.java index 31299fac7..4661b876c 100644 --- a/src/main/java/net/prominic/groovyls/compiler/documentation/DocumentationFactory.java +++ b/src/main/java/net/prominic/groovyls/compiler/documentation/DocumentationFactory.java @@ -1,6 +1,7 @@ package net.prominic.groovyls.compiler.documentation; import net.prominic.groovyls.compiler.ast.ASTContext; + import org.codehaus.groovy.ast.AnnotatedNode; import org.jetbrains.annotations.Nullable; @@ -15,9 +16,7 @@ public DocumentationFactory(IDocumentationProvider... providers) { public @Nullable String getDocumentation(AnnotatedNode node, ASTContext context) { for (IDocumentationProvider provider : providers) { String documentation = provider.getDocumentation(node, context); - if (documentation != null) { - return documentation; - } + if (documentation != null) { return documentation; } } return null; } diff --git a/src/main/java/net/prominic/groovyls/compiler/documentation/GroovydocProvider.java b/src/main/java/net/prominic/groovyls/compiler/documentation/GroovydocProvider.java index fd3a25bc4..bbe599b70 100644 --- a/src/main/java/net/prominic/groovyls/compiler/documentation/GroovydocProvider.java +++ b/src/main/java/net/prominic/groovyls/compiler/documentation/GroovydocProvider.java @@ -1,6 +1,7 @@ package net.prominic.groovyls.compiler.documentation; import net.prominic.groovyls.compiler.ast.ASTContext; + import org.codehaus.groovy.ast.AnnotatedNode; import org.jetbrains.annotations.Nullable; @@ -14,9 +15,7 @@ public class GroovydocProvider implements IDocumentationProvider { public @Nullable String getDocumentation(AnnotatedNode node, ASTContext context) { var groovydoc = node.getGroovydoc(); - if (groovydoc == null || !groovydoc.isPresent()) { - return null; - } + if (groovydoc == null || !groovydoc.isPresent()) { return null; } String content = groovydoc.getContent(); String[] lines = content.split("\n"); StringBuilder markdownBuilder = new StringBuilder(); @@ -65,14 +64,12 @@ public class GroovydocProvider implements IDocumentationProvider { } return markdownBuilder.toString(). - trim(); + trim(); } private static void appendLine(StringBuilder markdownBuilder, String line) { line = reformatLine(line); - if (line.length() == 0) { - return; - } + if (line.length() == 0) { return; } markdownBuilder.append(line); markdownBuilder.append("\n"); } diff --git a/src/main/java/net/prominic/groovyls/compiler/documentation/IDocumentationProvider.java b/src/main/java/net/prominic/groovyls/compiler/documentation/IDocumentationProvider.java index 85ae10649..2d8ec67e1 100644 --- a/src/main/java/net/prominic/groovyls/compiler/documentation/IDocumentationProvider.java +++ b/src/main/java/net/prominic/groovyls/compiler/documentation/IDocumentationProvider.java @@ -1,10 +1,12 @@ package net.prominic.groovyls.compiler.documentation; import net.prominic.groovyls.compiler.ast.ASTContext; + import org.codehaus.groovy.ast.AnnotatedNode; import org.jetbrains.annotations.Nullable; public interface IDocumentationProvider { - @Nullable String getDocumentation(AnnotatedNode node, ASTContext context); + @Nullable + String getDocumentation(AnnotatedNode node, ASTContext context); } diff --git a/src/main/java/net/prominic/groovyls/compiler/util/GroovyASTUtils.java b/src/main/java/net/prominic/groovyls/compiler/util/GroovyASTUtils.java index ac116a888..391db783e 100644 --- a/src/main/java/net/prominic/groovyls/compiler/util/GroovyASTUtils.java +++ b/src/main/java/net/prominic/groovyls/compiler/util/GroovyASTUtils.java @@ -19,16 +19,17 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls.compiler.util; -import com.cleanroommc.groovyscript.api.Hidden; -import com.cleanroommc.groovyscript.helper.ArrayUtils; -import com.cleanroommc.groovyscript.mapper.ObjectMapper; -import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; -import com.cleanroommc.groovyscript.sandbox.expand.IDocumented; -import groovy.lang.*; -import groovy.lang.groovydoc.Groovydoc; -import groovy.lang.groovydoc.GroovydocHolder; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.function.Predicate; +import java.util.stream.Collectors; + import net.prominic.groovyls.compiler.ast.ASTContext; import net.prominic.groovyls.util.GroovyLanguageServerUtils; + import org.codehaus.groovy.ast.*; import org.codehaus.groovy.ast.expr.*; import org.codehaus.groovy.ast.stmt.ExpressionStatement; @@ -37,35 +38,32 @@ import org.jetbrains.annotations.NotNull; import org.objectweb.asm.Opcodes; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.function.Predicate; -import java.util.stream.Collectors; +import com.cleanroommc.groovyscript.api.Hidden; +import com.cleanroommc.groovyscript.helper.ArrayUtils; +import com.cleanroommc.groovyscript.mapper.ObjectMapper; +import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; +import com.cleanroommc.groovyscript.sandbox.expand.IDocumented; + +import groovy.lang.*; +import groovy.lang.groovydoc.Groovydoc; +import groovy.lang.groovydoc.GroovydocHolder; public class GroovyASTUtils { public static final int EXPANSION_MARKER = 0x01000000; public static final int HIDDEN_MARKER = 0x02000000; - public static ASTNode getEnclosingNodeOfType(ASTNode offsetNode, Class nodeType, - ASTContext context) { + public static ASTNode getEnclosingNodeOfType(ASTNode offsetNode, Class nodeType, ASTContext context) { ASTNode current = offsetNode; while (current != null) { - if (nodeType.isInstance(current)) { - return current; - } + if (nodeType.isInstance(current)) { return current; } current = context.getVisitor().getParent(current); } return null; } public static ASTNode getDefinition(ASTNode node, boolean strict, ASTContext context) { - if (node == null) { - return null; - } + if (node == null) { return null; } ASTNode parentNode = context.getVisitor().getParent(node); if (node instanceof ExpressionStatement) { ExpressionStatement statement = (ExpressionStatement) node; @@ -97,17 +95,13 @@ public static ASTNode getDefinition(ASTNode node, boolean strict, ASTContext con } else if (parentNode instanceof PropertyExpression) { PropertyExpression propertyExpression = (PropertyExpression) parentNode; PropertyNode propNode = GroovyASTUtils.getPropertyFromExpression(propertyExpression, context); - if (propNode != null) { - return propNode; - } + if (propNode != null) { return propNode; } return GroovyASTUtils.getFieldFromExpression(propertyExpression, context); } } else if (node instanceof VariableExpression) { VariableExpression variableExpression = (VariableExpression) node; Variable accessedVariable = variableExpression.getAccessedVariable(); - if (accessedVariable instanceof ASTNode) { - return (ASTNode) accessedVariable; - } + if (accessedVariable instanceof ASTNode) { return (ASTNode) accessedVariable; } Object binding = context.getLanguageServerContext().getSandbox().getBindings().get(variableExpression.getName()); if (binding == null) { @@ -128,9 +122,7 @@ public static ASTNode getDefinition(ASTNode node, boolean strict, ASTContext con public static ASTNode getTypeDefinition(ASTNode node, ASTContext context) { ASTNode definitionNode = getDefinition(node, false, context); - if (definitionNode == null) { - return null; - } + if (definitionNode == null) { return null; } if (definitionNode instanceof MethodNode) { MethodNode method = (MethodNode) definitionNode; return tryToResolveOriginalClassNode(method.getReturnType(), true, context); @@ -143,9 +135,7 @@ public static ASTNode getTypeDefinition(ASTNode node, ASTContext context) { public static List getReferences(ASTNode node, ASTContext context) { ASTNode definitionNode = getDefinition(node, true, context); - if (definitionNode == null) { - return Collections.emptyList(); - } + if (definitionNode == null) { return Collections.emptyList(); } return context.getVisitor().getNodes().stream().filter(otherNode -> { ASTNode otherDefinition = getDefinition(otherNode, false, context); return definitionNode.equals(otherDefinition) && node.getLineNumber() != -1 && node.getColumnNumber() != -1; @@ -154,13 +144,9 @@ public static List getReferences(ASTNode node, ASTContext context) { private static ClassNode tryToResolveOriginalClassNode(ClassNode node, boolean strict, ASTContext context) { for (ClassNode originalNode : context.getVisitor().getClassNodes()) { - if (originalNode.equals(node)) { - return originalNode; - } - } - if (strict) { - return null; + if (originalNode.equals(node)) { return originalNode; } } + if (strict) { return null; } return node; } @@ -203,25 +189,29 @@ public static Object resolveDynamicValue(ASTNode node, ASTContext context) { public static FieldNode getFieldFromExpression(PropertyExpression node, ASTContext context) { ClassNode classNode = getTypeOfNode(node.getObjectExpression(), context); - if (classNode != null) { - return classNode.getField(node.getProperty().getText()); - } + if (classNode != null) { return classNode.getField(node.getProperty().getText()); } return null; } - public static List getFieldsForLeftSideOfPropertyExpression(ClassNode classNode, Expression expr, ASTContext context) { + public static List getFieldsForLeftSideOfPropertyExpression(ClassNode classNode, Expression expr, + ASTContext context) { boolean statics = expr instanceof ClassExpression; - return collectFields(classNode, new ArrayList<>(), node -> statics == node.isStatic() && (node.getModifiers() & HIDDEN_MARKER) == 0); + return collectFields(classNode, new ArrayList<>(), node -> statics == node.isStatic() && (node + .getModifiers() & HIDDEN_MARKER) == 0); } - public static List getPropertiesForLeftSideOfPropertyExpression(ClassNode classNode, Expression expr, ASTContext context) { + public static List getPropertiesForLeftSideOfPropertyExpression(ClassNode classNode, Expression expr, + ASTContext context) { boolean statics = expr instanceof ClassExpression; - return collectProperties(classNode, new ArrayList<>(), node -> statics == node.isStatic() && (node.getModifiers() & HIDDEN_MARKER) == 0); + return collectProperties(classNode, new ArrayList<>(), node -> statics == node.isStatic() && (node + .getModifiers() & HIDDEN_MARKER) == 0); } - public static List getMethodsForLeftSideOfPropertyExpression(ClassNode classNode, Expression expr, ASTContext context) { + public static List getMethodsForLeftSideOfPropertyExpression(ClassNode classNode, Expression expr, + ASTContext context) { boolean statics = expr instanceof ClassExpression; - return collectMethods(classNode, new ArrayList<>(), node -> statics == node.isStatic() && (node.getModifiers() & HIDDEN_MARKER) == 0); + return collectMethods(classNode, new ArrayList<>(), node -> statics == node.isStatic() && (node + .getModifiers() & HIDDEN_MARKER) == 0); } public static List collectFields(ClassNode classNode, List nodes, Predicate test) { @@ -237,7 +227,8 @@ public static List collectFields(ClassNode classNode, List return nodes; } - public static List collectProperties(ClassNode classNode, List nodes, Predicate test) { + public static List collectProperties(ClassNode classNode, List nodes, + Predicate test) { for (PropertyNode node : classNode.getProperties()) { if (test.test(node)) nodes.add(node); } @@ -280,35 +271,25 @@ public static ClassNode getTypeOfNode(ASTNode node, ASTContext context) { } else if (node instanceof MethodCallExpression) { MethodCallExpression expression = (MethodCallExpression) node; ObjectMapper goh = getGohOfNode(expression, context); - if (goh != null) { - return ClassHelper.makeCached(goh.getReturnType()); - } + if (goh != null) { return ClassHelper.makeCached(goh.getReturnType()); } MethodNode methodNode = GroovyASTUtils.getMethodFromCallExpression(expression, context); - if (methodNode != null) { - return methodNode.getReturnType(); - } + if (methodNode != null) { return methodNode.getReturnType(); } return expression.getType(); } else if (node instanceof StaticMethodCallExpression expr) { MethodNode methodNode = GroovyASTUtils.getMethodFromCallExpression(expr, context); - if (methodNode != null) { - return methodNode.getReturnType(); - } + if (methodNode != null) { return methodNode.getReturnType(); } return expr.getType(); } else if (node instanceof PropertyExpression) { PropertyExpression expression = (PropertyExpression) node; PropertyNode propNode = GroovyASTUtils.getPropertyFromExpression(expression, context); - if (propNode != null) { - return getTypeOfNode(propNode, context); - } + if (propNode != null) { return getTypeOfNode(propNode, context); } return expression.getType(); } else if (node instanceof Variable) { Variable var = (Variable) node; if (var.getName().equals("this")) { ClassNode enclosingClass = (ClassNode) getEnclosingNodeOfType(node, ClassNode.class, context); - if (enclosingClass != null) { - return enclosingClass; - } + if (enclosingClass != null) { return enclosingClass; } } else if (var.isDynamicTyped()) { ASTNode defNode = GroovyASTUtils.getDefinition(node, false, context); if (defNode instanceof Variable) { @@ -326,9 +307,7 @@ public static ClassNode getTypeOfNode(ASTNode node, ASTContext context) { } } } - if (var.getOriginType() != null) { - return var.getOriginType(); - } + if (var.getOriginType() != null) { return var.getOriginType(); } } if (node instanceof Expression) { Expression expression = (Expression) node; @@ -342,9 +321,9 @@ public static List getMethodOverloadsFromCallExpression(MethodCall n List mn = new ArrayList<>(); if (methodCallExpr.isImplicitThis()) { Object o = context.getLanguageServerContext().getSandbox().getBindings().get(node.getMethodAsString()); - if (o instanceof ObjectMapper goh) { + if (o instanceof ObjectMappergoh) { mn.addAll(goh.getMethodNodes()); - } else if (o instanceof Closure closure) { + } else if (o instanceof Closureclosure) { mn.add(methodNodeOfClosure(node.getMethodAsString(), closure)); } } @@ -358,8 +337,8 @@ public static List getMethodOverloadsFromCallExpression(MethodCall n ClassNode constructorType = constructorCallExpr.getType(); if (constructorType != null) { fillClassNode(constructorType); - return constructorType.getDeclaredConstructors().stream().map(constructor -> (MethodNode) constructor) - .collect(Collectors.toList()); + return constructorType.getDeclaredConstructors().stream().map(constructor -> (MethodNode) constructor).collect( + Collectors.toList()); } } else if (node instanceof StaticMethodCallExpression staticMethodCallExpression) { var ownerType = staticMethodCallExpression.getOwnerType(); @@ -379,7 +358,9 @@ public static MethodNode getMethodFromCallExpression(MethodCall node, ASTContext List possibleMethods = getMethodOverloadsFromCallExpression(node, context); if (!possibleMethods.isEmpty() && node.getArguments() instanceof ArgumentListExpression) { ArgumentListExpression actualArguments = (ArgumentListExpression) node.getArguments(); - MethodNode foundMethod = possibleMethods.stream().max(new Comparator() { + MethodNode foundMethod = possibleMethods.stream().max(new Comparator() + { + public int compare(MethodNode m1, MethodNode m2) { Parameter[] p1 = m1.getParameters(); Parameter[] p2 = m2.getParameters(); @@ -387,9 +368,7 @@ public int compare(MethodNode m1, MethodNode m2) { int m2Value = calculateArgumentsScore(p2, actualArguments, argIndex); if (m1Value > m2Value) { return 1; - } else if (m1Value < m2Value) { - return -1; - } + } else if (m1Value < m2Value) { return -1; } return 0; } }).orElse(null); @@ -433,11 +412,8 @@ private static int calculateArgumentsScore(Parameter[] parameters, ArgumentListE } public static Range findAddImportRange(ASTNode offsetNode, ASTContext context) { - ModuleNode moduleNode = (ModuleNode) GroovyASTUtils.getEnclosingNodeOfType(offsetNode, ModuleNode.class, - context); - if (moduleNode == null) { - return new Range(new Position(0, 0), new Position(0, 0)); - } + ModuleNode moduleNode = (ModuleNode) GroovyASTUtils.getEnclosingNodeOfType(offsetNode, ModuleNode.class, context); + if (moduleNode == null) { return new Range(new Position(0, 0), new Position(0, 0)); } ASTNode afterNode = null; if (afterNode == null) { List importNodes = moduleNode.getImports(); @@ -448,38 +424,31 @@ public static Range findAddImportRange(ASTNode offsetNode, ASTContext context) { if (afterNode == null) { afterNode = moduleNode.getPackage(); } - if (afterNode == null) { - return new Range(new Position(0, 0), new Position(0, 0)); - } + if (afterNode == null) { return new Range(new Position(0, 0), new Position(0, 0)); } Range nodeRange = GroovyLanguageServerUtils.astNodeToRange(afterNode); - if (nodeRange == null) { - return new Range(new Position(0, 0), new Position(0, 0)); - } + if (nodeRange == null) { return new Range(new Position(0, 0), new Position(0, 0)); } Position position = new Position(nodeRange.getEnd().getLine() + 1, 0); return new Range(position, position); } public static MethodNode methodNodeOfClosure(String name, Closure closure) { - Class declarer = closure.getThisObject() == null ? - (closure.getOwner() == null ? Object.class : closure.getOwner().getClass()) : - closure.getThisObject().getClass(); - MethodNode method = new MethodNode(name, Modifier.PUBLIC, ClassHelper.OBJECT_TYPE, - ArrayUtils.map(closure.getParameterTypes(), - c -> new Parameter(ClassHelper.makeCached(c), ""), - new Parameter[closure.getParameterTypes().length]), + Class declarer = closure.getThisObject() == null ? (closure.getOwner() == null ? Object.class : closure.getOwner() + .getClass()) : + closure.getThisObject().getClass(); + MethodNode method = new MethodNode(name, Modifier.PUBLIC, ClassHelper.OBJECT_TYPE, ArrayUtils.map(closure + .getParameterTypes(), + c -> new Parameter(ClassHelper.makeCached(c), + ""), + new Parameter[closure.getParameterTypes().length]), null, null); method.setDeclaringClass(ClassHelper.makeCached(declarer)); return method; } public static ObjectMapper getGohOfNode(MethodCallExpression expr, ASTContext context) { - if (expr.isImplicitThis()) { - return ObjectMapperManager.getObjectMapper(expr.getMethodAsString()); - } + if (expr.isImplicitThis()) { return ObjectMapperManager.getObjectMapper(expr.getMethodAsString()); } ClassNode type = getTypeOfNode(expr.getObjectExpression(), context); - if (type != null) { - return ObjectMapperManager.getObjectMapper(type.getTypeClass(), expr.getMethodAsString()); - } + if (type != null) { return ObjectMapperManager.getObjectMapper(type.getTypeClass(), expr.getMethodAsString()); } return null; } @@ -497,9 +466,9 @@ public static void fillClassNode(ClassNode classNode) { if (mm.isPrivate()) continue; int m = mm.getModifiers(); if (mm instanceof Hidden hidden && hidden.isHidden()) m |= HIDDEN_MARKER; - Parameter[] params = ArrayUtils.map(mm.getNativeParameterTypes(), - c -> new Parameter(ClassHelper.makeCached(c), ""), - new Parameter[mm.getNativeParameterTypes().length]); + Parameter[] params = ArrayUtils.map(mm.getNativeParameterTypes(), c -> new Parameter(ClassHelper.makeCached(c), + ""), new Parameter[mm + .getNativeParameterTypes().length]); MethodNode node = new MethodNode(mm.getName(), m, ClassHelper.makeCached(mm.getReturnType()), params, null, null); node.setDeclaringClass(classNode); if (mm instanceof IDocumented documented && documented.getDocumentation() != null) { @@ -510,7 +479,8 @@ public static void fillClassNode(ClassNode classNode) { for (MetaProperty mp : emc.getExpandoProperties()) { int m = mp.getModifiers(); if (mp instanceof Hidden hidden && hidden.isHidden()) m |= HIDDEN_MARKER; - FieldNode field = new FieldNode(mp.getName(), m, ClassHelper.makeCached(mp.getType()), classNode.redirect(), null); + FieldNode field = new FieldNode(mp.getName(), m, ClassHelper.makeCached(mp.getType()), classNode.redirect(), + null); PropertyNode property = makeProperty(classNode, field, m); classNode.addProperty(property); } @@ -538,4 +508,4 @@ private static PropertyNode makeProperty(ClassNode classNode, FieldNode field, i } return property; } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/compiler/util/GroovyReflectionUtils.java b/src/main/java/net/prominic/groovyls/compiler/util/GroovyReflectionUtils.java index 17b1ee162..3e456f240 100644 --- a/src/main/java/net/prominic/groovyls/compiler/util/GroovyReflectionUtils.java +++ b/src/main/java/net/prominic/groovyls/compiler/util/GroovyReflectionUtils.java @@ -1,35 +1,45 @@ package net.prominic.groovyls.compiler.util; -import com.cleanroommc.groovyscript.sandbox.security.GroovySecurityManager; -import com.google.common.collect.Iterators; -import io.github.classgraph.MethodInfo; -import net.prominic.groovyls.compiler.ast.ASTContext; -import org.codehaus.groovy.ast.MethodNode; - import java.lang.reflect.Method; import java.util.Arrays; import java.util.Optional; +import net.prominic.groovyls.compiler.ast.ASTContext; + +import org.codehaus.groovy.ast.MethodNode; + +import com.cleanroommc.groovyscript.sandbox.security.GroovySecurityManager; +import com.google.common.collect.Iterators; + +import io.github.classgraph.MethodInfo; + public class GroovyReflectionUtils { public static Optional resolveMethodFromMethodNode(MethodNode methodNode, ASTContext context) { - return Arrays.stream(methodNode.getDeclaringClass().getTypeClass().getMethods()) - .filter(GroovySecurityManager.INSTANCE::isValid) - .filter(method -> method.getName().equals(methodNode.getName()) && - method.getParameterTypes().length == methodNode.getParameters().length && - Iterators.elementsEqual(Arrays.stream(method.getParameterTypes()).iterator(), - Arrays.stream(methodNode.getParameters()).map(parameter -> parameter.getType().getTypeClass()).iterator())) - .findFirst(); + return Arrays.stream(methodNode.getDeclaringClass().getTypeClass().getMethods()).filter( + GroovySecurityManager.INSTANCE::isValid) + .filter(method -> method.getName().equals(methodNode.getName()) && method + .getParameterTypes().length == methodNode.getParameters().length && Iterators.elementsEqual(Arrays.stream(method.getParameterTypes()) + .iterator(), + Arrays.stream(methodNode.getParameters()) + .map(parameter -> parameter.getType() + .getTypeClass()) + .iterator())) + .findFirst(); } public static Optional resolveMethodFromMethodInfo(MethodInfo methodInfo, ASTContext context) { - return Arrays.stream(methodInfo.getClassInfo().loadClass().getMethods()) - .filter(GroovySecurityManager.INSTANCE::isValid) - .filter(method -> method.getName().equals(methodInfo.getName()) && - method.getParameterTypes().length == methodInfo.getParameterInfo().length && - Iterators.elementsEqual(Arrays.stream(method.getParameterTypes()).iterator(), - Arrays.stream(methodInfo.getParameterInfo()).map(parameter -> context.getLanguageServerContext().getScanResult() - .loadClass(parameter.getTypeSignatureOrTypeDescriptor().toString(), true)).iterator())) - .findFirst(); + return Arrays.stream(methodInfo.getClassInfo().loadClass().getMethods()).filter(GroovySecurityManager.INSTANCE::isValid) + .filter(method -> method.getName().equals(methodInfo.getName()) && method + .getParameterTypes().length == methodInfo.getParameterInfo().length && Iterators.elementsEqual(Arrays.stream(method.getParameterTypes()) + .iterator(), + Arrays.stream(methodInfo.getParameterInfo()) + .map(parameter -> context.getLanguageServerContext() + .getScanResult() + .loadClass(parameter.getTypeSignatureOrTypeDescriptor() + .toString(), + true)) + .iterator())) + .findFirst(); } } diff --git a/src/main/java/net/prominic/groovyls/config/CompilationUnitFactory.java b/src/main/java/net/prominic/groovyls/config/CompilationUnitFactory.java index 02e380342..b4ce0da4d 100644 --- a/src/main/java/net/prominic/groovyls/config/CompilationUnitFactory.java +++ b/src/main/java/net/prominic/groovyls/config/CompilationUnitFactory.java @@ -19,13 +19,6 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls.config; -import com.cleanroommc.groovyscript.GroovyScript; -import net.prominic.groovyls.compiler.ILanguageServerContext; -import net.prominic.groovyls.compiler.control.GroovyLSCompilationUnit; -import net.prominic.groovyls.util.FileContentsTracker; -import org.codehaus.groovy.control.SourceUnit; -import org.jetbrains.annotations.Nullable; - import java.io.File; import java.io.IOException; import java.net.URI; @@ -36,6 +29,15 @@ import java.util.List; import java.util.Set; +import net.prominic.groovyls.compiler.ILanguageServerContext; +import net.prominic.groovyls.compiler.control.GroovyLSCompilationUnit; +import net.prominic.groovyls.util.FileContentsTracker; + +import org.codehaus.groovy.control.SourceUnit; +import org.jetbrains.annotations.Nullable; + +import com.cleanroommc.groovyscript.GroovyScript; + public class CompilationUnitFactory extends CompilationUnitFactoryBase { protected static final String FILE_EXTENSION_GROOVY = ".groovy"; @@ -94,9 +96,7 @@ public GroovyLSCompilationUnit create(Path workspaceRoot, @Nullable URI context) fileContentsTracker.getOpenURIs().forEach(uri -> { // if we're only tracking changes, skip all files that haven't // actually changed - if (urisToAdd != null && !urisToAdd.contains(uri)) { - return; - } + if (urisToAdd != null && !urisToAdd.contains(uri)) { return; } String contents = fileContentsTracker.getContents(uri); addOpenFileToCompilationUnit(uri, contents, compilationUnit); }); @@ -110,9 +110,7 @@ protected void addDirectoryToCompilationUnit(Path dirPath, GroovyLSCompilationUn try { if (Files.exists(dirPath)) { Files.walk(dirPath).forEach((filePath) -> { - if (!filePath.toString().endsWith(FILE_EXTENSION_GROOVY)) { - return; - } + if (!filePath.toString().endsWith(FILE_EXTENSION_GROOVY)) { return; } URI fileURI = filePath.toUri(); if (!fileContentsTracker.isOpen(fileURI)) { File file = filePath.toFile(); @@ -130,14 +128,10 @@ protected void addDirectoryToCompilationUnit(Path dirPath, GroovyLSCompilationUn } fileContentsTracker.getOpenURIs().forEach(uri -> { Path openPath = Paths.get(uri); - if (!openPath.normalize().startsWith(dirPath.normalize())) { - return; - } - if (changedUris != null && !changedUris.contains(uri)) { - return; - } + if (!openPath.normalize().startsWith(dirPath.normalize())) { return; } + if (changedUris != null && !changedUris.contains(uri)) { return; } String contents = fileContentsTracker.getContents(uri); addOpenFileToCompilationUnit(uri, contents, compilationUnit); }); } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/config/CompilationUnitFactoryBase.java b/src/main/java/net/prominic/groovyls/config/CompilationUnitFactoryBase.java index 5b76c4a32..bc6d41ae7 100644 --- a/src/main/java/net/prominic/groovyls/config/CompilationUnitFactoryBase.java +++ b/src/main/java/net/prominic/groovyls/config/CompilationUnitFactoryBase.java @@ -1,11 +1,5 @@ package net.prominic.groovyls.config; -import groovy.lang.GroovyClassLoader; -import net.prominic.groovyls.compiler.control.GroovyLSCompilationUnit; -import net.prominic.groovyls.compiler.control.io.StringReaderSourceWithURI; -import org.codehaus.groovy.control.CompilerConfiguration; -import org.codehaus.groovy.control.SourceUnit; - import java.io.File; import java.net.URI; import java.nio.file.Path; @@ -15,15 +9,21 @@ import java.util.List; import java.util.Map; +import net.prominic.groovyls.compiler.control.GroovyLSCompilationUnit; +import net.prominic.groovyls.compiler.control.io.StringReaderSourceWithURI; + +import org.codehaus.groovy.control.CompilerConfiguration; +import org.codehaus.groovy.control.SourceUnit; + +import groovy.lang.GroovyClassLoader; + public abstract class CompilationUnitFactoryBase implements ICompilationUnitFactory { protected CompilerConfiguration config; protected GroovyClassLoader classLoader; protected List additionalClasspathList; - public List getAdditionalClasspathList() { - return additionalClasspathList; - } + public List getAdditionalClasspathList() { return additionalClasspathList; } public void setAdditionalClasspathList(List additionalClasspathList) { this.additionalClasspathList = additionalClasspathList; @@ -54,9 +54,7 @@ protected CompilerConfiguration getConfiguration() { } protected void getClasspathList(List result) { - if (additionalClasspathList == null) { - return; - } + if (additionalClasspathList == null) { return; } for (String entry : additionalClasspathList) { boolean mustBeDirectory = false; @@ -86,8 +84,8 @@ protected void getClasspathList(List result) { protected void addOpenFileToCompilationUnit(URI uri, String contents, GroovyLSCompilationUnit compilationUnit) { Path filePath = Paths.get(uri); - SourceUnit sourceUnit = new SourceUnit(filePath.toString(), - new StringReaderSourceWithURI(contents, uri, compilationUnit.getConfiguration()), + SourceUnit sourceUnit = new SourceUnit(filePath.toString(), new StringReaderSourceWithURI(contents, uri, compilationUnit + .getConfiguration()), compilationUnit.getConfiguration(), compilationUnit.getClassLoader(), compilationUnit.getErrorCollector()); compilationUnit.addSource(sourceUnit); diff --git a/src/main/java/net/prominic/groovyls/config/ICompilationUnitFactory.java b/src/main/java/net/prominic/groovyls/config/ICompilationUnitFactory.java index 231be27bc..6a9525830 100644 --- a/src/main/java/net/prominic/groovyls/config/ICompilationUnitFactory.java +++ b/src/main/java/net/prominic/groovyls/config/ICompilationUnitFactory.java @@ -19,26 +19,28 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls.config; -import net.prominic.groovyls.compiler.control.GroovyLSCompilationUnit; -import org.jetbrains.annotations.Nullable; - import java.net.URI; import java.nio.file.Path; import java.util.List; +import net.prominic.groovyls.compiler.control.GroovyLSCompilationUnit; + +import org.jetbrains.annotations.Nullable; + public interface ICompilationUnitFactory { - /** - * If this factory would normally reuse an existing compilation unit, forces - * the creation of a new one. - */ - public void invalidateCompilationUnit(); - public List getAdditionalClasspathList(); + /** + * If this factory would normally reuse an existing compilation unit, forces + * the creation of a new one. + */ + public void invalidateCompilationUnit(); + + public List getAdditionalClasspathList(); - public void setAdditionalClasspathList(List classpathList); + public void setAdditionalClasspathList(List classpathList); - /** - * Returns a compilation unit. - */ + /** + * Returns a compilation unit. + */ GroovyLSCompilationUnit create(Path workspaceRoot, @Nullable URI context); -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/providers/CompletionProvider.java b/src/main/java/net/prominic/groovyls/providers/CompletionProvider.java index 9c6c0c275..ea8404920 100644 --- a/src/main/java/net/prominic/groovyls/providers/CompletionProvider.java +++ b/src/main/java/net/prominic/groovyls/providers/CompletionProvider.java @@ -19,19 +19,18 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls.providers; -import com.cleanroommc.groovyscript.mapper.ObjectMapper; -import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; -import com.cleanroommc.groovyscript.server.Completions; -import groovy.lang.Closure; -import groovy.lang.DelegatesTo; -import io.github.classgraph.*; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import java.net.URI; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; + import net.prominic.groovyls.compiler.ast.ASTContext; import net.prominic.groovyls.compiler.util.GroovyASTUtils; import net.prominic.groovyls.compiler.util.GroovyReflectionUtils; import net.prominic.groovyls.util.CompletionItemFactory; import net.prominic.groovyls.util.GroovyLanguageServerUtils; import net.prominic.groovyls.util.URIUtils; + import org.codehaus.groovy.ast.*; import org.codehaus.groovy.ast.expr.*; import org.codehaus.groovy.ast.stmt.BlockStatement; @@ -40,23 +39,28 @@ import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.jetbrains.annotations.NotNull; -import java.net.URI; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; +import com.cleanroommc.groovyscript.mapper.ObjectMapper; +import com.cleanroommc.groovyscript.mapper.ObjectMapperManager; +import com.cleanroommc.groovyscript.server.Completions; + +import groovy.lang.Closure; +import groovy.lang.DelegatesTo; +import io.github.classgraph.*; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; public class CompletionProvider { private final ASTContext astContext; - //private int maxItemCount = 1000; + // private int maxItemCount = 1000; private boolean isIncomplete = false; public CompletionProvider(ASTContext astContext) { this.astContext = astContext; } - public CompletableFuture, CompletionList>> provideCompletion( - TextDocumentIdentifier textDocument, Position position, CompletionContext context) { + public CompletableFuture, CompletionList>> provideCompletion(TextDocumentIdentifier textDocument, + Position position, + CompletionContext context) { URI uri = URIUtils.toUri(textDocument.getUri()); Completions items = new Completions(1000); @@ -71,9 +75,9 @@ public CompletableFuture, CompletionList>> provideCo private void populateKeywords(Completions items) { items.addAll(new String[]{"def", "assert", "if", "for", "else", "while", "switch", "case", "break", "continue", "return", - "transient", "import", "class", "extends", "implements", "enum", "try", "catch", "finally", "throw", "new", "in", "as", - "instanceof", "super", "this", "null", "true", "false", "void", "byte", "short", "int", "long", "float", "double", "boolean", - "private", "public", "protected"}, + "transient", "import", "class", "extends", "implements", "enum", "try", "catch", "finally", + "throw", "new", "in", "as", "instanceof", "super", "this", "null", "true", "false", "void", + "byte", "short", "int", "long", "float", "double", "boolean", "private", "public", "protected"}, s -> { var item = new CompletionItem(s); item.setKind(CompletionItemKind.Keyword); @@ -118,7 +122,8 @@ private boolean populateItemsFromNode(Position position, ASTNode offsetNode, Com private boolean populateItemsFromConstantExpression(ConstantExpression node, ASTNode parent, Completions items) { if (node.getType().getTypeClass() == String.class) { ASTNode parentParent = astContext.getVisitor().getParent(parent); - if (parentParent instanceof MethodCallExpression expr && expr.getArguments() instanceof ArgumentListExpression args && !args.getExpressions().isEmpty()) { + if (parentParent instanceof MethodCallExpression expr && expr.getArguments() instanceof ArgumentListExpression args && !args.getExpressions() + .isEmpty()) { ObjectMapper goh = GroovyASTUtils.getGohOfNode(expr, astContext); if (goh != null && goh.getCompleter() != null) { int index = -1; @@ -136,48 +141,44 @@ private boolean populateItemsFromConstantExpression(ConstantExpression node, AST return true; } - private void populateItemsFromStaticMethodCallExpression(StaticMethodCallExpression methodCallExpr, Position position, Completions items) { + private void populateItemsFromStaticMethodCallExpression(StaticMethodCallExpression methodCallExpr, Position position, + Completions items) { Set existingNames = new ObjectOpenHashSet<>(); populateItemsFromGlobalScope(methodCallExpr.getMethod(), existingNames, items); } - private static void populateItemsFromGameObjects(String memberNamePrefix, - Set existingNames, Completions items) { - ObjectMapperManager.getObjectMappers().stream() - .filter(handler -> { - if (handler.getName().startsWith(memberNamePrefix) && !existingNames.contains(handler.getName())) { - existingNames.add(handler.getName()); - return true; - } - return false; - }).forEach(handler -> { - for (Class[] paramTypes : handler.getParamTypes()) { - var completionItem = CompletionItemFactory.createCompletion(CompletionItemKind.Method, handler.getName()); - completionItem.setDetail("(global scope)"); - StringBuilder builder = new StringBuilder().append('('); - for (int i = 0; i < paramTypes.length; i++) { - var parameter = paramTypes[i]; - builder.append(parameter.getSimpleName()); - if (i < paramTypes.length - 1) { - builder.append(","); - } - } - builder.append(") -> "); - builder.append(handler.getReturnType().getSimpleName()); - CompletionItemLabelDetails details = new CompletionItemLabelDetails(); - details.setDetail(builder.toString()); - completionItem.setLabelDetails(details); - items.add(completionItem); + private static void populateItemsFromGameObjects(String memberNamePrefix, Set existingNames, Completions items) { + ObjectMapperManager.getObjectMappers().stream().filter(handler -> { + if (handler.getName().startsWith(memberNamePrefix) && !existingNames.contains(handler.getName())) { + existingNames.add(handler.getName()); + return true; + } + return false; + }).forEach(handler -> { + for (Class[] paramTypes : handler.getParamTypes()) { + var completionItem = CompletionItemFactory.createCompletion(CompletionItemKind.Method, handler.getName()); + completionItem.setDetail("(global scope)"); + StringBuilder builder = new StringBuilder().append('('); + for (int i = 0; i < paramTypes.length; i++) { + var parameter = paramTypes[i]; + builder.append(parameter.getSimpleName()); + if (i < paramTypes.length - 1) { + builder.append(","); } - }); + } + builder.append(") -> "); + builder.append(handler.getReturnType().getSimpleName()); + CompletionItemLabelDetails details = new CompletionItemLabelDetails(); + details.setDetail(builder.toString()); + completionItem.setLabelDetails(details); + items.add(completionItem); + } + }); } - private void populateItemsFromPropertyExpression(PropertyExpression propExpr, Position position, - Completions items) { + private void populateItemsFromPropertyExpression(PropertyExpression propExpr, Position position, Completions items) { Range propertyRange = GroovyLanguageServerUtils.astNodeToRange(propExpr.getProperty()); - if (propertyRange == null) { - return; - } + if (propertyRange == null) { return; } String memberName = getMemberName(propExpr.getPropertyAsString(), propertyRange, position); populateItemsFromExpression(propExpr.getObjectExpression(), memberName, items); } @@ -185,42 +186,33 @@ private void populateItemsFromPropertyExpression(PropertyExpression propExpr, Po private void populateItemsFromMethodCallExpression(MethodCallExpression methodCallExpr, Position position, Completions items) { Range methodRange = GroovyLanguageServerUtils.astNodeToRange(methodCallExpr.getMethod()); - if (methodRange == null) { - return; - } + if (methodRange == null) { return; } String memberName = getMemberName(methodCallExpr.getMethodAsString(), methodRange, position); populateItemsFromExpression(methodCallExpr.getObjectExpression(), memberName, items); } private void populateItemsFromImportNode(ImportNode importNode, Position position, Completions items) { Range importRange = GroovyLanguageServerUtils.astNodeToRange(importNode); - if (importRange == null) { - return; - } + if (importRange == null) { return; } // skip the "import " at the beginning - importRange.setStart(new Position(importRange.getEnd().getLine(), - importRange.getEnd().getCharacter() - importNode.getType().getName().length())); + importRange.setStart(new Position(importRange.getEnd().getLine(), importRange.getEnd().getCharacter() - importNode + .getType() + .getName() + .length())); String importText = getMemberName(importNode.getType().getName(), importRange, position); - ModuleNode enclosingModule = (ModuleNode) GroovyASTUtils.getEnclosingNodeOfType(importNode, ModuleNode.class, - astContext); + ModuleNode enclosingModule = (ModuleNode) GroovyASTUtils.getEnclosingNodeOfType(importNode, ModuleNode.class, astContext); String enclosingPackageName = enclosingModule.getPackageName(); - List importNames = enclosingModule.getImports().stream() - .map(ImportNode::getClassName).collect(Collectors.toList()); + List importNames = enclosingModule.getImports().stream().map(ImportNode::getClassName).collect(Collectors + .toList()); List localClassItems = astContext.getVisitor().getClassNodes().stream().filter(classNode -> { String packageName = classNode.getPackageName(); - if (packageName == null || packageName.length() == 0 || packageName.equals(enclosingPackageName)) { - return false; - } + if (packageName == null || packageName.length() == 0 || packageName.equals(enclosingPackageName)) { return false; } String className = classNode.getName(); String classNameWithoutPackage = classNode.getNameWithoutPackage(); - if (!className.startsWith(importText) && !classNameWithoutPackage.startsWith(importText)) { - return false; - } - if (importNames.contains(className)) { - return false; - } + if (!className.startsWith(importText) && !classNameWithoutPackage.startsWith(importText)) { return false; } + if (importNames.contains(className)) { return false; } return true; }).map(classNode -> { CompletionItem item = CompletionItemFactory.createCompletion(classNode, classNode.getName(), astContext); @@ -237,9 +229,7 @@ private void populateItemsFromImportNode(ImportNode importNode, Position positio List packageItems = packages.stream().filter(packageInfo -> { String packageName = packageInfo.getName(); - if (packageName.startsWith(importText)) { - return true; - } + if (packageName.startsWith(importText)) { return true; } return false; }).map(packageInfo -> { CompletionItem item = CompletionItemFactory.createCompletion(CompletionItemKind.Module, packageInfo.getName()); @@ -250,20 +240,15 @@ private void populateItemsFromImportNode(ImportNode importNode, Position positio List classItems = classes.stream().filter(classInfo -> { String packageName = classInfo.getPackageName(); - if (packageName == null || packageName.length() == 0 || packageName.equals(enclosingPackageName)) { - return false; - } + if (packageName == null || packageName.length() == 0 || packageName.equals(enclosingPackageName)) { return false; } String className = classInfo.getName(); String classNameWithoutPackage = classInfo.getSimpleName(); - if (!className.startsWith(importText) && !classNameWithoutPackage.startsWith(importText)) { - return false; - } - if (importNames.contains(className)) { - return false; - } + if (!className.startsWith(importText) && !classNameWithoutPackage.startsWith(importText)) { return false; } + if (importNames.contains(className)) { return false; } return true; }).map(classInfo -> { - CompletionItem item = CompletionItemFactory.createCompletion(classInfoToCompletionItemKind(classInfo), classInfo.getName()); + CompletionItem item = CompletionItemFactory.createCompletion(classInfoToCompletionItemKind(classInfo), classInfo + .getName()); item.setTextEdit(Either.forLeft(new TextEdit(importRange, classInfo.getName()))); if (classInfo.getSimpleName().startsWith(importText)) { @@ -276,14 +261,10 @@ private void populateItemsFromImportNode(ImportNode importNode, Position positio private void populateItemsFromClassNode(ClassNode classNode, Position position, Completions items) { ASTNode parentNode = astContext.getVisitor().getParent(classNode); - if (!(parentNode instanceof ClassNode)) { - return; - } + if (!(parentNode instanceof ClassNode)) { return; } ClassNode parentClassNode = (ClassNode) parentNode; Range classRange = GroovyLanguageServerUtils.astNodeToRange(classNode); - if (classRange == null) { - return; - } + if (classRange == null) { return; } String className = getMemberName(classNode.getUnresolvedName(), classRange, position); if (classNode.equals(parentClassNode.getUnresolvedSuperClass())) { populateTypes(classNode, className, new HashSet<>(), true, false, false, items); @@ -292,22 +273,17 @@ private void populateItemsFromClassNode(ClassNode classNode, Position position, } } - private void populateItemsFromConstructorCallExpression(ConstructorCallExpression constructorCallExpr, - Position position, Completions items) { + private void populateItemsFromConstructorCallExpression(ConstructorCallExpression constructorCallExpr, Position position, + Completions items) { Range typeRange = GroovyLanguageServerUtils.astNodeToRange(constructorCallExpr.getType()); - if (typeRange == null) { - return; - } + if (typeRange == null) { return; } String typeName = getMemberName(constructorCallExpr.getType().getNameWithoutPackage(), typeRange, position); populateTypes(constructorCallExpr, typeName, new HashSet<>(), true, false, false, items); } - private void populateItemsFromVariableExpression(VariableExpression varExpr, Position position, - Completions items) { + private void populateItemsFromVariableExpression(VariableExpression varExpr, Position position, Completions items) { Range varRange = GroovyLanguageServerUtils.astNodeToRange(varExpr); - if (varRange == null) { - return; - } + if (varRange == null) { return; } String memberName = getMemberName(varExpr.getName(), varRange, position); populateItemsFromScope(varExpr, memberName, items); } @@ -352,25 +328,25 @@ private void populateItemsFromPropertiesAndFields(List properties, private void populateItemsFromMethods(List methods, String memberNamePrefix, Set existingNames, Completions items) { - List methodItems = methods.stream() - .filter(method -> { - String methodName = method.getName(); - // overloads can cause duplicates - if (methodName.startsWith(memberNamePrefix) && !existingNames.contains(methodName)) { - existingNames.add(methodName); - return !method.getDeclaringClass().isResolved() || - (method.getModifiers() & GroovyASTUtils.EXPANSION_MARKER) != 0 || - GroovyReflectionUtils.resolveMethodFromMethodNode(method, astContext).isPresent(); - } - return false; - }).map(method -> { - CompletionItem item = CompletionItemFactory.createCompletion(method, method.getName(), astContext); + List methodItems = methods.stream().filter(method -> { + String methodName = method.getName(); + // overloads can cause duplicates + if (methodName.startsWith(memberNamePrefix) && !existingNames.contains(methodName)) { + existingNames.add(methodName); + return !method.getDeclaringClass().isResolved() || (method + .getModifiers() & GroovyASTUtils.EXPANSION_MARKER) != 0 || GroovyReflectionUtils.resolveMethodFromMethodNode(method, + astContext) + .isPresent(); + } + return false; + }).map(method -> { + CompletionItem item = CompletionItemFactory.createCompletion(method, method.getName(), astContext); - var details = getMethodNodeDetails(method); - item.setLabelDetails(details); + var details = getMethodNodeDetails(method); + item.setLabelDetails(details); - return item; - }).collect(Collectors.toList()); + return item; + }).collect(Collectors.toList()); items.addAll(methodItems); } @@ -421,7 +397,8 @@ private void populateItemsFromExpression(Expression leftSide, String memberNameP ClassNode classNode = GroovyASTUtils.getTypeOfNode(leftSide, astContext); if (classNode == null) return; GroovyASTUtils.fillClassNode(classNode); - List properties = GroovyASTUtils.getPropertiesForLeftSideOfPropertyExpression(classNode, leftSide, astContext); + List properties = GroovyASTUtils.getPropertiesForLeftSideOfPropertyExpression(classNode, leftSide, + astContext); List fields = GroovyASTUtils.getFieldsForLeftSideOfPropertyExpression(classNode, leftSide, astContext); populateItemsFromPropertiesAndFields(properties, fields, memberNamePrefix, existingNames, items); @@ -429,20 +406,17 @@ private void populateItemsFromExpression(Expression leftSide, String memberNameP populateItemsFromMethods(methods, memberNamePrefix, existingNames, items); } - private void populateItemsFromGlobalScope(String memberNamePrefix, - Set existingNames, List items) { + private void populateItemsFromGlobalScope(String memberNamePrefix, Set existingNames, List items) { astContext.getLanguageServerContext().getSandbox().getBindings().forEach((variableName, value) -> { - if (!variableName.startsWith(memberNamePrefix) || existingNames.contains(variableName)) { - return; - } + if (!variableName.startsWith(memberNamePrefix) || existingNames.contains(variableName)) { return; } existingNames.add(variableName); - if (value instanceof ObjectMapper goh) { + if (value instanceof ObjectMappergoh) { for (MethodNode method : goh.getMethodNodes()) { var item = CompletionItemFactory.createCompletion(method, goh.getName(), astContext); item.setLabelDetails(getMethodNodeDetails(method)); items.add(item); } - } else if (value instanceof Closure closure) { + } else if (value instanceof Closureclosure) { MethodNode method = GroovyASTUtils.methodNodeOfClosure(variableName, closure); var item = CompletionItemFactory.createCompletion(method, variableName, astContext); item.setLabelDetails(getMethodNodeDetails(method)); @@ -455,30 +429,35 @@ private void populateItemsFromGlobalScope(String memberNamePrefix, }); List staticMethodItems = astContext.getLanguageServerContext().getSandbox().getStaticImports().stream() - .map(staticImport -> astContext.getLanguageServerContext().getScanResult().getClassInfo(staticImport.getName())) - .filter(Objects::nonNull) - .flatMap(classInfo -> classInfo.getMethodInfo().stream().filter(ClassMemberInfo::isStatic)) - .filter(methodInfo -> { - String methodName = methodInfo.getName(); - if (methodName.startsWith(memberNamePrefix) && !existingNames.contains(methodName)) { - existingNames.add(methodName); - return GroovyReflectionUtils.resolveMethodFromMethodInfo(methodInfo, astContext).isPresent(); - } - return false; - }) - .map(methodInfo -> { - var item = CompletionItemFactory.createCompletion(CompletionItemKind.Method, methodInfo.getName()); - - var details = getMethodInfoDetails(methodInfo); - item.setLabelDetails(details); - return item; - }) - .collect(Collectors.toList()); + .map(staticImport -> astContext.getLanguageServerContext() + .getScanResult().getClassInfo( + staticImport.getName())) + .filter(Objects::nonNull).flatMap(classInfo -> classInfo + .getMethodInfo() + .stream() + .filter(ClassMemberInfo::isStatic)) + .filter(methodInfo -> { + String methodName = methodInfo.getName(); + if (methodName.startsWith(memberNamePrefix) && !existingNames.contains(methodName)) { + existingNames.add(methodName); + return GroovyReflectionUtils.resolveMethodFromMethodInfo(methodInfo, + astContext) + .isPresent(); + } + return false; + }).map(methodInfo -> { + var item = CompletionItemFactory.createCompletion(CompletionItemKind.Method, + methodInfo.getName()); + + var details = getMethodInfoDetails(methodInfo); + item.setLabelDetails(details); + return item; + }).collect(Collectors.toList()); items.addAll(staticMethodItems); } - private void populateItemsFromVariableScope(VariableScope variableScope, String memberNamePrefix, - Set existingNames, Completions items) { + private void populateItemsFromVariableScope(VariableScope variableScope, String memberNamePrefix, Set existingNames, + Completions items) { //populateItemsFromGameObjects(memberNamePrefix, existingNames, items); populateItemsFromGlobalScope(memberNamePrefix, existingNames, items); @@ -510,7 +489,8 @@ private void populateItemsFromScope(ASTNode node, String namePrefix, Completions int argIndex = -1; while (current != null) { if (current instanceof ClassNode classNode) { - populateItemsFromPropertiesAndFields(classNode.getProperties(), classNode.getFields(), namePrefix, existingNames, items); + populateItemsFromPropertiesAndFields(classNode.getProperties(), classNode.getFields(), namePrefix, existingNames, + items); populateItemsFromMethods(classNode.getMethods(), namePrefix, existingNames, items); } else if (current instanceof MethodNode methodNode) { populateItemsFromVariableScope(methodNode.getVariableScope(), namePrefix, existingNames, items); @@ -539,12 +519,12 @@ private void populateItemsFromScope(ASTNode node, String namePrefix, Completions if (valueExpr instanceof ConstantExpression ce) { try { classNode = ClassHelper.makeCached(Class.forName(ce.getText())); - } catch (ClassNotFoundException ignored) { - } + } catch (ClassNotFoundException ignored) {} } } if (classNode != null) { - populateItemsFromPropertiesAndFields(classNode.getProperties(), classNode.getFields(), namePrefix, existingNames, items); + populateItemsFromPropertiesAndFields(classNode.getProperties(), classNode.getFields(), namePrefix, + existingNames, items); populateItemsFromMethods(classNode.getMethods(), namePrefix, existingNames, items); } } @@ -561,8 +541,7 @@ private void populateItemsFromScope(ASTNode node, String namePrefix, Completions populateTypes(node, namePrefix, existingNames, items); } - private void populateTypes(ASTNode offsetNode, String namePrefix, Set existingNames, - Completions items) { + private void populateTypes(ASTNode offsetNode, String namePrefix, Set existingNames, Completions items) { populateTypes(offsetNode, namePrefix, existingNames, true, true, true, items); } @@ -570,11 +549,10 @@ private void populateTypes(ASTNode offsetNode, String namePrefix, Set ex boolean includeInterfaces, boolean includeEnums, Completions items) { Range addImportRange = GroovyASTUtils.findAddImportRange(offsetNode, astContext); - ModuleNode enclosingModule = (ModuleNode) GroovyASTUtils.getEnclosingNodeOfType(offsetNode, ModuleNode.class, - astContext); + ModuleNode enclosingModule = (ModuleNode) GroovyASTUtils.getEnclosingNodeOfType(offsetNode, ModuleNode.class, astContext); String enclosingPackageName = enclosingModule.getPackageName(); - List importNames = enclosingModule.getImports().stream().map(importNode -> importNode.getClassName()) - .collect(Collectors.toList()); + List importNames = enclosingModule.getImports().stream().map(importNode -> importNode.getClassName()).collect( + Collectors.toList()); List localClassItems = astContext.getVisitor().getClassNodes().stream().filter(classNode -> { if (items.reachedLimit()) return false; @@ -588,7 +566,8 @@ private void populateTypes(ASTNode offsetNode, String namePrefix, Set ex }).map(classNode -> { String className = classNode.getName(); String packageName = classNode.getPackageName(); - CompletionItem item = CompletionItemFactory.createCompletion(classNode, classNode.getNameWithoutPackage(), astContext); + CompletionItem item = CompletionItemFactory.createCompletion(classNode, classNode.getNameWithoutPackage(), + astContext); item.setDetail(packageName); if (packageName != null && !packageName.equals(enclosingPackageName) && !importNames.contains(className)) { List additionalTextEdits = new ArrayList<>(); @@ -614,7 +593,8 @@ private void populateTypes(ASTNode offsetNode, String namePrefix, Set ex }).map(classInfo -> { String className = classInfo.getName(); String packageName = classInfo.getPackageName(); - CompletionItem item = CompletionItemFactory.createCompletion(classInfoToCompletionItemKind(classInfo), classInfo.getSimpleName()); + CompletionItem item = CompletionItemFactory.createCompletion(classInfoToCompletionItemKind(classInfo), classInfo + .getSimpleName()); item.setDetail(packageName); if (packageName != null && !packageName.equals(enclosingPackageName) && !importNames.contains(className)) { List additionalTextEdits = new ArrayList<>(); @@ -628,23 +608,16 @@ private void populateTypes(ASTNode offsetNode, String namePrefix, Set ex } private String getMemberName(String memberName, Range range, Position position) { - if (position.getLine() == range.getStart().getLine() - && position.getCharacter() > range.getStart().getCharacter()) { + if (position.getLine() == range.getStart().getLine() && position.getCharacter() > range.getStart().getCharacter()) { int length = position.getCharacter() - range.getStart().getCharacter(); - if (length > 0 && length <= memberName.length()) { - return memberName.substring(0, length).trim(); - } + if (length > 0 && length <= memberName.length()) { return memberName.substring(0, length).trim(); } } return ""; } private CompletionItemKind classInfoToCompletionItemKind(ClassInfo classInfo) { - if (classInfo.isInterface()) { - return CompletionItemKind.Interface; - } - if (classInfo.isEnum()) { - return CompletionItemKind.Enum; - } + if (classInfo.isInterface()) { return CompletionItemKind.Interface; } + if (classInfo.isEnum()) { return CompletionItemKind.Enum; } return CompletionItemKind.Class; } @@ -658,4 +631,4 @@ private TextEdit createAddImportTextEdit(String className, Range range) { edit.setRange(range); return edit; } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/providers/DefinitionProvider.java b/src/main/java/net/prominic/groovyls/providers/DefinitionProvider.java index fc4d4e701..35856c6fc 100644 --- a/src/main/java/net/prominic/groovyls/providers/DefinitionProvider.java +++ b/src/main/java/net/prominic/groovyls/providers/DefinitionProvider.java @@ -25,7 +25,10 @@ import java.util.concurrent.CompletableFuture; import net.prominic.groovyls.compiler.ast.ASTContext; +import net.prominic.groovyls.compiler.util.GroovyASTUtils; +import net.prominic.groovyls.util.GroovyLanguageServerUtils; import net.prominic.groovyls.util.URIUtils; + import org.codehaus.groovy.ast.ASTNode; import org.eclipse.lsp4j.Location; import org.eclipse.lsp4j.LocationLink; @@ -33,10 +36,6 @@ import org.eclipse.lsp4j.TextDocumentIdentifier; import org.eclipse.lsp4j.jsonrpc.messages.Either; -import net.prominic.groovyls.compiler.ast.ASTNodeVisitor; -import net.prominic.groovyls.compiler.util.GroovyASTUtils; -import net.prominic.groovyls.util.GroovyLanguageServerUtils; - public class DefinitionProvider { private final ASTContext astContext; @@ -45,13 +44,11 @@ public DefinitionProvider(ASTContext astContext) { this.astContext = astContext; } - public CompletableFuture, List>> provideDefinition( - TextDocumentIdentifier textDocument, Position position) { + public CompletableFuture, List>> provideDefinition(TextDocumentIdentifier textDocument, + Position position) { URI uri = URIUtils.toUri(textDocument.getUri()); ASTNode offsetNode = astContext.getVisitor().getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter()); - if (offsetNode == null) { - return CompletableFuture.completedFuture(Either.forLeft(Collections.emptyList())); - } + if (offsetNode == null) { return CompletableFuture.completedFuture(Either.forLeft(Collections.emptyList())); } ASTNode definitionNode = GroovyASTUtils.getDefinition(offsetNode, true, astContext); if (definitionNode == null || definitionNode.getLineNumber() == -1 || definitionNode.getColumnNumber() == -1) { @@ -64,10 +61,8 @@ public CompletableFuture, List>> provideDocumentSymbols( - TextDocumentIdentifier textDocument) { + public CompletableFuture>> provideDocumentSymbols(TextDocumentIdentifier textDocument) { URI uri = URIUtils.toUri(textDocument.getUri()); List nodes = astContext.getVisitor().getNodes(uri); List> symbols = nodes.stream().filter(node -> { - return node instanceof ClassNode || node instanceof MethodNode || node instanceof FieldNode - || node instanceof PropertyNode; + return node instanceof ClassNode || node instanceof MethodNode || node instanceof FieldNode || node instanceof PropertyNode; }).map(node -> { if (node instanceof ClassNode) { ClassNode classNode = (ClassNode) node; @@ -74,4 +73,4 @@ public CompletableFuture>> provid }).collect(Collectors.toList()); return CompletableFuture.completedFuture(symbols); } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/providers/HoverProvider.java b/src/main/java/net/prominic/groovyls/providers/HoverProvider.java index 1f145ea97..517a336a0 100644 --- a/src/main/java/net/prominic/groovyls/providers/HoverProvider.java +++ b/src/main/java/net/prominic/groovyls/providers/HoverProvider.java @@ -19,16 +19,18 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls.providers; -import com.cleanroommc.groovyscript.GroovyScript; +import java.net.URI; +import java.util.concurrent.CompletableFuture; + import net.prominic.groovyls.compiler.ast.ASTContext; import net.prominic.groovyls.compiler.util.GroovyASTUtils; import net.prominic.groovyls.util.GroovyNodeToStringUtils; import net.prominic.groovyls.util.URIUtils; + import org.codehaus.groovy.ast.*; import org.eclipse.lsp4j.*; -import java.net.URI; -import java.util.concurrent.CompletableFuture; +import com.cleanroommc.groovyscript.GroovyScript; public class HoverProvider { @@ -41,23 +43,18 @@ public HoverProvider(ASTContext astContext) { public CompletableFuture provideHover(TextDocumentIdentifier textDocument, Position position) { URI uri = URIUtils.toUri(textDocument.getUri()); ASTNode offsetNode = astContext.getVisitor().getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter()); - if (offsetNode == null) { - return CompletableFuture.completedFuture(null); - } + if (offsetNode == null) { return CompletableFuture.completedFuture(null); } ASTNode definitionNode = GroovyASTUtils.getDefinition(offsetNode, false, astContext); - if (definitionNode == null) { - return CompletableFuture.completedFuture(null); - } + if (definitionNode == null) { return CompletableFuture.completedFuture(null); } String content = getContent(definitionNode); - if (content == null) { - return CompletableFuture.completedFuture(null); - } + if (content == null) { return CompletableFuture.completedFuture(null); } String documentation = null; if (definitionNode instanceof AnnotatedNode annotatedNode) { - documentation = astContext.getLanguageServerContext().getDocumentationFactory().getDocumentation(annotatedNode, astContext); + documentation = astContext.getLanguageServerContext().getDocumentationFactory().getDocumentation(annotatedNode, + astContext); } StringBuilder contentsBuilder = new StringBuilder(); @@ -92,4 +89,4 @@ private String getContent(ASTNode hoverNode) { } return null; } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/providers/ReferenceProvider.java b/src/main/java/net/prominic/groovyls/providers/ReferenceProvider.java index dd79f132e..c2c55f05b 100644 --- a/src/main/java/net/prominic/groovyls/providers/ReferenceProvider.java +++ b/src/main/java/net/prominic/groovyls/providers/ReferenceProvider.java @@ -26,16 +26,15 @@ import java.util.stream.Collectors; import net.prominic.groovyls.compiler.ast.ASTContext; +import net.prominic.groovyls.compiler.util.GroovyASTUtils; +import net.prominic.groovyls.util.GroovyLanguageServerUtils; import net.prominic.groovyls.util.URIUtils; + import org.codehaus.groovy.ast.ASTNode; import org.eclipse.lsp4j.Location; import org.eclipse.lsp4j.Position; import org.eclipse.lsp4j.TextDocumentIdentifier; -import net.prominic.groovyls.compiler.ast.ASTNodeVisitor; -import net.prominic.groovyls.compiler.util.GroovyASTUtils; -import net.prominic.groovyls.util.GroovyLanguageServerUtils; - public class ReferenceProvider { private final ASTContext astContext; @@ -44,13 +43,11 @@ public ReferenceProvider(ASTContext astContext) { this.astContext = astContext; } - public CompletableFuture> provideReferences(TextDocumentIdentifier textDocument, - Position position) { + public CompletableFuture> provideReferences(TextDocumentIdentifier textDocument, Position position) { URI documentURI = URIUtils.toUri(textDocument.getUri()); - ASTNode offsetNode = astContext.getVisitor().getNodeAtLineAndColumn(documentURI, position.getLine(), position.getCharacter()); - if (offsetNode == null) { - return CompletableFuture.completedFuture(Collections.emptyList()); - } + ASTNode offsetNode = astContext.getVisitor().getNodeAtLineAndColumn(documentURI, position.getLine(), position + .getCharacter()); + if (offsetNode == null) { return CompletableFuture.completedFuture(Collections.emptyList()); } List references = GroovyASTUtils.getReferences(offsetNode, astContext); List locations = references.stream().map(node -> { @@ -60,4 +57,4 @@ public CompletableFuture> provideReferences(TextDocumen return CompletableFuture.completedFuture(locations); } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/providers/RenameProvider.java b/src/main/java/net/prominic/groovyls/providers/RenameProvider.java index b97c644a6..4048c09f7 100644 --- a/src/main/java/net/prominic/groovyls/providers/RenameProvider.java +++ b/src/main/java/net/prominic/groovyls/providers/RenameProvider.java @@ -29,7 +29,12 @@ import java.util.regex.Pattern; import net.prominic.groovyls.compiler.ast.ASTContext; +import net.prominic.groovyls.compiler.util.GroovyASTUtils; +import net.prominic.groovyls.util.FileContentsTracker; +import net.prominic.groovyls.util.GroovyLanguageServerUtils; import net.prominic.groovyls.util.URIUtils; +import net.prominic.lsp.utils.Ranges; + import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.MethodNode; @@ -48,12 +53,6 @@ import org.eclipse.lsp4j.WorkspaceEdit; import org.eclipse.lsp4j.jsonrpc.messages.Either; -import net.prominic.groovyls.compiler.ast.ASTNodeVisitor; -import net.prominic.groovyls.compiler.util.GroovyASTUtils; -import net.prominic.groovyls.util.FileContentsTracker; -import net.prominic.groovyls.util.GroovyLanguageServerUtils; -import net.prominic.lsp.utils.Ranges; - public class RenameProvider { private final ASTContext astContext; @@ -74,10 +73,9 @@ public CompletableFuture provideRename(RenameParams renameParams) WorkspaceEdit workspaceEdit = new WorkspaceEdit(documentChanges); URI documentURI = URIUtils.toUri(textDocument.getUri()); - ASTNode offsetNode = astContext.getVisitor().getNodeAtLineAndColumn(documentURI, position.getLine(), position.getCharacter()); - if (offsetNode == null) { - return CompletableFuture.completedFuture(workspaceEdit); - } + ASTNode offsetNode = astContext.getVisitor().getNodeAtLineAndColumn(documentURI, position.getLine(), position + .getCharacter()); + if (offsetNode == null) { return CompletableFuture.completedFuture(workspaceEdit); } List references = GroovyASTUtils.getReferences(offsetNode, astContext); references.forEach(node -> { @@ -127,9 +125,7 @@ public CompletableFuture provideRename(RenameParams renameParams) textEdit.setNewText(newName); textEdit.setRange(range); } - if (textEdit == null) { - return; - } + if (textEdit == null) { return; } if (!textEditChanges.containsKey(uri.toString())) { textEditChanges.put(uri.toString(), new ArrayList<>()); @@ -151,13 +147,9 @@ public CompletableFuture provideRename(RenameParams renameParams) private String getPartialNodeText(URI uri, ASTNode node) { Range range = GroovyLanguageServerUtils.astNodeToRange(node); - if (range == null) { - return null; - } + if (range == null) { return null; } String contents = files.getContents(uri); - if (contents == null) { - return null; - } + if (contents == null) { return null; } return Ranges.getSubstring(contents, range, 1); } @@ -211,8 +203,7 @@ private TextEdit createTextEditToRenameMethodNode(MethodNode methodNode, String return textEdit; } - private TextEdit createTextEditToRenamePropertyNode(PropertyNode propNode, String newName, String text, - Range range) { + private TextEdit createTextEditToRenamePropertyNode(PropertyNode propNode, String newName, String text, Range range) { // the AST doesn't give us access to the name location, so we // need to find it manually Pattern propPattern = Pattern.compile("\\b" + propNode.getName() + "\\b"); @@ -232,4 +223,4 @@ private TextEdit createTextEditToRenamePropertyNode(PropertyNode propNode, Strin textEdit.setNewText(newName); return textEdit; } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/providers/SignatureHelpProvider.java b/src/main/java/net/prominic/groovyls/providers/SignatureHelpProvider.java index 50df7b35e..87731ba7c 100644 --- a/src/main/java/net/prominic/groovyls/providers/SignatureHelpProvider.java +++ b/src/main/java/net/prominic/groovyls/providers/SignatureHelpProvider.java @@ -19,11 +19,18 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls.providers; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.CompletableFuture; + import net.prominic.groovyls.compiler.ast.ASTContext; import net.prominic.groovyls.compiler.util.GroovyASTUtils; import net.prominic.groovyls.util.GroovyLanguageServerUtils; import net.prominic.groovyls.util.GroovyNodeToStringUtils; import net.prominic.groovyls.util.URIUtils; + import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.MethodNode; import org.codehaus.groovy.ast.Parameter; @@ -32,12 +39,6 @@ import org.codehaus.groovy.ast.expr.MethodCall; import org.eclipse.lsp4j.*; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.CompletableFuture; - public class SignatureHelpProvider { private final ASTContext astContext; @@ -46,13 +47,10 @@ public SignatureHelpProvider(ASTContext astContext) { this.astContext = astContext; } - public CompletableFuture provideSignatureHelp(TextDocumentIdentifier textDocument, - Position position) { + public CompletableFuture provideSignatureHelp(TextDocumentIdentifier textDocument, Position position) { URI uri = URIUtils.toUri(textDocument.getUri()); ASTNode offsetNode = astContext.getVisitor().getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter()); - if (offsetNode == null) { - return CompletableFuture.completedFuture(new SignatureHelp(Collections.emptyList(), -1, -1)); - } + if (offsetNode == null) { return CompletableFuture.completedFuture(new SignatureHelp(Collections.emptyList(), -1, -1)); } int activeParamIndex = -1; MethodCall methodCall = null; ASTNode parentNode = astContext.getVisitor().getParent(offsetNode); @@ -65,14 +63,10 @@ public CompletableFuture provideSignatureHelp(TextDocumentIdentif activeParamIndex = getActiveParameter(position, expressions); } - if (methodCall == null) { - return CompletableFuture.completedFuture(new SignatureHelp(Collections.emptyList(), -1, -1)); - } + if (methodCall == null) { return CompletableFuture.completedFuture(new SignatureHelp(Collections.emptyList(), -1, -1)); } List methods = GroovyASTUtils.getMethodOverloadsFromCallExpression(methodCall, astContext); - if (methods.isEmpty()) { - return CompletableFuture.completedFuture(new SignatureHelp(Collections.emptyList(), -1, -1)); - } + if (methods.isEmpty()) { return CompletableFuture.completedFuture(new SignatureHelp(Collections.emptyList(), -1, -1)); } List sigInfos = new ArrayList<>(); for (MethodNode method : methods) { @@ -87,7 +81,8 @@ public CompletableFuture provideSignatureHelp(TextDocumentIdentif SignatureInformation sigInfo = new SignatureInformation(); sigInfo.setLabel(GroovyNodeToStringUtils.methodToString(method, astContext)); sigInfo.setParameters(parameters); - String markdownDocs = astContext.getLanguageServerContext().getDocumentationFactory().getDocumentation(method, astContext); + String markdownDocs = astContext.getLanguageServerContext().getDocumentationFactory().getDocumentation(method, + astContext); if (markdownDocs != null) { sigInfo.setDocumentation(new MarkupContent(MarkupKind.MARKDOWN, markdownDocs)); @@ -108,14 +103,12 @@ private int getActiveParameter(Position position, List expressions) if (exprRange == null) { continue; } - if (position.getLine() < exprRange.getEnd().getLine()) { - return i; - } - if (position.getLine() == exprRange.getEnd().getLine() - && position.getCharacter() <= exprRange.getEnd().getCharacter()) { + if (position.getLine() < exprRange.getEnd().getLine()) { return i; } + if (position.getLine() == exprRange.getEnd().getLine() && position.getCharacter() <= exprRange.getEnd() + .getCharacter()) { return i; } } return expressions.size(); } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/providers/TypeDefinitionProvider.java b/src/main/java/net/prominic/groovyls/providers/TypeDefinitionProvider.java index 032172721..d781ca61d 100644 --- a/src/main/java/net/prominic/groovyls/providers/TypeDefinitionProvider.java +++ b/src/main/java/net/prominic/groovyls/providers/TypeDefinitionProvider.java @@ -25,7 +25,10 @@ import java.util.concurrent.CompletableFuture; import net.prominic.groovyls.compiler.ast.ASTContext; +import net.prominic.groovyls.compiler.util.GroovyASTUtils; +import net.prominic.groovyls.util.GroovyLanguageServerUtils; import net.prominic.groovyls.util.URIUtils; + import org.codehaus.groovy.ast.ASTNode; import org.eclipse.lsp4j.Location; import org.eclipse.lsp4j.LocationLink; @@ -33,10 +36,6 @@ import org.eclipse.lsp4j.TextDocumentIdentifier; import org.eclipse.lsp4j.jsonrpc.messages.Either; -import net.prominic.groovyls.compiler.ast.ASTNodeVisitor; -import net.prominic.groovyls.compiler.util.GroovyASTUtils; -import net.prominic.groovyls.util.GroovyLanguageServerUtils; - public class TypeDefinitionProvider { private final ASTContext astContext; @@ -45,13 +44,11 @@ public TypeDefinitionProvider(ASTContext astContext) { this.astContext = astContext; } - public CompletableFuture, List>> provideTypeDefinition( - TextDocumentIdentifier textDocument, Position position) { + public CompletableFuture, List>> provideTypeDefinition(TextDocumentIdentifier textDocument, + Position position) { URI uri = URIUtils.toUri(textDocument.getUri()); ASTNode offsetNode = astContext.getVisitor().getNodeAtLineAndColumn(uri, position.getLine(), position.getCharacter()); - if (offsetNode == null) { - return CompletableFuture.completedFuture(Either.forLeft(Collections.emptyList())); - } + if (offsetNode == null) { return CompletableFuture.completedFuture(Either.forLeft(Collections.emptyList())); } ASTNode definitionNode = GroovyASTUtils.getTypeDefinition(offsetNode, astContext); if (definitionNode == null || definitionNode.getLineNumber() == -1 || definitionNode.getColumnNumber() == -1) { @@ -64,10 +61,8 @@ public CompletableFuture, List> provideWorkspaceSymb PropertyNode propNode = (PropertyNode) node; name = propNode.getName(); } - if (name == null) { - return false; - } + if (name == null) { return false; } return name.toLowerCase().contains(lowerCaseQuery); }).map(node -> { URI uri = astContext.getVisitor().getURI(node); @@ -91,4 +87,4 @@ public CompletableFuture> provideWorkspaceSymb }).filter(symbolInformation -> symbolInformation != null).collect(Collectors.toList()); return CompletableFuture.completedFuture(symbols); } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/util/ClassGraphUtils.java b/src/main/java/net/prominic/groovyls/util/ClassGraphUtils.java index 2bf453960..b9540df63 100644 --- a/src/main/java/net/prominic/groovyls/util/ClassGraphUtils.java +++ b/src/main/java/net/prominic/groovyls/util/ClassGraphUtils.java @@ -1,17 +1,18 @@ package net.prominic.groovyls.util; -import io.github.classgraph.ClassInfo; import net.prominic.groovyls.compiler.ast.ASTContext; + import org.codehaus.groovy.ast.ClassNode; import org.jetbrains.annotations.Nullable; +import io.github.classgraph.ClassInfo; + public class ClassGraphUtils { public static @Nullable ClassInfo resolveAllowedClassInfo(ClassNode node, ASTContext context) { ClassInfo result = null; while (result == null) { - if (node.equals(new ClassNode(Object.class))) - return null; + if (node.equals(new ClassNode(Object.class))) return null; result = context.getLanguageServerContext().getScanResult().getClassInfo(node.getName()); for (ClassNode anInterface : node.getInterfaces()) { result = context.getLanguageServerContext().getScanResult().getClassInfo(anInterface.getName()); diff --git a/src/main/java/net/prominic/groovyls/util/CompletionItemFactory.java b/src/main/java/net/prominic/groovyls/util/CompletionItemFactory.java index faa827d90..699b55423 100644 --- a/src/main/java/net/prominic/groovyls/util/CompletionItemFactory.java +++ b/src/main/java/net/prominic/groovyls/util/CompletionItemFactory.java @@ -1,6 +1,7 @@ package net.prominic.groovyls.util; import net.prominic.groovyls.compiler.ast.ASTContext; + import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.AnnotatedNode; import org.eclipse.lsp4j.*; @@ -11,7 +12,8 @@ public static CompletionItem createCompletion(ASTNode node, String label, ASTCon var completionItem = createCompletion(GroovyLanguageServerUtils.astNodeToCompletionItemKind(node), label); if (node instanceof AnnotatedNode annotatedNode) { - var documentation = astContext.getLanguageServerContext().getDocumentationFactory().getDocumentation(annotatedNode, astContext); + var documentation = astContext.getLanguageServerContext().getDocumentationFactory().getDocumentation(annotatedNode, + astContext); if (documentation != null) { completionItem.setDocumentation(new MarkupContent(MarkupKind.MARKDOWN, documentation)); diff --git a/src/main/java/net/prominic/groovyls/util/FileContentsTracker.java b/src/main/java/net/prominic/groovyls/util/FileContentsTracker.java index 2c9fad625..33c4cbc10 100644 --- a/src/main/java/net/prominic/groovyls/util/FileContentsTracker.java +++ b/src/main/java/net/prominic/groovyls/util/FileContentsTracker.java @@ -19,9 +19,6 @@ //////////////////////////////////////////////////////////////////////////////// package net.prominic.groovyls.util; -import net.prominic.lsp.utils.Positions; -import org.eclipse.lsp4j.*; - import java.io.BufferedReader; import java.io.IOException; import java.net.URI; @@ -32,18 +29,18 @@ import java.util.Map; import java.util.Set; +import net.prominic.lsp.utils.Positions; + +import org.eclipse.lsp4j.*; + public class FileContentsTracker { private Map openFiles = new HashMap<>(); private Set changedFiles = new HashSet<>(); - public Set getOpenURIs() { - return openFiles.keySet(); - } + public Set getOpenURIs() { return openFiles.keySet(); } - public Set getChangedURIs() { - return changedFiles; - } + public Set getChangedURIs() { return changedFiles; } public void resetChangedFiles() { changedFiles = new HashSet<>(); @@ -105,8 +102,7 @@ public String getContents(URI uri) { if (reader != null) { try { reader.close(); - } catch (IOException e) { - } + } catch (IOException e) {} } } } @@ -116,4 +112,4 @@ public String getContents(URI uri) { public void setContents(URI uri, String contents) { openFiles.put(uri, contents); } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/groovyls/util/GroovyLanguageServerUtils.java b/src/main/java/net/prominic/groovyls/util/GroovyLanguageServerUtils.java index a0e2aed85..d75491518 100644 --- a/src/main/java/net/prominic/groovyls/util/GroovyLanguageServerUtils.java +++ b/src/main/java/net/prominic/groovyls/util/GroovyLanguageServerUtils.java @@ -36,136 +36,112 @@ import org.eclipse.lsp4j.SymbolKind; public class GroovyLanguageServerUtils { - /** - * Converts a Groovy position to a LSP position. - * - * May return null if the Groovy line is -1 - */ - public static Position createGroovyPosition(int groovyLine, int groovyColumn) { - if (groovyLine == -1) { - return null; - } - if (groovyColumn == -1) { - groovyColumn = 0; - } - int lspLine = groovyLine; - if (lspLine > 0) { - lspLine--; - } - int lspColumn = groovyColumn; - if (lspColumn > 0) { - lspColumn--; - } - return new Position(lspLine, lspColumn); - } - public static Range syntaxExceptionToRange(SyntaxException exception) { - return new Range(createGroovyPosition(exception.getStartLine(), exception.getStartColumn()), - createGroovyPosition(exception.getEndLine(), exception.getEndColumn())); - } + /** + * Converts a Groovy position to a LSP position. + * May return null if the Groovy line is -1 + */ + public static Position createGroovyPosition(int groovyLine, int groovyColumn) { + if (groovyLine == -1) { return null; } + if (groovyColumn == -1) { + groovyColumn = 0; + } + int lspLine = groovyLine; + if (lspLine > 0) { + lspLine--; + } + int lspColumn = groovyColumn; + if (lspColumn > 0) { + lspColumn--; + } + return new Position(lspLine, lspColumn); + } - /** - * Converts a Groovy AST node to an LSP range. - * - * May return null if the node's start line is -1 - */ - public static Range astNodeToRange(ASTNode node) { - Position start = createGroovyPosition(node.getLineNumber(), node.getColumnNumber()); - if (start == null) { - return null; - } - Position end = createGroovyPosition(node.getLastLineNumber(), node.getLastColumnNumber()); - if (end == null) { - end = start; - } - return new Range(start, end); - } + public static Range syntaxExceptionToRange(SyntaxException exception) { + return new Range(createGroovyPosition(exception.getStartLine(), exception.getStartColumn()), createGroovyPosition( + exception.getEndLine(), + exception.getEndColumn())); + } - public static CompletionItemKind astNodeToCompletionItemKind(ASTNode node) { - if (node instanceof ClassNode) { - ClassNode classNode = (ClassNode) node; - if (classNode.isInterface()) { - return CompletionItemKind.Interface; - } else if (classNode.isEnum()) { - return CompletionItemKind.Enum; - } - return CompletionItemKind.Class; - } else if (node instanceof MethodNode) { - return CompletionItemKind.Method; - } else if (node instanceof Variable) { - if (node instanceof FieldNode || node instanceof PropertyNode) { - return CompletionItemKind.Field; - } - return CompletionItemKind.Variable; - } - return CompletionItemKind.Property; - } + /** + * Converts a Groovy AST node to an LSP range. + * May return null if the node's start line is -1 + */ + public static Range astNodeToRange(ASTNode node) { + Position start = createGroovyPosition(node.getLineNumber(), node.getColumnNumber()); + if (start == null) { return null; } + Position end = createGroovyPosition(node.getLastLineNumber(), node.getLastColumnNumber()); + if (end == null) { + end = start; + } + return new Range(start, end); + } - public static SymbolKind astNodeToSymbolKind(ASTNode node) { - if (node instanceof ClassNode) { - ClassNode classNode = (ClassNode) node; - if (classNode.isInterface()) { - return SymbolKind.Interface; - } else if (classNode.isEnum()) { - return SymbolKind.Enum; - } - return SymbolKind.Class; - } else if (node instanceof MethodNode) { - return SymbolKind.Method; - } else if (node instanceof Variable) { - if (node instanceof FieldNode || node instanceof PropertyNode) { - return SymbolKind.Field; - } - return SymbolKind.Variable; - } - return SymbolKind.Property; - } + public static CompletionItemKind astNodeToCompletionItemKind(ASTNode node) { + if (node instanceof ClassNode) { + ClassNode classNode = (ClassNode) node; + if (classNode.isInterface()) { + return CompletionItemKind.Interface; + } else if (classNode.isEnum()) { return CompletionItemKind.Enum; } + return CompletionItemKind.Class; + } else if (node instanceof MethodNode) { + return CompletionItemKind.Method; + } else if (node instanceof Variable) { + if (node instanceof FieldNode || node instanceof PropertyNode) { return CompletionItemKind.Field; } + return CompletionItemKind.Variable; + } + return CompletionItemKind.Property; + } - /** - * Converts a Groovy AST node to an LSP location. - * - * May return null if the node's start line is -1 - */ - public static Location astNodeToLocation(ASTNode node, URI uri) { - Range range = astNodeToRange(node); - if (range == null) { - return null; - } - return new Location(uri.toString(), range); - } + public static SymbolKind astNodeToSymbolKind(ASTNode node) { + if (node instanceof ClassNode) { + ClassNode classNode = (ClassNode) node; + if (classNode.isInterface()) { + return SymbolKind.Interface; + } else if (classNode.isEnum()) { return SymbolKind.Enum; } + return SymbolKind.Class; + } else if (node instanceof MethodNode) { + return SymbolKind.Method; + } else if (node instanceof Variable) { + if (node instanceof FieldNode || node instanceof PropertyNode) { return SymbolKind.Field; } + return SymbolKind.Variable; + } + return SymbolKind.Property; + } - public static SymbolInformation astNodeToSymbolInformation(ClassNode node, URI uri, String parentName) { - Location location = astNodeToLocation(node, uri); - if (location == null) { - return null; - } - SymbolKind symbolKind = astNodeToSymbolKind(node); - return new SymbolInformation(node.getName(), symbolKind, location, - parentName); - } + /** + * Converts a Groovy AST node to an LSP location. + * May return null if the node's start line is -1 + */ + public static Location astNodeToLocation(ASTNode node, URI uri) { + Range range = astNodeToRange(node); + if (range == null) { return null; } + return new Location(uri.toString(), range); + } - public static SymbolInformation astNodeToSymbolInformation(MethodNode node, URI uri, String parentName) { - Location location = astNodeToLocation(node, uri); - if (location == null) { - return null; - } - SymbolKind symbolKind = astNodeToSymbolKind(node); - return new SymbolInformation(node.getName(), symbolKind, location, - parentName); - } + public static SymbolInformation astNodeToSymbolInformation(ClassNode node, URI uri, String parentName) { + Location location = astNodeToLocation(node, uri); + if (location == null) { return null; } + SymbolKind symbolKind = astNodeToSymbolKind(node); + return new SymbolInformation(node.getName(), symbolKind, location, parentName); + } - public static SymbolInformation astNodeToSymbolInformation(Variable node, URI uri, String parentName) { - if (!(node instanceof ASTNode)) { - // DynamicVariable isn't an ASTNode - return null; - } - ASTNode astVar = (ASTNode) node; - Location location = astNodeToLocation(astVar, uri); - if (location == null) { - return null; - } - SymbolKind symbolKind = astNodeToSymbolKind(astVar); - return new SymbolInformation(node.getName(), symbolKind, location, - parentName); - } -} \ No newline at end of file + public static SymbolInformation astNodeToSymbolInformation(MethodNode node, URI uri, String parentName) { + Location location = astNodeToLocation(node, uri); + if (location == null) { return null; } + SymbolKind symbolKind = astNodeToSymbolKind(node); + return new SymbolInformation(node.getName(), symbolKind, location, parentName); + } + + public static SymbolInformation astNodeToSymbolInformation(Variable node, URI uri, String parentName) { + if (!(node instanceof ASTNode)) { + // DynamicVariable isn't an ASTNode + return null; + } + ASTNode astVar = (ASTNode) node; + Location location = astNodeToLocation(astVar, uri); + if (location == null) { return null; } + SymbolKind symbolKind = astNodeToSymbolKind(astVar); + return new SymbolInformation(node.getName(), symbolKind, location, parentName); + } +} diff --git a/src/main/java/net/prominic/groovyls/util/GroovyNodeToStringUtils.java b/src/main/java/net/prominic/groovyls/util/GroovyNodeToStringUtils.java index 498a5d82d..6b0dcbf2c 100644 --- a/src/main/java/net/prominic/groovyls/util/GroovyNodeToStringUtils.java +++ b/src/main/java/net/prominic/groovyls/util/GroovyNodeToStringUtils.java @@ -20,6 +20,8 @@ package net.prominic.groovyls.util; import net.prominic.groovyls.compiler.ast.ASTContext; +import net.prominic.groovyls.compiler.util.GroovyASTUtils; + import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.ConstructorNode; @@ -28,9 +30,6 @@ import org.codehaus.groovy.ast.Parameter; import org.codehaus.groovy.ast.Variable; -import net.prominic.groovyls.compiler.ast.ASTNodeVisitor; -import net.prominic.groovyls.compiler.util.GroovyASTUtils; - public class GroovyNodeToStringUtils { private static final String JAVA_OBJECT = "java.lang.Object"; @@ -81,9 +80,7 @@ public static String constructorToString(ConstructorNode constructorNode, ASTCon } public static String methodToString(MethodNode methodNode, ASTContext astContext) { - if (methodNode instanceof ConstructorNode) { - return constructorToString((ConstructorNode) methodNode, astContext); - } + if (methodNode instanceof ConstructorNode) { return constructorToString((ConstructorNode) methodNode, astContext); } StringBuilder builder = new StringBuilder(); if (methodNode.isPublic()) { if (!methodNode.isSyntheticPublic()) { @@ -157,4 +154,4 @@ public static String variableToString(Variable variable, ASTContext astContext) builder.append(variable.getName()); return builder.toString(); } -} \ No newline at end of file +} diff --git a/src/main/java/net/prominic/lsp/utils/Positions.java b/src/main/java/net/prominic/lsp/utils/Positions.java index b9716e6fc..0510c22c9 100644 --- a/src/main/java/net/prominic/lsp/utils/Positions.java +++ b/src/main/java/net/prominic/lsp/utils/Positions.java @@ -27,46 +27,42 @@ import org.eclipse.lsp4j.Position; public class Positions { - public static final Comparator COMPARATOR = (Position p1, Position p2) -> { - if (p1.getLine() != p2.getLine()) { - return p1.getLine() - p2.getLine(); - } - return p1.getCharacter() - p2.getCharacter(); - }; - public static boolean valid(Position p) { - return p.getLine() >= 0 || p.getCharacter() >= 0; - } + public static final Comparator COMPARATOR = (Position p1, Position p2) -> { + if (p1.getLine() != p2.getLine()) { return p1.getLine() - p2.getLine(); } + return p1.getCharacter() - p2.getCharacter(); + }; - public static int getOffset(String string, Position position) { - int line = position.getLine(); - int character = position.getCharacter(); - int currentIndex = 0; - if (line > 0) { - BufferedReader reader = new BufferedReader(new StringReader(string)); - try { - int readLines = 0; - while (true) { - char currentChar = (char) reader.read(); - if (currentChar == -1) { - return -1; - } - currentIndex++; - if (currentChar == '\n') { - readLines++; - if (readLines == line) { - break; - } - } - } - } catch (IOException e) { - return -1; - } - try { - reader.close(); - } catch (IOException e) { - } - } - return currentIndex + character; - } -} \ No newline at end of file + public static boolean valid(Position p) { + return p.getLine() >= 0 || p.getCharacter() >= 0; + } + + public static int getOffset(String string, Position position) { + int line = position.getLine(); + int character = position.getCharacter(); + int currentIndex = 0; + if (line > 0) { + BufferedReader reader = new BufferedReader(new StringReader(string)); + try { + int readLines = 0; + while (true) { + char currentChar = (char) reader.read(); + if (currentChar == -1) { return -1; } + currentIndex++; + if (currentChar == '\n') { + readLines++; + if (readLines == line) { + break; + } + } + } + } catch (IOException e) { + return -1; + } + try { + reader.close(); + } catch (IOException e) {} + } + return currentIndex + character; + } +} diff --git a/src/main/java/net/prominic/lsp/utils/Ranges.java b/src/main/java/net/prominic/lsp/utils/Ranges.java index 69854748d..a91730842 100644 --- a/src/main/java/net/prominic/lsp/utils/Ranges.java +++ b/src/main/java/net/prominic/lsp/utils/Ranges.java @@ -27,66 +27,66 @@ import org.eclipse.lsp4j.Range; public class Ranges { - public static boolean contains(Range range, Position position) { - return Positions.COMPARATOR.compare(position, range.getStart()) >= 0 - && Positions.COMPARATOR.compare(position, range.getEnd()) <= 0; - } - public static boolean intersect(Range r1, Range r2) { - return contains(r1, r2.getStart()) || contains(r1, r2.getEnd()); - } + public static boolean contains(Range range, Position position) { + return Positions.COMPARATOR.compare(position, range.getStart()) >= 0 && Positions.COMPARATOR.compare(position, range + .getEnd()) <= 0; + } - public static String getSubstring(String string, Range range) { - return getSubstring(string, range, 0); - } + public static boolean intersect(Range r1, Range r2) { + return contains(r1, r2.getStart()) || contains(r1, r2.getEnd()); + } - public static String getSubstring(String string, Range range, int maxLines) { - BufferedReader reader = new BufferedReader(new StringReader(string)); - StringBuilder builder = new StringBuilder(); - Position start = range.getStart(); - Position end = range.getEnd(); - int startLine = start.getLine(); - int startChar = start.getCharacter(); - int endLine = end.getLine(); - int endChar = end.getCharacter(); - int lineCount = 1 + (endLine - startLine); - if (maxLines > 0 && lineCount > maxLines) { - endLine = startLine + maxLines - 1; - endChar = 0; - } - try { - for (int i = 0; i < startLine; i++) { - // ignore these lines - reader.readLine(); - } - for (int i = 0; i < startChar; i++) { - // ignore these characters - reader.read(); - } - int endCharStart = startChar; - int maxLineBreaks = endLine - startLine; - if (maxLineBreaks > 0) { - endCharStart = 0; - int readLines = 0; - while (readLines < maxLineBreaks) { - char character = (char) reader.read(); - if (character == '\n') { - readLines++; - } - builder.append(character); - } - } - // the remaining characters on the final line - for (int i = endCharStart; i < endChar; i++) { - builder.append((char) reader.read()); - } - } catch (IOException e) { - return null; - } - try { - reader.close(); - } catch (IOException e) { - } - return builder.toString(); - } -} \ No newline at end of file + public static String getSubstring(String string, Range range) { + return getSubstring(string, range, 0); + } + + public static String getSubstring(String string, Range range, int maxLines) { + BufferedReader reader = new BufferedReader(new StringReader(string)); + StringBuilder builder = new StringBuilder(); + Position start = range.getStart(); + Position end = range.getEnd(); + int startLine = start.getLine(); + int startChar = start.getCharacter(); + int endLine = end.getLine(); + int endChar = end.getCharacter(); + int lineCount = 1 + (endLine - startLine); + if (maxLines > 0 && lineCount > maxLines) { + endLine = startLine + maxLines - 1; + endChar = 0; + } + try { + for (int i = 0; i < startLine; i++) { + // ignore these lines + reader.readLine(); + } + for (int i = 0; i < startChar; i++) { + // ignore these characters + reader.read(); + } + int endCharStart = startChar; + int maxLineBreaks = endLine - startLine; + if (maxLineBreaks > 0) { + endCharStart = 0; + int readLines = 0; + while (readLines < maxLineBreaks) { + char character = (char) reader.read(); + if (character == '\n') { + readLines++; + } + builder.append(character); + } + } + // the remaining characters on the final line + for (int i = endCharStart; i < endChar; i++) { + builder.append((char) reader.read()); + } + } catch (IOException e) { + return null; + } + try { + reader.close(); + } catch (IOException e) {} + return builder.toString(); + } +}