mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-16 21:05:01 +00:00
config refactoring, configurable IDs for hardcoded mods.
This commit is contained in:
10 files changed
+138
-24
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package com.falsepattern.endlessids;
|
||||
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IChunkMixin;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IExtendedBlockStorageMixin;
|
||||
@@ -117,7 +118,7 @@ public class Hooks {
|
||||
if (id > 0) {
|
||||
final Block block = (Block) Block.blockRegistry.getObjectById(id);
|
||||
if (block == null) {
|
||||
if (IEConfig.removeInvalidBlocks) {
|
||||
if (GeneralConfig.removeInvalidBlocks) {
|
||||
blkIdsLSB[off] = 0;
|
||||
}
|
||||
} else if (block != Blocks.air) {
|
||||
@@ -134,7 +135,7 @@ public class Hooks {
|
||||
|
||||
public static int getIdFromBlockWithCheck(final Block block, final Block oldBlock) {
|
||||
final int id = Block.getIdFromBlock(block);
|
||||
if (IEConfig.catchUnregisteredBlocks && id == -1) {
|
||||
if (GeneralConfig.catchUnregisteredBlocks && id == -1) {
|
||||
throw new IllegalArgumentException("Block " + block +
|
||||
" is not registered. <-- Say about this to the author of this mod, or you can try to enable \"RemoveInvalidBlocks\" option in EID config.");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.falsepattern.endlessids;
|
||||
|
||||
import com.falsepattern.endlessids.asm.IETransformer;
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
import com.falsepattern.lib.config.ConfigException;
|
||||
import com.falsepattern.lib.config.ConfigurationManager;
|
||||
import lombok.SneakyThrows;
|
||||
@@ -15,7 +16,6 @@ import java.util.Set;
|
||||
import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.DependsOn;
|
||||
import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.Name;
|
||||
import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.SortingIndex;
|
||||
import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
||||
|
||||
@MCVersion("1.7.10")
|
||||
@@ -25,7 +25,7 @@ import static cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
||||
public class IEPlugin implements IFMLLoadingPlugin {
|
||||
static {
|
||||
try {
|
||||
ConfigurationManager.registerConfig(IEConfig.class);
|
||||
ConfigurationManager.registerConfig(GeneralConfig.class);
|
||||
} catch (ConfigException e) {
|
||||
System.err.println("Failed to load EndlessIDs config. Using defaults.");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.falsepattern.endlessids.config;
|
||||
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
|
||||
@Config(modid = Tags.MODID, category = "DarkWorld")
|
||||
public class DarkWorldIDConfig {
|
||||
@Config.Comment("Original: 100")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(10100)
|
||||
public static int darkOceanID;
|
||||
|
||||
@Config.Comment("Original: 101")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(10101)
|
||||
public static int darkPlainsID;
|
||||
|
||||
@Config.Comment("Original: 102")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(10102)
|
||||
public static int darkDesertID;
|
||||
|
||||
@Config.Comment("Original: 103")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(10103)
|
||||
public static int darkHillsID;
|
||||
|
||||
@Config.Comment("Original: 104")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(10104)
|
||||
public static int darkForestID;
|
||||
|
||||
@Config.Comment("Original: 105")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(10105)
|
||||
public static int darkTaigaID;
|
||||
|
||||
@Config.Comment("Original: 106")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(10106)
|
||||
public static int darkSwampID;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.falsepattern.endlessids.config;
|
||||
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.endlessids.constants.ExtendedConstants;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
|
||||
@Config(modid = Tags.MODID, category = "futurepack")
|
||||
public class FuturepackIDConfig {
|
||||
@Config.Comment("Original: 97")
|
||||
@Config.RangeInt(min = 40, max = ExtendedConstants.biomeIDCount - 1)
|
||||
@Config.DefaultInt(11097)
|
||||
public static int spaceID;
|
||||
}
|
||||
+3
-2
@@ -1,9 +1,10 @@
|
||||
package com.falsepattern.endlessids;
|
||||
package com.falsepattern.endlessids.config;
|
||||
|
||||
import com.falsepattern.endlessids.Tags;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
|
||||
@Config(modid = Tags.MODID)
|
||||
public class IEConfig {
|
||||
public class GeneralConfig {
|
||||
public static boolean catchUnregisteredBlocks = false;
|
||||
|
||||
@Config.Comment("Remove invalid (corrupted) blocks from the game.")
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.falsepattern.endlessids.constants;
|
||||
|
||||
import com.falsepattern.endlessids.IEConfig;
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
|
||||
public class ExtendedConstants {
|
||||
//Tunables
|
||||
public static final int bitsPerID = 24;
|
||||
public static final int bitsPerMetadata = 4;
|
||||
public static final int countCorrectionBits = IEConfig.countCorrectionBits;
|
||||
public static final int countCorrectionBits = GeneralConfig.countCorrectionBits;
|
||||
|
||||
public static final int watchableBits = 7;
|
||||
public static final int bitsPerBiome = 16;
|
||||
|
||||
+47
-10
@@ -1,5 +1,6 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.darkworld;
|
||||
|
||||
import com.falsepattern.endlessids.config.DarkWorldIDConfig;
|
||||
import matthbo.mods.darkworld.init.ModBiomes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -9,15 +10,51 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
remap = false)
|
||||
public abstract class ModBiomesMixin {
|
||||
@ModifyConstant(method = "init",
|
||||
constant = {@Constant(intValue = 100),
|
||||
@Constant(intValue = 101),
|
||||
@Constant(intValue = 102),
|
||||
@Constant(intValue = 103),
|
||||
@Constant(intValue = 104),
|
||||
@Constant(intValue = 105),
|
||||
@Constant(intValue = 106)},
|
||||
require = 7)
|
||||
private static int shiftBiomeIDsUp(int id) {
|
||||
return id + 10000;
|
||||
constant = @Constant(intValue = 100),
|
||||
require = 1)
|
||||
private static int darkOceanID(int id) {
|
||||
return DarkWorldIDConfig.darkOceanID;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "init",
|
||||
constant = @Constant(intValue = 101),
|
||||
require = 1)
|
||||
private static int darkPlainsID(int id) {
|
||||
return DarkWorldIDConfig.darkPlainsID;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "init",
|
||||
constant = @Constant(intValue = 102),
|
||||
require = 1)
|
||||
private static int darkDesertID(int id) {
|
||||
return DarkWorldIDConfig.darkDesertID;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "init",
|
||||
constant = @Constant(intValue = 103),
|
||||
require = 1)
|
||||
private static int darkHillsID(int id) {
|
||||
return DarkWorldIDConfig.darkHillsID;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "init",
|
||||
constant = @Constant(intValue = 104),
|
||||
require = 1)
|
||||
private static int darkForestID(int id) {
|
||||
return DarkWorldIDConfig.darkForestID;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "init",
|
||||
constant = @Constant(intValue = 105),
|
||||
require = 1)
|
||||
private static int darkTaigaID(int id) {
|
||||
return DarkWorldIDConfig.darkTaigaID;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "init",
|
||||
constant = @Constant(intValue = 106),
|
||||
require = 1)
|
||||
private static int darkSwampID(int id) {
|
||||
return DarkWorldIDConfig.darkSwampID;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.futurepack;
|
||||
|
||||
import com.falsepattern.endlessids.config.FuturepackIDConfig;
|
||||
import futurepack.common.dim.BiomeGenSpace;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -11,6 +12,6 @@ public abstract class BiomeGenSpaceMixin {
|
||||
constant = @Constant(intValue = 97),
|
||||
require = 1)
|
||||
private static int shiftBiomeIDsUp(int id) {
|
||||
return id + 11000;
|
||||
return FuturepackIDConfig.spaceID;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.falsepattern.endlessids.mixin.plugin;
|
||||
|
||||
import com.falsepattern.endlessids.IEConfig;
|
||||
import com.falsepattern.endlessids.config.GeneralConfig;
|
||||
import com.falsepattern.lib.mixin.IMixin;
|
||||
import com.falsepattern.lib.mixin.ITargetedMod;
|
||||
import lombok.Getter;
|
||||
@@ -37,7 +37,7 @@ public enum Mixin implements IMixin {
|
||||
//endregion Minecraft->common->biome
|
||||
//region Minecraft->common->misc
|
||||
BlockFireMixin(Side.COMMON, always(), "vanilla.misc.BlockFireMixin"),
|
||||
DataWatcherMixin(Side.COMMON, condition(() -> IEConfig.extendDataWatcher), "vanilla.misc.DataWatcherMixin"),
|
||||
DataWatcherMixin(Side.COMMON, condition(() -> GeneralConfig.extendDataWatcher), "vanilla.misc.DataWatcherMixin"),
|
||||
ItemInWorldManagerMixin(Side.COMMON, always(), "vanilla.misc.ItemInWorldManagerMixin"),
|
||||
StatListMixin(Side.COMMON, always(), "vanilla.misc.StatListMixin"),
|
||||
WorldMixin(Side.COMMON, always(), "vanilla.misc.WorldMixin"),
|
||||
@@ -144,7 +144,7 @@ public enum Mixin implements IMixin {
|
||||
//endregion LOTR->common
|
||||
//region MFQM->common
|
||||
MFQMMixin(Side.COMMON, require(TargetedMod.MFQM), "mfqm.MFQMMixin"),
|
||||
MFQMDataWatcherMixin(Side.COMMON, require(TargetedMod.MFQM).and(condition(() -> IEConfig.extendDataWatcher)),
|
||||
MFQMDataWatcherMixin(Side.COMMON, require(TargetedMod.MFQM).and(condition(() -> GeneralConfig.extendDataWatcher)),
|
||||
"mfqm.MFQMDataWatcherMixin"),
|
||||
//endregion MFQM->common
|
||||
//region NaturesCompass->common
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.falsepattern.endlessids.mixin.plugin;
|
||||
|
||||
import com.falsepattern.endlessids.config.DarkWorldIDConfig;
|
||||
import com.falsepattern.endlessids.config.FuturepackIDConfig;
|
||||
import com.falsepattern.lib.config.ConfigException;
|
||||
import com.falsepattern.lib.config.ConfigurationManager;
|
||||
import com.falsepattern.lib.mixin.ITargetedMod;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -19,12 +23,13 @@ public enum TargetedMod implements ITargetedMod {
|
||||
BIOMETWEAKER("Biome Tweaker", true, startsWith("biometweaker-")),
|
||||
BIOMEWAND("Biome Wand", true, startsWith("1.7.10-biome-wand-").or(startsWith("biome-wand"))),
|
||||
COFHLIB("CoFH Lib", true, startsWith("cofhlib-")),
|
||||
DARKWORLD("Dark World", true, startsWith("darkworld-")),
|
||||
DARKWORLD("Dark World", true, startsWith("darkworld-").and(loadConfig(DarkWorldIDConfig.class))),
|
||||
DRAGONAPI("DragonAPI", false, startsWith("dragonapi")),
|
||||
EB("Enhanced Biomes", true, startsWith("Enhanced Biomes").or(startsWith("enhancedbiomes"))),
|
||||
EREBUS("The Erebus", true, startsWith("theerebus")),
|
||||
EXTRAUTILITIES("Extra Utilities", true, startsWith("extrautilities-")),
|
||||
FUTUREPACK("Futurepack", true, startsWith("[1.7.10]futurepack").or(startsWith("futurepack-"))),
|
||||
FUTUREPACK("Futurepack", true, startsWith("[1.7.10]futurepack").or(startsWith("futurepack-")).and(loadConfig(
|
||||
FuturepackIDConfig.class))),
|
||||
GALACTICRAFTCORE("GalactiCraftCore", false, startsWith("galacticraftcore")),
|
||||
HIGHLANDS("Highlands", true, startsWith("highlands")),
|
||||
ICG("Immersive Cavegen", true, startsWith("immersivecavegen")),
|
||||
@@ -40,6 +45,17 @@ public enum TargetedMod implements ITargetedMod {
|
||||
WORLDEDIT("WorldEdit", false, startsWith("worldedit-")),
|
||||
;
|
||||
|
||||
private static Predicate<String> loadConfig(Class<?> configClass) {
|
||||
return (str) -> {
|
||||
try {
|
||||
ConfigurationManager.registerConfig(configClass);
|
||||
} catch (ConfigException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
@Getter
|
||||
private final String modName;
|
||||
@Getter
|
||||
|
||||
Reference in new issue
Block a user