Filter Cards, all done

This commit is contained in:
Aidan C. Brady 2014-03-08 17:47:39 -05:00
parent 71c041917d
commit 1500bfe929
9 changed files with 316 additions and 3 deletions

View file

@ -0,0 +1,12 @@
package mekanism.api;
import net.minecraft.nbt.NBTTagCompound;
public interface IFilterAccess
{
public NBTTagCompound getFilterData(NBTTagCompound nbtTags);
public void setFilterData(NBTTagCompound nbtTags);
public String getDataType();
}

View file

@ -3,6 +3,7 @@ package mekanism.common;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import mekanism.api.Coord4D;
import mekanism.api.IFilterAccess;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage;
import net.minecraft.inventory.ISidedInventory;
@ -11,7 +12,7 @@ import buildcraft.api.power.IPowerReceptor;
import cofh.api.energy.IEnergyHandler;
import dan200.computer.api.IPeripheral;
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IPeripheral
public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess
{
public int[] getBoundSlots(Coord4D location, int side);

View file

@ -66,6 +66,7 @@ import mekanism.common.item.ItemDirtyDust;
import mekanism.common.item.ItemDust;
import mekanism.common.item.ItemElectricBow;
import mekanism.common.item.ItemEnergized;
import mekanism.common.item.ItemFilterCard;
import mekanism.common.item.ItemFreeRunners;
import mekanism.common.item.ItemGasMask;
import mekanism.common.item.ItemIngot;
@ -260,6 +261,7 @@ public class Mekanism
public static Item BrineBucket;
public static Item FreeRunners;
public static ItemJetpack ArmoredJetpack;
public static Item FilterCard;
//Blocks
public static Block BasicBlock;
@ -573,6 +575,9 @@ public class Mekanism
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(ArmoredJetpack.getEmptyItem(), new Object[] {
"D D", "BSB", " J ", Character.valueOf('D'), "dustDiamond", Character.valueOf('B'), "ingotBronze", Character.valueOf('S'), "blockSteel", Character.valueOf('J'), Jetpack.getEmptyItem()
}));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(FilterCard), new Object[] {
" A ", "ACA", " A ", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('C'), "circuitBasic"
}));
for(RecipeType type : RecipeType.values())
{
@ -794,6 +799,7 @@ public class Mekanism
EnergyUpgrade = new ItemMachineUpgrade(configuration.getItem("EnergyUpgrade", ITEM_ID++).getInt()).setUnlocalizedName("EnergyUpgrade");
EnergyTablet = (ItemEnergized)new ItemEnergized(configuration.getItem("EnergyTablet", ITEM_ID++).getInt(), 1000000, 120).setUnlocalizedName("EnergyTablet");
Dictionary = new ItemDictionary(configuration.getItem("Dictionary", ITEM_ID++).getInt()).setUnlocalizedName("Dictionary");
FilterCard = new ItemFilterCard(configuration.getItem("FilterCard", ITEM_ID++).getInt()).setUnlocalizedName("FilterCard");
ElectricBow = (ItemElectricBow)new ItemElectricBow(configuration.getItem("ElectricBow", ITEM_ID++).getInt()).setUnlocalizedName("ElectricBow");
PortableTeleporter = new ItemPortableTeleporter(configuration.getItem("PortableTeleporter", ITEM_ID++).getInt()).setUnlocalizedName("PortableTeleporter");
Configurator = new ItemConfigurator(configuration.getItem("Configurator", ITEM_ID++).getInt()).setUnlocalizedName("Configurator");
@ -859,6 +865,7 @@ public class Mekanism
GameRegistry.registerItem(Crystal, "Crystal");
GameRegistry.registerItem(FreeRunners, "FrictionBoots");
GameRegistry.registerItem(ArmoredJetpack, "ArmoredJetpack");
GameRegistry.registerItem(FilterCard, "FilterCard");
}
/**

View file

@ -0,0 +1,119 @@
package mekanism.common.item;
import java.util.List;
import mekanism.api.EnumColor;
import mekanism.api.IFilterAccess;
import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatMessageComponent;
import net.minecraft.world.World;
public class ItemFilterCard extends ItemMekanism
{
public ItemFilterCard(int id)
{
super(id);
setMaxStackSize(1);
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
super.addInformation(itemstack, entityplayer, list, flag);
list.add(EnumColor.GREY + MekanismUtils.localize("gui.data") + ": " + EnumColor.INDIGO + MekanismUtils.localize(getDataType(itemstack)));
}
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
if(!world.isRemote)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof IFilterAccess)
{
if(player.isSneaking())
{
NBTTagCompound data = ((IFilterAccess)tileEntity).getFilterData(new NBTTagCompound());
if(data != null)
{
data.setString("dataType", ((IFilterAccess)tileEntity).getDataType());
setData(stack, data);
player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.filterCard.got") + " " + EnumColor.INDIGO + MekanismUtils.localize(data.getString("dataType")));
}
return true;
}
else if(getData(stack) != null)
{
if(((IFilterAccess)tileEntity).getDataType().equals(getDataType(stack)))
{
((IFilterAccess)tileEntity).setFilterData(getData(stack));
player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.DARK_GREEN + MekanismUtils.localize("tooltip.filterCard.set") + " " + EnumColor.INDIGO + MekanismUtils.localize(getDataType(stack)));
setData(stack, null);
}
else {
player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + MekanismUtils.localize("tooltip.filterCard.unequal") + ".");
}
return true;
}
}
}
return false;
}
public void setData(ItemStack itemstack, NBTTagCompound data)
{
if(itemstack.stackTagCompound == null)
{
itemstack.setTagCompound(new NBTTagCompound());
}
if(data != null)
{
itemstack.stackTagCompound.setCompoundTag("data", data);
}
else {
itemstack.stackTagCompound.removeTag("data");
}
}
public NBTTagCompound getData(ItemStack itemstack)
{
if(itemstack.stackTagCompound == null)
{
return null;
}
NBTTagCompound data = itemstack.stackTagCompound.getCompoundTag("data");
if(data.hasNoTags())
{
return null;
}
else {
return itemstack.stackTagCompound.getCompoundTag("data");
}
}
public String getDataType(ItemStack itemstack)
{
NBTTagCompound data = getData(itemstack);
if(data != null)
{
return data.getString("dataType");
}
return "gui.none";
}
}

View file

@ -3,6 +3,7 @@ package mekanism.common.tile;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergyTile;
import mekanism.api.Coord4D;
import mekanism.api.IFilterAccess;
import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.common.IAdvancedBoundingBlock;
@ -10,6 +11,7 @@ import mekanism.common.util.InventoryUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@ -21,7 +23,7 @@ import dan200.computer.api.IComputerAccess;
import dan200.computer.api.ILuaContext;
import dan200.computer.api.IPeripheral;
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IPeripheral
public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IPeripheral, IFilterAccess
{
@Override
public int getSizeInventory()
@ -470,4 +472,37 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
getInv().detach(computer);
}
@Override
public NBTTagCompound getFilterData(NBTTagCompound nbtTags)
{
if(getInv() == null)
{
return null;
}
return getInv().getFilterData(nbtTags);
}
@Override
public void setFilterData(NBTTagCompound nbtTags)
{
if(getInv() == null)
{
return;
}
getInv().setFilterData(nbtTags);
}
@Override
public String getDataType()
{
if(getInv() == null)
{
return "null";
}
return getInv().getDataType();
}
}

View file

@ -1293,4 +1293,70 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
@Override
public void detach(IComputerAccess computer) {}
@Override
public NBTTagCompound getFilterData(NBTTagCompound nbtTags)
{
nbtTags.setInteger("radius", radius);
nbtTags.setInteger("minY", minY);
nbtTags.setInteger("maxY", maxY);
nbtTags.setBoolean("doEject", doEject);
nbtTags.setBoolean("doPull", doPull);
nbtTags.setBoolean("silkTouch", silkTouch);
nbtTags.setInteger("controlType", controlType.ordinal());
nbtTags.setBoolean("inverse", inverse);
if(replaceStack != null)
{
nbtTags.setCompoundTag("replaceStack", replaceStack.writeToNBT(new NBTTagCompound()));
}
NBTTagList filterTags = new NBTTagList();
for(MinerFilter filter : filters)
{
filterTags.appendTag(filter.write(new NBTTagCompound()));
}
if(filterTags.tagCount() != 0)
{
nbtTags.setTag("filters", filterTags);
}
return nbtTags;
}
@Override
public void setFilterData(NBTTagCompound nbtTags)
{
radius = nbtTags.getInteger("radius");
minY = nbtTags.getInteger("minY");
maxY = nbtTags.getInteger("maxY");
doEject = nbtTags.getBoolean("doEject");
doPull = nbtTags.getBoolean("doPull");
silkTouch = nbtTags.getBoolean("silkTouch");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
inverse = nbtTags.getBoolean("inverse");
if(nbtTags.hasKey("replaceStack"))
{
replaceStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("replaceStack"));
}
if(nbtTags.hasKey("filters"))
{
NBTTagList tagList = nbtTags.getTagList("filters");
for(int i = 0; i < tagList.tagCount(); i++)
{
filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i)));
}
}
}
@Override
public String getDataType()
{
return "tooltip.filterCard.digitalMiner";
}
}

View file

@ -5,6 +5,7 @@ import java.util.EnumSet;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
import mekanism.api.IFilterAccess;
import mekanism.common.HashList;
import mekanism.common.IActiveState;
import mekanism.common.ILogisticalTransporter;
@ -31,7 +32,7 @@ import net.minecraftforge.common.ForgeDirection;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityLogisticalSorter extends TileEntityElectricBlock implements IRedstoneControl, IActiveState
public class TileEntityLogisticalSorter extends TileEntityElectricBlock implements IRedstoneControl, IActiveState, IFilterAccess
{
public HashList<TransporterFilter> filters = new HashList<TransporterFilter>();
@ -540,4 +541,68 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
{
return true;
}
@Override
public NBTTagCompound getFilterData(NBTTagCompound nbtTags)
{
nbtTags.setInteger("controlType", controlType.ordinal());
if(color != null)
{
nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color));
}
nbtTags.setBoolean("autoEject", autoEject);
nbtTags.setBoolean("roundRobin", roundRobin);
nbtTags.setInteger("rrIndex", rrIndex);
NBTTagList filterTags = new NBTTagList();
for(TransporterFilter filter : filters)
{
NBTTagCompound tagCompound = new NBTTagCompound();
filter.write(tagCompound);
filterTags.appendTag(tagCompound);
}
if(filterTags.tagCount() != 0)
{
nbtTags.setTag("filters", filterTags);
}
return nbtTags;
}
@Override
public void setFilterData(NBTTagCompound nbtTags)
{
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
if(nbtTags.hasKey("color"))
{
color = TransporterUtils.colors.get(nbtTags.getInteger("color"));
}
autoEject = nbtTags.getBoolean("autoEject");
roundRobin = nbtTags.getBoolean("roundRobin");
rrIndex = nbtTags.getInteger("rrIndex");
if(nbtTags.hasKey("filters"))
{
NBTTagList tagList = nbtTags.getTagList("filters");
for(int i = 0; i < tagList.tagCount(); i++)
{
filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i)));
}
}
}
@Override
public String getDataType()
{
return "tooltip.filterCard.logisticalSorter";
}
}

View file

@ -33,6 +33,7 @@ item.Salt.name=Salt
item.BrineBucket.name=Brine Bucket
item.FreeRunners.name=Free Runners
item.ArmoredJetpack.name=Armored Jetpack
item.FilterCard.name=Filter Card
//Gas Tank
tile.GasTank.GasTank.name=Gas Tank
@ -266,6 +267,7 @@ gui.on=On
gui.off=Off
gui.filters=Filters
gui.idle=Idle
gui.data=Data
gui.chemicalInfuser.short=C. Infuser
gui.chemicalDissolutionChamber.short=C. Dissolution Chamber
@ -356,6 +358,12 @@ tooltip.configurator.noLink=No link
tooltip.configurator.linkMsg=Bound to
tooltip.configurator.dim=dimension
tooltip.filterCard.got=Retrieved filter data from
tooltip.filterCard.set=Injected filter data of type
tooltip.filterCard.unequal=Unequal filter data formats
tooltip.filterCard.logisticalSorter=Logistical Sorter
tooltip.filterCard.digitalMiner=Digital Miner
tooltip.balloon=Balloon
tooltip.jetpack.regular=Regular

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB