From b5fb5c5efbb0d81561bb174694dfa85190728180 Mon Sep 17 00:00:00 2001 From: brachy84 Date: Wed, 13 Mar 2024 20:29:02 +0100 Subject: [PATCH] better snippets --- .../snippets/groovyscript.snippets.json | 45 ++++++++++++++++--- .../groovyscript/GroovyScript.java | 4 +- .../sandbox/GroovyScriptSandbox.java | 4 +- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/editors/vscode/snippets/groovyscript.snippets.json b/editors/vscode/snippets/groovyscript.snippets.json index ca250f30b..12fb83626 100644 --- a/editors/vscode/snippets/groovyscript.snippets.json +++ b/editors/vscode/snippets/groovyscript.snippets.json @@ -1,19 +1,54 @@ { - "Check is mod loaded": { + "Check is mod loaded preprocessor": { + "scope": "groovy", "prefix": "is mod loaded", "description": "Check if the mod is loaded", "body": [ - "if (!isLoaded('${1:modname}')) return", - "println 'mod \\'${1:modname}\\' detected, running script'" + "// MODS_LOADED: ${1:modname}" + ] + }, + "Check for Packmode": { + "scope": "groovy", + "prefix": "is packmode", + "description": "Check if the mod is loaded", + "body": [ + "// PACKMODE: ${1:packmode}" + ] + }, + "SideOnly annotation": { + "scope": "groovy", + "prefix": "client only", + "description": "@SideOnly(Side.CLIENT)", + "body": [ + "@SideOnly(Side.CLIENT)" ] }, "Listen for event": { + "scope": "groovy", "prefix": "listen forge event", "description": "Listen for a forge event", "body": [ - "eventManager.listen { ${1:eventtype} event ->", - "", + "event_manager.listen { ${1:eventtype} event ->", + "\t$2", "}" ] + }, + "Shaped crafting recipe": { + "scope": "groovy", + "prefix": "shaped crafting", + "description": "Create a shaped crafting recipe", + "body": [ + "crafting.addShaped('${1:recipe_name}', item('${2:output}', [", + "\t[$3]", + "])" + ] + }, + "Shapeless crafting recipe": { + "scope": "groovy", + "prefix": "shapeless crafting", + "description": "Create a shapeless crafting recipe", + "body": [ + "crafting.addShapeless('${1:recipe_name}', item('${2:output}', [$3]))" + ] } } \ No newline at end of file diff --git a/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java b/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java index 128123b2e..339a4b1f1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java +++ b/src/main/java/com/cleanroommc/groovyscript/GroovyScript.java @@ -8,8 +8,8 @@ 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.linkgenerator.LinkGeneratorHooks; import com.cleanroommc.groovyscript.documentation.Documentation; +import com.cleanroommc.groovyscript.documentation.linkgenerator.LinkGeneratorHooks; import com.cleanroommc.groovyscript.event.EventHandler; import com.cleanroommc.groovyscript.gameobjects.GameObjectHandlerManager; import com.cleanroommc.groovyscript.helper.JsonHelper; @@ -54,8 +54,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.relauncher.FMLLaunchHandler; -import net.prominic.groovyls.GroovyLanguageServer; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.ApiStatus; diff --git a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java index 8e47cbd8b..6ec677178 100644 --- a/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java +++ b/src/main/java/com/cleanroommc/groovyscript/sandbox/GroovyScriptSandbox.java @@ -72,7 +72,9 @@ public GroovyScriptSandbox(URL... scriptEnvironment) { "net.minecraft.util.EnumFacing", "net.minecraft.util.ResourceLocation", "net.minecraftforge.fml.common.eventhandler.EventPriority", - "com.cleanroommc.groovyscript.event.EventBusType"); + "com.cleanroommc.groovyscript.event.EventBusType", + "net.minecraftforge.fml.relauncher.Side", + "net.minecraftforge.fml.relauncher.SideOnly"); this.storedExceptions = new Object2ObjectOpenHashMap<>(); }