This repository has been archived by the owner on Jun 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Just Enough Items compatibility: show trades list to the left if JEI is loaded Left/Right and left pixel offset can be set in config
- Loading branch information
Showing
6 changed files
with
146 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/de/guntram/mcmod/easiervillagertrading/ConfigurationHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package de.guntram.mcmod.easiervillagertrading; | ||
|
||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.client.event.ConfigChangedEvent; | ||
import java.io.File; | ||
import net.minecraftforge.common.config.Configuration; | ||
import net.minecraftforge.fml.common.Loader; | ||
|
||
public class ConfigurationHandler { | ||
|
||
private static ConfigurationHandler instance; | ||
|
||
private Configuration config; | ||
private String configFileName; | ||
private boolean showLeft; | ||
private int leftPixelOffset; | ||
|
||
public static ConfigurationHandler getInstance() { | ||
if (instance==null) | ||
instance=new ConfigurationHandler(); | ||
return instance; | ||
} | ||
|
||
public void load(final File configFile) { | ||
if (config == null) { | ||
config = new Configuration(configFile); | ||
configFileName=configFile.getPath(); | ||
loadConfig(); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { | ||
// System.out.println("OnConfigChanged for "+event.getModID()); | ||
if (event.getModID().equalsIgnoreCase(EasierVillagerTrading.MODID)) { | ||
loadConfig(); | ||
} | ||
} | ||
|
||
private void loadConfig() { | ||
showLeft=config.getBoolean("Trades list left", Configuration.CATEGORY_CLIENT, | ||
Loader.isModLoaded("jei"), | ||
"Show trades list to the left, for Just Enough Items compatibility"); | ||
leftPixelOffset=config.getInt("Trades left pixel offset", Configuration.CATEGORY_CLIENT, | ||
0, 0, Integer.MAX_VALUE, | ||
"How many pixels left of the GUI the trades list will be shown. Use 0 for auto detect. "+ | ||
"Only used if Trades list left is true."); | ||
if (config.hasChanged()) | ||
config.save(); | ||
} | ||
|
||
public static Configuration getConfig() { | ||
return getInstance().config; | ||
} | ||
|
||
public static String getConfigFileName() { | ||
return getInstance().configFileName; | ||
} | ||
|
||
public static boolean showLeft() { return getInstance().showLeft; } | ||
public static int leftPixelOffset() { return getInstance().leftPixelOffset; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/de/guntram/mcmod/easiervillagertrading/GuiConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.guntram.mcmod.easiervillagertrading; | ||
|
||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraftforge.common.config.ConfigElement; | ||
import static net.minecraftforge.common.config.Configuration.CATEGORY_CLIENT; | ||
|
||
public class GuiConfig extends net.minecraftforge.fml.client.config.GuiConfig { | ||
public GuiConfig(GuiScreen parent) { | ||
super(parent, | ||
new ConfigElement(ConfigurationHandler.getConfig().getCategory(CATEGORY_CLIENT)).getChildElements(), | ||
EasierVillagerTrading.MODID, | ||
false, | ||
false, | ||
"Easier Villager Trading configuration"); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/de/guntram/mcmod/easiervillagertrading/GuiFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package de.guntram.mcmod.easiervillagertrading; | ||
|
||
import java.util.Set; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraftforge.fml.client.IModGuiFactory; | ||
|
||
public class GuiFactory implements IModGuiFactory { | ||
@Override | ||
public void initialize(final Minecraft minecraftInstance) { | ||
} | ||
|
||
@Override | ||
public Class<? extends GuiScreen> mainConfigGuiClass() { | ||
return de.guntram.mcmod.easiervillagertrading.GuiConfig.class; | ||
} | ||
|
||
@Override | ||
public Set<IModGuiFactory.RuntimeOptionCategoryElement> runtimeGuiCategories() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public IModGuiFactory.RuntimeOptionGuiHandler getHandlerFor(final IModGuiFactory.RuntimeOptionCategoryElement element) { | ||
return null; | ||
} | ||
} |