diff options
author | Maxim <maxim235@gmx.de> | 2023-04-22 17:38:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-22 08:38:49 -0700 |
commit | fdde96ab6fef30064b67e28390008ee4ba455655 (patch) | |
tree | ee169d0d4a8432433c4ec01eada1e24049a0e47a /src/main/java/gregtech/api/logic | |
parent | de864236f83dc31c53ca77a6939357a0959bca75 (diff) | |
download | GT5-Unofficial-fdde96ab6fef30064b67e28390008ee4ba455655.tar.gz GT5-Unofficial-fdde96ab6fef30064b67e28390008ee4ba455655.tar.bz2 GT5-Unofficial-fdde96ab6fef30064b67e28390008ee4ba455655.zip |
MuTE overhaul and ACR (#1883)
* complex controller start
* Added methods to get input fluids and items
* Added logic to complex parallel mute
* Added ACR and fixed many, many, many, many bugs
* Added void protection setting to checkRecipe
* do not init nbt, if mteID and mteRegistry are the same
* Improved GUI design
* Force structure check when pressing power switch
* ACR Textures
* Added T1 structure
* Added perfect OC
* Added WAILA
* fix mutes resetting their nbt
* Fix ACR GUI
* fix npe
* Added void protection for MuTEs
* Fixed ACR starting recipe while another one is ongoing
* nbt saving
* maybe fix structure breaking
* Fix complex machine disabling on startup
* correctly update input tanks
* move casings over
* Changed logic of casings to change mode and facing in one go by sneaking
* Fixed the casing target not resetting
* Added side only annotations
* don't leave it empty
* Added power logic and tiered blocks to ACR
* Change facing to wrench side if casing mode is currently none
* lasers anyone?
* Added ACR item chaining
* Remove unncessary item lists
* Use HashSet for process whitelists
* Optimize list capacities
* Fix potential recipe voiding bug
* Rename methods for consistancy
* Fix NPE
* Duct tape fix structure check
* allow MuTEs to connect to cables
* Added separate tank inventories for input separation (#1887)
* Fixed unregistering tank function
* Fixed input busses not being automatable
* Added fluid chaining
* Fixed saving of input tanks
* Forbid inventory registering with empty name
* Display all input tanks in controller GUI
* Fixed fluid hatch GUI height
* Reset casing lists when checking the structure
* Make inventory GUI size consistant
* Make use of the tooltip cache
* rename thing clean up
* Forgot to put tooltip into map
* Added tooltip to ACR
* Reset whitelists when one whitelist window was opened
* Refined scanner string
* Fixed progress times
* Fixed MuTE not consuming fluids
* Properly register controller inventories
* switch to ForgeDirection
* switch to new Renderer
* Added missing contains check on registerInventory
* Fixed output tanks not registering
* Fixed upgrade tank loading
* fix machines not having active/inactive textures
* fix overlays not loading correctly
* Don't register controller directly
* Remove magic strings all
* fix active not setting to inactive
* allow glow
* item renderer
* fix glow
* MuTE improved hatch GUI and fluid output locking (#1889)
* Allow output hatches to be fluid locked
* Reworked hatch GUI
* Check target before trying to open GUI
* Make ACR GUI easier to look at
* fix covers not rendering on mutes
* fix covers not displaying above the item/fluid in/out
* new folder texture structure
* Reduce network traffic caused by covers
* Fixed WAILA fluid locking display
* Don't save everything to the itemstack NBT
* Added possibility to save NBT of MuTE to its itemstack
* fix textures, but make sacrifices
* mah textures
* Removed the need for all textures to be present
* Added glow texture for active coke oven
* Removed unncesssary upgrade casing textures
* shorten nbt tags
---------
Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/api/logic')
5 files changed, 216 insertions, 1 deletions
diff --git a/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java b/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java new file mode 100644 index 0000000000..d38a3d98fd --- /dev/null +++ b/src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java @@ -0,0 +1,183 @@ +package gregtech.api.logic; + +import java.util.stream.LongStream; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.multitileentity.multiblock.base.Controller; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_ParallelHelper; +import gregtech.api.util.GT_Recipe; + +public class ComplexParallelProcessingLogic { + + protected Controller<?> tileEntity; + protected GT_Recipe.GT_Recipe_Map recipeMap; + protected boolean hasPerfectOverclock; + protected final int maxComplexParallels; + protected final ItemStack[][] outputItems; + protected final ItemStack[][] inputItems; + protected final FluidStack[][] inputFluids; + protected final FluidStack[][] outputFluids; + protected final long[] availableEut; + protected final long[] eut; + protected final long[] durations; + protected boolean[] isVoidProtected; + + public ComplexParallelProcessingLogic(int maxComplexParallels) { + this(null, maxComplexParallels); + } + + public ComplexParallelProcessingLogic(GT_Recipe.GT_Recipe_Map recipeMap, int maxComplexParallels) { + this.maxComplexParallels = maxComplexParallels; + this.recipeMap = recipeMap; + inputItems = new ItemStack[maxComplexParallels][]; + outputItems = new ItemStack[maxComplexParallels][]; + inputFluids = new FluidStack[maxComplexParallels][]; + outputFluids = new FluidStack[maxComplexParallels][]; + eut = new long[maxComplexParallels]; + availableEut = new long[maxComplexParallels]; + durations = new long[maxComplexParallels]; + isVoidProtected = new boolean[maxComplexParallels]; + } + + public ComplexParallelProcessingLogic setRecipeMap(GT_Recipe.GT_Recipe_Map recipeMap) { + this.recipeMap = recipeMap; + return this; + } + + public ComplexParallelProcessingLogic setInputItems(int index, ItemStack... itemInputs) { + if (index >= 0 && index < maxComplexParallels) { + inputItems[index] = itemInputs; + } + return this; + } + + public ComplexParallelProcessingLogic setInputFluids(int index, FluidStack... inputFluids) { + if (index >= 0 && index < maxComplexParallels) { + this.inputFluids[index] = inputFluids; + } + return this; + } + + public ComplexParallelProcessingLogic setTileEntity(Controller<?> tileEntity) { + this.tileEntity = tileEntity; + return this; + } + + public ComplexParallelProcessingLogic setEut(int index, long eut) { + if (index >= 0 && index < maxComplexParallels) { + availableEut[index] = eut; + } + return this; + } + + public ComplexParallelProcessingLogic setVoidProtection(int index, boolean shouldVoidProtect) { + if (index >= 0 && index < maxComplexParallels) { + isVoidProtected[index] = shouldVoidProtect; + } + return this; + } + + public ComplexParallelProcessingLogic setPerfectOverclock(boolean shouldOverclockPerfectly) { + this.hasPerfectOverclock = shouldOverclockPerfectly; + return this; + } + + public ComplexParallelProcessingLogic clear() { + for (int i = 0; i < maxComplexParallels; i++) { + outputItems[i] = null; + outputFluids[i] = null; + durations[i] = 0; + eut[i] = 0; + } + return this; + } + + public ComplexParallelProcessingLogic clear(int index) { + if (index >= 0 && index < maxComplexParallels) { + inputItems[index] = null; + inputFluids[index] = null; + outputItems[index] = null; + outputFluids[index] = null; + durations[index] = 0; + availableEut[index] = 0; + eut[index] = 0; + } + return this; + } + + public boolean process(int index) { + if (recipeMap == null) { + return false; + } + GT_Recipe recipe = recipeMap + .findRecipe(tileEntity, false, false, availableEut[index], inputFluids[index], inputItems[index]); + if (recipe == null) { + return false; + } + + GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(recipe) + .setItemInputs(inputItems[index]) + .setFluidInputs(inputFluids[index]) + .setAvailableEUt(availableEut[index]) + .enableConsumption() + .enableOutputCalculation(); + + if (isVoidProtected[index]) { + helper.enableVoidProtection(tileEntity); + } + + helper.build(); + + if (helper.getCurrentParallel() <= 0) { + return false; + } + + GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(recipe.mEUt) + .setDuration(recipe.mDuration) + .setEUt(availableEut[index]); + + if (hasPerfectOverclock) { + calculator.enablePerfectOC(); + } + + if (calculator.getConsumption() == Long.MAX_VALUE - 1 || calculator.getDuration() == Integer.MAX_VALUE - 1) { + return false; + } + + durations[index] = calculator.getDuration(); + eut[index] = calculator.getConsumption(); + outputItems[index] = helper.getItemOutputs(); + outputFluids[index] = helper.getFluidOutputs(); + + return true; + } + + public long getDuration(int index) { + if (index >= 0 && index < maxComplexParallels) { + return durations[index]; + } + return 0; + } + + public long getTotalEU() { + return LongStream.of(eut) + .sum(); + } + + public ItemStack[] getOutputItems(int index) { + if (index >= 0 && index < maxComplexParallels) { + return outputItems[index]; + } + return null; + } + + public FluidStack[] getOutputFluids(int index) { + if (index >= 0 && index < maxComplexParallels) { + return outputFluids[index]; + } + return null; + } +} diff --git a/src/main/java/gregtech/api/logic/ModelRenderLogic.java b/src/main/java/gregtech/api/logic/ModelRenderLogic.java new file mode 100644 index 0000000000..d9f2fdcf27 --- /dev/null +++ b/src/main/java/gregtech/api/logic/ModelRenderLogic.java @@ -0,0 +1,5 @@ +package gregtech.api.logic; + +public abstract class ModelRenderLogic { + +} diff --git a/src/main/java/gregtech/api/logic/PowerLogic.java b/src/main/java/gregtech/api/logic/PowerLogic.java index 8044a2f979..ac12ef8917 100644 --- a/src/main/java/gregtech/api/logic/PowerLogic.java +++ b/src/main/java/gregtech/api/logic/PowerLogic.java @@ -15,6 +15,7 @@ public class PowerLogic { private long voltage = 0; private long amperage = 0; private int type = 0; + private boolean canUseLaser = false; public PowerLogic() {} @@ -38,6 +39,16 @@ public class PowerLogic { return this; } + public PowerLogic disableLaser() { + canUseLaser = false; + return this; + } + + public PowerLogic enableLaser() { + canUseLaser = true; + return this; + } + public boolean addEnergyUnsafe(long totalEUAdded) { if (storedEnergy + totalEUAdded >= energyCapacity) { return false; @@ -127,4 +138,8 @@ public class PowerLogic { voltage = powerLogic.getLong(NBT.POWER_LOGIC_VOLTAGE); type = powerLogic.getInteger(NBT.POWER_LOGIC_TYPE); } + + public boolean canUseLaser() { + return canUseLaser; + } } diff --git a/src/main/java/gregtech/api/logic/interfaces/ModelRenderLogicHost.java b/src/main/java/gregtech/api/logic/interfaces/ModelRenderLogicHost.java new file mode 100644 index 0000000000..9a0afaa539 --- /dev/null +++ b/src/main/java/gregtech/api/logic/interfaces/ModelRenderLogicHost.java @@ -0,0 +1,10 @@ +package gregtech.api.logic.interfaces; + +import gregtech.api.logic.ModelRenderLogic; + +public interface ModelRenderLogicHost { + + ModelRenderLogic getRenderLogic(); + + boolean shouldRenderModel(); +} diff --git a/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java b/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java index 8e504674aa..1a66e5fe83 100644 --- a/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java +++ b/src/main/java/gregtech/api/logic/interfaces/PowerLogicHost.java @@ -1,10 +1,12 @@ package gregtech.api.logic.interfaces; +import net.minecraftforge.common.util.ForgeDirection; + import gregtech.api.logic.PowerLogic; public interface PowerLogicHost { - PowerLogic getPowerLogic(byte side); + PowerLogic getPowerLogic(ForgeDirection facing); default boolean isEnergyReceiver() { return false; |