This commit is contained in:
Aidan Brady 2013-11-30 12:29:49 -05:00
parent 0c618a1cf3
commit a4ab6db57b
29 changed files with 337 additions and 227 deletions

View file

@ -1,8 +1,10 @@
package mekanism.api.transmitters; package mekanism.api.transmitters;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.Set; import java.util.Set;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -137,19 +139,18 @@ public class TransmitterNetworkRegistry implements ITickHandler
try { try {
if(c != null) if(c != null)
{ {
synchronized(INSTANCE) Map copy = (Map)((HashMap)c.chunkTileEntityMap).clone();
{
for(Iterator iter = c.chunkTileEntityMap.values().iterator(); iter.hasNext();)
{
Object obj = iter.next();
if(obj instanceof ITransmitter) for(Iterator iter = c.chunkTileEntityMap.values().iterator(); iter.hasNext();)
{ {
((ITransmitter)obj).refreshTransmitterNetwork(); Object obj = iter.next();
((ITransmitter)obj).chunkLoad();
} if(obj instanceof ITransmitter)
} {
} ((ITransmitter)obj).refreshTransmitterNetwork();
((ITransmitter)obj).chunkLoad();
}
}
} }
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();

View file

@ -60,7 +60,7 @@ import mekanism.client.sound.SoundHandler;
import mekanism.common.CommonProxy; import mekanism.common.CommonProxy;
import mekanism.common.EntityObsidianTNT; import mekanism.common.EntityObsidianTNT;
import mekanism.common.EntityRobit; import mekanism.common.EntityRobit;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.IElectricChest; import mekanism.common.IElectricChest;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
@ -308,7 +308,7 @@ public class ClientProxy extends CommonProxy
case 8: case 8:
return new GuiEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity); return new GuiEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity);
case 9: case 9:
return new GuiConfiguration(player, (IConfigurable)tileEntity); return new GuiConfiguration(player, (IInvConfiguration)tileEntity);
case 10: case 10:
return new GuiGasTank(player.inventory, (TileEntityGasTank)tileEntity); return new GuiGasTank(player.inventory, (TileEntityGasTank)tileEntity);
case 11: case 11:

View file

@ -5,7 +5,7 @@ import java.util.Map;
import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer;
import mekanism.common.EnumColor; import mekanism.common.EnumColor;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.Object3D; import mekanism.common.Object3D;
import mekanism.common.PacketHandler; import mekanism.common.PacketHandler;
import mekanism.common.SideData; import mekanism.common.SideData;
@ -32,9 +32,9 @@ public class GuiConfiguration extends GuiMekanism
public Map<Integer, GuiPos> inputPosMap = new HashMap<Integer, GuiPos>(); public Map<Integer, GuiPos> inputPosMap = new HashMap<Integer, GuiPos>();
public IConfigurable configurable; public IInvConfiguration configurable;
public GuiConfiguration(EntityPlayer player, IConfigurable tile) public GuiConfiguration(EntityPlayer player, IInvConfiguration tile)
{ {
super(new ContainerNull(player, (TileEntityContainerBlock)tile)); super(new ContainerNull(player, (TileEntityContainerBlock)tile));

View file

@ -3,7 +3,7 @@ package mekanism.client.gui;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.SideData; import mekanism.common.SideData;
import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemConfigurator;
import mekanism.common.tileentity.TileEntityContainerBlock; import mekanism.common.tileentity.TileEntityContainerBlock;
@ -75,7 +75,7 @@ public abstract class GuiMekanism extends GuiContainer
{ {
if(slot.slotNumber < tileEntity.getSizeInventory()) if(slot.slotNumber < tileEntity.getSizeInventory())
{ {
IConfigurable config = (IConfigurable)tileEntity; IInvConfiguration config = (IInvConfiguration)tileEntity;
for(SideData data : config.getSideData()) for(SideData data : config.getSideData())
{ {

View file

@ -6,7 +6,7 @@ import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.MekanismRenderer.DisplayInteger; import mekanism.client.render.MekanismRenderer.DisplayInteger;
import mekanism.client.render.MekanismRenderer.Model3D; import mekanism.client.render.MekanismRenderer.Model3D;
import mekanism.common.EnumColor; import mekanism.common.EnumColor;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.Object3D; import mekanism.common.Object3D;
import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemConfigurator;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
@ -39,10 +39,10 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
{ {
renderAModelAt((IConfigurable)tileEntity, x, y, z, partialTick); renderAModelAt((IInvConfiguration)tileEntity, x, y, z, partialTick);
} }
public void renderAModelAt(IConfigurable configurable, double x, double y, double z, float partialTick) public void renderAModelAt(IInvConfiguration configurable, double x, double y, double z, float partialTick)
{ {
TileEntity tileEntity = (TileEntity)configurable; TileEntity tileEntity = (TileEntity)configurable;
EntityPlayer player = mc.thePlayer; EntityPlayer player = mc.thePlayer;

View file

@ -1,35 +1,10 @@
package mekanism.common; package mekanism.common;
import java.util.ArrayList; import net.minecraft.entity.player.EntityPlayer;
/**
* Implement this if your TileEntity is capable of being modified by a Configurator in it's 'modify' mode.
* @author AidanBrady
*
*/
public interface IConfigurable public interface IConfigurable
{ {
/** public boolean onSneakRightClick(EntityPlayer player, int side);
* Gets an ArrayList of side data this machine contains.
* @return
*/
public ArrayList<SideData> getSideData();
/** public boolean onRightClick(EntityPlayer player, int side);
* Gets this machine's configuration as a byte[] -- each byte matching with the index of the defined SideData.
* @return
*/
public byte[] getConfiguration();
/**
* Gets this machine's current orientation.
* @return
*/
public int getOrientation();
/**
* Gets this machine's ejector.
* @return
*/
public IEjector getEjector();
} }

View file

@ -0,0 +1,35 @@
package mekanism.common;
import java.util.ArrayList;
/**
* Implement this if your TileEntity is capable of being modified by a Configurator in it's 'modify' mode.
* @author AidanBrady
*
*/
public interface IInvConfiguration
{
/**
* Gets an ArrayList of side data this machine contains.
* @return
*/
public ArrayList<SideData> getSideData();
/**
* Gets this machine's configuration as a byte[] -- each byte matching with the index of the defined SideData.
* @return
*/
public byte[] getConfiguration();
/**
* Gets this machine's current orientation.
* @return
*/
public int getOrientation();
/**
* Gets this machine's ejector.
* @return
*/
public IEjector getEjector();
}

View file

@ -1206,11 +1206,13 @@ public class Mekanism
} }
@ForgeSubscribe @ForgeSubscribe
public void onChunkLoad(ChunkEvent.Load event) public synchronized void onChunkLoad(ChunkEvent.Load event)
{ {
if(event.getChunk() != null && !event.world.isRemote) if(event.getChunk() != null && !event.world.isRemote)
{ {
for(Iterator iter = event.getChunk().chunkTileEntityMap.values().iterator(); iter.hasNext();) Map copy = (Map)((HashMap)event.getChunk().chunkTileEntityMap).clone();
for(Iterator iter = copy.values().iterator(); iter.hasNext();)
{ {
Object obj = iter.next(); Object obj = iter.next();

View file

@ -84,7 +84,7 @@ public class TileComponentEjector implements ITileComponent, IEjector
List<ForgeDirection> outputSides = new ArrayList<ForgeDirection>(); List<ForgeDirection> outputSides = new ArrayList<ForgeDirection>();
IConfigurable configurable = (IConfigurable)tileEntity; IInvConfiguration configurable = (IInvConfiguration)tileEntity;
for(int i = 0; i < configurable.getConfiguration().length; i++) for(int i = 0; i < configurable.getConfiguration().length; i++)
{ {

View file

@ -11,7 +11,7 @@ import mekanism.common.IBoundingBlock;
import mekanism.common.IElectricChest; import mekanism.common.IElectricChest;
import mekanism.common.IFactory; import mekanism.common.IFactory;
import mekanism.common.IFactory.RecipeType; import mekanism.common.IFactory.RecipeType;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.IRedstoneControl; import mekanism.common.IRedstoneControl;
import mekanism.common.ISpecialBounds; import mekanism.common.ISpecialBounds;
import mekanism.common.ISustainedInventory; import mekanism.common.ISustainedInventory;
@ -790,9 +790,9 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
upgrade.setSpeedMultiplier(((IUpgradeManagement)tileEntity).getSpeedMultiplier(), itemStack); upgrade.setSpeedMultiplier(((IUpgradeManagement)tileEntity).getSpeedMultiplier(), itemStack);
} }
if(tileEntity instanceof IConfigurable) if(tileEntity instanceof IInvConfiguration)
{ {
IConfigurable config = (IConfigurable)tileEntity; IInvConfiguration config = (IInvConfiguration)tileEntity;
if(itemStack.stackTagCompound == null) if(itemStack.stackTagCompound == null)
{ {

View file

@ -17,7 +17,7 @@ import mekanism.common.IFactory;
import mekanism.common.IRedstoneControl; import mekanism.common.IRedstoneControl;
import mekanism.common.IRedstoneControl.RedstoneControl; import mekanism.common.IRedstoneControl.RedstoneControl;
import mekanism.common.EnumColor; import mekanism.common.EnumColor;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.ISustainedInventory; import mekanism.common.ISustainedInventory;
import mekanism.common.ISustainedTank; import mekanism.common.ISustainedTank;
import mekanism.common.IUpgradeManagement; import mekanism.common.IUpgradeManagement;
@ -209,9 +209,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
((IUpgradeManagement)tileEntity).setSpeedMultiplier(getSpeedMultiplier(stack)); ((IUpgradeManagement)tileEntity).setSpeedMultiplier(getSpeedMultiplier(stack));
} }
if(tileEntity instanceof IConfigurable) if(tileEntity instanceof IInvConfiguration)
{ {
IConfigurable config = (IConfigurable)tileEntity; IInvConfiguration config = (IInvConfiguration)tileEntity;
if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSideData")) if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSideData"))
{ {

View file

@ -4,25 +4,19 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import mekanism.api.transmitters.ITransmitter;
import mekanism.common.EnumColor; import mekanism.common.EnumColor;
import mekanism.common.IConfigurable; import mekanism.common.IConfigurable;
import mekanism.common.IInvConfiguration;
import mekanism.common.Object3D; import mekanism.common.Object3D;
import mekanism.common.PacketHandler; import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission; import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketTileEntity; import mekanism.common.network.PacketTileEntity;
import mekanism.common.tileentity.TileEntityBasicBlock; import mekanism.common.tileentity.TileEntityBasicBlock;
import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.tileentity.TileEntityContainerBlock;
import mekanism.common.tileentity.TileEntityElectricChest; import mekanism.common.tileentity.TileEntityElectricChest;
import mekanism.common.tileentity.TileEntityElectricPump;
import mekanism.common.tileentity.TileEntityDiversionTransporter;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.tileentity.TileEntityMechanicalPipe;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TransporterUtils;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -35,6 +29,8 @@ public class ItemConfigurator extends ItemEnergized
public final int ENERGY_PER_CONFIGURE = 400; public final int ENERGY_PER_CONFIGURE = 400;
public final int ENERGY_PER_ITEM_DUMP = 8; public final int ENERGY_PER_ITEM_DUMP = 8;
private Random random = new Random();
public ItemConfigurator(int id) public ItemConfigurator(int id)
{ {
super(id, 60000, 120); super(id, 60000, 120);
@ -52,78 +48,26 @@ public class ItemConfigurator extends ItemEnergized
{ {
if(!world.isRemote) if(!world.isRemote)
{ {
if(player.isSneaking()) TileEntity tile = world.getBlockTileEntity(x, y, z);
if(tile instanceof IConfigurable)
{ {
if(world.getBlockTileEntity(x, y, z) instanceof TileEntityMechanicalPipe) IConfigurable config = (IConfigurable)tile;
{
TileEntityMechanicalPipe tileEntity = (TileEntityMechanicalPipe)world.getBlockTileEntity(x, y, z);
tileEntity.isActive = !tileEntity.isActive;
tileEntity.getTransmitterNetwork().refresh();
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())));
return true;
}
else if(world.getBlockTileEntity(x, y, z) instanceof TileEntityElectricPump)
{
TileEntityElectricPump tileEntity = (TileEntityElectricPump)world.getBlockTileEntity(x, y, z);
tileEntity.recurringNodes.clear();
tileEntity.cleaningNodes.clear();
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.configurator.pumpReset"))); if(player.isSneaking())
return true; {
} config.onSneakRightClick(player, side);
else if(world.getBlockTileEntity(x, y, z) instanceof TileEntityLogisticalTransporter) }
{ else {
if(world.getBlockTileEntity(x, y, z) instanceof TileEntityDiversionTransporter) config.onRightClick(player, side);
{ }
TileEntityDiversionTransporter transporter = (TileEntityDiversionTransporter)world.getBlockTileEntity(x, y, z);
int newMode = (transporter.modes[side] + 1) % 3;
String description = "ERROR";
transporter.modes[side] = newMode;
switch(newMode)
{
case 0:
description = MekanismUtils.localize("control.disabled.desc");
break;
case 1:
description = MekanismUtils.localize("control.high.desc");
break;
case 2:
description = MekanismUtils.localize("control.low.desc");
break;
}
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleDiverter") + ": " + EnumColor.RED + description));
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(transporter), transporter.getNetworkedData(new ArrayList())), Object3D.get(transporter), 50D);
return true;
}
else {
TileEntityLogisticalTransporter transporter = (TileEntityLogisticalTransporter)world.getBlockTileEntity(x, y, z);
TransporterUtils.incrementColor(transporter);
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(transporter), transporter.getNetworkedData(new ArrayList())), Object3D.get(transporter), 50D);
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleColor") + ": " + (transporter.color != null ? transporter.color.getName() : EnumColor.BLACK + MekanismUtils.localize("gui.none"))));
return true;
}
}
else if(world.getBlockTileEntity(x, y, z) instanceof TileEntityBin)
{
TileEntityBin bin = (TileEntityBin)world.getBlockTileEntity(x, y, z);
bin.setActive(!bin.getActive());
world.playSoundEffect(x, y, z, "random.click", 0.3F, 1);
return true;
}
}
else if(world.getBlockTileEntity(x, y, z) instanceof ITransmitter)
{
((ITransmitter)world.getBlockTileEntity(x, y, z)).fixTransmitterNetwork();
} }
if(getState(stack) == 0) if(getState(stack) == 0)
{ {
if(world.getBlockTileEntity(x, y, z) instanceof IConfigurable) if(tile instanceof IInvConfiguration)
{ {
IConfigurable config = (IConfigurable)world.getBlockTileEntity(x, y, z); IInvConfiguration config = (IInvConfiguration)tile;
if(!player.isSneaking()) if(!player.isSneaking())
{ {
@ -150,17 +94,16 @@ public class ItemConfigurator extends ItemEnergized
} }
else if(getState(stack) == 1) else if(getState(stack) == 1)
{ {
if(world.getBlockTileEntity(x, y, z) instanceof TileEntityContainerBlock) if(tile instanceof IInventory)
{ {
int itemAmount = 0; int itemAmount = 0;
Random random = new Random(); IInventory inv = (IInventory)tile;
TileEntityContainerBlock tileEntity = (TileEntityContainerBlock)world.getBlockTileEntity(x, y, z);
if(!(tileEntity instanceof TileEntityElectricChest) || (((TileEntityElectricChest)tileEntity).canAccess())) if(!(inv instanceof TileEntityElectricChest) || (((TileEntityElectricChest)inv).canAccess()))
{ {
for(int i = 0; i < tileEntity.getSizeInventory(); i++) for(int i = 0; i < inv.getSizeInventory(); i++)
{ {
ItemStack slotStack = tileEntity.getStackInSlot(i); ItemStack slotStack = inv.getStackInSlot(i);
if(slotStack != null) if(slotStack != null)
{ {
@ -196,7 +139,7 @@ public class ItemConfigurator extends ItemEnergized
item.motionZ = random.nextGaussian() * k; item.motionZ = random.nextGaussian() * k;
world.spawnEntityInWorld(item); world.spawnEntityInWorld(item);
tileEntity.inventory[i] = null; inv.setInventorySlotContents(i, null);
setEnergy(stack, getEnergy(stack) - ENERGY_PER_ITEM_DUMP); setEnergy(stack, getEnergy(stack) - ENERGY_PER_ITEM_DUMP);
} }
} }
@ -212,11 +155,9 @@ public class ItemConfigurator extends ItemEnergized
} }
else if(getState(stack) == 2) else if(getState(stack) == 2)
{ {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if(tile instanceof TileEntityBasicBlock)
if(tileEntity instanceof TileEntityBasicBlock)
{ {
TileEntityBasicBlock basicBlock = (TileEntityBasicBlock)tileEntity; TileEntityBasicBlock basicBlock = (TileEntityBasicBlock)tile;
int newSide = basicBlock.facing; int newSide = basicBlock.facing;
if(!player.isSneaking()) if(!player.isSneaking())

View file

@ -3,7 +3,7 @@ package mekanism.common.network;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.ITileNetwork; import mekanism.common.ITileNetwork;
import mekanism.common.Object3D; import mekanism.common.Object3D;
import mekanism.common.PacketHandler; import mekanism.common.PacketHandler;
@ -72,9 +72,9 @@ public class PacketConfigurationUpdate implements IMekanismPacket
TileEntity tile = object3D.getTileEntity(world); TileEntity tile = object3D.getTileEntity(world);
if(tile instanceof IConfigurable) if(tile instanceof IInvConfiguration)
{ {
IConfigurable config = (IConfigurable)tile; IInvConfiguration config = (IInvConfiguration)tile;
if(packetType == ConfigurationPacket.EJECT) if(packetType == ConfigurationPacket.EJECT)
{ {
@ -87,15 +87,15 @@ public class PacketConfigurationUpdate implements IMekanismPacket
if(clickType == 0) if(clickType == 0)
{ {
MekanismUtils.incrementOutput((IConfigurable)tile, configIndex); MekanismUtils.incrementOutput((IInvConfiguration)tile, configIndex);
} }
else if(clickType == 1) else if(clickType == 1)
{ {
MekanismUtils.decrementOutput((IConfigurable)tile, configIndex); MekanismUtils.decrementOutput((IInvConfiguration)tile, configIndex);
} }
else if(clickType == 2) else if(clickType == 2)
{ {
((IConfigurable)tile).getConfiguration()[configIndex] = 0; ((IInvConfiguration)tile).getConfiguration()[configIndex] = 0;
} }
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(object3D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), object3D, 50D); PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(object3D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), object3D, 50D);

View file

@ -4,7 +4,7 @@ import java.util.ArrayList;
import mekanism.client.sound.IHasSound; import mekanism.client.sound.IHasSound;
import mekanism.common.IActiveState; import mekanism.common.IActiveState;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.IEjector; import mekanism.common.IEjector;
import mekanism.common.IElectricMachine; import mekanism.common.IElectricMachine;
import mekanism.common.IRedstoneControl; import mekanism.common.IRedstoneControl;
@ -26,7 +26,7 @@ import com.google.common.io.ByteArrayDataInput;
import dan200.computer.api.IComputerAccess; import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral; import dan200.computer.api.IPeripheral;
public abstract class TileEntityBasicMachine extends TileEntityElectricBlock implements IElectricMachine, IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IRedstoneControl public abstract class TileEntityBasicMachine extends TileEntityElectricBlock implements IElectricMachine, IPeripheral, IActiveState, IInvConfiguration, IUpgradeTile, IHasSound, IRedstoneControl
{ {
/** This machine's side configuration. */ /** This machine's side configuration. */
public byte[] sideConfig; public byte[] sideConfig;

View file

@ -3,6 +3,7 @@ package mekanism.common.tileentity;
import java.util.ArrayList; import java.util.ArrayList;
import mekanism.common.IActiveState; import mekanism.common.IActiveState;
import mekanism.common.IConfigurable;
import mekanism.common.Object3D; import mekanism.common.Object3D;
import mekanism.common.PacketHandler; import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission; import mekanism.common.PacketHandler.Transmission;
@ -23,7 +24,7 @@ import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IDeepStorageUnit public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IDeepStorageUnit, IConfigurable
{ {
public boolean isActive; public boolean isActive;
@ -490,4 +491,18 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
{ {
return MAX_STORAGE; return MAX_STORAGE;
} }
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
setActive(!getActive());
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.click", 0.3F, 1);
return true;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
return false;
}
} }

View file

@ -30,18 +30,21 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
{ {
super.readFromNBT(nbtTags); super.readFromNBT(nbtTags);
NBTTagList tagList = nbtTags.getTagList("Items"); if(handleInventory())
inventory = new ItemStack[getSizeInventory()];
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
{ {
NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount); NBTTagList tagList = nbtTags.getTagList("Items");
byte slotID = tagCompound.getByte("Slot"); inventory = new ItemStack[getSizeInventory()];
if(slotID >= 0 && slotID < getSizeInventory()) for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
{ {
setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound)); NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount);
} byte slotID = tagCompound.getByte("Slot");
if(slotID >= 0 && slotID < getSizeInventory())
{
setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
}
}
} }
} }
@ -50,20 +53,23 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
{ {
super.writeToNBT(nbtTags); super.writeToNBT(nbtTags);
NBTTagList tagList = new NBTTagList(); if(handleInventory())
for(int slotCount = 0; slotCount < getSizeInventory(); slotCount++)
{ {
if(getStackInSlot(slotCount) != null) NBTTagList tagList = new NBTTagList();
{
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setByte("Slot", (byte)slotCount);
getStackInSlot(slotCount).writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
}
}
nbtTags.setTag("Items", tagList); for(int slotCount = 0; slotCount < getSizeInventory(); slotCount++)
{
if(getStackInSlot(slotCount) != null)
{
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setByte("Slot", (byte)slotCount);
getStackInSlot(slotCount).writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
}
}
nbtTags.setTag("Items", tagList);
}
} }
@Override @Override
@ -189,7 +195,7 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
@Override @Override
public void setInventory(NBTTagList nbtTags, Object... data) public void setInventory(NBTTagList nbtTags, Object... data)
{ {
if(nbtTags == null || nbtTags.tagCount() == 0) if(nbtTags == null || nbtTags.tagCount() == 0 || !handleInventory())
{ {
return; return;
} }
@ -213,17 +219,25 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
{ {
NBTTagList tagList = new NBTTagList(); NBTTagList tagList = new NBTTagList();
for(int slots = 0; slots < inventory.length; slots++) if(handleInventory())
{ {
if(inventory[slots] != null) for(int slots = 0; slots < inventory.length; slots++)
{ {
NBTTagCompound tagCompound = new NBTTagCompound(); if(inventory[slots] != null)
tagCompound.setByte("Slot", (byte)slots); {
inventory[slots].writeToNBT(tagCompound); NBTTagCompound tagCompound = new NBTTagCompound();
tagList.appendTag(tagCompound); tagCompound.setByte("Slot", (byte)slots);
} inventory[slots].writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
}
}
} }
return tagList; return tagList;
} }
public boolean handleInventory()
{
return true;
}
} }

View file

@ -2,12 +2,18 @@ package mekanism.common.tileentity;
import java.util.ArrayList; import java.util.ArrayList;
import com.google.common.io.ByteArrayDataInput; import mekanism.common.EnumColor;
import mekanism.common.Object3D;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.transporter.TransporterStack; import mekanism.common.transporter.TransporterStack;
import mekanism.common.util.TransporterUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.util.ChatMessageComponent;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityDiversionTransporter extends TileEntityLogisticalTransporter public class TileEntityDiversionTransporter extends TileEntityLogisticalTransporter
{ {
@ -71,4 +77,31 @@ public class TileEntityDiversionTransporter extends TileEntityLogisticalTranspor
return data; return data;
} }
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
int newMode = (modes[side] + 1) % 3;
String description = "ERROR";
modes[side] = newMode;
switch(newMode)
{
case 0:
description = MekanismUtils.localize("control.disabled.desc");
break;
case 1:
description = MekanismUtils.localize("control.high.desc");
break;
case 2:
description = MekanismUtils.localize("control.low.desc");
break;
}
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleDiverter") + ": " + EnumColor.RED + description));
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), Object3D.get(this), 50D);
return true;
}
} }

View file

@ -84,7 +84,9 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
protected EnumSet<ForgeDirection> getConsumingSides() protected EnumSet<ForgeDirection> getConsumingSides()
{ {
return EnumSet.allOf(ForgeDirection.class); EnumSet set = EnumSet.allOf(ForgeDirection.class);
set.remove(ForgeDirection.UNKNOWN);
return set;
} }
public double getMaxOutput() public double getMaxOutput()

View file

@ -8,18 +8,21 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import mekanism.common.EnumColor;
import mekanism.common.IConfigurable;
import mekanism.common.ISustainedTank; import mekanism.common.ISustainedTank;
import mekanism.common.Mekanism;
import mekanism.common.Object3D; import mekanism.common.Object3D;
import mekanism.common.PacketHandler; import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission; import mekanism.common.PacketHandler.Transmission;
import mekanism.common.network.PacketTileEntity; import mekanism.common.network.PacketTileEntity;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatMessageComponent;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
@ -30,7 +33,7 @@ import net.minecraftforge.fluids.IFluidHandler;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank, IConfigurable
{ {
/** This pump's tank */ /** This pump's tank */
public FluidTank fluidTank; public FluidTank fluidTank;
@ -511,4 +514,21 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
{ {
return from == ForgeDirection.getOrientation(1); return from == ForgeDirection.getOrientation(1);
} }
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
recurringNodes.clear();
cleaningNodes.clear();
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.configurator.pumpReset")));
return true;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
return false;
}
} }

View file

@ -98,6 +98,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPo
{ {
EnumSet set = EnumSet.allOf(ForgeDirection.class); EnumSet set = EnumSet.allOf(ForgeDirection.class);
set.remove(getOutputtingSides()); set.remove(getOutputtingSides());
set.remove(ForgeDirection.UNKNOWN);
return set; return set;
} }

View file

@ -14,7 +14,7 @@ import mekanism.client.sound.IHasSound;
import mekanism.common.IActiveState; import mekanism.common.IActiveState;
import mekanism.common.IFactory.RecipeType; import mekanism.common.IFactory.RecipeType;
import mekanism.common.EnumColor; import mekanism.common.EnumColor;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.IEjector; import mekanism.common.IEjector;
import mekanism.common.IRedstoneControl; import mekanism.common.IRedstoneControl;
import mekanism.common.IUpgradeTile; import mekanism.common.IUpgradeTile;
@ -40,7 +40,7 @@ import dan200.computer.api.IComputerAccess;
import dan200.computer.api.ILuaContext; import dan200.computer.api.ILuaContext;
import dan200.computer.api.IPeripheral; import dan200.computer.api.IPeripheral;
public class TileEntityFactory extends TileEntityElectricBlock implements IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IRedstoneControl, IGasAcceptor, IGasStorage, ITubeConnection public class TileEntityFactory extends TileEntityElectricBlock implements IPeripheral, IActiveState, IInvConfiguration, IUpgradeTile, IHasSound, IRedstoneControl, IGasAcceptor, IGasStorage, ITubeConnection
{ {
/** This Factory's tier. */ /** This Factory's tier. */
public FactoryTier tier; public FactoryTier tier;

View file

@ -6,6 +6,7 @@ import java.util.Set;
import mekanism.common.EnumColor; import mekanism.common.EnumColor;
import mekanism.common.HashList; import mekanism.common.HashList;
import mekanism.common.IConfigurable;
import mekanism.common.ITileNetwork; import mekanism.common.ITileNetwork;
import mekanism.common.Object3D; import mekanism.common.Object3D;
import mekanism.common.PacketHandler; import mekanism.common.PacketHandler;
@ -18,12 +19,14 @@ import mekanism.common.transporter.TransporterStack.Path;
import mekanism.common.util.InventoryUtils; import mekanism.common.util.InventoryUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TransporterUtils; import mekanism.common.util.TransporterUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatMessageComponent;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -36,7 +39,7 @@ import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class TileEntityLogisticalTransporter extends TileEntity implements ITileNetwork, IPipeTile public class TileEntityLogisticalTransporter extends TileEntity implements ITileNetwork, IPipeTile, IConfigurable
{ {
public static final int SPEED = 5; public static final int SPEED = 5;
@ -532,4 +535,20 @@ public class TileEntityLogisticalTransporter extends TileEntity implements ITile
{ {
return true; return true;
} }
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
TransporterUtils.incrementColor(this);
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), Object3D.get(this), 50D);
player.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + MekanismUtils.localize("tooltip.configurator.toggleColor") + ": " + (color != null ? color.getName() : EnumColor.BLACK + MekanismUtils.localize("gui.none"))));
return true;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
return false;
}
} }

View file

@ -13,6 +13,8 @@ import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission; import mekanism.common.PacketHandler.Transmission;
import mekanism.common.PipeUtils; import mekanism.common.PipeUtils;
import mekanism.common.network.PacketDataRequest; import mekanism.common.network.PacketDataRequest;
import mekanism.common.network.PacketTileEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
@ -273,4 +275,14 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<FluidNetwork
{ {
return getTransmitterNetwork().getFlow(); return getTransmitterNetwork().getFlow();
} }
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
isActive = !isActive;
getTransmitterNetwork().refresh();
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
return true;
}
} }

View file

@ -10,7 +10,7 @@ import mekanism.api.infuse.InfusionOutput;
import mekanism.client.sound.IHasSound; import mekanism.client.sound.IHasSound;
import mekanism.common.EnumColor; import mekanism.common.EnumColor;
import mekanism.common.IActiveState; import mekanism.common.IActiveState;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.IEjector; import mekanism.common.IEjector;
import mekanism.common.IRedstoneControl; import mekanism.common.IRedstoneControl;
import mekanism.common.IUpgradeTile; import mekanism.common.IUpgradeTile;
@ -36,7 +36,7 @@ import dan200.computer.api.IComputerAccess;
import dan200.computer.api.ILuaContext; import dan200.computer.api.ILuaContext;
import dan200.computer.api.IPeripheral; import dan200.computer.api.IPeripheral;
public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implements IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IRedstoneControl public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implements IPeripheral, IActiveState, IInvConfiguration, IUpgradeTile, IHasSound, IRedstoneControl
{ {
/** This machine's side configuration. */ /** This machine's side configuration. */
public byte[] sideConfig = new byte[] {2, 1, 0, 5, 3, 4}; public byte[] sideConfig = new byte[] {2, 1, 0, 5, 3, 4};

View file

@ -2,18 +2,21 @@ package mekanism.common.tileentity;
import java.util.ArrayList; import java.util.ArrayList;
import com.google.common.io.ByteArrayDataInput;
import mekanism.api.transmitters.ITransmitter; import mekanism.api.transmitters.ITransmitter;
import mekanism.api.transmitters.TransmitterNetworkRegistry; import mekanism.api.transmitters.TransmitterNetworkRegistry;
import mekanism.common.IConfigurable;
import mekanism.common.ITileNetwork; import mekanism.common.ITileNetwork;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public abstract class TileEntityTransmitter<N> extends TileEntity implements ITransmitter<N>, ITileNetwork public abstract class TileEntityTransmitter<N> extends TileEntity implements ITransmitter<N>, ITileNetwork, IConfigurable
{ {
public N theNetwork; public N theNetwork;
@ -95,4 +98,17 @@ public abstract class TileEntityTransmitter<N> extends TileEntity implements ITr
{ {
return data; return data;
} }
@Override
public boolean onSneakRightClick(EntityPlayer player, int side)
{
return false;
}
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
fixTransmitterNetwork();
return true;
}
} }

View file

@ -6,7 +6,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import mekanism.common.EnumColor; import mekanism.common.EnumColor;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.Object3D; import mekanism.common.Object3D;
import mekanism.common.tileentity.TileEntityBin; import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.transporter.TransporterStack.Path; import mekanism.common.transporter.TransporterStack.Path;
@ -88,9 +88,9 @@ public class TransporterManager
{ {
ItemStack toInsert = stack.itemStack.copy(); ItemStack toInsert = stack.itemStack.copy();
if(stack.pathType != Path.HOME && inv instanceof IConfigurable) if(stack.pathType != Path.HOME && inv instanceof IInvConfiguration)
{ {
IConfigurable config = (IConfigurable)inv; IInvConfiguration config = (IInvConfiguration)inv;
int tileSide = config.getOrientation(); int tileSide = config.getOrientation();
EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite());
@ -234,9 +234,9 @@ public class TransporterManager
return itemStack; return itemStack;
} }
if(tileEntity instanceof IConfigurable) if(tileEntity instanceof IInvConfiguration)
{ {
IConfigurable config = (IConfigurable)tileEntity; IInvConfiguration config = (IInvConfiguration)tileEntity;
int tileSide = config.getOrientation(); int tileSide = config.getOrientation();
EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite());

View file

@ -1,7 +1,7 @@
package mekanism.common.util; package mekanism.common.util;
import mekanism.common.EnumColor; import mekanism.common.EnumColor;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.tileentity.TileEntityBin; import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.tileentity.TileEntityLogisticalSorter; import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.transporter.InvStack; import mekanism.common.transporter.InvStack;
@ -347,9 +347,9 @@ public final class InventoryUtils
return ((TileEntityLogisticalSorter)tileEntity).canSendHome(itemStack); return ((TileEntityLogisticalSorter)tileEntity).canSendHome(itemStack);
} }
if(!force && tileEntity instanceof IConfigurable) if(!force && tileEntity instanceof IInvConfiguration)
{ {
IConfigurable config = (IConfigurable)tileEntity; IInvConfiguration config = (IInvConfiguration)tileEntity;
int tileSide = config.getOrientation(); int tileSide = config.getOrientation();
EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite());

View file

@ -15,7 +15,7 @@ import java.util.Map;
import mekanism.common.DynamicTankCache; import mekanism.common.DynamicTankCache;
import mekanism.common.EnumColor; import mekanism.common.EnumColor;
import mekanism.common.IActiveState; import mekanism.common.IActiveState;
import mekanism.common.IConfigurable; import mekanism.common.IInvConfiguration;
import mekanism.common.IFactory; import mekanism.common.IFactory;
import mekanism.common.Object3D; import mekanism.common.Object3D;
import mekanism.common.IFactory.RecipeType; import mekanism.common.IFactory.RecipeType;
@ -551,7 +551,7 @@ public final class MekanismUtils
* @param config - configurable machine * @param config - configurable machine
* @param side - side to increment output of * @param side - side to increment output of
*/ */
public static void incrementOutput(IConfigurable config, int side) public static void incrementOutput(IInvConfiguration config, int side)
{ {
int max = config.getSideData().size()-1; int max = config.getSideData().size()-1;
int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side])); int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side]));
@ -571,7 +571,7 @@ public final class MekanismUtils
* @param config - configurable machine * @param config - configurable machine
* @param side - side to increment output of * @param side - side to increment output of
*/ */
public static void decrementOutput(IConfigurable config, int side) public static void decrementOutput(IInvConfiguration config, int side)
{ {
int max = config.getSideData().size()-1; int max = config.getSideData().size()-1;
int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side])); int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side]));

View file

@ -26,6 +26,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.item.IItemElectric; import universalelectricity.core.item.IItemElectric;
@ -77,7 +78,9 @@ public class TileEntityBattery extends TileEntityElectricBlock
structure.inventory.add(structure.visibleInventory[0]); structure.inventory.add(structure.visibleInventory[0]);
structure.visibleInventory[0] = null; structure.visibleInventory[0] = null;
structure.sortInventory(); structure.sortInventory();
updateAllClients(); updateAllClients();
MekanismUtils.saveChunk(this);
} }
} }
} }
@ -134,6 +137,12 @@ public class TileEntityBattery extends TileEntityElectricBlock
} }
} }
@Override
public double getMaxOutput()
{
return structure.getVolume()*1000;
}
public void updateClient() public void updateClient()
{ {
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList()))); PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())));
@ -153,21 +162,22 @@ public class TileEntityBattery extends TileEntityElectricBlock
{ {
super.readFromNBT(nbtTags); super.readFromNBT(nbtTags);
// Main inventory //Main inventory
if(nbtTags.hasKey("Items")) if(nbtTags.hasKey("CellItems"))
{ {
NBTTagList tagList = nbtTags.getTagList("Items"); System.out.println("yay");
NBTTagList tagList = nbtTags.getTagList("CellItems");
structure.inventory = new ArrayList<ItemStack>(); structure.inventory = new ArrayList<ItemStack>();
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
{ {
NBTTagCompound tagCompound = (NBTTagCompound) tagList.tagAt(tagCount); NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount);
int slotID = tagCompound.getInteger("Slot"); int slotID = tagCompound.getInteger("Slot");
structure.inventory.add(slotID, ItemStack.loadItemStackFromNBT(tagCompound)); structure.inventory.add(slotID, ItemStack.loadItemStackFromNBT(tagCompound));
} }
} }
// Visible inventory //Visible inventory
if(nbtTags.hasKey("VisibleItems")) if(nbtTags.hasKey("VisibleItems"))
{ {
NBTTagList tagList = nbtTags.getTagList("VisibleItems"); NBTTagList tagList = nbtTags.getTagList("VisibleItems");
@ -175,7 +185,7 @@ public class TileEntityBattery extends TileEntityElectricBlock
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
{ {
NBTTagCompound tagCompound = (NBTTagCompound) tagList.tagAt(tagCount); NBTTagCompound tagCompound = (NBTTagCompound)tagList.tagAt(tagCount);
byte slotID = tagCompound.getByte("Slot"); byte slotID = tagCompound.getByte("Slot");
if(slotID >= 0 && slotID < structure.visibleInventory.length) if(slotID >= 0 && slotID < structure.visibleInventory.length)
@ -206,9 +216,9 @@ public class TileEntityBattery extends TileEntityElectricBlock
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) public void writeToNBT(NBTTagCompound nbtTags)
{ {
super.writeToNBT(nbt); super.writeToNBT(nbtTags);
if(!structure.wroteInventory) if(!structure.wroteInventory)
{ {
@ -228,7 +238,7 @@ public class TileEntityBattery extends TileEntityElectricBlock
} }
} }
nbt.setTag("Items", tagList); nbtTags.setTag("CellItems", tagList);
} }
//Visible inventory //Visible inventory
@ -252,7 +262,7 @@ public class TileEntityBattery extends TileEntityElectricBlock
} }
} }
nbt.setTag("VisibleItems", tagList); nbtTags.setTag("VisibleItems", tagList);
} }
structure.wroteInventory = true; structure.wroteInventory = true;
@ -275,7 +285,7 @@ public class TileEntityBattery extends TileEntityElectricBlock
} }
} }
nbt.setTag("inputSides", tagList); nbtTags.setTag("inputSides", tagList);
} }
} }
@ -476,6 +486,8 @@ public class TileEntityBattery extends TileEntityElectricBlock
@Override @Override
public ItemStack decrStackSize(int slotID, int amount) public ItemStack decrStackSize(int slotID, int amount)
{ {
MekanismUtils.saveChunk(this);
if(getStackInSlot(slotID) != null) if(getStackInSlot(slotID) != null)
{ {
ItemStack tempStack; ItemStack tempStack;
@ -511,6 +523,8 @@ public class TileEntityBattery extends TileEntityElectricBlock
@Override @Override
public void setInventorySlotContents(int i, ItemStack itemstack) public void setInventorySlotContents(int i, ItemStack itemstack)
{ {
MekanismUtils.saveChunk(this);
if(i == 0) if(i == 0)
{ {
structure.visibleInventory[0] = itemstack; structure.visibleInventory[0] = itemstack;
@ -548,13 +562,17 @@ public class TileEntityBattery extends TileEntityElectricBlock
@Override @Override
public EnumSet<ForgeDirection> getConsumingSides() public EnumSet<ForgeDirection> getConsumingSides()
{ {
return inputSides; EnumSet set = inputSides.clone();
set.remove(ForgeDirection.UNKNOWN);
return set;
} }
@Override @Override
public EnumSet<ForgeDirection> getOutputtingSides() public EnumSet<ForgeDirection> getOutputtingSides()
{ {
return EnumSet.complementOf(inputSides); EnumSet set = EnumSet.complementOf(inputSides);
set.remove(ForgeDirection.UNKNOWN);
return set;
} }
/** /**
@ -572,4 +590,10 @@ public class TileEntityBattery extends TileEntityElectricBlock
return true; return true;
} }
} }
@Override
public boolean handleInventory()
{
return false;
}
} }