Remove Capacitor and Empty Capacitor, fix mouses, made sorter and miner maintain configuration

This commit is contained in:
Aidan Brady 2013-11-21 21:37:03 -05:00
parent 5f2545d8e8
commit 0e2d2917d1
15 changed files with 158 additions and 177 deletions

View file

@ -1,12 +0,0 @@
package mekanism.api.induction;
import universalelectricity.core.item.IItemElectric;
/**
* @author Calclavia
*
*/
public interface ICapacitor extends IItemElectric
{
}

View file

@ -13,6 +13,7 @@ import mekanism.common.IBoundingBlock;
import mekanism.common.IElectricChest;
import mekanism.common.IFactory;
import mekanism.common.IFactory.RecipeType;
import mekanism.common.IRedstoneControl;
import mekanism.common.ISpecialBounds;
import mekanism.common.ISustainedInventory;
import mekanism.common.ISustainedTank;
@ -21,6 +22,7 @@ import mekanism.common.Mekanism;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.Tier;
import mekanism.common.miner.MinerFilter;
import mekanism.common.network.PacketElectricChest;
import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
import mekanism.common.network.PacketLogisticalSorterGui;
@ -44,7 +46,9 @@ import mekanism.common.tileentity.TileEntityMetallurgicInfuser;
import mekanism.common.tileentity.TileEntityOsmiumCompressor;
import mekanism.common.tileentity.TileEntityPurificationChamber;
import mekanism.common.tileentity.TileEntityTeleporter;
import mekanism.common.transporter.TransporterFilter;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TransporterUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -58,6 +62,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
@ -801,6 +806,81 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
itemStack.stackTagCompound.setByte("config"+i, config.getConfiguration()[i]);
}
}
if(tileEntity instanceof TileEntityDigitalMiner)
{
TileEntityDigitalMiner miner = (TileEntityDigitalMiner)tileEntity;
if(itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.stackTagCompound.setBoolean("hasMinerConfig", true);
itemStack.stackTagCompound.setInteger("radius", miner.radius);
itemStack.stackTagCompound.setInteger("minY", miner.minY);
itemStack.stackTagCompound.setInteger("maxY", miner.maxY);
itemStack.stackTagCompound.setBoolean("doEject", miner.doEject);
itemStack.stackTagCompound.setBoolean("doPull", miner.doPull);
if(miner.replaceStack != null)
{
itemStack.stackTagCompound.setCompoundTag("replaceStack", miner.replaceStack.writeToNBT(new NBTTagCompound()));
}
NBTTagList filterTags = new NBTTagList();
for(MinerFilter filter : miner.filters)
{
filterTags.appendTag(filter.write(new NBTTagCompound()));
}
if(filterTags.tagCount() != 0)
{
itemStack.stackTagCompound.setTag("filters", filterTags);
}
}
if(tileEntity instanceof TileEntityLogisticalSorter)
{
TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity;
if(itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.stackTagCompound.setBoolean("hasSorterConfig", true);
if(sorter.color != null)
{
itemStack.stackTagCompound.setInteger("color", TransporterUtils.colors.indexOf(sorter.color));
}
itemStack.stackTagCompound.setBoolean("autoEject", sorter.autoEject);
itemStack.stackTagCompound.setBoolean("roundRobin", sorter.roundRobin);
NBTTagList filterTags = new NBTTagList();
for(TransporterFilter filter : sorter.filters)
{
NBTTagCompound tagCompound = new NBTTagCompound();
filter.write(tagCompound);
filterTags.appendTag(tagCompound);
}
if(filterTags.tagCount() != 0)
{
itemStack.stackTagCompound.setTag("filters", filterTags);
}
}
if(tileEntity instanceof IRedstoneControl)
{
IRedstoneControl control = (IRedstoneControl)tileEntity;
itemStack.stackTagCompound.setInteger("controlType", control.getControlType().ordinal());
}
if(tileEntity instanceof TileEntityElectricBlock)
{

View file

@ -14,6 +14,8 @@ import mekanism.api.energy.EnergizedItemManager;
import mekanism.api.energy.IEnergizedItem;
import mekanism.common.IElectricChest;
import mekanism.common.IFactory;
import mekanism.common.IRedstoneControl;
import mekanism.common.IRedstoneControl.RedstoneControl;
import mekanism.common.ISustainedInventory;
import mekanism.common.ISustainedTank;
import mekanism.common.Mekanism;
@ -22,12 +24,17 @@ import mekanism.common.PacketHandler.Transmission;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.integration.IC2ItemManager;
import mekanism.common.inventory.InventoryElectricChest;
import mekanism.common.miner.MinerFilter;
import mekanism.common.network.PacketElectricChest;
import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
import mekanism.common.tileentity.TileEntityDigitalMiner;
import mekanism.common.tileentity.TileEntityElectricBlock;
import mekanism.common.tileentity.TileEntityElectricChest;
import mekanism.common.tileentity.TileEntityFactory;
import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.transporter.TransporterFilter;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TransporterUtils;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
@ -203,6 +210,66 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
}
}
if(tileEntity instanceof TileEntityDigitalMiner)
{
TileEntityDigitalMiner miner = (TileEntityDigitalMiner)tileEntity;
if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasMinerConfig"))
{
miner.radius = stack.stackTagCompound.getInteger("radius");
miner.minY = stack.stackTagCompound.getInteger("minY");
miner.maxY = stack.stackTagCompound.getInteger("maxY");
miner.doEject = stack.stackTagCompound.getBoolean("doEject");
miner.doPull = stack.stackTagCompound.getBoolean("doPull");
if(stack.stackTagCompound.hasKey("replaceStack"))
{
miner.replaceStack = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("replaceStack"));
}
if(stack.stackTagCompound.hasKey("filters"))
{
NBTTagList tagList = stack.stackTagCompound.getTagList("filters");
for(int i = 0; i < tagList.tagCount(); i++)
{
miner.filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i)));
}
}
}
}
if(tileEntity instanceof TileEntityLogisticalSorter)
{
TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity;
if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSorterConfig"))
{
if(stack.stackTagCompound.hasKey("color"))
{
sorter.color = TransporterUtils.colors.get(stack.stackTagCompound.getInteger("color"));
}
sorter.autoEject = stack.stackTagCompound.getBoolean("autoEject");
sorter.roundRobin = stack.stackTagCompound.getBoolean("roundRobin");
if(stack.stackTagCompound.hasKey("filters"))
{
NBTTagList tagList = stack.stackTagCompound.getTagList("filters");
for(int i = 0; i < tagList.tagCount(); i++)
{
sorter.filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.tagAt(i)));
}
}
}
}
if(tileEntity instanceof IRedstoneControl)
{
((IRedstoneControl)tileEntity).setControlType(RedstoneControl.values()[stack.stackTagCompound.getInteger("controlType")]);
}
if(tileEntity instanceof TileEntityFactory)
{
((TileEntityFactory)tileEntity).recipeType = getRecipeType(stack);

View file

@ -121,7 +121,7 @@ public class PacketDigitalMinerGui implements IMekanismPacket
{
Container container = null;
playerMP.closeScreen();
playerMP.closeContainer();
if(guiType == 0)
{

View file

@ -121,7 +121,7 @@ public class PacketLogisticalSorterGui implements IMekanismPacket
{
Container container = null;
playerMP.closeScreen();
playerMP.closeContainer();
if(guiType == 0)
{

View file

@ -6,6 +6,7 @@ import mekanism.api.Object3D;
import mekanism.common.Mekanism;
import mekanism.common.tileentity.TileEntityBasicBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World;
import com.google.common.io.ByteArrayDataInput;
@ -44,8 +45,6 @@ public class PacketSimpleGui implements IMekanismPacket
if(worldServer != null && object3D.getTileEntity(worldServer) instanceof TileEntityBasicBlock)
{
player.closeScreen();
if(guiId == -1)
{
return;

View file

@ -9,8 +9,6 @@ import mekanism.induction.common.block.BlockMultimeter;
import mekanism.induction.common.block.BlockTesla;
import mekanism.induction.common.item.ItemBlockContractor;
import mekanism.induction.common.item.ItemBlockMultimeter;
import mekanism.induction.common.item.ItemCapacitor;
import mekanism.induction.common.item.ItemInfiniteCapacitor;
import mekanism.induction.common.item.ItemLinker;
import mekanism.induction.common.tileentity.TileEntityBattery;
import mekanism.induction.common.tileentity.TileEntityEMContractor;
@ -98,8 +96,6 @@ public class MekanismInduction implements IModule
}
// Items
public static Item Capacitor;
public static Item InfiniteCapacitor;
public static Item Linker;
// Blocks
@ -119,9 +115,7 @@ public class MekanismInduction implements IModule
Mekanism.configuration.load();
// Items
Capacitor = new ItemCapacitor(Mekanism.configuration.get(Configuration.CATEGORY_ITEM, "Capacitor", getNextItemID()).getInt()).setUnlocalizedName("Capacitor");
Linker = new ItemLinker(Mekanism.configuration.get(Configuration.CATEGORY_ITEM, "Linker", getNextItemID()).getInt()).setUnlocalizedName("Linker");
InfiniteCapacitor = new ItemInfiniteCapacitor(Mekanism.configuration.get(Configuration.CATEGORY_ITEM, "InfiniteCapacitor", getNextItemID()).getInt()).setUnlocalizedName("InfiniteCapacitor");
// Blocks
Tesla = new BlockTesla(Mekanism.configuration.getBlock("Tesla", getNextBlockID()).getInt()).setUnlocalizedName("Tesla");
@ -131,8 +125,6 @@ public class MekanismInduction implements IModule
Mekanism.configuration.save();
GameRegistry.registerItem(Capacitor, "Capacitor");
GameRegistry.registerItem(InfiniteCapacitor, "InfiniteCapacitor");
GameRegistry.registerItem(Linker, "Linker");
GameRegistry.registerBlock(Tesla, "Tesla");
@ -161,29 +153,23 @@ public class MekanismInduction implements IModule
@EventHandler
public void postInit(FMLPostInitializationEvent evt)
{
/**
* Recipes
*/
ItemStack emptyCapacitor = new ItemStack(Capacitor);
((IItemElectric)Capacitor).setElectricity(emptyCapacitor, 0);
/** Capacitor **/
GameRegistry.addRecipe(new ShapedOreRecipe(emptyCapacitor, "RRR", "RIR", "RRR", 'R', Item.redstone, 'I', UniversalRecipes.PRIMARY_METAL));
GameRegistry.addRecipe(new ShapedOreRecipe(Mekanism.EnergyTablet, "RRR", "RIR", "RRR", 'R', Item.redstone, 'I', UniversalRecipes.PRIMARY_METAL));
/** Linker **/
GameRegistry.addRecipe(new ShapedOreRecipe(Linker, " E ", "GCG", " E ", 'E', Item.eyeOfEnder, 'C', emptyCapacitor, 'G', UniversalRecipes.SECONDARY_METAL));
GameRegistry.addRecipe(new ShapedOreRecipe(Linker, " E ", "GCG", " E ", 'E', Item.eyeOfEnder, 'C', Mekanism.EnergyTablet, 'G', UniversalRecipes.SECONDARY_METAL));
/** Tesla - by Jyzarc */
GameRegistry.addRecipe(new ShapedOreRecipe(Tesla, "WEW", " C ", " I ", 'W', Mekanism.EnrichedAlloy, 'E', Item.eyeOfEnder, 'C', emptyCapacitor, 'I', Mekanism.MachineBlock));
GameRegistry.addRecipe(new ShapedOreRecipe(Tesla, "WEW", " C ", " I ", 'W', Mekanism.EnrichedAlloy, 'E', Item.eyeOfEnder, 'C', Mekanism.EnergyTablet, 'I', Mekanism.MachineBlock));
/** Multimeter */
GameRegistry.addRecipe(new ShapedOreRecipe(Multimeter, "WWW", "ICI", 'W', Mekanism.EnrichedAlloy, 'C', emptyCapacitor, 'I', UniversalRecipes.PRIMARY_METAL));
GameRegistry.addRecipe(new ShapedOreRecipe(Multimeter, "WWW", "ICI", 'W', Mekanism.EnrichedAlloy, 'C', Mekanism.EnergyTablet, 'I', UniversalRecipes.PRIMARY_METAL));
/** Battery */
GameRegistry.addRecipe(new ShapedOreRecipe(Battery, "III", "IRI", "III", 'R', Block.blockRedstone, 'I', Mekanism.EnergyCube));
/** EM Contractor */
GameRegistry.addRecipe(new ShapedOreRecipe(ElectromagneticContractor, " I ", "GCG", "WWW", 'W', UniversalRecipes.PRIMARY_METAL, 'C', emptyCapacitor, 'G', UniversalRecipes.SECONDARY_METAL, 'I', UniversalRecipes.PRIMARY_METAL));
GameRegistry.addRecipe(new ShapedOreRecipe(ElectromagneticContractor, " I ", "GCG", "WWW", 'W', UniversalRecipes.PRIMARY_METAL, 'C', Mekanism.EnergyTablet, 'G', UniversalRecipes.SECONDARY_METAL, 'I', UniversalRecipes.PRIMARY_METAL));
}
@Override

View file

@ -3,7 +3,6 @@
*/
package mekanism.induction.common.block;
import mekanism.api.induction.ICapacitor;
import mekanism.common.Mekanism;
import mekanism.common.util.ListUtils;
import mekanism.induction.client.render.BlockRenderingHandler;
@ -12,7 +11,6 @@ import mekanism.induction.common.tileentity.TileEntityBattery;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -78,7 +76,7 @@ public class BlockBattery extends Block implements ITileEntityProvider
{
if (entityPlayer.getCurrentEquippedItem() != null)
{
if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ICapacitor)
if (entityPlayer.getCurrentEquippedItem().itemID == Mekanism.EnergyTablet.itemID)
{
if (side != 0 && side != 1)
{

View file

@ -1,42 +0,0 @@
/**
*
*/
package mekanism.induction.common.item;
import mekanism.api.induction.ICapacitor;
import mekanism.common.Mekanism;
import mekanism.induction.common.MekanismInduction;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration;
import universalelectricity.compatibility.ItemUniversalElectric;
/**
* Stores power.
*
* @author Calclavia
*
*/
public class ItemCapacitor extends ItemUniversalElectric implements ICapacitor
{
public ItemCapacitor(int id)
{
super(id);
this.setCreativeTab(Mekanism.tabMekanism);
this.setTextureName("mekanism:Capacitor");
this.setMaxStackSize(1);
this.setMaxDamage(100);
}
@Override
public float getTransfer(ItemStack itemStack)
{
return this.getMaxEnergyStored(itemStack) * 0.05F;
}
@Override
public float getMaxElectricityStored(ItemStack theItem)
{
return 500;
}
}

View file

@ -1,87 +0,0 @@
/**
*
*/
package mekanism.induction.common.item;
import java.util.List;
import mekanism.common.Mekanism;
import mekanism.induction.common.MekanismInduction;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.Configuration;
import universalelectricity.compatibility.ItemUniversalElectric;
/**
* Stores power.
*
* @author Calclavia
*
*/
public class ItemInfiniteCapacitor extends ItemUniversalElectric
{
public ItemInfiniteCapacitor(int id)
{
super(id);
this.setCreativeTab(Mekanism.tabMekanism);
this.setTextureName("mekanism:Capacitor");
this.setMaxStackSize(1);
this.setMaxDamage(100);
}
@Override
public void registerIcons(IconRegister register)
{
itemIcon = register.registerIcon("mekanism:Capacitor");
}
@Override
public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean par4)
{
list.add("Infinite");
}
@Override
public float recharge(ItemStack itemStack, float energy, boolean doReceive)
{
return energy;
}
@Override
public float discharge(ItemStack itemStack, float energy, boolean doTransfer)
{
return energy;
}
@Override
public void setElectricity(ItemStack itemStack, float joules)
{
}
@Override
public float getTransfer(ItemStack itemStack)
{
return Float.POSITIVE_INFINITY;
}
@Override
public float getElectricityStored(ItemStack itemStack)
{
return Float.POSITIVE_INFINITY;
}
@Override
public float getMaxElectricityStored(ItemStack theItem)
{
return Float.POSITIVE_INFINITY;
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(this));
}
}

View file

@ -11,8 +11,8 @@ import java.util.List;
import java.util.Set;
import mekanism.api.Object3D;
import mekanism.api.induction.ICapacitor;
import mekanism.common.ITileNetwork;
import mekanism.common.Mekanism;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketDataRequest;
@ -75,7 +75,7 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
{
if(structure.inventory.size() < structure.getMaxCells())
{
if(structure.visibleInventory[0].getItem() instanceof ICapacitor)
if(structure.visibleInventory[0].itemID == Mekanism.EnergyTablet.itemID)
{
structure.inventory.add(structure.visibleInventory[0]);
structure.visibleInventory[0] = null;

View file

@ -223,6 +223,4 @@ tile.ElectromagneticContractor.name=Elektromagnetischer Kontraktor
tile.Battery.name=Modulare Batterie
//Items
item.Capacitor.name=Kondensatorenzelle
item.InfiniteCapacitor.name=Unendliche Kondensatorenzelle
item.Linker.name=Elektrostatischer Linker

View file

@ -224,6 +224,4 @@ tile.ElectromagneticContractor.name=Electromagnetic Contractor
tile.Battery.name=Modular Battery
//Items
item.Capacitor.name=Capacitor Cell
item.InfiniteCapacitor.name=Infinite Capacitor Cell
item.Linker.name=Electrostatic Linker

View file

@ -223,6 +223,4 @@ tile.ElectromagneticContractor.name=Электромагнитный контр
tile.Battery.name=Модульный аккумулятор
//Items
item.Capacitor.name=Capacitor Cell
item.InfiniteCapacitor.name=Infinite Capacitor Cell
item.Linker.name=Electrostatic Linker

View file

@ -223,6 +223,4 @@ tile.ElectromagneticContractor.name=电磁承接口
tile.Battery.name=模块电池
//Items
item.Capacitor.name=电容器
item.InfiniteCapacitor.name=无限电容器
item.Linker.name=静电链接器