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 Fluid Void Cell #234

Merged
merged 10 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -0,0 +1,135 @@
package com.glodblock.github.common.item;

import java.util.EnumSet;
import java.util.List;

import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;

import com.glodblock.github.FluidCraft;
import com.glodblock.github.api.FluidCraftAPI;
import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.NameConst;

import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.Platform;
import cpw.mods.fml.common.registry.GameRegistry;

public class ItemDefectiveSingularityFluidStorageCell extends AEBaseItem
implements IStorageFluidCell, IRegister<ItemDefectiveSingularityFluidStorageCell> {

public ItemDefectiveSingularityFluidStorageCell() {
super();
setUnlocalizedName(NameConst.ITEM_DEFECTIVE_SINGULARITY_FLUID_STORAGE);
setTextureName(FluidCraft.resource(NameConst.ITEM_DEFECTIVE_SINGULARITY_FLUID_STORAGE).toString());
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
}

@Override
public ItemDefectiveSingularityFluidStorageCell register() {
GameRegistry.registerItem(this, NameConst.ITEM_DEFECTIVE_SINGULARITY_FLUID_STORAGE, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}

@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines,
final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell()
.getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inventory instanceof final IFluidCellInventoryHandler handler) {
lines.add(GuiText.VoidCellTooltip.getLocal());
lines.add(0 + " " + GuiText.Of.getLocal() + " \u00A7k9999\u00A77 " + GuiText.BytesUsed.getLocal());
final IFluidCellInventory inv = handler.getCellInv();
if (GuiScreen.isShiftKeyDown()) {
lines.add(GuiText.Filter.getLocal() + ": ");
for (int i = 0; i < inv.getConfigInventory().getSizeInventory(); ++i) {
ItemStack s = inv.getConfigInventory().getStackInSlot(i);
if (s != null) lines.add(s.getDisplayName());
}
}
}
}

@Override
public long getBytes(ItemStack cellItem) {
return 0;
}

@Override
public int getBytesPerType(ItemStack cellItem) {
return 0;
}

@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
return requestedAddition == null || requestedAddition.getFluid() == null
|| FluidCraftAPI.instance().isBlacklistedInStorage(requestedAddition.getFluid().getClass());
}

@Override
public boolean storableInStorageCell() {
return true;
}

@Override
public boolean isStorageCell(ItemStack i) {
return true;
}

@Override
public double getIdleDrain(ItemStack is) {
return 0;
}

@Override
public int getTotalTypes(ItemStack cellItem) {
return 0;
}

@Override
public boolean isEditable(ItemStack is) {
return true;
}

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

@Override
public IInventory getConfigInventory(ItemStack is) {
return new CellConfig(is);
}

@Override
public FuzzyMode getFuzzyMode(ItemStack is) {
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
try {
return FuzzyMode.valueOf(fz);
} catch (final Throwable t) {
return FuzzyMode.IGNORE_ALL;
}
}

@Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.glodblock.github.common.storage;

import java.util.List;

import javax.annotation.Nonnull;

import net.minecraft.item.ItemStack;

import appeng.api.config.Actionable;
import appeng.api.exceptions.AppEngException;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.ISaveProvider;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;

public class DefectiveSingularityCellInventory extends FluidCellInventory {

public DefectiveSingularityCellInventory(ItemStack o, ISaveProvider container) throws AppEngException {
super(o, container);
}

@Override
public boolean canHoldNewFluid() {
return true;
}

@Override
public long getTotalBytes() {
return 0;
}

@Override
public long getFreeBytes() {
return 0;
}

@Override
public long getUsedBytes() {
return 0;
}

@Override
public long getTotalFluidTypes() {
return 63;
}

@Override
public long getStoredFluidCount() {
return 0;
}

@Override
public long getStoredFluidTypes() {
return 0;
}

@Override
public long getRemainingFluidTypes() {
return 63;
}

@Override
public long getRemainingFluidCount() {
return Long.MAX_VALUE;
}

@Override
public int getUnusedFluidCount() {
return Integer.MAX_VALUE;
}

@Override
public int getStatusForCell() {
return 1;
}

@Override
protected void loadCellFluids() {}

@Override
protected IItemList<IAEFluidStack> getCellFluids() {
return null;
}

@Override
public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActionSource src) {
if (input == null || input.getStackSize() == 0) {
return null;
}
if (this.cellType.isBlackListed(this.cellItem, input)) {
return input;
}
return null;
}

@Override
public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) {
return null;
}

@Override
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out, int iteration) {
return out;
}

@Override
public IAEFluidStack getAvailableItem(@Nonnull IAEFluidStack request, int iteration) {
return null;
}

@Override
public List<IAEFluidStack> getContents() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraftforge.fluids.FluidStack;

import com.glodblock.github.common.item.ItemBaseInfinityStorageCell;
import com.glodblock.github.common.item.ItemDefectiveSingularityFluidStorageCell;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInventory;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;

Expand Down Expand Up @@ -86,6 +87,8 @@ public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, fina
return new FluidCellInventoryHandler(new CreativeFluidCellInventory(o, container2));
} else if (o.getItem() instanceof ProxyFluidStorageCell) {
return new FluidCellInventoryHandler(new ProxyFluidCellInventory(o, container2));
} else if (o.getItem() instanceof ItemDefectiveSingularityFluidStorageCell) {
return new FluidCellInventoryHandler(new DefectiveSingularityCellInventory(o, container2));
} else {
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.glodblock.github.common.item.ItemBasicFluidStorageCell;
import com.glodblock.github.common.item.ItemBasicFluidStoragePart;
import com.glodblock.github.common.item.ItemCreativeFluidStorageCell;
import com.glodblock.github.common.item.ItemDefectiveSingularityFluidStorageCell;
import com.glodblock.github.common.item.ItemEnergyCard;
import com.glodblock.github.common.item.ItemFluidConversionMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
Expand Down Expand Up @@ -140,6 +141,8 @@ public static void init() {}
16384,
5,
600000D).register();
public static ItemDefectiveSingularityFluidStorageCell FLUID_VOID_CELL = new ItemDefectiveSingularityFluidStorageCell()
.register();
public static ItemCreativeFluidStorageCell CREATIVE_CELL = new ItemCreativeFluidStorageCell().register();
public static ItemInfinityWaterStorageCell INFINITY_WATER_CELL = new ItemInfinityWaterStorageCell().register();
public static ItemBasicFluidStoragePart CELL_PART = new ItemBasicFluidStoragePart().register();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/glodblock/github/util/NameConst.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class NameConst {
public static final String ITEM_MULTI_FLUID_STORAGE = "multi_fluid_storage";
public static final String ITEM_QUANTUM_FLUID_STORAGE = ITEM_FLUID_STORAGE + ".quantum";
public static final String ITEM_SINGULARITY_FLUID_STORAGE = ITEM_FLUID_STORAGE + ".singularity";
public static final String ITEM_DEFECTIVE_SINGULARITY_FLUID_STORAGE = ITEM_SINGULARITY_FLUID_STORAGE + ".defective";
public static final String ITEM_ARTIFICIAL_UNIVERSE_STORAGE = ITEM_FLUID_STORAGE + ".Universe";
public static final String ITEM_INFINITY_FLUID_STORAGE = ITEM_FLUID_STORAGE + ".infinity";
public static final String ITEM_INFINITY_WATER_FLUID_STORAGE = ITEM_INFINITY_FLUID_STORAGE + ".water";
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/ae2fc/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ item.multi_fluid_storage.4096.name=%s4096k%s ME Multi-Fluid Storage Cell
item.multi_fluid_storage.16384.name=%s16384k%s ME Multi-Fluid Storage Cell
item.fluid_storage.quantum.name=ME Fluid Quantum Storage Cell
item.fluid_storage.singularity.name=ME Fluid Digital Singularity Storage Cell
item.fluid_storage.singularity.defective.name=ME Defective Fluid Digital Singularity Storage Cell
item.fluid_storage.Universe.name=ME Fluid Artificial Universe Storage Cell
item.fluid_storage.infinity.water.name=ME Fluid Infinity Water Storage Cell
item.fluid_part.0.name=%s1k%s ME Fluid Storage Component
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.