Skip to content

Commit

Permalink
Merge branch '1.10.2' of https://github.com/squeek502/Squake into 1.12.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	java/squeek/quakemovement/ModQuakeMovement.java
  • Loading branch information
squeek502 committed Jun 19, 2018
2 parents 8915b9e + aa92961 commit 9d29dda
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 10 deletions.
33 changes: 24 additions & 9 deletions java/squeek/quakemovement/ModConfig.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package squeek.quakemovement;

import java.io.File;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.io.File;

public class ModConfig
{
private static final String CATEGORY_MOVEMENT = "movement";
public static final String CATEGORY_MOVEMENT = "movement";

public static float TRIMP_MULTIPLIER;
private static final String TRIMP_MULTIPLIER_NAME = "trimpMultiplier";
Expand Down Expand Up @@ -65,14 +68,19 @@ public class ModConfig
private static final String ENABLED_NAME = "enabled";
private static final boolean ENABLED_DEFAULT = true;

private static Configuration config;
public static Configuration config;

public static void init(File file)
{
config = new Configuration(file);

load();
if (config == null)
{
config = new Configuration(file);
load();
}
}

public static void load()
{
UNCAPPED_BUNNYHOP_ENABLED = config.get(CATEGORY_MOVEMENT, UNCAPPED_BUNNYHOP_ENABLED_NAME, UNCAPPED_BUNNYHOP_ENABLED_DEFAULT, "if enabled, the soft and hard caps will not be applied at all").getBoolean(UNCAPPED_BUNNYHOP_ENABLED_DEFAULT);
AIR_ACCELERATE = config.get(CATEGORY_MOVEMENT, AIR_ACCELERATE_NAME, AIR_ACCELERATE_DEFAULT, "a higher value means you can turn more sharply in the air without losing speed").getDouble(AIR_ACCELERATE_DEFAULT);
MAX_AIR_ACCEL_PER_TICK = config.get(CATEGORY_MOVEMENT, MAX_AIR_ACCEL_PER_TICK_NAME, MAX_AIR_ACCEL_PER_TICK_DEFAULT, "a higher value means faster air acceleration").getDouble(MAX_AIR_ACCEL_PER_TICK_DEFAULT);
Expand Down Expand Up @@ -105,11 +113,18 @@ public static void setEnabled(boolean enabled)

public static void save()
{
config.save();
if (config.hasChanged())
{
config.save();
}
}

public static void load()
@SubscribeEvent
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event)
{
config.load();
if (event.getModID().equalsIgnoreCase(ModInfo.MODID))
{
load();
}
}
}
13 changes: 13 additions & 0 deletions java/squeek/quakemovement/ModConfigGui.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package squeek.quakemovement;

import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.fml.client.config.GuiConfig;

public class ModConfigGui extends GuiConfig
{
public ModConfigGui(GuiScreen parentScreen)
{
super(parentScreen, new ConfigElement(ModConfig.config.getCategory(ModConfig.CATEGORY_MOVEMENT)).getChildElements(), ModInfo.MODID, false, false, GuiConfig.getAbridgedConfigPath(ModConfig.config.toString()));
}
}
33 changes: 33 additions & 0 deletions java/squeek/quakemovement/ModConfigGuiFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package squeek.quakemovement;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.client.IModGuiFactory;

import java.util.Set;

public class ModConfigGuiFactory implements IModGuiFactory
{
@Override
public void initialize(Minecraft minecraftInstance)
{
}

@Override
public Class<? extends GuiScreen> mainConfigGuiClass()
{
return ModConfigGui.class;
}

@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
{
return null;
}

@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element)
{
return null;
}
}
1 change: 1 addition & 0 deletions java/squeek/quakemovement/ModInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ public final class ModInfo
{
public static final String MODID = "squake";
public static final String VERSION = "${version}";
public static final String CONFIG_GUI_FACTORY_CLASS = "squeek.quakemovement.ModConfigGuiFactory";
}
3 changes: 2 additions & 1 deletion java/squeek/quakemovement/ModQuakeMovement.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;

@Mod(modid = ModInfo.MODID, version = ModInfo.VERSION, name="Squake", acceptedMinecraftVersions="[1.12.2]", dependencies = "after:squeedometer")
@Mod(modid = ModInfo.MODID, version = ModInfo.VERSION, name="Squake", acceptedMinecraftVersions="[1.12.2]", dependencies = "after:squeedometer", guiFactory = ModInfo.CONFIG_GUI_FACTORY_CLASS)
public class ModQuakeMovement
{
// The instance of your mod that Forge uses.
Expand All @@ -22,6 +22,7 @@ public class ModQuakeMovement
public void preInit(FMLPreInitializationEvent event)
{
ModConfig.init(event.getSuggestedConfigurationFile());
MinecraftForge.EVENT_BUS.register(new ModConfig());
MinecraftForge.EVENT_BUS.register(this);
if (event.getSide() == Side.CLIENT)
{
Expand Down

0 comments on commit 9d29dda

Please sign in to comment.