-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compatible with forge 1.16.5-36.0.22.
- Loading branch information
1 parent
c897f52
commit 56ec3d5
Showing
9 changed files
with
330 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
83 changes: 83 additions & 0 deletions
83
...m/transformers/net/minecraft/client/renderer/entity/EntityRendererManagerTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package io.github.zekerzhayard.optiforge.asm.transformers.net.minecraft.client.renderer.entity; | ||
|
||
import java.util.Objects; | ||
|
||
import cpw.mods.modlauncher.api.ITransformer; | ||
import io.github.zekerzhayard.optiforge.asm.transformers.ITransformerImpl; | ||
import io.github.zekerzhayard.optiforge.asm.utils.ASMUtils; | ||
import net.minecraftforge.coremod.api.ASMAPI; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.AbstractInsnNode; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.FieldInsnNode; | ||
import org.objectweb.asm.tree.LocalVariableNode; | ||
import org.objectweb.asm.tree.MethodInsnNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
import org.objectweb.asm.tree.TypeInsnNode; | ||
import org.spongepowered.asm.util.Bytecode; | ||
|
||
public class EntityRendererManagerTransformer implements ITransformer<ClassNode>, ITransformerImpl { | ||
@Override | ||
public String targetClass() { | ||
return "net.minecraft.client.renderer.entity.EntityRendererManager"; | ||
} | ||
|
||
@Override | ||
public ClassNode transform(ClassNode input) { | ||
// https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/patches/minecraft/net/minecraft/client/renderer/entity/EntityRendererManager.java.patch#L18-L19 | ||
// | ||
// private void func_229093_a_(MatrixStack p_229093_1_, IVertexBuilder p_229093_2_, Entity p_229093_3_, float p_229093_4_) { | ||
// float f = p_229093_3_.func_213311_cf() / 2.0F; | ||
// this.func_229094_a_(p_229093_1_, p_229093_2_, p_229093_3_, 1.0F, 1.0F, 1.0F); | ||
// - if (p_229093_3_ instanceof EnderDragonEntity) { | ||
// + if (p_229093_3_.isMultipartEntity()) { | ||
// double d0 = -MathHelper.func_219803_d((double)p_229093_4_, p_229093_3_.field_70142_S, p_229093_3_.func_226277_ct_()); | ||
// double d1 = -MathHelper.func_219803_d((double)p_229093_4_, p_229093_3_.field_70137_T, p_229093_3_.func_226278_cu_()); | ||
// double d2 = -MathHelper.func_219803_d((double)p_229093_4_, p_229093_3_.field_70136_U, p_229093_3_.func_226281_cx_()); | ||
// | ||
|
||
MethodNode renderDebugBoundingBox = Objects.requireNonNull(Bytecode.findMethod(input, ASMAPI.mapMethod("func_229093_a_"), "(Lcom/mojang/blaze3d/matrix/MatrixStack;Lcom/mojang/blaze3d/vertex/IVertexBuilder;Lnet/minecraft/entity/Entity;F)V")); | ||
|
||
for (AbstractInsnNode ain : renderDebugBoundingBox.instructions.toArray()) { | ||
if (ain.getOpcode() == Opcodes.INSTANCEOF) { | ||
TypeInsnNode tin = (TypeInsnNode) ain; | ||
if (tin.desc.equals("net/minecraft/entity/boss/dragon/EnderDragonEntity")) { | ||
renderDebugBoundingBox.instructions.set(tin, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/entity/Entity", "isMultipartEntity", "()Z", false)); | ||
} | ||
} else if (ain.getOpcode() == Opcodes.INVOKEVIRTUAL) { | ||
MethodInsnNode min = (MethodInsnNode) ain; | ||
if (min.owner.equals("net/minecraft/entity/boss/dragon/EnderDragonEntity") && min.name.equals(ASMAPI.mapMethod("func_213404_dT")) && min.desc.equals("()[Lnet/minecraft/entity/boss/dragon/EnderDragonPartEntity;")) { | ||
|
||
// | ||
// https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/patches/minecraft/net/minecraft/client/renderer/entity/EntityRendererManager.java.patch#L24-L25 | ||
// | ||
// double d1 = -MathHelper.func_219803_d((double)p_229093_4_, p_229093_3_.field_70137_T, p_229093_3_.func_226278_cu_()); | ||
// double d2 = -MathHelper.func_219803_d((double)p_229093_4_, p_229093_3_.field_70136_U, p_229093_3_.func_226281_cx_()); | ||
// | ||
// - for(EnderDragonPartEntity enderdragonpartentity : ((EnderDragonEntity)p_229093_3_).func_213404_dT()) { | ||
// + for(net.minecraftforge.entity.PartEntity<?> enderdragonpartentity : p_229093_3_.getParts()) { | ||
// p_229093_1_.func_227860_a_(); | ||
// double d3 = d0 + MathHelper.func_219803_d((double)p_229093_4_, enderdragonpartentity.field_70142_S, enderdragonpartentity.func_226277_ct_()); | ||
// double d4 = d1 + MathHelper.func_219803_d((double)p_229093_4_, enderdragonpartentity.field_70137_T, enderdragonpartentity.func_226278_cu_()); | ||
// | ||
|
||
renderDebugBoundingBox.instructions.remove(min.getPrevious()); | ||
renderDebugBoundingBox.instructions.set(min, new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/entity/Entity", "getParts", "()[Lnet/minecraftforge/entity/PartEntity;")); | ||
} else if (min.owner.equals("net/minecraft/entity/boss/dragon/EnderDragonPartEntity") && (min.name.equals(ASMAPI.mapMethod("func_226277_ct_")) || min.name.equals(ASMAPI.mapMethod("func_226278_cu_")) || min.name.equals(ASMAPI.mapMethod("func_226281_cx_"))) && min.desc.equals("()D")) { | ||
min.owner = "net/minecraftforge/entity/PartEntity"; | ||
} | ||
} else if (ain.getOpcode() == Opcodes.GETFIELD) { | ||
FieldInsnNode fin = (FieldInsnNode) ain; | ||
if (fin.owner.equals("net/minecraft/entity/boss/dragon/EnderDragonPartEntity") && (fin.name.equals(ASMAPI.mapField("field_70142_S")) || fin.name.equals(ASMAPI.mapField("field_70137_T")) || fin.name.equals(ASMAPI.mapField("field_70136_U"))) && fin.desc.equals("D")) { | ||
fin.owner = "net/minecraftforge/entity/PartEntity"; | ||
} | ||
} | ||
} | ||
|
||
LocalVariableNode enderdragonpartentity = Objects.requireNonNull(ASMUtils.findLocalVariable(renderDebugBoundingBox, "Lnet/minecraft/entity/boss/dragon/EnderDragonPartEntity;", 0)); | ||
enderdragonpartentity.desc = "Lnet/minecraftforge/entity/PartEntity;"; | ||
enderdragonpartentity.signature = "Lnet/minecraftforge/entity/PartEntity<*>;"; | ||
|
||
return input; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...io/github/zekerzhayard/optiforge/asm/transformers/net/minecraft/util/UtilTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.github.zekerzhayard.optiforge.asm.transformers.net.minecraft.util; | ||
|
||
import java.util.Objects; | ||
|
||
import cpw.mods.modlauncher.api.ITransformer; | ||
import io.github.zekerzhayard.optiforge.asm.transformers.ITransformerImpl; | ||
import net.minecraftforge.coremod.api.ASMAPI; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.AbstractInsnNode; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.MethodInsnNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
import org.spongepowered.asm.util.Bytecode; | ||
|
||
public class UtilTransformer implements ITransformer<ClassNode>, ITransformerImpl { | ||
@Override | ||
public String targetClass() { | ||
return "net.minecraft.util.Util"; | ||
} | ||
|
||
@Override | ||
public ClassNode transform(ClassNode input) { | ||
// https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/patches/minecraft/net/minecraft/util/Util.java.patch#L7-L8 | ||
// | ||
// try { | ||
// type = DataFixesManager.func_210901_a().getSchema(DataFixUtils.makeKey(SharedConstants.func_215069_a().getWorldVersion())).getChoiceType(p_240990_0_, p_240990_1_); | ||
// } catch (IllegalArgumentException illegalargumentexception) { | ||
// - field_195650_a.error("No data fixer registered for {}", (Object)p_240990_1_); | ||
// + field_195650_a.debug("No data fixer registered for {}", (Object)p_240990_1_); | ||
// if (SharedConstants.field_206244_b) { | ||
// throw illegalargumentexception; | ||
// } | ||
// | ||
|
||
MethodNode attemptDataFixInternal = Objects.requireNonNull(Bytecode.findMethod(input, ASMAPI.mapMethod("func_240990_b_"), "(Lcom/mojang/datafixers/DSL$TypeReference;Ljava/lang/String;)Lcom/mojang/datafixers/types/Type;")); | ||
|
||
for (AbstractInsnNode ain : attemptDataFixInternal.instructions.toArray()) { | ||
if (ain.getOpcode() == Opcodes.INVOKEINTERFACE) { | ||
MethodInsnNode min = (MethodInsnNode) ain; | ||
if (min.owner.equals("org/apache/logging/log4j/Logger") && min.name.equals("error") && min.desc.equals("(Ljava/lang/String;Ljava/lang/Object;)V")) { | ||
min.name = "debug"; | ||
} | ||
} | ||
} | ||
|
||
return input; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...hayard/optiforge/asm/transformers/net/minecraft/world/server/ChunkManagerTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.github.zekerzhayard.optiforge.asm.transformers.net.minecraft.world.server; | ||
|
||
import java.util.Objects; | ||
|
||
import cpw.mods.modlauncher.api.ITransformer; | ||
import io.github.zekerzhayard.optiforge.asm.transformers.ITransformerImpl; | ||
import net.minecraftforge.coremod.api.ASMAPI; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.AbstractInsnNode; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
import org.objectweb.asm.tree.TypeInsnNode; | ||
import org.spongepowered.asm.util.Bytecode; | ||
|
||
public class ChunkManagerTransformer implements ITransformer<ClassNode>, ITransformerImpl { | ||
@Override | ||
public String targetClass() { | ||
return "net.minecraft.world.server.ChunkManager"; | ||
} | ||
|
||
@Override | ||
public ClassNode transform(ClassNode input) { | ||
|
||
// | ||
// https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/patches/minecraft/net/minecraft/world/server/ChunkManager.java.patch#L39-L40 | ||
// | ||
// } | ||
// | ||
// protected void func_219210_a(Entity p_219210_1_) { | ||
// - if (!(p_219210_1_ instanceof EnderDragonPartEntity)) { | ||
// + if (!(p_219210_1_ instanceof net.minecraftforge.entity.PartEntity)) { | ||
// EntityType<?> entitytype = p_219210_1_.func_200600_R(); | ||
// int i = entitytype.func_233602_m_() * 16; | ||
// int j = entitytype.func_220332_l(); | ||
// | ||
|
||
MethodNode track = Objects.requireNonNull(Bytecode.findMethod(input, ASMAPI.mapMethod("func_219210_a"), "(Lnet/minecraft/entity/Entity;)V")); | ||
|
||
for (AbstractInsnNode ain : track.instructions.toArray()) { | ||
if (ain.getOpcode() == Opcodes.INSTANCEOF) { | ||
TypeInsnNode tin = (TypeInsnNode) ain; | ||
if (tin.desc.equals("net/minecraft/entity/boss/dragon/EnderDragonPartEntity")) { | ||
tin.desc = "net/minecraftforge/entity/PartEntity"; | ||
} | ||
} | ||
} | ||
|
||
return input; | ||
} | ||
} |
Oops, something went wrong.