Skip to content

Commit

Permalink
Migrate to gtnhlib config (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss authored Nov 19, 2024
1 parent 9218463 commit 2507ef6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.gtnewhorizon.gtnhlib.config.ConfigException;
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
import com.gtnewhorizons.gtnhintergalactic.block.IGBlocks;
import com.gtnewhorizons.gtnhintergalactic.config.IGConfig;
import com.gtnewhorizons.gtnhintergalactic.item.IGItems;
import com.gtnewhorizons.gtnhintergalactic.proxy.CommonProxy;

Expand Down Expand Up @@ -38,6 +41,14 @@
+ "after:IronChest;")
public class GTNHIntergalactic {

static {
try {
ConfigurationManager.registerConfig(IGConfig.class);
} catch (ConfigException e) {
throw new RuntimeException(e);
}
}

/** Logger used by this mod */
public static final Logger LOG = LogManager.getLogger(Tags.MODID);
/** Prefix for assets */
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.gtnewhorizons.gtnhintergalactic.config;

import com.gtnewhorizon.gtnhlib.config.Config;

import gregtech.api.enums.Mods;

@Config(modid = Mods.Names.G_T_N_H_INTERGALACTIC, filename = "gtnhintergalactic")
public class IGConfig {

public static SpaceElevator spaceElevator = new SpaceElevator();

@Config.Comment("Space Elevator section")
public static class SpaceElevator {

@Config.Comment("If true, the Space Elevator will use it's fancy renderer, otherwise a simple block renderer")
@Config.DefaultBoolean(true)
public boolean isCableRenderingEnabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.util.IIcon;

import com.gtnewhorizons.gtnhintergalactic.block.IGBlocks;
import com.gtnewhorizons.gtnhintergalactic.config.Config;
import com.gtnewhorizons.gtnhintergalactic.item.IGItems;
import com.gtnewhorizons.gtnhintergalactic.loader.MachineLoader;
import com.gtnewhorizons.gtnhintergalactic.loader.RecipeLoader;
Expand All @@ -30,9 +29,7 @@ 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) {
Config.synchronizeConfiguration(event.getSuggestedConfigurationFile());
}
public void preInit(FMLPreInitializationEvent event) {}

// load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed)
public void init(FMLInitializationEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.gtnewhorizon.gtnhlib.client.renderer.shader.ShaderProgram;
import com.gtnewhorizons.gtnhintergalactic.GTNHIntergalactic;
import com.gtnewhorizons.gtnhintergalactic.block.BlockSpaceElevatorCable;
import com.gtnewhorizons.gtnhintergalactic.config.Config;
import com.gtnewhorizons.gtnhintergalactic.config.IGConfig;
import com.gtnewhorizons.gtnhintergalactic.tile.TileEntitySpaceElevatorCable;

import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
Expand Down Expand Up @@ -108,7 +108,7 @@ public RenderSpaceElevatorCable() {
*/
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) {
if (!Config.isCableRenderingEnabled) return;
if (!IGConfig.spaceElevator.isCableRenderingEnabled) return;
if (!(tile instanceof TileEntitySpaceElevatorCable)) return;

final TileEntitySpaceElevatorCable cableTile = (TileEntitySpaceElevatorCable) tile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;

import com.gtnewhorizons.gtnhintergalactic.config.Config;
import com.gtnewhorizons.gtnhintergalactic.config.IGConfig;

import cpw.mods.fml.relauncher.Side;
import io.netty.buffer.ByteBuf;
Expand Down Expand Up @@ -159,7 +159,7 @@ public boolean shouldRender() {
*/
@Override
public void updateEntity() {
if (!Config.isCableRenderingEnabled) return;
if (!IGConfig.spaceElevator.isCableRenderingEnabled) return;
super.updateEntity();
// If the render state changed we need to issue a block renderer update to switch to the block renderer
if (worldObj != null && worldObj.isRemote) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.gtnewhorizon.structurelib.structure.StructureUtility;
import com.gtnewhorizons.gtnhintergalactic.block.IGBlocks;
import com.gtnewhorizons.gtnhintergalactic.client.lore.LoreHolder;
import com.gtnewhorizons.gtnhintergalactic.config.Config;
import com.gtnewhorizons.gtnhintergalactic.config.IGConfig;
import com.gtnewhorizons.gtnhintergalactic.gui.IG_UITextures;
import com.gtnewhorizons.gtnhintergalactic.tile.TileEntitySpaceElevatorCable;
import com.gtnewhorizons.gtnhintergalactic.tile.multi.GT_MetaTileEntity_EnhancedMultiBlockBase_EM;
Expand Down Expand Up @@ -600,7 +600,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
}
this.isLoadedChunk = true;
} else {
if (elevatorCable != null && Config.isCableRenderingEnabled
if (elevatorCable != null && IGConfig.spaceElevator.isCableRenderingEnabled
&& elevatorCable.getAnimation() == TileEntitySpaceElevatorCable.ClimberAnimation.NO_ANIMATION
&& aTick % 2000 == 0) {
elevatorCable.startAnimation(TileEntitySpaceElevatorCable.ClimberAnimation.DELIVER_ANIMATION);
Expand Down

0 comments on commit 2507ef6

Please sign in to comment.