mirror of
https://github.com/squeek502/Squake.git
synced 2025-08-03 17:58:08 -04:00
Port to 1.12
This commit is contained in:
parent
ca8c1b1079
commit
90693c06b8
@ -7,15 +7,15 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
|
||||
minecraft {
|
||||
version = "1.11.2-13.20.0.2201"
|
||||
mappings = "snapshot_20161220"
|
||||
version = "14.21.0.2363"
|
||||
mappings = "snapshot_20170625"
|
||||
runDir = "run"
|
||||
|
||||
coreMod = "squeek.quakemovement.ASMPlugin"
|
||||
|
@ -10,7 +10,7 @@ import org.objectweb.asm.tree.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@IFMLLoadingPlugin.MCVersion("1.11.2")
|
||||
@IFMLLoadingPlugin.MCVersion("1.12")
|
||||
public class ASMPlugin implements IFMLLoadingPlugin, IClassTransformer
|
||||
{
|
||||
public static boolean isObfuscated = false;
|
||||
@ -27,15 +27,16 @@ public class ASMPlugin implements IFMLLoadingPlugin, IClassTransformer
|
||||
ClassNode classNode = readClassFromBytes(bytes);
|
||||
MethodNode method;
|
||||
|
||||
method = findMethodNodeOfClass(classNode, isObfuscated ? "g" : "moveEntityWithHeading", "(FF)V");
|
||||
method = findMethodNodeOfClass(classNode, isObfuscated ? "a" : "travel", "(FFF)V");
|
||||
if (method == null)
|
||||
throw new RuntimeException("could not find EntityPlayer.moveEntityWithHeading");
|
||||
throw new RuntimeException("could not find EntityPlayer.travel");
|
||||
|
||||
InsnList loadParameters = new InsnList();
|
||||
loadParameters.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
loadParameters.add(new VarInsnNode(Opcodes.FLOAD, 1));
|
||||
loadParameters.add(new VarInsnNode(Opcodes.FLOAD, 2));
|
||||
injectStandardHook(method, findFirstInstruction(method), CLASS_QUAKE_CLIENT_PLAYER, "moveEntityWithHeading", toMethodDescriptor("Z", CLASS_ENTITY_PLAYER, "F", "F"), loadParameters);
|
||||
loadParameters.add(new VarInsnNode(Opcodes.FLOAD, 3));
|
||||
injectStandardHook(method, findFirstInstruction(method), CLASS_QUAKE_CLIENT_PLAYER, "moveEntityWithHeading", toMethodDescriptor("Z", CLASS_ENTITY_PLAYER, "F", "F", "F"), loadParameters);
|
||||
|
||||
method = findMethodNodeOfClass(classNode, isObfuscated ? "n" : "onLivingUpdate", "()V");
|
||||
if (method == null)
|
||||
@ -76,7 +77,7 @@ public class ASMPlugin implements IFMLLoadingPlugin, IClassTransformer
|
||||
ClassNode classNode = readClassFromBytes(bytes);
|
||||
MethodNode method;
|
||||
|
||||
method = findMethodNodeOfClass(classNode, isObfuscated ? "a" : "moveRelative", "(FFF)V");
|
||||
method = findMethodNodeOfClass(classNode, isObfuscated ? "b" : "moveRelative", "(FFFF)V");
|
||||
if (method == null)
|
||||
throw new RuntimeException("could not find Entity.moveRelative");
|
||||
|
||||
@ -85,7 +86,8 @@ public class ASMPlugin implements IFMLLoadingPlugin, IClassTransformer
|
||||
loadParameters.add(new VarInsnNode(Opcodes.FLOAD, 1));
|
||||
loadParameters.add(new VarInsnNode(Opcodes.FLOAD, 2));
|
||||
loadParameters.add(new VarInsnNode(Opcodes.FLOAD, 3));
|
||||
injectStandardHook(method, findFirstInstruction(method), CLASS_QUAKE_CLIENT_PLAYER, "moveRelativeBase", toMethodDescriptor("Z", CLASS_ENTITY, "F", "F", "F"), loadParameters);
|
||||
loadParameters.add(new VarInsnNode(Opcodes.FLOAD, 4));
|
||||
injectStandardHook(method, findFirstInstruction(method), CLASS_QUAKE_CLIENT_PLAYER, "moveRelativeBase", toMethodDescriptor("Z", CLASS_ENTITY, "F", "F", "F", "F"), loadParameters);
|
||||
|
||||
return writeClassToBytes(classNode);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod(modid = ModInfo.MODID, version = ModInfo.VERSION, name="Squake", acceptedMinecraftVersions="[1.11,1.12)", dependencies = "after:squeedometer")
|
||||
@Mod(modid = ModInfo.MODID, version = ModInfo.VERSION, name="Squake", acceptedMinecraftVersions="[1.12,1.13)", dependencies = "after:squeedometer")
|
||||
public class ModQuakeMovement
|
||||
{
|
||||
// The instance of your mod that Forge uses.
|
||||
|
@ -45,7 +45,7 @@ public class QuakeClientPlayer
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean moveEntityWithHeading(EntityPlayer player, float sidemove, float forwardmove)
|
||||
public static boolean moveEntityWithHeading(EntityPlayer player, float sidemove, float upmove, float forwardmove)
|
||||
{
|
||||
if (!player.world.isRemote)
|
||||
return false;
|
||||
@ -58,7 +58,7 @@ public class QuakeClientPlayer
|
||||
if ((player.capabilities.isFlying || player.isElytraFlying()) && player.getRidingEntity() == null)
|
||||
return false;
|
||||
else
|
||||
didQuakeMovement = quake_moveEntityWithHeading(player, sidemove, forwardmove);
|
||||
didQuakeMovement = quake_moveEntityWithHeading(player, sidemove, upmove, forwardmove);
|
||||
|
||||
if (didQuakeMovement)
|
||||
player.addMovementStat(player.posX - d0, player.posY - d1, player.posZ - d2);
|
||||
@ -100,15 +100,15 @@ public class QuakeClientPlayer
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean moveRelativeBase(Entity entity, float sidemove, float forwardmove, float friction)
|
||||
public static boolean moveRelativeBase(Entity entity, float sidemove, float upmove, float forwardmove, float friction)
|
||||
{
|
||||
if (!(entity instanceof EntityPlayer))
|
||||
return false;
|
||||
|
||||
return moveRelative((EntityPlayer)entity, sidemove, forwardmove, friction);
|
||||
return moveRelative((EntityPlayer)entity, sidemove, forwardmove, upmove, friction);
|
||||
}
|
||||
|
||||
public static boolean moveRelative(EntityPlayer player, float sidemove, float forwardmove, float friction)
|
||||
public static boolean moveRelative(EntityPlayer player, float sidemove, float upmove, float forwardmove, float friction)
|
||||
{
|
||||
if (!player.world.isRemote)
|
||||
return false;
|
||||
@ -377,10 +377,10 @@ public class QuakeClientPlayer
|
||||
player.limbSwing += player.limbSwingAmount;
|
||||
}
|
||||
|
||||
private static void minecraft_WaterMove(EntityPlayer player, float sidemove, float forwardmove)
|
||||
private static void minecraft_WaterMove(EntityPlayer player, float sidemove, float upmove, float forwardmove)
|
||||
{
|
||||
double d0 = player.posY;
|
||||
player.moveRelative(sidemove, forwardmove, 0.04F);
|
||||
player.moveRelative(sidemove, upmove, forwardmove, 0.04F);
|
||||
player.move(MoverType.SELF, player.motionX, player.motionY, player.motionZ);
|
||||
player.motionX *= 0.800000011920929D;
|
||||
player.motionY *= 0.800000011920929D;
|
||||
@ -393,13 +393,13 @@ public class QuakeClientPlayer
|
||||
}
|
||||
}
|
||||
|
||||
public static void minecraft_moveEntityWithHeading(EntityPlayer player, float sidemove, float forwardmove)
|
||||
public static void minecraft_moveEntityWithHeading(EntityPlayer player, float sidemove, float upmove, float forwardmove)
|
||||
{
|
||||
// take care of water and lava movement using default code
|
||||
if ((player.isInWater() && !player.capabilities.isFlying)
|
||||
|| (player.isInLava() && !player.capabilities.isFlying))
|
||||
{
|
||||
player.moveEntityWithHeading(sidemove, forwardmove);
|
||||
player.travel(sidemove, upmove, forwardmove);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -407,7 +407,7 @@ public class QuakeClientPlayer
|
||||
float momentumRetention = getSlipperiness(player);
|
||||
|
||||
// alter motionX/motionZ based on desired movement
|
||||
player.moveRelative(sidemove, forwardmove, minecraft_getMoveSpeed(player));
|
||||
player.moveRelative(sidemove, upmove, forwardmove, minecraft_getMoveSpeed(player));
|
||||
|
||||
// make adjustments for ladder interaction
|
||||
minecraft_ApplyLadderPhysics(player);
|
||||
@ -440,7 +440,7 @@ public class QuakeClientPlayer
|
||||
/**
|
||||
* Moves the entity based on the specified heading. Args: strafe, forward
|
||||
*/
|
||||
public static boolean quake_moveEntityWithHeading(EntityPlayer player, float sidemove, float forwardmove)
|
||||
public static boolean quake_moveEntityWithHeading(EntityPlayer player, float sidemove, float upmove, float forwardmove)
|
||||
{
|
||||
// take care of lava movement using default code
|
||||
if ((player.isInLava() && !player.capabilities.isFlying))
|
||||
@ -450,7 +450,7 @@ public class QuakeClientPlayer
|
||||
else if (player.isInWater() && !player.capabilities.isFlying)
|
||||
{
|
||||
if (ModConfig.SHARKING_ENABLED)
|
||||
quake_WaterMove(player, sidemove, forwardmove);
|
||||
quake_WaterMove(player, sidemove, upmove, forwardmove);
|
||||
else
|
||||
{
|
||||
return false;
|
||||
@ -616,7 +616,7 @@ public class QuakeClientPlayer
|
||||
}
|
||||
}
|
||||
|
||||
private static void quake_WaterMove(EntityPlayer player, float sidemove, float forwardmove)
|
||||
private static void quake_WaterMove(EntityPlayer player, float sidemove, float upmove, float forwardmove)
|
||||
{
|
||||
double lastPosY = player.posY;
|
||||
|
||||
@ -628,7 +628,7 @@ public class QuakeClientPlayer
|
||||
|
||||
if (!isSharking || curspeed < 0.078F)
|
||||
{
|
||||
minecraft_WaterMove(player, sidemove, forwardmove);
|
||||
minecraft_WaterMove(player, sidemove, upmove, forwardmove);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user