Skip to content

Commit

Permalink
"fix" #480 (#482)
Browse files Browse the repository at this point in the history
* "fix" #480

* memoize this cuz why not, should? speed it up.
  • Loading branch information
screret authored Oct 23, 2023
1 parent 0c4e81d commit 553487b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.gregtechceu.gtceu.client.renderer.block;

import com.google.common.base.Suppliers;
import com.gregtechceu.gtceu.client.model.ItemBakedModel;
import com.lowdragmc.lowdraglib.LDLib;
import com.lowdragmc.lowdraglib.client.bakedpipeline.FaceQuad;
Expand Down Expand Up @@ -43,7 +44,7 @@ public class OreBlockRenderer extends BlockStateRenderer {
private final boolean emissive;

public OreBlockRenderer(Supplier<BlockState> stone, Supplier<ResourceLocation> overlaySupplier, boolean emissive) {
this.stone = stone;
this.stone = Suppliers.memoize(stone::get);
this.overlaySupplier = overlaySupplier;
this.emissive = emissive;
if (LDLib.isClient()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (mixinClassName.contains("com.gregtechceu.gtceu.core.mixins.kjs")) {
if (mixinClassName.contains("com.gregtechceu.gtceu.core.mixins.kjs") || mixinClassName.contains("com.gregtechceu.gtceu.core.mixins.rhino")) {
return MixinPluginShared.isClassFound("dev.latvian.mods.kubejs.KubeJSPlugin");
} else if (mixinClassName.contains("com.gregtechceu.gtceu.core.mixins.create")) {
return MixinPluginShared.isClassFound("com.simibubi.create.compat.Mods");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.gregtechceu.gtceu.core.mixins.rhino;

import dev.latvian.mods.rhino.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Coerce;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = Interpreter.class, remap = false)
public class InterpreterMixin {

/**
* {@code @Coerce}'d because the InterpretedFunction class is package-private. It "works".
* What a bodge for an issue that should never even happen, looking at the code.
* God I hate Rhino.
*/
@SuppressWarnings("InvalidInjectorMethodSignature")
@Inject(method = "interpret", at = @At(value = "INVOKE", target = "Ldev/latvian/mods/rhino/Kit;codeBug()Ljava/lang/RuntimeException;"), remap = false, cancellable = true)
private static void gtceu$doNotCrashPls(@Coerce NativeFunction ifun, Context cx, Scriptable scope, Scriptable thisObj, Object[] args, CallbackInfoReturnable<Object> cir) {
cir.setReturnValue(ScriptRuntime.doTopCall(cx, scope, ifun, thisObj, args, cx.isStrictMode()));
}
}
3 changes: 2 additions & 1 deletion common/src/main/resources/gtceu-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"WorldLoaderPackConfigMixin",
"create.RotationPropagatorMixin",
"kjs.RecipeEventJSMixin",
"top.ConfigMixin"
"top.ConfigMixin",
"rhino.InterpreterMixin"
],
"injectors": {
"defaultRequire": 1,
Expand Down

0 comments on commit 553487b

Please sign in to comment.