This repository has been archived by the owner on Sep 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
390 additions
and
36 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
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/github/wohaopa/GTNHModify/client/gui/GTNHModifyGuiConfig.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,24 @@ | ||
package com.github.wohaopa.GTNHModify.client.gui; | ||
|
||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraftforge.common.config.ConfigElement; | ||
import net.minecraftforge.common.config.Configuration; | ||
|
||
import com.github.wohaopa.GTNHModify.GTNHModifyMod; | ||
import com.github.wohaopa.GTNHModify.config.Config; | ||
|
||
import cpw.mods.fml.client.config.GuiConfig; | ||
|
||
public class GTNHModifyGuiConfig extends GuiConfig { | ||
|
||
@SuppressWarnings({ "unchecked", "rawtypes" }) | ||
public GTNHModifyGuiConfig(GuiScreen guiScreen) { | ||
super( | ||
guiScreen, | ||
new ConfigElement(Config.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), | ||
GTNHModifyMod.MODID, | ||
false, | ||
false, | ||
GuiConfig.getAbridgedConfigPath(Config.config.toString())); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/github/wohaopa/GTNHModify/client/gui/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,31 @@ | ||
package com.github.wohaopa.GTNHModify.client.gui; | ||
|
||
import java.util.Set; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiScreen; | ||
|
||
import cpw.mods.fml.client.IModGuiFactory; | ||
|
||
public class GuiFactory implements IModGuiFactory { | ||
|
||
@Override | ||
public void initialize(Minecraft minecraftInstance) { | ||
|
||
} | ||
|
||
@Override | ||
public Class<? extends GuiScreen> mainConfigGuiClass() { | ||
return GTNHModifyGuiConfig.class; | ||
} | ||
|
||
@Override | ||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { | ||
return null; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/main/java/com/github/wohaopa/GTNHModify/config/Config.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,68 @@ | ||
package com.github.wohaopa.GTNHModify.config; | ||
|
||
import java.io.File; | ||
|
||
import net.minecraftforge.common.config.Configuration; | ||
|
||
import com.github.wohaopa.GTNHModify.GTNHModifyMod; | ||
import com.github.wohaopa.GTNHModify.strategies.Energyless; | ||
import com.github.wohaopa.GTNHModify.strategies.None; | ||
import com.github.wohaopa.GTNHModify.strategies.OneTick; | ||
import com.github.wohaopa.GTNHModify.strategies.Output64; | ||
import com.github.wohaopa.GTNHModify.strategies.Strategy; | ||
import com.github.wohaopa.GTNHModify.strategies.Tenths; | ||
|
||
import cpw.mods.fml.client.event.ConfigChangedEvent; | ||
import cpw.mods.fml.common.FMLCommonHandler; | ||
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
|
||
public class Config { | ||
|
||
public static Configuration config; | ||
|
||
public static Strategy strategy = new None(); | ||
|
||
private static boolean doSave; | ||
|
||
public static void init(File configFile) { | ||
if (config == null) { | ||
config = new Configuration(configFile); | ||
} | ||
doSave = false; | ||
loadConfig(); | ||
FMLCommonHandler.instance() | ||
.bus() | ||
.register(new Config()); | ||
} | ||
|
||
@SubscribeEvent | ||
public void onConfigChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) { | ||
if (event.modID.equalsIgnoreCase(GTNHModifyMod.MODID)) { | ||
loadConfig(); | ||
} | ||
} | ||
|
||
private static void loadConfig() { | ||
|
||
String strategyName = config.getString( | ||
"Strategy", | ||
Configuration.CATEGORY_GENERAL, | ||
"None", | ||
"Possible values: [None, OneTick, Tenths, Output64, Energyless]"); | ||
|
||
switch (strategyName) { | ||
case "OneTick" -> strategy = new OneTick(); | ||
case "Tenths" -> strategy = new Tenths(); | ||
case "Output64" -> strategy = new Output64(); | ||
case "Energyless" -> strategy = new Energyless(); | ||
default -> strategy = new None(); | ||
} | ||
|
||
if (config.hasChanged() || doSave) { | ||
config.save(); | ||
|
||
doSave = false; | ||
} | ||
} | ||
|
||
} |
11 changes: 0 additions & 11 deletions
11
src/main/java/com/github/wohaopa/GTNHModify/handler/FurnaceRecipesHandler.java
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/main/java/com/github/wohaopa/GTNHModify/handler/Furnace_RecipesHandler.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,19 @@ | ||
package com.github.wohaopa.GTNHModify.handler; | ||
|
||
import net.minecraft.item.crafting.FurnaceRecipes; | ||
|
||
import com.github.wohaopa.GTNHModify.config.Config; | ||
|
||
@IHandler("init") | ||
public class Furnace_RecipesHandler { | ||
|
||
public static void init() { | ||
FurnaceRecipes.smelting() | ||
.getSmeltingList() | ||
.forEach((itemStack, itemStack2) -> Config.strategy.handler_FurnaceRecipe(itemStack, itemStack2)); | ||
} | ||
|
||
public static int handle(Object owner, int number) { | ||
return Config.strategy.handler_FurnaceProcessingTime(owner, number); | ||
} | ||
} |
11 changes: 9 additions & 2 deletions
11
src/main/java/com/github/wohaopa/GTNHModify/handler/GT_RecipesHandler.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 |
---|---|---|
@@ -1,17 +1,24 @@ | ||
package com.github.wohaopa.GTNHModify.handler; | ||
|
||
import com.github.wohaopa.GTNHModify.config.Config; | ||
|
||
import gregtech.api.recipe.RecipeMap; | ||
import gregtech.api.util.GT_Recipe; | ||
|
||
@IHandler("init") | ||
public class GT_RecipesHandler { | ||
|
||
protected static void init() { | ||
RecipeMap.ALL_RECIPE_MAPS.forEach( | ||
(s, recipeMap) -> recipeMap.getAllRecipes() | ||
.forEach(recipe -> { recipe.mDuration = 1; })); | ||
.forEach(recipe -> Config.strategy.handler_GT_Recipe(recipe))); | ||
GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes | ||
.forEach(gtRecipeAssemblyLine -> { gtRecipeAssemblyLine.mDuration = 1; }); | ||
.forEach(gtRecipeAssemblyLine -> { Config.strategy.handler_GT_Recipe_AssemblyLine(gtRecipeAssemblyLine); }); | ||
|
||
} | ||
|
||
public static int handle(Object owner, int number) { | ||
return Config.strategy.handler_GT_ProcessingTime(owner, number); | ||
} | ||
|
||
} |
26 changes: 24 additions & 2 deletions
26
src/main/java/com/github/wohaopa/GTNHModify/handler/Handlers.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 |
---|---|---|
@@ -1,9 +1,31 @@ | ||
package com.github.wohaopa.GTNHModify.handler; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class Handlers { | ||
|
||
public static List<String> handlers = Arrays.asList("Furnace", "GT"); | ||
private static final String Suffix = "_RecipesHandler"; | ||
|
||
public static void init() { | ||
GT_RecipesHandler.init(); | ||
FurnaceRecipesHandler.init(); | ||
String pkg = Handlers.class.getName() | ||
.replace("Handlers", ""); | ||
for (String name : handlers) { | ||
String className = pkg + name + Suffix; | ||
try { | ||
Class<?> clazz = Class.forName(className); | ||
IHandler iHandler = clazz.getAnnotation(IHandler.class); | ||
if (iHandler != null) { | ||
clazz.getDeclaredMethod(iHandler.value()) | ||
.invoke(null); | ||
} | ||
} catch (ClassNotFoundException | InvocationTargetException | IllegalAccessException | ||
| NoSuchMethodException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/github/wohaopa/GTNHModify/handler/IHandler.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,13 @@ | ||
package com.github.wohaopa.GTNHModify.handler; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface IHandler { | ||
|
||
String value(); | ||
} |
15 changes: 6 additions & 9 deletions
15
src/main/java/com/github/wohaopa/GTNHModify/mixins/GT_DrillingLogicDelegateMixin.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 |
---|---|---|
@@ -1,20 +1,17 @@ | ||
package com.github.wohaopa.GTNHModify.mixins; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import gregtech.common.misc.GT_DrillingLogicDelegate; | ||
import gregtech.common.misc.GT_IDrillingLogicDelegateOwner; | ||
|
||
@Mixin(value = GT_DrillingLogicDelegate.class, remap = false) | ||
public abstract class GT_DrillingLogicDelegateMixin { | ||
|
||
@Redirect( | ||
method = "onPostTickRetract", | ||
at = @At(value = "INVOKE", target = "Lgregtech/common/misc/GT_IDrillingLogicDelegateOwner;getMachineSpeed()I")) | ||
private int injected(GT_IDrillingLogicDelegateOwner owner) { | ||
return 50; | ||
} | ||
// @Redirect( | ||
// method = "onPostTickRetract", | ||
// at = @At(value = "INVOKE", target = "Lgregtech/common/misc/GT_IDrillingLogicDelegateOwner;getMachineSpeed()I")) | ||
// private int injected(GT_IDrillingLogicDelegateOwner owner) { | ||
// return 100; | ||
// } | ||
|
||
} |
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/github/wohaopa/GTNHModify/strategies/Energyless.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,11 @@ | ||
package com.github.wohaopa.GTNHModify.strategies; | ||
|
||
import gregtech.api.util.GT_Recipe; | ||
|
||
public class Energyless extends Strategy { | ||
|
||
@Override | ||
public void handler_GT_Recipe(GT_Recipe gtRecipe) { | ||
if (gtRecipe.mEUt > 0) gtRecipe.mEUt = 0; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/github/wohaopa/GTNHModify/strategies/None.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,5 @@ | ||
package com.github.wohaopa.GTNHModify.strategies; | ||
|
||
public class None extends Strategy { | ||
|
||
} |
Oops, something went wrong.