Skip to content

Commit 28e96e0

Browse files
author
Scribble
authored
Update to Alpha7
2 parents da54730 + f1c29de commit 28e96e0

20 files changed

+824
-377
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ apply plugin: 'org.spongepowered.mixin'
1919
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
2020

2121

22-
version = "Alpha7-WIP"
22+
version = "Alpha7"
2323
group = "de.scribble.lp.tastools" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
2424
archivesBaseName = "TASmod-1.12.2"
2525

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import de.scribble.lp.tasmod.commands.recording.CommandRecord;
1616
import de.scribble.lp.tasmod.commands.savetas.CommandSaveTAS;
1717
import de.scribble.lp.tasmod.commands.tutorial.CommandPlaybacktutorial;
18+
import de.scribble.lp.tasmod.savestates.server.SavestateCommand;
19+
import de.scribble.lp.tasmod.savestates.server.SavestateHandler;
1820
import de.scribble.lp.tasmod.savestates.server.SavestateTrackerFile;
1921
import de.scribble.lp.tasmod.tickratechanger.CommandTickrate;
2022
import de.scribble.lp.tasmod.util.ModIncompatibleException;
@@ -53,6 +55,8 @@ public class TASmod {
5355
public static final Logger logger = LogManager.getLogger("TASMod");
5456

5557
public static ContainerStateServer containerStateServer;
58+
59+
public static SavestateHandler savestateHandler;
5660

5761
@EventHandler
5862
public void preInit(FMLPreInitializationEvent ev) throws Exception {
@@ -99,6 +103,7 @@ public void serverStart(FMLServerStartingEvent ev) {
99103
ev.registerServerCommand(new CommandPlaybacktutorial());
100104
ev.registerServerCommand(new CommandFolder());
101105
ev.registerServerCommand(new CommandClearInputs());
106+
ev.registerServerCommand(new SavestateCommand());
102107

103108
// Save Loadstate Count
104109
File savestateDirectory = new File(serverInstance.getDataDirectory() + File.separator + "saves" + File.separator + "savestates" + File.separator);
@@ -107,6 +112,8 @@ public void serverStart(FMLServerStartingEvent ev) {
107112
} catch (IOException e) {
108113
e.printStackTrace();
109114
}
115+
116+
savestateHandler=new SavestateHandler(ev.getServer());
110117
}
111118

112119
public static TASmod getInstance() {

src/main/java/de/scribble/lp/tasmod/events/KeybindingEvents.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
public class KeybindingEvents {
2020

2121
public static void fireKeybindingsEvent() {
22-
VirtualKeybindings.increaseCooldowntimer();
2322

2423
if (VirtualKeybindings.isKeyDownExceptTextfield(ClientProxy.savestateSaveKey)) {
2524

src/main/java/de/scribble/lp/tasmod/inputcontainer/InputContainer.java

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class InputContainer {
6868
private BigArrayList<TickInputContainer> inputs = new BigArrayList<TickInputContainer>(directory + File.separator + "temp");
6969

7070
public DesyncMonitoring dMonitor = new DesyncMonitoring();
71-
71+
7272
// =====================================================================================================
7373

7474
private String authors = "Insert author here";
@@ -123,6 +123,7 @@ public String setTASState(TASstate stateIn, boolean verbose) {
123123
return verbose ? TextFormatting.RED + "An error occured while reading the start location of the TAS. The file might be broken" : "";
124124
}
125125
}
126+
Minecraft.getMinecraft().gameSettings.chatLinks = false; // #119
126127
index = 0;
127128
state = TASstate.PLAYBACK;
128129
return verbose ? TextFormatting.GREEN + "Starting playback" : "";
@@ -177,76 +178,6 @@ public TASstate getState() {
177178
return state;
178179
}
179180

180-
@Deprecated
181-
public String setRecording(boolean enabled) {
182-
return setRecording(enabled, true);
183-
}
184-
185-
/**
186-
* Starts/Stops a recording
187-
*
188-
* @param enabled If true: starts a recording, else stops a running recording
189-
* @return Chat message depending on the state
190-
*/
191-
@Deprecated
192-
public String setRecording(boolean enabled, boolean verbose) {
193-
if (state == TASstate.PLAYBACK) {
194-
return verbose ? TextFormatting.RED + "A playback is already running" : "";
195-
}
196-
if (enabled) {
197-
state = TASstate.RECORDING;
198-
} else {
199-
state = TASstate.NONE;
200-
}
201-
202-
if (state == TASstate.RECORDING) {
203-
if (Minecraft.getMinecraft().player != null) {
204-
startLocation = getStartLocation(Minecraft.getMinecraft().player); // TODO #99 Make this a secondary command
205-
}
206-
return verbose ? TextFormatting.GREEN + "Starting the recording" : "";
207-
} else if (state == TASstate.NONE) {
208-
return verbose ? TextFormatting.GREEN + "Stopping the recording" : "";
209-
}
210-
return "";
211-
}
212-
213-
@Deprecated
214-
public String setPlayback(boolean enabled) {
215-
return setPlayback(enabled, true);
216-
}
217-
218-
/**
219-
* Starts/Stops a playback
220-
*
221-
* @param enabled If true: start a playback, else aborts a running playback
222-
* @return Chat message depending on the state
223-
*/
224-
@Deprecated
225-
public String setPlayback(boolean enabled, boolean verbose) {
226-
if (state == TASstate.RECORDING)
227-
return verbose ? TextFormatting.RED + "A recording is already running" : "";
228-
if (enabled) {
229-
state = TASstate.PLAYBACK;
230-
} else {
231-
state = TASstate.NONE;
232-
}
233-
if (state == TASstate.PLAYBACK) {
234-
if (Minecraft.getMinecraft().player != null && !startLocation.isEmpty()) {
235-
try {
236-
tpPlayer(startLocation);
237-
} catch (NumberFormatException e) {
238-
state = TASstate.NONE;
239-
e.printStackTrace();
240-
return verbose ? TextFormatting.RED + "An error occured while reading the start location of the TAS. The file might be broken" : "";
241-
}
242-
}
243-
index = 0;
244-
return verbose ? TextFormatting.GREEN + "Starting playback" : "";
245-
} else {
246-
return verbose ? TextFormatting.GREEN + "Aborting playback" : "";
247-
}
248-
}
249-
250181
// =====================================================================================================
251182
// Methods to update the temporary variables of the container.
252183
// These act as an input and output, depending if a recording or a playback is

src/main/java/de/scribble/lp/tasmod/mixin/MixinMinecraftServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public long modifyMSPT(long fiftyLong) {
3737
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;tick()V", ordinal = 1))
3838
public void redirectTick(MinecraftServer server) {
3939
this.tick();
40-
if (SavestateHandler.state == SavestateState.WASLOADING) {
41-
SavestateHandler.state = SavestateState.NONE;
40+
if (TASmod.savestateHandler.state == SavestateState.WASLOADING) {
41+
TASmod.savestateHandler.state = SavestateState.NONE;
4242
SavestateHandler.playerLoadSavestateEventServer();
4343
}
4444

src/main/java/de/scribble/lp/tasmod/mixin/MixinDragonFightManager.java renamed to src/main/java/de/scribble/lp/tasmod/mixin/fixes/MixinDragonFightManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package de.scribble.lp.tasmod.mixin;
1+
package de.scribble.lp.tasmod.mixin.fixes;
22

33
import org.spongepowered.asm.mixin.Mixin;
44
import org.spongepowered.asm.mixin.Shadow;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package de.scribble.lp.tasmod.mixin.fixes;
2+
3+
import org.spongepowered.asm.mixin.Mixin;
4+
import org.spongepowered.asm.mixin.Shadow;
5+
import org.spongepowered.asm.mixin.injection.At;
6+
import org.spongepowered.asm.mixin.injection.Inject;
7+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
8+
9+
import de.scribble.lp.tasmod.ClientProxy;
10+
import net.minecraft.client.Minecraft;
11+
import net.minecraft.client.settings.GameSettings;
12+
13+
@Mixin(Minecraft.class)
14+
public class MixinMinecraftFullscreen {
15+
16+
@Shadow
17+
private GameSettings gameSettings;
18+
19+
@Inject(method = "toggleFullscreen", at = @At("RETURN"))
20+
public void inject_toggleFullscreen(CallbackInfo ci) {
21+
int keyF11=this.gameSettings.keyBindFullscreen.getKeyCode();
22+
ClientProxy.virtual.getNextKeyboard().get(keyF11).setPressed(false);
23+
}
24+
}

src/main/java/de/scribble/lp/tasmod/savestates/server/GuiSavestateSavingScreen.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77

88
public class GuiSavestateSavingScreen extends GuiScreen{
99

10-
10+
@Override
11+
public void initGui() {
12+
this.mc=Minecraft.getMinecraft();
13+
super.initGui();
14+
}
15+
1116
@Override
1217
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
1318
this.drawDefaultBackground();

src/main/java/de/scribble/lp/tasmod/savestates/server/LoadstatePacket.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,30 @@
55

66
public class LoadstatePacket implements IMessage{
77

8+
public int index;
9+
10+
/**
11+
* Load a savestate at the current index
12+
*/
813
public LoadstatePacket() {
14+
index=-1;
15+
}
16+
17+
/**
18+
* Load the savestate at the specified index
19+
* @param index The index to load the savestate
20+
*/
21+
public LoadstatePacket(int index) {
22+
this.index = index;
923
}
24+
1025
@Override
1126
public void fromBytes(ByteBuf buf) {
27+
index=buf.readInt();
1228
}
1329

1430
@Override
1531
public void toBytes(ByteBuf buf) {
32+
buf.writeInt(index);
1633
}
1734
}

src/main/java/de/scribble/lp/tasmod/savestates/server/LoadstatePacketHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package de.scribble.lp.tasmod.savestates.server;
22

3+
import de.scribble.lp.tasmod.TASmod;
34
import de.scribble.lp.tasmod.savestates.server.chunkloading.SavestatesChunkControl;
45
import de.scribble.lp.tasmod.savestates.server.exceptions.LoadstateException;
56
import net.minecraft.client.Minecraft;
@@ -22,15 +23,14 @@ public IMessage onMessage(LoadstatePacket message, MessageContext ctx) {
2223
return;
2324
}
2425
try {
25-
SavestateHandler.loadState();
26+
TASmod.savestateHandler.loadState(message.index);
2627
} catch (LoadstateException e) {
2728
player.sendMessage(new TextComponentString(TextFormatting.RED+"Failed to load a savestate: "+e.getMessage()));
28-
2929
} catch (Exception e) {
3030
player.sendMessage(new TextComponentString(TextFormatting.RED+"Failed to load a savestate: "+e.getCause().toString()));
3131
e.printStackTrace();
3232
} finally {
33-
SavestateHandler.state=SavestateState.NONE;
33+
TASmod.savestateHandler.state=SavestateState.NONE;
3434
}
3535
});
3636
}else {

0 commit comments

Comments
 (0)