Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support Void and Distribution card for cells and increase card limit for cells #262

Merged
merged 1 commit into from
Jan 17, 2025
Merged
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
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.7.18-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-521-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-523-GTNH:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.8.2:dev')
api("com.github.GTNewHorizons:GTNHLib:0.6.1:dev")
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@ public boolean isEditable(ItemStack is) {

@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 2);
return new CellUpgrades(is, 5);
}

@Override
Original file line number Diff line number Diff line change
@@ -19,7 +19,9 @@

import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.exceptions.AppEngException;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.ISaveProvider;
@@ -46,6 +48,8 @@ public class FluidCellInventory implements IFluidCellInventory {
protected IItemList<IAEFluidStack> cellFluids;
protected final NBTTagCompound tagCompound;
public static final int singleByteAmount = 256 * 8;
private boolean cardVoidOverflow = false;
private boolean cardDistribution = false;

public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
if (o == null) {
@@ -74,6 +78,21 @@ public FluidCellInventory(final ItemStack o, final ISaveProvider container) thro
}
}

final IInventory upgrades = this.getUpgradesInventory();
for (int x = 0; x < upgrades.getSizeInventory(); x++) {
final ItemStack is = upgrades.getStackInSlot(x);
if (is != null && is.getItem() instanceof IUpgradeModule) {
final Upgrades u = ((IUpgradeModule) is.getItem()).getType(is);
if (u != null) {
switch (u) {
case VOID_OVERFLOW -> cardVoidOverflow = true;
case DISTRIBUTION -> cardDistribution = true;
default -> {}
}
}
}
}

this.container = container;
this.tagCompound = Platform.openNbtData(o);
this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG);
@@ -180,6 +199,25 @@ public long getRemainingFluidCount() {
return remaining > 0 ? remaining : 0;
}

@Override
public long getRemainingFluidCountDist(IAEFluidStack l) {
long remaining;
long types = 0;
for (int i = 0; i < this.getTotalFluidTypes(); i++) {
if (this.getConfigInventory().getStackInSlot(i) != null) {
types++;
}
}
if (types == 0) types = this.getTotalFluidTypes();
if (l != null) {
remaining = (((this.getTotalBytes() / types) - (int) Math.ceil((double) l.getStackSize() / singleByteAmount)
- getBytesPerType()) * singleByteAmount) + (singleByteAmount - l.getStackSize() % singleByteAmount);
} else {
remaining = ((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount;
}
return remaining > 0 ? remaining : 0;
}

@Override
public int getUnusedFluidCount() {
final int div = (int) (this.getStoredFluidCount() % singleByteAmount);
@@ -293,9 +331,17 @@ public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActio
final IAEFluidStack l = this.getCellFluids().findPrecise(input);

if (l != null) {
final long remainingFluidSlots = this.getRemainingFluidCount();
long remainingFluidSlots;
if (cardDistribution) {
remainingFluidSlots = this.getRemainingFluidCountDist(l);
} else {
remainingFluidSlots = this.getRemainingFluidCount();
}

if (remainingFluidSlots < 0) {
if (remainingFluidSlots <= 0) {
if (cardVoidOverflow) {
return null;
}
return input;
}

@@ -320,8 +366,13 @@ public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActio

if (this.canHoldNewFluid()) // room for new type, and for at least one item!
{
final long remainingFluidCount = this.getRemainingFluidCount()
- ((long) this.getBytesPerType() * singleByteAmount);
long remainingFluidCount;
if (cardDistribution) {
remainingFluidCount = this.getRemainingFluidCountDist(null);
} else {
remainingFluidCount = this.getRemainingFluidCount()
- ((long) this.getBytesPerType() * singleByteAmount);
}

if (remainingFluidCount > 0) {
if (input.getStackSize() > remainingFluidCount) {
Original file line number Diff line number Diff line change
@@ -60,6 +60,11 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
*/
long getRemainingFluidCount();

/**
* @return how many more fluids can be stored with Distribution card.
*/
long getRemainingFluidCountDist(IAEFluidStack l);

/**
* @return how many fluid types remain.
*/
27 changes: 27 additions & 0 deletions src/main/java/com/glodblock/github/proxy/CommonProxy.java
Original file line number Diff line number Diff line change
@@ -76,6 +76,15 @@ public void postInit(FMLPostInitializationEvent event) {
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096K), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384K), 1);

Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL1K), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL4K), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL16K), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL64K), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL256K), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL1024K), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096K), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384K), 1);

Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL1KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL4KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16KM), 1);
@@ -85,6 +94,24 @@ public void postInit(FMLPostInitializationEvent event) {
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096KM), 1);
Upgrades.STICKY.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384KM), 1);

Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL1KM), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL4KM), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL16KM), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL64KM), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL256KM), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL1024KM), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096KM), 1);
Upgrades.VOID_OVERFLOW.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384KM), 1);

Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL1KM), 1);
Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL4KM), 1);
Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL16KM), 1);
Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL64KM), 1);
Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL256KM), 1);
Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL1024KM), 1);
Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL4096KM), 1);
Upgrades.DISTRIBUTION.registerItem(new ItemStack(ItemAndBlockHolder.CELL16384KM), 1);

Upgrades.FAKE_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
Upgrades.FAKE_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
Upgrades.FAKE_CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE_P2P), 1);