Added some useful eel commands, and attempt at fix for reloading every restart.
This commit is contained in:
parent
40ca57331c
commit
8aaebfeb63
4 changed files with 140 additions and 1 deletions
|
@ -0,0 +1,4 @@
|
||||||
|
package techreborn.compat.ee3;
|
||||||
|
|
||||||
|
public class CommandCustomLoad {
|
||||||
|
}
|
64
src/main/java/techreborn/compat/ee3/CommandRegen.java
Normal file
64
src/main/java/techreborn/compat/ee3/CommandRegen.java
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
package techreborn.compat.ee3;
|
||||||
|
|
||||||
|
import com.pahimar.ee3.command.CommandSyncEnergyValues;
|
||||||
|
import com.pahimar.ee3.exchange.DynamicEnergyValueInitThread;
|
||||||
|
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
||||||
|
import com.pahimar.ee3.reference.Reference;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import net.minecraft.command.CommandBase;
|
||||||
|
import net.minecraft.command.ICommandSender;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class CommandRegen extends CommandBase {
|
||||||
|
|
||||||
|
public static final String EE3_ENERGYVALUES_DIR =
|
||||||
|
FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory()
|
||||||
|
+ File.separator +"data" + File.separator
|
||||||
|
+ Reference.LOWERCASE_MOD_ID + File.separator
|
||||||
|
+ "energyvalues";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandName()
|
||||||
|
{
|
||||||
|
return "eeregen";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRequiredPermissionLevel()
|
||||||
|
{
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandUsage(ICommandSender commandSender)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processCommand(ICommandSender commandSender, String[] args)
|
||||||
|
{
|
||||||
|
commandSender.addChatMessage(new ChatComponentText("Regening EMC Values..."));
|
||||||
|
File energyValuesDirectory = new File(EE3_ENERGYVALUES_DIR);
|
||||||
|
|
||||||
|
if(energyValuesDirectory.exists() && energyValuesDirectory.isDirectory())
|
||||||
|
{
|
||||||
|
File [] files = energyValuesDirectory.listFiles();
|
||||||
|
for(File f : files)
|
||||||
|
{
|
||||||
|
if(f.getName().toLowerCase().contains(".gz")){
|
||||||
|
f.delete();
|
||||||
|
commandSender.addChatMessage(new ChatComponentText("Deleted " + f.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
commandSender.addChatMessage(new ChatComponentText("Regening EMC Values"));
|
||||||
|
DynamicEnergyValueInitThread.initEnergyValueRegistry();
|
||||||
|
EnergyValueRegistry.getInstance().setShouldRegenNextRestart(false);
|
||||||
|
commandSender.addChatMessage(new ChatComponentText("Syncing all EMC Values"));
|
||||||
|
new CommandSyncEnergyValues().processCommand(commandSender, args);
|
||||||
|
}
|
||||||
|
}
|
58
src/main/java/techreborn/compat/ee3/CommandReload.java
Normal file
58
src/main/java/techreborn/compat/ee3/CommandReload.java
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
package techreborn.compat.ee3;
|
||||||
|
|
||||||
|
import com.pahimar.ee3.exchange.DynamicEnergyValueInitThread;
|
||||||
|
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
||||||
|
import com.pahimar.ee3.reference.Files;
|
||||||
|
import com.pahimar.ee3.reference.Reference;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import net.minecraft.command.CommandBase;
|
||||||
|
import net.minecraft.command.ICommandSender;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class CommandReload extends CommandBase {
|
||||||
|
|
||||||
|
public static final String EE3_ENERGYVALUES_DIR =
|
||||||
|
FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory()
|
||||||
|
+ File.separator +"data" + File.separator
|
||||||
|
+ Reference.LOWERCASE_MOD_ID + File.separator
|
||||||
|
+ "energyvalues";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandName()
|
||||||
|
{
|
||||||
|
return "eerelaod";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRequiredPermissionLevel()
|
||||||
|
{
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandUsage(ICommandSender commandSender)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processCommand(ICommandSender commandSender, String[] args)
|
||||||
|
{
|
||||||
|
commandSender.addChatMessage(new ChatComponentText("Reloading EMC Values..."));
|
||||||
|
File energyValuesDirectory = new File(EE3_ENERGYVALUES_DIR);
|
||||||
|
|
||||||
|
if(energyValuesDirectory.exists() && energyValuesDirectory.isDirectory()) {
|
||||||
|
File staticValues = new File(energyValuesDirectory, Files.STATIC_ENERGY_VALUES_JSON);
|
||||||
|
commandSender.addChatMessage(new ChatComponentText("Looking for " + staticValues.getName()));
|
||||||
|
if(staticValues.exists()){
|
||||||
|
commandSender.addChatMessage(new ChatComponentText("Found static values, reloading from disk!"));
|
||||||
|
} else {
|
||||||
|
commandSender.addChatMessage(new ChatComponentText("Will now recompute all values!!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DynamicEnergyValueInitThread.initEnergyValueRegistry();
|
||||||
|
EnergyValueRegistry.getInstance().setShouldRegenNextRestart(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,17 @@
|
||||||
package techreborn.compat.ee3;
|
package techreborn.compat.ee3;
|
||||||
|
|
||||||
import com.pahimar.ee3.api.exchange.RecipeRegistryProxy;
|
import com.pahimar.ee3.api.exchange.RecipeRegistryProxy;
|
||||||
|
import com.pahimar.ee3.exchange.EnergyValueRegistry;
|
||||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||||
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import techreborn.api.recipe.IBaseRecipeType;
|
import techreborn.api.recipe.IBaseRecipeType;
|
||||||
import techreborn.api.recipe.RecipeHandler;
|
import techreborn.api.recipe.RecipeHandler;
|
||||||
|
import techreborn.command.TechRebornDevCommand;
|
||||||
import techreborn.compat.ICompatModule;
|
import techreborn.compat.ICompatModule;
|
||||||
|
|
||||||
public class EmcValues implements ICompatModule {
|
public class EmcValues implements ICompatModule {
|
||||||
|
@ -27,11 +32,19 @@ public class EmcValues implements ICompatModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postInit(FMLPostInitializationEvent event) {
|
public void postInit(FMLPostInitializationEvent event) {
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serverStarting(FMLServerStartingEvent event) {
|
public void serverStarting(FMLServerStartingEvent event) {
|
||||||
|
event.registerServerCommand(new CommandRegen());
|
||||||
|
event.registerServerCommand(new CommandReload());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void serverTick(TickEvent.ServerTickEvent event){
|
||||||
|
//This should be a fix for the things not saving
|
||||||
|
EnergyValueRegistry.getInstance().setShouldRegenNextRestart(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue