aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
AgeCommit message (Collapse)Author
2023-07-28Less hostile user interfaces (Buffer/Filter/Input bus) (#2165)Yannick Marcotte-Gourde
* Made Emit Energy button a CycleButtonWidget * Made Emit Redstone button a CycleButtonWidget * Made Invert Redstone button a CycleButtonWidget * Made Stocking Mode button a CycleButtonWidget * Spotless apply * Made Invert Filter button a CycleButtonWidget * public bInvertFilter -> protected invertFilter * Deduplicated filter code * Made Allow NBT button a CycleButtonWidget * Made Ignore NBT button a CycleButtonWidget * public bNBTAllowed -> private allowNbt * public bNBTAllowed -> private ignoreNbt * Grey extended tooltips * Don't hardcode multiline tooltips * Document hidden functionality * Cleaned numeric constants * Fixed string constant declaration * Named constants in filter * Unify filter redstone behavior * Fix cover filter mode being inverted so that the displayed mode is the active one * Less magic numbers * Allow right clicking recipe filter * Display only machine type in recipe filter and cycle through compatible machines * Buffer tooltips show output voltage to clarify their role as passthroughs * Added more info to Emit EU/Redstone buttons * Added Sorting mode button to buffers/filters * Added Sorting mode button and stack limit button to input buses * Don't cycle prefixes when clicking with itemstack * Fixed tooltips to work off of the inventory * Fix RecipeFilter losing filter * Support multiblock machines * Use ModularUi syncers to sync state with client Thanks minecraft7771! * Grey text for recipe filter helper text * AnimatedTooltipHandler -> EnumChatFormatting * Explicited RecipeFilter filter building * Specify color for empty slot tooltip * Don't cache new uses of GT5U.MBTT.MachineType. Also corrected MachineType::description * Removed unused getItemExtraTooltip * Multiple returns in getItemStackMachineRecipeMap
2023-07-28Add more API to ParallelHelper and rework OverclockCalculator (#2185)BlueWeabo
* refactor OC calc * somewhat refactor parallel helper * fix PA not OCing correctly no clue why it wasn't using super and then setting the duration again. * make use of new api to make fusion cleaner * make batch mode actually dynamic * add another reason for 0 parallel * move variables around to try and group them together * address reviews * add overclocking past 1 tick by adding parallels * add null check and make a basic calculator to prevent npe * check null recipeMap supplier * address reviews * addressing of reviews * make it possible to call some OverclockCalculator methods through static methods * address reviews * make sure one doesn't get too many OCs when calculatin under 1 tick * add api for custom duration under one tick and fix batch mode doing 0 ticking * fix not calculating duration under 1 tick correctly * spotless * try to have correct eut consumption * address review * make sure mk5 fusion is said in nei * fix eutCalculating under one tick way too much and address reviews * remove roundUp voltage
2023-07-26Remove "Ore Byproduct List" NEI in favor of custom diagram mod (#2183)miozune
2023-07-24Make Parallel Helper do better chanced output calculation for paralleled ↵BlueWeabo
chanced recipes (#2130) * better calculation * roll for each parallel * skip rolling for recipes with chance at 100% * address not setting as null when stcksize is 0
2023-07-24fix implosion compressor requiring wrong amount of output (#2168)Glease
2023-07-22Fix recipe check broken by fluid registry (#2161)miozune
2023-07-22Exposed recipe consumption via method (#2162)Maxim
* Exposed recipe consumption via method
2023-07-19Migrate fusion reactor to proper generic processing logic (#2145)Maxim
* Migrate fusion to generic processing logic * Adjusted OC calculator to allow max number of OCs * Fixed typo * Fix buffer consumption logic * Fix oversight * Addressed reviews
2023-07-18Fix GT_ParallelHelper always doing batch mode parallels instead of focusing ↵BlueWeabo
on normal parallels (#2147) * fix * make sure normal parallels are ran before batch mode
2023-07-18Added machine type on single block tooltips (#2138)boubou19
* change tooltips * put machine types together * Added constructor to accept multi line tooltip on sbs * sorting machine registering methods * update MachineType * migrate machines to multiline description * add new constructor for matter amplifier * migrate matter amplifier to multi line tooltip * spotless apply * Capitalize machine types * breakdown large run methods into themed methods * migrate TE IDs to an enum (1/?) * spotless apply * migrate TE IDs to an enum (2/?) * migrate TE IDs to an enum (3/?) * migrate TE IDs to an enum (4/?) * spotless apply * sorting crafting recipes by type + fix meta id typo * migrate TE IDs to an enum(5/?) * spotless apply * merge master (#2143) * Make structure tooltips more colorful (#2133) * default color changes * add colored casing amount builders * oversight * address reviews * GPL Special Item access (#2134) * Added getters to allow a machine to set the special item for recipe checking * Changes to ore factorys running mode description (#2135) * Changes the integrated ore factory mode description to match what its actually doing. * Some tooltip grammar changes. That would have annoyed me :) * Enable void protection for PA (#2136) * Added ofNoOverclock builder that accepts eut and duration (#2140) * Fix findRecipe might limit stack size by 64 (#2139) * Fix potential issue with applecore ItemFoodProxy (#2137) * Fix potential issue with applecore ItemFoodProxy * Fix the worst class loader issue ive ever encountered --------- Co-authored-by: GDCloud <93287602+GDCloudstrike@users.noreply.github.com> Co-authored-by: Maxim <maxim235@gmx.de> Co-authored-by: Lyfts <127234178+Lyfts@users.noreply.github.com> Co-authored-by: miozune <miozune@gmail.com> Co-authored-by: Serenibyss <10861407+serenibyss@users.noreply.github.com> * Moved machine type and descriptions to lang files * Removed redundant visibility modifier * Only expose translated descriptions * Using prefix gt.recipe for NEI compatibility * Deprecate use of LanguageManager in GT_Recipe_Map * Unify GT_Recipe and MachineType localization * Electromagnetic Polarizer consistency with Separator * Added Packager MachineType * Added Scanner MachineType * Added Rock breaker MachineType * Added Mass Fabricator MachineType * Added Replicator MachineType * Added "Machine Type" tooltip to steam machines * public modifier unnecessary * Spotless apply --------- Co-authored-by: minecraft7771 <maxim235@gmx.de> Co-authored-by: Martin Robertz <dream-master@gmx.net> Co-authored-by: GDCloud <93287602+GDCloudstrike@users.noreply.github.com> Co-authored-by: Lyfts <127234178+Lyfts@users.noreply.github.com> Co-authored-by: miozune <miozune@gmail.com> Co-authored-by: Serenibyss <10861407+serenibyss@users.noreply.github.com> Co-authored-by: YannickMG <yannickmg@gmail.com>
2023-07-17Fix division by zero error with VoidProtectionHelper (#2144)miozune
2023-07-17Fix findRecipe might limit stack size by 64 (#2139)miozune
2023-07-16Added ofNoOverclock builder that accepts eut and duration (#2140)Maxim
2023-07-13Make structure tooltips more colorful (#2133)GDCloud
* default color changes * add colored casing amount builders * oversight * address reviews
2023-07-10Generic processing logic (#2096)Maxim
* Added enumeration for check recipe result * Rework processing logic to work with MTEs too * Switched first few multiblocks to new checkRecipe method * Applied generic logic to EBF * Added support for long power base and applied generic processing logic to more machines * Address some feedback * Added more setter to further configure the processing logic * Change internal checkRecipe to work with checkRecipeResult, to allow the injection of custom failure messages * Suppress warning, change access * Merge recipeMap and mapSupplier * Move calls to setMetaTEController and setRecipeMap to base classes * Make processingLogic final * Make results non-null * Rename `ProcessingLogic#checkRecipe` -> `#validateRecipe` Otherwise it's confusing with `GT_MetaTileEntity_MultiBlockBase#checkRecipe` * oops * Added recipe locking to generic processing logic * Rename: getWorldObject -> getIHasWorldObjectAndCoords * Annotate missing overrides * Renamed recipeLockableController -> recipeLockableMachine * Migrated Cleanroom * Migrated pyrolyse oven * Migrated driller * Migrated charcoal pit * Migrated DT * Rename: controller -> machine * Make recipemaps override base `findRecipe` and mark others final * Remove unused maps * Add FindRecipeResult * Remove IHasWorldObjectAndCoords parameter from findRecipe This removes argument for printer recipemap to pass for GT_ModHandler.getAllRecipeOutput, but I don't think there's any mod that adds world-specific coloring recipe. * Added method to set processing logic power so machines can override it on demand * Restructure CheckRecipeResult, show voltage required and move package * Reword: insufficient voltage -> power * Change text color: dark gray -> gray * Added findRecipeResult for insufficient heat * Migrated PCB factory * Fix result not being reset on shut down * Show coil tier for heat * clean * Reverted migration of driller base * Migrated TPM * Moved getting of parallel supplier, to accomodate TPM * Migrated power gen multiblocks * Migrated Assembling Line * Migrated fusion * Migrated multi smelter * Migrated boiler * Migrated DTPF * Migrated ore factory * Migrated heat exchanger * Make checkRecipe() final, javadoc, minor cleanup * Fix overclock behavior with multiple hatches, javadoc, minor cleanup * Minor fix for javadoc * Fixed creation of OC calculator not factoring in batch mode correctly * Make GT_ParallelHelper#setRecipe nonnull * Rework SimpleCheckRecipeResult to not require registration * Migrate charcoal pit and cleanroom * Fix result not being reset when turning off machine * Add API for BW to make recipemap sensitive to special slot on recipe search * Migrated PA * Migrated driller base * Make ProcessingLogic#duration int * Minor cleanup * missing recipe locking for long multi * Fix NPE * Show crash message and turn off machine * minor javadoc fix * Fixed power setting for extended power base * Integrate SingleRecipeCheck into ProcessingLogic, fix duration overflow, fix duration for batch mode, migrate PA for GT_MetaTileEntity_ExtendedPowerMultiBlockBase * Fixed ME stocking busses * Minor PA fixes * Cleanup item collecting logic & apply to normal multi as well * Oversight * Derp * Multiple voltage instead of amperage with recipe map amperage, since usually amperage is intended for parallel, not for recipe checking * Fix missing EU modifiers on PCB factory OC calculator * Removed left over OC method * Fixed duration calculation of PCB not applying roughness multiplier * Fixed OC parameters * Make createOverclockCalculator nonnull & more nonnull annotations * Fixed input processing voltage * Round down voltage for other machines too * Revert Nano Forge, return correct long voltage * Use region / endregion --------- Co-authored-by: miozune <miozune@gmail.com>
2023-07-06Remove container item check (#2118)Jakub
2023-06-19Fix chunk corruption when using single recipe lock (#2092)Maxim
* Added null checks to single recipe check saving * Removed left over brackets
2023-06-18Fix Precision (#2091)Runakai1
* Fix Precision This increases the maximum amount of temperature upgrades from 8 to 10 while halfing the amount of temperature boost they give to allow for more precision. Previously you were not able to simulate a warm biome in normal/normal. Doubles Boost, halfes energy consumption. * increase to 16
2023-06-18Add class for handling external materials (#2089)miozune
2023-06-12Fix missing copy call for fluid recipe builder (#2078)miozune
* Fix missing copy call for fluid recipe builder * maybe this needs copy as well?
2023-06-07Enable fire resistance checks for heat and hot item damage (#2065)Wilhelm Schuster
2023-06-07Remove GT_FluidStack (#2063)miozune
2023-06-05Fix fluid registry related bugs (#2057)miozune
2023-06-05Use IVoidable for GT_ParallelHelper (#2053)miozune
2023-06-05Code cleanup (#2040)chill
* remove redundant suppressions * prettify commented code * improve comments The integer comment contradicted the code, so I deleted it. * delete commented-out code * update bitwise int flip from XOR to the dedicated tilda operator The flip was a 32-bit XOR, which is an int-flip. That XOR was replaced with an equivalent tilda operator. * convert a field to inline This field was used only once, so put it straight to where it is used. * remove fluid fix since no-one uses Forge version 1355 or earlier * unwrap switches where fitting In some places, we suppress IntelliJ's inspection RedundantLabeledSwitchRuleCodeBlock - we don't want to unwrap some of the suggested cases because we want to keep the consistency in a switch statement for the sake of readability. * fuse "collect" into Stream API * fix javadocs * remove unnecessary public modifiers from an interface Members of an interface are public by default. * move common parts outside of if * suppress OverrideOnly warning in a javadoc * remove unused lock * suppress warnings about unchecked casts These warnings require non-trivial fixes that are yet to arrive. For now, let's suppress them to reduce the warning-bloat. * remove outdated comment * remove final modifier from private methods Because they are private, it is hard to accidentally overwrite them. Therefore, the final modifier is redundant in this case. * refactor getIcon The first 'if' doesn't cover only tMeta == 9 && mConnectedMachineTextures, therefore the second if can be unrolled. The last switch is redundant because all tMeta values are covered by switches, but let's keep SOLID_STEEL as a fallback just in case. * explain what the casings are and why block casings are split * suppress switch-to-if suggestion * remove unnecessary null check The null is handled in doGenerateItem() * address redundant local variables * rename variables in onTick * suppress warning about accessing static member via instance * rephrase exception * rephrase javadoc * address field-can-be-final warnings * remove empty methods * enum cannot inherit, so protected is redundant * remove redundant throws * update imports to be not wildcard * remove unnecessary try-catch * update for loop * remove redundant code in order to use the diamond operator * update instanceof to use pattern variables * replace blank lines with <p> in javadocs * fix dangling javadocs * suppress warning about unreachable methods in javadocs * remove redundant operation * add the descriptions of parameters in javadocs Also fix javadocs along the way. * relax returned type in javadoc That was done in order to make the docs reflect the code more often. Otherwise, people may forget to change the returned type again with another change. * make long conversion explicit Integer multiplication can give a wrong result if one of the parts is not explicitly cast to long. Let's cast one of the parts where applicable. * remove unary plus * simplify unary minus * use addAll instead of forEach,add It was suggested by IntelliJ to replace the iteration with a bulk operation to improve performance. * replace .asList with .singletonList for consistency * simplify toArray calls Explanation from IntelliJ: There are two styles to convert a collection to an array: * A pre-sized array, for example, c.toArray(new String[c.size()]) * An empty array, for example, c.toArray(new String[0]) In older Java versions, using a pre-sized array was recommended, as the reflection call necessary to create an array of proper size was quite slow. However, since late updates of OpenJDK 6, this call was intrinsified, making the performance of the empty array version the same, and sometimes even better, compared to the pre-sized version. Also, passing a pre-sized array is dangerous for a concurrent or synchronized collection as a data race is possible between the size and toArray calls. This may result in extra nulls at the end of the array if the collection was concurrently shrunk during the operation. * split StringBuilder append Explanation by IntelliJ: Reports String concatenation used as the argument to appends. Such calls may profitably be turned into chained append calls on the existing StringBuilder saving the cost of an extra StringBuilder allocation. This inspection ignores compile-time evaluated String concatenations, in which case the conversion would only worsen performance. * annotate overriding methods with @Nonnull where needed The method that was overridden has @Nonnull so the method that is overriding should also have @Nonnull. * remove set adding itself to itself * remove null check because findField either works or blows up cpw.mods.fml.relauncher.ReflectionHelper::findField either returns a non-null value or throws a RuntimeException, so no need to check of null. * remove slot comparison with tInventory.length slot max value is 127 when tInventory.length is set to 256, which results in that the condition is always true and unnecessary. * remove aOutput2 null check As GT_Values.NI is null, there is no need to check aOutput2 for null again * suppress the suggestion to delete tMeta < 13 mConnectedMachineTextures can change, so tMeta range is not guaranteed * remove aCoverVariable % 3 < 2 the if above already limits the result of % 3 to "2", so the condition "less than 2" is always false. * unwrap "if" because bonus is unchanged Unwrap if because even if the bonus is a variable, it hasn't been changed for the past 8 years and is unlikely to be changed in the future. * reformat javadoc * improve ignoring an exception Make them either more clear or concise * fixup fix typo * update deprecated calls of newInstance() * remove testing BaseMetaTileEntity GregTech_API.constructBaseMetaTileEntity() checks the creation by itself, logging and throwing a runtime error if failed. * unwrap hatch-fill for do_SolarSalt To reach this branch, do_coolant needs to be false and we need to still be in the function, which means that do_SolarSalt was set to true in the previous top-tier "if". * remove always-false input-bus checks of MTE PlasmaForge size() is non-negative, and the values it is compared to are final and 0. * length and size are non-negative Therefore, there's no need to check their negativity * aOutput is guaranteed to be positive * tThereWasARecipe is always false when reached in its first occurrence * convert an assert into if Only tStack 2 is checked for null because if it isn't null then tStack1 also isn't null based on the "if" above. Also IntelliJ was sure that tStack is not null for some reason. On a side note, assertions work only either with a specified flag or in debug runs. Therefore, it is dangerous to rely on them. * simplify stone-gravel-cobble if tBlock != Blocks.stone because of the if at the start of the method. for the last else-if, tBlock == Blocks.gravel because of the check slightly above the change. * interDimensional is always true because of the first if * convert an example to javadoc * remove always-false statements * replace referential string equality with equals If we compare strings by "==", we compare references to them, which is not what we usually want. I wasn't sure if String Pool works here, so I played it save with equals(). * use Automatic Resource Management for AutoCloseable ByteBufOutputStream * add todo to swap from sleep to event bus * null is checked by instanceof * merge switch branches * add a TODO to use clamp() * new String declaration is redundant * use getOrDefault for a map * replace StringBuilder with concatenation where fitting Using a StringBuilder to concatenate two string will not make the program faster or more understandable, so I swapped it to concatenation. * remove unnecessary continue * flip if * remove redundant returns * unwrap ifs It's checked at the top "if" that aType == IItemRenderer.ItemRenderType.INVENTORY, so all aType.equals(IItemRenderer.ItemRenderType.INVENTORY below are always true. * remove checking all GT VERSIONs except the API one * remove version check from GT_Mod and delete respective VERSION fields Aside from GregTech_API.VERSION, these fields are not used anywhere in the project, so only GregTech_API.VERSION was kept. The idea and the usage check were done by miozune.
2023-06-04Fix void protection not working with MB with custom output hatch field (#2051)miozune
* Fix void protection not working with MB with custom output hatch field * forgot to filter * Add util method for DT-like structure
2023-06-03fix incorrect GT_RecipeBuilder deep copy (#2048)Glease
* fix incorrect GT_RecipeBuilder deep copy * spotlessApply (#2049) Co-authored-by: GitHub GTNH Actions <> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-06-03Chemical reactor recipe map fix (#2046)chochem
* minor stuff * disable some optimizations
2023-06-01some gtmodhandler improvements (#2043)chochem
* remove terrible naming conflict * ra2 for the alloysmelter+furnace combo
2023-05-28make private fields final where possible (#2028)chill
2023-05-28simplify ifs (#2027)chill
2023-05-28Add new mode for void protection & implement it for more multis (#2024)miozune
* Void protection improvements * Rename methods: isXXXButtonEnabled -> supportsXXX * Adjust texture for forbidden * Add MultiBlockFeatureSupportDumpers * Fix oversight in PCBFactory * Revert void protection support for PA * Rename class: ControllerWithButtons -> ControllerWithOptionalFeatures
2023-05-28simplify logic expressions (#2026)chill
2023-05-26Add void protection mode to fluid and ore drillers (#2023)miozune
* Refactor GT_ParallelHelper part 1 * Refactor GT_ParallelHelper part 2 * Move void protection logic to separated class * Clean doc * Fix inverted logic in VoidProtectionHelper * Add void protection mode to fluid and ore drillers
2023-05-24Adjust overrides to allow opening machine GUI (#2019)Maxim
2023-05-24Fixed mixer recipe map ending up without programmed circuits (#2020)Maxim
2023-05-23Speedup Recycler recipe lookup (#2016)miozune
2023-05-19Debug for recipe collisions (#2008)chochem
* add collision debug * fix npe * try better names * unwrap nested ifs * do it for the other too * follow some code writing suggestions * add more info to panic crash * code polishing
2023-05-19Yet another round of ra2 conversions (#2006)chochem
* lathe and saplings * toolhead oreproc recipes * fluid solidification * reverse macerating * autoclave combs * implosion compressor * assembler recipes * assembling line * slicer recipes * minor fixes * attempted cell to fluid fix * minor fix 2
2023-05-17More RA2 conversion for automatic gt recipes (#2000)chochem
* fully convert all wiremill recipes and clean up unnecessary duplicate code * fully convert all polarizer recipes * fully convert all canner recipes * RA2 for oredict plank recipes * RA2 for oredict stoneCobble recipes * convert some assembler recipes to RA2 * fix * fix2 * remove recipes that were never in the game
2023-05-15Various GT recipe fixes (#1990)chochem
* null checks for cables * actually fix drillhead recycling * revert old incorrect drill fix * fix netherstar cables
2023-05-13More ReverseArcSmelting fixes (#1979)chochem
* null check and removal for reversearcfurnace * max 9 not 10 outputs
2023-05-10Slight adjustment for TPM NEI (#1972)miozune
2023-05-06Exploring some various ForgeDirection fixes (#1950)Jason Mitchell
* Fix mFacing NPEs * Default facing fixes (#1945) * QuickFixes incomplete facing fixes * fix Neither UP nor DOWN conditions as offsetY == 0 is not valid test * fix neither up nor down again * Still not fixed: use ForgeDirection.flag for clarty killed more ordinal siding. * get ride of offset testing --------- Co-authored-by: Jakub <53441451+kuba6000@users.noreply.github.com> Co-authored-by: Jason Mitchell <mitchej@gmail.com> * bit logic fix * Fix single block machine facings * Predict the machine facing direction clientside before the server packet arrives * Fix isFacingValid logic --------- Co-authored-by: Léa Gris <lea.gris@noiraude.net> Co-authored-by: Jakub <53441451+kuba6000@users.noreply.github.com> Co-authored-by: Martin Robertz <dream-master@gmx.net> Co-authored-by: Raven Szewczyk <git@eigenraven.me>
2023-05-06Show energy flow amperage and correct voltage tier in WAILA for machine ↵Wilhelm Schuster
blocks (#1955) Previously, WAILA just showed voltage tier based on total energy flow. This was problematic for machines that accept multiple amps such as the Arc Furnace. Even though it can accept up to 3A of input, increasing the total input voltage by one tier, it obviously cannot accept that voltage from a single source.
2023-05-05fix (#1951)BlueWeabo
2023-05-01bs+saMartin Robertz
2023-04-30Some more ra2 fixes (#1932)chochem
* multiple RA2 fixes * revert the revert of my work why do I have to fix shit multiple times * more fixes * and more * these dont exist and are always null * sa * better check * and another forgotten null check * fix turbine blades
2023-04-26arc furnace fix (#1921)chochem
2023-04-24Mask direction patches (#1908)Léa Gris
* Fix wrong wrenching direction for EAST * Fix Remove useless casting * Impr upgrade from magic numbers to EnumMap and remove misplaced fix