Skip to content

Commit

Permalink
Fixed computronics play sound distance
Browse files Browse the repository at this point in the history
Signed-off-by: djpadbit <[email protected]>
  • Loading branch information
djpadbit committed Feb 3, 2019
1 parent f6b30dc commit 3f20d9b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/main/java/com/sonicether/soundphysics/CoreModInjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,27 @@ public byte[] transform(final String obfuscated, final String deobfuscated, byte
// Target method: setHearing
bytes = patchMethodInClass(obfuscated, bytes, "setHearing", "(FF)V", Opcodes.FLOAD,
AbstractInsnNode.VAR_INSN, "", null, 1, toInject, false, 0, 0, false, 0);
} else

if (obfuscated.equals("pl.asie.computronics.api.audio.AudioPacket") && Config.computronicsPatching) {
// Inside AudioPacket
InsnList toInject = new InsnList();

toInject.add(new FieldInsnNode(Opcodes.GETSTATIC, "com/sonicether/soundphysics/SoundPhysics",
"soundDistanceAllowance", "D"));
toInject.add(new FieldInsnNode(Opcodes.GETSTATIC, "com/sonicether/soundphysics/SoundPhysics",
"soundDistanceAllowance", "D"));
toInject.add(new InsnNode(Opcodes.DMUL));
toInject.add(new InsnNode(Opcodes.D2I));
toInject.add(new InsnNode(Opcodes.IMUL));

// Target method: canHearReceiver
bytes = patchMethodInClass(obfuscated, bytes, "canHearReceiver", "(Lnet/minecraft/entity/player/EntityPlayerMP;Lpl/asie/computronics/api/audio/IAudioReceiver;)Z", Opcodes.IMUL,
AbstractInsnNode.INSN, "", null, -1, toInject, false, 0, 0, false, 0);
}

//System.out.println("[SP Inject] "+obfuscated+" ("+deobfuscated+")");

return bytes;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/sonicether/soundphysics/SoundPhysics.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@

import org.objectweb.asm.Type;

@Mod(modid = SoundPhysics.modid, clientSideOnly = true, acceptedMinecraftVersions = SoundPhysics.mcVersion, version = SoundPhysics.version, guiFactory = "com.sonicether.soundphysics.SPGuiFactory")
@Mod(modid = SoundPhysics.modid, clientSideOnly = true, acceptedMinecraftVersions = SoundPhysics.mcVersion, version = SoundPhysics.version, guiFactory = "com.sonicether.soundphysics.SPGuiFactory",
dependencies="before:computronics") // Dependencies to make sure that SP's config is loaded before patching Computronics
public class SoundPhysics {

public static final String modid = "soundphysics";
Expand Down

0 comments on commit 3f20d9b

Please sign in to comment.