update wireless interface recipe

This commit is contained in:
asdflj committed 2023-02-10 16:19:34 +08:00
1 parent 8d14239c53
commit 56b8683686
9 files changed
+237 -7

No files matched your search

@@ -0,0 +1,146 @@
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 net.minecraft.util.StatCollector;
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.items.AEBaseItem;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
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.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemCreativeFluidStorageCell extends AEBaseItem
implements IStorageFluidCell, IRegister<ItemCreativeFluidStorageCell> {
public ItemCreativeFluidStorageCell() {
super();
setUnlocalizedName(NameConst.ITEM_CREATIVE_FLUID_STORAGE);
setTextureName(FluidCraft.resource(NameConst.ITEM_CREATIVE_FLUID_STORAGE).toString());
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
}
@Override
public int getBytes(ItemStack cellItem) {
return 0;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
return 0;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition) {
if (Config.blacklistEssentiaGas && ModAndClassUtil.ThE && requestedAddition != null) {
return ModAndClassUtil.essentiaGas.isInstance(requestedAddition.getFluid());
}
return false;
}
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(ItemStack i) {
return true;
}
@Override
public double getIdleDrain() {
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 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 IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
final IFluidCellInventory cellInventory = handler.getCellInv();
if (GuiScreen.isCtrlKeyDown()) {
if (cellInventory.getContents().size() > 0) {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_CONTENTS));
for (IAEFluidStack fluid : cellInventory.getContents()) {
if (fluid != null) {
lines.add(String.format(" %s", fluid.getFluidStack().getLocalizedName()));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
}
}
@Override
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode) {
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
@Override
public ItemCreativeFluidStorageCell register() {
GameRegistry.registerItem(this, NameConst.ITEM_CREATIVE_FLUID_STORAGE, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -0,0 +1,70 @@
package com.glodblock.github.common.storage;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.AEApi;
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 com.glodblock.github.util.Util;
public class CreativeFluidCellInventory extends FluidCellInventory {
public CreativeFluidCellInventory(ItemStack o, ISaveProvider container) throws AppEngException {
super(o, container);
}
@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;
}
if (this.getCellFluids().findPrecise(input) != null) {
return null;
} else {
return input;
}
}
@Override
public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) {
if (request == null) {
return null;
}
if (this.getCellFluids().findPrecise(request) != null) {
return request.copy();
} else {
return null;
}
}
@Override
protected void loadCellFluids() {
if (this.cellFluids == null) {
this.cellFluids = AEApi.instance().storage().createFluidList();
}
this.cellFluids.resetStatus(); // clears totals and stuff.
IInventory inv = this.cellType.getConfigInventory(this.cellItem);
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack is = inv.getStackInSlot(i);
if (Util.FluidUtil.isFluidContainer(is)) {
FluidStack fs = Util.getFluidFromItem(is);
if (fs == null) continue;
IAEFluidStack iaeFluidStack = Util.FluidUtil.createAEFluidStack(fs);
if (this.cellFluids.findPrecise(iaeFluidStack) == null) {
iaeFluidStack.setStackSize(Integer.MAX_VALUE);
this.cellFluids.add(iaeFluidStack);
}
}
}
}
}
@@ -22,21 +22,23 @@ import appeng.api.storage.data.IItemList;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.item.ItemCreativeFluidStorageCell;
public class FluidCellInventory implements IFluidCellInventory {
private static final String FLUID_TYPE_TAG = "ft";
private static final String FLUID_COUNT_TAG = "fc";
private static final String FLUID_SLOT = "#";
private static final String FLUID_SLOT_COUNT = "@";
private IStorageFluidCell cellType;
protected IStorageFluidCell cellType;
private static String[] fluidSlots;
private static String[] fluidSlotCount;
private final ItemStack cellItem;
protected final ItemStack cellItem;
private final ISaveProvider container;
private final int MAX_TYPE = 63;
private long storedFluidCount;
private short storedFluids;
private IItemList<IAEFluidStack> cellFluids;
protected IItemList<IAEFluidStack> cellFluids;
private final NBTTagCompound tagCompound;
public static final int singleByteAmount = 256 * 8;
@@ -76,7 +78,11 @@ public class FluidCellInventory implements IFluidCellInventory {
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2) {
try {
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
if (o.getItem() instanceof ItemCreativeFluidStorageCell) {
return new FluidCellInventoryHandler(new CreativeFluidCellInventory(o, container2));
} else {
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
}
} catch (final AppEngException e) {
return null;
}
@@ -185,7 +191,7 @@ public class FluidCellInventory implements IFluidCellInventory {
return 3;
}
private void loadCellFluids() {
protected void loadCellFluids() {
if (this.cellFluids == null) {
this.cellFluids = AEApi.instance().storage().createFluidList();
}
@@ -203,7 +209,7 @@ public class FluidCellInventory implements IFluidCellInventory {
}
}
private IItemList<IAEFluidStack> getCellFluids() {
protected IItemList<IAEFluidStack> getCellFluids() {
if (this.cellFluids == null) {
this.loadCellFluids();
}
@@ -52,6 +52,7 @@ public class ItemAndBlockHolder {
.register();
public static ItemBasicFluidStorageCell CELL16384K = new ItemBasicFluidStorageCell(CellType.Cell16384kPart, 16384)
.register();
public static ItemCreativeFluidStorageCell CREATIVE_CELL = new ItemCreativeFluidStorageCell().register();
public static ItemBasicFluidStoragePart CELL_PART = new ItemBasicFluidStoragePart().register();
public static void loadSetting() {
@@ -91,6 +91,10 @@ public class RecipeLoader implements Runnable {
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"),
1,
380);
public static final ItemStack AE2_INTERFACE_TERMINAL = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"),
1,
480);
public static final ItemStack AE2_CRAFTING_CP_UNIT = new ItemStack(
GameRegistry.findItem("appliedenergistics2", "tile.BlockCraftingUnit"),
1,
@@ -142,7 +146,7 @@ public class RecipeLoader implements Runnable {
GameRegistry.addShapelessRecipe(INTERFACE.stack(), FLUID_INTERFACE.stack());
GameRegistry.addShapelessRecipe(WIRELESS_FLUID_TERM.stack(), AE2_WIRELESS_TERMINAL, BUCKET);
GameRegistry.addShapelessRecipe(WIRELESS_PATTERN_TERM.stack(), WIRELESS_FLUID_TERM, FLUID_TERMINAL);
GameRegistry.addShapelessRecipe(WIRELESS_INTERFACE_TERM.stack(), AE2_WIRELESS_TERMINAL, AE2_INTERFACE);
GameRegistry.addShapelessRecipe(WIRELESS_INTERFACE_TERM.stack(), AE2_WIRELESS_TERMINAL, AE2_INTERFACE_TERMINAL);
GameRegistry
.addRecipe(new ShapedOreRecipe(CERTUS_QUARTZ_TANK.stack(), "GGG", "G G", "GGG", 'G', AE2_QUARTZ_GLASS));
GameRegistry.addShapelessRecipe(FLUID_AUTO_FILLER.stack(), FLUID_TERMINAL, ENCODER);
@@ -35,6 +35,7 @@ public class NameConst {
public static final String ITEM_PART_FLUID_LEVEL_EMITTER = "part_fluid_level_emitter";
public static final String ITEM_FLUID_PACKET = "fluid_packet";
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
public static final String ITEM_CREATIVE_FLUID_STORAGE = "creative_" + ITEM_FLUID_STORAGE;
public static final String ITEM_FLUID_PORTABLE_CELL = "portable_fluid_cell";
public static final String ITEM_WIRELESS_FLUID_TERMINAL = "wireless_fluid_terminal";
public static final String ITEM_WIRELESS_INTERFACE_TERMINAL = "wireless_interface_terminal";