Skip to content

Commit

Permalink
MuTE overhaul and ACR (#1883)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
4 people authored Apr 22, 2023
1 parent de86423 commit fdde96a
Show file tree
Hide file tree
Showing 82 changed files with 3,817 additions and 861 deletions.
34 changes: 25 additions & 9 deletions src/main/java/gregtech/api/enums/GT_Values.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public static final class NBT {
TANK_CAPACITY = "gt.tankcap", // Number
TANK_IN = "gt.tank.in.", // FluidStack
TANK_OUT = "gt.tank.out.", // FluidStack
TEXTURE = "gt.texture", // String
TEXTURE_FOLDER = "gt.texture.folder", // String
INV_INPUT_SIZE = "gt.invsize.in", // Number
INV_OUTPUT_SIZE = "gt.invsize.out", // Number
INV_INPUT_LIST = "gt.invlist.in", // NBT List
Expand All @@ -326,22 +326,34 @@ public static final class NBT {
TARGET_X = "gt.target.x", // Number
TARGET_Y = "gt.target.y", // Number
TARGET_Z = "gt.target.z", // Number
LOCKED_INVENTORY = "gt.locked.inventory", // String
LOCKED_INVENTORY_INDEX = "gt.locked.inventory.index", // Number
LOCKED_FLUID = "gt.locked.fluid", // String
LOCKED_INVENTORY = "gt.locked.inv", // String
LOCKED_INVENTORY_INDEX = "gt.locked.inv.index", // Number
UPGRADE_INVENTORY_SIZE = "gt.invsize.upg", // String
UPGRADE_INVENTORY_UUID = "gt.invuuid.upg", // String
UPGRADE_INVENTORY_NAME = "gt.invname.upg", // String
UPGRADE_INVENTORIES_INPUT = "gt.invlist.upg.in", // NBT List
UPGRADE_INVENTORIES_OUTPUT = "gt.invlist.upg.out", // NBT List
UPGRADE_TANK_CAPACITY = "gt.tank.cap.upg", // Long
UPGRADE_TANK_CAPACITY_MULTIPLIER = "gt.tank.cap.mult.upg", // Long
UPGRADE_TANK_UUID = "gt.tankuuid.upg", // String
UPGRADE_TANK_NAME = "gt.tankname.upg", // String
UPGRADE_TANKS_INPUT = "gt.tanklist.upg.in", // NBT List
UPGRADE_TANKS_OUTPUT = "gt.tanklist.upg.out", // NBT List
UPGRADE_TANKS_COUNT = "gt.tankcount.upg", // Int
UPGRADE_TANKS_PREFIX = "gt.tank.upg", // NBT Tag
SEPARATE_INPUTS = "gt.separate.inputs", // Boolean
VOID_EXCESS = "gt.void.excess", // Boolean
BATCH_MODE = "gt.batch.mode", // Boolean
RECIPE_LOCK = "gt.recipe.lock", // Boolean

// Logic
POWER_LOGIC = "gt.power.logic", // NBT Tag
POWER_LOGIC_STORED_ENERGY = "gt.power.logic.stored.energy", // Number
POWER_LOGIC_ENERGY_CAPACITY = "gt.power.logic.energy.capacity", // Number
POWER_LOGIC_VOLTAGE = "gt.power.logic.voltage", // Number
POWER_LOGIC_AMPERAGE = "gt.power.logic.voltage", // Number
POWER_LOGIC_TYPE = "gt.power.logic.type", // Number
POWER_LOGIC = "gt.pow.logic", // NBT Tag
POWER_LOGIC_STORED_ENERGY = "gt.pow.energy", // Number
POWER_LOGIC_ENERGY_CAPACITY = "gt.pow.energy.cap", // Number
POWER_LOGIC_VOLTAGE = "gt.pow.volt", // Number
POWER_LOGIC_AMPERAGE = "gt.pow.amp", // Number
POWER_LOGIC_TYPE = "gt.pow.type", // Number
empty_ = "";
}

Expand Down Expand Up @@ -588,6 +600,10 @@ public static final class NBT {
+ EnumChatFormatting.BOLD
+ "Weabo";

public static final String Authorminecraft7771 = "Author: " + EnumChatFormatting.BLUE
+ EnumChatFormatting.LIGHT_PURPLE
+ "minecraft7771";

// 7.5F comes from GT_Tool_Turbine_Large#getBaseDamage() given huge turbines are the most efficient now.
public static double getMaxPlasmaTurbineEfficiencyFromMaterial(Materials material) {
return (5F + (7.5F + material.mToolQuality)) / 10.0;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/gregtech/api/fluid/FluidTankGT.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static com.google.common.primitives.Ints.saturatedCast;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -446,8 +448,25 @@ public int getCapacity() {
return saturatedCast(capacity());
}

public long getCapacityMultiplier() {
return mAdjustableMultiplier;
}

@Override
public FluidTankInfo getInfo() {
return new FluidTankInfo(isEmpty() ? null : mFluid.copy(), saturatedCast(capacity()));
}

public static FluidStack[] getFluidsFromTanks(FluidTankGT[] tanks) {
if (tanks == null) {
return null;
}
List<FluidStack> fluidStacks = new ArrayList<>();
for (FluidTankGT tank : tanks) {
if (tank.getFluid() != null) {
fluidStacks.add(tank.getFluid());
}
}
return fluidStacks.toArray(new FluidStack[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static long emitEnergyToNetwork(long aVoltage, long aAmperage, IEnergyCon
final TileEntity tTileEntity = emitterTile.getTileEntityAtSide(i);
if (tTileEntity instanceof PowerLogicHost host) {

PowerLogic logic = host.getPowerLogic(j);
PowerLogic logic = host.getPowerLogic(ForgeDirection.getOrientation(j));
if (logic == null || logic.isEnergyReceiver()) {
continue;
}
Expand Down
183 changes: 183 additions & 0 deletions src/main/java/gregtech/api/logic/ComplexParallelProcessingLogic.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
5 changes: 5 additions & 0 deletions src/main/java/gregtech/api/logic/ModelRenderLogic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package gregtech.api.logic;

public abstract class ModelRenderLogic {

}
15 changes: 15 additions & 0 deletions src/main/java/gregtech/api/logic/PowerLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand All @@ -38,6 +39,16 @@ public PowerLogic setType(int type) {
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;
Expand Down Expand Up @@ -127,4 +138,8 @@ public void loadFromNBT(NBTTagCompound nbt) {
voltage = powerLogic.getLong(NBT.POWER_LOGIC_VOLTAGE);
type = powerLogic.getInteger(NBT.POWER_LOGIC_TYPE);
}

public boolean canUseLaser() {
return canUseLaser;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gregtech.api.logic.interfaces;

import gregtech.api.logic.ModelRenderLogic;

public interface ModelRenderLogicHost {

ModelRenderLogic getRenderLogic();

boolean shouldRenderModel();
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/gregtech/api/metatileentity/BaseTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ public final int getOffsetZ(byte aSide, int aMultiplier) {

@Override
public final boolean isServerSide() {
if (worldObj == null) {
return false;
}
return !worldObj.isRemote;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.interfaces.tileentity.IEnergyConnected;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.interfaces.PowerLogicHost;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
import gregtech.api.objects.GT_Cover_None;
Expand Down Expand Up @@ -336,8 +337,12 @@ public boolean canConnect(byte aSide, TileEntity tTileEntity) {
final ForgeDirection tDir = ForgeDirection.getOrientation(tSide);

// GT Machine handling
if ((tTileEntity instanceof IEnergyConnected) && (((IEnergyConnected) tTileEntity).inputEnergyFrom(tSide, false)
|| ((IEnergyConnected) tTileEntity).outputsEnergyTo(tSide, false))) return true;
if ((tTileEntity instanceof PowerLogicHost
&& ((PowerLogicHost) tTileEntity).getPowerLogic(ForgeDirection.getOrientation(aSide)) != null)
|| ((tTileEntity instanceof IEnergyConnected)
&& (((IEnergyConnected) tTileEntity).inputEnergyFrom(tSide, false)
|| ((IEnergyConnected) tTileEntity).outputsEnergyTo(tSide, false))))
return true;

// Solar Panel Compat
if (coverBehavior instanceof GT_Cover_SolarPanel) return true;
Expand Down
Loading

0 comments on commit fdde96a

Please sign in to comment.