-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: check wither visibility before spawning particles
fixes sp614x/optifine#3616
- Loading branch information
asbyth
committed
Nov 9, 2020
1 parent
8b8693c
commit 823523e
Showing
5 changed files
with
67 additions
and
13 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
59 changes: 59 additions & 0 deletions
59
src/main/java/club/sk1er/patcher/tweaker/asm/optifine/witherfix/EntityWitherTransformer.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,59 @@ | ||
package club.sk1er.patcher.tweaker.asm.optifine.witherfix; | ||
|
||
import club.sk1er.patcher.tweaker.transform.PatcherTransformer; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.AbstractInsnNode; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.InsnList; | ||
import org.objectweb.asm.tree.InsnNode; | ||
import org.objectweb.asm.tree.JumpInsnNode; | ||
import org.objectweb.asm.tree.LabelNode; | ||
import org.objectweb.asm.tree.MethodInsnNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
import org.objectweb.asm.tree.VarInsnNode; | ||
|
||
import java.util.ListIterator; | ||
|
||
public class EntityWitherTransformer implements PatcherTransformer { | ||
@Override | ||
public String[] getClassName() { | ||
return new String[]{"net.minecraft.entity.boss.EntityWither"}; | ||
} | ||
|
||
@Override | ||
public void transform(ClassNode classNode, String name) { | ||
for (MethodNode method : classNode.methods) { | ||
final String methodName = mapMethodName(classNode, method); | ||
|
||
if (methodName.equals("onLivingUpdate") || methodName.equals("func_70636_d")) { | ||
final ListIterator<AbstractInsnNode> iterator = method.instructions.iterator(); | ||
|
||
while (iterator.hasNext()) { | ||
final AbstractInsnNode next = iterator.next(); | ||
|
||
if (next instanceof MethodInsnNode && next.getOpcode() == Opcodes.INVOKEVIRTUAL) { | ||
final String methodInsnName = mapMethodNameFromNode(next); | ||
|
||
if ((methodInsnName.equals("isArmored") || methodInsnName.equals("func_82205_o")) && next.getNext().getOpcode() == Opcodes.ISTORE) { | ||
method.instructions.insertBefore(next.getNext().getNext(), checkVisibility()); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
break; | ||
} | ||
} | ||
} | ||
|
||
private InsnList checkVisibility() { | ||
InsnList list = new InsnList(); | ||
list.add(new VarInsnNode(Opcodes.ALOAD, 0)); | ||
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "net/minecraft/entity/boss/EntityWither", "func_82150_aj", "()Z", false)); | ||
LabelNode ifeq = new LabelNode(); | ||
list.add(new JumpInsnNode(Opcodes.IFEQ, ifeq)); | ||
list.add(new InsnNode(Opcodes.RETURN)); | ||
list.add(ifeq); | ||
return list; | ||
} | ||
} |