Skip to content

Commit 953cd85

Browse files
ScribbleScribble
authored andcommitted
Documentation and messages for multiplayer
1 parent dc12b59 commit 953cd85

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public String getName() {
2424

2525
@Override
2626
public String getUsage(ICommandSender sender) {
27-
return "/play <true|false>";
27+
return "/play [true|false]";
2828
}
2929

3030
@Override
@@ -42,11 +42,13 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
4242
if (!(sender instanceof EntityPlayer)) {
4343
return;
4444
}
45-
// if (ClientProxy.virtual.getContainer().isPlayingback()) {
46-
// return;
47-
// }
45+
4846
if (args.length < 1) {
49-
CommonProxy.NETWORK.sendToServer(new PlaybackPacket(!ClientProxy.virtual.getContainer().isPlayingback()));
47+
if(!server.isDedicatedServer()) {
48+
CommonProxy.NETWORK.sendToServer(new PlaybackPacket(!ClientProxy.virtual.getContainer().isPlayingback()));
49+
} else {
50+
sender.sendMessage(new TextComponentString(TextFormatting.RED+"For multiplayer sessions use /play true|false to start/stop a playback"));
51+
}
5052
} else if (args.length == 1) {
5153
if (args[0].equalsIgnoreCase("true")) {
5254
CommonProxy.NETWORK.sendToAll(new PlaybackPacket(true));

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
4343
return;
4444
}
4545
if (args.length < 1) {
46-
CommonProxy.NETWORK.sendToServer(new RecordingPacket(!ClientProxy.virtual.getContainer().isRecording()));
46+
if (!server.isDedicatedServer()) {
47+
CommonProxy.NETWORK.sendToServer(new RecordingPacket(!ClientProxy.virtual.getContainer().isRecording()));
48+
} else {
49+
sender.sendMessage(new TextComponentString(TextFormatting.RED + "For multiplayer sessions use /play true|false to start/stop a recording"));
50+
}
4751
} else if (args.length == 1) {
4852
if (args[0].equalsIgnoreCase("true")) {
4953
CommonProxy.NETWORK.sendToAll(new RecordingPacket(true));

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,23 @@
5757
*/
5858
public class VirtualInput {
5959

60+
/**
61+
* The container where all inputs get stored during recording or stored and ready to be played back
62+
*/
6063
private InputContainer container = new InputContainer();
6164

6265
// ===========================Keyboard=================================
6366

67+
/**
68+
* The state of the keyboard recognized by the game. Updated on a tick basis <br>
69+
* See also: {@link VirtualInput}
70+
*/
6471
private VirtualKeyboard currentKeyboard = new VirtualKeyboard();
6572

73+
/**
74+
* The state of the keyboard which will replace {@linkplain VirtualInput#currentKeyboard} in the next tick. Updated every frame<br>
75+
* See also: {@link VirtualInput}
76+
*/
6677
private VirtualKeyboard nextKeyboard = new VirtualKeyboard();
6778

6879
private List<VirtualKeyboardEvent> currentKeyboardEvents = new ArrayList<VirtualKeyboardEvent>();
@@ -209,7 +220,7 @@ public List<String> getNextKeyboardPresses() {
209220

210221
private VirtualMouse currentMouse = new VirtualMouse();
211222

212-
public VirtualMouse nextMouse = new VirtualMouse();
223+
private VirtualMouse nextMouse = new VirtualMouse();
213224

214225
private List<VirtualMouseEvent> currentMouseEvents = new ArrayList<VirtualMouseEvent>();
215226
private Iterator<VirtualMouseEvent> currentMouseEventIterator = currentMouseEvents.iterator();
@@ -349,19 +360,31 @@ public float getSubtickYaw() {
349360
return currentSubtick.getYaw();
350361
}
351362

363+
// =====================================Container===========================================
364+
352365
public InputContainer getContainer() {
353366
return container;
354367
}
355368

369+
/**
370+
* Updates the input container and the {@link #nextKeyboard} as well as {@link #nextMouse}<br>
371+
* Gets executed each game tick
372+
*/
356373
public void updateContainer() {
357374
nextKeyboard = container.addKeyboardToContainer(nextKeyboard);
358375
nextMouse = container.addMouseToContainer(nextMouse);
359376
}
360377

378+
/**
379+
* Replaces the {@link #container}, used in
380+
* @param container to replace the current one
381+
*/
361382
public void setContainer(InputContainer container) {
362383
this.container = container;
363384
}
364385

386+
// =====================================Savestates===========================================
387+
365388
public void loadSavestate(InputContainer container) {
366389
if (this.container.isPlayingback()) {
367390
preloadInput(this.container, container.size() - 1);

0 commit comments

Comments
 (0)