diff options
author | BlueWeabo <ilia.iliev2005@gmail.com> | 2024-01-06 00:41:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-05 23:41:00 +0100 |
commit | 02bedd5c0a96a654c6692edd1b7f2765fd9c46b4 (patch) | |
tree | 57dd675f658dda3caba629f15d4708247e702f88 /src/main/java/gregtech/common | |
parent | fc63cee4c0284635c601889ce49a892cf73082ff (diff) | |
download | GT5-Unofficial-02bedd5c0a96a654c6692edd1b7f2765fd9c46b4.tar.gz GT5-Unofficial-02bedd5c0a96a654c6692edd1b7f2765fd9c46b4.tar.bz2 GT5-Unofficial-02bedd5c0a96a654c6692edd1b7f2765fd9c46b4.zip |
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 <maxim235@gmx.de>
Co-authored-by: BlueWeabo <ilia.iliev2005@gmail.com>
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 <dream-master@gmx.net>
* 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 <dream-master@gmx.net>
* 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<FindRecipeResult> 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 <miozune@gmail.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 <dream-master@gmx.net>
Co-authored-by: Harry <harryyunull@gmail.com>
Co-authored-by: Eraldoe <Eraldoe@users.noreply.github.com>
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 <C0bra5@users.noreply.github.com>
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 <jaidencolebaker@gmail.com>
* 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 <jason@puzzle.io>
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 <maxim235@gmx.de>
Co-authored-by: RIONDY 'POPlol333' Adam <76914762+POPlol333@users.noreply.github.com>
Co-authored-by: Jason Mitchell <mitchej@gmail.com>
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 <miozune@gmail.com>
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 <dream-master@gmx.net>
Co-authored-by: Harry <harryyunull@gmail.com>
Co-authored-by: Eraldoe <Eraldoe@users.noreply.github.com>
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 <C0bra5@users.noreply.github.com>
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 <jaidencolebaker@gmail.com>
Co-authored-by: boubou19 <miisterunknown@gmail.com>
Co-authored-by: Jason Mitchell <jason@puzzle.io>
Diffstat (limited to 'src/main/java/gregtech/common')
29 files changed, 2437 insertions, 612 deletions
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 31f7bf4943..24e8b9d271 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -139,7 +139,6 @@ import gregtech.api.enums.TierEU; import gregtech.api.enums.ToolDictNames; import gregtech.api.fluid.GT_FluidFactory; import gregtech.api.interfaces.IBlockOnWalkOver; -import gregtech.api.interfaces.IGlobalWirelessEnergy; import gregtech.api.interfaces.IProjectileItem; import gregtech.api.interfaces.IToolStats; import gregtech.api.interfaces.internal.IGT_Mod; @@ -176,7 +175,7 @@ import gregtech.common.misc.GlobalEnergyWorldSavedData; import gregtech.common.misc.GlobalMetricsCoverDatabase; import gregtech.common.misc.spaceprojects.SpaceProjectWorldSavedData; -public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IGlobalWirelessEnergy { +public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { private static final EnumSet<OreGenEvent.GenerateMinable.EventType> PREVENTED_ORES = EnumSet.of( OreGenEvent.GenerateMinable.EventType.COAL, diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Pump.java b/src/main/java/gregtech/common/covers/GT_Cover_Pump.java index c19f9d0d3a..a31a18c821 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Pump.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Pump.java @@ -45,33 +45,35 @@ public class GT_Cover_Pump extends GT_CoverBehavior { return aCoverVariable; } } - if ((aTileEntity instanceof IFluidHandler)) { - final IFluidHandler tTank2 = aTileEntity.getITankContainerAtSide(side); - if (tTank2 != null) { - // aTileEntity.decreaseStoredEnergyUnits(GT_Utility.getTier(this.mTransferRate), true); - final IFluidHandler tTank1 = (IFluidHandler) aTileEntity; - if (aCoverVariable % 2 == 0) { - FluidStack tLiquid = tTank1.drain(side, this.mTransferRate, false); - if (tLiquid != null) { - tLiquid = tLiquid.copy(); - tLiquid.amount = tTank2.fill(side.getOpposite(), tLiquid, false); - if (tLiquid.amount > 0 && canTransferFluid(tLiquid)) { - tTank2.fill(side.getOpposite(), tTank1.drain(side, tLiquid.amount, true), true); - } - } - } else { - FluidStack tLiquid = tTank2.drain(side.getOpposite(), this.mTransferRate, false); - if (tLiquid != null) { - tLiquid = tLiquid.copy(); - tLiquid.amount = tTank1.fill(side, tLiquid, false); - if (tLiquid.amount > 0 && canTransferFluid(tLiquid)) { - tTank1.fill(side, tTank2.drain(side.getOpposite(), tLiquid.amount, true), true); - } - } + + if (aTileEntity instanceof IFluidHandler current) { + final IFluidHandler toAccess = aTileEntity.getITankContainerAtSide(side); + transferFluid(current, toAccess, side, aCoverVariable % 2); + } + return aCoverVariable; + } + + protected void transferFluid(IFluidHandler current, IFluidHandler toAccess, ForgeDirection side, + int exportOrImport) { + if (exportOrImport == 0) { + FluidStack liquid = current.drain(side, this.mTransferRate, false); + if (liquid != null) { + liquid = liquid.copy(); + liquid.amount = toAccess.fill(side.getOpposite(), liquid, false); + if (liquid.amount > 0 && canTransferFluid(liquid)) { + toAccess.fill(side.getOpposite(), current.drain(side, liquid.amount, true), true); } } + return; + } + FluidStack liquid = toAccess.drain(side.getOpposite(), this.mTransferRate, false); + if (liquid != null) { + liquid = liquid.copy(); + liquid.amount = current.fill(side, liquid, false); + if (liquid.amount > 0 && canTransferFluid(liquid)) { + current.fill(side, toAccess.drain(side.getOpposite(), liquid.amount, true), true); + } } - return aCoverVariable; } protected boolean canTransferFluid(FluidStack fluid) { diff --git a/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java b/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java new file mode 100644 index 0000000000..89b42c8500 --- /dev/null +++ b/src/main/java/gregtech/common/gui/ComplexParallelMachineGUIProvider.java @@ -0,0 +1,32 @@ +package gregtech.common.gui; + +import javax.annotation.Nonnull; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; + +import gregtech.api.gui.GUIHost; +import gregtech.api.logic.ComplexParallelProcessingLogic; +import gregtech.api.logic.interfaces.PowerLogicHost; +import gregtech.api.logic.interfaces.ProcessingLogicHost; + +/** + * Default GUI class for machines with complex parallel + */ +public class ComplexParallelMachineGUIProvider<T extends GUIHost & ProcessingLogicHost<? extends ComplexParallelProcessingLogic<?>> & PowerLogicHost> + extends MachineGUIProvider<T> { + + public ComplexParallelMachineGUIProvider(@Nonnull T host) { + super(host); + } + + @Override + protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + + } + + @Override + protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + + } +} diff --git a/src/main/java/gregtech/common/gui/MachineGUIProvider.java b/src/main/java/gregtech/common/gui/MachineGUIProvider.java new file mode 100644 index 0000000000..91d14c209a --- /dev/null +++ b/src/main/java/gregtech/common/gui/MachineGUIProvider.java @@ -0,0 +1,498 @@ +package gregtech.common.gui; + +import static gregtech.api.metatileentity.BaseTileEntity.BUTTON_FORBIDDEN_TOOLTIP; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nonnull; + +import net.minecraft.util.StatCollector; + +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import com.gtnewhorizons.modularui.common.widget.TabButton; +import com.gtnewhorizons.modularui.common.widget.TabContainer; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import gregtech.api.enums.InventoryType; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.VoidingMode; +import gregtech.api.gui.GUIHost; +import gregtech.api.gui.GUIProvider; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.api.logic.MuTEProcessingLogic; +import gregtech.api.logic.PowerLogic; +import gregtech.api.logic.interfaces.PowerLogicHost; +import gregtech.api.logic.interfaces.ProcessingLogicHost; + +/** + * Default GUI a machine will use to show its information + */ +public class MachineGUIProvider<T extends GUIHost & ProcessingLogicHost<? extends MuTEProcessingLogic<?>> & PowerLogicHost> + extends GUIProvider<T> { + + private static final int LOGO_SIZE = 17; + @Nonnull + protected static final Pos2d POWER_SWITCH_BUTTON_DEFAULT_POS = new Pos2d(144, 0); + @Nonnull + protected static final Pos2d VOIDING_MODE_BUTTON_DEFAULT_POS = new Pos2d(54, 0); + @Nonnull + protected static final Pos2d INPUT_SEPARATION_BUTTON_DEFAULT_POS = new Pos2d(36, 0); + @Nonnull + protected static final Pos2d BATCH_MODE_BUTTON_DEFAULT_POS = new Pos2d(18, 0); + @Nonnull + protected static final Pos2d RECIPE_LOCKING_BUTTON_DEFAULT_POS = new Pos2d(0, 0); + + public MachineGUIProvider(@Nonnull T host) { + super(host); + } + + @Override + protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + + } + + @Override + protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + int page = 0; + builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + MultiChildWidget mainTab = new MultiChildWidget(); + mainTab.setSize(host.getWidth(), host.getHeight()); + createMainTab(mainTab, builder, uiContext); + TabContainer tabs = new TabContainer().setButtonSize(20, 24); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0, 1f, 0.5f), + new ItemDrawable(host.getAsItem()).withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0.5f, 1f, 1f), + new ItemDrawable(host.getAsItem()).withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip(host.getMachineName()) + .setPos(20 * (page - 1), -20)) + .addPage(mainTab); + if (host.hasItemInput()) { + MultiChildWidget itemInputTab = new MultiChildWidget(); + itemInputTab.setSize(host.getWidth(), host.getHeight()); + createItemInputTab(itemInputTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_ITEM_IN.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_ITEM_IN.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Item Input Inventory") + .setPos(20 * (page - 1), -20)) + .addPage(itemInputTab.addChild(getLogo().setPos(147, 86))); + } + + if (host.hasItemOutput()) { + MultiChildWidget itemOutputTab = new MultiChildWidget(); + itemOutputTab.setSize(host.getWidth(), host.getHeight()); + createItemOutputTab(itemOutputTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_ITEM_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_ITEM_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Item Output Inventory") + .setPos(20 * (page - 1), -20)) + .addPage(itemOutputTab.addChild(getLogo().setPos(147, 86))); + } + + if (host.hasFluidInput()) { + MultiChildWidget fluidInputTab = new MultiChildWidget(); + fluidInputTab.setSize(host.getWidth(), host.getHeight()); + createFluidInputTab(fluidInputTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_FLUID_IN.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_FLUID_IN.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Fluid Input Tanks") + .setPos(20 * (page - 1), -20)) + .addPage(fluidInputTab.addChild(getLogo().setPos(147, 86))); + } + + if (host.hasFluidOutput()) { + MultiChildWidget fluidOutputTab = new MultiChildWidget(); + fluidOutputTab.setSize(host.getWidth(), host.getHeight()); + createFluidOutputTab(fluidOutputTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Fluid Output Tanks") + .setPos(20 * (page - 1), -20)) + .addPage(fluidOutputTab.addChild(getLogo().setPos(147, 86))); + } + MultiChildWidget powerInfoTab = new MultiChildWidget(); + powerInfoTab.setSize(host.getWidth(), host.getHeight()); + createPowerTab(powerInfoTab, builder, uiContext); + tabs.addTabButton( + new TabButton(page++) + .setBackground( + false, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f), + GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .setBackground( + true, + ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f), + GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16) + .withOffset(2, 4)) + .addTooltip("Power Information") + .setPos(20 * (page - 1), -20)) + .addPage(powerInfoTab.addChild(getLogo().setPos(147, 86))); + builder.widget(tabs); + } + + protected void createMainTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + MultiChildWidget buttons = new MultiChildWidget(); + buttons.setSize(16, 167) + .setPos(7, 86); + buttons.addChild(createPowerSwitchButton(builder)) + .addChild(createVoidExcessButton(builder)) + .addChild(createInputSeparationButton(builder)) + .addChild(createBatchModeButton(builder)) + .addChild(createLockToSingleRecipeButton(builder)); + tab.addChild( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setPos(7, 4) + .setSize(160, 75)) + .addChild(buttons); + } + + protected void createItemInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getItemLogic(InventoryType.Input, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); + } + + protected void createItemOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getItemLogic(InventoryType.Output, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); + } + + protected void createFluidInputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getFluidLogic(InventoryType.Input, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); + } + + protected void createFluidOutputTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + tab.addChild( + host.getFluidLogic(InventoryType.Output, null) + .getGuiPart() + .setSize(18 * 4 + 9, 5 * 18) + .setPos(host.getWidth() / 2 - 2 * 18, 10)); + } + + protected void createPowerTab(@Nonnull MultiChildWidget tab, @Nonnull Builder builder, + @Nonnull UIBuildContext uiBuildContext) { + PowerLogic power = host.getPowerLogic(); + tab.addChild( + TextWidget.dynamicString(() -> power.getStoredEnergy() + "/" + power.getCapacity() + " EU") + .setPos(10, 30)) + .addChild( + TextWidget.dynamicString(() -> power.getVoltage() + " EU/t" + "(" + power.getMaxAmperage() + " A)") + .setPos(10, 60)); + } + + /** + * Should return the logo you want to use that is pasted on each tab. Default is the GT logo. + */ + @Nonnull + protected Widget getLogo() { + DrawableWidget logo = new DrawableWidget(); + logo.setDrawable(GUITextureSet.DEFAULT.getGregTechLogo()) + .setSize(LOGO_SIZE, LOGO_SIZE); + return logo; + } + + protected Pos2d getPowerSwitchButtonPos() { + return POWER_SWITCH_BUTTON_DEFAULT_POS; + } + + protected ButtonWidget createPowerSwitchButton(IWidgetBuilder<?> builder) { + ButtonWidget button = new ButtonWidget(); + button.setOnClick((clickData, widget) -> { + if (host.isAllowedToWork()) { + host.disableWorking(); + } else { + host.enableWorking(); + } + }) + .setPlayClickSoundResource( + () -> host.isAllowedToWork() ? SoundResource.GUI_BUTTON_UP.resourceLocation + : SoundResource.GUI_BUTTON_DOWN.resourceLocation) + .setBackground(() -> { + if (host.isAllowedToWork()) { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD_PRESSED, + GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_ON }; + } else { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, + GT_UITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF }; + } + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(host::isAllowedToWork, host::setAllowedToWork), builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.power_switch")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(getPowerSwitchButtonPos()) + .setSize(16, 16); + return button; + } + + @Nonnull + protected Pos2d getVoidingModeButtonPos() { + return VOIDING_MODE_BUTTON_DEFAULT_POS; + } + + @Nonnull + protected ButtonWidget createVoidExcessButton(IWidgetBuilder<?> builder) { + ButtonWidget button = new ButtonWidget(); + button.setOnClick((clickData, widget) -> { + if (host.supportsVoidProtection()) { + Set<VoidingMode> allowed = host.getAllowedVoidingModes(); + switch (clickData.mouseButton) { + case 0 -> host.setVoidingMode( + host.getVoidingMode() + .nextInCollection(allowed)); + case 1 -> host.setVoidingMode( + host.getVoidingMode() + .previousInCollection(allowed)); + } + widget.notifyTooltipChange(); + } + }) + .setPlayClickSound(host.supportsVoidProtection()) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(host.getVoidingMode().buttonTexture); + ret.add(host.getVoidingMode().buttonOverlay); + if (!host.supportsVoidProtection()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_FORBIDDEN); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer( + new FakeSyncWidget.IntegerSyncer( + () -> host.getVoidingMode() + .ordinal(), + val -> host.setVoidingMode(VoidingMode.fromOrdinal(val))), + builder) + .dynamicTooltip( + () -> Arrays.asList( + StatCollector.translateToLocal("GT5U.gui.button.voiding_mode"), + StatCollector.translateToLocal( + host.getVoidingMode() + .getTransKey()))) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(getVoidingModeButtonPos()) + .setSize(16, 16); + if (!host.supportsVoidProtection()) { + button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); + } + return button; + } + + @Nonnull + protected Pos2d getInputSeparationButtonPos() { + return INPUT_SEPARATION_BUTTON_DEFAULT_POS; + } + + protected ButtonWidget createInputSeparationButton(IWidgetBuilder<?> builder) { + ButtonWidget button = new ButtonWidget(); + button.setOnClick((clickData, widget) -> { + if (host.supportsInputSeparation()) { + host.setInputSeparation(!host.isInputSeparated()); + } + }) + .setPlayClickSound(host.supportsInputSeparation()) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + if (host.isInputSeparated()) { + ret.add(GT_UITextures.BUTTON_STANDARD_PRESSED); + if (host.supportsInputSeparation()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_ON); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_ON_DISABLED); + } + } else { + ret.add(GT_UITextures.BUTTON_STANDARD); + if (host.supportsInputSeparation()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_OFF); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_INPUT_SEPARATION_OFF_DISABLED); + } + } + if (!host.supportsInputSeparation()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_FORBIDDEN); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(host::isInputSeparated, host::setInputSeparation), builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.input_separation")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(getInputSeparationButtonPos()) + .setSize(16, 16); + if (!host.supportsInputSeparation()) { + button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); + } + return button; + } + + @Nonnull + protected Pos2d getBatchModeButtonPos() { + return BATCH_MODE_BUTTON_DEFAULT_POS; + } + + protected ButtonWidget createBatchModeButton(IWidgetBuilder<?> builder) { + ButtonWidget button = new ButtonWidget(); + button.setOnClick((clickData, widget) -> { + if (host.supportsBatchMode()) { + host.setBatchMode(!host.isBatchModeEnabled()); + } + }) + .setPlayClickSound(host.supportsBatchMode()) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + if (host.isBatchModeEnabled()) { + ret.add(GT_UITextures.BUTTON_STANDARD_PRESSED); + if (host.supportsBatchMode()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_ON); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_ON_DISABLED); + } + } else { + ret.add(GT_UITextures.BUTTON_STANDARD); + if (host.supportsBatchMode()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_OFF); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_BATCH_MODE_OFF_DISABLED); + } + } + if (!host.supportsBatchMode()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_FORBIDDEN); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(host::isBatchModeEnabled, host::setBatchMode), builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.batch_mode")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(getBatchModeButtonPos()) + .setSize(16, 16); + if (!host.supportsBatchMode()) { + button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); + } + return button; + } + + @Nonnull + protected Pos2d getRecipeLockingButtonPos() { + return RECIPE_LOCKING_BUTTON_DEFAULT_POS; + } + + protected ButtonWidget createLockToSingleRecipeButton(IWidgetBuilder<?> builder) { + ButtonWidget button = new ButtonWidget(); + button.setOnClick((clickData, widget) -> { + if (host.supportsSingleRecipeLocking()) { + host.setRecipeLocking(!host.isRecipeLockingEnabled()); + } + }) + .setPlayClickSound(host.supportsSingleRecipeLocking()) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + if (host.isRecipeLockingEnabled()) { + ret.add(GT_UITextures.BUTTON_STANDARD_PRESSED); + if (host.supportsSingleRecipeLocking()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_LOCKED); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_LOCKED_DISABLED); + } + } else { + ret.add(GT_UITextures.BUTTON_STANDARD); + if (host.supportsSingleRecipeLocking()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED); + } else { + ret.add(GT_UITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED_DISABLED); + } + } + if (!host.supportsSingleRecipeLocking()) { + ret.add(GT_UITextures.OVERLAY_BUTTON_FORBIDDEN); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(host::isRecipeLockingEnabled, host::setRecipeLocking), + builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.lock_recipe")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(getRecipeLockingButtonPos()) + .setSize(16, 16); + if (!host.supportsSingleRecipeLocking()) { + button.addTooltip(StatCollector.translateToLocal(BUTTON_FORBIDDEN_TOOLTIP)); + } + return button; + } +} diff --git a/src/main/java/gregtech/common/gui/PartGUIProvider.java b/src/main/java/gregtech/common/gui/PartGUIProvider.java new file mode 100644 index 0000000000..7600444f71 --- /dev/null +++ b/src/main/java/gregtech/common/gui/PartGUIProvider.java @@ -0,0 +1,33 @@ +package gregtech.common.gui; + +import javax.annotation.Nonnull; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow.Builder; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; + +import gregtech.api.gui.GUIHost; +import gregtech.api.gui.GUIProvider; +import gregtech.api.logic.interfaces.FluidInventoryLogicHost; +import gregtech.api.logic.interfaces.ItemInventoryLogicHost; +import gregtech.api.logic.interfaces.PowerLogicHost; + +public class PartGUIProvider<T extends GUIHost & ItemInventoryLogicHost & PowerLogicHost & FluidInventoryLogicHost> + extends GUIProvider<T> { + + public PartGUIProvider(@Nonnull T host) { + super(host); + } + + @Override + protected void attachSynchHandlers(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'attachSynchHandlers'"); + } + + @Override + protected void addWidgets(@Nonnull Builder builder, @Nonnull UIBuildContext uiContext) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'addWidgets'"); + } + +} diff --git a/src/main/java/gregtech/common/misc/GT_Command.java b/src/main/java/gregtech/common/misc/GT_Command.java index 35e7a71f65..ad3293be90 100644 --- a/src/main/java/gregtech/common/misc/GT_Command.java +++ b/src/main/java/gregtech/common/misc/GT_Command.java @@ -1,5 +1,13 @@ package gregtech.common.misc; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.getRawUUIDFromUsername; +import static gregtech.common.misc.WirelessNetworkManager.getUUIDFromUsername; +import static gregtech.common.misc.WirelessNetworkManager.getUserEU; +import static gregtech.common.misc.WirelessNetworkManager.getUsernameFromUUID; +import static gregtech.common.misc.WirelessNetworkManager.joinUserNetwork; +import static gregtech.common.misc.WirelessNetworkManager.setUserEU; + import java.lang.reflect.Field; import java.math.BigInteger; import java.util.ArrayList; @@ -16,12 +24,11 @@ import com.gtnewhorizon.structurelib.StructureLib; import gregtech.GT_Mod; import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.IGlobalWirelessEnergy; import gregtech.api.objects.GT_ChunkManager; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; -public final class GT_Command extends CommandBase implements IGlobalWirelessEnergy { +public final class GT_Command extends CommandBase { @Override public String getCommandName() { @@ -355,7 +362,7 @@ public final class GT_Command extends CommandBase implements IGlobalWirelessEner "User " + formatted_username + " is currently in network of " + EnumChatFormatting.BLUE - + GetUsernameFromUUID(uuidTeam) + + getUsernameFromUUID(uuidTeam) + EnumChatFormatting.RESET + ".")); diff --git a/src/main/java/gregtech/common/misc/WirelessNetworkManager.java b/src/main/java/gregtech/common/misc/WirelessNetworkManager.java new file mode 100644 index 0000000000..dc11becdbb --- /dev/null +++ b/src/main/java/gregtech/common/misc/WirelessNetworkManager.java @@ -0,0 +1,164 @@ +package gregtech.common.misc; + +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; + +public class WirelessNetworkManager { + + private WirelessNetworkManager() {} + + // User 0 will join user 1 by calling this function. They will share the same energy network. + public static void joinUserNetwork(String user_uuid_0, String user_uuid_1) { + GlobalEnergyTeam.put(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 + // has changed their username and adjust the maps accordingly. This should be called infrequently. Ideally on first + // tick of a machine being placed only. + + public static void strongCheckOrAddUser(EntityPlayer user) { + strongCheckOrAddUser( + user.getUniqueID() + .toString(), + user.getDisplayName()); + } + + public static void strongCheckOrAddUser(UUID user_uuid, String user_name) { + strongCheckOrAddUser(user_uuid.toString(), user_name); + } + + public static 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); + } + + // ------------------------------------------------------------------------------------ + // Add EU to the users global energy. You can enter a negative number to subtract it. + // If the value goes below 0 it will return false and not perform the operation. + // 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. + public static 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; + } + + public static boolean addEUToGlobalEnergyMap(UUID user_uuid, BigInteger EU) { + return addEUToGlobalEnergyMap(user_uuid.toString(), EU); + } + + public static boolean addEUToGlobalEnergyMap(UUID user_uuid, long EU) { + return addEUToGlobalEnergyMap(user_uuid.toString(), BigInteger.valueOf(EU)); + } + + public static boolean addEUToGlobalEnergyMap(UUID user_uuid, int EU) { + return addEUToGlobalEnergyMap(user_uuid.toString(), BigInteger.valueOf(EU)); + } + + public static boolean addEUToGlobalEnergyMap(String user_uuid, long EU) { + return addEUToGlobalEnergyMap(user_uuid, BigInteger.valueOf(EU)); + } + + public static boolean addEUToGlobalEnergyMap(String user_uuid, int EU) { + return addEUToGlobalEnergyMap(user_uuid, BigInteger.valueOf(EU)); + } + + // ------------------------------------------------------------------------------------ + + public static BigInteger getUserEU(String user_uuid) { + return GlobalEnergy.getOrDefault(GlobalEnergyTeam.getOrDefault(user_uuid, user_uuid), BigInteger.ZERO); + } + + // This overwrites the EU in the network. Only use this if you are absolutely sure you know what you are doing. + public static 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); + } + + public static String getUsernameFromUUID(String uuid) { + return GlobalEnergyName.getOrDefault(GlobalEnergyTeam.getOrDefault(uuid, ""), ""); + } + + public static String getUUIDFromUsername(String username) { + return GlobalEnergyTeam.getOrDefault(GlobalEnergyName.getOrDefault(username, ""), ""); + } + + /** + * + * @param username + * @return + */ + public static String getRawUUIDFromUsername(String username) { + return GlobalEnergyName.getOrDefault(username, ""); + } + + public static void clearGlobalEnergyInformationMaps() { + // Do not use this unless you are 100% certain you know what you are doing. + GlobalEnergy.clear(); + GlobalEnergyName.clear(); + GlobalEnergyTeam.clear(); + } + + public static 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; + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/upgrade/Ampere.java b/src/main/java/gregtech/common/tileentities/casings/upgrade/Ampere.java new file mode 100644 index 0000000000..1644f8fde0 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/upgrade/Ampere.java @@ -0,0 +1,47 @@ +package gregtech.common.tileentities.casings.upgrade; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.enums.GT_Values; +import gregtech.api.multitileentity.interfaces.IMultiBlockController; +import gregtech.api.multitileentity.multiblock.casing.UpgradeCasing; +import gregtech.api.util.GT_Utility; + +public class Ampere extends UpgradeCasing { + + private long amperage; + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.amperage"; + } + + @Override + public void readMultiTileNBT(NBTTagCompound aNBT) { + super.readMultiTileNBT(aNBT); + amperage = aNBT.getInteger(GT_Values.NBT.UPGRADE_AMPERAGE); + } + + @Override + protected void customWork(IMultiBlockController target) { + target.setMaxAmperage(amperage); + } + + @Override + public boolean breakBlock() { + final IMultiBlockController controller = getTarget(false); + if (controller != null) { + controller.setMaxAmperage(2); + } + return super.breakBlock(); + } + + @Override + public void addToolTips(List<String> list, ItemStack stack, boolean f3_h) { + super.addToolTips(list, stack, f3_h); + list.add("Increases allowed amperage to " + GT_Utility.formatNumbers(amperage)); + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/upgrade/Cleanroom.java b/src/main/java/gregtech/common/tileentities/casings/upgrade/Cleanroom.java new file mode 100644 index 0000000000..641327b427 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/upgrade/Cleanroom.java @@ -0,0 +1,26 @@ +package gregtech.common.tileentities.casings.upgrade; + +import gregtech.api.multitileentity.interfaces.IMultiBlockController; +import gregtech.api.multitileentity.multiblock.casing.UpgradeCasing; + +public class Cleanroom extends UpgradeCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.cleanroom"; + } + + @Override + protected void customWork(IMultiBlockController target) { + target.setCleanroom(true); + } + + @Override + public boolean breakBlock() { + final IMultiBlockController controller = getTarget(false); + if (controller != null) { + controller.setCleanroom(false); + } + return super.breakBlock(); + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/upgrade/Heater.java b/src/main/java/gregtech/common/tileentities/casings/upgrade/Heater.java new file mode 100644 index 0000000000..6d8bd81d0f --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/upgrade/Heater.java @@ -0,0 +1,21 @@ +package gregtech.common.tileentities.casings.upgrade; + +import gregtech.api.multitileentity.interfaces.IMultiBlockController; +import gregtech.api.multitileentity.interfaces.UpgradableModularMuTE; +import gregtech.api.multitileentity.multiblock.casing.UpgradeCasing; +import gregtech.api.util.GT_StructureUtilityMuTE.UpgradeCasings; + +public class Heater extends UpgradeCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.modular.heater"; + } + + @Override + protected void customWork(IMultiBlockController target) { + if (target instanceof UpgradableModularMuTE upgradable) { + upgradable.increaseMucCount(UpgradeCasings.Heater, this.tier); + } + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/upgrade/Insulator.java b/src/main/java/gregtech/common/tileentities/casings/upgrade/Insulator.java new file mode 100644 index 0000000000..6cb0b630d6 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/upgrade/Insulator.java @@ -0,0 +1,22 @@ +package gregtech.common.tileentities.casings.upgrade; + +import gregtech.api.multitileentity.interfaces.IMultiBlockController; +import gregtech.api.multitileentity.interfaces.UpgradableModularMuTE; +import gregtech.api.multitileentity.multiblock.casing.UpgradeCasing; +import gregtech.api.util.GT_StructureUtilityMuTE.UpgradeCasings; + +public class Insulator extends UpgradeCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.modular.insulator"; + } + + @Override + protected void customWork(IMultiBlockController target) { + if (target instanceof UpgradableModularMuTE upgradable) { + upgradable.increaseMucCount(UpgradeCasings.Insulator, this.tier); + } + } + +} diff --git a/src/main/java/gregtech/common/tileentities/casings/upgrade/Inventory.java b/src/main/java/gregtech/common/tileentities/casings/upgrade/Inventory.java index e42f0bfb86..5087c7f09e 100644 --- a/src/main/java/gregtech/common/tileentities/casings/upgrade/Inventory.java +++ b/src/main/java/gregtech/common/tileentities/casings/upgrade/Inventory.java @@ -1,7 +1,9 @@ package gregtech.common.tileentities.casings.upgrade; +import java.util.List; import java.util.UUID; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; @@ -10,35 +12,45 @@ import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; import gregtech.api.enums.GT_Values.NBT; +import gregtech.api.enums.InventoryType; import gregtech.api.multitileentity.interfaces.IMultiBlockController; import gregtech.api.multitileentity.multiblock.casing.UpgradeCasing; import gregtech.api.net.GT_Packet_MultiTileEntity; public class Inventory extends UpgradeCasing { - public UUID mInventoryID; - public static final int INPUT = 0; - public static final int OUTPUT = 1; - public static final int BOTH = 2; - private String mInventoryName = "inventory"; - private int mInventorySize; - private final int mType = BOTH; + public UUID inventoryID; - public String getInventoryName() { - return mInventoryName; + private String inventoryName = "inventory"; + private int inventorySize; + private InventoryType type = InventoryType.Both; + + public String getCustomInventoryName() { + return inventoryName; + } + + public String getInventoryID() { + return inventoryID.toString(); } public void setInventoryName(String aInventoryName) { - mInventoryName = aInventoryName; + inventoryName = aInventoryName; + } + + public InventoryType getType() { + return type; } @Override - protected void customWork(IMultiBlockController aTarget) { - int tInvSize = mInventorySize; - if (mType == BOTH) { - tInvSize /= 2; + protected void customWork(IMultiBlockController target) { + int invSize = inventorySize; + if (type == InventoryType.Both) { + invSize /= 2; + } + target.registerItemInventory(invSize, tier, type, true); + if (isServerSide()) { + issueClientUpdate(); } - aTarget.registerInventory(mInventoryName, mInventoryID.toString(), tInvSize, mType); } @Override @@ -49,34 +61,28 @@ public class Inventory extends UpgradeCasing { @Override public void readMultiTileNBT(NBTTagCompound aNBT) { super.readMultiTileNBT(aNBT); - if (aNBT.hasKey(NBT.UPGRADE_INVENTORY_UUID)) { - mInventoryID = UUID.fromString(aNBT.getString(NBT.UPGRADE_INVENTORY_UUID)); + if (aNBT.hasKey(NBT.UPGRADE_INVENTORY_NAME)) { + inventoryName = aNBT.getString(NBT.UPGRADE_INVENTORY_NAME); } else { - mInventoryID = UUID.randomUUID(); + inventoryName = "inventory"; } - mInventorySize = aNBT.getInteger(NBT.UPGRADE_INVENTORY_SIZE); - mInventoryName = aNBT.getString(NBT.UPGRADE_INVENTORY_NAME); - + inventorySize = aNBT.getInteger(NBT.UPGRADE_INVENTORY_SIZE); } @Override public void writeMultiTileNBT(NBTTagCompound aNBT) { super.writeMultiTileNBT(aNBT); - aNBT.setString(NBT.UPGRADE_INVENTORY_UUID, mInventoryID.toString()); - aNBT.setString(NBT.UPGRADE_INVENTORY_NAME, mInventoryName); + aNBT.setString(NBT.UPGRADE_INVENTORY_UUID, inventoryID.toString()); + aNBT.setString(NBT.UPGRADE_INVENTORY_NAME, inventoryName); } @Override - protected void onBaseTEDestroyed() { - super.onBaseTEDestroyed(); - unregisterInventories(); - } - - private void unregisterInventories() { + public boolean breakBlock() { final IMultiBlockController controller = getTarget(false); if (controller != null) { - controller.unregisterInventory(mInventoryName, mInventoryID.toString(), mType); + controller.unregisterItemInventory(inventoryID, type); } + return super.breakBlock(); } @Override @@ -87,12 +93,12 @@ public class Inventory extends UpgradeCasing { @Override public void addUIWidgets(Builder builder, UIBuildContext buildContext) { builder.widget( - new TextFieldWidget().setGetter(() -> mInventoryName) + new TextFieldWidget().setGetter(() -> inventoryName) .setSetter((val) -> { - mInventoryName = val; + inventoryName = val; final IMultiBlockController controller = getTarget(false); if (controller != null) { - controller.changeInventoryName(mInventoryName, mInventoryID.toString(), mType); + controller.changeItemInventoryDisplayName(inventoryID, inventoryName, type); } }) .setSize(100, 25) @@ -100,10 +106,27 @@ public class Inventory extends UpgradeCasing { } @Override + protected boolean canOpenControllerGui() { + return false; + } + + @Override public GT_Packet_MultiTileEntity getClientDataPacket() { final GT_Packet_MultiTileEntity packet = super.getClientDataPacket(); - String name = getInventoryName(); - packet.setInventoryName(name); + String name = getCustomInventoryName(); + packet.setInventoryName(name, inventoryID.toString()); return packet; } + + @Override + public void addToolTips(List<String> list, ItemStack stack, boolean f3_h) { + super.addToolTips(list, stack, f3_h); + list.add("Adds another item inventory"); + list.add("Inventory size: " + inventorySize); + list.add("Inventory Type: " + type); + } + + public void setInventoryId(String inventoryID) { + this.inventoryID = UUID.fromString(inventoryID); + } } diff --git a/src/main/java/gregtech/common/tileentities/casings/upgrade/Laser.java b/src/main/java/gregtech/common/tileentities/casings/upgrade/Laser.java new file mode 100644 index 0000000000..ab66281f54 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/upgrade/Laser.java @@ -0,0 +1,26 @@ +package gregtech.common.tileentities.casings.upgrade; + +import gregtech.api.multitileentity.interfaces.IMultiBlockController; +import gregtech.api.multitileentity.multiblock.casing.UpgradeCasing; + +public class Laser extends UpgradeCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.laser"; + } + + @Override + protected void customWork(IMultiBlockController target) { + target.setLaserSupport(true); + } + + @Override + public boolean breakBlock() { + final IMultiBlockController controller = getTarget(false); + if (controller != null) { + controller.setLaserSupport(false); + } + return super.breakBlock(); + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/upgrade/Tank.java b/src/main/java/gregtech/common/tileentities/casings/upgrade/Tank.java new file mode 100644 index 0000000000..ebc84be38a --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/upgrade/Tank.java @@ -0,0 +1,61 @@ +package gregtech.common.tileentities.casings.upgrade; + +import java.util.List; +import java.util.UUID; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import gregtech.api.enums.GT_Values; +import gregtech.api.multitileentity.interfaces.IMultiBlockController; +import gregtech.api.multitileentity.multiblock.casing.UpgradeCasing; +import gregtech.api.util.GT_Utility; + +public class Tank extends UpgradeCasing { + + private int tankCount; + private int tankCapacity; + public UUID tankID; + public static final int INPUT = 0; + public static final int OUTPUT = 1; + public static final int BOTH = 2; + private String tankName = "tank"; + private int type = BOTH; + + @Override + protected void customWork(IMultiBlockController aTarget) { + + } + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.tank"; + } + + public String getCustomTankName() { + return tankName; + } + + public String getTankID() { + return tankID.toString(); + } + + public int getType() { + return type; + } + + @Override + public void readMultiTileNBT(NBTTagCompound aNBT) { + super.readMultiTileNBT(aNBT); + tankCount = aNBT.getInteger(GT_Values.NBT.UPGRADE_TANK_COUNT); + tankCapacity = aNBT.getInteger(GT_Values.NBT.UPGRADE_TANK_CAPACITY); + } + + @Override + public void addToolTips(List<String> list, ItemStack stack, boolean f3_h) { + super.addToolTips(list, stack, f3_h); + list.add("Adds another tank inventory"); + list.add("Number of tanks: " + tankCount); + list.add("Tank capacity: " + GT_Utility.formatNumbers(tankCapacity) + " L"); + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/upgrade/Wireless.java b/src/main/java/gregtech/common/tileentities/casings/upgrade/Wireless.java new file mode 100644 index 0000000000..0cb6a595bf --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/upgrade/Wireless.java @@ -0,0 +1,26 @@ +package gregtech.common.tileentities.casings.upgrade; + +import gregtech.api.multitileentity.interfaces.IMultiBlockController; +import gregtech.api.multitileentity.multiblock.casing.UpgradeCasing; + +public class Wireless extends UpgradeCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.wireless"; + } + + @Override + protected void customWork(IMultiBlockController target) { + target.setWirelessSupport(true); + } + + @Override + public boolean breakBlock() { + final IMultiBlockController controller = getTarget(false); + if (controller != null) { + controller.setWirelessSupport(false); + } + return super.breakBlock(); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_TranscendentPlasmaMixer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_TranscendentPlasmaMixer.java index e4873f6d9d..58b42eca7f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_TranscendentPlasmaMixer.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_TranscendentPlasmaMixer.java @@ -11,6 +11,9 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_DTPF_ON; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION1_GLOW; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.getUserEU; +import static gregtech.common.misc.WirelessNetworkManager.processInitialSettings; import static gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_PlasmaForge.DIM_BRIDGE_CASING; import static gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_PlasmaForge.DIM_INJECTION_CASING; import static gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_PlasmaForge.DIM_TRANS_CASING; @@ -34,7 +37,6 @@ import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; -import gregtech.api.interfaces.IGlobalWirelessEnergy; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -52,7 +54,7 @@ import gregtech.common.items.GT_IntegratedCircuit_Item; public class GT_MetaTileEntity_TranscendentPlasmaMixer extends GT_MetaTileEntity_EnhancedMultiBlockBase<GT_MetaTileEntity_TranscendentPlasmaMixer> - implements IGlobalWirelessEnergy, ISurvivalConstructable { + implements ISurvivalConstructable { private static final String[][] structure = new String[][] { { " CAC ", " ABA ", " ABA ", " A~A ", " ABA ", " ABA ", " CAC " }, diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java new file mode 100644 index 0000000000..a253f6ac1e --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalProcessor.java @@ -0,0 +1,508 @@ +package gregtech.common.tileentities.machines.multiblock; + +import static com.google.common.primitives.Ints.saturatedCast; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ENERGY_IN; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_IN; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_OUT; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_IN; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_OUT; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.NOTHING; +import static gregtech.api.util.GT_StructureUtilityMuTE.MOTOR_CASINGS; +import static gregtech.api.util.GT_StructureUtilityMuTE.ofMuTECasings; + +import java.util.ArrayList; +import java.util.HashSet; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.Constants; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidTank; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.Materials; +import gregtech.api.fluid.FluidTankGT; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.multitileentity.enums.GT_MultiTileCasing; +import gregtech.api.multitileentity.multiblock.base.ComplexParallelController; +import gregtech.api.multitileentity.multiblock.casing.Glasses; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_StructureUtility; +import gregtech.api.util.GT_StructureUtilityMuTE; +import gregtech.common.tileentities.machines.multiblock.logic.AdvChemicalProcessorProcessingLogic; + +public class AdvChemicalProcessor + extends ComplexParallelController<AdvChemicalProcessor, AdvChemicalProcessorProcessingLogic> { + + private static IStructureDefinition<AdvChemicalProcessor> STRUCTURE_DEFINITION = null; + protected static final String STRUCTURE_PIECE_T1 = "T1"; + protected static final String STRUCTURE_PIECE_T2 = "T2"; + protected static final String STRUCTURE_PIECE_T3 = "T3"; + protected static final String STRUCTURE_PIECE_T4 = "T4"; + protected static final String STRUCTURE_PIECE_T5_6 = "T5_6"; + protected static final String STRUCTURE_PIECE_T7_8 = "T7_8"; + protected static final Vec3Impl STRUCTURE_OFFSET_T1 = new Vec3Impl(3, 1, 0); + protected static final Vec3Impl STRUCTURE_OFFSET_T2 = new Vec3Impl(1, 4, -3); + protected static final Vec3Impl STRUCTURE_OFFSET_T3 = new Vec3Impl(8, 0, 5); + protected static final Vec3Impl STRUCTURE_OFFSET_T4 = new Vec3Impl(-14, 0, 0); + protected static final Vec3Impl STRUCTURE_OFFSET_T5 = new Vec3Impl(14, 0, -6); + protected static final Vec3Impl STRUCTURE_OFFSET_T6 = new Vec3Impl(-16, 0, 0); + protected static final Vec3Impl STRUCTURE_OFFSET_T7 = new Vec3Impl(16, 0, 15); + protected static final Vec3Impl STRUCTURE_OFFSET_T8 = new Vec3Impl(-16, 0, 0); + protected static final int PROCESS_WINDOW_BASE_ID = 100; + protected static final int ITEM_WHITELIST_SLOTS = 8; + protected static final int FLUID_WHITELIST_SLOTS = 8; + protected static final int MAX_PROCESSES = 8; + protected HeatingCoilLevel coilTier; + protected final ArrayList<HashSet<String>> processWhitelists = new ArrayList<>(MAX_PROCESSES); + protected final ArrayList<ItemStackHandler> processWhitelistInventoryHandlers = new ArrayList<>(MAX_PROCESSES); + protected final ArrayList<ArrayList<IFluidTank>> processFluidWhiteLists = new ArrayList<>(MAX_PROCESSES); + protected boolean wasWhitelistOpened = false; + + public AdvChemicalProcessor() { + super(); + for (int i = 0; i < MAX_PROCESSES; i++) { + processWhitelists.add(null); + processWhitelistInventoryHandlers.add(new ItemStackHandler(ITEM_WHITELIST_SLOTS)); + ArrayList<IFluidTank> processFluidTanks = new ArrayList<>(FLUID_WHITELIST_SLOTS); + for (int j = 0; j < FLUID_WHITELIST_SLOTS; j++) { + processFluidTanks.add(new FluidTankGT()); + } + processFluidWhiteLists.add(processFluidTanks); + } + setMaxComplexParallels(1, false); + } + + @Override + public void readMultiTileNBT(NBTTagCompound nbt) { + super.readMultiTileNBT(nbt); + setMaxComplexParallels(nbt.getInteger("processors"), false); + final NBTTagCompound processWhiteLists = nbt.getCompoundTag("whiteLists"); + long capacity = 1000; + if (nbt.hasKey(GT_Values.NBT.TANK_CAPACITY)) { + capacity = saturatedCast(nbt.getLong(GT_Values.NBT.TANK_CAPACITY)); + } + for (int i = 0; i < MAX_PROCESSES; i++) { + + if (processWhiteLists == null) { + continue; + } + + final NBTTagCompound itemList = processWhiteLists.getCompoundTag("items" + i); + if (itemList != null) { + processWhitelistInventoryHandlers.get(i) + .deserializeNBT(itemList); + } + final NBTTagList fluidList = processWhiteLists.getTagList("fluids" + i, Constants.NBT.TAG_COMPOUND); + + if (fluidList == null) { + continue; + } + + for (int j = 0; j < fluidList.tagCount(); j++) { + final NBTTagCompound fluid = fluidList.getCompoundTagAt(j); + + if (fluid == null) { + continue; + } + + short index = fluid.getShort("s"); + FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(fluid); + if (fluidStack != null) { + processFluidWhiteLists.get(i) + .get(index) + .fill(fluidStack, true); + } + } + } + } + + @Override + public void writeMultiTileNBT(NBTTagCompound nbt) { + super.writeMultiTileNBT(nbt); + nbt.setInteger("processors", maxComplexParallels); + final NBTTagCompound processWhiteLists = new NBTTagCompound(); + for (int i = 0; i < MAX_PROCESSES; i++) { + processWhiteLists.setTag( + "items" + i, + processWhitelistInventoryHandlers.get(i) + .serializeNBT()); + final NBTTagList fluidList = new NBTTagList(); + for (int j = 0; j < FLUID_WHITELIST_SLOTS; j++) { + final FluidStack fluidStack = processFluidWhiteLists.get(i) + .get(j) + .getFluid(); + if (fluidStack != null) { + final NBTTagCompound tag = new NBTTagCompound(); + tag.setByte("s", (byte) j); + fluidStack.writeToNBT(tag); + fluidList.appendTag(tag); + } + } + processWhiteLists.setTag("fluids" + i, fluidList); + } + nbt.setTag("whiteLists", processWhiteLists); + } + + @Override + public short getCasingRegistryID() { + return GT_MultiTileCasing.Chemical.getRegistryId(); + } + + @Override + public int getCasingMeta() { + return GT_MultiTileCasing.Chemical.getId(); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Chemical Reactor") + .addInfo("Controller block for the Advanced Chemical Processor") + .addInfo("Does not lose efficiency when overclocked") + .addInfo("Accepts fluids instead of fluid cells") + .addInfo("Can do multiple different recipes at once") + .addInfo("By using the whitelist filter a recipe can push its output") + .addInfo("to a different recipes input to chain them") + .addInfo("Disclaimer: Still WIP - Use at your own risk") + .addInfo(GT_Values.Authorminecraft7771) + .addSeparator() + .beginStructureBlock(5, 3, 3, false) + .addController("Front center") + .addCasingInfoExactly("PTFE Pipe Machine Casing", 8, false) + .addCasingInfoExactly("Heating Coils", 3, true) + .addCasingInfoExactly("EV+ Glass", 3, true) + .addCasingInfoExactly("Motor Casing", 3, true) + .addCasingInfoExactly("Chemical Casing", 27, false) + .toolTipFinisher("Gregtech"); + return tt; + } + + @Override + public Vec3Impl getStartingStructureOffset() { + return STRUCTURE_OFFSET_T1; + } + + @Override + public boolean checkMachine() { + setCoilTier(HeatingCoilLevel.None); + buildState.startBuilding(getStartingStructureOffset()); + if (!checkPiece(STRUCTURE_PIECE_T1, buildState.getCurrentOffset())) return buildState.failBuilding(); + if (maxComplexParallels > 1) { + buildState.addOffset(STRUCTURE_OFFSET_T2); + if (!checkPiece(STRUCTURE_PIECE_T2, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + if (maxComplexParallels > 2) { + buildState.addOffset(STRUCTURE_OFFSET_T3); + if (!checkPiece(STRUCTURE_PIECE_T3, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + if (maxComplexParallels > 3) { + buildState.addOffset(STRUCTURE_OFFSET_T4); + if (!checkPiece(STRUCTURE_PIECE_T4, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + if (maxComplexParallels > 4) { + buildState.addOffset(STRUCTURE_OFFSET_T5); + if (!checkPiece(STRUCTURE_PIECE_T5_6, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + if (maxComplexParallels > 5) { + buildState.addOffset(STRUCTURE_OFFSET_T6); + if (!checkPiece(STRUCTURE_PIECE_T5_6, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + if (maxComplexParallels > 6) { + buildState.addOffset(STRUCTURE_OFFSET_T7); + if (!checkPiece(STRUCTURE_PIECE_T7_8, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + if (maxComplexParallels > 7) { + buildState.addOffset(STRUCTURE_OFFSET_T8); + if (!checkPiece(STRUCTURE_PIECE_T7_8, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + buildState.stopBuilding(); + return super.checkMachine(); + } + + @Override + public void construct(ItemStack trigger, boolean hintsOnly) { + buildState.startBuilding(getStartingStructureOffset()); + buildPiece(STRUCTURE_PIECE_T1, trigger, hintsOnly, buildState.getCurrentOffset()); + if (maxComplexParallels > 1) { + buildState.addOffset(STRUCTURE_OFFSET_T2); + buildPiece(STRUCTURE_PIECE_T2, trigger, hintsOnly, buildState.getCurrentOffset()); + } + if (maxComplexParallels > 2) { + buildState.addOffset(STRUCTURE_OFFSET_T3); + buildPiece(STRUCTURE_PIECE_T3, trigger, hintsOnly, buildState.getCurrentOffset()); + } + if (maxComplexParallels > 3) { + buildState.addOffset(STRUCTURE_OFFSET_T4); + buildPiece(STRUCTURE_PIECE_T4, trigger, hintsOnly, buildState.getCurrentOffset()); + } + if (maxComplexParallels > 4) { + buildState.addOffset(STRUCTURE_OFFSET_T5); + buildPiece(STRUCTURE_PIECE_T5_6, trigger, hintsOnly, buildState.getCurrentOffset()); + } + if (maxComplexParallels > 5) { + buildState.addOffset(STRUCTURE_OFFSET_T6); + buildPiece(STRUCTURE_PIECE_T5_6, trigger, hintsOnly, buildState.getCurrentOffset()); + } + if (maxComplexParallels > 6) { + buildState.addOffset(STRUCTURE_OFFSET_T7); + buildPiece(STRUCTURE_PIECE_T7_8, trigger, hintsOnly, buildState.getCurrentOffset()); + } + if (maxComplexParallels > 7) { + buildState.addOffset(STRUCTURE_OFFSET_T8); + buildPiece(STRUCTURE_PIECE_T7_8, trigger, hintsOnly, buildState.getCurrentOffset()); + } + + buildState.stopBuilding(); + } + + @Override + public IStructureDefinition<AdvChemicalProcessor> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<AdvChemicalProcessor>builder() + .addShape( + STRUCTURE_PIECE_T1, + transpose( + new String[][] { { "CPCPC", "CCCCC", "CPCPC" }, { "CGC~C", "GWWWU", "CGCCC" }, + { "CPCPC", "CTTTC", "CPCPC" } })) + .addShape( + STRUCTURE_PIECE_T2, + new String[][] { { " ", " ", " ", " ", " ", " F F ", " B B " }, + { " ", " ", " ", " ", " ", " F F ", " B B " }, + { " ", " ", " ", " ", " ", " F F ", " BBB " }, + { " C ", " CGC ", " CGC ", " CGC ", " CGC ", " CGC ", " BCCCB " }, + { " BBB ", " C C ", " C C ", " C C ", " C C ", " C C ", "BCPPPCB" }, + { " CBBBC ", " G W G ", " G W G ", " G W G ", " G W G ", " G W G ", "BCPCPCB" }, + { " BBB ", " C C ", " C C ", " C C ", " C C ", " C C ", "BCPPPCB" }, + { " C ", " CGC ", " CGC ", " CGC ", " CGC ", " CGC ", " BCCCB " }, + { " ", " ", " ", " ", " ", " ", " BBB " } }) + .addShape( + STRUCTURE_PIECE_T3, + new String[][] { + { " ", " ", " ", " ", " ", " ", " BBB " }, + { " C ", " CGC ", " CGC ", " CGC ", " CGC ", " CGC ", " BCCCB " }, + { " BBB ", " C C ", " C C ", " C C ", " C C ", " C CFFF", "BCPPPCBBB" }, + { " CBBBC ", " G W G ", " G W G ", " G W G ", " G W G ", " G W G ", "BCPCPCB " }, + { " BBB ", " C C ", " C C ", " C C ", " C C ", " C CFFF", "BCPPPCBBB" }, + { " C ", " CGC ", " CGC ", " CGC ", " CGC ", " CGC ", " BCCCB " }, + { " ", " ", " ", " ", " ", " ", " BBB " } }) + .addShape( + STRUCTURE_PIECE_T4, + new String[][] { + { " ", " ", " ", " ", " ", " ", " BBB " }, + { " C ", " CGC ", " CGC ", " CGC ", " CGC ", " CGC ", " BCCCB " }, + { " BBB ", " C C ", " C C ", " C C ", " C C ", "FFFC C ", "BBBCPPPCB" }, + { " CBBBC ", " G W G ", " G W G ", " G W G ", " G W G ", " G W G ", " BCPCPCB" }, + { " BBB ", " C C ", " C C ", " C C ", " C C ", "FFFC C ", "BBBCPPPCB" }, + { " C ", " CGC ", " CGC ", " CGC ", " CGC ", " CGC ", " BCCCB " }, + { " ", " ", " ", " ", " ", " ", " BBB " } }) + .addShape( + STRUCTURE_PIECE_T5_6, + new String[][] { { " ", " ", " ", " ", " ", " F F ", " " }, + { " ", " ", " ", " ", " ", " F F ", " B B " }, + { " ", " ", " ", " ", " ", " F F ", " B B " }, + { " ", " ", " ", " ", " ", " F F ", " BBB " }, + { " C ", " CGC ", " CGC ", " CGC ", " CGC ", " CGC ", " BCCCB " }, + { " BBB ", " C C ", " C C ", " C C ", " C C ", " C C ", "BCPPPCB" }, + { " CBBBC ", " G W G ", " G W G ", " G W G ", " G W G ", " G W G ", "BCPCPCB" }, + { " BBB ", " C C ", " C C ", " C C ", " C C ", " C C ", "BCPPPCB" }, + { " C ", " CGC ", " CGC ", " CGC ", " CGC ", " CGC ", " BCCCB " }, + { " ", " ", " ", " ", " ", " ", " BBB " } }) + .addShape( + STRUCTURE_PIECE_T7_8, + new String[][] { { " ", " ", " ", " ", " ", " ", " BBB " }, + { " C ", " CGC ", " CGC ", " CGC ", " CGC ", " CGC ", " BCCCB " }, + { " BBB ", " C C ", " C C ", " C C ", " C C ", " C C ", "BCPPPCB" }, + { " CBBBC ", " G W G ", " G W G ", " G W G ", " G W G ", " G W G ", "BCPCPCB" }, + { " BBB ", " C C ", " C C ", " C C ", " C C ", " C C ", "BCPPPCB" }, + { " C ", " CGC ", " CGC ", " CGC ", " CGC ", " CGC ", " BCCCB " }, + { " ", " ", " ", " ", " ", " F F ", " BBB " }, + { " ", " ", " ", " ", " ", " F F ", " B B " }, + { " ", " ", " ", " ", " ", " F F ", " B B " }, + { " ", " ", " ", " ", " ", " F F ", " " } }) + .addElement( + 'C', + ofMuTECasings( + FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT | ENERGY_IN, + GT_MultiTileCasing.Chemical.getCasing())) + .addElement('P', ofBlock(GregTech_API.sBlockCasings8, 1)) + .addElement('T', ofMuTECasings(NOTHING, MOTOR_CASINGS)) + .addElement( + 'W', + GT_StructureUtility.ofCoil(AdvChemicalProcessor::setCoilTier, AdvChemicalProcessor::getCoilTier)) + .addElement('G', Glasses.chainAllGlasses()) + .addElement('B', ofBlock(GregTech_API.sBlockCasings4, 1)) + .addElement('F', GT_StructureUtility.ofFrame(Materials.Steel)) + .addElement( + 'U', + ofMuTECasings( + FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT | ENERGY_IN, + GT_MultiTileCasing.Chemical.getCasing(), + GT_StructureUtilityMuTE.INVENTORY_CASINGS)) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + protected void setMaxComplexParallels(int parallel, boolean stopMachine) { + super.setMaxComplexParallels(parallel, stopMachine); + onStructureChange(); + } + + protected MultiChildWidget createMainPage(IWidgetBuilder<?> builder) { + MultiChildWidget child = new MultiChildWidget(); + for (int i = 0; i < MAX_PROCESSES; i++) { + final int processIndex = i; + child.addChild( + new ButtonWidget().setPlayClickSound(true) + .setOnClick( + (clickData, widget) -> { + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(PROCESS_WINDOW_BASE_ID + processIndex); + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_WHITELIST) + .setSize(18, 18) + .setEnabled((widget -> processIndex < maxComplexParallels)) + .setPos(20 * (i % 4) + 18, 18 + (i / 4) * 20)); + } + child.addChild( + new TextFieldWidget().setGetterInt(() -> maxComplexParallels) + .setSetterInt(parallel -> setMaxComplexParallels(parallel, true)) + .setNumbers(1, MAX_PROCESSES) + .setTextColor(Color.WHITE.normal) + .setTextAlignment(Alignment.Center) + .addTooltip("Tier") + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD) + .setSize(18, 18) + .setPos(130, 85)); + return child; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + for (int i = 0; i < MAX_PROCESSES; i++) { + final int processIndex = i; + buildContext.addSyncedWindow( + PROCESS_WINDOW_BASE_ID + i, + (player) -> createProcessConfigWindow(player, processIndex)); + } + buildContext.addCloseListener(() -> { + // Reset HashSet, we will let it re-generate on next item output + if (wasWhitelistOpened) { + for (int i = 0; i < MAX_PROCESSES; i++) { + processWhitelists.set(i, null); + } + wasWhitelistOpened = false; + } + }); + } + + protected ModularWindow createProcessConfigWindow(final EntityPlayer player, final int processIndex) { + wasWhitelistOpened = true; + ModularWindow.Builder builder = ModularWindow.builder(86, 100); + builder.widget( + new TextWidget("Process " + processIndex).setTextAlignment(Alignment.Center) + .setPos(13, 7)); + builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.widget( + SlotGroup.ofItemHandler(processWhitelistInventoryHandlers.get(processIndex), 4) + .startFromSlot(0) + .endAtSlot(ITEM_WHITELIST_SLOTS - 1) + .phantom(true) + .background(getGUITextureSet().getItemSlot()) + .build() + .setPos(7, 19)); + builder.widget( + SlotGroup.ofFluidTanks(processFluidWhiteLists.get(processIndex), 4) + .startFromSlot(0) + .endAtSlot(FLUID_WHITELIST_SLOTS - 1) + .phantom(true) + .build() + .setPos(7, 55)); + return builder.build(); + } + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.advchemicalprocessor"; + } + + @Override + public String getLocalName() { + return "Advanced Chemical Processor"; + } + + public void setCoilTier(HeatingCoilLevel coilTier) { + this.coilTier = coilTier; + } + + public HeatingCoilLevel getCoilTier() { + return coilTier; + } + + @Override + protected boolean hasPerfectOverclock() { + return true; + } + + protected void generateWhitelist(int processIndex) { + HashSet<String> whitelist = new HashSet<>(); + for (ItemStack itemStack : processWhitelistInventoryHandlers.get(processIndex) + .getStacks()) { + if (itemStack != null) { + whitelist.add(getWhitelistString(itemStack)); + } + } + for (IFluidTank tank : processFluidWhiteLists.get(processIndex)) { + if (tank.getFluid() != null) { + whitelist.add(getWhitelistString(tank.getFluid())); + } + } + processWhitelists.set(processIndex, whitelist); + } + + protected String getWhitelistString(ItemStack itemStack) { + if (itemStack != null) { + return itemStack.getUnlocalizedName(); + } + return null; + } + + protected String getWhitelistString(FluidStack fluidStack) { + if (fluidStack != null) { + return fluidStack.getUnlocalizedName(); + } + return null; + } + + @Override + @Nonnull + protected AdvChemicalProcessorProcessingLogic createProcessingLogic() { + return new AdvChemicalProcessorProcessingLogic(); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalReactor.java deleted file mode 100644 index 38ed9b6603..0000000000 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalReactor.java +++ /dev/null @@ -1,434 +0,0 @@ -package gregtech.common.tileentities.machines.multiblock; - -import static com.google.common.primitives.Ints.saturatedCast; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ENERGY_IN; -import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_IN; -import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_OUT; -import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_IN; -import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_OUT; -import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.NOTHING; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidTank; - -import org.apache.commons.lang3.ArrayUtils; - -import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureDefinition; -import com.gtnewhorizon.structurelib.util.Vec3Impl; -import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; -import com.gtnewhorizons.modularui.api.math.Alignment; -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; -import com.gtnewhorizons.modularui.common.widget.ButtonWidget; -import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; -import com.gtnewhorizons.modularui.common.widget.SlotGroup; -import com.gtnewhorizons.modularui.common.widget.TextWidget; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.fluid.FluidTankGT; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.logic.ComplexParallelProcessingLogic; -import gregtech.api.multitileentity.enums.GT_MultiTileCasing; -import gregtech.api.multitileentity.multiblock.base.ComplexParallelController; -import gregtech.api.multitileentity.multiblock.casing.Glasses; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_StructureUtility; -import gregtech.common.tileentities.casings.upgrade.Inventory; - -public class AdvChemicalReactor extends ComplexParallelController<AdvChemicalReactor> { - - private static IStructureDefinition<AdvChemicalReactor> STRUCTURE_DEFINITION = null; - protected static final String STRUCTURE_PIECE_T1 = "T1"; - protected static final Vec3Impl STRUCTURE_OFFSET = new Vec3Impl(3, 1, 0); - protected static final int PROCESS_WINDOW_BASE_ID = 100; - protected static final int ITEM_WHITELIST_SLOTS = 8; - protected static final int FLUID_WHITELIST_SLOTS = 8; - protected static final int MAX_PROCESSES = 4; - protected int numberOfProcessors = MAX_PROCESSES; // TODO: Set this value depending on structure - protected HeatingCoilLevel coilTier; - protected final ArrayList<HashSet<String>> processWhitelists = new ArrayList<>(MAX_PROCESSES); - protected final ArrayList<ItemStackHandler> processWhitelistInventoryHandlers = new ArrayList<>(MAX_PROCESSES); - protected final ArrayList<ArrayList<IFluidTank>> processFluidWhiteLists = new ArrayList<>(MAX_PROCESSES); - protected boolean wasWhitelistOpened = false; - - public AdvChemicalReactor() { - super(); - for (int i = 0; i < MAX_PROCESSES; i++) { - processWhitelists.add(null); - processWhitelistInventoryHandlers.add(new ItemStackHandler(ITEM_WHITELIST_SLOTS)); - ArrayList<IFluidTank> processFluidTanks = new ArrayList<>(FLUID_WHITELIST_SLOTS); - for (int j = 0; j < FLUID_WHITELIST_SLOTS; j++) { - processFluidTanks.add(new FluidTankGT()); - } - processFluidWhiteLists.add(processFluidTanks); - } - processingLogic = new ComplexParallelProcessingLogic(getRecipeMap(), MAX_PROCESSES); - } - - @Override - public RecipeMap<?> getRecipeMap() { - return RecipeMaps.chemicalReactorRecipes; - } - - @Override - public void readMultiTileNBT(NBTTagCompound nbt) { - super.readMultiTileNBT(nbt); - final NBTTagCompound processWhiteLists = nbt.getCompoundTag("whiteLists"); - long capacity = 1000; - if (nbt.hasKey(GT_Values.NBT.TANK_CAPACITY)) { - capacity = saturatedCast(nbt.getLong(GT_Values.NBT.TANK_CAPACITY)); - } - for (int i = 0; i < MAX_PROCESSES; i++) { - registerInventory("processInventory" + i, "processInventory" + i, 8, Inventory.INPUT); - registerFluidInventory( - "processInventory" + i, - "processInventory" + i, - 8, - capacity, - maxParallel * 2L, - Inventory.INPUT); - if (processWhiteLists != null) { - final NBTTagCompound itemList = processWhiteLists.getCompoundTag("items" + i); - if (itemList != null) { - processWhitelistInventoryHandlers.get(i) - .deserializeNBT(itemList); - } - final NBTTagList fluidList = processWhiteLists.getTagList("fluids" + i, Constants.NBT.TAG_COMPOUND); - if (fluidList != null) { - for (int j = 0; j < fluidList.tagCount(); j++) { - final NBTTagCompound fluid = fluidList.getCompoundTagAt(j); - if (fluid != null) { - short index = fluid.getShort("s"); - FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(fluid); - if (fluidStack != null) { - processFluidWhiteLists.get(i) - .get(index) - .fill(fluidStack, true); - } - } - } - } - } - } - } - - @Override - public void writeMultiTileNBT(NBTTagCompound nbt) { - super.writeMultiTileNBT(nbt); - final NBTTagCompound processWhiteLists = new NBTTagCompound(); - for (int i = 0; i < MAX_PROCESSES; i++) { - processWhiteLists.setTag( - "items" + i, - processWhitelistInventoryHandlers.get(i) - .serializeNBT()); - final NBTTagList fluidList = new NBTTagList(); - for (int j = 0; j < FLUID_WHITELIST_SLOTS; j++) { - final FluidStack fluidStack = processFluidWhiteLists.get(i) - .get(j) - .getFluid(); - if (fluidStack != null) { - final NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("s", (byte) j); - fluidStack.writeToNBT(tag); - fluidList.appendTag(tag); - } - } - processWhiteLists.setTag("fluids" + i, fluidList); - } - nbt.setTag("whiteLists", processWhiteLists); - } - - @Override - public short getCasingRegistryID() { - return 0; - } - - @Override - public int getCasingMeta() { - return GT_MultiTileCasing.Chemical.getId(); - } - - @Override - public GT_Multiblock_Tooltip_Builder createTooltip() { - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Chemical Reactor") - .addInfo("Controller block for the Advanced Chemical Reactor") - .addInfo("Does not lose efficiency when overclocked") - .addInfo("Accepts fluids instead of fluid cells") - .addInfo("Can do multiple different recipes at once") - .addInfo("By using the whitelist filter a recipe can push its output") - .addInfo("to a different recipes input to chain them") - .addInfo(GT_Values.Authorminecraft7771) - .addSeparator() - .beginStructureBlock(5, 3, 3, false) - .addController("Front center") - .addCasingInfoExactly("PTFE Pipe Machine Casing", 8, false) - .addCasingInfoExactly("Heating Coils", 3, true) - .addCasingInfoExactly("EV+ Glass", 3, true) - .addCasingInfoExactly("Motor Casing", 3, true) - .addCasingInfoExactly("Chemical Casing", 27, false) - .toolTipFinisher("Gregtech"); - return tt; - } - - @Override - public Vec3Impl getStartingStructureOffset() { - return STRUCTURE_OFFSET; - } - - @Override - public boolean checkMachine() { - setCoilTier(HeatingCoilLevel.None); - setMaxComplexParallels(MAX_PROCESSES); - buildState.startBuilding(getStartingStructureOffset()); - boolean result = checkPiece(STRUCTURE_PIECE_T1, buildState.stopBuilding()); - return result && super.checkMachine(); - } - - @Override - public void construct(ItemStack trigger, boolean hintsOnly) { - buildState.startBuilding(getStartingStructureOffset()); - buildPiece(STRUCTURE_PIECE_T1, trigger, hintsOnly, buildState.stopBuilding()); - } - - @Override - public IStructureDefinition<AdvChemicalReactor> getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.<AdvChemicalReactor>builder() - .addShape( - STRUCTURE_PIECE_T1, - transpose( - new String[][] { { "CPCPC", "CCCCC", "CPCPC" }, { "CGC~C", "GWWWC", "CGCCC" }, - { "CPCPC", "CTTTC", "CPCPC" } })) - .addElement( - 'C', - addMultiTileCasing( - "gt.multitileentity.casings", - getCasingMeta(), - FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT | ENERGY_IN)) - .addElement('P', ofBlock(GregTech_API.sBlockCasings8, 1)) - .addElement('T', addMotorCasings(NOTHING)) - .addElement( - 'W', - GT_StructureUtility.ofCoil(AdvChemicalReactor::setCoilTier, AdvChemicalReactor::getCoilTier)) - .addElement('G', Glasses.chainAllGlasses()) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - protected FluidStack[] getInputFluids(int index) { - if (index < 0 || index >= MAX_PROCESSES) { - return null; - } - if (separateInputs) { - return ArrayUtils.addAll( - getFluidInputsForTankArray("processInventory" + index), - FluidTankGT.getFluidsFromTanks(inputTanks)); - } else { - return super.getInputFluids(index); - } - } - - @Override - protected ItemStack[] getInputItems(int index) { - if (index < 0 || index >= MAX_PROCESSES) { - return null; - } - if (separateInputs) { - return ArrayUtils.addAll( - getItemInputsForInventory("processInventory" + index), - inputInventory.getStacks() - .toArray(new ItemStack[0])); - } else { - return super.getInputItems(index); - } - } - - @Override - protected void outputItems(int index) { - ComplexParallelProcessingLogic processingLogic = getComplexProcessingLogic(); - if (processingLogic != null && index >= 0 && index < maxComplexParallels) { - for (int i = 0; i < MAX_PROCESSES; i++) { - // Regenerate whitelist, if it has been reset - if (processWhitelists.get(i) == null) { - generateWhitelist(i); - } - int outputIndex = i; - // Output items that are on the whitelist of this process - outputItems( - multiBlockInputInventory.get("processInventory" + i), - Arrays.stream(processingLogic.getOutputItems(index)) - .filter( - itemStack -> processWhitelists.get(outputIndex) - .contains(getWhitelistString(itemStack))) - .toArray(ItemStack[]::new)); - } - // Output remaining items - if (processingLogic.getOutputItems(index) != null && processingLogic.getOutputItems(index).length > 0) { - outputItems(processingLogic.getOutputItems(index)); - } - } - } - - @Override - protected void outputFluids(int index) { - ComplexParallelProcessingLogic processingLogic = getComplexProcessingLogic(); - if (processingLogic != null && index >= 0 && index < maxComplexParallels) { - for (int i = 0; i < MAX_PROCESSES; i++) { - // Regenerate whitelist, if it has been reset - if (processWhitelists.get(i) == null) { - generateWhitelist(i); - } - int outputIndex = i; - // Output fluids that are on the whitelist of this process - outputFluids( - multiBlockInputTank.get("processInventory" + i), - Arrays.stream(processingLogic.getOutputFluids(index)) - .filter( - fluidStack -> processWhitelists.get(outputIndex) - .contains(getWhitelistString(fluidStack))) - .toArray(FluidStack[]::new)); - } - // Output remaining fluids - if (processingLogic.getOutputFluids(index) != null && processingLogic.getOutputFluids(index).length > 0) { - outputFluids(processingLogic.getOutputFluids(index)); - } - } - } - - @Override - protected MultiChildWidget createMainPage(IWidgetBuilder<?> builder) { - MultiChildWidget child = super.createMainPage(builder); - for (int i = 0; i < MAX_PROCESSES; i++) { - final int processIndex = i; - child.addChild( - new ButtonWidget().setPlayClickSound(true) - .setOnClick( - (clickData, widget) -> { - if (!widget.isClient()) widget.getContext() - .openSyncedWindow(PROCESS_WINDOW_BASE_ID + processIndex); - }) - .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_WHITELIST) - .setSize(18, 18) - .setPos(20 * i + 18, 18)); - } - return child; - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - super.addUIWidgets(builder, buildContext); - for (int i = 0; i < MAX_PROCESSES; i++) { - final int processIndex = i; - buildContext.addSyncedWindow( - PROCESS_WINDOW_BASE_ID + i, - (player) -> createProcessConfigWindow(player, processIndex)); - } - buildContext.addCloseListener(() -> { - // Reset HashSet, we will let it re-generate on next item output - if (wasWhitelistOpened) { - for (int i = 0; i < MAX_PROCESSES; i++) { - processWhitelists.set(i, null); - } - wasWhitelistOpened = false; - } - }); - } - - protected ModularWindow createProcessConfigWindow(final EntityPlayer player, final int processIndex) { - wasWhitelistOpened = true; - ModularWindow.Builder builder = ModularWindow.builder(86, 100); - builder.widget( - new TextWidget("Process " + processIndex).setTextAlignment(Alignment.Center) - .setPos(13, 7)); - builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); - builder.widget( - SlotGroup.ofItemHandler(processWhitelistInventoryHandlers.get(processIndex), 4) - .startFromSlot(0) - .endAtSlot(ITEM_WHITELIST_SLOTS - 1) - .phantom(true) - .background(getGUITextureSet().getItemSlot()) - .build() - .setPos(7, 19)); - builder.widget( - SlotGroup.ofFluidTanks(processFluidWhiteLists.get(processIndex), 4) - .startFromSlot(0) - .endAtSlot(FLUID_WHITELIST_SLOTS - 1) - .phantom(true) - .build() - .setPos(7, 55)); - return builder.build(); - } - - @Override - public String getTileEntityName() { - return "gt.multitileentity.multiblock.advchemicalreactor"; - } - - @Override - public String getLocalName() { - return "Advanced Chemical Reactor"; - } - - public void setCoilTier(HeatingCoilLevel coilTier) { - this.coilTier = coilTier; - } - - public HeatingCoilLevel getCoilTier() { - return coilTier; - } - - @Override - protected boolean hasPerfectOverclock() { - return true; - } - - protected void generateWhitelist(int processIndex) { - HashSet<String> whitelist = new HashSet<>(); - for (ItemStack itemStack : processWhitelistInventoryHandlers.get(processIndex) - .getStacks()) { - if (itemStack != null) { - whitelist.add(getWhitelistString(itemStack)); - } - } - for (IFluidTank tank : processFluidWhiteLists.get(processIndex)) { - if (tank.getFluid() != null) { - whitelist.add(getWhitelistString(tank.getFluid())); - } - } - processWhitelists.set(processIndex, whitelist); - } - - protected String getWhitelistString(ItemStack itemStack) { - if (itemStack != null) { - return itemStack.getUnlocalizedName(); - } - return null; - } - - protected String getWhitelistString(FluidStack fluidStack) { - if (fluidStack != null) { - return fluidStack.getUnlocalizedName(); - } - return null; - } -} diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/CokeOven.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/CokeOven.java index 13f60da821..06fc7b42b1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/CokeOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/CokeOven.java @@ -2,9 +2,12 @@ package gregtech.common.tileentities.machines.multiblock; import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_IN; import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_OUT; +import static gregtech.api.util.GT_StructureUtilityMuTE.ofMuTECasings; import java.util.List; +import javax.annotation.Nonnull; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; @@ -16,34 +19,29 @@ import com.gtnewhorizon.structurelib.structure.StructureDefinition; import com.gtnewhorizon.structurelib.util.Vec3Impl; import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils; import com.gtnewhorizons.modularui.common.widget.DrawableWidget; -import com.gtnewhorizons.modularui.common.widget.SlotWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; import gregtech.GT_Mod; import gregtech.api.enums.GT_Values; -import gregtech.api.logic.PollutionLogic; -import gregtech.api.logic.ProcessingLogic; -import gregtech.api.logic.interfaces.PollutionLogicHost; -import gregtech.api.logic.interfaces.ProcessingLogicHost; import gregtech.api.multitileentity.enums.GT_MultiTileCasing; import gregtech.api.multitileentity.multiblock.base.Controller; +import gregtech.api.task.tasks.PollutionTask; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.common.tileentities.machines.multiblock.logic.CokeOvenProcessingLogic; -public class CokeOven extends Controller<CokeOven> implements PollutionLogicHost, ProcessingLogicHost { +public class CokeOven extends Controller<CokeOven, CokeOvenProcessingLogic> { private static IStructureDefinition<CokeOven> STRUCTURE_DEFINITION = null; private static final Vec3Impl OFFSET = new Vec3Impl(1, 1, 0); private static final String MAIN = "Main"; - private static final PollutionLogic POLLUTION_LOGIC = new PollutionLogic().setPollutionAmount(10); - private final ProcessingLogic PROCESSING_LOGIC = new CokeOvenProcessingLogic(); + private static final int POLLUTION_AMOUNT = 10; public CokeOven() { super(); setElectric(false); + new PollutionTask<>(this).setPollutionPerSecond(POLLUTION_AMOUNT); } @Override @@ -81,7 +79,7 @@ public class CokeOven extends Controller<CokeOven> implements PollutionLogicHost .addInfo("Used for charcoal") .beginStructureBlock(3, 3, 3, true) .addCasingInfoExactly("Coke Oven Bricks", 25, false) - .addPollutionAmount(POLLUTION_LOGIC.getPollutionAmount()) + .addPollutionAmount(POLLUTION_AMOUNT) .toolTipFinisher(GT_Values.AuthorBlueWeabo); return tt; } @@ -98,29 +96,18 @@ public class CokeOven extends Controller<CokeOven> implements PollutionLogicHost .addShape( MAIN, new String[][] { { "AAA", "A~A", "AAA" }, { "AAA", "A-A", "AAA" }, { "AAA", "AAA", "AAA" } }) - .addElement('A', addMultiTileCasing("gt.multitileentity.casings", getCasingMeta(), ITEM_IN | ITEM_OUT)) + .addElement('A', ofMuTECasings(ITEM_IN | ITEM_OUT, GT_MultiTileCasing.CokeOven.getCasing())) .build(); } return STRUCTURE_DEFINITION; } @Override - protected boolean hasFluidInput() { + public boolean hasFluidInput() { return false; } @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget( - new SlotWidget(inputInventory, 0).setPos(18, 18) - .setSize(18, 18)); - builder.widget( - new SlotWidget(outputInventory, 0).setPos(36, 36) - .setSize(18, 18)); - builder.widget(createButtons(builder)); - } - - @Override protected void addTitleTextStyle(ModularWindow.Builder builder, String title) { final int TAB_PADDING = 3; final int TITLE_PADDING = 2; @@ -159,12 +146,8 @@ public class CokeOven extends Controller<CokeOven> implements PollutionLogicHost } @Override - public PollutionLogic getPollutionLogic() { - return POLLUTION_LOGIC; - } - - @Override - public ProcessingLogic getProcessingLogic() { - return PROCESSING_LOGIC; + @Nonnull + protected CokeOvenProcessingLogic createProcessingLogic() { + return new CokeOvenProcessingLogic(); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/DistillationTower.java new file mode 100644 index 0000000000..326bfcc9ee --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/DistillationTower.java @@ -0,0 +1,174 @@ +package gregtech.common.tileentities.machines.multiblock; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.*; +import static gregtech.api.util.GT_StructureUtilityMuTE.MOTOR_CASINGS; +import static gregtech.api.util.GT_StructureUtilityMuTE.ofMuTECasings; + +import javax.annotation.Nonnull; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.Materials; +import gregtech.api.multitileentity.enums.GT_MultiTileCasing; +import gregtech.api.multitileentity.multiblock.base.StackableController; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_StructureUtility; +import gregtech.common.tileentities.machines.multiblock.logic.DistillationTowerProcessingLogic; + +public class DistillationTower extends StackableController<DistillationTower, DistillationTowerProcessingLogic> { + + private static IStructureDefinition<DistillationTower> STRUCTURE_DEFINITION_MEGA = null; + private static final Vec3Impl STRUCTURE_OFFSET_MEGA = new Vec3Impl(8, 3, 0); + private static final Vec3Impl STRUCTURE_OFFSET_MEGA_START = new Vec3Impl(0, 3, 0); + private static final Vec3Impl STRUCTURE_OFFSET_MEGA_STOP = new Vec3Impl(0, 5, 0); + private static final Vec3Impl STRUCTURE_OFFSET_MEGA_STACK = new Vec3Impl(0, 3, 0); + private static final String STACKABLE_MIDDLE_1 = "STACKABLE_MIDDLE_1"; + private static final String STACKABLE_MIDDLE_2 = "STACKABLE_MIDDLE_2"; + private boolean isMega = true; + + @Override + public short getCasingRegistryID() { + return 0; + } + + @Override + public int getCasingMeta() { + return GT_MultiTileCasing.Distillation.getId(); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Distillation Tower") + .addInfo("Controller block for the Distillation Tower") + .addInfo("Can be specialised to be a mega structure") + .addInfo(GT_Values.Authorminecraft7771) + .addSeparator() + .beginStructureBlock(5, 3, 3, false) + .addController("Front center") + .toolTipFinisher("Gregtech"); + return tt; + } + + @Override + public Vec3Impl getStartingStructureOffset() { + return STRUCTURE_OFFSET_MEGA; + } + + @Override + public IStructureDefinition<DistillationTower> getStructureDefinition() { + if (STRUCTURE_DEFINITION_MEGA == null) { + STRUCTURE_DEFINITION_MEGA = StructureDefinition.<DistillationTower>builder() + .addShape( + STACKABLE_START, + transpose( + // spotless:off + new String[][]{ + {" "," "," "," "," "," ECCCCCE "," CCCCCCC "," C C "," EC CE "," CC CC "," CC CC ABA "," CC CC B B "," CC CC ABA "," CC CC "," EC CE "," C C "," CCCCCCC "," ECCCCCE "," "}, + {" "," EEE "," E "," E "," E "," E E E "," CCCCCCC "," C C "," EC CE "," C C "," C C ABA "," C C B B "," C C ABA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + {" CCCCC "," CCCCC "," CCCCC "," "," "," E E "," CCCCCCC "," C C "," EC CE "," C C "," C C ABA "," C C B B "," C C ABA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + {" CXC~C "," BDDDB "," CBCBC "," B B "," B B "," E B B E "," CCCCCCC "," C C "," EC CE "," C C "," C C AAA "," C C A A "," C C AAA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + {" CCCCC "," CCCCC "," CCCCC "," "," CCCCCCCCCCC "," CAAAAAAAAAC ","CCCACCCCCCCACCC ","CAACAAAAAAACAAC ","CACAADDDDDAACAC ","CACADDDDDDDACACCCCC","CACADDAAADDACACCCCC","CACADDAAADDACACCCCC","CACADDAAADDACACCCCC","CACADDDDDDDACACCCCC","CACAADDDDDAACAC ","CAACAAAAAAACAAC ","CCCACCCCCCCACCC "," CAAAAAAAAAC "," CCCCCCCCCCC "} + })) + .addShape( + STACKABLE_STOP, + transpose( + new String[][]{ + {" "," "," "," "," "," "," "," "," "," "," CCC "," CCC "," CCC "," "," "," "," "," "," "}, + {" "," "," "," "," "," E E "," E E "," E E "," EEEEAAAAAEEEE "," AAAAAAA "," AA AA "," AA AA "," AA AA "," AAAAAAA "," EEEEAAAAAEEEE "," E E "," E E "," E E "," "}, + {" "," "," "," "," "," ECCCCCE "," CCCCCCCCC "," CCCCCCCCCCC "," ECCC CCCE "," CCC CCC "," CCC CCC "," CCC CCC "," CCC CCC "," CCC CCC "," ECCC CCCE "," CCCCCCCCCCC "," CCCCCCCCC "," ECCCCCE "," "}, + {" "," "," "," "," "," E E "," CCCCCCC "," C C "," EC CE "," C C "," C C "," C C "," C C "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + {" "," "," "," "," "," E E "," CCCCCCC "," C C "," EC CE "," C C "," C CAAAAA "," C CABBBA "," C CAAAAA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + {" "," "," "," "," "," ECCCCCE "," CCCCCCC "," C C "," EC CE "," CC CC "," CC CABBBA "," CC C B "," CC CABBBA "," CC CC "," EC CE "," C C "," CCCCCCC "," ECCCCCE "," "}, + {" "," "," "," "," "," E E "," CCCCCCC "," C C "," EC CE "," C C "," C CAAABA "," C CAAA B "," C CAAABA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + {" "," "," "," "," "," E E "," CCCCCCC "," C C "," EC CE "," C C "," C C ABA "," C C A B "," C C ABA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + })) + .addShape( + STACKABLE_MIDDLE_1, + transpose( + new String[][]{ + {" "," "," "," "," "," E E "," CCCCCCC "," C C "," EC CE "," C C "," C C ABA "," C C B B "," C C ABA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + {" "," "," "," "," "," E E "," CCCCCCC "," C C "," EC CE "," C C "," C C ABA "," C C B B "," C C ABA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + {" "," "," "," "," "," E E "," CCCCCCC "," C C "," EC CE "," C C "," C C ABA "," C C B B "," C C ABA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + })) + .addShape( + STACKABLE_MIDDLE_2, + transpose( + new String[][]{ + {" "," "," "," "," "," ECCCCCE "," CCCCCCC "," C C "," EC CE "," CC CC "," CC CC ABA "," CC CC B B "," CC CC ABA "," CC CC "," EC CE "," C C "," CCCCCCC "," ECCCCCE "," "}, + {" "," "," "," "," "," E E "," CCCCCCC "," C C "," EC CE "," C C "," C C ABA "," C C B B "," C C ABA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + {" "," "," "," "," "," E E "," CCCCCCC "," C C "," EC CE "," C C "," C C ABA "," C C B B "," C C ABA "," C C "," EC CE "," C C "," CCCCCCC "," E E "," "}, + })) + // spotless:on + .addElement( + 'C', + ofMuTECasings( + FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT | ENERGY_IN, + GT_MultiTileCasing.Distillation.getCasing())) + .addElement('E', GT_StructureUtility.ofFrame(Materials.StainlessSteel)) + .addElement('A', ofBlock(GregTech_API.sBlockCasings2, 0)) + .addElement('B', ofBlock(GregTech_API.sBlockCasings2, 13)) + .addElement('X', ofMuTECasings(NOTHING, MOTOR_CASINGS)) + .addElement('D', GT_StructureUtility.ofCoil((tile, meta) -> {}, (tile) -> HeatingCoilLevel.None)) + .build(); + } + return STRUCTURE_DEFINITION_MEGA; + } + + @Override + public int getFluidOutputCount() { + return 12; + } + + @Override + public int getMinStacks() { + return 0; + } + + @Override + public int getMaxStacks() { + return 9; + } + + @Override + public Vec3Impl getStartingStackOffset() { + return STRUCTURE_OFFSET_MEGA_START; + } + + @Override + public Vec3Impl getPerStackOffset() { + return STRUCTURE_OFFSET_MEGA_STACK; + } + + @Override + public Vec3Impl getAfterLastStackOffset() { + return STRUCTURE_OFFSET_MEGA_STOP; + } + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.distillationtower"; + } + + @Override + public String getLocalName() { + return "Distillation Tower"; + } + + @Override + protected String getStackableMiddle(int stackIndex) { + return stackIndex % 2 == 0 ? STACKABLE_MIDDLE_1 : STACKABLE_MIDDLE_2; + } + + @Override + @Nonnull + protected DistillationTowerProcessingLogic createProcessingLogic() { + return new DistillationTowerProcessingLogic(); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/LaserEngraver.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/LaserEngraver.java new file mode 100644 index 0000000000..93bcc09a0b --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/LaserEngraver.java @@ -0,0 +1,305 @@ +package gregtech.common.tileentities.machines.multiblock; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockUnlocalizedName; +import static gregtech.api.enums.Mods.*; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.*; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ENERGY_IN; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_OUT; +import static gregtech.api.util.GT_StructureUtilityMuTE.*; + +import java.util.UUID; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.multitileentity.enums.GT_MultiTileCasing; +import gregtech.api.multitileentity.multiblock.base.ComplexParallelController; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_StructureUtility; +import gregtech.common.tileentities.machines.multiblock.logic.LaserEngraverProcessingLogic; + +public class LaserEngraver extends ComplexParallelController<LaserEngraver, LaserEngraverProcessingLogic> { + + private static IStructureDefinition<LaserEngraver> STRUCTURE_DEFINITION = null; + protected static final String STRUCTURE_MAIN = "Main"; + protected static final String STRUCTURE_PIECE_T1 = "T1"; + protected static final String STRUCTURE_PIECE_T2 = "T2"; + protected static final String STRUCTURE_PIECE_T3 = "T3"; + protected static final String STRUCTURE_PIECE_T4 = "T4"; + protected static final String STRUCTURE_PIECE_T5 = "T5"; + protected static final String STRUCTURE_PIECE_T6 = "T6"; + protected static final int PROCESS_WINDOW_BASE_ID = 100; + protected static final Vec3Impl STRUCTURE_OFFSET_T1 = new Vec3Impl(3, 1, 0); + protected static final Vec3Impl STRUCTURE_OFFSET_T2 = new Vec3Impl(1, 3, 0); + protected static final Vec3Impl STRUCTURE_OFFSET_T3 = new Vec3Impl(-6, 0, -5); + protected static final Vec3Impl STRUCTURE_OFFSET_T4 = new Vec3Impl(18, 0, 0); + protected static final Vec3Impl STRUCTURE_OFFSET_T5 = new Vec3Impl(-18, 0, 9); + protected static final Vec3Impl STRUCTURE_OFFSET_T6 = new Vec3Impl(18, 0, 0); + protected static final int MAX_PROCESSES = 6; + protected RecipeMap<?> recipeMap; + private UUID LaserEngraver; + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.laserengraver"; + } + + @Override + public Vec3Impl getStartingStructureOffset() { + return STRUCTURE_OFFSET_T1; + } + + @Override + public boolean checkMachine() { + buildState.startBuilding(getStartingStructureOffset()); + if (!checkPiece(STRUCTURE_PIECE_T1, buildState.getCurrentOffset())) return buildState.failBuilding(); + if (maxComplexParallels > 1) { + buildState.addOffset(STRUCTURE_OFFSET_T2); + if (!checkPiece(STRUCTURE_PIECE_T2, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + if (maxComplexParallels > 2) { + buildState.addOffset(STRUCTURE_OFFSET_T3); + if (!checkPiece(STRUCTURE_PIECE_T3, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + if (maxComplexParallels > 3) { + buildState.addOffset(STRUCTURE_OFFSET_T4); + if (!checkPiece(STRUCTURE_PIECE_T4, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + if (maxComplexParallels > 4) { + buildState.addOffset(STRUCTURE_OFFSET_T5); + if (!checkPiece(STRUCTURE_PIECE_T5, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + if (maxComplexParallels > 5) { + buildState.addOffset(STRUCTURE_OFFSET_T6); + if (!checkPiece(STRUCTURE_PIECE_T6, buildState.getCurrentOffset())) return buildState.failBuilding(); + } + buildState.stopBuilding(); + return super.checkMachine(); + } + + @Override + public void construct(ItemStack trigger, boolean hintsOnly) { + buildState.startBuilding(getStartingStructureOffset()); + buildPiece(STRUCTURE_PIECE_T1, trigger, hintsOnly, buildState.getCurrentOffset()); + if (maxComplexParallels > 1) { + buildState.addOffset(STRUCTURE_OFFSET_T2); + buildPiece(STRUCTURE_PIECE_T2, trigger, hintsOnly, buildState.getCurrentOffset()); + } + if (maxComplexParallels > 2) { + buildState.addOffset(STRUCTURE_OFFSET_T3); + buildPiece(STRUCTURE_PIECE_T3, trigger, hintsOnly, buildState.getCurrentOffset()); + } + if (maxComplexParallels > 3) { + buildState.addOffset(STRUCTURE_OFFSET_T4); + buildPiece(STRUCTURE_PIECE_T4, trigger, hintsOnly, buildState.getCurrentOffset()); + } + if (maxComplexParallels > 4) { + buildState.addOffset(STRUCTURE_OFFSET_T5); + buildPiece(STRUCTURE_PIECE_T5, trigger, hintsOnly, buildState.getCurrentOffset()); + } + if (maxComplexParallels > 5) { + buildState.addOffset(STRUCTURE_OFFSET_T6); + buildPiece(STRUCTURE_PIECE_T6, trigger, hintsOnly, buildState.getCurrentOffset()); + } + buildState.stopBuilding(); + } + + @Override + public IStructureDefinition<LaserEngraver> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<LaserEngraver>builder() + .addShape( + STRUCTURE_PIECE_T1, + transpose( + // spotless:off + new String[][]{{"ACADA", "AAAAA", "AAAAA"}, {"GGA~A", "H I", "GGAAA"}, + {"AAAAA", "ABBBA", "AAAAA"}})) + .addShape( + STRUCTURE_PIECE_T2, + new String[][]{{" ", " ", " ", " ", " ", " "}, + {" K ", " K ", " K ", " ", " ", " "}, + {" K ", " ", " ", " ", " ", " "}, + {" K ", " ", " ", " ", " ", " "}, + {" K ", " ", " ", " ", " ", " "}, + {" K ", "FBF FBF", " G G ", " G G ", " G G ", "FBF FBF"}, + {" KKKKK ", "BIB BIB", "G G G G", "G G G G", "G G G G", "BHB BHB"}, + {" K K ", "FBF FBF", " G G ", " G G ", " G G ", "FBF FBF"}, + {" K K ", " ", " ", " ", " ", " "}, + {" K K ", "FBF FBF", " G G ", " G G ", " G G ", "FBF FBF"}, + {" KKKKK ", "BIB BIB", "G G G G", "G G G G", "G G G G", "BHB BHB"}, + {" ", "FBF FBF", " G G ", " G G ", " G G ", "FBF FBF",}}) + .addShape( + STRUCTURE_PIECE_T3, + new String[][]{ + {" ", " BBBBB FBF ", " BGGGB G ", " BGGGB G ", " BMLMB G ", " BBBBB FBF "}, + {" KKKKKKK ", " BBAAABB BIB ", " B B G G ", " B B G G ", " B B G G ", " BBBBBBB BHB "}, + {" K ", " BABBBAB FBF ", " G G G ", " G G G ", " M HHH M G ", " BBBBBBB FBF "}, + {"KKKKKK ", " BABIBAB ", " G G ", " G G ", " L HHH L ", " BBBBBBB "}, + {" K ", " BABBBAB FBF ", " G G G ", " G G G ", " M HHH M G ", " BBBBBBB FBF "}, + {" KKKKKKK ", " BBAAABB BIB ", " B B G G ", " B B G G ", " B B G G ", " BBBBBBB BHB "}, + {" ", " BBBBB FBF ", " BGGGB G ", " BGGGB G ", " BMLMB G ", " BBBBB FBF "}}) + .addShape( + STRUCTURE_PIECE_T4, + new String[][]{ + {" ", "FBF BBBBB ", " G BGGGB ", " G BGGGB ", " G BNLNB ", "FBF BBBBB "}, + {" KKKKKKK ", "BIB BBAAABB ", "G G B B ", "G G B B ", "G G B B ", "BHB BBBBBBB "}, + {" K ", "FBF BABBBAB ", " G G G ", " G G G ", " G N HHH N ", "FBF BBBBBBB "}, + {" KKKKKK", " BABIBAB ", " G G ", " G G ", " L HHH L ", " BBBBBBB "}, + {" K ", "FBF BABBBAB ", " G G G ", " G G G ", " G N HHH N ", "FBF BBBBBBB "}, + {" KKKKKKK ", "BIB BBAAABB ", "G G B B ", "G G B B ", "G G B B ", "BHB BBBBBBB "}, + {" ", "FBF BBBBB ", " G BGGGB ", " G BGGGB ", " G BNLNB ", "FBF BBBBB "}}) + .addShape( + STRUCTURE_PIECE_T5, + new String[][]{ + {" ", " BBBBB FBF ", " BGGGB G ", " BGGGB G ", " BOLOB G ", " BBBBB FBF "}, + {" KKKKKKK ", " BBAAABB BIB ", " B B G G ", " B B G G ", " B B G G ", " BBBBBBB BHB "}, + {" K ", " BABBBAB FBF ", " G G G ", " G G G ", " O HHH O G ", " BBBBBBB FBF "}, + {" K ", " BABIBAB ", " G G ", " G G ", " L HHH L ", " BBBBBBB "}, + {" K ", " BABBBAB FBF ", " G G G ", " G G G ", " O HHH O G ", " BBBBBBB FBF "}, + {" KKKKKKK ", " BBAAABB BIB ", " B B G G ", " B B G G ", " B B G G ", " BBBBBBB BHB "}, + {" K ", " BBBBB FBF ", " BGGGB G ", " BGGGB G ", " BOLOB G ", " BBBBB FBF "}, + {" K ", " ", " ", " ", " "}, + {" K ", " ", " ", " ", " "}, + {" K ", " ", " ", " ", " "}}) + .addShape( + STRUCTURE_PIECE_T6, + new String[][]{ + {" ", "FBF BBBBB ", " G BGGGB ", " G BGGGB ", " G BPLPB ", "FBF BBBBB "}, + {" KKKKKKK ", "BIB BBAAABB ", "G G B B ", "G G B B ", "G G B B ", "BHB BBBBBBB "}, + {" K ", "FBF BABBBAB ", " G G G ", " G G G ", " G P HHH P ", "FBF BBBBBBB "}, + {" K ", " BABIBAB ", " G G ", " G G ", " L HHH L ", " BBBBBBB "}, + {" K ", "FBF BABBBAB ", " G G G ", " G G G ", " G P HHH P ", "FBF BBBBBBB "}, + {" KKKKKKK ", "BIB BBAAABB ", "G G B B ", "G G B B ", "G G B B ", "BHB BBBBBBB "}, + {" K ", "FBF BBBBB ", " G BGGGB ", " G BGGGB ", " G BPLPB ", "FBF BBBBB "}, + {" K ", " ", " ", " ", " "}, + {" K ", " ", " ", " ", " "}, + {" K ", " ", " ", " ", " "}}) + // spotless:on + .addElement( + 'A', + ofMuTECasings( + FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT | ENERGY_IN, + GT_MultiTileCasing.LaserEngraver.getCasing())) + .addElement( + 'B', + ofMuTECasings( + FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT | ENERGY_IN, + GT_MultiTileCasing.BlackLaserEngraverCasing.getCasing())) + .addElement( + 'C', + ofMuTECasings(NOTHING, CLEANROOM_CASINGS, GT_MultiTileCasing.LaserEngraver.getCasing())) + .addElement('D', ofMuTECasings(NOTHING, WIRELESS_CASINGS, GT_MultiTileCasing.LaserEngraver.getCasing())) + .addElement('E', ofMuTECasings(NOTHING, MOTOR_CASINGS)) + .addElement('F', GT_StructureUtility.ofFrame(Materials.Naquadah) + + ) + .addElement('H', ofMuTECasings(NOTHING, GT_MultiTileCasing.Mirror.getCasing())) + + .addElement( + 'G', + ofChain( + ofBlockUnlocalizedName(IndustrialCraft2.ID, "blockAlloyGlass", 0, true), + ofBlockUnlocalizedName(BartWorks.ID, "BW_GlasBlocks", 0, true), + ofBlockUnlocalizedName(BartWorks.ID, "BW_GlasBlocks2", 0, true), + ofBlockUnlocalizedName(Thaumcraft.ID, "blockCosmeticOpaque", 2, false))) + .addElement('I', ofMuTECasings(NOTHING, EMITTER_CASINGS)) + .addElement('K', ofBlock(GregTech_API.sBlockCasings3, 11)) + .addElement('L', ofMuTECasings(NOTHING, ROBOT_ARM_CASINGS)) + .addElement('M', ofMuTECasings(NOTHING, GT_MultiTileCasing.LaserEngraverUpgrade1.getCasing())) + .addElement('N', ofMuTECasings(NOTHING, GT_MultiTileCasing.LaserEngraverUpgrade2.getCasing())) + .addElement('O', ofMuTECasings(NOTHING, GT_MultiTileCasing.LaserEngraverUpgrade3.getCasing())) + .addElement('P', ofMuTECasings(NOTHING, GT_MultiTileCasing.LaserEngraverUpgrade4.getCasing())) + .build(); + buildState.stopBuilding(); + } + return STRUCTURE_DEFINITION; + } + + protected MultiChildWidget createMainPage(IWidgetBuilder<?> builder) { + MultiChildWidget child = new MultiChildWidget(); + for (int i = 0; i < MAX_PROCESSES; i++) { + final int processIndex = i; + child.addChild( + new ButtonWidget().setPlayClickSound(true) + .setOnClick( + (clickData, widget) -> { + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(PROCESS_WINDOW_BASE_ID + processIndex); + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_WHITELIST) + .setSize(18, 18) + .setEnabled((widget -> processIndex < maxComplexParallels)) + .setPos(20 * (i % 4) + 18, 18 + (i / 4) * 20)); + } + child.addChild( + new TextFieldWidget().setGetterInt(() -> maxComplexParallels) + .setSetterInt(parallel -> setMaxComplexParallels(parallel, true)) + .setNumbers(1, MAX_PROCESSES) + .setTextColor(Color.WHITE.normal) + .setTextAlignment(Alignment.Center) + .addTooltip("Tier") + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD) + .setSize(18, 18) + .setPos(130, 85)); + return child; + } + + @Override + public short getCasingRegistryID() { + return 0; + } + + @Override + public void readMultiTileNBT(NBTTagCompound nbt) { + super.readMultiTileNBT(nbt); + setMaxComplexParallels(nbt.getInteger("processors"), false); + } + + @Override + public void writeMultiTileNBT(NBTTagCompound nbt) { + super.writeMultiTileNBT(nbt); + nbt.setInteger("processors", maxComplexParallels); + } + + @Override + public int getCasingMeta() { + return GT_MultiTileCasing.LaserEngraver.getId(); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Laser Engraver") + .addInfo("Used for Engraving") + .addSeparator() + .beginStructureBlock(3, 3, 5, true) + .addController("Front right center") + .toolTipFinisher(GT_Values.AuthorTheEpicGamer274); + return tt; + } + + @Override + @Nonnull + protected LaserEngraverProcessingLogic createProcessingLogic() { + return new LaserEngraverProcessingLogic(); + } + +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/LayeredCokeBattery.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/LayeredCokeBattery.java new file mode 100644 index 0000000000..3b00708e40 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/LayeredCokeBattery.java @@ -0,0 +1,295 @@ +package gregtech.common.tileentities.machines.multiblock; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.Mods.*; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ENERGY_IN; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_IN; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_OUT; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_IN; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_OUT; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.NOTHING; +import static gregtech.api.util.GT_StructureUtilityMuTE.AMPERAGE_CASINGS; +import static gregtech.api.util.GT_StructureUtilityMuTE.HEATER_CASINGS; +import static gregtech.api.util.GT_StructureUtilityMuTE.INSULATOR_CASINGS; +import static gregtech.api.util.GT_StructureUtilityMuTE.MOTOR_CASINGS; +import static gregtech.api.util.GT_StructureUtilityMuTE.ofMuTECasings; + +import java.util.Arrays; +import java.util.Map; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SoundResource; +import gregtech.api.multitileentity.enums.GT_MultiTileCasing; +import gregtech.api.multitileentity.multiblock.base.StackableModularController; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_StructureUtility; +import gregtech.api.util.GT_StructureUtilityMuTE.UpgradeCasings; +import gregtech.common.tileentities.machines.multiblock.logic.LayeredCokeBatteryProcessingLogic; + +public class LayeredCokeBattery + extends StackableModularController<LayeredCokeBattery, LayeredCokeBatteryProcessingLogic> { + + private static IStructureDefinition<LayeredCokeBattery> STRUCTURE_DEFINITION_MEGA = null; + protected static final String STRUCTURE_PIECE_BASE = "T1"; + private static final Vec3Impl STRUCTURE_OFFSET_BASE = new Vec3Impl(2, 2, 0); + private static final Vec3Impl STRUCTURE_OFFSET_MEGA_POSITION = new Vec3Impl(4, 7, -4); + private static final Vec3Impl STRUCTURE_OFFSET_MEGA_START = new Vec3Impl(0, 0, -3); + private static final Vec3Impl STRUCTURE_OFFSET_MEGA_STACK = new Vec3Impl(0, 0, -2); + private static final Vec3Impl STRUCTURE_OFFSET_MEGA_STOP = new Vec3Impl(0, 0, -1); + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.layeredcokebattery"; + } + + @Override + public String getLocalName() { + return "Layered Coke Battery"; + } + + @Override + public Vec3Impl getStartingStructureOffset() { + return STRUCTURE_OFFSET_BASE; + } + + public UpgradeCasings getBaseMucType() { + return UpgradeCasings.Heater; + } + + public int getParallelFactor() { + return 2; + } + + @Override + public void construct(ItemStack trigger, boolean hintsOnly) { + final int blueprintCount = (trigger.stackSize - 1) + getMinStacks(); + final int stackCount = Math.min(blueprintCount, getMaxStacks()); + + buildState.startBuilding(getStartingStructureOffset()); + buildPiece(STRUCTURE_PIECE_BASE, trigger, hintsOnly, buildState.getCurrentOffset()); + buildState.addOffset(getMegaPositionOffset()); + + if (stackCount >= 1) { + buildPiece(STACKABLE_START, trigger, hintsOnly, buildState.getCurrentOffset()); + buildState.addOffset(getStartingStackOffset()); + + for (int i = 0; i < stackCount; i++) { + buildPiece(STACKABLE_MIDDLE, trigger, hintsOnly, buildState.getCurrentOffset()); + buildState.addOffset(getPerStackOffset()); + } + if (hasTop()) { + buildPiece(STACKABLE_STOP, trigger, hintsOnly, buildState.getCurrentOffset()); + } + } + + buildState.stopBuilding(); + } + + @Override + public IStructureDefinition<LayeredCokeBattery> getStructureDefinition() { + if (STRUCTURE_DEFINITION_MEGA == null) { + STRUCTURE_DEFINITION_MEGA = StructureDefinition.<LayeredCokeBattery>builder() + .addShape( + STRUCTURE_PIECE_BASE, + transpose( + new String[][] { { " AAA ", "AAAAA", "AEEEP", "AAAAA" }, { " AAA ", "A A", "A A", "AAAAA" }, + { " A~A ", "A A", "A A", "AAAAA" }, { " AAA ", "A A", "A A", "AAAAA" }, + { " AAA ", "AAAAA", "AAAAA", "AAAAA" } })) + .addShape( + STACKABLE_STOP, + transpose( + new String[][] { { "AHFFFFAFFFFHA", "AAAAAAAAAAAAA" }, { " B B B B B B ", "AFAFAFAFAFAFA" }, + { "HB B B B B BH", "AFAFAFAFAFAFA" }, { " B B B B B B ", "AFAFAFAFAFAFA" }, + { " B B B B B B ", "AFAFAFAFAFAFA" }, { " B B B B B B ", "AFAFAFAFAFAFA" }, + { " B B B B B B ", "AFAFAFAFAFAFA" }, { " B B B B B B ", "AFAFAFAFAFAFA" }, + { " B B B B B B ", "AFAFAFAFAFAFA" }, { "HB B B B B BH", "AFAFAFAFAFAFA" }, + { " B B B B B B ", "AFAFAFAFAFAFA" }, { "AAAAAAAAAAAAA", "AAAAAAAAAAAAA" } })) + .addShape( + STACKABLE_MIDDLE, + transpose( + new String[][] { { "AHFFFFAFFFFHA", "AAAAAAAAAAAAA" }, { " B A B ", "AAAAAAAAAAAAA" }, + { "HB A BH", "AAAAAAAAAAAAA" }, { " B A B ", "AAAAAAAAAAAAA" }, + { " B A B ", "AAAAAAAAAAAAA" }, { " B A B ", "AAAAAAAAAAAAA" }, + { " B A B ", "AAAAAAAAAAAAA" }, { " B A B ", "AAAAAAAAAAAAA" }, + { " B A B ", "AAAAAAAAAAAAA" }, { "HB A BH", "AAAAAAAAAAAAA" }, + { " B A B ", "AAAAAAAAAAAAA" }, { "AAAAAAAAAAAAA", "AAAAAAAAAAAAA" } })) + .addShape( + STACKABLE_START, + transpose( + new String[][] { { "AAAAAAAAAAAAA", "AHFFFFAFFFFHA", "AAAAAAAAAAAAA" }, + { "AFAFAFAFAFAFA", " B B B B B B ", "AAAAAAAAAAAAA" }, + { "AFAFAFAFAFAFA", "HB B B B B BH", "AAAAAAAAAAAAA" }, + { "AFAFAFAFAFAFA", " B B B B B B ", "AAAAAAAAAAAAA" }, + { "AFAFAFAFAFAFA", " B B B B B B ", "AAAAAAAAAAAAA" }, + { "AFAFAFAFAFAFA", " B B B B B B ", "AAAAAAAAAAAAA" }, + { "AFAFAFAFAFAFA", " B B B B B B ", "AAAAAAAAAAAAA" }, + { "AFAFAFAFAFAFA", " B B B B B B ", "AAAAAAAAAAAAA" }, + { "AFAFAFAFAFAFA", " B B B B B B ", "AAAAAAAAAAAAA" }, + { "AFAFAFAFAFAFA", "HB B B B B BH", "AAAAAAAAAAAAA" }, + { "AFAFAFAFAFAFA", " B B B B B B ", "AAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAA", "AAAAAAAAAAAAA", "AAAAAAAAAAAAA" } })) + .addElement( + 'A', + ofMuTECasings( + FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT | ENERGY_IN, + GT_MultiTileCasing.Chemical.getCasing())) + .addElement( + 'B', + ofMuTECasings( + FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT | ENERGY_IN, + GT_MultiTileCasing.Distillation.getCasing())) + .addElement('C', ofBlock(GregTech_API.sBlockCasings4, 1)) + .addElement('D', GT_StructureUtility.ofFrame(Materials.Steel)) + .addElement('E', ofMuTECasings(NOTHING, MOTOR_CASINGS)) + .addElement( + 'F', + ofChain( + ofBlockUnlocalizedName(IndustrialCraft2.ID, "blockAlloyGlass", 0, true), + ofBlockUnlocalizedName(BartWorks.ID, "BW_GlasBlocks", 0, true), + ofBlockUnlocalizedName(BartWorks.ID, "BW_GlasBlocks2", 0, true), + ofBlockUnlocalizedName(Thaumcraft.ID, "blockCosmeticOpaque", 2, false))) + .addElement('H', ofMuTECasings(NOTHING, HEATER_CASINGS, INSULATOR_CASINGS)) + .addElement('P', ofMuTECasings(NOTHING, AMPERAGE_CASINGS)) + .build(); + } + return STRUCTURE_DEFINITION_MEGA; + } + + public boolean checkMachine() { + stackCount = 0; + resetMucCount(); + + buildState.startBuilding(getStartingStructureOffset()); + if (!checkPiece(STRUCTURE_PIECE_BASE, buildState.getCurrentOffset())) return buildState.failBuilding(); + + buildState.addOffset(getMegaPositionOffset()); + if (!checkPiece(STACKABLE_START, buildState.getCurrentOffset())) { + return buildState.failBuilding(); + } + + buildState.addOffset(getStartingStackOffset()); + for (int i = 0; i < getMaxStacks(); i++) { + if (!checkPiece(getStackableMiddle(i), buildState.getCurrentOffset())) { + break; + } + + buildState.addOffset(getPerStackOffset()); + stackCount++; + } + if (stackCount < getMinStacks()) return buildState.failBuilding(); + + if (!checkPiece(getStackableStop(), buildState.stopBuilding())) { + return buildState.failBuilding(); + } + + calculateTier(); + if (!calculateMucMultipliers()) { + return false; + } + calculateParallels(); + updatePowerLogic(); + return tier > 0; + } + + protected boolean calculateMucMultipliers() { + Map<UpgradeCasings, int[]> mucMap = getMucMap(); + int[] heaterList = mucMap.get(UpgradeCasings.Heater); + int[] insulatorList = mucMap.get(UpgradeCasings.Insulator); + int totalHeaterCount = Arrays.stream(heaterList) + .sum(); + int totalInsulatorCount = Arrays.stream(insulatorList) + .sum(); + if (totalHeaterCount + totalInsulatorCount < stackCount || totalInsulatorCount > totalHeaterCount) { + return false; + } + if (totalInsulatorCount > 0) { + // To be improved later, when more MUCs are added + // durationMultiplier = 1.0 / totalHeaterCount; + euTickMultiplier = 1.0 / totalInsulatorCount; + } + return true; + } + + @Override + public short getCasingRegistryID() { + return 0; + } + + @Override + public int getCasingMeta() { + return GT_MultiTileCasing.Distillation.getId(); + } + + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Coke Oven") + .addInfo("Controller for the Layered Coke Battery") + .addSeparator() + .beginVariableStructureBlock(7, 9, 2 + getMinStacks(), 2 + getMaxStacks(), 7, 9, true) + .addController("Bottom Front Center") + .addCasingInfoExactly("Test Casing", 60, false) + .addEnergyHatch("Any bottom layer casing") + .addInputHatch("Any non-optional external facing casing on the stacks") + .addInputBus("Any non-optional external facing casing on the stacks") + .addOutputHatch("Any non-optional external facing casing on the stacks") + .addOutputBus("Any non-optional external facing casing on the stacks") + .addStructureInfo( + String.format("Stackable middle stacks between %d-%d time(s).", getMinStacks(), getMaxStacks())) + .toolTipFinisher("Wildcard"); + return tt; + } + + @Override + public int getMinStacks() { + return 0; + } + + @Override + public int getMaxStacks() { + return 20; + } + + public Vec3Impl getMegaPositionOffset() { + return STRUCTURE_OFFSET_MEGA_POSITION; + } + + @Override + public Vec3Impl getStartingStackOffset() { + return STRUCTURE_OFFSET_MEGA_START; + } + + @Override + public Vec3Impl getPerStackOffset() { + return STRUCTURE_OFFSET_MEGA_STACK; + } + + @Override + public Vec3Impl getAfterLastStackOffset() { + return STRUCTURE_OFFSET_MEGA_STOP; + } + + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.IC2_MACHINES_MACERATOR_OP.resourceLocation; + } + + @Override + @Nonnull + protected LayeredCokeBatteryProcessingLogic createProcessingLogic() { + return new LayeredCokeBatteryProcessingLogic(); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/Macerator.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/Macerator.java index dda7eb9420..dfdacfe7f2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/Macerator.java +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/Macerator.java @@ -1,6 +1,5 @@ package gregtech.common.tileentities.machines.multiblock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ENERGY_IN; import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_IN; @@ -8,27 +7,20 @@ import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_ import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_IN; import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_OUT; import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.NOTHING; +import static gregtech.api.util.GT_StructureUtilityMuTE.*; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; - -import org.apache.commons.lang3.tuple.Pair; +import javax.annotation.Nonnull; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import com.gtnewhorizon.structurelib.util.Vec3Impl; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.SoundResource; -import gregtech.api.enums.TierEU; +import gregtech.api.multitileentity.enums.GT_MultiTileCasing; import gregtech.api.multitileentity.multiblock.base.StackableController; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; +import gregtech.common.tileentities.machines.multiblock.logic.MaceratorProcessingLogic; -public class Macerator extends StackableController<Macerator> { +public class Macerator extends StackableController<Macerator, MaceratorProcessingLogic> { private static IStructureDefinition<Macerator> STRUCTURE_DEFINITION = null; @@ -45,25 +37,23 @@ public class Macerator extends StackableController<Macerator> { public IStructureDefinition<Macerator> getStructureDefinition() { if (STRUCTURE_DEFINITION == null) { STRUCTURE_DEFINITION = StructureDefinition.<Macerator>builder() - .addShape(STACKABLE_TOP, transpose(new String[][] { { " CCC ", "CCCCC", "CCCCC", "CCCCC", " CCC " }, })) + .addShape( + STACKABLE_STOP, + transpose(new String[][] { { " CCC ", "CCCCC", "CCCCC", "CCCCC", " CCC " }, })) .addShape( STACKABLE_MIDDLE, transpose(new String[][] { { " BBB ", " B---B ", "DC---CD", " B---B ", " BBB " }, })) .addShape( - STACKABLE_BOTTOM, + STACKABLE_START, transpose(new String[][] { { " G~F ", "AAAAA", "AAAAA", "AAAAA", " AAA " }, })) - .addElement('A', ofChain(addMultiTileCasing("gt.multitileentity.casings", getCasingMeta(), ENERGY_IN))) + .addElement('A', ofMuTECasings(ENERGY_IN, GT_MultiTileCasing.Macerator.getCasing())) .addElement( 'B', - ofChain( - addMultiTileCasing( - "gt.multitileentity.casings", - getCasingMeta(), - FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT))) - .addElement('C', addMultiTileCasing("gt.multitileentity.casings", getCasingMeta(), NOTHING)) - .addElement('D', addMultiTileCasing("gt.multitileentity.casings", getCasingMeta(), NOTHING)) - .addElement('F', addMotorCasings(NOTHING)) - .addElement('G', addMultiTileCasing("gt.multitileentity.component.casings", 10000, NOTHING)) + ofMuTECasings(FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT, GT_MultiTileCasing.Macerator.getCasing())) + .addElement('C', ofMuTECasings(NOTHING, GT_MultiTileCasing.Macerator.getCasing())) + .addElement('D', ofMuTECasings(NOTHING, GT_MultiTileCasing.Macerator.getCasing())) + .addElement('F', ofMuTECasings(NOTHING, MOTOR_CASINGS)) + .addElement('G', ofMuTECasings(NOTHING, INVENTORY_CASINGS)) .build(); } return STRUCTURE_DEFINITION; @@ -135,42 +125,8 @@ public class Macerator extends StackableController<Macerator> { } @Override - protected boolean checkRecipe() { - if (isSeparateInputs()) { - for (Pair<ItemStack[], String> tItemInputs : getItemInputsForEachInventory()) { - if (processRecipe(tItemInputs.getLeft(), tItemInputs.getRight())) { - return true; - } - } - return false; - } else { - ItemStack[] tItemInputs = getInventoriesForInput().getStacks() - .toArray(new ItemStack[0]); - return processRecipe(tItemInputs, null); - } - } - - private boolean processRecipe(ItemStack[] aItemInputs, String aInventory) { - RecipeMap<?> tRecipeMap = RecipeMaps.maceratorRecipes; - GT_Recipe tRecipe = tRecipeMap.findRecipe(this, false, TierEU.IV, null, aItemInputs); - if (tRecipe == null) { - return false; - } - - if (!tRecipe.isRecipeInputEqual(true, false, 1, null, aItemInputs)) { - return false; - } - - setDuration(tRecipe.mDuration); - setEut(tRecipe.mEUt); - - setItemOutputs(aInventory, tRecipe.mOutputs); - return true; - } - - @SideOnly(Side.CLIENT) - @Override - protected ResourceLocation getActivitySoundLoop() { - return SoundResource.IC2_MACHINES_MACERATOR_OP.resourceLocation; + @Nonnull + protected MaceratorProcessingLogic createProcessingLogic() { + return new MaceratorProcessingLogic(); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/AdvChemicalProcessorProcessingLogic.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/AdvChemicalProcessorProcessingLogic.java new file mode 100644 index 0000000000..59879e30c7 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/AdvChemicalProcessorProcessingLogic.java @@ -0,0 +1,12 @@ +package gregtech.common.tileentities.machines.multiblock.logic; + +import gregtech.api.logic.ComplexParallelProcessingLogic; +import gregtech.api.recipe.RecipeMaps; + +public class AdvChemicalProcessorProcessingLogic + extends ComplexParallelProcessingLogic<AdvChemicalProcessorProcessingLogic> { + + public AdvChemicalProcessorProcessingLogic() { + setRecipeMap(RecipeMaps.multiblockChemicalReactorRecipes); + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/CokeOvenProcessingLogic.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/CokeOvenProcessingLogic.java index 046bb4a114..1534b05bc3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/CokeOvenProcessingLogic.java +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/CokeOvenProcessingLogic.java @@ -5,17 +5,19 @@ import static net.minecraftforge.oredict.OreDictionary.getOreID; import static net.minecraftforge.oredict.OreDictionary.getOreIDs; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import gregtech.api.logic.ProcessingLogic; -import gregtech.api.recipe.check.CheckRecipeResult; -import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.logic.FluidInventoryLogic; +import gregtech.api.logic.ItemInventoryLogic; +import gregtech.api.logic.MuTEProcessingLogic; +import gregtech.api.recipe.RecipeMap; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; -public class CokeOvenProcessingLogic extends ProcessingLogic { +public class CokeOvenProcessingLogic extends MuTEProcessingLogic<CokeOvenProcessingLogic> { private static final int NORMAL_RECIPE_TIME = 1800; private static final int WOOD_ORE_ID = getOreID("logWood"); @@ -27,26 +29,33 @@ public class CokeOvenProcessingLogic extends ProcessingLogic { private static final int SUGAR_CHARCOAL_ORE_ID = getOreID("itemCharcoalSugar"); private int timeMultiplier = 1; + @Nonnull @Override - public @Nonnull CheckRecipeResult process() { - if (inputItems == null || inputItems[0] == null) { - return CheckRecipeResultRegistry.NO_RECIPE; - } - ItemStack input = inputItems[0]; - int originalStackSize = input.stackSize; - ItemStack output = findRecipe(input); - if (currentOutputItems != null && currentOutputItems[0] != null && !currentOutputItems[0].isItemEqual(output)) { - return CheckRecipeResultRegistry.NO_RECIPE; + protected Object findRecipe(@Nullable RecipeMap<?> map, @Nonnull ItemInventoryLogic itemInput, + @Nonnull FluidInventoryLogic fluidInput) { + for (ItemStack item : itemInput.getStoredItems()) { + ItemStack output = findRecipe(item); + if (output != null) { + ItemStack input = item.copy(); + input.stackSize = 1; + return null; + // return FindRecipeResult.ofSuccess( + // GT_Values.RA.stdBuilder() + // .itemInputs(input) + // .itemOutputs(output) + // .noFluidInputs() + // .noFluidOutputs() + // .duration(NORMAL_RECIPE_TIME * timeMultiplier) + // .eut(0) + // .build() + // .get()); + } } - input.stackSize -= 1; - setDuration(NORMAL_RECIPE_TIME * timeMultiplier); - setOutputItems(output); - - return originalStackSize > input.stackSize ? CheckRecipeResultRegistry.SUCCESSFUL - : CheckRecipeResultRegistry.NO_RECIPE; + return null; } - protected ItemStack findRecipe(ItemStack input) { + @Nullable + private ItemStack findRecipe(@Nonnull ItemStack input) { for (int oreId : getOreIDs(input)) { if (oreId == COAL_ORE_ID) { return GT_OreDictUnificator.get("fuelCoke", null, 1); diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/DistillationTowerProcessingLogic.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/DistillationTowerProcessingLogic.java new file mode 100644 index 0000000000..6f27c9a0e6 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/DistillationTowerProcessingLogic.java @@ -0,0 +1,7 @@ +package gregtech.common.tileentities.machines.multiblock.logic; + +import gregtech.api.logic.ComplexParallelProcessingLogic; + +public class DistillationTowerProcessingLogic extends ComplexParallelProcessingLogic<DistillationTowerProcessingLogic> { + +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/LaserEngraverProcessingLogic.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/LaserEngraverProcessingLogic.java new file mode 100644 index 0000000000..3f4a6bfe70 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/LaserEngraverProcessingLogic.java @@ -0,0 +1,7 @@ +package gregtech.common.tileentities.machines.multiblock.logic; + +import gregtech.api.logic.ComplexParallelProcessingLogic; + +public class LaserEngraverProcessingLogic extends ComplexParallelProcessingLogic<LaserEngraverProcessingLogic> { + +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/LayeredCokeBatteryProcessingLogic.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/LayeredCokeBatteryProcessingLogic.java new file mode 100644 index 0000000000..b2e43b6fa9 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/LayeredCokeBatteryProcessingLogic.java @@ -0,0 +1,7 @@ +package gregtech.common.tileentities.machines.multiblock.logic; + +import gregtech.api.logic.MuTEProcessingLogic; + +public class LayeredCokeBatteryProcessingLogic extends MuTEProcessingLogic<LayeredCokeBatteryProcessingLogic> { + +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/MaceratorProcessingLogic.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/MaceratorProcessingLogic.java new file mode 100644 index 0000000000..3f7d8a25f7 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/logic/MaceratorProcessingLogic.java @@ -0,0 +1,7 @@ +package gregtech.common.tileentities.machines.multiblock.logic; + +import gregtech.api.logic.MuTEProcessingLogic; + +public class MaceratorProcessingLogic extends MuTEProcessingLogic<MaceratorProcessingLogic> { + +} |