mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 09:34:42 +00:00
second commit
This commit is contained in:
1 parent
913088788f
commit
8315db5ee9
2 files changed
+37
-14
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,6 +34,7 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.ICellRestriction;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.CellConfig;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
@@ -41,7 +43,7 @@ import appeng.util.IterationCounter;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
|
||||
public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluidCell {
|
||||
public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluidCell, ICellRestriction {
|
||||
|
||||
protected CellType component;
|
||||
protected long totalBytes;
|
||||
@@ -92,9 +94,9 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
|
||||
final boolean displayMoreInfo) {
|
||||
final boolean displayMoreInfo) {
|
||||
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
|
||||
.getCellInventory(stack, null, StorageChannel.FLUIDS);
|
||||
.getCellInventory(stack, null, StorageChannel.FLUIDS);
|
||||
|
||||
if (inventory instanceof final FluidCellInventoryHandler handler) {
|
||||
final IFluidCellInventory cellInventory = handler.getCellInv();
|
||||
@@ -144,7 +146,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
|
||||
|
||||
if (handler.isPreformatted()) {
|
||||
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included
|
||||
: GuiText.Excluded).getLocal();
|
||||
: GuiText.Excluded).getLocal();
|
||||
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal());
|
||||
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
@@ -213,6 +215,27 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
|
||||
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCellData(ItemStack is) {
|
||||
return totalBytes + ","
|
||||
+ this.getTotalTypes(null)
|
||||
+ ","
|
||||
+ this.getBytesPerType(null)
|
||||
+ ","
|
||||
+ 256 * 8
|
||||
+ ","
|
||||
+ Platform.openNbtData(is).getByte("cellRestrictionTypes")
|
||||
+ ","
|
||||
+ Platform.openNbtData(is).getLong("cellRestrictionAmount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCellRestriction(ItemStack is, String newData) {
|
||||
List<String> data = Arrays.asList(newData.split(",", 2));
|
||||
Platform.openNbtData(is).setByte("cellRestrictionTypes", Byte.parseByte(data.get(0)));
|
||||
Platform.openNbtData(is).setLong("cellRestrictionAmount", Long.parseLong(data.get(1)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
|
||||
if (player.isSneaking()) {
|
||||
|
||||
@@ -155,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
|
||||
@@ -202,8 +202,8 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
public long getRemainingFluidCount() {
|
||||
if (restrictionLong > 0) {
|
||||
return Math.min(
|
||||
restrictionLong - this.getStoredFluidCount(),
|
||||
this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount());
|
||||
restrictionLong - this.getStoredFluidCount(),
|
||||
this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount());
|
||||
}
|
||||
final long remaining = this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount();
|
||||
return remaining > 0 ? remaining : 0;
|
||||
@@ -224,15 +224,15 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
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);
|
||||
- (int) Math.ceil((double) l.getStackSize() / singleByteAmount)
|
||||
- getBytesPerType()) * singleByteAmount)
|
||||
+ (singleByteAmount - l.getStackSize() % singleByteAmount);
|
||||
}
|
||||
} else {
|
||||
if (restrictionLong > 0) {
|
||||
remaining = Math.min(
|
||||
restrictionLong / types,
|
||||
((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount);
|
||||
restrictionLong / types,
|
||||
((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount);
|
||||
} else {
|
||||
remaining = ((this.getTotalBytes() / types) - this.getBytesPerType()) * singleByteAmount;
|
||||
}
|
||||
@@ -393,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