Skip to content

Commit

Permalink
Another one down
Browse files Browse the repository at this point in the history
  • Loading branch information
ALongStringOfNumbers committed Dec 7, 2023
1 parent 2972a76 commit 5ef927f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/main/java/gregtech/asm/GregTechTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@
import gregtech.asm.visitors.JEIVisitor;
import gregtech.asm.visitors.LittleTilesVisitor;
import gregtech.asm.visitors.ModelCTMVisitor;
import gregtech.asm.visitors.RenderItemVisitor;

import net.minecraft.launchwrapper.IClassTransformer;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;

import java.util.Iterator;

public class GregTechTransformer implements IClassTransformer, Opcodes {

Expand Down Expand Up @@ -170,16 +165,18 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
* return classWriter.toByteArray();
* }
*/
case RenderItemVisitor.TARGET_CLASS_NAME: {
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(basicClass);
classReader.accept(classNode, 0);
Iterator<MethodNode> methods = classNode.methods.iterator();
RenderItemVisitor.transform(methods);
ClassWriter classWriter = new ClassWriter(0);
classNode.accept(classWriter);
return classWriter.toByteArray();
}
/*
* case RenderItemVisitor.TARGET_CLASS_NAME: {
* ClassNode classNode = new ClassNode();
* ClassReader classReader = new ClassReader(basicClass);
* classReader.accept(classNode, 0);
* Iterator<MethodNode> methods = classNode.methods.iterator();
* RenderItemVisitor.transform(methods);
* ClassWriter classWriter = new ClassWriter(0);
* classNode.accept(classWriter);
* return classWriter.toByteArray();
* }
*/
/*
* case RecipeRepairItemVisitor.TARGET_CLASS_NAME: {
* ClassReader classReader = new ClassReader(basicClass);
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/gregtech/mixins/minecraft/RenderItemMixin.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package gregtech.mixins.minecraft;

import gregtech.api.GTValues;
import gregtech.asm.hooks.RenderItemHooks;

import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -22,4 +24,16 @@ private void renderItemOverlayIntoGUIInject(FontRenderer fr, ItemStack stack, in
RenderItemHooks.renderLampOverlay(stack, xPosition, yPosition);
}
}

@Inject(method = "renderItemOverlayIntoGUI",
at = @At(value = "INVOKE_ASSIGN",
target = "Lnet/minecraft/client/Minecraft;getMinecraft()Lnet/minecraft/client/Minecraft;",
shift = At.Shift.BEFORE,
ordinal = 0))
public void showDurabilityBarMixin(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text,
CallbackInfo ci) {
if (!Loader.isModLoaded(GTValues.MODID_ECORE)) {
RenderItemHooks.renderElectricBar(stack, xPosition, yPosition);
}
}
}

0 comments on commit 5ef927f

Please sign in to comment.