mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-17 02:45:08 +00:00
Add handlers for deprecated item cells
Now the placeholder should work automatically in a drive. The void cell is still a WIP.
This commit is contained in:
1 parent
3e2a0482e9
commit
3245de6ba1
8 files changed
+268
-49
No files matched your search
@@ -3,7 +3,6 @@ package com.glodblock.github.common.storage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInvHandler;
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInventory;
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
@@ -4,7 +4,10 @@ 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.ProxyExtremeStorageCell;
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyItemCellHandler;
|
||||
import com.glodblock.github.crossmod.extracells.storage.ProxyItemStorageCell;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
@@ -46,17 +49,17 @@ public class ItemReplacements {
|
||||
deprecateFluidStorage("storage.fluid", 7, ItemAndBlockHolder.CELL16384KM,
|
||||
16384, 131072, 4.0);
|
||||
// Thanks, AEApi.
|
||||
deprecateItemStorage("storage.physical", 0, AEApi.instance().definitions().items().cell256k());
|
||||
deprecateItemStorage("storage.physical", 1, AEApi.instance().definitions().items().cell1024k());
|
||||
deprecateItemStorage("storage.physical", 2, AEApi.instance().definitions().items().cell4096k());
|
||||
deprecateItemStorage("storage.physical", 3, AEApi.instance().definitions().items().cell16384k());
|
||||
deprecateItemStorage("storage.physical", 4, AEApi.instance().definitions().items().cellContainer());
|
||||
deprecateItemStorage("storage.physical.advanced.singularity", 0,
|
||||
AEApi.instance().definitions().items().cellSingularity());
|
||||
deprecateItemStorage("storage.physical.advanced.quantum", 0,
|
||||
AEApi.instance().definitions().items().cellQuantum());
|
||||
deprecateItemStorage("storage.physical.void", 0,
|
||||
AEApi.instance().definitions().items().cellVoid());
|
||||
AEApi.instance().registries().cell().addCellHandler(new ProxyItemCellHandler());
|
||||
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);
|
||||
deprecateItem("storage.physical.void", 0, AEApi.instance().definitions().items().cellVoid());
|
||||
deprecateItem("pattern.fluid", ItemAndBlockHolder.PATTERN);
|
||||
deprecateItem("terminal.fluid.wireless", ItemAndBlockHolder.WIRELESS_FLUID_TERM);
|
||||
/* Storage casings */
|
||||
@@ -114,6 +117,28 @@ public class ItemReplacements {
|
||||
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
|
||||
@@ -157,7 +182,7 @@ public class ItemReplacements {
|
||||
*/
|
||||
private static void deprecateFluidStorage(String srcName, int srcMeta, ItemMultiFluidStorageCell replacement, long kilobytes, int bytesPerType, double idleDrain) {
|
||||
ProxyFluidStorageCell proxyItem = getOrBuildFluidStorage(srcName);
|
||||
ProxyItem.ProxyFluidStorageEntry entry = new ProxyItem.ProxyFluidStorageEntry(replacement, kilobytes, bytesPerType, idleDrain);
|
||||
ProxyItem.ProxyStorageEntry entry = new ProxyItem.ProxyStorageEntry(replacement, kilobytes, bytesPerType, idleDrain);
|
||||
proxyItem.addMetaReplacement(srcMeta, entry);
|
||||
}
|
||||
|
||||
@@ -165,11 +190,36 @@ public class ItemReplacements {
|
||||
* 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(String srcName, int srcMeta, IItemDefinition replacement) {
|
||||
private static void deprecateItemStorage(int srcMeta, IItemDefinition replacement, long kilobytes, int bytesPerType, double idleDrain) {
|
||||
if (replacement.isEnabled()) {
|
||||
ProxyItem item = getOrBuildItem(srcName);
|
||||
ProxyItem.ProxyItemEntry storage = new ProxyItem.ItemStorageEntry(
|
||||
replacement.maybeItem().get(), replacement.maybeStack(1).get().getItemDamage());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,34 +99,32 @@ public class ProxyItem extends FCBaseItem {
|
||||
this.replacementMeta = replacementMeta;
|
||||
}
|
||||
|
||||
NBTTagCompound replaceNBT(NBTTagCompound compound) {
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
|
||||
protected static class ItemStorageEntry extends ProxyItemEntry {
|
||||
ItemStorageEntry(Item replacement, int replacementMeta) {
|
||||
super(replacement, replacementMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
NBTTagCompound replaceNBT(NBTTagCompound compound) {
|
||||
System.out.println(compound);
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
|
||||
protected static class ProxyFluidStorageEntry extends ProxyItemEntry {
|
||||
protected static class ProxyStorageEntry extends ProxyItemEntry {
|
||||
public final long maxBytes;
|
||||
public final int bytesPerType;
|
||||
public final double idleDrain;
|
||||
protected ProxyFluidStorageEntry(ItemMultiFluidStorageCell replacement, long kilobytes, int bytesPerType, 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")) {
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
package com.glodblock.github.crossmod.extracells.storage;
|
||||
|
||||
import com.glodblock.github.common.storage.*;
|
||||
|
||||
|
||||
public class ProxyFluidCellInvHandler extends FluidCellInventoryHandler {
|
||||
|
||||
public ProxyFluidCellInvHandler(FluidCellInventory inv) {
|
||||
super(inv);
|
||||
}
|
||||
}
|
||||
+6
-8
@@ -6,13 +6,11 @@ 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.item.ItemMultiFluidStorageCell;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.crossmod.extracells.ProxyItem;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCell {
|
||||
|
||||
@@ -25,8 +23,8 @@ public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCel
|
||||
int meta = cellItem.getItemDamage();
|
||||
if (replacements.containsKey(meta)) {
|
||||
ProxyItemEntry entry = replacements.get(meta);
|
||||
if (entry instanceof ProxyFluidStorageEntry) {
|
||||
return ((ProxyFluidStorageEntry) entry).maxBytes;
|
||||
if (entry instanceof ProxyStorageEntry) {
|
||||
return ((ProxyStorageEntry) entry).maxBytes;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -37,8 +35,8 @@ public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCel
|
||||
int meta = cellItem.getItemDamage();
|
||||
if (replacements.containsKey(meta)) {
|
||||
ProxyItemEntry entry = replacements.get(meta);
|
||||
if (entry instanceof ProxyFluidStorageEntry) {
|
||||
return ((ProxyFluidStorageEntry) entry).bytesPerType;
|
||||
if (entry instanceof ProxyStorageEntry) {
|
||||
return ((ProxyStorageEntry) entry).bytesPerType;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -67,8 +65,8 @@ public class ProxyFluidStorageCell extends ProxyItem implements IStorageFluidCel
|
||||
int meta = is.getItemDamage();
|
||||
if (replacements.containsKey(meta)) {
|
||||
ProxyItemEntry entry = replacements.get(meta);
|
||||
if (entry instanceof ProxyFluidStorageEntry) {
|
||||
return ((ProxyFluidStorageEntry) entry).idleDrain;
|
||||
if (entry instanceof ProxyStorageEntry) {
|
||||
return ((ProxyStorageEntry) entry).idleDrain;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.glodblock.github.crossmod.extracells.storage;
|
||||
|
||||
import appeng.core.features.registries.entries.BasicCellHandler;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ProxyItemCellHandler extends BasicCellHandler {
|
||||
|
||||
@Override
|
||||
public boolean isCell(ItemStack is) {
|
||||
return is != null && is.getItem() != null && is.getItem() instanceof ProxyItemStorageCell;
|
||||
}
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
package com.glodblock.github.crossmod.extracells.storage;
|
||||
|
||||
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;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* 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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user