Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ public abstract class ContainerMEFluidBus extends ContainerUpgradeable implement
private final MEFluidBus owner;
@GuiSync(7)
public int capacityUpgrades = 0;
@GuiSync(8)
public int tankCapacity = 0;

public ContainerMEFluidBus(final InventoryPlayer ip, final MEFluidBus te) {
super(ip, te);
this.owner = te;
this.tankSync = new FluidSyncHelper(owner.getTanks(), 0);
this.tankCapacity = ((AEFluidInventoryUpgradeable) owner.getTanks()).getCapacity();
}

@Override
Expand Down Expand Up @@ -73,6 +76,11 @@ public void detectAndSendChanges() {
if (capacityUpgrades != installedUpgrades) {
capacityUpgrades = installedUpgrades;
}

int currentTankCapacity = ((AEFluidInventoryUpgradeable) this.owner.getTanks()).getCapacity();
if (this.tankCapacity != currentTankCapacity) {
this.tankCapacity = currentTankCapacity;
}
}

super.detectAndSendChanges();
Expand All @@ -81,11 +89,22 @@ public void detectAndSendChanges() {
@Override
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
super.onUpdate(field, oldValue, newValue);
if (Platform.isClient() && field.equals("capacityUpgrades")) {

if (!Platform.isClient()) {
return;
}

if ("capacityUpgrades".equals(field)) {
this.capacityUpgrades = (int) newValue;
((AEFluidInventoryUpgradeable) this.owner.getTanks()).setCapacity(
(int) (Math.pow(4, this.capacityUpgrades + 1) * (MEFluidBus.TANK_DEFAULT_CAPACITY / 4)));
return;
}

if (!"tankCapacity".equals(field)) {
return;
}

this.tankCapacity = (int) newValue;
((AEFluidInventoryUpgradeable) this.owner.getTanks()).setCapacity(this.tankCapacity);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.mekeng.github.common.container.sync.IGasSyncContainer;
import com.mekeng.github.common.me.data.IAEGasStack;
import com.mekeng.github.util.helpers.GasSyncHelper;
import github.kasuminova.mmce.common.tile.base.MEFluidBus;
import github.kasuminova.mmce.common.tile.base.MEGasBus;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
Expand All @@ -27,10 +26,14 @@ public abstract class ContainerMEGasBus extends ContainerUpgradeable implements
@GuiSync(7)
public int capacityUpgrades = 0;

@GuiSync(8)
public int tankCapacity = 0;

public ContainerMEGasBus(final InventoryPlayer ip, final MEGasBus te) {
super(ip, te);
this.owner = te;
this.tankSync = GasSyncHelper.create(owner.getTanks(), 0);
this.tankCapacity = owner.getTankCapacity();
}

@Override
Expand Down Expand Up @@ -74,6 +77,11 @@ public void detectAndSendChanges() {
if (capacityUpgrades != installedUpgrades) {
capacityUpgrades = installedUpgrades;
}

int currentTankCapacity = this.owner.getTankCapacity();
if (this.tankCapacity != currentTankCapacity) {
this.tankCapacity = currentTankCapacity;
}
}

super.detectAndSendChanges();
Expand All @@ -82,12 +90,22 @@ public void detectAndSendChanges() {
@Override
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
super.onUpdate(field, oldValue, newValue);
if (Platform.isClient() && field.equals("capacityUpgrades")) {

if (!Platform.isClient()) {
return;
}

if ("capacityUpgrades".equals(field)) {
this.capacityUpgrades = (int) newValue;
this.owner.getTanks().setCap(
(int) (Math.pow(4, this.capacityUpgrades + 1) * (MEFluidBus.TANK_DEFAULT_CAPACITY / 4))
);
return;
}

if (!"tankCapacity".equals(field)) {
return;
}

this.tankCapacity = (int) newValue;
this.owner.getTanks().setCap(this.tankCapacity);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import github.kasuminova.mmce.common.util.AEFluidInventoryUpgradeable;
import hellfirepvp.modularmachinery.common.data.Config;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import net.minecraft.item.ItemStack;
Expand All @@ -40,7 +41,7 @@ public abstract class MEFluidBus extends MEMachineComponent implements
IGridTickable {

public static final int TANK_SLOT_AMOUNT = 9;
public static final int TANK_DEFAULT_CAPACITY = 8000;
public static int TANK_DEFAULT_CAPACITY = Config.meFluidBusBaseCapacity;

protected final IFluidStorageChannel channel = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class);
protected final ConfigManager cm = new ConfigManager(this);
Expand All @@ -53,11 +54,33 @@ public abstract class MEFluidBus extends MEMachineComponent implements
protected boolean inTick = false;

public MEFluidBus() {
this.tanks = new AEFluidInventoryUpgradeable(this, TANK_SLOT_AMOUNT, TANK_DEFAULT_CAPACITY);
this.tanks = new AEFluidInventoryUpgradeable(this, TANK_SLOT_AMOUNT, getBaseTankCapacity());
this.upgrades = new StackUpgradeInventory(proxy.getMachineRepresentation(), this, 5);
this.changedSlots = new boolean[TANK_SLOT_AMOUNT];
}

public static int getBaseTankCapacity() {
TANK_DEFAULT_CAPACITY = Math.max(1, Config.meFluidBusBaseCapacity);
return TANK_DEFAULT_CAPACITY;
}

public static int calculateTankCapacity(final int capacityUpgrades) {
long capacity = getBaseTankCapacity();
int remainingUpgrades = Math.max(0, capacityUpgrades);

// Capacity cards multiply tank size by four, so clamp before the next step would overflow.
while (remainingUpgrades > 0) {
if (capacity > Integer.MAX_VALUE / 4L) {
return Integer.MAX_VALUE;
}

capacity *= 4L;
remainingUpgrades--;
}

return (int) capacity;
}

protected synchronized int[] getNeedUpdateSlots() {
long current = world.getTotalWorldTime();
if (lastFullCheckTick + 100 < current) {
Expand Down Expand Up @@ -146,8 +169,7 @@ public void onChangeInventory(final IItemHandler inv, final int slot, final InvO
}

private void updateTankCapacity() {
tanks.setCapacity(
(int) (Math.pow(4, getInstalledUpgrades(Upgrades.CAPACITY) + 1) * (MEFluidBus.TANK_DEFAULT_CAPACITY / 4)));
tanks.setCapacity(calculateTankCapacity(getInstalledUpgrades(Upgrades.CAPACITY)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.mekeng.github.common.me.inventory.impl.GasInventory;
import com.mekeng.github.common.me.storage.IGasStorageChannel;
import github.kasuminova.mmce.common.util.GasInventoryHandler;
import hellfirepvp.modularmachinery.common.data.Config;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import mekanism.api.gas.IGasHandler;
Expand All @@ -40,7 +41,7 @@ public abstract class MEGasBus extends MEMachineComponent implements
IGridTickable {

public static final int TANK_SLOT_AMOUNT = 9;
public static final int TANK_DEFAULT_CAPACITY = 8000;
public static int TANK_DEFAULT_CAPACITY = Config.meGasBusBaseCapacity;

protected final IGasStorageChannel channel = AEApi.instance().storage().getStorageChannel(IGasStorageChannel.class);
protected final ConfigManager cm = new ConfigManager(this);
Expand All @@ -53,12 +54,34 @@ public abstract class MEGasBus extends MEMachineComponent implements
protected boolean inTick = false;

public MEGasBus() {
this.tanks = new GasInventory(TANK_SLOT_AMOUNT, TANK_DEFAULT_CAPACITY, this);
this.tanks = new GasInventory(TANK_SLOT_AMOUNT, getBaseTankCapacity(), this);
this.handler = new GasInventoryHandler(tanks);
this.upgrades = new StackUpgradeInventory(proxy.getMachineRepresentation(), this, 5);
this.changedSlots = new boolean[TANK_SLOT_AMOUNT];
}

public static int getBaseTankCapacity() {
TANK_DEFAULT_CAPACITY = Math.max(1, Config.meGasBusBaseCapacity);
return TANK_DEFAULT_CAPACITY;
}

public static int calculateTankCapacity(final int capacityUpgrades) {
long capacity = getBaseTankCapacity();
int remainingUpgrades = Math.max(0, capacityUpgrades);

// Capacity cards multiply tank size by four, so clamp before the next step would overflow.
while (remainingUpgrades > 0) {
if (capacity > Integer.MAX_VALUE / 4L) {
return Integer.MAX_VALUE;
}

capacity *= 4L;
remainingUpgrades--;
}

return (int) capacity;
}

protected synchronized int[] getNeedUpdateSlots() {
long current = world.getTotalWorldTime();
if (lastFullCheckTick + 100 < current) {
Expand All @@ -79,6 +102,10 @@ public GasInventory getTanks() {
return tanks;
}

public int getTankCapacity() {
return tanks.getTanks()[0].getMaxGas();
}

@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == Capabilities.GAS_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
Expand Down Expand Up @@ -155,8 +182,7 @@ public void onGasInventoryChanged(final IGasInventory iGasInventory, final int s
}

private void updateTankCapacity() {
tanks.setCap(
(int) (Math.pow(4, getInstalledUpgrades(Upgrades.CAPACITY) + 1) * (MEGasBus.TANK_DEFAULT_CAPACITY / 4)));
tanks.setCap(calculateTankCapacity(getInstalledUpgrades(Upgrades.CAPACITY)));
}

@Override
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/hellfirepvp/modularmachinery/common/data/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class Config {
public static boolean asyncControllerModelRender = true;
public static boolean enableDurationMultiplier = true;
public static int machineColor;
public static int meFluidBusBaseCapacity = 8000;
public static int meGasBusBaseCapacity = 8000;
public static int maxMachineParallelism = 2048;
public static int defaultFactoryMaxThread = 20;

Expand Down Expand Up @@ -108,6 +110,18 @@ private static void load() {
enableFluxNetworksIntegration = lastReadConfig.getBoolean("enable-fluxnetworks-integration", "general", true,
"When enabled, allows you to use the flux network to transfer larger amounts of energy than 2147483647.");

// Base Capacity of ME Buses
meFluidBusBaseCapacity = lastReadConfig.getInt(
"me-fluid-bus-base-capacity", "general",
8000, 1, Integer.MAX_VALUE,
"The base tank capacity of each ME Fluid Bus slot before Capacity Card multipliers are applied. The final per-slot capacity clamps at Integer.MAX_VALUE."
);
meGasBusBaseCapacity = lastReadConfig.getInt(
"me-gas-bus-base-capacity", "general",
8000, 1, Integer.MAX_VALUE,
"The base tank capacity of each ME Gas Bus slot before Capacity Card multipliers are applied. The final per-slot capacity clamps at Integer.MAX_VALUE."
);

// Parallelize Feature
machineParallelizeEnabledByDefault = lastReadConfig.getBoolean("machine-parallelize-enabled-bydefault",
"parallel-controller", true, "Whether the machine parallel recipe processing is enabled by default.");
Expand Down