Skip to content

Commit

Permalink
redo config and mixins
Browse files Browse the repository at this point in the history
now depends on GTNHLib

Signed-off-by: unilock <[email protected]>
  • Loading branch information
unilock committed Oct 30, 2024
1 parent 503d770 commit 70e1d09
Show file tree
Hide file tree
Showing 27 changed files with 312 additions and 167 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {

implementation("com.github.GTNewHorizons:GTNHLib:0.5.18:dev")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ mixinsPackage = mixin
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
coreModClass = EarlyMixinLoader

# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
Expand Down
118 changes: 118 additions & 0 deletions src/main/java/cc/unilock/legacyfixes/EarlyMixinLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package cc.unilock.legacyfixes;

import com.gtnewhorizon.gtnhlib.config.ConfigException;
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

@IFMLLoadingPlugin.MCVersion("1.7.10")
public class EarlyMixinLoader implements IFMLLoadingPlugin, IEarlyMixinLoader {
static {
try {
ConfigurationManager.registerConfig(LegacyFixesConfig.class);
} catch (ConfigException e) {
throw new RuntimeException(e);
}
}

@Override
public String getMixinConfig() {
return "mixins.legacyfixes.early.json";
}

@Override
public List<String> getMixins(Set<String> loadedCoreMods) {
List<String> mixins = new ArrayList<>();

if (LegacyFixesConfig.apatheticMobs) {
mixins.add("apatheticMobs.EntityAITargetMixin");
mixins.add("apatheticMobs.EntityCreatureMixin");
}
if (LegacyFixesConfig.bedSpawnFix) {
mixins.add("bedSpawnFix.BlockBedMixin");
mixins.add("bedSpawnFix.EntityPlayerAccessor");
}
if (LegacyFixesConfig.hungerless) {
if (Loader.isModLoaded("AppleCore")) {
LegacyFixes.LOGGER.error("LegacyFixes failed to enable hungerless with AppleCore installed!");
} else {
mixins.add("hungerless.FoodStatsMixin");
}
}
if (LegacyFixesConfig.jumpClimbing) {
if (LegacyFixesConfig.slideClimbing) {
LegacyFixes.LOGGER.error("LegacyFixes failed to enable jumpClimbing with slideClimbing enabled!");
} else {
mixins.add("jumpClimbing.EntityLivingBaseMixin");
}
}
if (LegacyFixesConfig.keepXP) {
mixins.add("keepXP.EntityLivingBaseMixin");
mixins.add("keepXP.EntityPlayerMixin");
}
if (LegacyFixesConfig.mc5694Fix) {
mixins.add("mc5694Fix.ItemInWorldManagerMixin");
}
if (LegacyFixesConfig.noTrample) {
mixins.add("noTrample.BlockFarmlandMixin");
}
if (LegacyFixesConfig.slideClimbing) {
if (LegacyFixesConfig.jumpClimbing) {
LegacyFixes.LOGGER.error("LegacyFixes failed to enable slideClimbing with jumpClimbing enabled!");
} else {
mixins.add("slideClimbing.EntityLivingBaseMixin");
}
}

if (FMLLaunchHandler.side().isClient()) {
if (LegacyFixesConfig.chatLinebreakFix) {
mixins.add("client.chatLinebreakFix.GuiNewChatMixin");
}
if (LegacyFixesConfig.nnbspFix) {
mixins.add("client.nnbspFix.FontRendererMixin");
}
if (LegacyFixesConfig.rmbClear) {
mixins.add("client.rmbClear.GuiTextFieldMixin");
}
if (LegacyFixesConfig.sortedEnchantments) {
mixins.add("client.sortedEnchantments.ItemEnchantedBookMixin");
mixins.add("client.sortedEnchantments.ItemStackMixin");
mixins.add("client.sortedEnchantments.NBTTagListAccessor");
}
}

return mixins;
}

@Override
public String[] getASMTransformerClass() {
return null;
}

@Override
public String getModContainerClass() {
return null;
}

@Override
public String getSetupClass() {
return null;
}

@Override
public void injectData(Map<String, Object> data) {
// NO-OP
}

@Override
public String getAccessTransformerClass() {
return null;
}
}
2 changes: 1 addition & 1 deletion src/main/java/cc/unilock/legacyfixes/LegacyFixes.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Mod(modid = "legacyfixes", version = Tags.VERSION, name = "LegacyFixes", acceptedMinecraftVersions = "[1.7.10]")
@Mod(modid = "legacyfixes", version = Tags.VERSION, name = "LegacyFixes", dependencies = "required-after:gtnhlib@[0.2.0,);")
public class LegacyFixes {
public static final Logger LOGGER = LogManager.getLogger("LegacyFixes");

Expand Down
92 changes: 54 additions & 38 deletions src/main/java/cc/unilock/legacyfixes/LegacyFixesConfig.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
package cc.unilock.legacyfixes;

import net.minecraftforge.common.config.Configuration;

import java.io.File;
import com.gtnewhorizon.gtnhlib.config.Config;

@Config(modid = "legacyfixes")
@Config.RequiresMcRestart
public class LegacyFixesConfig {
public static boolean apatheticMobs = false;
public static boolean bedSpawnFix = true;
public static boolean chatLinebreakFix = false;
public static boolean doubleDoors = true;
public static boolean hungerless = false;
public static boolean jumpClimbing = true;
public static boolean keepXP = false;
public static boolean mc5694Fix = true;
public static boolean nnbspFix = true;
public static boolean noTrample = false;
public static boolean rmbClear = true;
public static boolean slideClimbing = false;
public static boolean sortedEnchantments = true;

public static void synchronizeConfiguration(File configFile) {
Configuration configuration = new Configuration(configFile);

apatheticMobs = configuration.getBoolean("apatheticMobs", Configuration.CATEGORY_GENERAL, apatheticMobs, "Prevents mobs from attacking / targeting players");
bedSpawnFix = configuration.getBoolean("bedSpawnFix", Configuration.CATEGORY_GENERAL, bedSpawnFix, "Allows beds to set a player's spawn point during the day (as in 1.15+)");
chatLinebreakFix = configuration.getBoolean("chatLinebreakFix", Configuration.CATEGORY_GENERAL, chatLinebreakFix, "Fixes line breaks in chat not rendering properly, but breaks certain formatting in fixed chat messages");
doubleDoors = configuration.getBoolean("doubleDoors", Configuration.CATEGORY_GENERAL, doubleDoors, "Makes double doors open simultaneously");
hungerless = configuration.getBoolean("hungerless", Configuration.CATEGORY_GENERAL, hungerless, "Makes the hunger system always act as if the difficulty is set to Peaceful (incompat with AppleCore)");
jumpClimbing = configuration.getBoolean("jumpClimbing", Configuration.CATEGORY_GENERAL, jumpClimbing, "Allows climbing ladders by jumping (incompat with slideClimbing)");
keepXP = configuration.getBoolean("keepXP", Configuration.CATEGORY_GENERAL, keepXP, "Players keep their experience level / points on death");
mc5694Fix = configuration.getBoolean("mc5694Fix", Configuration.CATEGORY_GENERAL, mc5694Fix, "Try to fix MC-5694 (\"High efficiency tools / fast mining destroys some blocks client-side only\")");
noTrample = configuration.getBoolean("noTrample", Configuration.CATEGORY_GENERAL, noTrample, "Prevents trampling farmland (completely)");
nnbspFix = configuration.getBoolean("nnbspFix", Configuration.CATEGORY_GENERAL, nnbspFix, "Fixes the \"NNBSP\" character in DateFormat outputs in Java 20+, as in the singleplayer world selection menu");
rmbClear = configuration.getBoolean("rmbClear", Configuration.CATEGORY_GENERAL, rmbClear, "Allows clearing text fields by right-clicking them");
slideClimbing = configuration.getBoolean("slideClimbing", Configuration.CATEGORY_GENERAL, slideClimbing, "Allows traversing ladders by looking up or down (incompat with jumpClimbing)");
sortedEnchantments = configuration.getBoolean("sortedEnchantments", Configuration.CATEGORY_GENERAL, sortedEnchantments, "Sorts enchantments in item tooltips (alphabetically)");

if (configuration.hasChanged()) {
configuration.save();
}
}
@Config.Comment("Prevents mobs from attacking / targeting players")
@Config.DefaultBoolean(false)
public static boolean apatheticMobs;

@Config.Comment("Allows beds to set a player's spawn point during the day (as in 1.15+)")
@Config.DefaultBoolean(true)
public static boolean bedSpawnFix;

@Config.Comment("Fixes line breaks in chat not rendering properly, but breaks certain formatting in fixed chat messages")
@Config.DefaultBoolean(false)
public static boolean chatLinebreakFix;

@Config.Comment("Makes double doors open simultaneously")
@Config.DefaultBoolean(true)
public static boolean doubleDoors;

@Config.Comment("Makes the hunger system always act as if the difficulty is set to Peaceful (incompat with AppleCore)")
@Config.DefaultBoolean(false)
public static boolean hungerless;

@Config.Comment("Allows climbing ladders by jumping (incompat with slideClimbing)")
@Config.DefaultBoolean(true)
public static boolean jumpClimbing;

@Config.Comment("Players keep their experience level / points on death")
@Config.DefaultBoolean(false)
public static boolean keepXP;

@Config.Comment("Try to fix MC-5694 (\"High efficiency tools / fast mining destroys some blocks client-side only\")")
@Config.DefaultBoolean(true)
public static boolean mc5694Fix;

@Config.Comment("Fixes the \"NNBSP\" character in DateFormat outputs in Java 20+, as in the singleplayer world selection menu")
@Config.DefaultBoolean(true)
public static boolean nnbspFix;

@Config.Comment("Prevents trampling farmland (completely)")
@Config.DefaultBoolean(false)
public static boolean noTrample;

@Config.Comment("Allows clearing text fields by right-clicking them")
@Config.DefaultBoolean(true)
public static boolean rmbClear;

@Config.Comment("Allows traversing ladders by looking up or down (incompat with jumpClimbing)")
@Config.DefaultBoolean(false)
public static boolean slideClimbing;

@Config.Comment("Sorts enchantments in item tooltips (alphabetically)")
@Config.DefaultBoolean(true)
public static boolean sortedEnchantments;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unilock.legacyfixes.mixin;
package cc.unilock.legacyfixes.mixin.early.apatheticMobs;

import cc.unilock.legacyfixes.LegacyFixesConfig;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unilock.legacyfixes.mixin;
package cc.unilock.legacyfixes.mixin.early.apatheticMobs;

import cc.unilock.legacyfixes.LegacyFixesConfig;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cc.unilock.legacyfixes.mixin;
package cc.unilock.legacyfixes.mixin.early.bedSpawnFix;

import cc.unilock.legacyfixes.LegacyFixesConfig;
import cc.unilock.legacyfixes.mixin.accessor.EntityPlayerAccessor;
import net.minecraft.block.BlockBed;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentTranslation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unilock.legacyfixes.mixin.accessor;
package cc.unilock.legacyfixes.mixin.early.bedSpawnFix;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChunkCoordinates;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unilock.legacyfixes.mixin.client;
package cc.unilock.legacyfixes.mixin.early.client.chatLinebreakFix;

import cc.unilock.legacyfixes.LegacyFixesConfig;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unilock.legacyfixes.mixin.client;
package cc.unilock.legacyfixes.mixin.early.client.nnbspFix;

import cc.unilock.legacyfixes.LegacyFixesConfig;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unilock.legacyfixes.mixin.client;
package cc.unilock.legacyfixes.mixin.early.client.rmbClear;

import cc.unilock.legacyfixes.LegacyFixesConfig;
import net.minecraft.client.gui.GuiTextField;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unilock.legacyfixes.mixin.client;
package cc.unilock.legacyfixes.mixin.early.client.sortedEnchantments;

import cc.unilock.legacyfixes.LegacyFixesConfig;
import cc.unilock.legacyfixes.util.NBTUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unilock.legacyfixes.mixin.client;
package cc.unilock.legacyfixes.mixin.early.client.sortedEnchantments;

import cc.unilock.legacyfixes.LegacyFixesConfig;
import cc.unilock.legacyfixes.util.NBTUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unilock.legacyfixes.mixin.client.accessor;
package cc.unilock.legacyfixes.mixin.early.client.sortedEnchantments;

import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.unilock.legacyfixes.mixin;
package cc.unilock.legacyfixes.mixin.early.hungerless;

import cc.unilock.legacyfixes.LegacyFixesConfig;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
Expand Down
Loading

0 comments on commit 70e1d09

Please sign in to comment.