mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 18:44:42 +00:00
EC2 Deprecation: Part 3 - Parts
Parts are deprecated.
This commit is contained in:
1 parent
68c0abba95
commit
7ad5b9d297
11 files changed
+763
-159
No files matched your search
@@ -24,7 +24,7 @@ public class EC2ProxyBlock extends Block {
|
||||
GameRegistry.registerBlock(this, EC2ProxyItemBlock.class, "ec2placeholder." + name);
|
||||
}
|
||||
|
||||
private static class EC2ProxyItemBlock extends ItemBlock {
|
||||
public static class EC2ProxyItemBlock extends ItemBlock {
|
||||
|
||||
public EC2ProxyItemBlock(Block block) {
|
||||
super(block);
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
package com.glodblock.github.crossmod.extracells;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.google.common.base.Optional;
|
||||
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class EC2Replacer {
|
||||
|
||||
private static Map<String, EC2ProxyItem> items;
|
||||
private static Map<String, EC2ProxyBlock> blocks;
|
||||
|
||||
/**
|
||||
@@ -24,129 +17,8 @@ public class EC2Replacer {
|
||||
* items for the entire EC2 mod. After running this once, you should set replaceEC2 back to false.
|
||||
*/
|
||||
public static void initReplacer() {
|
||||
items = new HashMap<>(23);
|
||||
blocks = new HashMap<>(23);
|
||||
deprecateItem("part.base", 0, ItemAndBlockHolder.FLUID_EXPORT_BUS, EC2Replacer::noop);
|
||||
deprecateItem("part.base", 1, ItemAndBlockHolder.FLUID_IMPORT_BUS, EC2Replacer::noop);
|
||||
deprecateItem("part.base", 2, ItemAndBlockHolder.FLUID_STORAGE_BUS, EC2Replacer::noop);
|
||||
deprecateItem("part.base", 3, ItemAndBlockHolder.FLUID_TERM, EC2Replacer::noop);
|
||||
deprecateItem("part.base", 4, ItemAndBlockHolder.FLUID_LEVEL_EMITTER, EC2Replacer::noop);
|
||||
deprecateItem("part.base", 9, ItemAndBlockHolder.FLUID_INTERFACE, EC2Replacer::noop);
|
||||
deprecateItem("part.base", 10, ItemAndBlockHolder.FLUID_STORAGE_MONITOR, EC2Replacer::noop);
|
||||
deprecateItem("part.base", 11, ItemAndBlockHolder.FLUID_CONVERSION_MONITOR, EC2Replacer::noop);
|
||||
deprecateItem("storage.fluid", 0, ItemAndBlockHolder.CELL1KM, EC2Replacer::transformFluidCellData);
|
||||
deprecateItem("storage.fluid", 1, ItemAndBlockHolder.CELL4KM, EC2Replacer::transformFluidCellData);
|
||||
deprecateItem("storage.fluid", 2, ItemAndBlockHolder.CELL16KM, EC2Replacer::transformFluidCellData);
|
||||
deprecateItem("storage.fluid", 3, ItemAndBlockHolder.CELL64KM, EC2Replacer::transformFluidCellData);
|
||||
deprecateItem("storage.fluid", 4, ItemAndBlockHolder.CELL256KM, EC2Replacer::transformFluidCellData);
|
||||
deprecateItem("storage.fluid", 5, ItemAndBlockHolder.CELL1024KM, EC2Replacer::transformFluidCellData);
|
||||
deprecateItem("storage.fluid", 6, ItemAndBlockHolder.CELL4096KM, EC2Replacer::transformFluidCellData);
|
||||
deprecateItem("storage.fluid", 7, ItemAndBlockHolder.CELL16384KM, EC2Replacer::transformFluidCellData);
|
||||
// Thanks, AEApi.
|
||||
if (AEApi.instance().definitions().items().cell256k().isEnabled()) {
|
||||
deprecateItem("storage.physical", 0,
|
||||
AEApi.instance().definitions().items().cell256k().maybeItem().get(),
|
||||
AEApi.instance().definitions().items().cell256k().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::transformItemCellData);
|
||||
}
|
||||
if (AEApi.instance().definitions().items().cell1024k().isEnabled()) {
|
||||
deprecateItem("storage.physical", 1,
|
||||
AEApi.instance().definitions().items().cell1024k().maybeItem().get(),
|
||||
AEApi.instance().definitions().items().cell1024k().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::transformItemCellData);
|
||||
}
|
||||
if (AEApi.instance().definitions().items().cell4096k().isEnabled()) {
|
||||
deprecateItem("storage.physical", 2,
|
||||
AEApi.instance().definitions().items().cell4096k().maybeItem().get(),
|
||||
AEApi.instance().definitions().items().cell4096k().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::transformItemCellData);
|
||||
}
|
||||
if (AEApi.instance().definitions().items().cell16384k().isEnabled()) {
|
||||
deprecateItem("storage.physical", 3,
|
||||
AEApi.instance().definitions().items().cell16384k().maybeItem().get(),
|
||||
AEApi.instance().definitions().items().cell16384k().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::transformItemCellData);
|
||||
}
|
||||
if (AEApi.instance().definitions().items().cellContainer().isEnabled()) {
|
||||
deprecateItem("storage.physical", 4,
|
||||
AEApi.instance().definitions().items().cellContainer().maybeItem().get(),
|
||||
AEApi.instance().definitions().items().cellContainer().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::transformItemCellData);
|
||||
}
|
||||
if (AEApi.instance().definitions().items().cellSingularity().isEnabled()) {
|
||||
deprecateItem("storage.physical.advanced.singularity", 0,
|
||||
AEApi.instance().definitions().items().cellSingularity().maybeItem().get(),
|
||||
AEApi.instance().definitions().items().cellSingularity().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::transformItemCellData);
|
||||
}
|
||||
if (AEApi.instance().definitions().items().cellQuantum().isEnabled()) {
|
||||
deprecateItem("storage.physical.advanced.quantum", 0,
|
||||
AEApi.instance().definitions().items().cellQuantum().maybeItem().get(),
|
||||
AEApi.instance().definitions().items().cellQuantum().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::transformItemCellData);
|
||||
}
|
||||
if (AEApi.instance().definitions().items().cellVoid().isEnabled()) {
|
||||
deprecateItem("storage.physical.advanced.singularity", 0,
|
||||
AEApi.instance().definitions().items().cellVoid().maybeItem().get(),
|
||||
AEApi.instance().definitions().items().cellVoid().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::transformItemCellData);
|
||||
}
|
||||
deprecateItem("pattern.fluid", 0, ItemAndBlockHolder.PATTERN, tag -> tag);
|
||||
deprecateItem("terminal.fluid.wireless", 0, ItemAndBlockHolder.WIRELESS_FLUID_TERM, tag -> tag);
|
||||
if (AEApi.instance().definitions().materials().emptyAdvancedStorageCell().isEnabled()) {
|
||||
deprecateItem("storage.casing", 0,
|
||||
AEApi.instance().definitions().materials().emptyAdvancedStorageCell().maybeItem().get(),
|
||||
AEApi.instance().definitions().materials().emptyAdvancedStorageCell().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::noop);
|
||||
}
|
||||
deprecateItem("storage.casing", 1, ItemAndBlockHolder.CELL_HOUSING, 2, EC2Replacer::noop);
|
||||
if (AEApi.instance().definitions().materials().cell256kPart().isEnabled()) {
|
||||
deprecateItem("storage.component", 0,
|
||||
AEApi.instance().definitions().materials().cell256kPart().maybeItem().get(),
|
||||
AEApi.instance().definitions().materials().cell256kPart().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::noop);
|
||||
}
|
||||
if (AEApi.instance().definitions().materials().cell1024kPart().isEnabled()) {
|
||||
deprecateItem("storage.component", 1,
|
||||
AEApi.instance().definitions().materials().cell1024kPart().maybeItem().get(),
|
||||
AEApi.instance().definitions().materials().cell1024kPart().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::noop);
|
||||
}
|
||||
if (AEApi.instance().definitions().materials().cell4096kPart().isEnabled()) {
|
||||
deprecateItem("storage.component", 2,
|
||||
AEApi.instance().definitions().materials().cell4096kPart().maybeItem().get(),
|
||||
AEApi.instance().definitions().materials().cell4096kPart().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::noop);
|
||||
}
|
||||
if (AEApi.instance().definitions().materials().cell16384kPart().isEnabled()) {
|
||||
deprecateItem("storage.component", 3,
|
||||
AEApi.instance().definitions().materials().cell16384kPart().maybeItem().get(),
|
||||
AEApi.instance().definitions().materials().cell16384kPart().maybeStack(1).get().getItemDamage(),
|
||||
EC2Replacer::noop);
|
||||
}
|
||||
deprecateItem("storage.component", 4, ItemAndBlockHolder.CELL_PART, 0, EC2Replacer::noop);
|
||||
deprecateItem("storage.component", 5, ItemAndBlockHolder.CELL_PART, 1, EC2Replacer::noop);
|
||||
deprecateItem("storage.component", 6, ItemAndBlockHolder.CELL_PART, 2, EC2Replacer::noop);
|
||||
deprecateItem("storage.component", 7, ItemAndBlockHolder.CELL_PART, 3, EC2Replacer::noop);
|
||||
deprecateItem("storage.component", 8, ItemAndBlockHolder.CELL_PART, 4, EC2Replacer::noop);
|
||||
deprecateItem("storage.component", 9, ItemAndBlockHolder.CELL_PART, 5, EC2Replacer::noop);
|
||||
deprecateItem("storage.component", 10, ItemAndBlockHolder.CELL_PART, 6, EC2Replacer::noop);
|
||||
deprecateItem("terminal.universal.wireless", 0, ItemAndBlockHolder.WIRELESS_ULTRA_TERM, tag -> tag);
|
||||
}
|
||||
|
||||
private static void deprecateItem(String name, int meta, Item replacement, Function<NBTTagCompound, NBTTagCompound> nbtTransformer) {
|
||||
deprecateItem(name, meta, replacement, 0, nbtTransformer);
|
||||
}
|
||||
|
||||
private static void deprecateItem(String name, int meta, Item replacement, int targetMeta, Function<NBTTagCompound, NBTTagCompound> nbtTransformer) {
|
||||
final String fullName = "extracells:" + name;
|
||||
EC2ProxyItem proxy = items.get(fullName);
|
||||
if (proxy == null) {
|
||||
proxy = new EC2ProxyItem(name);
|
||||
items.put(fullName, proxy);
|
||||
proxy.register();
|
||||
}
|
||||
proxy.addMetaReplacement(meta, replacement, targetMeta, nbtTransformer);
|
||||
ItemReplacements.init();
|
||||
}
|
||||
|
||||
private static void deprecateBlock(String name, int meta, Block replacement) {
|
||||
@@ -156,13 +28,14 @@ public class EC2Replacer {
|
||||
private static void deprecateBlock(String name, int meta, Block replacement, int metaReplacement) {
|
||||
EC2ProxyBlock block = new EC2ProxyBlock(name, meta, replacement, metaReplacement);
|
||||
blocks.put("extracells:" + name, block);
|
||||
block.register();
|
||||
}
|
||||
|
||||
public static void replaceExtraCells(FMLMissingMappingsEvent event) {
|
||||
List<FMLMissingMappingsEvent.MissingMapping> mappings = event.getAll();
|
||||
for (FMLMissingMappingsEvent.MissingMapping m : mappings) {
|
||||
if (items.containsKey(m.name)) {
|
||||
Item toRemap = items.get(m.name);
|
||||
if (ItemReplacements.registry.containsKey(m.name)) {
|
||||
Item toRemap = ItemReplacements.registry.get(m.name);
|
||||
m.remap(toRemap);
|
||||
} else if (blocks.containsKey(m.name)) {
|
||||
Block toRemap = blocks.get(m.name);
|
||||
@@ -170,16 +43,4 @@ public class EC2Replacer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static NBTTagCompound noop(NBTTagCompound compound) {
|
||||
return compound;
|
||||
}
|
||||
|
||||
private static NBTTagCompound transformFluidCellData(NBTTagCompound compound) {
|
||||
return compound; //for now no op
|
||||
}
|
||||
|
||||
private static NBTTagCompound transformItemCellData(NBTTagCompound compound) {
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.glodblock.github.crossmod.extracells;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import com.glodblock.github.crossmod.extracells.parts.*;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Shell class to organize proxy replacements and hide the ugliness
|
||||
*/
|
||||
public class ItemReplacements {
|
||||
|
||||
protected static Map<String, ProxyItem> 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);
|
||||
deprecateFluidStorage("storage.fluid", 1, ItemAndBlockHolder.CELL4KM);
|
||||
deprecateFluidStorage("storage.fluid", 3, ItemAndBlockHolder.CELL64KM);
|
||||
deprecateFluidStorage("storage.fluid", 4, ItemAndBlockHolder.CELL256KM);
|
||||
deprecateFluidStorage("storage.fluid", 2, ItemAndBlockHolder.CELL16KM);
|
||||
deprecateFluidStorage("storage.fluid", 5, ItemAndBlockHolder.CELL1024KM);
|
||||
deprecateFluidStorage("storage.fluid", 6, ItemAndBlockHolder.CELL4096KM);
|
||||
deprecateFluidStorage("storage.fluid", 7, ItemAndBlockHolder.CELL16384KM);
|
||||
// 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());
|
||||
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 = registry.get(fullName);
|
||||
if (proxy == null) {
|
||||
proxy = new ProxyItem(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);
|
||||
}
|
||||
|
||||
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 storage item.
|
||||
*/
|
||||
private static void deprecateFluidStorage(String srcName, int srcMeta, Item replacement) {
|
||||
ProxyItem item = getOrBuildItem(srcName);
|
||||
ProxyItem.ProxyReplacement storage = new FluidStorageReplacement(replacement, 0);
|
||||
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(String srcName, int srcMeta, IItemDefinition replacement) {
|
||||
if (replacement.isEnabled()) {
|
||||
ProxyItem item = getOrBuildItem(srcName);
|
||||
ProxyItem.ProxyReplacement storage = new ItemStorageReplacement(
|
||||
replacement.maybeItem().get(), replacement.maybeStack(1).get().getItemDamage());
|
||||
item.addMetaReplacement(srcMeta, storage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FluidStorageReplacement extends ProxyItem.ProxyReplacement {
|
||||
FluidStorageReplacement(Item replacement, int replacementMeta) {
|
||||
super(replacement, replacementMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
NBTTagCompound replaceNBT(NBTTagCompound compound) {
|
||||
System.out.println(compound);
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
|
||||
class ItemStorageReplacement extends ProxyItem.ProxyReplacement {
|
||||
ItemStorageReplacement(Item replacement, int replacementMeta) {
|
||||
super(replacement, replacementMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
NBTTagCompound replaceNBT(NBTTagCompound compound) {
|
||||
System.out.println(compound);
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
+49
-15
@@ -1,6 +1,7 @@
|
||||
package com.glodblock.github.crossmod.extracells;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.FCBaseItem;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -10,25 +11,37 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class EC2ProxyItem extends Item {
|
||||
/**
|
||||
* 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, ProxyReplacement> replacements;
|
||||
public EC2ProxyItem(String ec2itemName) {
|
||||
public ProxyItem(String ec2itemName) {
|
||||
this.name = ec2itemName;
|
||||
this.replacements = new HashMap<>();
|
||||
}
|
||||
|
||||
void register() {
|
||||
@Override
|
||||
public FCBaseItem register() {
|
||||
GameRegistry.registerItem(this, "ec2placeholder." + name, FluidCraft.MODID);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void addMetaReplacement(int srcMeta, Item replacement, int targetMeta, Function<NBTTagCompound, NBTTagCompound> nbtTransformer) {
|
||||
this.replacements.put(srcMeta, new ProxyReplacement(replacement, targetMeta, nbtTransformer));
|
||||
protected void addMetaReplacement(int srcMeta, Item replacement, int targetMeta) {
|
||||
this.replacements.put(srcMeta, new ProxyReplacement(replacement, targetMeta));
|
||||
}
|
||||
|
||||
protected void addMetaReplacement(int srcMeta, ProxyReplacement replacement) {
|
||||
this.replacements.put(srcMeta, replacement);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,6 +49,12 @@ public class EC2ProxyItem extends Item {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List info, boolean p_77624_4_) {
|
||||
info.add("§7With Extra Cells gone, this is what remains...");
|
||||
info.add("§7Put in your inventory to get a replacement (or disappear if incompatible)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) {
|
||||
if (!worldIn.isRemote && entityIn instanceof EntityPlayer) {
|
||||
@@ -48,9 +67,9 @@ public class EC2ProxyItem extends Item {
|
||||
if (r == null) {
|
||||
player.inventory.setInventorySlotContents(i, null);
|
||||
} else {
|
||||
ItemStack replaceStack = new ItemStack(r.replacement, stack.stackSize, r.meta);
|
||||
ItemStack replaceStack = new ItemStack(r.replacement, stack.stackSize, r.replacementMeta);
|
||||
if (replaceStack.hasTagCompound()) {
|
||||
replaceStack.setTagCompound(r.nbtTransformer.apply(replaceStack.getTagCompound()));
|
||||
replaceStack.setTagCompound(r.replaceNBT(replaceStack.getTagCompound()));
|
||||
}
|
||||
player.inventory.setInventorySlotContents(i, replaceStack);
|
||||
}
|
||||
@@ -58,14 +77,29 @@ public class EC2ProxyItem extends Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
private static class ProxyReplacement {
|
||||
private final Item replacement;
|
||||
private final int meta;
|
||||
protected final Function<NBTTagCompound, NBTTagCompound> nbtTransformer;
|
||||
ProxyReplacement(Item replacement, int meta, Function<NBTTagCompound, NBTTagCompound> nbtTransformer) {
|
||||
|
||||
/**
|
||||
* Base class for a mapping from source (Item, meta) -> replacement (Item, meta).
|
||||
* Optionally, override the {@link ProxyReplacement#replaceNBT(NBTTagCompound)}
|
||||
* method for custom NBT migration.
|
||||
*/
|
||||
protected static class ProxyReplacement {
|
||||
|
||||
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
|
||||
*/
|
||||
ProxyReplacement(Item replacement, int replacementMeta) {
|
||||
this.replacement = replacement;
|
||||
this.meta = meta;
|
||||
this.nbtTransformer = nbtTransformer;
|
||||
this.replacementMeta = replacementMeta;
|
||||
}
|
||||
|
||||
NBTTagCompound replaceNBT(NBTTagCompound compound) {
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.glodblock.github.crossmod.extracells;
|
||||
|
||||
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;
|
||||
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 java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 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.ProxyReplacement 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 appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
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.ProxyReplacement {
|
||||
|
||||
Function<ProxyPartItem, ProxyPart> proxyPart;
|
||||
|
||||
PartReplacement(Item replacement, Function<ProxyPartItem, ProxyPart> proxyPart) {
|
||||
super(replacement, 0);
|
||||
this.proxyPart = proxyPart;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPart;
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPartItem;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
|
||||
|
||||
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,42 @@
|
||||
package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPart;
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPartItem;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
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,63 @@
|
||||
package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPart;
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPartItem;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
|
||||
|
||||
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,38 @@
|
||||
package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPart;
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPartItem;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
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,34 @@
|
||||
package com.glodblock.github.crossmod.extracells.parts;
|
||||
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPart;
|
||||
import com.glodblock.github.crossmod.extracells.ProxyPartItem;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user