Worked on multiblock battery
This commit is contained in:
parent
2f397145a0
commit
8f3d78ce1d
12 changed files with 222 additions and 410 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 1d94973d405930d7b68a25cc0040c82a671a8fc6
|
||||
Subproject commit 8cf5a56046328e7feacac579bfac2144dc2ee91d
|
|
@ -1 +1 @@
|
|||
Subproject commit deaf0e46b7754fcce3b1ea22dc71f45e3a000131
|
||||
Subproject commit b2b8aa4684ee8b20d061c867ab7c14e5fc907135
|
98
src/resonantinduction/battery/BatteryStructure.java
Normal file
98
src/resonantinduction/battery/BatteryStructure.java
Normal file
|
@ -0,0 +1,98 @@
|
|||
package resonantinduction.battery;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.api.energy.EnergyStorageHandler;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
|
||||
public class BatteryStructure extends EnergyStorageHandler
|
||||
{
|
||||
public BatteryStructure(TileBattery battery)
|
||||
{
|
||||
super(TileBattery.STORAGE);
|
||||
this.battery.add(battery);
|
||||
}
|
||||
|
||||
public Set<TileBattery> battery = new LinkedHashSet<TileBattery>();
|
||||
|
||||
public int length;
|
||||
|
||||
public int width;
|
||||
|
||||
public int height;
|
||||
|
||||
public ItemStack tempStack;
|
||||
|
||||
public boolean isMultiblock;
|
||||
|
||||
public boolean didTick;
|
||||
|
||||
public boolean wroteNBT;
|
||||
|
||||
public int getVolume()
|
||||
{
|
||||
return this.battery.size();
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override
|
||||
* public int hashCode()
|
||||
* {
|
||||
* int code = 1;
|
||||
* code = 31 * locations.hashCode();
|
||||
* code = 31 * length;
|
||||
* code = 31 * width;
|
||||
* code = 31 * height;
|
||||
* return code;
|
||||
* }
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof BatteryStructure))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
BatteryStructure data = (BatteryStructure) obj;
|
||||
|
||||
if (!data.battery.equals(battery))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data.length != length || data.width != width || data.height != height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void merge(TileBattery tile)
|
||||
{
|
||||
// Merge structure.
|
||||
long energyToMerge = ((TileBattery) tile).structure.getEnergy();
|
||||
long capacityToMerge = ((TileBattery) tile).structure.getEnergyCapacity();
|
||||
this.battery.addAll(((TileBattery) tile).structure.battery);
|
||||
((TileBattery) tile).structure.battery.clear();
|
||||
this.resetReferences();
|
||||
this.setCapacity(capacityToMerge);
|
||||
this.receiveEnergy(energyToMerge, true);
|
||||
}
|
||||
|
||||
public void resetReferences()
|
||||
{
|
||||
Iterator<TileBattery> it = this.battery.iterator();
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
TileBattery tile = it.next();
|
||||
tile.structure = this;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,220 +0,0 @@
|
|||
package resonantinduction.battery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.base.ListUtil;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
|
||||
/**
|
||||
* Essentially a pathfinder for multiblock battery structures.
|
||||
*
|
||||
* @author Aidancbrady
|
||||
*
|
||||
*/
|
||||
public class BatteryUpdateProtocol
|
||||
{
|
||||
/** The battery nodes that have already been iterated over. */
|
||||
public Set<TileBattery> iteratedNodes = new HashSet<TileBattery>();
|
||||
|
||||
/** The structures found, all connected by some nodes to the pointer. */
|
||||
public SynchronizedBatteryData structureFound = null;
|
||||
|
||||
/** The original block the calculation is getting run from. */
|
||||
public TileEntity pointer;
|
||||
|
||||
public BatteryUpdateProtocol(TileEntity tileEntity)
|
||||
{
|
||||
pointer = tileEntity;
|
||||
}
|
||||
|
||||
public void updateBatteries()
|
||||
{
|
||||
loopThrough(this.pointer);
|
||||
|
||||
if (structureFound != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void loopThrough(TileEntity tile)
|
||||
{
|
||||
if (structureFound == null)
|
||||
{
|
||||
World worldObj = tile.worldObj;
|
||||
|
||||
int origX = tile.xCoord, origY = tile.yCoord, origZ = tile.zCoord;
|
||||
|
||||
boolean isCorner = true;
|
||||
boolean rightBlocks = true;
|
||||
|
||||
Set<Vector3> locations = new HashSet<Vector3>();
|
||||
|
||||
int xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0;
|
||||
|
||||
int x = 0, y = 0, z = 0;
|
||||
|
||||
if ((isBattery(origX + 1, origY, origZ) && isBattery(origX - 1, origY, origZ)) || (isBattery(origX, origY + 1, origZ) && isBattery(origX, origY - 1, origZ)) || (isBattery(origX, origY, origZ + 1) && isBattery(origX, origY, origZ - 1)))
|
||||
{
|
||||
isCorner = false;
|
||||
}
|
||||
|
||||
if (isCorner)
|
||||
{
|
||||
if (isBattery(origX + 1, origY, origZ))
|
||||
{
|
||||
xmin = 0;
|
||||
|
||||
while (isBattery(origX + x + 1, origY, origZ))
|
||||
{
|
||||
x++;
|
||||
}
|
||||
|
||||
xmax = x;
|
||||
}
|
||||
else
|
||||
{
|
||||
xmax = 0;
|
||||
|
||||
while (isBattery(origX + x - 1, origY, origZ))
|
||||
{
|
||||
x--;
|
||||
}
|
||||
|
||||
xmin = x;
|
||||
}
|
||||
|
||||
if (isBattery(origX, origY + 1, origZ))
|
||||
{
|
||||
ymin = 0;
|
||||
|
||||
while (isBattery(origX, origY + y + 1, origZ))
|
||||
{
|
||||
y++;
|
||||
}
|
||||
|
||||
ymax = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
ymax = 0;
|
||||
|
||||
while (isBattery(origX, origY + y - 1, origZ))
|
||||
{
|
||||
y--;
|
||||
}
|
||||
|
||||
ymin = y;
|
||||
}
|
||||
|
||||
if (isBattery(origX, origY, origZ + 1))
|
||||
{
|
||||
zmin = 0;
|
||||
|
||||
while (isBattery(origX, origY, origZ + z + 1))
|
||||
{
|
||||
z++;
|
||||
}
|
||||
|
||||
zmax = z;
|
||||
}
|
||||
else
|
||||
{
|
||||
zmax = 0;
|
||||
|
||||
while (isBattery(origX, origY, origZ + z - 1))
|
||||
{
|
||||
z--;
|
||||
}
|
||||
|
||||
zmin = z;
|
||||
}
|
||||
|
||||
for (x = xmin; x <= xmax; x++)
|
||||
{
|
||||
for (y = ymin; y <= ymax; y++)
|
||||
{
|
||||
for (z = zmin; z <= zmax; z++)
|
||||
{
|
||||
if (!isBattery(origX + x, origY + y, origZ + z))
|
||||
{
|
||||
rightBlocks = false;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
locations.add(new Vector3(tile).translate(new Vector3(x, y, z)));
|
||||
}
|
||||
}
|
||||
|
||||
if (!rightBlocks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!rightBlocks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (locations.size() >= 1 && locations.size() < 512)
|
||||
{
|
||||
if (rightBlocks && isCorner)
|
||||
{
|
||||
SynchronizedBatteryData structure = new SynchronizedBatteryData();
|
||||
structure.locations = locations;
|
||||
structure.length = Math.abs(xmax - xmin) + 1;
|
||||
structure.height = Math.abs(ymax - ymin) + 1;
|
||||
structure.width = Math.abs(zmax - zmin) + 1;
|
||||
|
||||
if (structure.getVolume() > 1)
|
||||
{
|
||||
structure.isMultiblock = true;
|
||||
}
|
||||
|
||||
if (structure.locations.contains(new Vector3(pointer)))
|
||||
{
|
||||
structureFound = structure;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iteratedNodes.add((TileBattery) tile);
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = new Vector3(tile).modifyPositionFromSide(side).getTileEntity(tile.worldObj);
|
||||
|
||||
if (tileEntity instanceof TileBattery)
|
||||
{
|
||||
if (!iteratedNodes.contains(tileEntity))
|
||||
{
|
||||
loopThrough(tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBattery(int x, int y, int z)
|
||||
{
|
||||
if (pointer.worldObj.getBlockTileEntity(x, y, z) instanceof TileBattery)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,6 +33,16 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
this.setTextureName(ResonantInduction.PREFIX + "machine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
System.out.println(((TileBattery) world.getBlockTileEntity(x, y, z)).structure.hashCode());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int id)
|
||||
{
|
||||
|
@ -41,7 +51,7 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
if (id == blockID)
|
||||
{
|
||||
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
|
||||
battery.update();
|
||||
battery.updateStructure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +62,7 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
if (!world.isRemote)
|
||||
{
|
||||
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
|
||||
battery.update();
|
||||
battery.updateStructure();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
package resonantinduction.battery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import resonantinduction.base.ListUtil;
|
||||
import universalelectricity.api.item.IEnergyItem;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
|
||||
public class SynchronizedBatteryData
|
||||
{
|
||||
public Set<Vector3> locations = new HashSet<Vector3>();
|
||||
|
||||
public int length;
|
||||
|
||||
public int width;
|
||||
|
||||
public int height;
|
||||
|
||||
public ItemStack tempStack;
|
||||
|
||||
public boolean isMultiblock;
|
||||
|
||||
public boolean didTick;
|
||||
|
||||
public boolean wroteNBT;
|
||||
|
||||
public int getVolume()
|
||||
{
|
||||
return length * width * height;
|
||||
}
|
||||
|
||||
public static SynchronizedBatteryData getBase(TileBattery tileEntity, List<ItemStack> inventory)
|
||||
{
|
||||
SynchronizedBatteryData structure = getBase(tileEntity);
|
||||
return structure;
|
||||
}
|
||||
|
||||
public static SynchronizedBatteryData getBase(TileBattery tileEntity)
|
||||
{
|
||||
SynchronizedBatteryData structure = new SynchronizedBatteryData();
|
||||
structure.length = 1;
|
||||
structure.width = 1;
|
||||
structure.height = 1;
|
||||
structure.locations.add(new Vector3(tileEntity));
|
||||
|
||||
return structure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int code = 1;
|
||||
code = 31 * locations.hashCode();
|
||||
code = 31 * length;
|
||||
code = 31 * width;
|
||||
code = 31 * height;
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof SynchronizedBatteryData))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SynchronizedBatteryData data = (SynchronizedBatteryData) obj;
|
||||
|
||||
if (!data.locations.equals(locations))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (data.length != length || data.width != width || data.height != height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -4,19 +4,21 @@
|
|||
package resonantinduction.battery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.ResonantInduction;
|
||||
import universalelectricity.api.energy.EnergyStorageHandler;
|
||||
import universalelectricity.api.UniversalClass;
|
||||
import universalelectricity.api.energy.IEnergyContainer;
|
||||
import universalelectricity.api.energy.IEnergyInterface;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.IPacketSender;
|
||||
import calclavia.lib.tile.TileEntityElectrical;
|
||||
import calclavia.lib.tile.TileAdvanced;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
|
@ -24,28 +26,43 @@ import cpw.mods.fml.common.network.PacketDispatcher;
|
|||
import cpw.mods.fml.common.network.Player;
|
||||
|
||||
/**
|
||||
* A modular battery with no GUI.
|
||||
* A modular battery.
|
||||
*
|
||||
* @author Calclavia, AidanBrady
|
||||
* @author Calclavia
|
||||
*/
|
||||
public class TileBattery extends TileEntityElectrical implements IPacketSender, IPacketReceiver
|
||||
@UniversalClass
|
||||
public class TileBattery extends TileAdvanced implements IPacketSender, IPacketReceiver, IEnergyInterface, IEnergyContainer
|
||||
{
|
||||
public static final long STORAGE = 10000000;
|
||||
public static final long STORAGE = 100000000;
|
||||
|
||||
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
|
||||
|
||||
public SynchronizedBatteryData structure = SynchronizedBatteryData.getBase(this);
|
||||
public SynchronizedBatteryData prevStructure;
|
||||
public BatteryStructure structure = new BatteryStructure(this);
|
||||
|
||||
public float clientEnergy;
|
||||
public int clientCells;
|
||||
public float clientMaxEnergy;
|
||||
|
||||
private EnumSet inputSides = EnumSet.allOf(ForgeDirection.class);
|
||||
|
||||
public TileBattery()
|
||||
@Override
|
||||
public void initiate()
|
||||
{
|
||||
this.energy = new EnergyStorageHandler(1000);
|
||||
this.updateStructure();
|
||||
}
|
||||
|
||||
public void updateStructure()
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj);
|
||||
|
||||
if (tile instanceof TileBattery)
|
||||
{
|
||||
this.structure.merge((TileBattery) tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,30 +72,6 @@ public class TileBattery extends TileEntityElectrical implements IPacketSender,
|
|||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.ticks == 5 && !this.structure.isMultiblock)
|
||||
{
|
||||
this.update();
|
||||
}
|
||||
|
||||
if (this.prevStructure != this.structure)
|
||||
{
|
||||
for (EntityPlayer player : playersUsing)
|
||||
{
|
||||
player.closeScreen();
|
||||
}
|
||||
|
||||
updateClient();
|
||||
}
|
||||
|
||||
this.prevStructure = structure;
|
||||
|
||||
this.structure.wroteNBT = false;
|
||||
this.structure.didTick = false;
|
||||
|
||||
if (this.playersUsing.size() > 0)
|
||||
{
|
||||
updateClient();
|
||||
}
|
||||
|
||||
for (EntityPlayer player : this.playersUsing)
|
||||
{
|
||||
|
@ -89,6 +82,11 @@ public class TileBattery extends TileEntityElectrical implements IPacketSender,
|
|||
}
|
||||
}
|
||||
|
||||
private void produce()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public float getTransferThreshhold()
|
||||
{
|
||||
return this.structure.getVolume() * 50;
|
||||
|
@ -99,19 +97,11 @@ public class TileBattery extends TileEntityElectrical implements IPacketSender,
|
|||
PacketDispatcher.sendPacketToAllPlayers(ResonantInduction.PACKET_TILE.getPacket(this, getPacketData(0).toArray()));
|
||||
}
|
||||
|
||||
public void updateAllClients()
|
||||
{
|
||||
for (Vector3 vec : structure.locations)
|
||||
{
|
||||
TileBattery battery = (TileBattery) vec.getTileEntity(worldObj);
|
||||
PacketDispatcher.sendPacketToAllPlayers(ResonantInduction.PACKET_TILE.getPacket(battery, battery.getPacketData(0).toArray()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
super.readFromNBT(nbt);
|
||||
this.structure.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,23 +111,11 @@ public class TileBattery extends TileEntityElectrical implements IPacketSender,
|
|||
|
||||
if (!structure.wroteNBT)
|
||||
{
|
||||
this.structure.writeToNBT(nbt);
|
||||
structure.wroteNBT = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
if (!worldObj.isRemote && (structure == null || !structure.didTick))
|
||||
{
|
||||
new BatteryUpdateProtocol(this).updateBatteries();
|
||||
|
||||
if (structure != null)
|
||||
{
|
||||
structure.didTick = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player)
|
||||
{
|
||||
|
@ -162,31 +140,38 @@ public class TileBattery extends TileEntityElectrical implements IPacketSender,
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getInputDirections()
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return this.inputSides;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getOutputDirections()
|
||||
public void setEnergy(ForgeDirection from, long energy)
|
||||
{
|
||||
return EnumSet.complementOf(this.inputSides);
|
||||
this.structure.setEnergy(energy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the input/output sides of the battery.
|
||||
*/
|
||||
public boolean toggleSide(ForgeDirection orientation)
|
||||
@Override
|
||||
public long getEnergy(ForgeDirection from)
|
||||
{
|
||||
if (this.inputSides.contains(orientation))
|
||||
{
|
||||
this.inputSides.remove(orientation);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inputSides.add(orientation);
|
||||
return true;
|
||||
}
|
||||
return this.structure.getEnergy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEnergyCapacity(ForgeDirection from)
|
||||
{
|
||||
return this.structure.getEnergyCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||
{
|
||||
return this.structure.receiveEnergy(receive, doReceive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
|
||||
{
|
||||
return this.structure.extractEnergy(extract, doExtract);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import resonantinduction.tesla.TileTesla;
|
|||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.IPacketSender;
|
||||
import calclavia.lib.tile.TileEntityAdvanced;
|
||||
import calclavia.lib.tile.TileAdvanced;
|
||||
import calclavia.lib.utility.InventoryUtility;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
@ -37,7 +37,7 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileEMLevitator extends TileEntityAdvanced implements IPacketReceiver, IPacketSender
|
||||
public class TileEMLevitator extends TileAdvanced implements IPacketReceiver, IPacketSender
|
||||
{
|
||||
public static int MAX_REACH = 40;
|
||||
public static int PUSH_DELAY = 5;
|
||||
|
|
|
@ -607,18 +607,4 @@ public class TileTesla extends TileEntityElectrical implements ITesla, IPacketSe
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getInputDirections()
|
||||
{
|
||||
EnumSet input = EnumSet.allOf(ForgeDirection.class);
|
||||
input.remove(ForgeDirection.DOWN);
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getOutputDirections()
|
||||
{
|
||||
return EnumSet.of(ForgeDirection.DOWN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package resonantinduction.wire.part;
|
||||
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -15,6 +15,7 @@ import universalelectricity.api.energy.IConductor;
|
|||
import universalelectricity.api.energy.IEnergyNetwork;
|
||||
import universalelectricity.api.vector.Vector3;
|
||||
import universalelectricity.api.vector.VectorHelper;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
|
||||
@UniversalClass
|
||||
public abstract class PartConductor extends PartAdvanced implements IConductor
|
||||
|
@ -23,6 +24,8 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
|
||||
protected Object[] connections = new Object[6];
|
||||
|
||||
private long savedBuffer;
|
||||
|
||||
/**
|
||||
* Universal Electricity conductor functions.
|
||||
*/
|
||||
|
@ -168,6 +171,31 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
}
|
||||
|
||||
super.preRemove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSavedBuffer()
|
||||
{
|
||||
return this.savedBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaveBuffer(long energy)
|
||||
{
|
||||
this.savedBuffer = energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(NBTTagCompound nbt)
|
||||
{
|
||||
super.save(nbt);
|
||||
nbt.setLong("savedBuffer", this.savedBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(NBTTagCompound nbt)
|
||||
{
|
||||
super.load(nbt);
|
||||
this.savedBuffer = nbt.getLong("savedBuffer");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
|
|||
}
|
||||
|
||||
this.recalculateConnections();
|
||||
|
||||
|
||||
super.onChunkLoad();
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
|
|||
|
||||
this.recalculateConnections();
|
||||
}
|
||||
|
||||
|
||||
super.onPartChanged(part);
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!calculatedSides[absDir])
|
||||
{
|
||||
this.disconnect(absDir);
|
||||
|
@ -902,5 +902,4 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
|
|||
CCRenderState.reset();
|
||||
RenderFlatWire.renderBreakingOverlay(renderBlocks.overrideBlockTexture, this);
|
||||
}
|
||||
|
||||
}
|
|
@ -166,4 +166,16 @@ public class TraitConductor extends TileMultipart implements IConductor
|
|||
return capacitance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSavedBuffer()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaveBuffer(long energy)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue