Skip to content

Commit

Permalink
better snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 committed Mar 13, 2024
1 parent 5e03fc1 commit b5fb5c5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
45 changes: 40 additions & 5 deletions editors/vscode/snippets/groovyscript.snippets.json
Original file line number Diff line number Diff line change
@@ -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]))"
]
}
}
4 changes: 1 addition & 3 deletions src/main/java/com/cleanroommc/groovyscript/GroovyScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<>();
}

Expand Down

0 comments on commit b5fb5c5

Please sign in to comment.