Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup ASM/mixins coremods #261

Merged
merged 13 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ forgeVersion = 10.13.4.1614
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = Developer

# Define a source file of your project with:
# Generate a class with String fields for the mod id, name, version and group name named with the fields below
generateGradleTokenClass = com.mitchej123.hodgepodge.Tags
gradleTokenModId =
gradleTokenModName = MODNAME
gradleTokenVersion = VERSION
gradleTokenGroupName =
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = Hodgepodge.java
gradleTokenModId =
gradleTokenModName =
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName =
replaceGradleTokenInFile =

# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can
# leave this property empty.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/mitchej123/hodgepodge/Hodgepodge.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class Hodgepodge {
public static final AnchorAlarm ANCHOR_ALARM = new AnchorAlarm();
public static final HodgepodgeEventHandler EVENT_HANDLER = new HodgepodgeEventHandler();
public static final String MODID = "hodgepodge";
public static final String VERSION = "GRADLETOKEN_VERSION";
public static final String NAME = "Hodgepodge";
public static final String VERSION = Tags.VERSION;
public static final String NAME = Tags.MODNAME;

@EventHandler
public void preinit(FMLPreInitializationEvent event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.mitchej123.hodgepodge;

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

Expand All @@ -19,18 +17,6 @@ public String getMixinConfig() {

@Override
public List<String> getMixins(Set<String> loadedMods) {
final List<String> mixins = new ArrayList<>();
final List<String> notLoading = new ArrayList<>();
for (Mixins mixin : Mixins.values()) {
if (mixin.phase == Mixins.Phase.LATE) {
if (mixin.shouldLoad(Collections.emptySet(), loadedMods)) {
mixins.addAll(mixin.mixinClasses);
} else {
notLoading.addAll(mixin.mixinClasses);
}
}
}
Common.log.info("Not loading the following LATE mixins: {}", notLoading.toString());
return mixins;
return Mixins.getLateMixins(loadedMods);
}
}
51 changes: 21 additions & 30 deletions src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

public class LoadingConfig {

private Configuration config;

// Adjustments
public boolean addSystemInfo;
public boolean arabicNumbersForEnchantsPotions;
Expand All @@ -19,7 +21,6 @@ public class LoadingConfig {
public int particleLimit;

// Mixins

public boolean addCVSupportToWandPedestal;
public boolean addToggleDebugMessage;
public boolean deduplicateForestryCompatInBOP;
Expand Down Expand Up @@ -148,12 +149,16 @@ public class LoadingConfig {
public boolean validatePacketEncodingBeforeSendingShouldCrash;
public boolean chunkSaveCMEDebug;
public boolean ic2CellWithContainer;
public boolean cofhWorldTransformer;
public boolean enableTileRendererProfiler;
public boolean disableAidSpawnByXUSpikes;

// render debug
public boolean renderDebug;
public int renderDebugMode;

// Pollution :nauseous:
public boolean pollutionBlockRecolor;
public boolean furnacesPollute;
public boolean rocketsPollute;
public boolean railcraftPollutes;
Expand All @@ -166,22 +171,13 @@ public class LoadingConfig {
public int tunnelBorePollutionAmount;
public double explosionPollutionAmount;

// ASM
public boolean cofhWorldTransformer;
public boolean enableTileRendererProfiler;
public boolean pollutionAsm;

public boolean disableAidSpawnByXUSpikes;

public String thermosCraftServerClass;

public static Configuration config;

public static BlockMatcher standardBlocks = new BlockMatcher();
public static BlockMatcher liquidBlocks = new BlockMatcher();
public static BlockMatcher doublePlants = new BlockMatcher();
public static BlockMatcher crossedSquares = new BlockMatcher();
public static BlockMatcher blockVine = new BlockMatcher();
public BlockMatcher standardBlocks = new BlockMatcher();
public BlockMatcher liquidBlocks = new BlockMatcher();
public BlockMatcher doublePlants = new BlockMatcher();
public BlockMatcher crossedSquares = new BlockMatcher();
public BlockMatcher blockVine = new BlockMatcher();

enum Category {

Expand Down Expand Up @@ -344,18 +340,14 @@ public LoadingConfig(File file) {
transparentChat = config.get(Category.TWEAKS.toString(), "transparentChat", true, "Doesn't render the black box behind messages when the chat is closed").getBoolean();
triggerAllConflictingKeybindings = config.get(Category.FIXES.toString(), "triggerAllConflictingKeybindings", true, "Triggers all conflicting key bindings on key press instead of a random one").getBoolean();
unbindKeybindsByDefault = config.get(Category.TWEAKS.toString(), "unbindKeybindsByDefault", true, "Unbinds keybinds of certain ARR mods to avoid keybinds conflicts").getBoolean();
ic2CellWithContainer = config.get(Category.TWEAKS.toString(), "ic2CellWithContainer ", false, "give ic2 cells containers like gregtech cells do").getBoolean();

// Disable for now as it is not compatible with anything modifying RenderBlocks
pollutionAsm = config.get(Category.ASM.toString(), "pollutionAsm", false, "Enable pollution rendering ASM").getBoolean();
disableAidSpawnByXUSpikes = config.get(Category.TWEAKS.toString(), "disableAidSpawnByXUSpikes", true, "Disables the spawn of zombie aid when zombie is killed by Extra Utilities Spikes, since it can spawn them too far.").getBoolean();
ic2CellWithContainer = config.get(Category.TWEAKS.toString(), "ic2CellWithContainer", false, "give ic2 cells containers like gregtech cells do").getBoolean();

// Pollution :nauseous:
pollutionBlockRecolor = config.get(Category.POLLUTION_RECOLOR.toString(), "pollutionRecolor", true, "Changes colors of certain blocks based on pollution levels").getBoolean();
furnacesPollute = config.get(Category.POLLUTION.toString(), "furnacesPollute", true, "Make furnaces Pollute").getBoolean();
rocketsPollute = config.get(Category.POLLUTION.toString(), "rocketsPollute", true, "Make rockets Pollute").getBoolean();
railcraftPollutes = config.get(Category.POLLUTION.toString(), "railcraftPollutes", true, "Make Railcraft Pollute").getBoolean();

disableAidSpawnByXUSpikes = config.get(Category.TWEAKS.toString(), "disableAidSpawnByXUSpikes", true, "Disables the spawn of zombie aid when zombie is killed by Extra Utilities Spikes, since it can spawn them too far.").getBoolean();

furnacePollutionAmount = config.get(Category.POLLUTION.toString(), "furnacePollution", 20, "Furnace pollution per second, min 1!", 1, Integer.MAX_VALUE).getInt();
fireboxPollutionAmount = config.get(Category.POLLUTION.toString(), "fireboxPollution", 15, "Pollution Amount for RC Firebox", 1, Integer.MAX_VALUE).getInt();
rocketPollutionAmount = config.get(Category.POLLUTION.toString(), "rocketPollution", 1000, "Pollution Amount for Rockets", 1, Integer.MAX_VALUE).getInt();
Expand All @@ -365,12 +357,11 @@ public LoadingConfig(File file) {
tunnelBorePollutionAmount = config.get(Category.POLLUTION.toString(), "tunnelBorePollution", 2, "Pollution Amount for tunnel bore", 1, Integer.MAX_VALUE).getInt();
explosionPollutionAmount = config.get(Category.POLLUTION.toString(), "explosionPollution", 33.34, "Explosion pollution").getDouble();


// spotless:on
if (config.hasChanged()) config.save();
}

public static void postInitClient() {
public void postInitClient() {
// need to be done later cause it initializes classes
if (config == null) {
System.err.println("Didn't load HODGEPODGE");
Expand All @@ -393,26 +384,26 @@ public static void postInitClient() {
* Defaults
*/

public static final String[] defaultPollutionRenderStandardBlock = new String[] {
private static final String[] defaultPollutionRenderStandardBlock = new String[] {
"net.minecraft.block.BlockGrass:GRASS", "net.minecraft.block.BlockLeavesBase:LEAVES",
"biomesoplenty.common.blocks.BlockOriginGrass:GRASS", "biomesoplenty.common.blocks.BlockLongGrass:GRASS",
"biomesoplenty.common.blocks.BlockNewGrass:GRASS", "tconstruct.blocks.slime.SlimeGrass:GRASS",
"thaumcraft.common.blocks.BlockMagicalLeaves:LEAVES", };

public static final String[] defaultPollutionRenderLiquidBlocks = new String[] {
private static final String[] defaultPollutionRenderLiquidBlocks = new String[] {
"net.minecraft.block.BlockLiquid:LIQUID", };

public static final String[] defaultPollutionRenderDoublePlant = new String[] {
private static final String[] defaultPollutionRenderDoublePlant = new String[] {
"net.minecraft.block.BlockDoublePlant:FLOWER", };

public static final String[] defaultPollutionRenderCrossedSquares = new String[] {
private static final String[] defaultPollutionRenderCrossedSquares = new String[] {
"net.minecraft.block.BlockTallGrass:FLOWER", "net.minecraft.block.BlockFlower:FLOWER",
"biomesoplenty.common.blocks.BlockBOPFlower:FLOWER", "biomesoplenty.common.blocks.BlockBOPFlower2:FLOWER",
"biomesoplenty.common.blocks.BlockBOPFoliage:FLOWER", };
public static final String[] defaultPollutionRenderblockVine = new String[] {
private static final String[] defaultPollutionRenderblockVine = new String[] {
"net.minecraft.block.BlockVine:FLOWER", };

public static final String pollutionRecolorComment = "Blocks that should be colored by pollution. \n"
private static final String pollutionRecolorComment = "Blocks that should be colored by pollution. \n"
+ "\tGrouped by the render type. \n"
+ "\tFormat: [BlockClass]:[colortype] \n"
+ "\tValid types: GRASS, LEAVES, FLOWER, LIQUID \n"
Expand Down
66 changes: 66 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/asm/AsmTransformers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.mitchej123.hodgepodge.asm;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;

import com.mitchej123.hodgepodge.Common;

import cpw.mods.fml.relauncher.FMLLaunchHandler;

public enum AsmTransformers {

// spotless:off
SPEEDUP_PROGRESS_BAR(
"Speed up Progress Bar by speeding up stripSpecialCharacters",
() -> Common.config.speedupProgressBar,
Side.CLIENT,
"com.mitchej123.hodgepodge.asm.transformers.fml.SpeedupProgressBarTransformer"),
THERMOS_SLEDGEHAMMER_FURNACE_FIX(
"Take a sledgehammer to CraftServer.resetRecipes() to prevent it from breaking our Furnace Fix",
() -> Common.thermosTainted && Common.config.speedupVanillaFurnace,
Side.BOTH,
"com.mitchej123.hodgepodge.asm.transformers.thermos.ThermosFurnaceSledgeHammer");
// spotless:on

private final Supplier<Boolean> applyIf;
private final Side side;
private final String[] transformerClasses;

AsmTransformers(@SuppressWarnings("unused") String description, Supplier<Boolean> applyIf, Side side,
String... transformers) {
this.applyIf = applyIf;
this.side = side;
this.transformerClasses = transformers;
}

private boolean shouldBeLoaded() {
return applyIf.get() && shouldLoadSide();
}

private boolean shouldLoadSide() {
return side == Side.BOTH || (side == Side.SERVER && FMLLaunchHandler.side().isServer())
|| (side == Side.CLIENT && FMLLaunchHandler.side().isClient());
}

public static String[] getTransformers() {
final List<String> list = new ArrayList<>();
for (AsmTransformers transformer : values()) {
if (transformer.shouldBeLoaded()) {
Common.log.info("Loading transformer {}", (Object[]) transformer.transformerClasses);
list.addAll(Arrays.asList(transformer.transformerClasses));
} else {
Common.log.info("Not loading transformer {}", (Object[]) transformer.transformerClasses);
}
}
return list.toArray(new String[0]);
}

private enum Side {
BOTH,
CLIENT,
SERVER
}

}
131 changes: 0 additions & 131 deletions src/main/java/com/mitchej123/hodgepodge/asm/References.java

This file was deleted.

Loading