forked from MinecraftTAS/TASmod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Control Bytes (@pancake) - Playback Interpolation (@pancake) - Fixes a softlock - Changing savestate loading behaviour - Bug Fixes
- Loading branch information
Showing
24 changed files
with
428 additions
and
120 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
62 changes: 62 additions & 0 deletions
62
src/main/java/de/pfannekuchen/tasmod/controlbytes/ControlByteHandler.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,62 @@ | ||
package de.pfannekuchen.tasmod.controlbytes; | ||
|
||
/** | ||
* Handles playback control bytes | ||
* @author Pancake | ||
*/ | ||
public class ControlByteHandler { | ||
|
||
/** | ||
* Resets all control-byte-controlled settings | ||
*/ | ||
public static void reset() { | ||
ControlByteHandler.shouldInterpolate = false; | ||
ControlByteHandler.shouldRenderHud = true; | ||
ControlByteHandler.text = ""; | ||
ControlByteHandler.hideInfoBox = true; | ||
} | ||
|
||
/** | ||
* Reacts to control bytes | ||
* @param command Control Command | ||
* @param args Arguments | ||
*/ | ||
public static void onControlByte(String command, String[] args) { | ||
switch (command.toLowerCase()) { | ||
case "interpolation": | ||
interpolation(args); | ||
break; | ||
case "hud": | ||
hud(args); | ||
break; | ||
case "info": | ||
info(args); | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
private static void info(String[] args) { | ||
ControlByteHandler.hideInfoBox = "off".equals(args[0].trim()) || "false".equals(args[0].trim()) || "no".equals(args[0].trim()) || "0".equals(args[0].trim()); | ||
// Parse array as text | ||
ControlByteHandler.text = ""; | ||
for (String string : args) { | ||
ControlByteHandler.text += " " + string; | ||
} | ||
ControlByteHandler.text = ControlByteHandler.text.trim(); | ||
} | ||
|
||
public static void interpolation(String[] args) { | ||
ControlByteHandler.shouldInterpolate = "on".equals(args[0].trim()) || "true".equals(args[0].trim()) || "yes".equals(args[0].trim()) || "1".equals(args[0].trim()); | ||
} | ||
|
||
public static void hud(String[] args) { | ||
ControlByteHandler.shouldRenderHud = "on".equals(args[0].trim()) || "true".equals(args[0].trim()) || "yes".equals(args[0].trim()) || "1".equals(args[0].trim()); | ||
} | ||
|
||
public static boolean hideInfoBox = true; | ||
public static String text = ""; | ||
public static boolean shouldInterpolate = false; | ||
public static boolean shouldRenderHud = true; | ||
|
||
} |
20 changes: 17 additions & 3 deletions
20
src/main/java/de/pfannekuchen/tasmod/events/CameraInterpolationEvents.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 |
---|---|---|
@@ -1,17 +1,31 @@ | ||
package de.pfannekuchen.tasmod.events; | ||
|
||
import de.pfannekuchen.tasmod.controlbytes.ControlByteHandler; | ||
import de.scribble.lp.tasmod.ClientProxy; | ||
import de.scribble.lp.tasmod.inputcontainer.TickInputContainer; | ||
import de.scribble.lp.tasmod.mixin.accessors.AccessorRunStuff; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.util.math.MathHelper; | ||
import net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
|
||
public class CameraInterpolationEvents { | ||
|
||
public static float rotationPitch = 0f; | ||
public static float rotationYaw = 0f; | ||
|
||
@SubscribeEvent | ||
public void inter(CameraSetup ev) { | ||
ev.setPitch(rotationPitch); | ||
ev.setYaw(rotationYaw); | ||
if (ClientProxy.virtual.getContainer().isPlayingback() && ControlByteHandler.shouldInterpolate) { | ||
TickInputContainer input = ClientProxy.virtual.getContainer().get(ClientProxy.virtual.getContainer().index()); | ||
if (input == null) return; | ||
float nextPitch = input.getSubticks().getPitch(); | ||
float nextYaw = input.getSubticks().getYaw(); | ||
ev.setPitch((float) MathHelper.clampedLerp(rotationPitch, nextPitch, ((AccessorRunStuff) Minecraft.getMinecraft()).timer().renderPartialTicks)); | ||
ev.setYaw((float) MathHelper.clampedLerp(rotationYaw, nextYaw+180, ((AccessorRunStuff) Minecraft.getMinecraft()).timer().renderPartialTicks)); | ||
} else { | ||
ev.setPitch(rotationPitch); | ||
ev.setYaw(rotationYaw); | ||
} | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.