mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-18 11:19:23 +00:00
Option to restrict fluid cell (#263)
Co-authored-by: Martin Robertz <[email protected]> Co-authored-by: Maya <[email protected]>
This commit is contained in:
4 files changed
+95
-17
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;
|
||||
|
||||
@@ -16,8 +17,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.api.FluidCraftAPI;
|
||||
import com.glodblock.github.common.storage.CellType;
|
||||
import com.glodblock.github.common.storage.FluidCellInventory;
|
||||
import com.glodblock.github.common.storage.FluidCellInventoryHandler;
|
||||
import com.glodblock.github.common.storage.IFluidCellInventory;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
@@ -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,12 +94,12 @@ 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();
|
||||
final FluidCellInventory cellInventory = (FluidCellInventory) handler.getCellInv();
|
||||
|
||||
if (cellInventory != null) {
|
||||
lines.add(
|
||||
@@ -118,7 +120,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
|
||||
+ GuiText.Of.getLocal()
|
||||
+ " "
|
||||
+ EnumChatFormatting.DARK_GREEN
|
||||
+ cellInventory.getTotalFluidTypes()
|
||||
+ cellInventory.getMaxFluidTypes()
|
||||
+ " "
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ GuiText.Types.getLocal());
|
||||
@@ -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()) {
|
||||
@@ -159,6 +161,17 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
|
||||
lines.add(GuiText.Sticky.getLocal());
|
||||
}
|
||||
}
|
||||
List<Object> restricted = handler.getRestricted();
|
||||
if (restricted != null && ((long) restricted.get(0) != 0 || (byte) restricted.get(1) != 0)) {
|
||||
lines.add(GuiText.Restricted.getLocal());
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
if ((long) restricted.get(0) != 0)
|
||||
lines.add(GuiText.MaxFluid.getLocal() + " " + nf.format((long) restricted.get(0)) + " mB");
|
||||
if ((byte) restricted.get(1) != 0)
|
||||
lines.add(GuiText.MaxTypes.getLocal() + " " + restricted.get(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,6 +226,29 @@ 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")
|
||||
+ ","
|
||||
+ "fluid";
|
||||
}
|
||||
|
||||
@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()) {
|
||||
|
||||
Reference in new issue
Block a user