Skip to content

Commit

Permalink
Update to Alpha7
Browse files Browse the repository at this point in the history
  • Loading branch information
Scribble authored Oct 24, 2021
2 parents da54730 + f1c29de commit 28e96e0
Show file tree
Hide file tree
Showing 20 changed files with 824 additions and 377 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apply plugin: 'org.spongepowered.mixin'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


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

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/de/scribble/lp/tasmod/TASmod.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import de.scribble.lp.tasmod.commands.recording.CommandRecord;
import de.scribble.lp.tasmod.commands.savetas.CommandSaveTAS;
import de.scribble.lp.tasmod.commands.tutorial.CommandPlaybacktutorial;
import de.scribble.lp.tasmod.savestates.server.SavestateCommand;
import de.scribble.lp.tasmod.savestates.server.SavestateHandler;
import de.scribble.lp.tasmod.savestates.server.SavestateTrackerFile;
import de.scribble.lp.tasmod.tickratechanger.CommandTickrate;
import de.scribble.lp.tasmod.util.ModIncompatibleException;
Expand Down Expand Up @@ -53,6 +55,8 @@ public class TASmod {
public static final Logger logger = LogManager.getLogger("TASMod");

public static ContainerStateServer containerStateServer;

public static SavestateHandler savestateHandler;

@EventHandler
public void preInit(FMLPreInitializationEvent ev) throws Exception {
Expand Down Expand Up @@ -99,6 +103,7 @@ public void serverStart(FMLServerStartingEvent ev) {
ev.registerServerCommand(new CommandPlaybacktutorial());
ev.registerServerCommand(new CommandFolder());
ev.registerServerCommand(new CommandClearInputs());
ev.registerServerCommand(new SavestateCommand());

// Save Loadstate Count
File savestateDirectory = new File(serverInstance.getDataDirectory() + File.separator + "saves" + File.separator + "savestates" + File.separator);
Expand All @@ -107,6 +112,8 @@ public void serverStart(FMLServerStartingEvent ev) {
} catch (IOException e) {
e.printStackTrace();
}

savestateHandler=new SavestateHandler(ev.getServer());
}

public static TASmod getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
public class KeybindingEvents {

public static void fireKeybindingsEvent() {
VirtualKeybindings.increaseCooldowntimer();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class InputContainer {
private BigArrayList<TickInputContainer> inputs = new BigArrayList<TickInputContainer>(directory + File.separator + "temp");

public DesyncMonitoring dMonitor = new DesyncMonitoring();

// =====================================================================================================

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

@Deprecated
public String setRecording(boolean enabled) {
return setRecording(enabled, true);
}

/**
* Starts/Stops a recording
*
* @param enabled If true: starts a recording, else stops a running recording
* @return Chat message depending on the state
*/
@Deprecated
public String setRecording(boolean enabled, boolean verbose) {
if (state == TASstate.PLAYBACK) {
return verbose ? TextFormatting.RED + "A playback is already running" : "";
}
if (enabled) {
state = TASstate.RECORDING;
} else {
state = TASstate.NONE;
}

if (state == TASstate.RECORDING) {
if (Minecraft.getMinecraft().player != null) {
startLocation = getStartLocation(Minecraft.getMinecraft().player); // TODO #99 Make this a secondary command
}
return verbose ? TextFormatting.GREEN + "Starting the recording" : "";
} else if (state == TASstate.NONE) {
return verbose ? TextFormatting.GREEN + "Stopping the recording" : "";
}
return "";
}

@Deprecated
public String setPlayback(boolean enabled) {
return setPlayback(enabled, true);
}

/**
* Starts/Stops a playback
*
* @param enabled If true: start a playback, else aborts a running playback
* @return Chat message depending on the state
*/
@Deprecated
public String setPlayback(boolean enabled, boolean verbose) {
if (state == TASstate.RECORDING)
return verbose ? TextFormatting.RED + "A recording is already running" : "";
if (enabled) {
state = TASstate.PLAYBACK;
} else {
state = TASstate.NONE;
}
if (state == TASstate.PLAYBACK) {
if (Minecraft.getMinecraft().player != null && !startLocation.isEmpty()) {
try {
tpPlayer(startLocation);
} catch (NumberFormatException e) {
state = TASstate.NONE;
e.printStackTrace();
return verbose ? TextFormatting.RED + "An error occured while reading the start location of the TAS. The file might be broken" : "";
}
}
index = 0;
return verbose ? TextFormatting.GREEN + "Starting playback" : "";
} else {
return verbose ? TextFormatting.GREEN + "Aborting playback" : "";
}
}

// =====================================================================================================
// Methods to update the temporary variables of the container.
// These act as an input and output, depending if a recording or a playback is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public long modifyMSPT(long fiftyLong) {
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;tick()V", ordinal = 1))
public void redirectTick(MinecraftServer server) {
this.tick();
if (SavestateHandler.state == SavestateState.WASLOADING) {
SavestateHandler.state = SavestateState.NONE;
if (TASmod.savestateHandler.state == SavestateState.WASLOADING) {
TASmod.savestateHandler.state = SavestateState.NONE;
SavestateHandler.playerLoadSavestateEventServer();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.scribble.lp.tasmod.mixin;
package de.scribble.lp.tasmod.mixin.fixes;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.scribble.lp.tasmod.mixin.fixes;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import de.scribble.lp.tasmod.ClientProxy;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.GameSettings;

@Mixin(Minecraft.class)
public class MixinMinecraftFullscreen {

@Shadow
private GameSettings gameSettings;

@Inject(method = "toggleFullscreen", at = @At("RETURN"))
public void inject_toggleFullscreen(CallbackInfo ci) {
int keyF11=this.gameSettings.keyBindFullscreen.getKeyCode();
ClientProxy.virtual.getNextKeyboard().get(keyF11).setPressed(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

public class GuiSavestateSavingScreen extends GuiScreen{


@Override
public void initGui() {
this.mc=Minecraft.getMinecraft();
super.initGui();
}

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,30 @@

public class LoadstatePacket implements IMessage{

public int index;

/**
* Load a savestate at the current index
*/
public LoadstatePacket() {
index=-1;
}

/**
* Load the savestate at the specified index
* @param index The index to load the savestate
*/
public LoadstatePacket(int index) {
this.index = index;
}

@Override
public void fromBytes(ByteBuf buf) {
index=buf.readInt();
}

@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(index);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.scribble.lp.tasmod.savestates.server;

import de.scribble.lp.tasmod.TASmod;
import de.scribble.lp.tasmod.savestates.server.chunkloading.SavestatesChunkControl;
import de.scribble.lp.tasmod.savestates.server.exceptions.LoadstateException;
import net.minecraft.client.Minecraft;
Expand All @@ -22,15 +23,14 @@ public IMessage onMessage(LoadstatePacket message, MessageContext ctx) {
return;
}
try {
SavestateHandler.loadState();
TASmod.savestateHandler.loadState(message.index);
} catch (LoadstateException e) {
player.sendMessage(new TextComponentString(TextFormatting.RED+"Failed to load a savestate: "+e.getMessage()));

} catch (Exception e) {
player.sendMessage(new TextComponentString(TextFormatting.RED+"Failed to load a savestate: "+e.getCause().toString()));
e.printStackTrace();
} finally {
SavestateHandler.state=SavestateState.NONE;
TASmod.savestateHandler.state=SavestateState.NONE;
}
});
}else {
Expand Down
Loading

0 comments on commit 28e96e0

Please sign in to comment.