Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"variants": {
"normal": {
"model": "placeholdername:dragon_egg"
"model": "groovyscriptdev:dragon_egg"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"normal": {
"model": "groovyscriptdev:dragon_egg_lamp"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"normal": {
"model": "groovyscriptdev:generic_block"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "block/dragon_egg",
"textures": {
"all": "placeholdername:blocks/dragon_egg_lamp"
"all": "groovyscriptdev:blocks/dragon_egg_lamp"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "placeholdername:blocks/generic_block"
"all": "groovyscriptdev:blocks/generic_block"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "placeholdername:items/clay_2"
"layer0": "groovyscriptdev:items/clay_2"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "placeholdername:items/clay_3"
"layer0": "groovyscriptdev:items/clay_3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "groovyscriptdev:block/dragon_egg_lamp"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "groovyscriptdev:block/generic_block"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "groovyscriptdev:items/heartofauniverse"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "placeholdername:items/prodigy_stick"
"layer0": "groovyscriptdev:items/prodigy_stick"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "placeholdername:items/snack"
"layer0": "groovyscriptdev:items/snack"
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

25 changes: 25 additions & 0 deletions examples/postInit/betterwithaddons.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,31 @@ mods.betterwithaddons.lure_tree.recipeBuilder()

mods.betterwithaddons.lure_tree.addBlacklist(entity('minecraft:chicken'))

// Packing:
// Converts an input itemstack in the form of a EntityItems into an IBlockState after a piston extends if the piston and
// location the EntityItems are in are fully surrounded by solid blocks.

mods.betterwithaddons.packing.removeByInput(item('minecraft:clay_ball'))
mods.betterwithaddons.packing.removeByOutput(blockstate('minecraft:gravel'))
// mods.betterwithaddons.packing.removeAll()

mods.betterwithaddons.packing.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.compress(blockstate('minecraft:clay'))
.register()

mods.betterwithaddons.packing.recipeBuilder()
.input(item('minecraft:clay') * 10)
.compress(blockstate('minecraft:diamond_block'))
.register()

mods.betterwithaddons.packing.recipeBuilder()
.input(item('minecraft:diamond'))
.compress(blockstate('minecraft:dirt'))
.jeiOutput(item('minecraft:diamond') * 64)
.register()


// Rotting Food:
// Converts an input item into an output itemstack after the given time has passed. Has the ability to customize the
// terminology used to indicate the age.
Expand Down
1 change: 0 additions & 1 deletion examples/postInit/thebetweenlands.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,3 @@ mods.thebetweenlands.steeping_pot.recipeBuilder()


mods.thebetweenlands.steeping_pot.addAcceptedItem(item('minecraft:gold_block'))

15 changes: 8 additions & 7 deletions examples/runConfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"packName": "PlaceHolder name",
"packId": "placeholdername",
"packName": "GroovyScript Dev",
"packId": "groovyscriptdev",
"version": "1.0.0",
"debug": true,
"classes": [
"classes/"
],
"loaders": {
"preInit": [
"classes/",
"preInit/"
],
"init": [],
"init": [
"init/"
],
"postInit": [
"postInit/"
"postInit/",
"recipes/"
]
},
"packmode": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ 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(), "\nlog.info('Hello World!')\n".getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE, StandardOpenOption.WRITE);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public GSCommand() {
}));

addSubcommand(new SimpleCommand("deleteScriptCache", (server, sender, args) -> {
if (GroovyScript.getSandbox().deleteScriptCache()) {
if (GroovyScript.getSandbox().getEngine().deleteScriptCache()) {
sender.sendMessage(new TextComponentString("Deleted groovy script cache").setStyle(StyleConstant.getSuccessStyle()));
} else {
sender.sendMessage(new TextComponentString("An error occurred while deleting groovy script cache").setStyle(StyleConstant.getErrorStyle()));
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public static LoadStage getLoadStage() {
}

public static boolean isReloading() {
return getLoadStage().isReloadable() && !ReloadableRegistryManager.isFirstLoad();
LoadStage loadStage = getLoadStage();
return loadStage != null && loadStage.isReloadable() && !ReloadableRegistryManager.isFirstLoad();
}

public static String getMinecraftVersion() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.cleanroommc.groovyscript.sandbox;

import com.cleanroommc.groovyscript.api.GroovyLog;
import groovy.lang.GroovyClassLoader;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.codehaus.groovy.runtime.InvokerHelper;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Map;

class CompiledClass {

Expand All @@ -29,12 +32,13 @@ public void onCompile(byte[] data, Class<?> clazz, String basePath) {

public void onCompile(Class<?> clazz, String basePath) {
this.clazz = clazz;
this.name = clazz.getName();
if (!this.name.equals(clazz.getName())) throw new IllegalArgumentException();
//this.name = clazz.getName();
if (this.data == null) {
GroovyLog.get().errorMC("The class doesnt seem to be compiled yet. (" + name + ")");
return;
}
if (!GroovyScriptSandbox.ENABLE_CACHE) return;
if (!CustomGroovyScriptEngine.ENABLE_CACHE) return;
try {
File file = getDataFile(basePath);
file.getParentFile().mkdirs();
Expand All @@ -47,14 +51,15 @@ public void onCompile(Class<?> clazz, String basePath) {
}
}

protected void ensureLoaded(CachedClassLoader classLoader, String basePath) {
protected void ensureLoaded(GroovyClassLoader classLoader, Map<String, CompiledClass> cache, String basePath) {
if (this.clazz == null) {
this.clazz = classLoader.defineClass(this.name, this.data);
cache.put(this.name, this);
}
}

public boolean readData(String basePath) {
if (this.data != null && GroovyScriptSandbox.ENABLE_CACHE) return true;
if (this.data != null && CustomGroovyScriptEngine.ENABLE_CACHE) return true;
File file = getDataFile(basePath);
if (!file.exists()) return false;
try {
Expand All @@ -71,6 +76,11 @@ public void deleteCache(String cachePath) {
} catch (IOException e) {
throw new RuntimeException(e);
}
if (this.clazz != null) {
InvokerHelper.removeClass(this.clazz);
this.clazz = null;
}
this.data = null;
}

protected File getDataFile(String basePath) {
Expand Down
Loading