Skip to content

Commit

Permalink
Added ingame tutorial
Browse files Browse the repository at this point in the history
Closed #11
Ready do realease the first alpha version I guess?
  • Loading branch information
Scribble authored and PancakeTAS committed Dec 16, 2020
1 parent f1a3481 commit 61cdd18
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 1 deletion.
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 = "Alpha1"
version = "Alpha2"
group = "de.scribble.lp.tastools" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "TASmod-1.12.2"

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/de/scribble/lp/tasmod/ClientProxy.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
package de.scribble.lp.tasmod;

import de.scribble.lp.tasmod.tutorial.TutorialHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

public class ClientProxy extends CommonProxy{

public static Configuration config;

static TutorialHandler playbackTutorial;

public void preInit(FMLPreInitializationEvent ev) {
config = new Configuration(ev.getSuggestedConfigurationFile());
Config.reloadClientConfig(config);
super.preInit(ev);
}
public void init(FMLInitializationEvent ev) {
playbackTutorial=new TutorialHandler((short)1);
MinecraftForge.EVENT_BUS.register(new InfoGui());
MinecraftForge.EVENT_BUS.register(playbackTutorial);

super.init(ev);
}
public void postInit(FMLPostInitializationEvent ev) {
super.postInit(ev);
}
public static TutorialHandler getPlaybackTutorial() {
return playbackTutorial;
}
}
15 changes: 15 additions & 0 deletions src/main/java/de/scribble/lp/tasmod/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package de.scribble.lp.tasmod;

import de.scribble.lp.tasmod.tutorial.TutorialHandler;
import net.minecraftforge.common.config.Configuration;

public class Config {
public static void reloadServerConfig(Configuration serverconfig) {

}
public static void reloadClientConfig(Configuration clientconfig) {
clientconfig.load();
TutorialHandler.istutorial=clientconfig.get("Tutorial","Enabled",true,"If the tutorial is enabled").getBoolean();
clientconfig.save();
}
}
2 changes: 2 additions & 0 deletions src/main/java/de/scribble/lp/tasmod/ModLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import de.scribble.lp.tasmod.recording.CommandRecord;
import de.scribble.lp.tasmod.tickratechanger.CommandTickrate;
import de.scribble.lp.tasmod.ticksync.CommandTickSync;
import de.scribble.lp.tasmod.tutorial.CommandPlaybacktutorial;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
Expand Down Expand Up @@ -60,6 +61,7 @@ public void serverStart(FMLServerStartingEvent ev) {
ev.registerServerCommand(new CommandTickSync());
ev.registerServerCommand(new CommandRecord());
ev.registerServerCommand(new CommandPlay());
ev.registerServerCommand(new CommandPlaybacktutorial());
}
public static ModLoader getInstance() {
return instance;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/de/scribble/lp/tasmod/playback/InputPlayback.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import de.scribble.lp.tasmod.ClientProxy;
import de.scribble.lp.tasmod.tutorial.TutorialHandler;
import de.scribble.lp.tasmod.virtual.VirtualKeyboardEvent;
import de.scribble.lp.tasmod.virtual.VirtualMouseAndKeyboard;
import de.scribble.lp.tasmod.virtual.VirtualMouseEvent;
Expand Down Expand Up @@ -48,6 +50,10 @@ public static void startPlayback(File file, String filename) {
playingback=true;
playbackIndex=-1;
subtickPlaybackindex=-1;
TutorialHandler tutorial= ClientProxy.getPlaybackTutorial();
if(tutorial.istutorial&&tutorial.getState()==6) {
tutorial.advanceState();
}
// Minecraft.getMinecraft().randommanager.setEntityRandomnessAll(0);
// RandomLogger.startRandomLogging();
}else {
Expand All @@ -56,6 +62,10 @@ public static void startPlayback(File file, String filename) {
}
public static void stopPlayback() {
if(isPlayingback()) {
TutorialHandler tutorial= ClientProxy.getPlaybackTutorial();
if(tutorial.istutorial&&tutorial.getState()==7) {
tutorial.advanceState();
}
playingback=false;
inputList=new ArrayList<TickFrame>();
subtickList=new ArrayList<VirtualSubticks>();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/de/scribble/lp/tasmod/recording/InputRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;

import de.scribble.lp.tasmod.ClientProxy;
import de.scribble.lp.tasmod.tutorial.TutorialHandler;
import de.scribble.lp.tasmod.virtual.VirtualKeyboardEvent;
import de.scribble.lp.tasmod.virtual.VirtualMouseAndKeyboard;
import de.scribble.lp.tasmod.virtual.VirtualMouseEvent;
Expand Down Expand Up @@ -59,6 +61,10 @@ public static void startRecording(String filename) {
// Minecraft.getMinecraft().randommanager.setEntityRandomnessAll(0);
// RandomLogger.startRandomLogging();
// new SavestateHandlerClient().saveState();
TutorialHandler tutorial= ClientProxy.getPlaybackTutorial();
if(tutorial.istutorial&&tutorial.getState()==3) {
tutorial.advanceState();
}
}else {
logger.error("There is already a recording running!");
}
Expand Down Expand Up @@ -195,6 +201,10 @@ public static void stopRecording() {
recording=false;
Thread t = new Thread(new FileWriterThread(output, fileLocation, logger), "FileWriterThreadTicks");
t.start();
TutorialHandler tutorial= ClientProxy.getPlaybackTutorial();
if(tutorial.istutorial&&tutorial.getState()==4) {
tutorial.advanceState();
}
// Thread t2 = new Thread(new FileWriterThread(outputSubtick, fileLocationSubTick, logger), "FileWriterThreadSubtick");
// t2.start();
// RandomLogger.stopRandomLogging();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package de.scribble.lp.tasmod.tutorial;

import de.scribble.lp.tasmod.ClientProxy;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;

public class CommandPlaybacktutorial extends CommandBase{

@Override
public String getName() {
return "playbacktutorial";
}

@Override
public String getUsage(ICommandSender sender) {
return "/playbacktutorial";
}

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if(sender instanceof EntityPlayer) {
if(!server.isDedicatedServer()) {
TutorialHandler handler=ClientProxy.getPlaybackTutorial();
if(handler.istutorial) {
handler.istutorial=false;
ClientProxy.config.get("Tutorial","Enabled",true,"If the tutorial is enabled").set(false);
ClientProxy.config.save();
}else {
handler.setState((short)1);
handler.istutorial=true;
}
}
}
}
}
Loading

0 comments on commit 61cdd18

Please sign in to comment.