Skip to content

Commit 55d561d

Browse files
ScribblePancakeTAS
authored andcommitted
Updated some things
-Updated aim assist a bit -Activate aim assist by default in tickrate 0 -Redone messages when recording Closes #18
1 parent 11067cb commit 55d561d

File tree

10 files changed

+29
-50
lines changed

10 files changed

+29
-50
lines changed

src/main/java/de/pfannekuchen/tasmod/events/AimAssistEvents.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import de.pfannekuchen.tasmod.utils.PlayerPositionCalculator;
44
import de.scribble.lp.tasmod.ClientProxy;
5+
import de.scribble.lp.tasmod.tickratechanger.TickrateChangerClient;
6+
import de.scribble.lp.tasmod.virtual.VirtualKeybindings;
57
import net.minecraft.client.Minecraft;
68
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
79
import net.minecraftforge.client.event.RenderGameOverlayEvent;
@@ -10,7 +12,6 @@
1012
public class AimAssistEvents {
1113

1214
public static boolean showNewPos;
13-
public static float das = 0f;
1415

1516
@SubscribeEvent
1617
public void ingameOverlay(RenderGameOverlayEvent ev) {
@@ -32,17 +33,14 @@ public void blockOverlay(DrawBlockHighlightEvent ev) {
3233
Minecraft mc = Minecraft.getMinecraft();
3334

3435
// Toggle
35-
if (ClientProxy.showNextLocation.isPressed() && das <= 0) {
36-
das = 60f;
36+
if (VirtualKeybindings.isKeyDown(ClientProxy.showNextLocation)) {
3737
showNewPos = !showNewPos;
3838
}
3939

40-
das--;
41-
4240
if (mc.world == null) return;
43-
if (AimAssistEvents.showNewPos) {
41+
if (TickrateChangerClient.TICKS_PER_SECOND == 0) {
4442
PlayerPositionCalculator.calculateNextPosition(mc, mc.player);
45-
ev.setCanceled(true);
43+
ev.setCanceled(true);
4644
}
4745
}
4846

src/main/java/de/pfannekuchen/tasmod/utils/PlayerPositionCalculator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ else if (!source.isSneaking() && source.height != 1.65F)
339339
else
340340
{
341341
float f2 = source.rotationPitch;
342-
float f1 = source.rotationYawHead;
342+
float f1 = source.rotationYaw;
343343
vec3d1 = source.getVectorForRotation(f2, f1);
344344
}
345345

src/main/java/de/scribble/lp/tasmod/ClientProxy.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import de.pfannekuchen.tasmod.events.AimAssistEvents;
66
import de.scribble.lp.tasmod.savestates.SavestateHandlerClient;
77
import de.scribble.lp.tasmod.tutorial.TutorialHandler;
8-
import de.scribble.lp.tasmod.virtual.VirtualKeybindings;
98
import net.minecraft.client.settings.KeyBinding;
109
import net.minecraft.launchwrapper.Launch;
1110
import net.minecraftforge.common.MinecraftForge;

src/main/java/de/scribble/lp/tasmod/ModLoader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import de.scribble.lp.tasmod.playback.CommandPlay;
77
import de.scribble.lp.tasmod.recording.CommandRecord;
8-
import de.scribble.lp.tasmod.savestates.SavestateHandlerClient;
98
import de.scribble.lp.tasmod.tickratechanger.CommandTickrate;
109
import de.scribble.lp.tasmod.tutorial.CommandPlaybacktutorial;
1110
import net.minecraft.server.MinecraftServer;

src/main/java/de/scribble/lp/tasmod/playback/CommandPlay.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.File;
44
import java.util.ArrayList;
55
import java.util.List;
6-
import java.util.Random;
76

87
import com.google.common.collect.ImmutableList;
98

@@ -80,10 +79,9 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
8079
TickSyncServer.resetTickCounter();
8180
CommonProxy.NETWORK.sendToAll(new TickSyncPackage(TickSyncServer.getServertickcounter(),true,TickSyncServer.isEnabled()));
8281
InputPlayback.startPlayback(file,args[0]);
83-
sender.sendMessage(new TextComponentString("Playback started"));
8482
return;
8583
} else if (args.length == 2 && !args[1].equalsIgnoreCase("load")) {
86-
sender.sendMessage(new TextComponentString(TextFormatting.RED + "Wrong usage! /play <filename> (load)"));
84+
sender.sendMessage(new TextComponentString(TextFormatting.RED + "Wrong usage! /play <filename>"));
8785
return;
8886
}
8987
} else {
@@ -96,7 +94,6 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
9694
return;
9795
} else if(InputPlayback.isPlayingback()){
9896
InputPlayback.stopPlayback();
99-
sender.sendMessage(new TextComponentString("Playback finished"));
10097

10198
//String[] sentences = new String[] {"I have finished my TAS", "Thats time!", "Playback done, where's the money?", "Im done, what's next?"};
10299
//Minecraft.getMinecraft().player.sendChatMessage(sentences[new Random().nextInt(sentences.length)]); // Uwot here he is using Random!!!

src/main/java/de/scribble/lp/tasmod/playback/InputPlayback.java

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.io.IOException;
77
import java.util.ArrayList;
88
import java.util.List;
9-
import java.util.Random;
109

1110
import org.apache.logging.log4j.LogManager;
1211
import org.apache.logging.log4j.Logger;
@@ -22,6 +21,7 @@
2221
import de.scribble.lp.tasmod.virtual.VirtualSubticks;
2322
import net.minecraft.client.Minecraft;
2423
import net.minecraft.util.text.TextComponentString;
24+
import net.minecraft.util.text.TextFormatting;
2525

2626
/**
2727
* Takes a file and produces VirtualEvents that can be presses in the VirtualMouseAndKeyboard
@@ -30,6 +30,7 @@
3030
*
3131
*/
3232
public class InputPlayback {
33+
private static Minecraft mc= Minecraft.getMinecraft();
3334
private static boolean playingback;
3435
private static Logger logger= LogManager.getLogger("InputPlayback");
3536
private static File fileLocation;
@@ -51,15 +52,18 @@ public static void startPlayback(File file, String filename) {
5152
}catch (IOException e){
5253
logger.error("Cannot read the tasfile "+filename);
5354
e.printStackTrace();
55+
mc.player.sendMessage(new TextComponentString(e.getMessage()));
5456
return;
5557
}
5658
try {
5759
readInputs();
5860
} catch (IOException e) {
5961
logger.error("Cannot read the tasfile "+filename);
6062
e.printStackTrace();
63+
mc.player.sendMessage(new TextComponentString(TextFormatting.RED+e.getMessage()));
6164
return;
6265
}
66+
mc.player.sendMessage(new TextComponentString("Playback started"));
6367
playingback=true;
6468
playbackIndex=-1;
6569
subtickPlaybackindex=-1;
@@ -121,6 +125,7 @@ public static void stopPlayback() {
121125
inputList=new ArrayList<TickFrame>();
122126
subtickList=new ArrayList<VirtualSubticks>();
123127
VirtualMouseAndKeyboard.unpressEverything();
128+
mc.player.sendMessage(new TextComponentString("Playback finished"));
124129
// RandomLogger.stopRandomLogging();
125130
}
126131
}
@@ -219,8 +224,7 @@ private static void readInputs() throws IOException {
219224
}else {
220225
//Errorhandling
221226
buff.close();
222-
logger.error("Error while reading 'Everything related to keyboard' in " + Filename + " in line " + linecounter+". Keyboard, KeyboardState and CharTyped always need to have the same number of inputs");
223-
throw new IOException();
227+
throw new IOException("Error while reading 'Everything related to keyboard' in " + Filename + " in line " + linecounter+". Keyboard, KeyboardState and CharTyped always need to have the same number of inputs");
224228
}
225229

226230
//Same as the keyboard but with the mouse
@@ -233,8 +237,7 @@ private static void readInputs() throws IOException {
233237

234238
}else {
235239
buff.close();
236-
logger.error("Error while reading 'Everything related to mouse' in " + Filename + " in line " + linecounter+". Mouse, MouseStates, ScrollWheel, DeltaX, DeltaY, MouseX, MouseY and slotID always need to have the same number of inputs");
237-
throw new IOException();
240+
throw new IOException("Error while reading 'Everything related to mouse' in " + Filename + " in line " + linecounter+". Mouse, MouseStates, ScrollWheel, DeltaX, DeltaY, MouseX, MouseY and slotID always need to have the same number of inputs");
238241
}
239242
//Adding every keyboard an mouse event from the current tick into yet another list that contains every input from every tick
240243
inputList.add(new TickFrame(tick, keyboardEvents, mouseEvents));
@@ -248,8 +251,7 @@ private static void readInputs() throws IOException {
248251
/*The following methods take different sections of the line and interpret them. Returns all inputs as a list*/
249252
private static int getTickCounter(String[] sections, int linecounter, int sectionnumber) throws IOException {
250253
if(sections[sectionnumber].isEmpty()) {
251-
logger.error("Error while reading tickcounter in "+Filename+ " in line "+linecounter+"and the input in position "+1+" from the left. The input is empty!");
252-
throw new IOException();
254+
throw new IOException("Error while reading tickcounter in "+Filename+ " in line "+linecounter+"and the input in position "+1+" from the left. The input is empty!");
253255
}else {
254256
int counter=getNumber("tickcounter", sections[sectionnumber], linecounter, 0);
255257
return counter;
@@ -271,8 +273,7 @@ private static List<Integer> getKeyboardPresses(String[] sections, int linecount
271273
if(VirtualMouseAndKeyboard.getKeyCodeFromKeyName(keys[i])!=-1) {
272274
out.add(VirtualMouseAndKeyboard.getKeyCodeFromKeyName(keys[i]));
273275
} else{
274-
logger.error("Error while reading 'Keyboard' in "+Filename+ " in line "+linecounter+" and the input in position "+(i+1)+" from the left. Couldn't find the key "+keys[i]+".");
275-
throw new IOException();
276+
throw new IOException("Error while reading 'Keyboard' in "+Filename+ " in line "+linecounter+" and the input in position "+(i+1)+" from the left. Couldn't find the key "+keys[i]+".");
276277
}
277278
}
278279
}
@@ -294,10 +295,9 @@ private static List<Boolean> getKeyboardStates(String[] sections, int linecounte
294295
if (keys[i].contentEquals("true")||keys[i].contentEquals("false")) {
295296
out.add(Boolean.parseBoolean(keys[i]));
296297
} else {
297-
logger.error("Error while reading 'KeyboardState' in " + Filename + " in line " + linecounter
298+
throw new IOException("Error while reading 'KeyboardState' in " + Filename + " in line " + linecounter
298299
+ " and the key in position " + (i + 1) + " from the left. Input is not true or false: '"
299300
+ keys[i] + "'");
300-
throw new IOException();
301301
}
302302
}
303303
}
@@ -315,8 +315,6 @@ private static List<Character> getCharTyped(String[] sections, int linecounter,
315315
for (int j = 0; j < chars.length; j++) {
316316
out.add(chars[j]);
317317
}
318-
319-
320318
}
321319
return out;
322320
}
@@ -338,10 +336,9 @@ private static List<Integer> getMouseButtonPresses(String[] sections, int lineco
338336
if (VirtualMouseAndKeyboard.getKeyCodeFromKeyName(keys[i]) != -1) {
339337
out.add(VirtualMouseAndKeyboard.getKeyCodeFromKeyName(keys[i]));
340338
} else {
341-
logger.error("Error while reading 'Mouse' in " + Filename + " in line " + linecounter
339+
throw new IOException("Error while reading 'Mouse' in " + Filename + " in line " + linecounter
342340
+ " and the key in position " + (i + 1) + " from the left. Couldn't find the key "
343341
+ keys[i]);
344-
throw new IOException();
345342
}
346343
}
347344
}
@@ -363,10 +360,9 @@ private static List<Boolean> getMouseStates(String[] sections, int linecounter,
363360
if (keys[i].contentEquals("true")||keys[i].contentEquals("false")) {
364361
out.add(Boolean.parseBoolean(keys[i]));
365362
} else {
366-
logger.error("Error while reading 'MouseState' in " + Filename + " in line " + linecounter
363+
throw new IOException("Error while reading 'MouseState' in " + Filename + " in line " + linecounter
367364
+ " and the key in position " + (i + 1) + " from the left. Input is not true or false: '"
368365
+ keys[i] + "'");
369-
throw new IOException();
370366
}
371367
}
372368
}
@@ -476,8 +472,7 @@ private static int getNumber(String name, String number, int linecounter, int po
476472
try {
477473
counter=Integer.parseInt(number);
478474
} catch (NumberFormatException e) {
479-
logger.error("Error while reading "+name+" in "+Filename+ " in line "+linecounter+" and the input in position "+(position+1)+" from the left. The input doesn't contain a number ("+number+")");
480-
throw new IOException();
475+
throw new IOException("Error while reading "+name+" in "+Filename+ " in line "+linecounter+" and the input in position "+(position+1)+" from the left. The input doesn't contain a number ("+number+")");
481476
}
482477
return counter;
483478
}
@@ -495,8 +490,7 @@ private static float getFloat(String name, String floatnumber, int linecounter,
495490
try {
496491
counter=Float.parseFloat(floatnumber);
497492
}catch (NumberFormatException e) {
498-
logger.error("Error while reading "+name+" in "+Filename+ " in line "+linecounter+" and the input in position "+(position+1)+" from the left. The input doesn't contain a number type float ("+floatnumber+")");
499-
throw new IOException();
493+
throw new IOException("Error while reading "+name+" in "+Filename+ " in line "+linecounter+" and the input in position "+(position+1)+" from the left. The input doesn't contain a number type float ("+floatnumber+")");
500494
}
501495
return counter;
502496
}
@@ -505,8 +499,7 @@ private static double getDouble(String name, String doublenumber, int linecounte
505499
try {
506500
counter=Double.parseDouble(doublenumber);
507501
}catch (NumberFormatException e) {
508-
logger.error("Error while reading "+name+" in "+Filename+ " in line "+linecounter+" and the input in position "+(position+1)+" from the left. The input doesn't contain a number of type double ("+doublenumber+")");
509-
throw new IOException();
502+
throw new IOException("Error while reading "+name+" in "+Filename+ " in line "+linecounter+" and the input in position "+(position+1)+" from the left. The input doesn't contain a number of type double ("+doublenumber+")");
510503
}
511504
return counter;
512505
}
@@ -520,7 +513,7 @@ private static float getPitch(String[] sections, int linecounter, int sectionnum
520513
sections[sectionnumber]=sections[sectionnumber].replace("Pitch:", "");
521514
}
522515
if(sections[sectionnumber].isEmpty()) {
523-
logger.error("Error while reading pitch in "+Filename+ " in line "+linecounter+". The input is empty!");
516+
throw new IOException("Error while reading pitch in "+Filename+ " in line "+linecounter+". The input is empty!");
524517
}else {
525518
x=getFloat("Pitch", sections[sectionnumber], linecounter, 1);
526519
}
@@ -532,7 +525,7 @@ private static float getYaw(String[] sections, int linecounter, int sectionnumbe
532525
sections[sectionnumber]=sections[sectionnumber].replace("Yaw:", "");
533526
}
534527
if(sections[sectionnumber].isEmpty()) {
535-
logger.error("Error while reading yaw in "+Filename+ " in line "+linecounter+". The input is empty!");
528+
throw new IOException("Error while reading yaw in "+Filename+ " in line "+linecounter+". The input is empty!");
536529
}else {
537530
y=getFloat("Yaw", sections[sectionnumber], linecounter, 1);
538531
}

src/main/java/de/scribble/lp/tasmod/recording/CommandRecord.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,12 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
7979
} catch (FileNotFoundException e) {
8080
e.printStackTrace();
8181
}
82-
sender.sendMessage(new TextComponentString("Recording started"));
8382
}
8483
if (args.length > 1) {
8584
sender.sendMessage(new TextComponentString(TextFormatting.RED + "Too many arguments"));
8685
}
8786
} else if (InputRecorder.isRecording()) {
8887
InputRecorder.stopRecording();
89-
sender.sendMessage(new TextComponentString("Recording stopped"));
9088
} else {
9189
sender.sendMessage(new TextComponentString(TextFormatting.RED + "A playback is running. /play to abort"));
9290
}

src/main/java/de/scribble/lp/tasmod/recording/InputRecorder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.apache.commons.lang3.StringUtils;
88
import org.apache.logging.log4j.LogManager;
99
import org.apache.logging.log4j.Logger;
10-
import org.lwjgl.input.Keyboard;
1110
import org.lwjgl.opengl.Display;
1211

1312
import de.scribble.lp.tasmod.ClientProxy;
@@ -19,6 +18,7 @@
1918
import de.scribble.lp.tasmod.virtual.VirtualMouseEvent;
2019
import de.scribble.lp.tasmod.virtual.VirtualSubticks;
2120
import net.minecraft.client.Minecraft;
21+
import net.minecraft.util.text.TextComponentString;
2222

2323
/**
2424
* Takes keys from the VirtualMouseAndKeyboard and adds them to a file
@@ -56,6 +56,7 @@ public static void startRecording() throws FileNotFoundException {
5656
public static void startRecording(String filename) throws FileNotFoundException {
5757
if (!recording) {
5858
makeTASDir();
59+
mc.player.sendMessage(new TextComponentString("Recording started"));
5960
File files = interpretFilename(filename);
6061
if (files == null) {
6162
logger.error("The filename is not applicable");
@@ -256,10 +257,10 @@ public static void stopRecording() {
256257
if (TutorialHandler.istutorial && tutorial.getState() == 4) {
257258
tutorial.advanceState();
258259
}
260+
mc.player.sendMessage(new TextComponentString("Recording stopped"));
259261
fileThread.close();
260262
// Thread t2 = new Thread(new FileWriterThread(outputSubtick, fileLocationSubTick, logger), "FileWriterThreadSubtick");
261263
// t2.start();
262-
// RandomLogger.stopRandomLogging();
263264
} else {
264265
logger.error("There is no recording that can be aborted!");
265266
}

src/main/java/de/scribble/lp/tasmod/tickratechanger/TickrateChangerClient.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package de.scribble.lp.tasmod.tickratechanger;
22

3-
import org.lwjgl.input.Keyboard;
4-
53
import de.scribble.lp.tasmod.ClientProxy;
64
import de.scribble.lp.tasmod.CommonProxy;
75
import de.scribble.lp.tasmod.virtual.VirtualKeybindings;

src/main/java/de/scribble/lp/tasmod/virtual/VirtualKeybindings.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
package de.scribble.lp.tasmod.virtual;
22

3-
import java.util.ArrayList;
43
import java.util.HashMap;
5-
import java.util.List;
6-
import java.util.Stack;
74

85
import org.lwjgl.input.Keyboard;
96

107
import com.google.common.collect.Maps;
118

129
import net.minecraft.client.settings.KeyBinding;
13-
import net.minecraft.util.IntHashMap;
1410

1511
/**
1612
* Transforms certain Minecraft keybindings to keybindings checked by LWJGL's isKeyDown method. <br>
@@ -19,7 +15,7 @@
1915
*
2016
*/
2117
public class VirtualKeybindings {
22-
private static final int standardCooldown=10;
18+
private static final long standardCooldown=20;
2319
private static HashMap<KeyBinding, Long> cooldownHashMap=Maps.<KeyBinding, Long>newHashMap();
2420
private static long cooldowntimer=0;
2521

0 commit comments

Comments
 (0)