mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
first commit
This commit is contained in:
1 parent
188d1ff4c1
commit
913088788f
1 file changed
+28
-6
@@ -50,6 +50,8 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
public static final int singleByteAmount = 256 * 8;
|
||||
private boolean cardVoidOverflow = false;
|
||||
private boolean cardDistribution = false;
|
||||
private byte restrictionTypes = 0;
|
||||
private long restrictionLong = 0;
|
||||
|
||||
public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
|
||||
if (o == null) {
|
||||
@@ -97,6 +99,8 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
this.tagCompound = Platform.openNbtData(o);
|
||||
this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG);
|
||||
this.storedFluidCount = this.tagCompound.getLong(FLUID_COUNT_TAG);
|
||||
this.restrictionTypes = this.tagCompound.getByte("cellRestrictionTypes");
|
||||
this.restrictionLong = this.tagCompound.getLong("cellRestrictionAmount");
|
||||
this.cellFluids = null;
|
||||
}
|
||||
|
||||
@@ -151,8 +155,8 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
public boolean canHoldNewFluid() {
|
||||
final long bytesFree = this.getFreeBytes();
|
||||
return (bytesFree > this.getBytesPerType()
|
||||
|| (bytesFree == this.getBytesPerType() && this.getUnusedFluidCount() > 0))
|
||||
&& this.getRemainingFluidTypes() > 0;
|
||||
|| (bytesFree == this.getBytesPerType() && this.getUnusedFluidCount() > 0))
|
||||
&& this.getRemainingFluidTypes() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -173,6 +177,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public long getTotalFluidTypes() {
|
||||
if (restrictionTypes > 0) return restrictionTypes;
|
||||
return this.cellType.getTotalTypes(this.cellItem);
|
||||
}
|
||||
|
||||
@@ -195,6 +200,11 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidCount() {
|
||||
if (restrictionLong > 0) {
|
||||
return Math.min(
|
||||
restrictionLong - this.getStoredFluidCount(),
|
||||
this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount());
|
||||
}
|
||||
final long remaining = this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount();
|
||||
return remaining > 0 ? remaining : 0;
|
||||
}
|
||||
@@ -210,10 +220,22 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
}
|
||||
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);
|
||||
if (restrictionLong > 0) {
|
||||
remaining = Math.min((restrictionLong / types) - l.getStackSize(), this.getUnusedFluidCount());
|
||||
} else {
|
||||
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;
|
||||
if (restrictionLong > 0) {
|
||||
remaining = Math.min(
|
||||
restrictionLong / types,
|
||||
((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount);
|
||||
} else {
|
||||
remaining = ((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount;
|
||||
}
|
||||
}
|
||||
return remaining > 0 ? remaining : 0;
|
||||
}
|
||||
@@ -371,7 +393,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
remainingFluidCount = this.getRemainingFluidCountDist(null);
|
||||
} else {
|
||||
remainingFluidCount = this.getRemainingFluidCount()
|
||||
- ((long) this.getBytesPerType() * singleByteAmount);
|
||||
- ((long) this.getBytesPerType() * singleByteAmount);
|
||||
}
|
||||
|
||||
if (remainingFluidCount > 0) {
|
||||
|
||||
Reference in new issue
Block a user