diff options
author | boubou19 <miisterunknown@gmail.com> | 2024-08-21 18:40:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-21 18:40:21 +0200 |
commit | 15208bb959da3d192c6dfa44a4f029544e98ddd8 (patch) | |
tree | 6273f3eb4149c7e86c3cee6a775ad2eebad85958 /src/main/java | |
parent | e6687f29ada12095e896855c4b22f8e0bdb2989f (diff) | |
download | GT5-Unofficial-15208bb959da3d192c6dfa44a4f029544e98ddd8.tar.gz GT5-Unofficial-15208bb959da3d192c6dfa44a4f029544e98ddd8.tar.bz2 GT5-Unofficial-15208bb959da3d192c6dfa44a4f029544e98ddd8.zip |
Cleaning up GT5U's post init (#2932)
* wrap MTE ids print into a debug option
* remove EnsureToBeLoadedLast config
* exit early
* spotless apply
* making collision checks optional by default
---------
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/gregtech/GT_Mod.java | 31 | ||||
-rw-r--r-- | src/main/java/gregtech/api/enums/OrePrefixes.java | 29 | ||||
-rw-r--r-- | src/main/java/gregtech/api/recipe/RecipeMap.java | 4 | ||||
-rw-r--r-- | src/main/java/gregtech/api/recipe/RecipeMapBackend.java | 3 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/GT_RecipeBuilder.java | 8 | ||||
-rw-r--r-- | src/main/java/gregtech/common/GT_Proxy.java | 162 | ||||
-rw-r--r-- | src/main/java/gregtech/loaders/preload/GT_PreLoad.java | 50 |
7 files changed, 144 insertions, 143 deletions
diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 17d76f564d..1f9180fc16 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -176,6 +176,7 @@ public class GT_Mod implements IGT_Mod { clientSide = "gregtech.common.GT_Client", serverSide = "gregtech.common.GT_Server") public static GT_Proxy gregtechproxy; + public static final boolean DEBUG = Boolean.getBoolean("gt.debug");; public static int MAX_IC2 = 2147483647; public static GT_Achievements achievements; @@ -334,11 +335,10 @@ public class GT_Mod implements IGT_Mod { new GT_Loader_MetaTileEntities_Recipes().run(); - if (gregtechproxy.mSortToTheEnd) { - new GT_ItemIterator().run(); - gregtechproxy.registerUnificationEntries(); - new GT_FuelLoader().run(); - } + new GT_ItemIterator().run(); + gregtechproxy.registerUnificationEntries(); + new GT_FuelLoader().run(); + if (Mods.Waila.isModLoaded()) { Waila.init(); } @@ -367,6 +367,7 @@ public class GT_Mod implements IGT_Mod { return; } + // Seems only used by GGFab so far for (Runnable tRunnable : GregTech_API.sBeforeGTPostload) { try { tRunnable.run(); @@ -377,20 +378,18 @@ public class GT_Mod implements IGT_Mod { gregtechproxy.onPostLoad(); - final int bound = GregTech_API.METATILEENTITIES.length; - for (int i1 = 1; i1 < bound; i1++) { - if (GregTech_API.METATILEENTITIES[i1] != null) { - GT_Log.out.printf("META %d %s\n", i1, GregTech_API.METATILEENTITIES[i1].getMetaName()); + if (DEBUG) { + // Prints all the used MTE id and their associated TE name, turned on with -Dgt.debug=true in jvm args + final int bound = GregTech_API.METATILEENTITIES.length; + for (int i1 = 1; i1 < bound; i1++) { + if (GregTech_API.METATILEENTITIES[i1] != null) { + GT_Log.out.printf("META %d %s\n", i1, GregTech_API.METATILEENTITIES[i1].getMetaName()); + } } } - if (gregtechproxy.mSortToTheEnd) { - gregtechproxy.registerUnificationEntries(); - } else { - new GT_ItemIterator().run(); - gregtechproxy.registerUnificationEntries(); - new GT_FuelLoader().run(); - } + gregtechproxy.registerUnificationEntries(); + new GT_BookAndLootLoader().run(); new GT_ItemMaxStacksizeLoader().run(); new GT_BlockResistanceLoader().run(); diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index 67371a3a9a..d0c9399980 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -1190,20 +1190,21 @@ public enum OrePrefixes { return; } - if ((aMaterial != Materials._NULL || mIsSelfReferencing || !mIsMaterialBased) - && GT_Utility.isStackValid(aStack)) { - // if (Materials.mPreventableComponents.contains(this) && !this.mDynamicItems.contains(aMaterial)) return; - for (IOreRecipeRegistrator tRegistrator : mOreProcessing) { - if (D2) GT_Log.ore.println( - "Processing '" + aOreDictName - + "' with the Prefix '" - + name() - + "' and the Material '" - + aMaterial.mName - + "' at " - + GT_Utility.getClassName(tRegistrator)); - tRegistrator.registerOre(this, aMaterial, aOreDictName, aModName, GT_Utility.copyAmount(1, aStack)); - } + if (!((aMaterial != Materials._NULL || mIsSelfReferencing || !mIsMaterialBased) + && GT_Utility.isStackValid(aStack))) { + return; + } + + for (IOreRecipeRegistrator tRegistrator : mOreProcessing) { + if (D2) GT_Log.ore.println( + "Processing '" + aOreDictName + + "' with the Prefix '" + + name() + + "' and the Material '" + + aMaterial.mName + + "' at " + + GT_Utility.getClassName(tRegistrator)); + tRegistrator.registerOre(this, aMaterial, aOreDictName, aModName, GT_Utility.copyAmount(1, aStack)); } } diff --git a/src/main/java/gregtech/api/recipe/RecipeMap.java b/src/main/java/gregtech/api/recipe/RecipeMap.java index 8ca9748f4f..46b32d18dd 100644 --- a/src/main/java/gregtech/api/recipe/RecipeMap.java +++ b/src/main/java/gregtech/api/recipe/RecipeMap.java @@ -1,5 +1,7 @@ package gregtech.api.recipe; +import static gregtech.api.util.GT_RecipeBuilder.ENABLE_COLLISION_CHECK; + import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -125,7 +127,7 @@ public final class RecipeMap<B extends RecipeMapBackend> implements IRecipeMap { aRecipe.mFakeRecipe = aFakeRecipe; if (aRecipe.mFluidInputs.length < backend.properties.minFluidInputs && aRecipe.mInputs.length < backend.properties.minItemInputs) return null; - if (aCheckForCollisions && backend.checkCollision(aRecipe)) return null; + if (aCheckForCollisions && ENABLE_COLLISION_CHECK && backend.checkCollision(aRecipe)) return null; return backend.compileRecipe(aRecipe); } diff --git a/src/main/java/gregtech/api/recipe/RecipeMapBackend.java b/src/main/java/gregtech/api/recipe/RecipeMapBackend.java index e41409fd51..8ba0895a7f 100644 --- a/src/main/java/gregtech/api/recipe/RecipeMapBackend.java +++ b/src/main/java/gregtech/api/recipe/RecipeMapBackend.java @@ -1,5 +1,6 @@ package gregtech.api.recipe; +import static gregtech.api.util.GT_RecipeBuilder.ENABLE_COLLISION_CHECK; import static gregtech.api.util.GT_RecipeBuilder.handleInvalidRecipe; import static gregtech.api.util.GT_RecipeBuilder.handleRecipeCollision; import static gregtech.api.util.GT_Utility.areStacksEqualOrNull; @@ -179,7 +180,7 @@ public class RecipeMapBackend { recipe = properties.recipeTransformer.apply(recipe); } if (recipe == null) continue; - if (builder.isCheckForCollision() && checkCollision(recipe)) { + if (builder.isCheckForCollision() && ENABLE_COLLISION_CHECK && checkCollision(recipe)) { handleCollision(recipe); continue; } diff --git a/src/main/java/gregtech/api/util/GT_RecipeBuilder.java b/src/main/java/gregtech/api/util/GT_RecipeBuilder.java index e8ae449c2d..137b7d6c86 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeBuilder.java +++ b/src/main/java/gregtech/api/util/GT_RecipeBuilder.java @@ -37,13 +37,20 @@ public class GT_RecipeBuilder { // debug mode expose problems. panic mode help you check nothing is wrong-ish without you actively monitoring private static final boolean DEBUG_MODE_NULL; + // Any stable release should be tested at least once with this: -Dgt.recipebuilder.panic.null=true private static boolean PANIC_MODE_NULL; private static final boolean DEBUG_MODE_INVALID; private static final boolean DEBUG_MODE_FULL_ENERGY; + // Any stable release should be tested at least once with this: -Dgt.recipebuilder.panic.invalid=true private static final boolean PANIC_MODE_INVALID; private static final boolean DEBUG_MODE_COLLISION; + + // Any stable release should be tested at least once with this: -Dgt.recipebuilder.panic.collision=true private static final boolean PANIC_MODE_COLLISION; + // This should only be enabled in non stable instances only with -Dgt.recipebuilder.recipe_collision_check=true + public static final boolean ENABLE_COLLISION_CHECK; + public static final int WILDCARD = 32767; // time units @@ -78,6 +85,7 @@ public class GT_RecipeBuilder { PANIC_MODE_NULL = panicAll || Boolean.getBoolean("gt.recipebuilder.panic.null"); PANIC_MODE_INVALID = panicAll || Boolean.getBoolean("gt.recipebuilder.panic.invalid"); PANIC_MODE_COLLISION = panicAll || Boolean.getBoolean("gt.recipebuilder.panic.collision"); + ENABLE_COLLISION_CHECK = Boolean.getBoolean("gt.recipebuilder.recipe_collision_check"); } protected ItemStack[] inputsBasic = new ItemStack[0]; diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 891c46fd92..b6eb9ec3ad 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1732,8 +1732,7 @@ public abstract class GT_Proxy implements IGT_Mod, IFuelHandler { } } String tModToName = aMod + " -> " + aEvent.Name; - if ((this.mOreDictActivated) || (GregTech_API.sPostloadStarted) - || ((this.mSortToTheEnd) && (GregTech_API.sLoadFinished))) { + if (this.mOreDictActivated || GregTech_API.sPostloadStarted || GregTech_API.sLoadFinished) { tModToName = aOriginalMod + " --Late--> " + aEvent.Name; } if (((aEvent.Ore.getItem() instanceof ItemBlock)) @@ -2313,113 +2312,108 @@ public abstract class GT_Proxy implements IGT_Mod, IFuelHandler { } public static void registerRecipes(GT_Proxy.OreDictEventContainer aOre) { - if ((aOre.mEvent.Ore == null) || (aOre.mEvent.Ore.getItem() == null)) { + if ((aOre.mEvent.Ore == null) || (aOre.mEvent.Ore.getItem() == null) + || (aOre.mPrefix == null) + || (aOre.mPrefix.isIgnored(aOre.mMaterial))) { return; } if (aOre.mEvent.Ore.stackSize != 1) { aOre.mEvent.Ore.stackSize = 1; } - if (aOre.mPrefix != null) { - if (!aOre.mPrefix.isIgnored(aOre.mMaterial)) { - aOre.mPrefix.processOre( - aOre.mMaterial == null ? Materials._NULL : aOre.mMaterial, - aOre.mEvent.Name, - aOre.mModID, - GT_Utility.copyAmount(1, aOre.mEvent.Ore)); - } - } else { - // GT_FML_LOGGER.info("Thingy Name: "+ aOre.mEvent.Name+ " !!!Unknown 'Thingy' detected!!! This - // Object seems to probably not follow a valid OreDictionary Convention, or I missed a Convention. Please - // report to GregTech Intergalactical for additional compatiblity. This is not an Error, an Issue nor a Lag - // Source, it is just an Information, which you should pass to me."); - } + + aOre.mPrefix.processOre( + aOre.mMaterial == null ? Materials._NULL : aOre.mMaterial, + aOre.mEvent.Name, + aOre.mModID, + GT_Utility.copyAmount(1, aOre.mEvent.Ore)); } @SubscribeEvent public void onPlayerTickEventServer(TickEvent.PlayerTickEvent aEvent) { - if ((aEvent.side.isServer()) && (aEvent.phase == TickEvent.Phase.END) && (!aEvent.player.isDead)) { - if ((aEvent.player.ticksExisted % 200 == 0) && (aEvent.player.capabilities.allowEdit) - && (!aEvent.player.capabilities.isCreativeMode) - && (this.mSurvivalIntoAdventure)) { - aEvent.player.setGameType(GameType.ADVENTURE); - aEvent.player.capabilities.allowEdit = false; - if (this.mAxeWhenAdventure) { - GT_Utility.sendChatToPlayer( - aEvent.player, - GT_LanguageManager.addStringLocalization( - "Interaction_DESCRIPTION_Index_097", - "It's dangerous to go alone! Take this.")); - aEvent.player.worldObj.spawnEntityInWorld( - new EntityItem( - aEvent.player.worldObj, - aEvent.player.posX, - aEvent.player.posY, - aEvent.player.posZ, - GT_MetaGenerated_Tool_01.INSTANCE - .getToolWithStats(ID_MetaTool_01.AXE.ID, 1, Materials.Flint, Materials.Wood, null))); - } - } - final boolean tHungerEffect = (this.mHungerEffect) && (aEvent.player.ticksExisted % 2400 == 1200); + if ((!aEvent.side.isServer()) || (aEvent.phase == TickEvent.Phase.END) || (aEvent.player.isDead)) { + return; + } - if (aEvent.player.ticksExisted % 120 != 0) { - return; + if ((aEvent.player.ticksExisted % 200 == 0) && (aEvent.player.capabilities.allowEdit) + && (!aEvent.player.capabilities.isCreativeMode) + && (this.mSurvivalIntoAdventure)) { + aEvent.player.setGameType(GameType.ADVENTURE); + aEvent.player.capabilities.allowEdit = false; + if (this.mAxeWhenAdventure) { + GT_Utility.sendChatToPlayer( + aEvent.player, + GT_LanguageManager.addStringLocalization( + "Interaction_DESCRIPTION_Index_097", + "It's dangerous to go alone! Take this.")); + aEvent.player.worldObj.spawnEntityInWorld( + new EntityItem( + aEvent.player.worldObj, + aEvent.player.posX, + aEvent.player.posY, + aEvent.player.posZ, + GT_MetaGenerated_Tool_01.INSTANCE + .getToolWithStats(ID_MetaTool_01.AXE.ID, 1, Materials.Flint, Materials.Wood, null))); } + } + final boolean tHungerEffect = (this.mHungerEffect) && (aEvent.player.ticksExisted % 2400 == 1200); - int tCount = 64; - for (int i = 0; i < 36; i++) { - final ItemStack tStack = aEvent.player.inventory.getStackInSlot(i); - if (tStack == null) { - continue; - } + if (aEvent.player.ticksExisted % 120 != 0) { + return; + } - if (!aEvent.player.capabilities.isCreativeMode) { - GT_Utility - .applyRadioactivity(aEvent.player, GT_Utility.getRadioactivityLevel(tStack), tStack.stackSize); - final float tHeat = GT_Utility.getHeatDamageFromItem(tStack); - if (tHeat != 0.0F) { - if (tHeat > 0.0F) { - GT_Utility.applyHeatDamageFromItem(aEvent.player, tHeat, tStack); - } else { - GT_Utility.applyFrostDamage(aEvent.player, -tHeat); - } + int tCount = 64; + for (int i = 0; i < 36; i++) { + final ItemStack tStack = aEvent.player.inventory.getStackInSlot(i); + if (tStack == null) { + continue; + } + + if (!aEvent.player.capabilities.isCreativeMode) { + GT_Utility + .applyRadioactivity(aEvent.player, GT_Utility.getRadioactivityLevel(tStack), tStack.stackSize); + final float tHeat = GT_Utility.getHeatDamageFromItem(tStack); + if (tHeat != 0.0F) { + if (tHeat > 0.0F) { + GT_Utility.applyHeatDamageFromItem(aEvent.player, tHeat, tStack); + } else { + GT_Utility.applyFrostDamage(aEvent.player, -tHeat); } } - if (tHungerEffect) { - tCount += tStack.stackSize * 64 / Math.max(1, tStack.getMaxStackSize()); - } - if (this.mInventoryUnification) { - GT_OreDictUnificator.setStack(true, tStack); - } + } + if (tHungerEffect) { + tCount += tStack.stackSize * 64 / Math.max(1, tStack.getMaxStackSize()); + } + if (this.mInventoryUnification) { + GT_OreDictUnificator.setStack(true, tStack); + } + } + for (int i = 0; i < 4; i++) { + final ItemStack tStack = aEvent.player.inventory.armorInventory[i]; + if (tStack == null) { + continue; } - for (int i = 0; i < 4; i++) { - final ItemStack tStack = aEvent.player.inventory.armorInventory[i]; - if (tStack == null) { - continue; - } - if (!aEvent.player.capabilities.isCreativeMode) { - GT_Utility - .applyRadioactivity(aEvent.player, GT_Utility.getRadioactivityLevel(tStack), tStack.stackSize); - final float tHeat = GT_Utility.getHeatDamageFromItem(tStack); - if (tHeat != 0.0F) { - if (tHeat > 0.0F) { - GT_Utility.applyHeatDamageFromItem(aEvent.player, tHeat, tStack); - } else { - GT_Utility.applyFrostDamage(aEvent.player, -tHeat); - } + if (!aEvent.player.capabilities.isCreativeMode) { + GT_Utility + .applyRadioactivity(aEvent.player, GT_Utility.getRadioactivityLevel(tStack), tStack.stackSize); + final float tHeat = GT_Utility.getHeatDamageFromItem(tStack); + if (tHeat != 0.0F) { + if (tHeat > 0.0F) { + GT_Utility.applyHeatDamageFromItem(aEvent.player, tHeat, tStack); + } else { + GT_Utility.applyFrostDamage(aEvent.player, -tHeat); } } - if (tHungerEffect) { - tCount += 256; - } - } if (tHungerEffect) { - aEvent.player.addExhaustion(Math.max(1.0F, tCount / 666.6F)); + tCount += 256; } } + if (tHungerEffect) { + aEvent.player.addExhaustion(Math.max(1.0F, tCount / 666.6F)); + } } public GT_ClientPreference getClientPreference(UUID aPlayerID) { diff --git a/src/main/java/gregtech/loaders/preload/GT_PreLoad.java b/src/main/java/gregtech/loaders/preload/GT_PreLoad.java index d1700da3ea..26d75c7933 100644 --- a/src/main/java/gregtech/loaders/preload/GT_PreLoad.java +++ b/src/main/java/gregtech/loaders/preload/GT_PreLoad.java @@ -56,33 +56,31 @@ import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; public class GT_PreLoad { public static void sortToTheEnd() { - if (GT_Mod.gregtechproxy.mSortToTheEnd) { - try { - GT_FML_LOGGER.info("GT_Mod: Sorting GregTech to the end of the Mod List for further processing."); - LoadController tLoadController = (LoadController) GT_Utility - .getFieldContent(Loader.instance(), "modController", true, true); - assert tLoadController != null; - List<ModContainer> tModList = tLoadController.getActiveModList(); - List<ModContainer> tNewModsList = new ArrayList<>(); - ModContainer tGregTech = null; - short tModList_sS = (short) tModList.size(); - for (short i = 0; i < tModList_sS; i = (short) (i + 1)) { - ModContainer tMod = tModList.get(i); - if (tMod.getModId() - .equalsIgnoreCase(GregTech.ID)) { - tGregTech = tMod; - } else { - tNewModsList.add(tMod); - } - } - if (tGregTech != null) { - tNewModsList.add(tGregTech); + try { + GT_FML_LOGGER.info("GT_Mod: Sorting GregTech to the end of the Mod List for further processing."); + LoadController tLoadController = (LoadController) GT_Utility + .getFieldContent(Loader.instance(), "modController", true, true); + assert tLoadController != null; + List<ModContainer> tModList = tLoadController.getActiveModList(); + List<ModContainer> tNewModsList = new ArrayList<>(); + ModContainer tGregTech = null; + short tModList_sS = (short) tModList.size(); + for (short i = 0; i < tModList_sS; i = (short) (i + 1)) { + ModContainer tMod = tModList.get(i); + if (tMod.getModId() + .equalsIgnoreCase(GregTech.ID)) { + tGregTech = tMod; + } else { + tNewModsList.add(tMod); } - Objects.requireNonNull(GT_Utility.getField(tLoadController, "activeModList", true, true)) - .set(tLoadController, tNewModsList); - } catch (Throwable e) { - GT_Mod.logStackTrace(e); } + if (tGregTech != null) { + tNewModsList.add(tGregTech); + } + Objects.requireNonNull(GT_Utility.getField(tLoadController, "activeModList", true, true)) + .set(tLoadController, tNewModsList); + } catch (Throwable e) { + GT_Mod.logStackTrace(e); } } @@ -521,8 +519,6 @@ public class GT_PreLoad { GT_Mod.gregtechproxy.mNerfedVanillaTools = tMainConfig .get(GT_Mod.aTextGeneral, "smallerVanillaToolDurability", true) .getBoolean(true); - GT_Mod.gregtechproxy.mSortToTheEnd = tMainConfig.get(GT_Mod.aTextGeneral, "EnsureToBeLoadedLast", true) - .getBoolean(true); GT_Mod.gregtechproxy.mAchievements = tMainConfig.get(GT_Mod.aTextGeneral, "EnableAchievements", true) .getBoolean(true); GT_Mod.gregtechproxy.mHideUnusedOres = tMainConfig.get(GT_Mod.aTextGeneral, "HideUnusedOres", true) |