Compare commits

..
Author SHA1 Message Date
Martin Robertz 9ff65a4fce Merge remote-tracking branch 'origin/quartz_tank_cell_fix' into dev 2023-04-30 17:13:34 +02:00
Firenoo 39e245b488 Fix FluidContainerRegistry interactions w/ Certus Quart Tank
The Certus Quartz Tank previously did not consider the
FluidContainerRegistry API for fluid containers, so fluid containers
that implemented that (like ic2 cells) were voided when filling the
tank.

Signed-off-by: Firenoo <[email protected]>
2023-04-30 08:02:06 -07:00
Martin Robertz 273c91b816 Merge remote-tracking branch 'origin/cell_workbench' into dev 2023-04-30 11:47:33 +02:00
Martin Robertz acfdd9087c Merge remote-tracking branch 'origin/export_fix_a' into dev 2023-04-30 11:47:14 +02:00
Firenoo 54bdeabd99 Allow all 63 partition items to be used for fluid cells
Previously, only one partition item was allowed. This fix will have
the cell consider all 63 slots. If you configure more than 1 or 5
cell slots, it works as expected - up to 1 or 5 of the whitelisted
fluids can be stored at a time.

This will degrade performance slightly.

Signed-off-by: Firenoo <[email protected]>
2023-04-29 20:46:52 -07:00
Firenoo df045ec1a8 Fix fluid export bus voiding fluids on crafting only mode
The Fluid Export Bus was voiding fluids on craft only mode because it
tried to craft it, and decided to continue with the normal export logic:
Extract fluid from ME system and fill the tank.

Unfortunately, there was a condition that prevented the extracted fluid
from going anywhere depending on craft only mode, so it got voided.

Commit fixes this by skipping the normal extract logic if set to craft
only. It also removes fluid simulation (we will see if they were actually
needed. Initial tests indicate no), which should improve performance by
a little bit.

Signed-off-by: Firenoo <[email protected]>
2023-04-29 19:59:03 -07:00
Martin Robertz 4e1983b87f Merge remote-tracking branch 'origin/byebyeEC2' into dev 2023-04-29 20:14:07 +02:00
firenoo 77ec41812d Add null check for tanks (#118)
* Add null check for tanks

Some IFluidHandlers return null for getTankInfo(), so a null check is needed.

* spotless apply
2023-04-28 19:19:53 +02:00
Firenoo 50c4015d54 apply spotless
too lazy to rebase
2023-04-28 10:01:34 -07:00
Firenoo b7b68515f1 Add more tooltip help and cell handler for void cell 2023-04-28 10:01:34 -07:00
Firenoo 3245de6ba1 Add handlers for deprecated item cells
Now the placeholder should work automatically in a drive.

The void cell is still a WIP.
2023-04-28 10:01:33 -07:00
Firenoo 3e2a0482e9 Fixed some storage cell conversion issues
The placeholders did not transfer NBT data properly
2023-04-28 10:01:33 -07:00
Firenoo 6b9e500655 Finish basic item replacement code
- parts work
- items are remapped properly, and converted when they enter the player inventory
2023-04-28 10:01:32 -07:00
Firenoo 709805b4c6 API changes to make room for Extra Cells fluid placeholder 2023-04-28 10:01:32 -07:00
Firenoo bfaec12011 set config "replaceEC2" to default true 2023-04-28 10:01:32 -07:00
Firenoo 7ad5b9d297 EC2 Deprecation: Part 3 - Parts
Parts are deprecated.
2023-04-28 10:01:31 -07:00
Firenoo 68c0abba95 EC2 deprecation: Part 2 - Blocks 2023-04-28 10:01:31 -07:00
Firenoo 682489de18 EC2 deprecation: Part 1 - Items
Laying the groundwork for absorbing EC2 mappings.
2023-04-28 10:01:28 -07:00
Martin Robertz 258465a654 fix (#117) 2023-04-26 22:38:09 +02:00
Martin Robertz adbc077736 Update dependencies.gradle 2023-04-26 22:13:49 +02:00
Martin Robertz adf317d6a1 update dep file 2023-04-26 21:36:16 +02:00
firenoo 508f6e5d64 Add null check when determining potential tanks to import (#116)
It seems that implementers of IFluidHandler sometimes return null
in `getTankInfo()`, so this adds a check for that before doing the
bus work.
2023-04-26 21:14:40 +02:00
34 changed files with 1515 additions and 64 deletions

No files matched your search

+16 -16
View File
@@ -1,27 +1,27 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.3.39-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-180-GTNH:dev')
api('com.github.GTNewHorizons:NotEnoughItems:2.3.45-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-195-GTNH:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.5.22:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.32:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.9.3:dev")
api('com.github.GTNewHorizons:waila:1.5.24:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.33:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.9.0:dev")
compileOnly('com.github.GTNewHorizons:ForestryMC:4.5.6:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.49:dev')
compileOnly('com.github.GTNewHorizons:EnderCore:0.2.11:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.41.216:dev')
compileOnly('com.github.GTNewHorizons:StructureLib:1.2.0-beta.2:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.4.11:dev')
compileOnly('com.github.GTNewHorizons:EnderCore:0.2.13:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.42.82:dev')
compileOnly('com.github.GTNewHorizons:StructureLib:1.2.6:dev')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.github.GTNewHorizons:AppleCore:3.2.5:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.28:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:AppleCore:3.2.10:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.33:dev') { transitive = false }
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.8.0.5-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.3.27-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.191:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.9.1-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.4.1-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.8.42:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:KekzTech:0.6.25:dev')
api('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
compileOnly('com.github.GTNewHorizons:KekzTech:0.7.8:dev')
api('com.github.GTNewHorizons:Baubles:1.0.1.16:dev')
}
@@ -6,6 +6,7 @@ import appeng.api.AEApi;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.FluidCellHandler;
import com.glodblock.github.crossmod.extracells.EC2Replacer;
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
import com.glodblock.github.crossmod.waila.WailaInit;
import com.glodblock.github.inventory.InventoryHandler;
@@ -93,6 +94,13 @@ public class FluidCraft {
SPacketMEUpdateBuffer.disable();
}
@Mod.EventHandler
public void missingMappings(FMLMissingMappingsEvent event) {
if (!ModAndClassUtil.EC2 && Config.replaceEC2) {
EC2Replacer.replaceExtraCells(event);
}
}
@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent event) {}
@@ -109,7 +109,7 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void renderToolTip(ItemStack stack, int x, int y) {
public void renderToolTip(ItemStack stack, int x, int y) {
List list;
if (stack.getItem() instanceof ItemFluidPacket) {
FluidStack fluid = ItemFluidPacket.getFluidStack(stack);
@@ -19,6 +19,7 @@ public class Config {
public static double portableCellBattery;
public static int packetSize;
public static int packetRate;
public static boolean replaceEC2;
public static void run() {
loadCategory();
@@ -60,6 +61,11 @@ public class Config {
.get("Fluid Craft for AE2", "packetRate", 50, "Period at which packets are dispatched, in ms.")
.getInt();
if (packetRate <= 0) packetRate = 50;
replaceEC2 = Config.getBoolean(
"Fluid Craft for AE2",
"replaceEC2",
true,
"Set true to handle missing item mappings from EC2. Note to work properly, you must have all relevant parts.");
if (Config.hasChanged()) Config.save();
}
@@ -131,12 +131,19 @@ public class BlockCertusQuartzTank extends BaseBlockContainer implements IRegist
if (liquid != null) {
int amountFilled = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
if (amountFilled != 0 && !entityplayer.capabilities.isCreativeMode && current.getItem() != null) {
ItemStack empty;
if (FluidContainerRegistry.isContainer(current)) {
empty = FluidContainerRegistry.drainFluidContainer(current);
} else {
// Try this as a fallback.
entityplayer.inventory.addItemStackToInventory(current.getItem().getContainerItem(current));
empty = current.getItem().getContainerItem(current);
}
if (current.stackSize > 1) {
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1;
entityplayer.inventory.addItemStackToInventory(current.getItem().getContainerItem(current));
entityplayer.inventory.addItemStackToInventory(empty);
} else {
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = current.getItem()
.getContainerItem(current);
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = empty;
}
}
return true;
@@ -175,7 +175,7 @@ public abstract class FCBaseItemCell extends AEBaseItem implements IStorageFluid
}
@Override
public double getIdleDrain() {
public double getIdleDrain(ItemStack is) {
return this.idleDrain;
}
@@ -71,7 +71,7 @@ public class ItemCreativeFluidStorageCell extends AEBaseItem
}
@Override
public double getIdleDrain() {
public double getIdleDrain(ItemStack is) {
return 0;
}
@@ -150,7 +150,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
}
@Override
public double getIdleDrain() {
public double getIdleDrain(ItemStack is) {
return 0.5;
}
@@ -119,40 +119,36 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
IAEFluidStack fluid = AEFluidStack
.create(ItemFluidPacket.getFluidStack(getInv().getStackInSlot(slotToExport)));
if (fluid != null) {
boolean isAllowed = true;
final IAEFluidStack toExtract = fluid.copy();
toExtract.setStackSize(this.calculateAmountToSend());
fluid.setStackSize(this.calculateAmountToSend());
if (this.craftOnly()) {
isAllowed = this.craftingTracker.handleCrafting(
this.didSomething = this.craftingTracker.handleCrafting(
i,
toExtract.getStackSize(),
ItemFluidDrop.newAeStack(toExtract),
fluid.getStackSize(),
ItemFluidDrop.newAeStack(fluid),
destination,
this.getTile().getWorldObj(),
this.getProxy().getGrid(),
cg,
this.source);
continue;
}
int space = fh.fill(this.getSide().getOpposite(), toExtract.getFluidStack(), false);
toExtract.setStackSize(space);
final IAEFluidStack real = inv.extractItems(toExtract, Actionable.MODULATE, this.source);
if (real != null && isAllowed) {
// Extract from the ME system.
final IAEFluidStack real = inv.extractItems(fluid, Actionable.MODULATE, this.source);
if (real != null) {
int realInserted = fh.fill(this.getSide().getOpposite(), real.getFluidStack(), true);
if (realInserted < real.getStackSize()) {
toExtract.setStackSize(real.getStackSize() - realInserted);
inv.injectItems(toExtract, Actionable.MODULATE, this.source);
// Could not use the entirety of the amount we extracted, so put it back.
fluid.setStackSize(real.getStackSize() - realInserted);
inv.injectItems(fluid, Actionable.MODULATE, this.source);
}
this.fluidToSend -= realInserted;
didSomething = true;
} else if (this.isCraftingEnabled()) {
this.craftingTracker.handleCrafting(
// If we didn't send anything, try crafting it if we can.
this.didSomething = this.craftingTracker.handleCrafting(
i,
toExtract.getStackSize(),
ItemFluidDrop.newAeStack(toExtract),
fluid.getStackSize(),
ItemFluidDrop.newAeStack(fluid),
destination,
this.getTile().getWorldObj(),
this.getProxy().getGrid(),
@@ -68,11 +68,15 @@ public class PartFluidImportBus extends FCSharedFluidBus {
if (te instanceof IFluidHandler) {
try {
final IFluidHandler fh = (IFluidHandler) te;
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
FluidTankInfo[] tanksInfo = fh.getTankInfo(this.getSide().getOpposite());
if (tanksInfo == null) {
return TickRateModulation.SLOWER;
}
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
int maxDrain = this.calculateAmountToSend();
boolean drained = false;
FluidTankInfo[] tanksInfo = fh.getTankInfo(this.getSide().getOpposite());
for (FluidTankInfo tankInfo : tanksInfo) {
if (tankInfo.fluid == null) {
continue;
@@ -69,6 +69,6 @@ public class FluidCellHandler implements ICellHandler {
@Override
public double cellIdleDrain(final ItemStack is, final IMEInventory handler) {
final IFluidCellInventory inv = ((IFluidCellInventoryHandler) handler).getCellInv();
return inv.getIdleDrain();
return inv.getIdleDrain(is);
}
}
@@ -23,23 +23,25 @@ import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.item.ItemCreativeFluidStorageCell;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInventory;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;
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 = "@";
protected static final String FLUID_TYPE_TAG = "ft";
protected static final String FLUID_COUNT_TAG = "fc";
protected static final String FLUID_SLOT = "#";
protected static final String FLUID_SLOT_COUNT = "@";
protected IStorageFluidCell cellType;
private static String[] fluidSlots;
private static String[] fluidSlotCount;
protected static String[] fluidSlots;
protected static String[] fluidSlotCount;
protected final ItemStack cellItem;
private final ISaveProvider container;
private final int MAX_TYPE = 63;
private long storedFluidCount;
private short storedFluids;
protected long storedFluidCount;
protected short storedFluids;
protected IItemList<IAEFluidStack> cellFluids;
private final NBTTagCompound tagCompound;
protected final NBTTagCompound tagCompound;
public static final int singleByteAmount = 256 * 8;
public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
@@ -80,6 +82,8 @@ public class FluidCellInventory implements IFluidCellInventory {
try {
if (o.getItem() instanceof ItemCreativeFluidStorageCell) {
return new FluidCellInventoryHandler(new CreativeFluidCellInventory(o, container2));
} else if (o.getItem() instanceof ProxyFluidStorageCell) {
return new FluidCellInventoryHandler(new ProxyFluidCellInventory(o, container2));
} else {
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
}
@@ -105,8 +109,8 @@ public class FluidCellInventory implements IFluidCellInventory {
}
@Override
public double getIdleDrain() {
return this.cellType.getIdleDrain();
public double getIdleDrain(ItemStack is) {
return this.cellType.getIdleDrain(is);
}
@Override
@@ -19,7 +19,7 @@ import com.glodblock.github.util.Util;
public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack> implements IFluidCellInventoryHandler {
FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
protected FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
super(c, StorageChannel.FLUIDS);
final IFluidCellInventory ci = this.getCellInv();
@@ -32,7 +32,6 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
final ItemStack is = config.getStackInSlot(x);
if (Util.getFluidFromItem(is) != null) {
priorityList.add(AEFluidStack.create(Util.getFluidFromItem(is)));
break;
}
}
if (!priorityList.isEmpty()) {
@@ -18,7 +18,7 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
/**
* @return idle cost for this Storage Cell
*/
double getIdleDrain();
double getIdleDrain(ItemStack is);
/**
* @return access configured list
@@ -17,7 +17,7 @@ public interface IStorageFluidCell extends ICellWorkbenchItem {
boolean isStorageCell(ItemStack i);
double getIdleDrain();
double getIdleDrain(ItemStack is);
int getTotalTypes(ItemStack cellItem);
}
@@ -0,0 +1,31 @@
package com.glodblock.github.crossmod.extracells;
import java.util.List;
import net.minecraft.item.Item;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.registry.GameRegistry;
public class EC2Replacer {
/**
* Should be called if and only if replaceEC2 config is true and EC2 not present. Registers proxy items for the
* entire EC2 mod. After running this once, you should set replaceEC2 back to false.
*/
public static void initReplacer() {
ItemReplacements.init();
}
public static void replaceExtraCells(FMLMissingMappingsEvent event) {
List<FMLMissingMappingsEvent.MissingMapping> mappings = event.getAll();
for (FMLMissingMappingsEvent.MissingMapping m : mappings) {
if (m.type == GameRegistry.Type.ITEM && ItemReplacements.registry.containsKey(m.name)) {
Item toRemap = ItemReplacements.registry.get(m.name);
m.remap(toRemap);
} else {
m.warn();
}
}
}
}
@@ -0,0 +1,254 @@
package com.glodblock.github.crossmod.extracells;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import net.minecraft.item.Item;
import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition;
import com.glodblock.github.common.item.ItemMultiFluidStorageCell;
import com.glodblock.github.crossmod.extracells.parts.*;
import com.glodblock.github.crossmod.extracells.storage.*;
import com.glodblock.github.loader.ItemAndBlockHolder;
import cpw.mods.fml.common.registry.GameRegistry;
/**
* Shell class to organize proxy replacements and hide the ugliness
*/
public class ItemReplacements {
protected static Map<String, Item> registry;
static void init() {
registry = new HashMap<>(23);
ProxyFluidBusIO.init();
ItemReplacements.proxyItems();
ItemReplacements.proxyPartItems();
}
/**
* Register proxy items (non-parts)
*/
static void proxyItems() {
deprecateFluidStorage("storage.fluid", 0, ItemAndBlockHolder.CELL1KM, 1, 8, 0.5);
deprecateFluidStorage("storage.fluid", 1, ItemAndBlockHolder.CELL4KM, 4, 32, 1.0);
deprecateFluidStorage("storage.fluid", 2, ItemAndBlockHolder.CELL16KM, 16, 128, 1.5);
deprecateFluidStorage("storage.fluid", 3, ItemAndBlockHolder.CELL64KM, 64, 512, 2.0);
deprecateFluidStorage("storage.fluid", 4, ItemAndBlockHolder.CELL256KM, 256, 2048, 2.5);
deprecateFluidStorage("storage.fluid", 5, ItemAndBlockHolder.CELL1024KM, 1024, 8192, 3.0);
deprecateFluidStorage("storage.fluid", 6, ItemAndBlockHolder.CELL4096KM, 4096, 32768, 3.5);
deprecateFluidStorage("storage.fluid", 7, ItemAndBlockHolder.CELL16384KM, 16384, 131072, 4.0);
// Thanks, AEApi.
AEApi.instance().registries().cell().addCellHandler(new ProxyItemCellHandler());
AEApi.instance().registries().cell().addCellHandler(new ProxyVoidCellHandler());
deprecateItemStorage(0, AEApi.instance().definitions().items().cell256k(), 256, 2048, 2.5);
deprecateItemStorage(1, AEApi.instance().definitions().items().cell1024k(), 1024, 8192, 3.0);
deprecateItemStorage(2, AEApi.instance().definitions().items().cell4096k(), 4096, 32768, 3.5);
deprecateItemStorage(3, AEApi.instance().definitions().items().cell16384k(), 16384, 131072, 4.0);
deprecateItemStorage(4, AEApi.instance().definitions().items().cellContainer(), 65536, 8, 2.0, 1);
deprecateExtremeStorage(
"storage.physical.advanced.quantum",
0,
AEApi.instance().definitions().items().cellQuantum(),
Integer.MAX_VALUE / 16,
4096,
1000.0);
deprecateExtremeStorage(
"storage.physical.advanced.singularity",
0,
AEApi.instance().definitions().items().cellSingularity(),
Long.MAX_VALUE / 16,
4096,
15000.0);
// Deprecate void cell manually
ProxyVoidStorageCell voidCell = new ProxyVoidStorageCell();
GameRegistry.registerItem(voidCell, "ec2placeholder.storage.physical.void");
registry.put("extracells:storage.physical.void", voidCell);
deprecateItem("pattern.fluid", ItemAndBlockHolder.PATTERN);
deprecateItem("terminal.fluid.wireless", ItemAndBlockHolder.WIRELESS_FLUID_TERM);
/* Storage casings */
deprecateItem("storage.casing", 0, AEApi.instance().definitions().materials().emptyAdvancedStorageCell());
deprecateItem("storage.casing", 1, ItemAndBlockHolder.CELL_HOUSING, 2);
/* Storage components (1k component, etc.) */
deprecateItem("storage.component", 0, AEApi.instance().definitions().materials().cell256kPart());
deprecateItem("storage.component", 1, AEApi.instance().definitions().materials().cell1024kPart());
deprecateItem("storage.component", 2, AEApi.instance().definitions().materials().cell4096kPart());
deprecateItem("storage.component", 3, AEApi.instance().definitions().materials().cell16384kPart());
deprecateItem("storage.component", 4, ItemAndBlockHolder.CELL_PART, 0);
deprecateItem("storage.component", 5, ItemAndBlockHolder.CELL_PART, 1);
deprecateItem("storage.component", 6, ItemAndBlockHolder.CELL_PART, 2);
deprecateItem("storage.component", 7, ItemAndBlockHolder.CELL_PART, 3);
deprecateItem("storage.component", 8, ItemAndBlockHolder.CELL_PART, 4);
deprecateItem("storage.component", 9, ItemAndBlockHolder.CELL_PART, 5);
deprecateItem("storage.component", 10, ItemAndBlockHolder.CELL_PART, 6);
deprecateItem("terminal.universal.wireless", ItemAndBlockHolder.WIRELESS_ULTRA_TERM);
}
/**
* Register proxy part items.
*/
static void proxyPartItems() {
deprecateItemPart(0, ItemAndBlockHolder.FLUID_EXPORT_BUS, ProxyFluidBusIO::new);
deprecateItemPart(1, ItemAndBlockHolder.FLUID_IMPORT_BUS, ProxyFluidBusIO::new);
deprecateItemPart(2, ItemAndBlockHolder.FLUID_STORAGE_BUS, ProxyFluidStorage::new);
deprecateItemPart(3, ItemAndBlockHolder.FLUID_TERM, ProxyPart::new);
deprecateItemPart(4, ItemAndBlockHolder.FLUID_LEVEL_EMITTER, ProxyLevelEmitter::new);
deprecateItemPart(9, ItemAndBlockHolder.FLUID_INTERFACE, ProxyFluidInterface::new);
deprecateItemPart(10, ItemAndBlockHolder.FLUID_STORAGE_MONITOR, ProxyStorageMonitor::new);
deprecateItemPart(11, ItemAndBlockHolder.FLUID_CONVERSION_MONITOR, ProxyStorageMonitor::new);
}
private static ProxyItem getOrBuildItem(String srcName) {
final String fullName = "extracells:" + srcName;
ProxyItem proxy = (ProxyItem) registry.get(fullName);
if (proxy == null) {
proxy = new ProxyItem(srcName);
registry.put(fullName, proxy);
proxy.register();
}
return proxy;
}
private static ProxyFluidStorageCell getOrBuildFluidStorage(String srcName) {
final String fullName = "extracells:" + srcName;
ProxyFluidStorageCell proxy = (ProxyFluidStorageCell) registry.get(fullName);
if (proxy == null) {
proxy = new ProxyFluidStorageCell(srcName);
registry.put(fullName, proxy);
proxy.register();
}
return proxy;
}
private static ProxyItemStorageCell getOrBuildItemStorage() {
final String fullName = "extracells:storage.physical";
ProxyItemStorageCell proxy = (ProxyItemStorageCell) registry.get(fullName);
if (proxy == null) {
proxy = new ProxyItemStorageCell("storage.physical");
registry.put(fullName, proxy);
proxy.register();
}
return proxy;
}
private static ProxyExtremeStorageCell getOrBuildItemStorage(String srcName) {
final String fullName = "extracells:" + srcName;
ProxyExtremeStorageCell proxy = (ProxyExtremeStorageCell) registry.get(fullName);
if (proxy == null) {
proxy = new ProxyExtremeStorageCell(srcName);
registry.put(fullName, proxy);
proxy.register();
}
return proxy;
}
/**
* Deprecate a simple item.
*
* @param srcName name of the to-be-replaced item without the mod id prefix
* @param srcMeta meta of the to-be-replaced item
* @param replacement item that will replace src
* @param targetMeta meta of the item that will replace src
*/
private static void deprecateItem(String srcName, int srcMeta, Item replacement, int targetMeta) {
getOrBuildItem(srcName).addMetaReplacement(srcMeta, replacement, targetMeta);
}
static void deprecateItemBlock(String srcName, int srcMeta, Item replacement, int targetMeta) {
getOrBuildItem("itemBlock." + srcName).addMetaReplacement(srcMeta, replacement, targetMeta);
}
private static void deprecateItem(String srcName, Item replacement) {
deprecateItem(srcName, 0, replacement, 0);
}
private static void deprecateItem(String srcName, int srcMeta, IItemDefinition replacement) {
if (replacement.isEnabled()) {
deprecateItem(
srcName,
srcMeta,
replacement.maybeItem().get(),
replacement.maybeStack(1).get().getItemDamage());
}
}
private static void deprecateItemPart(int srcMeta, Item replacement,
Function<ProxyPartItem, ProxyPart> partBuilder) {
final String fullName = "extracells:part.base";
ProxyPartItem proxyItem = (ProxyPartItem) registry.get(fullName);
if (proxyItem == null) {
proxyItem = new ProxyPartItem("part.base");
registry.put(fullName, proxyItem);
proxyItem.register();
}
proxyItem.addItemPart(srcMeta, replacement, partBuilder);
}
/**
* Deprecate a fluid storage item. Note that we can't access the properties directly, so we need to do this
*/
private static void deprecateFluidStorage(String srcName, int srcMeta, ItemMultiFluidStorageCell replacement,
long kilobytes, int bytesPerType, double idleDrain) {
ProxyFluidStorageCell proxyItem = getOrBuildFluidStorage(srcName);
ProxyItem.ProxyStorageEntry entry = new ProxyItem.ProxyStorageEntry(
replacement,
kilobytes,
bytesPerType,
idleDrain);
proxyItem.addMetaReplacement(srcMeta, entry);
}
/**
* Deprecate a storage item. This goes through AEAPI, as AE2FC doesn't have any item cells. If the item is disabled
* in AEAPI, the replacement will not be registered!
*/
private static void deprecateItemStorage(int srcMeta, IItemDefinition replacement, long kilobytes, int bytesPerType,
double idleDrain) {
if (replacement.isEnabled()) {
ProxyItemStorageCell item = getOrBuildItemStorage();
int meta = replacement.maybeStack(1).get().getItemDamage();
ProxyItem.ProxyItemEntry storage = new ProxyItem.ProxyStorageEntry(
replacement.maybeItem().get(),
kilobytes,
bytesPerType,
idleDrain);
item.addMetaReplacement(srcMeta, storage);
}
}
/**
* Deprecate a storage item. This goes through AEAPI, as AE2FC doesn't have any item cells. If the item is disabled
* in AEAPI, the replacement will not be registered!
*/
private static void deprecateItemStorage(int srcMeta, IItemDefinition replacement, long kilobytes, int bytesPerType,
double idleDrain, int types) {
if (replacement.isEnabled()) {
ProxyItemStorageCell item = getOrBuildItemStorage();
int meta = replacement.maybeStack(1).get().getItemDamage();
ProxyItem.ProxyItemEntry storage = new ProxyItem.ProxyStorageEntry(
replacement.maybeItem().get(),
kilobytes,
bytesPerType,
idleDrain,
types);
item.addMetaReplacement(srcMeta, storage);
}
}
private static void deprecateExtremeStorage(String srcName, int srcMeta, IItemDefinition replacement, long bytes,
int bytesPerType, double idleDrain) {
if (replacement.isEnabled()) {
ProxyExtremeStorageCell item = getOrBuildItemStorage(srcName);
int meta = replacement.maybeStack(1).get().getItemDamage();
ProxyItem.ProxyItemEntry storage = new ProxyItem.ProxyStorageEntry(
replacement.maybeItem().get(),
bytes / 1024,
bytesPerType,
idleDrain);
item.addMetaReplacement(srcMeta, storage);
}
}
}
@@ -0,0 +1,150 @@
package com.glodblock.github.crossmod.extracells;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.FCBaseItem;
import cpw.mods.fml.common.registry.GameRegistry;
/**
* EC2ProxyItem - Item that "holds" the data of a missing item.
*/
public class ProxyItem extends FCBaseItem {
protected final String name;
/**
* Maps a metadata value to a replacement.
*/
protected final Map<Integer, ProxyItemEntry> replacements;
public ProxyItem(String ec2itemName) {
this.name = ec2itemName;
this.replacements = new HashMap<>();
setUnlocalizedName("ec2placeholder." + name);
}
@Override
public FCBaseItem register() {
GameRegistry.registerItem(this, "ec2placeholder." + name, FluidCraft.MODID);
return this;
}
protected void addMetaReplacement(int srcMeta, Item replacement, int targetMeta) {
this.replacements.put(srcMeta, new ProxyItemEntry(replacement, targetMeta));
}
protected void addMetaReplacement(int srcMeta, ProxyItemEntry replacement) {
this.replacements.put(srcMeta, replacement);
}
@Override
public boolean getHasSubtypes() {
return true;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List info, boolean p_77624_4_) {
int meta = stack.getItemDamage();
ProxyItemEntry itemRepl = replacements.get(meta);
if (itemRepl != null) {
info.add(EnumChatFormatting.RED + "Extra Cells Placeholder for:");
info.add(EnumChatFormatting.AQUA + itemRepl.replacement.getUnlocalizedName());
info.add(EnumChatFormatting.GOLD + "Put in your inventory to get a replacement.");
info.add(EnumChatFormatting.GOLD + "It will disappear if no replacement was found.");
info.add(EnumChatFormatting.RED + "Report missing conversions on the Github.");
}
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) {
if (!worldIn.isRemote && entityIn instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityIn;
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
ItemStack s = player.inventory.getStackInSlot(i);
if (s == stack) {
int meta = stack.getItemDamage();
ProxyItemEntry r = replacements.get(meta);
if (r == null) {
player.inventory.setInventorySlotContents(i, null);
} else {
ItemStack replaceStack = new ItemStack(r.replacement, stack.stackSize, r.replacementMeta);
if (stack.hasTagCompound()) {
replaceStack.setTagCompound(r.replaceNBT(stack.getTagCompound()));
}
player.inventory.setInventorySlotContents(i, replaceStack);
}
break;
}
}
}
}
/**
* Base class for a mapping from source (Item, meta) -> replacement (Item, meta). Optionally, override the
* {@link ProxyItemEntry#replaceNBT(NBTTagCompound)} method for custom NBT migration.
*/
protected static class ProxyItemEntry {
protected final Item replacement;
protected final int replacementMeta;
/**
* Creates a Proxy Replacement.
*
* @param replacement Item that will replace the other.
* @param replacementMeta Metadata/damage value of the replacement
*/
protected ProxyItemEntry(Item replacement, int replacementMeta) {
this.replacement = replacement;
this.replacementMeta = replacementMeta;
}
NBTTagCompound replaceNBT(NBTTagCompound compound) {
System.out.println(compound);
return compound;
}
}
protected static class ProxyStorageEntry extends ProxyItemEntry {
public final long maxBytes;
public final int bytesPerType;
public final double idleDrain;
public final int types;
protected ProxyStorageEntry(Item replacement, long kilobytes, int bytesPerType, double idleDrain) {
super(replacement, 0);
this.maxBytes = kilobytes * 1024;
this.bytesPerType = bytesPerType;
this.idleDrain = idleDrain;
this.types = 63;
}
protected ProxyStorageEntry(Item replacement, long kilobytes, int bytesPerType, double idleDrain, int types) {
super(replacement, 0);
this.maxBytes = kilobytes * 1024;
this.bytesPerType = bytesPerType;
this.idleDrain = idleDrain;
this.types = types;
}
@Override
NBTTagCompound replaceNBT(NBTTagCompound compound) {
if (compound != null && compound.hasKey("ecc")) {
compound.removeTag("ecc");
}
return compound;
}
}
}
@@ -0,0 +1,226 @@
package com.glodblock.github.crossmod.extracells;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Random;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.networking.IGridNode;
import appeng.api.parts.*;
import appeng.api.storage.data.IAEItemStack;
import appeng.util.item.AEItemStack;
import cpw.mods.fml.common.registry.GameRegistry;
import io.netty.buffer.ByteBuf;
/**
* ProxyPart is expected to be immediately replaced with the replacement part on load.
*/
public class ProxyPart implements IPart, IPartDeprecated {
/**
* Prevent memory leaks by having one of the instances be a weak ref.
*/
private final WeakReference<ProxyPartItem> item;
/**
* Name for debug
*/
private final String name;
public ProxyPart(ProxyPartItem item) {
this.item = new WeakReference<>(item);
this.name = item.name;
}
@Override
public ItemStack getItemStack(PartItemStack type) {
return null;
}
@Override
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) {}
@Override
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer) {}
@Override
public void renderDynamic(double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer) {}
@Override
public IIcon getBreakingTexture() {
return null;
}
@Override
public boolean requireDynamicRender() {
return false;
}
@Override
public boolean isSolid() {
return false;
}
@Override
public boolean canConnectRedstone() {
return false;
}
@Override
public void writeToNBT(NBTTagCompound data) {}
@Override
public void readFromNBT(NBTTagCompound data) {}
@Override
public int getLightLevel() {
return 0;
}
@Override
public boolean isLadder(EntityLivingBase entity) {
return false;
}
@Override
public void onNeighborChanged() {}
@Override
public int isProvidingStrongPower() {
return 0;
}
@Override
public int isProvidingWeakPower() {
return 0;
}
@Override
public void writeToStream(ByteBuf data) {}
@Override
public boolean readFromStream(ByteBuf data) {
return false;
}
@Override
public IGridNode getGridNode() {
return null;
}
@Override
public void onEntityCollision(Entity entity) {}
@Override
public void removeFromWorld() {}
@Override
public void addToWorld() {}
@Override
public IGridNode getExternalFacingNode() {
return null;
}
@Override
public void setPartHostInfo(ForgeDirection side, IPartHost host, TileEntity tile) {}
@Override
public boolean onActivate(EntityPlayer player, Vec3 pos) {
return false;
}
@Override
public boolean onShiftActivate(EntityPlayer player, Vec3 pos) {
return false;
}
@Override
public void getDrops(List<ItemStack> drops, boolean wrenched) {}
@Override
public int cableConnectionRenderTo() {
return 0;
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random r) {
}
@Override
public void onPlacement(EntityPlayer player, ItemStack held, ForgeDirection side) {}
@Override
public boolean canBePlacedOn(BusSupport what) {
return false;
}
@Override
public void getBoxes(IPartCollisionHelper boxes) {}
@Override
public NBTTagCompound transformPart(NBTTagCompound def) {
int meta = def.getShort("Damage");
if (item.get() == null) {
throw new NullPointerException("Umm, this wasn't supposed to happen. The ref item " + name + " was GC'd.");
}
ProxyItem.ProxyItemEntry r = item.get().replacements.get(meta);
def.setInteger("id", Item.getIdFromItem(r.replacement));
def.setShort("Damage", (short) r.replacementMeta);
return def;
}
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
return extra;
}
/**
* Creates a new fluid display NBT tag from the fluid name
*/
public static NBTTagCompound createFluidDisplayTag(String fluidName) {
NBTTagCompound fluidDisplay = new NBTTagCompound();
Fluid fluid = FluidRegistry.getFluid(fluidName);
if (fluid != null) {
ItemStack fluidPacket = new ItemStack(GameRegistry.findItem("ae2fc", "fluid_packet"), 1, 0);
NBTTagCompound fluidPacketTag = new NBTTagCompound();
// FluidStack
FluidStack fluidStack = new FluidStack(fluid, 1000);
NBTTagCompound fluidStackNbt = new NBTTagCompound();
fluidStack.writeToNBT(fluidStackNbt);
fluidPacketTag.setTag("FluidStack", fluidStackNbt);
// FluidPacket
fluidPacketTag.setBoolean("DisplayOnly", true);
fluidPacket.setTagCompound(fluidPacketTag);
// Final Item
IAEItemStack aeStack = AEItemStack.create(fluidPacket);
aeStack.writeToNBT(fluidDisplay);
}
return fluidDisplay;
}
public static NBTTagCompound createFluidNBT(String fluidName, long amount) {
NBTTagCompound fluid = new NBTTagCompound();
fluid.setString("FluidName", fluidName);
fluid.setBoolean("Craft", false);
fluid.setLong("Req", 0);
fluid.setLong("Cnt", amount);
return fluid;
}
}
@@ -0,0 +1,58 @@
package com.glodblock.github.crossmod.extracells;
import java.util.function.Function;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartItem;
public class ProxyPartItem extends ProxyItem implements IPartItem {
/**
* Creates a ProxyPartItem associated with the ProxyPart instance. This instance is reused on each call to
* {@link #createPartFromItemStack(ItemStack)}.
*
* @param ec2itemName extra cells internal name
*/
public ProxyPartItem(String ec2itemName) {
super(ec2itemName);
}
/**
*
* @param srcMeta
* @param replacement
* @param part
*/
protected void addItemPart(int srcMeta, Item replacement, Function<ProxyPartItem, ProxyPart> part) {
this.replacements.put(srcMeta, new PartReplacement(replacement, part));
}
@Nullable
@Override
public IPart createPartFromItemStack(ItemStack is) {
final int meta = is.getItemDamage();
if (this.replacements.get(meta) instanceof PartReplacement) {
PartReplacement part = (PartReplacement) this.replacements.get(meta);
return part.proxyPart.apply(this);
}
return null;
}
}
/**
* Item replacement entry for ItemParts. All targets replace into 0.
*/
class PartReplacement extends ProxyItem.ProxyItemEntry {
Function<ProxyPartItem, ProxyPart> proxyPart;
PartReplacement(Item replacement, Function<ProxyPartItem, ProxyPart> proxyPart) {
super(replacement, 0);
this.proxyPart = proxyPart;
}
}
@@ -0,0 +1,76 @@
package com.glodblock.github.crossmod.extracells.parts;
import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import appeng.api.config.RedstoneMode;
import com.glodblock.github.crossmod.extracells.ProxyPart;
import com.glodblock.github.crossmod.extracells.ProxyPartItem;
public class ProxyFluidBusIO extends ProxyPart {
/**
* Map for converting slots from bus EC2 -> AE2FC
*/
private static int[] FILTER_MAP = null;
public static void init() {
FILTER_MAP = new int[] { 5, 3, 6, 1, 0, 2, 7, 4, 8 };
}
public ProxyFluidBusIO(ProxyPartItem partItem) {
super(partItem);
}
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Transform NBT in place
// Fluid Filter
NBTTagCompound fluidFilterNew = new NBTTagCompound();
for (int slot = 0; slot < 9; ++slot) {
String oldFilterName = "FilterFluid#" + slot;
fluidFilterNew
.setTag("#" + FILTER_MAP[slot], ProxyPart.createFluidDisplayTag(extra.getString(oldFilterName)));
extra.removeTag(oldFilterName);
}
extra.setTag("config", fluidFilterNew);
// Upgrades
NBTTagList upgrades = extra.getTagList("upgradeInventory", TAG_COMPOUND);
NBTTagCompound upgradesNew = new NBTTagCompound();
for (int i = 0; i < 4; ++i) {
NBTTagCompound upgrade = upgrades.getCompoundTagAt(i);
upgrade.removeTag("Slot");
upgradesNew.setTag("#" + i, upgrade);
}
extra.removeTag("upgradeInventory");
extra.setTag("upgrades", upgradesNew);
// Redstone mode
RedstoneMode redstoneMode = RedstoneMode.values()[extra.getInteger("redstoneMode")];
switch (redstoneMode) {
case LOW_SIGNAL:
extra.setString("REDSTONE_CONTROLLED", "LOW_SIGNAL");
break;
case HIGH_SIGNAL:
extra.setString("REDSTONE_CONTROLLED", "HIGH_SIGNAL");
break;
case SIGNAL_PULSE:
extra.setString("REDSTONE_CONTROLLED", "SIGNAL_PULSE");
break;
default:
extra.setString("REDSTONE_CONTROLLED", "IGNORE");
break;
}
extra.removeTag("redstoneMode");
// Part data
extra.setTag("part", extra.getCompoundTag("node").getCompoundTag("node0"));
extra.removeTag("node");
// Extra tags
extra.setString("CRAFT_ONLY", "NO");
extra.setString("FUZZY_MODE", "IGNORE_ALL");
extra.setString("SCHEDULING_MODE", "DEFAULT");
return extra;
}
}
@@ -0,0 +1,44 @@
package com.glodblock.github.crossmod.extracells.parts;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.Constants;
import com.glodblock.github.crossmod.extracells.ProxyPart;
import com.glodblock.github.crossmod.extracells.ProxyPartItem;
public class ProxyFluidInterface extends ProxyPart {
public ProxyFluidInterface(ProxyPartItem item) {
super(item);
}
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Internal fluids - ConfigInv and FluidInv
NBTTagCompound tank = extra.getCompoundTag("tank");
NBTTagCompound configTank = new NBTTagCompound();
configTank.setTag("#0", ProxyPart.createFluidDisplayTag(tank.getString("FluidName")));
extra.setTag("ConfigInv", configTank);
NBTTagCompound fluidTank = new NBTTagCompound();
NBTTagCompound fluid = ProxyPart.createFluidNBT(tank.getString("FluidName"), tank.getLong("Amount"));
fluidTank.setTag("#0", fluid);
extra.setTag("FluidInv", fluidTank);
extra.removeTag("tank");
// Patterns
NBTTagList patterns = extra.getCompoundTag("inventory").getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
NBTTagCompound newPatterns = new NBTTagCompound();
for (int i = 0; i < patterns.tagCount(); ++i) {
NBTTagCompound p = patterns.getCompoundTagAt(i);
p.removeTag("Slot");
newPatterns.setTag("#" + i, p);
}
extra.removeTag("inventory");
extra.setTag("patterns", newPatterns);
// Part
extra.setTag("part", extra.getCompoundTag("node").getCompoundTag("node0"));
extra.removeTag("node");
return extra;
}
}
@@ -0,0 +1,67 @@
package com.glodblock.github.crossmod.extracells.parts;
import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import com.glodblock.github.crossmod.extracells.ProxyPart;
import com.glodblock.github.crossmod.extracells.ProxyPartItem;
public class ProxyFluidStorage extends ProxyPart {
private static int[] FILTER_MAP = null;
protected static void init() {
// spotless:off
FILTER_MAP = new int[] {
0, 9, 18, 27, 36, 45,
1, 10, 19, 28, 37, 46,
2, 11, 20, 29, 38, 47,
3, 12, 21, 30, 39, 48,
4, 13, 22, 31, 40, 49,
5, 14, 23, 32, 41, 50,
6, 15, 24, 33, 42, 51,
7, 16, 25, 34, 43, 52,
8, 17, 26, 35, 44, 53 };
//spotless:on
}
public ProxyFluidStorage(ProxyPartItem item) {
super(item);
}
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Transform in place, less messy IMO
// Fluid filter slots
NBTTagCompound fluidFilterNew = new NBTTagCompound();
for (int slot = 0; slot < 54; ++slot) {
String oldFilterName = "FilterFluid#" + slot;
fluidFilterNew
.setTag("#" + FILTER_MAP[slot], ProxyPart.createFluidDisplayTag(extra.getString(oldFilterName)));
extra.removeTag(oldFilterName);
}
extra.setTag("config", fluidFilterNew);
// Part data
extra.setTag("part", extra.getCompoundTag("node").getCompoundTag("node0"));
extra.removeTag("node");
// Access
extra.setString("ACCESS", extra.getString("access"));
extra.removeTag("access");
// Upgrades
NBTTagList upgrades = extra.getTagList("upgradeInventory", TAG_COMPOUND);
NBTTagCompound upgradeNew = new NBTTagCompound();
upgradeNew.setTag("#0", upgrades.getCompoundTagAt(0));
upgradeNew.setTag("#1", new NBTTagCompound());
upgradeNew.setTag("#2", new NBTTagCompound());
upgradeNew.setTag("#3", new NBTTagCompound());
upgradeNew.setTag("#4", new NBTTagCompound());
extra.setTag("upgrades", upgradeNew);
extra.removeTag("upgradeInventory");
return extra;
}
}
@@ -0,0 +1,41 @@
package com.glodblock.github.crossmod.extracells.parts;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.RedstoneMode;
import com.glodblock.github.crossmod.extracells.ProxyPart;
import com.glodblock.github.crossmod.extracells.ProxyPartItem;
public class ProxyLevelEmitter extends ProxyPart {
public ProxyLevelEmitter(ProxyPartItem item) {
super(item);
}
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Fluid
NBTTagCompound fluidSlots = new NBTTagCompound();
fluidSlots.setTag("#0", ProxyPart.createFluidDisplayTag(extra.getString("fluid")));
extra.setTag("config", fluidSlots);
extra.removeTag("fluid");
// Redstone
RedstoneMode redstoneMode = RedstoneMode.values()[extra.getInteger("mode")];
if (redstoneMode == RedstoneMode.LOW_SIGNAL) {
extra.setString("REDSTONE_EMITTER", "LOW_SIGNAL");
} else {
extra.setString("REDSTONE_EMITTER", "HIGH_SIGNAL");
}
extra.removeTag("mode");
// Level
long wanted = extra.getLong("wantedAmount");
extra.setLong("reportingValue", wanted);
extra.setLong("lastReportingValue", wanted);
extra.removeTag("wantedAmount");
// Part
extra.setTag("part", extra.getCompoundTag("node").getCompoundTag("node0"));
extra.removeTag("node");
return extra;
}
}
@@ -0,0 +1,36 @@
package com.glodblock.github.crossmod.extracells.parts;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import com.glodblock.github.crossmod.extracells.ProxyPart;
import com.glodblock.github.crossmod.extracells.ProxyPartItem;
public class ProxyStorageMonitor extends ProxyPart {
public ProxyStorageMonitor(ProxyPartItem item) {
super(item);
}
@Override
public NBTTagCompound transformNBT(NBTTagCompound extra) {
// Fluid
int fluid = extra.getInteger("fluid");
Fluid f = FluidRegistry.getFluid(fluid);
NBTTagCompound itemDisplay = ProxyPart.createFluidNBT(f.getName(), 0L);
extra.setTag("configuredItem", itemDisplay);
extra.removeTag("amount");
extra.removeTag("fluid");
// Locked and other props
extra.setBoolean("isLocked", extra.getBoolean("locked"));
extra.removeTag("locked");
extra.setByte("spin", (byte) 0);
extra.setFloat("opacity", 255.0f);
// Part
extra.setTag("part", extra.getCompoundTag("node").getCompoundTag("node0"));
extra.removeTag("node");
return extra;
}
}
@@ -0,0 +1,15 @@
package com.glodblock.github.crossmod.extracells.storage;
import net.minecraft.item.ItemStack;
public class ProxyExtremeStorageCell extends ProxyItemStorageCell {
public ProxyExtremeStorageCell(String ec2itemName) {
super(ec2itemName);
}
@Override
public int getTotalTypes(ItemStack cellItem) {
return 1;
}
}
@@ -0,0 +1,77 @@
package com.glodblock.github.crossmod.extracells.storage;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.AEApi;
import appeng.api.exceptions.AppEngException;
import appeng.api.storage.ISaveProvider;
import appeng.api.storage.data.IAEFluidStack;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.storage.FluidCellInventory;
public class ProxyFluidCellInventory extends FluidCellInventory {
private static final String EC_CONVERTED = "ecc";
public ProxyFluidCellInventory(ItemStack o, ISaveProvider container) throws AppEngException {
super(o, container);
}
@Override
protected void loadCellFluids() {
// If we've already converted the tag to AE2FC, just go to super.
// Else, proceed with conversion
if (!this.tagCompound.hasKey(EC_CONVERTED)) {
if (this.cellFluids == null) {
this.cellFluids = AEApi.instance().storage().createFluidList();
}
this.cellFluids.resetStatus(); // clears totals and stuff.
// Load using Extra Cell's NBT format
for (int i = 0; i < this.cellType.getTotalTypes(this.cellItem); i++) {
FluidStack fs = FluidStack.loadFluidStackFromNBT(tagCompound.getCompoundTag("Fluid#" + i));
tagCompound.removeTag("Fluid#" + i);
final AEFluidStack aet = AEFluidStack.create(fs);
if (aet != null) {
if (aet.getStackSize() > 0) {
this.cellFluids.add(aet);
}
}
}
this.tagCompound.setBoolean(EC_CONVERTED, true);
// Convert to the new format
long fluidCount = 0;
int x = 0;
for (final IAEFluidStack v : this.cellFluids) {
fluidCount += v.getStackSize();
final NBTBase c = this.tagCompound.getTag(fluidSlots[x]);
if (c instanceof NBTTagCompound) {
v.writeToNBT((NBTTagCompound) c);
} else {
final NBTTagCompound g = new NBTTagCompound();
v.writeToNBT(g);
this.tagCompound.setTag(fluidSlots[x], g);
}
this.tagCompound.setLong(fluidSlotCount[x], v.getStackSize());
x++;
}
this.storedFluids = (short) this.cellFluids.size();
if (!this.cellFluids.isEmpty()) {
this.tagCompound.setShort(FLUID_TYPE_TAG, this.storedFluids);
}
this.storedFluidCount = fluidCount;
if (fluidCount > 0) {
this.tagCompound.setLong(FLUID_COUNT_TAG, fluidCount);
}
} else {
super.loadCellFluids();
}
}
}
@@ -0,0 +1,111 @@
package com.glodblock.github.crossmod.extracells.storage;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.data.IAEFluidStack;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.Platform;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.crossmod.extracells.ProxyItem;
import com.glodblock.github.util.ModAndClassUtil;
public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCell {
public ProxyFluidStorageCell(String ec2itemName) {
super(ec2itemName);
}
@Override
public long getBytes(ItemStack cellItem) {
int meta = cellItem.getItemDamage();
if (replacements.containsKey(meta)) {
ProxyItemEntry entry = replacements.get(meta);
if (entry instanceof ProxyStorageEntry) {
return ((ProxyStorageEntry) entry).maxBytes;
}
}
return 0;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
int meta = cellItem.getItemDamage();
if (replacements.containsKey(meta)) {
ProxyItemEntry entry = replacements.get(meta);
if (entry instanceof ProxyStorageEntry) {
return ((ProxyStorageEntry) entry).bytesPerType;
}
}
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(ItemStack is) {
int meta = is.getItemDamage();
if (replacements.containsKey(meta)) {
ProxyItemEntry entry = replacements.get(meta);
if (entry instanceof ProxyStorageEntry) {
return ((ProxyStorageEntry) entry).idleDrain;
}
}
return 0;
}
@Override
public int getTotalTypes(ItemStack cellItem) {
return 5;
}
@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) {
}
}
@@ -0,0 +1,13 @@
package com.glodblock.github.crossmod.extracells.storage;
import net.minecraft.item.ItemStack;
import appeng.core.features.registries.entries.BasicCellHandler;
public class ProxyItemCellHandler extends BasicCellHandler {
@Override
public boolean isCell(ItemStack is) {
return is != null && is.getItem() != null && is.getItem() instanceof ProxyItemStorageCell;
}
}
@@ -0,0 +1,161 @@
package com.glodblock.github.crossmod.extracells.storage;
import javax.annotation.Nullable;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.config.FuzzyMode;
import appeng.api.implementations.items.IStorageCell;
import appeng.api.storage.data.IAEItemStack;
import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.util.Platform;
import com.glodblock.github.crossmod.extracells.ProxyItem;
/**
* Proxy Item Storage. 256K, 1024K, etc. -> AE2's version. For now its just mirroring AE2's version, will need to
* transition to something better.
*/
public class ProxyItemStorageCell extends ProxyItem implements IStorageCell {
public ProxyItemStorageCell(String ec2itemName) {
super(ec2itemName);
}
@Override
public int getBytes(ItemStack cellItem) {
if (cellItem == null) {
return 0;
}
int meta = cellItem.getItemDamage();
if (replacements.containsKey(meta)) {
ProxyItemEntry entry = replacements.get(meta);
if (entry instanceof ProxyStorageEntry) {
return (int) ((ProxyStorageEntry) entry).maxBytes;
}
}
return 0;
}
@Override
public int BytePerType(ItemStack cellItem) {
if (cellItem == null) {
return 0;
}
int meta = cellItem.getItemDamage();
if (replacements.containsKey(meta)) {
ProxyItemEntry entry = replacements.get(meta);
if (entry instanceof ProxyStorageEntry) {
return ((ProxyStorageEntry) entry).bytesPerType;
}
}
return 0;
}
@Override
public int getBytesPerType(ItemStack cellItem) {
if (cellItem == null) {
return 0;
}
int meta = cellItem.getItemDamage();
if (replacements.containsKey(meta)) {
ProxyItemEntry entry = replacements.get(meta);
if (entry instanceof ProxyStorageEntry) {
return ((ProxyStorageEntry) entry).bytesPerType;
}
}
return 0;
}
@Override
public long getBytesLong(ItemStack cellItem) {
if (cellItem == null) {
return 0;
}
int meta = cellItem.getItemDamage();
if (replacements.containsKey(meta)) {
ProxyItemEntry entry = replacements.get(meta);
if (entry instanceof ProxyStorageEntry) {
return ((ProxyStorageEntry) entry).maxBytes;
}
}
return 0;
}
@Override
public int getTotalTypes(ItemStack cellItem) {
return 63;
}
@Override
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requestedAddition) {
return false;
}
@Override
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell(ItemStack i) {
return true;
}
@Override
public double getIdleDrain(@Nullable ItemStack cellItem) {
if (cellItem == null) {
return 0.0;
}
int meta = cellItem.getItemDamage();
if (replacements.containsKey(meta)) {
ProxyItemEntry entry = replacements.get(meta);
if (entry instanceof ProxyStorageEntry) {
return ((ProxyStorageEntry) entry).bytesPerType;
}
}
return 0;
}
@Override
public double getIdleDrain() {
return 0;
}
@Override
public boolean isEditable(ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(ItemStack is) {
return new CellUpgrades(is, 2);
}
@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());
}
@Override
public String getOreFilter(ItemStack is) {
return Platform.openNbtData(is).getString("OreFilter");
}
}
@@ -0,0 +1,13 @@
package com.glodblock.github.crossmod.extracells.storage;
import net.minecraft.item.ItemStack;
import appeng.core.features.registries.entries.VoidCellHandler;
public class ProxyVoidCellHandler extends VoidCellHandler {
@Override
public boolean isCell(ItemStack is) {
return is != null && is.getItem() != null && is.getItem() instanceof ProxyVoidStorageCell;
}
}
@@ -0,0 +1,44 @@
package com.glodblock.github.crossmod.extracells.storage;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.items.storage.ItemVoidStorageCell;
public class ProxyVoidStorageCell extends ItemVoidStorageCell {
private final String name = AEApi.instance().definitions().items().cellVoid().maybeStack(1).get()
.getUnlocalizedName();
@Override
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> info,
boolean displayMoreInfo) {
info.add(EnumChatFormatting.RED + "Extra Cells Placeholder for:");
info.add(EnumChatFormatting.AQUA + name);
info.add(EnumChatFormatting.GOLD + "Put in your inventory to get a replacement.");
info.add(EnumChatFormatting.GOLD + "It will disappear if no replacement was found.");
info.add(EnumChatFormatting.RED + "Report missing conversions on the Github.");
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) {
if (!worldIn.isRemote && entityIn instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityIn;
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
ItemStack s = player.inventory.getStackInSlot(i);
if (s == stack) {
ItemStack replaceStack = AEApi.instance().definitions().items().cellVoid().maybeStack(1).get();
player.inventory.setInventorySlotContents(i, replaceStack);
break;
}
}
}
}
}
@@ -278,9 +278,15 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
@Override
public Iterator<ItemSlot> iterator() {
return new SlotIterator(
invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0],
invItems != null ? invItems.iterator() : Collections.emptyIterator());
FluidTankInfo[] info = null;
if (invFluids != null) {
info = invFluids.getTankInfo(side);
}
// Null check is needed because some tank infos return null (EIO conduits...)
if (info == null) {
info = new FluidTankInfo[0];
}
return new SlotIterator(info, invItems != null ? invItems.iterator() : Collections.emptyIterator());
}
private IFluidHandler getSideFluid(ForgeDirection direction) {
@@ -466,7 +472,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
@Override
public boolean hasNext() {
return nextSlotIndex < tanks.length || itemSlots.hasNext();
return itemSlots.hasNext() || nextSlotIndex < tanks.length;
}
@Override
@@ -9,6 +9,7 @@ import appeng.api.config.Upgrades;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.tile.TileWalrus;
import com.glodblock.github.crossmod.extracells.EC2Replacer;
import com.glodblock.github.inventory.external.AEFluidInterfaceHandler;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.SPacketMEUpdateBuffer;
@@ -30,6 +31,9 @@ public class CommonProxy {
public void init(FMLInitializationEvent event) {
this.registerMovables();
FMLCommonHandler.instance().bus().register(SPacketMEUpdateBuffer.class);
if (!ModAndClassUtil.EC2 && Config.replaceEC2) {
EC2Replacer.initReplacer();
}
}
public void postInit(FMLPostInitializationEvent event) {