From 02bedd5c0a96a654c6692edd1b7f2765fd9c46b4 Mon Sep 17 00:00:00 2001 From: BlueWeabo Date: Sat, 6 Jan 2024 00:41:00 +0200 Subject: Merge MuTEMaster into Master (#2431) * Fix MuTE structure check and power intake (#1975) * Fixed casing lists being cleared for every checked structure piece * Fixed power being taken from any side BUT the right one * ACP Structure - Rebased (#1978) * Added 2nd structure tier to ACR and make complex parallels depend on it * Added tier 3 to 8 structure pieces to ACR * Added disclaimer * Renamed ACR to ACP because MV CR already is named ACR * Add autopush functionality to MuTE (#1976) - fix conflict * Working auto push * Revert wildcard import * Addresssed reviews * Fix reference issue * Minor MuTE fixes - Rebased (#1983) * Fixed ACP recipe map * Fixed controller side being used instead of part side when accessing tanks * Fix Structure not forming (#1984) * fix cables not connecting * fix structure and don't store controller * Add missing tooltips (#1981) * Add missing tooltips * Address blue's change * Distillation MuTE (#1989) * Started work on DT MuTE * Renamed methods so they also make sense when used horizontally * MuTE Upgrade Casings - Rebased (#1988) - fix conflict * Added cleanroom upgrade casing * Added inventory and tank upgrades * Added tooltips to mute casings * Added power upgrades * Set player UUID when placing MuTE * MuTE fixes (#1991) * Fixed pipes not connectable to MuTE casings * Fixed not all things being renamed to ACP * Fix running in obf * fix for real yo * Add a Generic Processing Logic and extract methods - Rebased (#1992) * add a generic processing logic * calculate tier in another method * calculate power logic in another method * Add Layered Coke Foundry (#1995) * Add the Foundry class and call it * Foundry name correction * Buildable stackable structure * Fixed min stacks and added motor casings * checkMachine override for custom checking * Working checkMachine for all stacks, and recipes * Fix getOutputFluids * Change recipe processing to GenericProcessingLogic * Change inventoryName to protected for override * Override checkRecipe for multis that consume EU * Rename class and add inner walls to multi * Structure update and other fixes * Fix processing logic being static * MuTE inventory upgrade logic (#2082) * Catch potential NPE * Don't load name when it doesn't exist * Potentially cause weird non-replicatable issue where registry ends up with different key * Use proper block removal method * Validate index before using it * Don't open controller GUI from inventory upgrade * semi-working concept * sync the ID of the inventory upgrade to correctly remove it later * remove unneeded boolean --------- Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> * fixed layeredCokeBattery checkMachine to prevent 'already in building state' (#2099) * MuTE casing structure element (#2105) - fix conflict * Added class containing MuTE relevant structure elements * Migrate MuTE to new structure element * Formatting fix * Use int array instead of int hashmap, since its expected these arrays will never get long enough to be faster as hashmap * Delete old code * Cache MuTEs for non-instance specific actions (#2109) * Introduce map of cached TEs, which are used to perform actions that don't require a specific instance of the TE. This prevents constant creation of new TEs * Remove static modifier from map of cached TEs * First Modular Upgrade Casings Implementation (#2142) * Base support for Heater MUCs - Define Heater upgrade casings; - Create the 5 tiers of Heaters; - Add method to increase and decrease count. * Refactor the cache of MUCs in structure - Change the way that each MUC is counted: since there will be several types, the integer that counted heaters is now a hashmap that divides all MUCs based on their type and tier, to be counted separately from each other. * Add Insulator MUC - Add second MUC type (insulator) to test alongside heaters on the Layered Coke Battery. * Fix MUC count reset * Refactor MUC implementation into subclass - Move the new methods and hashmap away from the base classes, and onto a s specific one that won't be used by unrelated multiblocks. * Remove empty lines * Refactor MUC implementations into subclasses * Requested fixes in StackableModularController * Change hashmap keys to an enum * Hashmap getter for load order purposes - Added a getter that generates the default value for the hashmap if it is null, due to problems with load order; * Apply spotless * NotNull annotations * More Additions to MUCs and the LCB (#2215) * Fix old LCB multi name in some locations * Refactor mucMap and override checkRecipe - Refactor mucMap to an array of primitive integers instead of the wrapper type, for ease of use with other methods such as stream; - Override checkRecipe for custom recipe behavior on MUC multis, to be implemented in a future commit; * First implementation of bonuses and MUC requirements - Change EU/t and recipe duration of this multi based on the count of different MUCs in the multi; - Fail the structure check based on the count of each of the allowed MUCs. * Parallel count implementation - Calculate parallels based on the count of base MUCs, the cheapest option amongst the possibilities, in this case heaters; - Added more abstract methods to require specific values from the multi classes. * Fix parallel count and processing - Fixed the handling of parallels by pointing to the corrent maxParallel variable in ProcessingLogic. * Test of parallels with additional amp input * Structure fix for the intended LCB - Changed MUC placements to match what I intended at the beginning, to better test the multi. * One more comment * Remove checkRecipe override * Refactor Item and Fluid to be in separate logic classes (#2178) - fix conflict * basics of inventory logic * mostly working item logic * working nbt saving/loading * fluid handler * FluidSlotHandler WIP * fluid handler mostly working * remove fluid handler from gt5u * prepare for conversion * use correct imports * spotless * more controller logic * spotless * final refactor. migration next * spotless * add more methods to logic classes * convert almost everything to use new Logic * spotless * make mute casing mode an int * allow pump cover to work with FluidInventoryLogic * pumps work * spotless * make item inventory logic work with every item input thing * rework Fluid Inventory Logic to work with all fluid inputs * spotless * address annotation reviews * finish off todos * missed to dos * cleanup Coke oven will get a new GUI when i get to it * address review * prevent npes from ControllerXXXLogic * null checks * remove accidentally added methods * fix missed return * fixes after rebase - fix conflict * Laser Engraver Multi. (#2223) - fix conflict * saving............. * clean up * savin * Small fixes + Adding back stuff, Crashes you and spams logs. * fix stack overflow * Fixes * Fixes --------- Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> * Add TickableTask (#2216) * Add autopush functionality to MuTE (#1976) * Working auto push * Revert wildcard import * Addresssed reviews * Fix reference issue * MuTE Upgrade Casings (#1988) * Added cleanroom upgrade casing * Added inventory and tank upgrades * Added tooltips to mute casings * Added power upgrades * Set player UUID when placing MuTE * Add a Generic Processing Logic and extract methods (#1992) * add a generic processing logic * calculate tier in another method * calculate power logic in another method * MuTE inventory upgrade logic (#2082) * Catch potential NPE * Don't load name when it doesn't exist * Potentially cause weird non-replicatable issue where registry ends up with different key * Use proper block removal method * Validate index before using it * Don't open controller GUI from inventory upgrade * semi-working concept * sync the ID of the inventory upgrade to correctly remove it later * remove unneeded boolean --------- Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> * MuTE casing structure element (#2105) * Added class containing MuTE relevant structure elements * Migrate MuTE to new structure element * Formatting fix * Use int array instead of int hashmap, since its expected these arrays will never get long enough to be faster as hashmap * Delete old code * Refactor Item and Fluid to be in separate logic classes (#2178) * basics of inventory logic * mostly working item logic * working nbt saving/loading * fluid handler * FluidSlotHandler WIP * fluid handler mostly working * remove fluid handler from gt5u * prepare for conversion * use correct imports * spotless * more controller logic * spotless * final refactor. migration next * spotless * add more methods to logic classes * convert almost everything to use new Logic * spotless * make mute casing mode an int * allow pump cover to work with FluidInventoryLogic * pumps work * spotless * make item inventory logic work with every item input thing * rework Fluid Inventory Logic to work with all fluid inputs * spotless * address annotation reviews * finish off todos * missed to dos * cleanup Coke oven will get a new GUI when i get to it * address review * prevent npes from ControllerXXXLogic * null checks * Base work * PollutionTask * move package * Fix generics * Internal -> OverrideOnly * rebase fix * Ducttape addPollution --------- Co-authored-by: Maxim Co-authored-by: BlueWeabo Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> * Rework a bit of ProcessingLogic to fit MuTEs (#2283) - fix conflicts * Add a way to enable or disable the crafting buffer on GPL multiblocks (#2218) * add a way to enable or disable the crafting buffer on GPL multiblocks * don't register the hatch either * fix Refractory Capsule (#2219) * Fix PAs overclocking ulv recipes too much (#2220) * fix PAs overclocking ulv recipes too much * make sure we save the returned value * Fix Digital Tank capacity for Fluid Storage Monitor (#2217) * Fix Digital Tank capacity for Fluid Storage Monitor * Annotations * Blacklist AE2FC drop and packet, and Chisel stones from Recycler (#2222) * Fix recycler blacklist being sensitive to NBT * Blacklist AE2FC drop and packet, and Chisel stones * fix class loader issue * Add detailed logging for ME hatches (#2224) * Fix overclock calculator calculating eu/t use for ulv recipe wrong on certain parallel (#2225) * fix overclock calculator calculating eu/t use for ulv recipe wrong on certain parallel * make formula into its own method * Fix drilling rigs, plants and concrete backfiller to fail with multiple energy hatches (#2227) * max-1-energy-hatch-in-drilling-rigs.-plants-and-concrete-backfiller * spotlessApply (#2228) Co-authored-by: GitHub GTNH Actions <> * revert --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * clear stale crafting input bus list (#2233) * add ability to remove item data and use it for clay (#2229) * Update buildscript (#2232) * Fix server crash with RecipeFilter (#2231) * Fix server crash with RecipeFilter * Make client send filtered machines to server * Use mUniqueIdentifier * Fix a NPE w/ injecting into super/quantum chests (#2234) When simulating an injection, if the stackSize > chest's capacity, it causes a NPE when the internal chest is empty. Also fixes a potential bug when void overflow is set; the chest should return null in such a scenario regardless of simulation/modulation. * Fix lag caused by getRecipeMap for PA (#2236) * Experimental fix to prevent infinite loop in Grid destruction (#2235) Co-authored-by: Firenoo <49818773+firenoo@users.noreply.github.com> * Fix ME Output Bus and Crafting Input Bus overflow when save/load (#2238) * Remove fire display from singleblock generator (#2240) * Fix some output slots allowing insertion (#2230) * fix overlay zfighting by disable depth test (#2226) * Crafting input - Optimize isEmpty check to reduce lag (#2239) * Optimize isEmpty check * rearrage * remove broken hsla recipe (#2241) * Correct PCB Factory Energy Hatch description (#2237) * Correct PCB Factory Energy Hatch description Changes the PCB factory description (the one seen when holding shift) which currently says "Energy Hatches: 1+" I believe this is incorrect and that the correct description is 1-2 energy hatches or 1 TT energy hatch. I believe the PCB factory uses this, which checks for 1-2 or 1 TT: public boolean checkExoticAndNormalEnergyHatches() { if (mExoticEnergyHatches.isEmpty() && mEnergyHatches.isEmpty()) { return false; } if (!mExoticEnergyHatches.isEmpty()) { if (!mEnergyHatches.isEmpty()) { return false; } if (mExoticEnergyHatches.size() != 1) { return false; } } return mEnergyHatches.size() <= 2; } * gradlew spotlessApply * Correct file name on resource pack guide (#2242) * Fix GT_RecipeConstants.Fuel (#2243) * Update text (#2246) * Fix startup tier for fusion NEI (#2249) * Update the conditionals buttons and tooltips on covers to reflect their actual effects (#2244) * Update redstone buttons and tooltips to better reflect actual use * Spotless Apply * Update GT_Cover_FluidRegulator.java * Update GT_Cover_FluidRegulator.java * Typo fix, Icon Improved and interactive blocking ui - Fixed a typo in the world machine - Fixed double button situation for conveyor belts. - There was never any issue, the testing methodology gave me invalid results. - Conveyor behaviour is in line with all the other covers affected by this PR/Branch. - Updated icon for the machine state to be a miniature machine controller cover. - Made the block/allow input section more interactive in order to better reflect the actual effect of these buttons. - In import mode, it actually blocks the machine from outputting from that side. * typos I can't write to save myself sometimes * Better text alignment - Better text alignment * fix typos I swear I can't write to save myself. --------- Co-authored-by: Martin Robertz * Fix Orichalcum and Shadowiron smelting (#2251) * fix orichalcum and shadowiron smelting * add Alduorite and Chrysotile * Fix tier display for Fusion NEI header (#2250) * fix ulv recipes being broken again when under 1 tick calculation is taken (#2254) * change way to fix zfighting (#2253) * Crafting input hatches QoLs (#2200) * Fixes + Detect Inventory Slot Changes * support rename + check for updates * add back onChangeListener + fix npe * ICustomNameObject TileEntity * Fix NPEs * Use IInterfaceTerminalSupport * fix * register * dep * spotless * General Crafting Input Hatch QoL fixes (#2212) * feat: refactor naming && include circuit and catalyst in default name * feat: add 4 more slot to solve my ocd * fix: formatting * feat: migrate from 4x8 to 4x9 * spotlessApply (#2213) Co-authored-by: GitHub GTNH Actions <> * QoLs * 9 manual items * spotless * feat: open master GUI when used, without holding a data-stick (#2221) * fix destpos * optimize empty check * Fix error when fluidInventory.size() == 0 If the fluidInventory size is 0, there is no element to get. Add a check for it. * name in waila + fix int overflow * unnecssary super * update deps --------- Co-authored-by: Fox_white <39846845+foxwhite25@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Firenoo <49818773+firenoo@users.noreply.github.com> Co-authored-by: Martin Robertz * Use real stack limit (#2256) * Fix incorrect data stick behaviors for hatches (#2257) * Fix pcb factory not applying its roughness multiplier when it doesn't OC (#2258) * fix PCB Factory not applying its roughness multiplier when it doesn't do any overclocks * spotless * Remove duplicate obsidian long rod (#2259) * disable gt obsidian long rod * cleaner code * Add hazmat to ThaumicBoots (#2260) * Add hazmat to ThaumicBoots does what it says * fixed * fix item names (#2263) * Fix renaming recipe check might ignore NBT equality (#2261) * Fix GPL ignoring if the recipe is allowed to be cached (#2262) * Added bricked blast furnace recipe progress to waila. (#2265) * Added bricked blast furnace recipe progress to waila. * fixed formatting issues. * Fix cutter recipes not being added (#2271) * add processing task * clean up item logic host * temporary fix for GT_StructrureMuTE * use j9+ feature on pollution task * prepare complex parallel logic for transition * feature to ProcessingLogicHost * fix up multiblock bases * add processing logic for each multi to prepare for transition * spotless * removed debug text from wailaBody of GT_MetaTileEntity_Hatch_CraftingInput_ME (#2272) * Proper recipe selection for output overflow in LCR and other multiblocks (#2247) * Implement Stream findRecipesWithResult for GT_RecipeMap * Change ProcessingLogic.process to actually use new findRecipesWithResult * Change ProcessingLogic.process to start finding something only for OUTPUT_FULL result * Refactor ProcessingLogic.process to make logic more readable * Replace while with for loop, remove NOT_FOUND return in end of findRecipesWithResult * Apply spotless * Make findRecipe use findRecipes, add annotation to GT_Recipe and FindRecipeResult for processRecipe and make method protected, replace wildcard imports * Remake isRecipeWithOutputFullFound * Add @Nonnull to methods * Apply spotless * Remove Stream version of findRecipeWithResult, replace with predicate one. Add GT_Predicated_Recipe_Map class for utilizing this method. Changes some existent recipe maps to inherit from base class. * Remove GT_Predicated_Recipe_Map, add Predicate directly to GT_Recipe_Map#findRecipeWithResult. Add AdvancedRecipeValidatorPredicate and FindRecipeWithAdvancedValidatorResult to allow store validation calculations for further use and proper errors displaying. * Fix InsufficientVoltage errors * Changes according to review comments. Integrate FindRecipeWithAdvancedValidatorResult to FindRecipeResult, rename AdvancedRecipeValidatorPredicate, encapsulate AdvancedRecipeValidatorPredicate fields, fixes some typos, etc * Moves InsufficientVoltage check to GT_ParallelHelper. Removes FindRecipeResult#State#INSUFFICIENT_VOLTAGE * Return an old findRecipeWithResult * Renames things, call old methods for singleblocks * Renames things, makes FindRecipeResult ctor private * Apply spotless * Move RecipeValidator, fix comments typos * update deps * fix up complex processing logic * add a getter for voiding mode * fix getAccessibleSlotsFromSide being wrong sometimes * allow for subtraction of a specific item * use long for amount * add a setter for machine host * initial work on finding recipes and input consumption * Deprecate PA by removing its controller recipe (#2273) * Restore PA controller recipe (#2276) * Restore PA controller recipe * Remove duplicated recipe * Add optional description to input hatch constructors (#2278) * mini fix (#2204) * [chore] Bump fallback version to 44 (#2274) * find recipe in theory working * add some helper methods to inventory logics * update deps * use collect not toList * fix loading crash * fix complex processing logic using wrong find recipe * fix up everything and get recipe finding working * annotate and clean up methods * spotless * save things to nbt * input separation for mutes and fully working processing * apply mute mode on processing logic * clean up overrides --------- Co-authored-by: chochem <40274384+chochem@users.noreply.github.com> Co-authored-by: miozune Co-authored-by: Pxx500 <81298696+Pxx500@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Glease <4586901+Glease@users.noreply.github.com> Co-authored-by: firenoo <49818773+firenoo@users.noreply.github.com> Co-authored-by: Martin Robertz Co-authored-by: Harry Co-authored-by: Eraldoe Co-authored-by: Jakub <53441451+kuba6000@users.noreply.github.com> Co-authored-by: Connor-Colenso <52056774+Connor-Colenso@users.noreply.github.com> Co-authored-by: Guillaume Mercier Co-authored-by: Fox_white <39846845+foxwhite25@users.noreply.github.com> Co-authored-by: Alastors <78517796+Alastors@users.noreply.github.com> Co-authored-by: Kyium <43573052+Kyium@users.noreply.github.com> Co-authored-by: SKProCH <29896317+SKProCH@users.noreply.github.com> Co-authored-by: Sampsa <69092953+S4mpsa@users.noreply.github.com> Co-authored-by: Jaiden Baker * address minecraft's reviews from #2283 * Refactor MuTE processing logic (#2301) -fix conflicts * Fix void protection for mutes (#2298) - fix conflicts * initial variables * implement working void protection on items and fluids * Adds a Simple PowerOutput task and cleans up some of the code. (#2303) * create a power output task which can be used for dynamos * refactor the controllers and clean up * add some documentation to power logic * make a wireless network manager class instead of using an interface * clean up and add documentation. * setAmperage to setMaxAmperage * fix comment * remove IGlobalWirelessEnergy usage * getAmperage -> getMaxAmperage * add todo for future * Cleanup MuTEMaster code (#2282) * exit early * spotless * better side checking * make if blocks mutually exclusive * more exit early * convert nested ternary operators into if blocks * remove dead code * collapse nested if blocks * add todo to break verylong condition into much smaller ones * spotless apply * collapsing nested if blocks and more exit early * spotless apply * extract try/catch block to its own utility method * break down this unreadable condition * boolean magic (1/5) * boolean magic (2/5) Also corrected some logic on the player null check, we want it to be non null * boolean magic (3/5) * boolean magic (4/5) * boolean magic (5/5) * remove todo * Fix logic --------- Co-authored-by: Jason Mitchell Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> * Clean up a lil bit and fix some issues with MuTEs (#2316) * clean up fixes * actual fix and remove useless if * Rework MuTEGUI structure (#2429) - fix conflicts` Merged to rebase MuTEMaster and fix any non-compile errors and game not launching in there * some docs on a few methods * innitial GUI class * try to implement guis * almost working - fix comflict * add UIBuildContext to getGUI method * make it compile * sketch gui - fix conflict * compile and spotless * add config option to enabling MuTEs * Spotless apply for branch feature/MuTEMaster for #2431 (#2432) spotlessApply Co-authored-by: GitHub GTNH Actions <> * address reviews on broken processing logic * spotless * fix doc and review --------- Co-authored-by: Maxim Co-authored-by: RIONDY 'POPlol333' Adam <76914762+POPlol333@users.noreply.github.com> Co-authored-by: Jason Mitchell Co-authored-by: Daniel Mendes <70096037+Steelux8@users.noreply.github.com> Co-authored-by: kstvr32 <109012629+kstvr32@users.noreply.github.com> Co-authored-by: TheEpicGamer274 <102255081+TheEpicGamer274@users.noreply.github.com> Co-authored-by: miozune Co-authored-by: chochem <40274384+chochem@users.noreply.github.com> Co-authored-by: Pxx500 <81298696+Pxx500@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Glease <4586901+Glease@users.noreply.github.com> Co-authored-by: firenoo <49818773+firenoo@users.noreply.github.com> Co-authored-by: Martin Robertz Co-authored-by: Harry Co-authored-by: Eraldoe Co-authored-by: Jakub <53441451+kuba6000@users.noreply.github.com> Co-authored-by: Connor-Colenso <52056774+Connor-Colenso@users.noreply.github.com> Co-authored-by: Guillaume Mercier Co-authored-by: Fox_white <39846845+foxwhite25@users.noreply.github.com> Co-authored-by: Alastors <78517796+Alastors@users.noreply.github.com> Co-authored-by: Kyium <43573052+Kyium@users.noreply.github.com> Co-authored-by: SKProCH <29896317+SKProCH@users.noreply.github.com> Co-authored-by: Sampsa <69092953+S4mpsa@users.noreply.github.com> Co-authored-by: Jaiden Baker Co-authored-by: boubou19 Co-authored-by: Jason Mitchell --- src/main/java/gregtech/GT_Mod.java | 10 +- src/main/java/gregtech/api/GregTech_API.java | 5 +- src/main/java/gregtech/api/enums/GT_Values.java | 12 +- .../java/gregtech/api/enums/InventoryType.java | 7 + src/main/java/gregtech/api/gui/GUIHost.java | 56 + src/main/java/gregtech/api/gui/GUIProvider.java | 38 + .../api/interfaces/IGlobalWirelessEnergy.java | 92 +- .../interfaces/tileentity/IEnergyConnected.java | 104 +- .../interfaces/tileentity/IMachineProgress.java | 10 +- .../api/logic/AbstractProcessingLogic.java | 346 ++++ .../api/logic/ComplexParallelProcessingLogic.java | 219 +-- .../gregtech/api/logic/ControllerFluidLogic.java | 152 ++ .../gregtech/api/logic/ControllerItemLogic.java | 148 ++ .../gregtech/api/logic/FluidInventoryLogic.java | 269 +++ .../gregtech/api/logic/ItemInventoryLogic.java | 314 +++ .../gregtech/api/logic/MuTEProcessingLogic.java | 256 +++ .../java/gregtech/api/logic/NullPowerLogic.java | 5 + .../java/gregtech/api/logic/PollutionLogic.java | 17 - src/main/java/gregtech/api/logic/PowerLogic.java | 129 +- .../java/gregtech/api/logic/ProcessingLogic.java | 323 +--- .../logic/interfaces/FluidInventoryLogicHost.java | 95 + .../logic/interfaces/ItemInventoryLogicHost.java | 172 ++ .../api/logic/interfaces/PollutionLogicHost.java | 8 - .../api/logic/interfaces/PowerLogicHost.java | 48 +- .../api/logic/interfaces/ProcessingLogicHost.java | 80 +- .../api/metatileentity/BaseTileEntity.java | 32 +- .../api/metatileentity/CommonMetaTileEntity.java | 23 + .../implementations/GT_MetaPipeEntity_Cable.java | 2 +- .../GT_MetaTileEntity_Wireless_Dynamo.java | 5 +- .../GT_MetaTileEntity_Wireless_Hatch.java | 5 +- .../api/multitileentity/MultiTileEntityBlock.java | 70 +- .../MultiTileEntityClassContainer.java | 18 + .../MultiTileEntityItemInternal.java | 168 +- .../multitileentity/MultiTileEntityRegistry.java | 12 +- .../api/multitileentity/base/MultiTileEntity.java | 182 +- .../base/TickableMultiTileEntity.java | 81 +- .../multitileentity/enums/GT_MultiTileCasing.java | 23 + .../enums/GT_MultiTileUpgradeCasing.java | 71 + .../enums/MultiTileCasingPurpose.java | 13 + .../interfaces/IMultiBlockController.java | 45 +- .../interfaces/IMultiBlockPart.java | 11 +- .../interfaces/IMultiTileEntity.java | 19 +- .../interfaces/UpgradableModularMuTE.java | 10 + .../multitileentity/interfaces/UpgradableMuTE.java | 12 + .../machine/MultiTileBasicMachine.java | 821 +++----- .../multiblock/base/ComplexParallelController.java | 198 +- .../multiblock/base/Controller.java | 2013 +++++--------------- .../multiblock/base/MultiBlockPart.java | 688 +++---- .../multiblock/base/PowerController.java | 92 - .../multiblock/base/StackableController.java | 43 +- .../base/StackableModularController.java | 77 + .../multiblock/base/WallShareablePart.java | 32 +- .../multiblock/casing/UpgradeCasing.java | 10 +- .../api/net/GT_Packet_MultiTileEntity.java | 96 +- .../java/gregtech/api/objects/GT_ItemStack.java | 4 +- .../api/recipe/check/CheckRecipeResult.java | 7 +- .../recipe/check/CheckRecipeResultRegistry.java | 16 + .../api/recipe/check/ResultInsufficientHeat.java | 20 +- .../check/ResultInsufficientMachineTier.java | 17 +- .../api/recipe/check/ResultInsufficientPower.java | 20 +- .../check/ResultInsufficientStartupPower.java | 17 +- .../api/recipe/check/SimpleCheckRecipeResult.java | 12 +- src/main/java/gregtech/api/task/TaskHost.java | 18 + src/main/java/gregtech/api/task/TickableTask.java | 48 + .../gregtech/api/task/tasks/PollutionTask.java | 45 + .../gregtech/api/task/tasks/PowerOutputTask.java | 32 + .../gregtech/api/task/tasks/ProcessingTask.java | 51 + .../gregtech/api/util/GT_OverclockCalculator.java | 25 + .../java/gregtech/api/util/GT_ParallelHelper.java | 77 +- src/main/java/gregtech/api/util/GT_Recipe.java | 77 + .../gregtech/api/util/GT_StructureUtilityMuTE.java | 271 +++ .../gregtech/api/util/VoidProtectionHelper.java | 124 +- .../java/gregtech/api/util/item/ItemHolder.java | 79 + .../api/util/recipe/RecipeInputRequirements.java | 77 + src/main/java/gregtech/common/GT_Proxy.java | 3 +- .../java/gregtech/common/covers/GT_Cover_Pump.java | 50 +- .../gui/ComplexParallelMachineGUIProvider.java | 32 + .../gregtech/common/gui/MachineGUIProvider.java | 498 +++++ .../java/gregtech/common/gui/PartGUIProvider.java | 33 + src/main/java/gregtech/common/misc/GT_Command.java | 13 +- .../common/misc/WirelessNetworkManager.java | 164 ++ .../tileentities/casings/upgrade/Ampere.java | 47 + .../tileentities/casings/upgrade/Cleanroom.java | 26 + .../tileentities/casings/upgrade/Heater.java | 21 + .../tileentities/casings/upgrade/Insulator.java | 22 + .../tileentities/casings/upgrade/Inventory.java | 93 +- .../common/tileentities/casings/upgrade/Laser.java | 26 + .../common/tileentities/casings/upgrade/Tank.java | 61 + .../tileentities/casings/upgrade/Wireless.java | 26 + .../GT_MetaTileEntity_TranscendentPlasmaMixer.java | 6 +- .../machines/multiblock/AdvChemicalProcessor.java | 508 +++++ .../machines/multiblock/AdvChemicalReactor.java | 434 ----- .../tileentities/machines/multiblock/CokeOven.java | 43 +- .../machines/multiblock/DistillationTower.java | 174 ++ .../machines/multiblock/LaserEngraver.java | 305 +++ .../machines/multiblock/LayeredCokeBattery.java | 295 +++ .../machines/multiblock/Macerator.java | 80 +- .../logic/AdvChemicalProcessorProcessingLogic.java | 12 + .../multiblock/logic/CokeOvenProcessingLogic.java | 49 +- .../logic/DistillationTowerProcessingLogic.java | 7 + .../logic/LaserEngraverProcessingLogic.java | 7 + .../logic/LayeredCokeBatteryProcessingLogic.java | 7 + .../multiblock/logic/MaceratorProcessingLogic.java | 7 + .../preload/GT_Loader_MultiTileEntities.java | 650 +++++-- .../java/gregtech/loaders/preload/GT_PreLoad.java | 9 + .../multitileentity/BigLaserEngraver/active.png | Bin 0 -> 255 bytes .../BigLaserEngraver/active_glow.png | Bin 0 -> 255 bytes .../multitileentity/BigLaserEngraver/base.png | Bin 0 -> 289 bytes .../multitileentity/BigLaserEngraver/inactive.png | Bin 0 -> 254 bytes .../BigLaserEngraver/inactive_glow.png | Bin 0 -> 256 bytes .../multitileentity/BlackLaserEngraver/base.png | Bin 0 -> 705 bytes .../blocks/multitileentity/Laserblock/base.png | Bin 0 -> 307 bytes .../advChemicalProcessor/active.png | Bin 0 -> 255 bytes .../advChemicalProcessor/active_glow.png | Bin 0 -> 255 bytes .../multitileentity/advChemicalProcessor/base.png | Bin 0 -> 333 bytes .../advChemicalProcessor/inactive.png | Bin 0 -> 254 bytes .../advChemicalProcessor/inactive_glow.png | Bin 0 -> 256 bytes .../multitileentity/advChemicalReactor/active.png | Bin 255 -> 0 bytes .../advChemicalReactor/active_glow.png | Bin 255 -> 0 bytes .../multitileentity/advChemicalReactor/base.png | Bin 333 -> 0 bytes .../advChemicalReactor/inactive.png | Bin 254 -> 0 bytes .../advChemicalReactor/inactive_glow.png | Bin 256 -> 0 bytes .../blocks/multitileentity/amperage/base.png | Bin 0 -> 443 bytes .../blocks/multitileentity/cleanroom/base.png | Bin 0 -> 443 bytes .../multitileentity/distillationTower/active.png | Bin 0 -> 255 bytes .../distillationTower/active_glow.png | Bin 0 -> 255 bytes .../multitileentity/distillationTower/base.png | Bin 0 -> 459 bytes .../multitileentity/distillationTower/inactive.png | Bin 0 -> 254 bytes .../distillationTower/inactive_glow.png | Bin 0 -> 256 bytes .../blocks/multitileentity/heater/base.png | Bin 0 -> 443 bytes .../blocks/multitileentity/insulator/base.png | Bin 0 -> 443 bytes .../blocks/multitileentity/inventory/base.png | Bin 0 -> 443 bytes .../textures/blocks/multitileentity/laser/base.png | Bin 0 -> 443 bytes .../multitileentity/laserengraverupgrade1/base.png | Bin 0 -> 411 bytes .../multitileentity/laserengraverupgrade2/base.png | Bin 0 -> 444 bytes .../multitileentity/laserengraverupgrade3/base.png | Bin 0 -> 486 bytes .../multitileentity/laserengraverupgrade4/base.png | Bin 0 -> 543 bytes .../textures/blocks/multitileentity/tank/base.png | Bin 0 -> 443 bytes .../blocks/multitileentity/wireless/base.png | Bin 0 -> 443 bytes 139 files changed, 7975 insertions(+), 4557 deletions(-) create mode 100644 src/main/java/gregtech/api/enums/InventoryType.java create mode 100644 src/main/java/gregtech/api/gui/GUIHost.java create mode 100644 src/main/java/gregtech/api/gui/GUIProvider.java create mode 100644 src/main/java/gregtech/api/logic/AbstractProcessingLogic.java create mode 100644 src/main/java/gregtech/api/logic/ControllerFluidLogic.java create mode 100644 src/main/java/gregtech/api/logic/ControllerItemLogic.java create mode 100644 src/main/java/gregtech/api/logic/FluidInventoryLogic.java create mode 100644 src/main/java/gregtech/api/logic/ItemInventoryLogic.java create mode 100644 src/main/java/gregtech/api/logic/MuTEProcessingLogic.java create mode 100644 src/main/java/gregtech/api/logic/NullPowerLogic.java delete mode 100644 src/main/java/gregtech/api/logic/PollutionLogic.java create mode 100644 src/main/java/gregtech/api/logic/interfaces/FluidInventoryLogicHost.java create mode 100644 src/main/java/gregtech/api/logic/interfaces/ItemInventoryLogicHost.java delete mode 100644 src/main/java/gregtech/api/logic/interfaces/PollutionLogicHost.java create mode 100644 src/main/java/gregtech/api/multitileentity/enums/GT_MultiTileUpgradeCasing.java create mode 100644 src/main/java/gregtech/api/multitileentity/enums/MultiTileCasingPurpose.java create mode 100644 src/main/java/gregtech/api/multitileentity/interfaces/UpgradableModularMuTE.java create mode 100644 src/main/java/gregtech/api/multitileentity/interfaces/UpgradableMuTE.java delete mode 100644 src/main/java/gregtech/api/multitileentity/multiblock/base/PowerController.java create mode 100644 src/main/java/gregtech/api/multitileentity/multiblock/base/StackableModularController.java create mode 100644 src/main/java/gregtech/api/task/TaskHost.java create mode 100644 src/main/java/gregtech/api/task/TickableTask.java create mode 100644 src/main/java/gregtech/api/task/tasks/PollutionTask.java create mode 100644 src/main/java/gregtech/api/task/tasks/PowerOutputTask.java create mode 100644 src/main/java/gregtech/api/task/tasks/ProcessingTask.java create mode 100644 src/main/java/gregtech/api/util/GT_StructureUtilityMuTE.java create mode 100644 src/main/java/gregtech/api/util/item/ItemHolder.java create mode 100644 src/main/java/gregtech/api/util/recipe/RecipeInputRequirements.java create mode 100644 src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java create mode 100644 src/main/java/gregtech/common/gui/MachineGUIProvider.java create mode 100644 src/main/java/gregtech/common/gui/PartGUIProvider.java create mode 100644 src/main/java/gregtech/common/misc/WirelessNetworkManager.java create mode 100644 src/main/java/gregtech/common/tileentities/casings/upgrade/Ampere.java create mode 100644 src/main/java/gregtech/common/tileentities/casings/upgrade/Cleanroom.java create mode 100644 src/main/java/gregtech/common/tileentities/casings/upgrade/Heater.java create mode 100644 src/main/java/gregtech/common/tileentities/casings/upgrade/Insulator.java create mode 100644 src/main/java/gregtech/common/tileentities/casings/upgrade/Laser.java create mode 100644 src/main/java/gregtech/common/tileentities/casings/upgrade/Tank.java create mode 100644 src/main/java/gregtech/common/tileentities/casings/upgrade/Wireless.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java delete mode 100644 src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalReactor.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/multiblock/DistillationTower.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/multiblock/LaserEngraver.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/multiblock/LayeredCokeBattery.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/multiblock/logic/AdvChemicalProcessorProcessingLogic.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/multiblock/logic/DistillationTowerProcessingLogic.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/multiblock/logic/LaserEngraverProcessingLogic.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/multiblock/logic/LayeredCokeBatteryProcessingLogic.java create mode 100644 src/main/java/gregtech/common/tileentities/machines/multiblock/logic/MaceratorProcessingLogic.java create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/BigLaserEngraver/active.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/BigLaserEngraver/active_glow.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/BigLaserEngraver/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/BigLaserEngraver/inactive.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/BigLaserEngraver/inactive_glow.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/BlackLaserEngraver/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/Laserblock/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/advChemicalProcessor/active.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/advChemicalProcessor/active_glow.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/advChemicalProcessor/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/advChemicalProcessor/inactive.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/advChemicalProcessor/inactive_glow.png delete mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/advChemicalReactor/active.png delete mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/advChemicalReactor/active_glow.png delete mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/advChemicalReactor/base.png delete mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/advChemicalReactor/inactive.png delete mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/advChemicalReactor/inactive_glow.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/amperage/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/cleanroom/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/distillationTower/active.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/distillationTower/active_glow.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/distillationTower/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/distillationTower/inactive.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/distillationTower/inactive_glow.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/heater/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/insulator/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/inventory/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/laser/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/laserengraverupgrade1/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/laserengraverupgrade2/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/laserengraverupgrade3/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/laserengraverupgrade4/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/tank/base.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/multitileentity/wireless/base.png (limited to 'src/main') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 59ee674e75..645702055b 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -61,7 +61,6 @@ import gregtech.api.enums.Textures; import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.interfaces.internal.IGT_Mod; import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; import gregtech.api.objects.XSTR; import gregtech.api.recipe.RecipeMaps; @@ -76,6 +75,7 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_RecipeRegistrator; import gregtech.api.util.GT_SpawnEventHandler; import gregtech.api.util.GT_Utility; +import gregtech.api.util.item.ItemHolder; import gregtech.common.GT_DummyWorld; import gregtech.common.GT_Network; import gregtech.common.GT_Proxy; @@ -286,7 +286,9 @@ public class GT_Mod implements IGT_Mod { new GT_Loader_ItemData().run(); new GT_Loader_Item_Block_And_Fluid().run(); new GT_Loader_MetaTileEntities().run(); - new GT_Loader_MultiTileEntities().run(); + if (GT_Values.enableMultiTileEntities) { + new GT_Loader_MultiTileEntities().run(); + } new GT_Loader_CircuitBehaviors().run(); new GT_CoverBehaviorLoader().run(); @@ -794,10 +796,10 @@ public class GT_Mod implements IGT_Mod { GT_Utility.reInit(); GT_Recipe.reInit(); try { - for (Map gt_itemStackMap : GregTech_API.sItemStackMappings) { + for (Map gt_itemStackMap : GregTech_API.sItemStackMappings) { GT_Utility.reMap(gt_itemStackMap); } - for (SetMultimap gt_itemStackMap : GregTech_API.itemStackMultiMaps) { + for (SetMultimap gt_itemStackMap : GregTech_API.itemStackMultiMaps) { GT_Utility.reMap(gt_itemStackMap); } } catch (Throwable e) { diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index c5e27aebca..1f936f3119 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -71,6 +71,7 @@ import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; +import gregtech.api.util.item.ItemHolder; import gregtech.api.world.GT_Worldgen; import gregtech.common.GT_DummyWorld; import gregtech.common.items.GT_IntegratedCircuit_Item; @@ -107,8 +108,8 @@ public class GregTech_API { /** * Fixes the HashMap Mappings for ItemStacks once the Server started */ - public static final Collection> sItemStackMappings = new ArrayList<>(); - public static final Collection> itemStackMultiMaps = new ArrayList<>(); + public static final Collection> sItemStackMappings = new ArrayList<>(); + public static final Collection> itemStackMultiMaps = new ArrayList<>(); /** * The MetaTileEntity-ID-List-Length diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index 98d9e5a176..418bf2d14c 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -289,7 +289,7 @@ public class GT_Values { public static final String COLOR = "gt.color", // Integer COVERS = "gt.covers", // String CUSTOM_NAME = "name", // String - DISPAY = "gt.display", // String + DISPLAY = "gt.display", // String TIER = "gt.tier", // Number FACING = "gt.facing", // Byte LOCK_UPGRADE = "gt.locked", // Boolean @@ -322,6 +322,7 @@ public class GT_Values { BURN_TIME_LEFT = "gt.burn.time.left", // Number TOTAL_BURN_TIME = "gt.total.burn.time", // Number ALLOWED_WORK = "gt.allowed.work", // Boolean + TASKS = "gt.tasks", // Compound // MultiBlock STRUCTURE_OK = "gt.structure.ok", ROTATION = "gt.eRotation", FLIP = "gt.eFlip", TARGET = "gt.target", // Boolean @@ -337,13 +338,14 @@ public class GT_Values { UPGRADE_INVENTORIES_INPUT = "gt.invlist.upg.in", // NBT List UPGRADE_INVENTORIES_OUTPUT = "gt.invlist.upg.out", // NBT List UPGRADE_TANK_CAPACITY = "gt.tank.cap.upg", // Long + UPGRADE_TANK_COUNT = "gt.tank.ct.upg", // Int UPGRADE_TANK_CAPACITY_MULTIPLIER = "gt.tank.cap.mult.upg", // Long UPGRADE_TANK_UUID = "gt.tankuuid.upg", // String UPGRADE_TANK_NAME = "gt.tankname.upg", // String UPGRADE_TANKS_INPUT = "gt.tanklist.upg.in", // NBT List UPGRADE_TANKS_OUTPUT = "gt.tanklist.upg.out", // NBT List - UPGRADE_TANKS_COUNT = "gt.tankcount.upg", // Int UPGRADE_TANKS_PREFIX = "gt.tank.upg", // NBT Tag + UPGRADE_AMPERAGE = "gt.amp.upg", // Long SEPARATE_INPUTS = "gt.separate.inputs", // Boolean VOIDING_MODE = "gt.voiding.mode", // String BATCH_MODE = "gt.batch.mode", // Boolean @@ -489,6 +491,11 @@ public class GT_Values { * Debug parameter for {@link gregtech.api.util.GT_ChunkAssociatedData} */ public static boolean debugWorldData = false; + /** + * Parameter if multi tile entities (MuTEs) should be enabled in the pack. Turned off by default until + * implementation is done. + */ + public static boolean enableMultiTileEntities = false; /** * Number of ticks between sending sound packets to clients for electric machines. Default is 1.5 seconds. Trying to * mitigate lag and FPS drops. @@ -606,6 +613,7 @@ public class GT_Values { + "minecraft7771"; public static final String AuthorQuerns = "Author: " + EnumChatFormatting.RED + "Querns"; + public static final String AuthorTheEpicGamer274 = "Author: " + "TheEpicGamer274"; // 7.5F comes from GT_Tool_Turbine_Large#getBaseDamage() given huge turbines are the most efficient now. public static double getMaxPlasmaTurbineEfficiencyFromMaterial(Materials material) { diff --git a/src/main/java/gregtech/api/enums/InventoryType.java b/src/main/java/gregtech/api/enums/InventoryType.java new file mode 100644 index 0000000000..f8e3c47741 --- /dev/null +++ b/src/main/java/gregtech/api/enums/InventoryType.java @@ -0,0 +1,7 @@ +package gregtech.api.enums; + +public enum InventoryType { + Input, + Output, + Both; +} diff --git a/src/main/java/gregtech/api/gui/GUIHost.java b/src/main/java/gregtech/api/gui/GUIHost.java new file mode 100644 index 0000000000..bbb94317c4 --- /dev/null +++ b/src/main/java/gregtech/api/gui/GUIHost.java @@ -0,0 +1,56 @@ +package gregtech.api.gui; + +import java.util.Objects; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; + +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; + +public interface GUIHost extends ITileWithModularUI { + + @Nonnull + @Override + default ModularWindow createWindow(UIBuildContext uiContext) { + Objects.requireNonNull(uiContext); + GUIProvider gui = getGUI(uiContext); + return gui.openGUI(uiContext); + } + + /** + * Width of the GUI when its being displayed + */ + default int getWidth() { + return 170; + } + + default int getHeight() { + return 192; + } + + @Nonnull + GUIProvider getGUI(@Nonnull UIBuildContext uiContext); + + ItemStack getAsItem(); + + String getMachineName(); + + default boolean hasItemInput() { + return true; + } + + default boolean hasItemOutput() { + return true; + } + + default boolean hasFluidInput() { + return true; + } + + default boolean hasFluidOutput() { + return true; + } +} diff --git a/src/main/java/gregtech/api/gui/GUIProvider.java b/src/main/java/gregtech/api/gui/GUIProvider.java new file mode 100644 index 0000000000..6fec4aa52a --- /dev/null +++ b/src/main/java/gregtech/api/gui/GUIProvider.java @@ -0,0 +1,38 @@ +package gregtech.api.gui; + +import java.util.Objects; + +import javax.annotation.Nonnull; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; + +public abstract class GUIProvider { + + @Nonnull + protected final T host; + + public GUIProvider(@Nonnull T host) { + this.host = host; + } + + @Nonnull + public ModularWindow openGUI(@Nonnull UIBuildContext uiContext) { + Builder builder = Objects.requireNonNull(ModularWindow.builder(host.getWidth(), host.getHeight())); + if (shouldBindPlayerInventory()) { + builder.bindPlayerInventory(uiContext.getPlayer()); + } + attachSynchHandlers(builder, uiContext); + addWidgets(builder, uiContext); + return Objects.requireNonNull(builder.build()); + } + + protected abstract void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext); + + protected abstract void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext); + + protected boolean shouldBindPlayerInventory() { + return true; + } +} diff --git a/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java b/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java index be4db5412a..47c03743a5 100644 --- a/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java +++ b/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java @@ -1,25 +1,25 @@ package gregtech.api.interfaces; -import static gregtech.common.misc.GlobalVariableStorage.GlobalEnergy; -import static gregtech.common.misc.GlobalVariableStorage.GlobalEnergyName; -import static gregtech.common.misc.GlobalVariableStorage.GlobalEnergyTeam; - import java.math.BigInteger; import java.util.UUID; import net.minecraft.entity.player.EntityPlayer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.common.misc.GlobalEnergyWorldSavedData; +import gregtech.common.misc.WirelessNetworkManager; // If you are adding very late-game content feel free to tap into this interface. // The eventual goal is to bypass laser/dynamo stuff and have energy deposited directly from ultra-endgame // multi-blocks directly into the users network. +/** + * Use WirelessNetworkManager instead + */ +@Deprecated public interface IGlobalWirelessEnergy { // User 0 will join user 1 by calling this function. They will share the same energy network. default void joinUserNetwork(String user_uuid_0, String user_uuid_1) { - GlobalEnergyTeam.put(user_uuid_0, user_uuid_1); + WirelessNetworkManager.joinUserNetwork(user_uuid_0, user_uuid_1); } // Adds a user to the energy map if they do not already exist. Otherwise, do nothing. Will also check if the user @@ -27,35 +27,18 @@ public interface IGlobalWirelessEnergy { // tick of a machine being placed only. default void strongCheckOrAddUser(EntityPlayer user) { - strongCheckOrAddUser( + WirelessNetworkManager.strongCheckOrAddUser( user.getUniqueID() .toString(), user.getDisplayName()); } default void strongCheckOrAddUser(UUID user_uuid, String user_name) { - strongCheckOrAddUser(user_uuid.toString(), user_name); + WirelessNetworkManager.strongCheckOrAddUser(user_uuid.toString(), user_name); } default void strongCheckOrAddUser(String user_uuid, String user_name) { - - // Check if the user has a team. Add them if not. - GlobalEnergyTeam.putIfAbsent(user_uuid, user_uuid); - - // Check if the user is in the global energy map. - GlobalEnergy.putIfAbsent(user_uuid, BigInteger.ZERO); - - // If the username linked to the users fixed uuid is not equal to their current name then remove it. - // This indicates that their username has changed. - if (!(GlobalEnergyName.getOrDefault(user_uuid, "") - .equals(user_name))) { - String old_name = GlobalEnergyName.get(user_uuid); - GlobalEnergyName.remove(old_name); - } - - // Add UUID -> Name, Name -> UUID. - GlobalEnergyName.put(user_name, user_uuid); - GlobalEnergyName.put(user_uuid, user_name); + WirelessNetworkManager.strongCheckOrAddUser(user_uuid, user_name); } // ------------------------------------------------------------------------------------ @@ -64,30 +47,7 @@ public interface IGlobalWirelessEnergy { // BigIntegers have much slower operations than longs/ints. You should call these methods // as infrequently as possible and bulk store values to add to the global map. default boolean addEUToGlobalEnergyMap(String userUUID, BigInteger EU) { - - // Mark the data as dirty and in need of saving. - try { - GlobalEnergyWorldSavedData.INSTANCE.markDirty(); - } catch (Exception exception) { - System.out.println("COULD NOT MARK GLOBAL ENERGY AS DIRTY IN ADD EU"); - exception.printStackTrace(); - } - - // Get the team UUID. Users are by default in a team with a UUID equal to their player UUID. - String teamUUID = GlobalEnergyTeam.getOrDefault(userUUID, userUUID); - - // Get the teams total energy stored. If they are not in the map, return 0 EU. - BigInteger totalEU = GlobalEnergy.getOrDefault(teamUUID, BigInteger.ZERO); - totalEU = totalEU.add(EU); - - // If there is sufficient EU then complete the operation and return true. - if (totalEU.signum() >= 0) { - GlobalEnergy.put(teamUUID, totalEU); - return true; - } - - // There is insufficient EU so cancel the operation and return false. - return false; + return WirelessNetworkManager.addEUToGlobalEnergyMap(userUUID, EU); } default boolean addEUToGlobalEnergyMap(UUID user_uuid, BigInteger EU) { @@ -113,28 +73,20 @@ public interface IGlobalWirelessEnergy { // ------------------------------------------------------------------------------------ default BigInteger getUserEU(String user_uuid) { - return GlobalEnergy.getOrDefault(GlobalEnergyTeam.getOrDefault(user_uuid, user_uuid), BigInteger.ZERO); + return WirelessNetworkManager.getUserEU(user_uuid); } // This overwrites the EU in the network. Only use this if you are absolutely sure you know what you are doing. default void setUserEU(String user_uuid, BigInteger EU) { - // Mark the data as dirty and in need of saving. - try { - GlobalEnergyWorldSavedData.INSTANCE.markDirty(); - } catch (Exception exception) { - System.out.println("COULD NOT MARK GLOBAL ENERGY AS DIRTY IN SET EU"); - exception.printStackTrace(); - } - - GlobalEnergy.put(GlobalEnergyTeam.get(user_uuid), EU); + WirelessNetworkManager.setUserEU(user_uuid, EU); } default String GetUsernameFromUUID(String uuid) { - return GlobalEnergyName.getOrDefault(GlobalEnergyTeam.getOrDefault(uuid, ""), ""); + return WirelessNetworkManager.getUsernameFromUUID(uuid); } default String getUUIDFromUsername(String username) { - return GlobalEnergyTeam.getOrDefault(GlobalEnergyName.getOrDefault(username, ""), ""); + return WirelessNetworkManager.getUUIDFromUsername(username); } /** @@ -143,24 +95,14 @@ public interface IGlobalWirelessEnergy { * @return */ default String getRawUUIDFromUsername(String username) { - return GlobalEnergyName.getOrDefault(username, ""); + return WirelessNetworkManager.getRawUUIDFromUsername(username); } static void clearGlobalEnergyInformationMaps() { - // Do not use this unless you are 100% certain you know what you are doing. - GlobalEnergy.clear(); - GlobalEnergyName.clear(); - GlobalEnergyTeam.clear(); + WirelessNetworkManager.clearGlobalEnergyInformationMaps(); } default String processInitialSettings(final IGregTechTileEntity machine) { - - // UUID and username of the owner. - final String UUID = machine.getOwnerUuid() - .toString(); - final String name = machine.getOwnerName(); - - strongCheckOrAddUser(UUID, name); - return UUID; + return WirelessNetworkManager.processInitialSettings(machine); } } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java index f866092d38..91a9759e47 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java @@ -1,5 +1,9 @@ package gregtech.api.interfaces.tileentity; +import java.util.Objects; + +import javax.annotation.Nonnull; + import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; @@ -53,24 +57,25 @@ public interface IEnergyConnected extends IColoredTileEntity { */ final class Util { + // TODO: Deduplicate code by rewokring the Enet system using the GTCEu one as inspiration - BlueWeabo /** * Emits Energy to the E-net. Also compatible with adjacent IC2 TileEntities. * * @return the used Amperage. */ - public static long emitEnergyToNetwork(long aVoltage, long aAmperage, IEnergyConnected aEmitter) { - long rUsedAmperes = 0; - if (!(aEmitter instanceof IHasWorldObjectAndCoords emitterTile)) { + public static long emitEnergyToNetwork(long voltage, long amperage, IEnergyConnected emitter) { + long usedAmperes = 0; + if (!(emitter instanceof IHasWorldObjectAndCoords emitterTile)) { return 0; } for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - if (rUsedAmperes > aAmperage) break; - if (!aEmitter.outputsEnergyTo(side)) { + if (usedAmperes > amperage) break; + if (!emitter.outputsEnergyTo(side)) { continue; } - final ForgeDirection oppositeSide = side.getOpposite(); + final ForgeDirection oppositeSide = Objects.requireNonNull(side.getOpposite()); final TileEntity tTileEntity = emitterTile.getTileEntityAtSide(side); if (tTileEntity instanceof PowerLogicHost host) { @@ -79,28 +84,95 @@ public interface IEnergyConnected extends IColoredTileEntity { continue; } - rUsedAmperes += logic.injectEnergy(aVoltage, aAmperage - rUsedAmperes); + usedAmperes += logic.injectEnergy(voltage, amperage - usedAmperes); } else if (tTileEntity instanceof IEnergyConnected energyConnected) { - if (aEmitter.getColorization() >= 0) { + if (emitter.getColorization() >= 0) { final byte tColor = energyConnected.getColorization(); - if (tColor >= 0 && tColor != aEmitter.getColorization()) continue; + if (tColor >= 0 && tColor != emitter.getColorization()) continue; } - rUsedAmperes += energyConnected.injectEnergyUnits(oppositeSide, aVoltage, aAmperage - rUsedAmperes); + usedAmperes += energyConnected.injectEnergyUnits(oppositeSide, voltage, amperage - usedAmperes); } else if (tTileEntity instanceof IEnergySink sink) { - if (sink.acceptsEnergyFrom((TileEntity) aEmitter, oppositeSide)) { - while (aAmperage > rUsedAmperes && sink.getDemandedEnergy() > 0 - && sink.injectEnergy(oppositeSide, aVoltage, aVoltage) < aVoltage) rUsedAmperes++; + if (sink.acceptsEnergyFrom((TileEntity) emitter, oppositeSide)) { + while (amperage > usedAmperes && sink.getDemandedEnergy() > 0 + && sink.injectEnergy(oppositeSide, voltage, voltage) < voltage) usedAmperes++; } } else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver receiver) { - final int rfOut = GT_Utility.safeInt(aVoltage * GregTech_API.mEUtoRF / 100); + final int rfOut = GT_Utility.safeInt(voltage * GregTech_API.mEUtoRF / 100); if (receiver.receiveEnergy(oppositeSide, rfOut, true) == rfOut) { receiver.receiveEnergy(oppositeSide, rfOut, false); - rUsedAmperes++; + usedAmperes++; + } + } + } + return usedAmperes; + } + + /** + * Same as {@link #emitEnergyToNetwork(long, long, IEnergyConnected)}, but instead we remove the energy directly from the logic itself. + * @param emitter The host, which is trying to emit energy in the network + * @param outputSide side from where energy is being outputted to. If its {@link ForgeDirection#UNKNOWN} then it doesn't emit energy to the network + */ + public static void emitEnergyToNetwork(@Nonnull final PowerLogicHost emitter, @Nonnull final ForgeDirection outputSide) { + if (outputSide == ForgeDirection.UNKNOWN) return; + final PowerLogic emitterLogic = emitter.getPowerLogic(); + long usedAmperes = 0; + long voltage = emitterLogic.getVoltage(); + long amperage = emitterLogic.getMaxAmperage(); + if (!(emitter instanceof final IHasWorldObjectAndCoords emitterTile)) { +