Skip to content

Commit

Permalink
Merge branch 'master' into goh-enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 authored May 8, 2024
2 parents 6ea6614 + 9f793ff commit 5fc020a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/postInit/mekanism.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mods.mekanism.infusion.removeByType(infusion('carbon'))
// mods.mekanism.infusion.removeByType(infusion('diamond'))
// mods.mekanism.infusion.removeAll()

mods.mekanism.infusion.addType('groovy_example', resource('placeholdername:blocks/example'))
mods.mekanism.infusion.addType('groovy_example', resource('placeholdername:blocks/mekanism_infusion_texture'))
mods.mekanism.infusion.add(infusion('diamond'), 100, item('minecraft:clay'))
mods.mekanism.infusion.add(infusion('carbon'), 100, item('minecraft:gold_ingot'))
mods.mekanism.infusion.add('groovy_example', 10, item('minecraft:ice'))
Expand Down
2 changes: 1 addition & 1 deletion examples/preInit/mekanism.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import net.minecraftforge.client.event.TextureStitchEvent
if (!isLoaded('mekanism')) return
println 'mod \'mekanism\' detected, running script'

eventManager.listen { TextureStitchEvent.Pre event ->
eventManager.listen(TextureStitchEvent.Pre) { event ->
event.getMap().registerSprite(resource('placeholdername:blocks/mekanism_infusion_texture'))
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ modGroup = com.cleanroommc.groovyscript
# Version of your mod.
# This field can be left empty if you want your mod's version to be determined by the latest git tag instead.
modVersion = 1.0.1
groovy_version = 4.0.13
groovy_version = 4.0.21
debug_use_examples_folder = true
debug_run_ls = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void onReload() {
objectStorage.removeScripted().forEach(pair -> InfuseRegistry.getObjectMap().remove(pair.getKey()));
}

@MethodDescription(example = @Example("'groovy_example', resource('placeholdername:blocks/example')"), 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class ThermalExpansion extends ModPropertyContainer {

@Override
public void initialize() {
GameObjectHandler.builder("mode", CompactorManager.Mode.class)
GameObjectHandler.builder("compactorMode", CompactorManager.Mode.class)
.mod("thermalexpansion")
.parser(IGameObjectParser.wrapEnum(CompactorManager.Mode.class, false))
.completerOfNamed(() -> Arrays.asList(CompactorManager.Mode.values()), v -> v.name().toUpperCase(Locale.ROOT))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import org.codehaus.groovy.ast.Parameter;
import org.codehaus.groovy.ast.*;
import org.codehaus.groovy.ast.expr.ConstantExpression;
import org.codehaus.groovy.ast.stmt.ReturnStatement;
import org.codehaus.groovy.vmplugin.v8.Java8;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
Expand All @@ -28,13 +30,6 @@ public abstract class Java8Mixin {
@Shadow
protected abstract ClassNode[] makeClassNodes(CompileUnit cu, Type[] types, Class<?>[] cls);

@Shadow
private static void setMethodDefaultValue(MethodNode mn, Method m) {
}

@Shadow
protected abstract GenericsType[] configureTypeVariable(TypeVariable<?>[] tvs);

@Shadow
protected abstract Annotation[][] getConstructorParameterAnnotations(Constructor<?> constructor);

Expand All @@ -47,6 +42,9 @@ private static void setMethodDefaultValue(MethodNode mn, Method m) {
@Shadow
protected abstract void makeRecordComponents(CompileUnit cu, ClassNode classNode, Class<?> clazz);

@Shadow
protected abstract GenericsType[] configureTypeParameters(TypeVariable<?>[] tp);

/**
* @author brachy84
* @reason remapping minecraft fields and methods
Expand All @@ -72,10 +70,13 @@ public void configureClassNode(final CompileUnit compileUnit, final ClassNode cl
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);
mn.setSynthetic(m.isSynthetic());
setMethodDefaultValue(mn, m);
setAnnotationMetaData(m.getAnnotations(), mn);
mn.setGenericsTypes(configureTypeVariable(m.getTypeParameters()));
if (true) { // TODO: GROOVY-10862
mn.setAnnotationDefault(true);
mn.setCode(new ReturnStatement(new ConstantExpression(m.getDefaultValue())));
}
mn.setGenericsTypes(configureTypeParameters(m.getTypeParameters()));
mn.setSynthetic(m.isSynthetic());
classNode.addMethod(mn);
}
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.cleanroommc.groovyscript.api.Result;
import com.cleanroommc.groovyscript.compat.mods.GroovyContainer;
import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer;
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;
Expand Down Expand Up @@ -147,7 +148,7 @@ public static void init() {
.register();
GameObjectHandler.builder("creativeTab", CreativeTabs.class)
.parser(GameObjectHandlers::parseCreativeTab)
.completerOfNamed(() -> Arrays.asList(CreativeTabs.CREATIVE_TAB_ARRAY), CreativeTabs::getTabLabel)
.completerOfNamed(() -> Arrays.asList(CreativeTabs.CREATIVE_TAB_ARRAY), v -> ((CreativeTabsAccessor) v).getTabLabel2())
.docOfType("creative tab")
.register();
GameObjectHandler.builder("textformat", TextFormatting.class)
Expand Down

0 comments on commit 5fc020a

Please sign in to comment.