aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/fluid
AgeCommit message (Collapse)Author
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-04-22MuTE overhaul and ACR (#1883)Maxim
* complex controller start * Added methods to get input fluids and items * Added logic to complex parallel mute * Added ACR and fixed many, many, many, many bugs * Added void protection setting to checkRecipe * do not init nbt, if mteID and mteRegistry are the same * Improved GUI design * Force structure check when pressing power switch * ACR Textures * Added T1 structure * Added perfect OC * Added WAILA * fix mutes resetting their nbt * Fix ACR GUI * fix npe * Added void protection for MuTEs * Fixed ACR starting recipe while another one is ongoing * nbt saving * maybe fix structure breaking * Fix complex machine disabling on startup * correctly update input tanks * move casings over * Changed logic of casings to change mode and facing in one go by sneaking * Fixed the casing target not resetting * Added side only annotations * don't leave it empty * Added power logic and tiered blocks to ACR * Change facing to wrench side if casing mode is currently none * lasers anyone? * Added ACR item chaining * Remove unncessary item lists * Use HashSet for process whitelists * Optimize list capacities * Fix potential recipe voiding bug * Rename methods for consistancy * Fix NPE * Duct tape fix structure check * allow MuTEs to connect to cables * Added separate tank inventories for input separation (#1887) * Fixed unregistering tank function * Fixed input busses not being automatable * Added fluid chaining * Fixed saving of input tanks * Forbid inventory registering with empty name * Display all input tanks in controller GUI * Fixed fluid hatch GUI height * Reset casing lists when checking the structure * Make inventory GUI size consistant * Make use of the tooltip cache * rename thing clean up * Forgot to put tooltip into map * Added tooltip to ACR * Reset whitelists when one whitelist window was opened * Refined scanner string * Fixed progress times * Fixed MuTE not consuming fluids * Properly register controller inventories * switch to ForgeDirection * switch to new Renderer * Added missing contains check on registerInventory * Fixed output tanks not registering * Fixed upgrade tank loading * fix machines not having active/inactive textures * fix overlays not loading correctly * Don't register controller directly * Remove magic strings all * fix active not setting to inactive * allow glow * item renderer * fix glow * MuTE improved hatch GUI and fluid output locking (#1889) * Allow output hatches to be fluid locked * Reworked hatch GUI * Check target before trying to open GUI * Make ACR GUI easier to look at * fix covers not rendering on mutes * fix covers not displaying above the item/fluid in/out * new folder texture structure * Reduce network traffic caused by covers * Fixed WAILA fluid locking display * Don't save everything to the itemstack NBT * Added possibility to save NBT of MuTE to its itemstack * fix textures, but make sacrifices * mah textures * Removed the need for all textures to be present * Added glow texture for active coke oven * Removed unncesssary upgrade casing textures * shorten nbt tags --------- Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> Co-authored-by: Martin Robertz <dream-master@gmx.net> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-04-10Update spotless config to 0.2.2Raven Szewczyk
2023-04-01update spotless formatting (#1827)boubou19
2023-01-30[ci skip] spotlessApply with the new settingsJason Mitchell
2022-10-01refactor(fluid_api): fluent interface (#1407)Léa Gris
* refactor(fluid_api): fluent interface Improves the initial construction model into a fluent interface. See: https://java-design-patterns.com/patterns/fluentinterface/ This change provides the built and saved states of a GT_Fluid, with their own interface, so that: object state validations are performed at build time, rather than causing an `IllegalStateException` to be thrown at runtime, with the previous implementation. This also allows the IDE to display and check the applicable methods for the GT_Fluid object's state, as it moves through the call chain. * hotfix off-by-one in FluidState.fromValue * minor: deduplicate buildAndRegister action * fix(withIconsFrom): needs dependency management Cracked fluid Icons were copied too early from non-cracked fluid within the `IGT_FluidBuilder`'s implementation. At this stage, the source Fluid has not registered its own icons yet, so the Cracked fluid got null Icons (fallback to Error checkerboard). This commit delegates the copy of the source fluid's Icons, to the `run` Icons texture's registration task; ensuring the source Fluid runs its own Icons textures registration before copying them, as a light-weight dependency management.
2022-09-08fix(API): GT_Fluid (#1349)Léa Gris
* fix(API): GT_Fluid - Fix: Use registeredFluid instead of GT_Fluid to configure Materials and containers to prevent crashes when retrieving fluids referrences from those. - Impr: Adjust fluid luminosity computation to better fit with Tungsten as maximum - Impr: Remove transparency from the fluid.molten.autogenerated.png texture to prevent molten materials to appear dilluted. * ./gradlew :spotlessApply * rev(comment): address review comment from @Glease rev: https://github.com/GTNewHorizons/GT5-Unofficial/pull/1349#pullrequestreview-1098651647 fix: Logic to handle working with own registered fluids and already registered fluids. imp: Some IGT_Fluid methods requires the fluid to be registered, throws an IllegalStateException on use at an unregistered fluid. imp: Normalizes @inheritDoc no additionnal text allowed
2022-09-05feat(API): Implements a featured API for GT_Fluid (#1345)Léa Gris
* feat(API): Implements a featured API for GT_Fluid *** Rationale The current implementation, which is based on the `GT_Fluid` object, does not allow for the evolution of the functionalities, or the variation of the fluid-related implementations in GregTech. *** Objectives This replacement API should free from these constraints, by providing : 1. The separation of responsibilities of the different tasks and steps: - The definition and progressive construction of an `IGT_Fluid`, - Registration of the `IGT_Fluid`, - Configuration of related equipment, such as containers, - Propagation of properties of an `IGT_Fluid` to related services such as Materials 2. The separation of interfaces exposed to the API from their internal implementations to allow: - Evolve the implementations in the most transparent way possible - To have internal GregTech implementations or outsourced implementations coexist in its extensions. *** Specificity of this new API - Provides a new interface to build and interact with fluid related records - Deprecates the old `api/objects/GT_Fluid` object and the `common/GT_Proxy.addFluid` record methods * fix(conversations): addresses @Glease review comments https://github.com/GTNewHorizons/GT5-Unofficial/pull/1345#pullrequestreview-1096261703 * ./gradlew :spotlessApply * fix(review): add review comments from @eigenraven Added missing final qualifiers on methods parameters. https://github.com/GTNewHorizons/GT5-Unofficial/pull/1345#pullrequestreview-1096318523 * fix(review) address remaining review comments from @eigenraven
2022-08-27Update buildscript & apply spotless (#1306)Raven Szewczyk
* Update dependencies * Update buildscript, apply spotless
2022-07-22MultiTileEntityJason Mitchell