Compare commits

...
11 Commits
Author SHA1 Message Date
Martin Robertz 4e1983b87f Merge remote-tracking branch 'origin/byebyeEC2' into dev 2023-04-29 20:14:07 +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
28 changed files with 1457 additions and 18 deletions

No files matched your search

@@ -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) {}
@@ -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();
}
@@ -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;
}
@@ -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();
@@ -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;
}
}
}
}
}
@@ -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) {