Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into avaritia
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 committed Aug 2, 2023
2 parents 46e7045 + dfa568c commit 41920e0
Show file tree
Hide file tree
Showing 15 changed files with 188 additions and 91 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/TestBuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will build and upload test artifact
# Simple workflow with ignoring condition to prevent unneccessary build
# To download artifact check on job task

name: Build Test Artifact

on:
push:
paths-ignore:
- '.github/workflows/build.yml' # Release GHA file, please change this when you change the file name
- 'LICENSE'
- 'README.md'
workflow_dispatch:

jobs:
build:
name: Build and Upload Artifact
runs-on: ubuntu-latest

steps:
- name: Checkout branch
uses: actions/checkout@v2

# https://github.com/madhead/read-java-properties#error-java_home-is-set-to-an-invalid-directory
- name: Gather Gradle properties
uses: madhead/read-java-properties@latest
id: gradle_properties
with:
file: gradle.properties
all: true

- name: Retrieve SHA short
id: vars
shell: bash
run: echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Change mod version
run: sed -i "s/mod_version.*=.*/mod_version = ${{ steps.gradle_properties.outputs.mod_version }}-${{ steps.vars.outputs.SHA_SHORT }}/g" gradle.properties

- name: Set up Temurin JDK 8
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
cache: gradle # Only cache stuff since test build action happen mostly

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build

- name: Upload Build Artifacts
uses: actions/[email protected]
with:
name: GroovyScript-${{ steps.gradle_properties.outputs.mod_version }}
path: build/libs
8 changes: 8 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ jobs:
tinkers-construct | recommends | *
tinkers-complement | recommends | *
constructs-armory | recommends | *
had-enough-items | recommends | *
actually-additions | recommends | *
botania | recommends | *
chisel | recommends | *
evilcraft | recommends | *
extended-crafting | recommends | *
forestry | recommends | *
roots | recommends | *
java: |
8
retry-attempts: 2
7 changes: 2 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ repositories {
}

dependencies {
implementation 'zone.rong:mixinbooter:7.1'
compileOnly 'org.jetbrains:annotations:24.0.1'
implementation 'zone.rong:mixinbooter:8.3'

String mixin = modUtils.enableMixins('org.spongepowered:mixin:0.8.3')

api (mixin) {
transitive = false
}
Expand All @@ -102,8 +102,6 @@ dependencies {
transitive = false
}

compileOnly 'org.jetbrains:annotations:23.0.0'

embed "org.apache.groovy:groovy:${project.groovy_version}"

implementation 'mezz.jei:jei_1.12.2:4.16.1.302'
Expand Down Expand Up @@ -270,7 +268,6 @@ dependencies {
runtimeOnly rfg.deobf('net.sengir.forestry:forestry_1.12.2:5.8.2.422')
runtimeOnly rfg.deobf('curse.maven:jei-bees-248370:2490058')
}

}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
org.gradle.jvmargs = -Xmx3G

# Mod Information
mod_version = 0.5.0
mod_version = 0.5.2
release_type = beta
maven_group = com.cleanroommc
archives_base_name = groovyscript
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/com/cleanroommc/groovyscript/GroovyScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,19 @@ public static void initializeGroovyPreInit() {
Loader.instance().setActiveModContainer(Loader.instance().getIndexedModList().get(ID));
}

long time = System.currentTimeMillis();
getSandbox().run(LoadStage.PRE_INIT);
LOGGER.info("Running early Groovy scripts took " + (System.currentTimeMillis() - time) + " ms");
runGroovyScriptsInLoader(LoadStage.PRE_INIT);

if (wasNull) {
Loader.instance().setActiveModContainer(null);
}
}

@ApiStatus.Internal
public static void initializeGroovyPostInit() {
public static void runGroovyScriptsInLoader(LoadStage loadStage) {
// called via mixin between fml post init and load complete
long time = System.currentTimeMillis();
getSandbox().run(LoadStage.POST_INIT);
LOGGER.info("Running Groovy scripts took " + (System.currentTimeMillis() - time) + " ms");
getSandbox().run(loadStage);
LOGGER.info("Running Groovy scripts during {} took {} ms", loadStage.getName(), System.currentTimeMillis() - time);
}

@Mod.EventHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public RecipeBuilder input(IBlockState blockstate) {

@Override
public String getErrorMsg() {
return "Error adding Roots Pyre recipe";
return "Error adding Roots Bark Carving recipe";
}

public String getRecipeNamePrefix() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public RecipeBuilder generate() {

@Override
public String getErrorMsg() {
return "Error adding Roots Pyre recipe";
return "Error adding Roots Mortar recipe";
}

public String getRecipeNamePrefix() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void validate(GroovyLog.Msg msg) {
PyreCraftingRecipe recipe = new PyreCraftingRecipe(output.get(0), xp);
input.forEach(i -> recipe.addIngredient(i.toMcIngredient()));
recipe.setBurnTime(this.burnTime);
recipe.setRegistryName(name);
recipe.setName(name.toString());
ModSupport.ROOTS.get().pyre.add(name, recipe);
return recipe;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@

public class Roots extends ModPropertyContainer {

AnimalHarvest animalHarvest = new AnimalHarvest();
AnimalHarvestFish animalHarvestFish = new AnimalHarvestFish();
BarkCarving barkCarving = new BarkCarving();
Chrysopoeia chrysopoeia = new Chrysopoeia();
FeyCrafter feyCrafter = new FeyCrafter();
FlowerGeneration flowerGeneration = new FlowerGeneration();
LifeEssence lifeEssence = new LifeEssence();
Modifiers modifiers = new Modifiers();
Moss moss = new Moss();
Mortar mortar = new Mortar();
Pacifist pacifist = new Pacifist();
Predicates predicates = new Predicates();
Pyre pyre = new Pyre();
Rituals rituals = new Rituals();
RunicShearBlock runicShearBlock = new RunicShearBlock();
RunicShearEntity runicShearEntity = new RunicShearEntity();
Spells spells = new Spells();
SummonCreature summonCreature = new SummonCreature();
Transmutation transmutation = new Transmutation();
public final AnimalHarvest animalHarvest = new AnimalHarvest();
public final AnimalHarvestFish animalHarvestFish = new AnimalHarvestFish();
public final BarkCarving barkCarving = new BarkCarving();
public final Chrysopoeia chrysopoeia = new Chrysopoeia();
public final FeyCrafter feyCrafter = new FeyCrafter();
public final FlowerGeneration flowerGeneration = new FlowerGeneration();
public final LifeEssence lifeEssence = new LifeEssence();
public final Modifiers modifiers = new Modifiers();
public final Moss moss = new Moss();
public final Mortar mortar = new Mortar();
public final Pacifist pacifist = new Pacifist();
public final Predicates predicates = new Predicates();
public final Pyre pyre = new Pyre();
public final Rituals rituals = new Rituals();
public final RunicShearBlock runicShearBlock = new RunicShearBlock();
public final RunicShearEntity runicShearEntity = new RunicShearEntity();
public final Spells spells = new Spells();
public final SummonCreature summonCreature = new SummonCreature();
public final Transmutation transmutation = new Transmutation();


public Roots() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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;
Expand All @@ -16,8 +17,11 @@ public void preInit(LoaderState state, Object[] eventData, CallbackInfo ci) {
if (state == LoaderState.PREINITIALIZATION) {
GroovyScript.initializeGroovyPreInit();
}
if (state == LoaderState.POSTINITIALIZATION) {
GroovyScript.runGroovyScriptsInLoader(LoadStage.INIT);
}
if (state == LoaderState.AVAILABLE) {
GroovyScript.initializeGroovyPostInit();
GroovyScript.runGroovyScriptsInLoader(LoadStage.POST_INIT);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ public static File getConfigDir() {
}

public static boolean isClient() {
return FMLCommonHandler.instance().getSide().isClient();
return FMLCommonHandler.instance().getEffectiveSide().isClient();
}

public static boolean isServer() {
return FMLCommonHandler.instance().getEffectiveSide().isServer();
}

public static boolean isDedicatedServer() {
return FMLCommonHandler.instance().getSide().isServer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,12 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

public class GroovyScriptSandbox extends GroovySandbox {

private static final String[] DEFAULT_IMPORTS = {
"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"
};
private final ImportCustomizer importCustomizer = new ImportCustomizer();

private LoadStage currentLoadStage;
private boolean checkSyntaxMode = false;
Expand All @@ -72,6 +41,35 @@ public GroovyScriptSandbox(URL... scriptEnvironment) {
registerBinding("EventManager", GroovyEventManager.INSTANCE);
registerBinding("eventManager", GroovyEventManager.INSTANCE);
registerBinding("event_manager", GroovyEventManager.INSTANCE);
this.importCustomizer.addStaticStars(GroovyHelper.class.getName(), MathHelper.class.getName());
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");
}

public void checkSyntax() {
Expand Down Expand Up @@ -137,10 +135,7 @@ protected void postInitBindings(Binding binding) {
@Override
protected void initEngine(GroovyScriptEngine engine, CompilerConfiguration config) {
config.addCompilationCustomizers(GroovyScriptCompiler.transformer());
ImportCustomizer importCustomizer = new ImportCustomizer();
importCustomizer.addStaticStars(GroovyHelper.class.getName(), MathHelper.class.getName());
importCustomizer.addImports(DEFAULT_IMPORTS);
config.addCompilationCustomizers(importCustomizer);
config.addCompilationCustomizers(this.importCustomizer);
}

@Override
Expand Down Expand Up @@ -179,7 +174,7 @@ protected void postRun() {

@Override
public Collection<File> getClassFiles() {
return GroovyScript.getRunConfig().getClassFiles();
return GroovyScript.getRunConfig().getClassFiles(this.currentLoadStage.getName());
}

@Override
Expand All @@ -191,4 +186,8 @@ public Collection<File> getScriptFiles() {
public LoadStage getCurrentLoader() {
return currentLoadStage;
}

public ImportCustomizer getImportCustomizer() {
return importCustomizer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static List<LoadStage> getLoadStages() {
}

public static final LoadStage PRE_INIT = new LoadStage("preInit", false, -1000000);
public static final LoadStage INIT = new LoadStage("init", false, -1000);
public static final LoadStage POST_INIT = new LoadStage("postInit", true, 0);

private final String name;
Expand Down
Loading

0 comments on commit 41920e0

Please sign in to comment.