-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(infoacc): bearing now stays in expected range
- Loading branch information
Showing
5 changed files
with
63 additions
and
2 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
51 changes: 51 additions & 0 deletions
51
src/main/java/tv/darkosto/sevpatches/core/patches/PatchInfoAccCompass.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,51 @@ | ||
package tv.darkosto.sevpatches.core.patches; | ||
|
||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.*; | ||
import tv.darkosto.sevpatches.core.utils.AsmUtils; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
import java.util.stream.StreamSupport; | ||
|
||
import static tv.darkosto.sevpatches.core.SevPatchesLoadingPlugin.*; | ||
|
||
public class PatchInfoAccCompass extends Patch { | ||
public PatchInfoAccCompass(byte[] inputClass) { | ||
super(inputClass); | ||
} | ||
|
||
@Override | ||
protected boolean patch() { | ||
MethodNode addDirectionInfo = AsmUtils.findMethod(this.classNode, "addDirectionInfo"); | ||
if (addDirectionInfo == null) return false; | ||
InsnList insnlist = addDirectionInfo.instructions; | ||
|
||
Iterable<AbstractInsnNode> insnsIter = insnlist::iterator; | ||
Stream<AbstractInsnNode> insns = StreamSupport.stream(insnsIter.spliterator(), false); | ||
|
||
// - int yaw = MathHelper.floor(player.rotationYaw % 360.0); | ||
List<AbstractInsnNode> labels = insns.filter(insn -> insn instanceof LabelNode).collect(Collectors.toList()); | ||
int startIndex = insnlist.indexOf(labels.get(0)) + 2; | ||
int endIndex = insnlist.indexOf(labels.get(1)); | ||
|
||
for (int i = startIndex; i < endIndex; i++) { | ||
AbstractInsnNode insn = insnlist.get(startIndex); | ||
insnlist.remove(insn); | ||
} | ||
|
||
// + int yaw = MathHelper.floor(MathHelper.positiveModulo(player.rotationYaw)); | ||
InsnList modYaw = new InsnList(); | ||
modYaw.add(new VarInsnNode(Opcodes.ALOAD, 1)); | ||
modYaw.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/entity/player/EntityPlayer", ENTITY_ROTATION_YAW, "F")); | ||
modYaw.add(new LdcInsnNode(360.0f)); | ||
modYaw.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/util/math/MathHelper", POSITIVE_MODULO, "(FF)F", false)); | ||
modYaw.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraft/util/math/MathHelper", FLOOR, "(F)I", false)); | ||
modYaw.add(new VarInsnNode(Opcodes.ISTORE, 3)); | ||
|
||
insnlist.insert(labels.get(0), modYaw); | ||
|
||
return true; | ||
} | ||
} |
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