-
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.
Client side version, now has a coremod to make this possible (boo, etc.)
- Loading branch information
1 parent
eb42643
commit ebc25cb
Showing
12 changed files
with
1,326 additions
and
112 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 was deleted.
Oops, something went wrong.
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,30 @@ | ||
package com.charles445.damagetilt; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.util.math.MathHelper; | ||
|
||
public class HookEntity | ||
{ | ||
public static void setVelocity(Entity entity, double x, double y, double z) | ||
{ | ||
if(!ModConfig.damageTiltEnabled) | ||
return; | ||
|
||
//This is run before motion is locally set | ||
|
||
if(entity != null) | ||
{ | ||
EntityPlayer player = Minecraft.getMinecraft().player; | ||
if(player != null && entity.equals(player)) | ||
{ | ||
//Set the value | ||
float result = (float)(MathHelper.atan2(player.motionZ - z, player.motionX - x) * (180D / Math.PI) - (double)player.rotationYaw); | ||
|
||
if(Float.isFinite(result)) | ||
player.attackedAtYaw = result; | ||
} | ||
} | ||
} | ||
} |
61 changes: 0 additions & 61 deletions
61
src/main/java/com/charles445/damagetilt/MessageUpdateAttackYaw.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/main/java/com/charles445/damagetilt/PacketHandler.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
src/main/java/com/charles445/damagetilt/asm/CoreLoader.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,49 @@ | ||
package com.charles445.damagetilt.asm; | ||
|
||
import java.util.Map; | ||
|
||
import com.charles445.damagetilt.asm.helper.ObfHelper; | ||
|
||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; | ||
|
||
@IFMLLoadingPlugin.Name("Damage Tilt ASM") | ||
@IFMLLoadingPlugin.SortingIndex(1002) | ||
@IFMLLoadingPlugin.TransformerExclusions({ "com.charles445.damagetilt.asm", "com.charles445.damagetilt.asm." }) | ||
|
||
public class CoreLoader implements IFMLLoadingPlugin | ||
{ | ||
// | ||
// IFMLLoadingPlugin | ||
// | ||
|
||
@Override | ||
public String[] getASMTransformerClass() | ||
{ | ||
return new String[] { "com.charles445.damagetilt.asm.DamageTiltASM" }; | ||
} | ||
|
||
@Override | ||
public void injectData(Map<String, Object> data) | ||
{ | ||
ObfHelper.setObfuscated((Boolean) data.get("runtimeDeobfuscationEnabled")); | ||
ObfHelper.setRunsAfterDeobfRemapper(true); | ||
} | ||
|
||
@Override | ||
public String getModContainerClass() | ||
{ | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getSetupClass() | ||
{ | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getAccessTransformerClass() | ||
{ | ||
return null; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/com/charles445/damagetilt/asm/DamageTiltASM.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,63 @@ | ||
package com.charles445.damagetilt.asm; | ||
|
||
import org.objectweb.asm.ClassWriter; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.objectweb.asm.tree.InsnList; | ||
import org.objectweb.asm.tree.MethodInsnNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
import org.objectweb.asm.tree.VarInsnNode; | ||
|
||
import com.charles445.damagetilt.asm.helper.ASMHelper; | ||
|
||
import net.minecraft.launchwrapper.IClassTransformer; | ||
|
||
public class DamageTiltASM implements IClassTransformer | ||
{ | ||
@Override | ||
public byte[] transform(String name, String transformedName, byte[] basicClass) | ||
{ | ||
if(transformedName.equals("net.minecraft.entity.Entity")) | ||
{ | ||
return transformEntity(basicClass); | ||
} | ||
|
||
return basicClass; | ||
} | ||
|
||
public byte[] transformEntity(byte[] basicClass) | ||
{ | ||
ClassNode cNode = ASMHelper.readClassFromBytes(basicClass); | ||
|
||
//net.minecraft.entity.Entity | ||
|
||
for(MethodNode mNode : cNode.methods) | ||
{ | ||
if(mNode.name.equals("func_70016_h") || mNode.name.equals("setVelocity")) | ||
{ | ||
//Matching name, verify correct desc | ||
if(mNode.desc.equals("(DDD)V")) | ||
{ | ||
//Found a match | ||
InsnList hook = new InsnList(); | ||
|
||
hook.add(new VarInsnNode(Opcodes.ALOAD,0)); //push this to stack | ||
hook.add(new VarInsnNode(Opcodes.DLOAD,1)); //push x to stack (increment 2 for doubles as param) | ||
hook.add(new VarInsnNode(Opcodes.DLOAD,3)); //push y to stack | ||
hook.add(new VarInsnNode(Opcodes.DLOAD,5)); //push z to stack | ||
hook.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/charles445/damagetilt/HookEntity", "setVelocity", "(Lnet/minecraft/entity/Entity;DDD)V", false)); | ||
|
||
//Add to method head | ||
mNode.instructions.insertBefore(ASMHelper.findFirstInstruction(mNode), hook); | ||
|
||
System.out.println("Damage Tilt Patched net.minecraft.entity.Entity"); | ||
return ASMHelper.writeClassToBytes(cNode, ClassWriter.COMPUTE_MAXS); | ||
} | ||
|
||
} | ||
} | ||
|
||
System.out.println("Damage Tilt Skipping patch for net.minecraft.entity.Entity"); | ||
return basicClass; | ||
} | ||
} |
Oops, something went wrong.