Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Commit

Permalink
Change the various strategies to Tweaker (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
wohaopa authored Aug 26, 2024
1 parent 739b112 commit 7189414
Show file tree
Hide file tree
Showing 32 changed files with 432 additions and 204 deletions.
6 changes: 2 additions & 4 deletions src/main/java/com/github/wohaopa/GTNHModify/CommonProxy.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.github.wohaopa.GTNHModify;

import com.github.wohaopa.GTNHModify.config.Config;
import com.github.wohaopa.GTNHModify.handler.Handlers;
import com.github.wohaopa.GTNHModify.strategies.Strategy;
import com.github.wohaopa.GTNHModify.tweakers.Tweakers;

import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
Expand All @@ -14,7 +13,6 @@ public class CommonProxy {
// preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the
// GameRegistry." (Remove if not needed)
public void preInit(FMLPreInitializationEvent event) {
Strategy.init();
Config.init(event.getSuggestedConfigurationFile());
}

Expand All @@ -26,6 +24,6 @@ public void postInit(FMLPostInitializationEvent event) {}

// register server commands in this event handler (Remove if not needed)
public void serverStarting(FMLServerStartingEvent event) {
Handlers.init();
Tweakers.initialize();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;

import com.github.wohaopa.GTNHModify.handler.Handlers;
import com.github.wohaopa.GTNHModify.tweakers.Tweakers;

public class GTNHModifyCommand extends CommandBase {

Expand Down Expand Up @@ -89,9 +89,9 @@ public void processCommand(ICommandSender sender, String[] args) {
case "help" -> printHelps(sender);
case "hello" -> sender.addChatMessage(new ChatComponentText("你好"));
case "load" -> {
if (Handlers.init())
sender.addChatMessage(new ChatComponentTranslation("commands.gtnh-modify.load.success"));
else sender.addChatMessage(new ChatComponentTranslation("commands.gtnh-modify.load.failure"));
Tweakers.initialize();
sender.addChatMessage(new ChatComponentTranslation("commands.gtnh-modify.load.success"));

}
default -> {
if (subCmds.contains(test)) {
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/com/github/wohaopa/GTNHModify/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraftforge.common.config.Configuration;

import com.github.wohaopa.GTNHModify.GTNHModifyMod;
import com.github.wohaopa.GTNHModify.strategies.Strategy;
import com.github.wohaopa.GTNHModify.tweakers.Tweakers;

import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.FMLCommonHandler;
Expand Down Expand Up @@ -37,13 +37,10 @@ public void onConfigChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event)

private static void loadConfig() {

String strategyName = config.getString(
"Strategy",
Configuration.CATEGORY_GENERAL,
"None",
"Possible values: [None, OneTick, Tenths, Output64, Energyless]");

Strategy.setStrategy(strategyName);
for (Tweakers tweaker : Tweakers.values()) {
tweaker.enabled = config
.getBoolean(tweaker.name, Configuration.CATEGORY_GENERAL, false, tweaker.description);
}

if (config.hasChanged() || doSave) {
config.save();
Expand Down

This file was deleted.

This file was deleted.

64 changes: 0 additions & 64 deletions src/main/java/com/github/wohaopa/GTNHModify/handler/Handlers.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/java/com/github/wohaopa/GTNHModify/handler/IHandler.java

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import com.github.wohaopa.GTNHModify.handler.MinecraftHandler;
import com.github.wohaopa.GTNHModify.tweakers.handler.MinecraftHandler;

@Mixin(TileEntityFurnace.class)
public abstract class TileEntityFurnaceMixin {

@ModifyConstant(method = "updateEntity", constant = @Constant(intValue = 200))
private int injected(int value) {
return MinecraftHandler.handle(this, value);
return MinecraftHandler.instance.handle(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import com.github.wohaopa.GTNHModify.handler.ThaumcraftHandler;
import com.github.wohaopa.GTNHModify.tweakers.handler.BotaniaHandler;

import vazkii.botania.common.block.tile.mana.TileSpreader;

Expand All @@ -19,6 +19,6 @@ public abstract class TileSpreaderMixin {
target = "Lvazkii/botania/common/block/tile/mana/TileSpreader;pingbackTicks:I",
opcode = Opcodes.PUTFIELD))
private void injectedPingback(TileSpreader tileSpreader, int pingbackTicks) {
tileSpreader.pingbackTicks = ThaumcraftHandler.handle(tileSpreader, pingbackTicks);
tileSpreader.pingbackTicks = BotaniaHandler.instance.handle(tileSpreader, pingbackTicks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import com.github.wohaopa.GTNHModify.handler.GregTechHandler;
import com.github.wohaopa.GTNHModify.tweakers.handler.GregTechHandler;

import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DrillerBase;
Expand All @@ -21,7 +21,7 @@ public abstract class GT_MetaTileEntity_DrillerBaseMixin {
shift = At.Shift.AFTER))
private void injected(CallbackInfoReturnable<CheckRecipeResult> cir) {

((GT_MetaTileEntity_DrillerBase) ((Object) this)).mMaxProgresstime = GregTechHandler
((GT_MetaTileEntity_DrillerBase) ((Object) this)).mMaxProgresstime = GregTechHandler.instance
.handle(this, ((GT_MetaTileEntity_DrillerBase) ((Object) this)).mMaxProgresstime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import com.github.wohaopa.GTNHModify.handler.GregTechHandler;
import com.github.wohaopa.GTNHModify.tweakers.handler.GregTechHandler;

import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Miner;

Expand All @@ -27,6 +27,6 @@ public class GT_MetaTileEntity_MinerMixin {
target = "Lgregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner;mSpeed:I",
opcode = Opcodes.GETFIELD))
private int injected(GT_MetaTileEntity_Miner miner) {
return GregTechHandler.handle(miner, mSpeed);
return GregTechHandler.instance.handle(miner, mSpeed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

import com.github.wohaopa.GTNHModify.handler.GregTechHandler;
import com.github.wohaopa.GTNHModify.tweakers.handler.GregTechHandler;

import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_MultiFurnace;

Expand All @@ -13,6 +13,6 @@ public class GT_MetaTileEntity_MultiFurnaceMixin {

@ModifyConstant(method = "checkProcessing", constant = @Constant(intValue = 512))
private int injected(int value) {
return GregTechHandler.handle(this, value);
return GregTechHandler.instance.handle(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

import com.github.wohaopa.GTNHModify.handler.GregTechHandler;
import com.github.wohaopa.GTNHModify.tweakers.handler.GregTechHandler;

import gregtech.common.tileentities.machines.basic.GT_MetaTileEntity_Scanner;

Expand All @@ -13,6 +13,6 @@ public abstract class GT_MetaTileEntity_ScannerMixin {

@ModifyArg(method = "checkRecipe", at = @At(value = "INVOKE", target = "calculateOverclockedNess"), index = 1)
private int injected(int x) {
return GregTechHandler.handle(this, x);
return GregTechHandler.instance.handle(this, x);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import com.github.wohaopa.GTNHModify.handler.ThaumcraftHandler;
import com.github.wohaopa.GTNHModify.tweakers.handler.ThaumcraftHandler;

import thaumcraft.common.tiles.TileAlchemyFurnace;

Expand All @@ -19,6 +19,6 @@ public abstract class TileAlchemyFurnaceMixin {
target = "Lthaumcraft/common/tiles/TileAlchemyFurnace;smeltTime:I",
opcode = Opcodes.PUTFIELD))
private void injectedSmeltTime(TileAlchemyFurnace furnace, int smeltTime) {
furnace.smeltTime = ThaumcraftHandler.handle(furnace, smeltTime);
furnace.smeltTime = ThaumcraftHandler.instance.handle(furnace, smeltTime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import com.github.wohaopa.GTNHModify.handler.ThaumcraftHandler;
import com.github.wohaopa.GTNHModify.tweakers.handler.ThaumcraftHandler;

import thaumcraft.common.tiles.TileNode;

Expand All @@ -23,6 +23,6 @@ public abstract class TileNodeMixin {
target = "Lthaumcraft/common/tiles/TileNode;regeneration:I",
opcode = Opcodes.PUTFIELD))
private void injectedHandleRecharge(TileNode tileNode, int regeneration) {
this.regeneration = ThaumcraftHandler.handle(tileNode, regeneration);
this.regeneration = ThaumcraftHandler.instance.handle(tileNode, regeneration);
}
}
Loading

0 comments on commit 7189414

Please sign in to comment.