Resolved #417 - Tesla now only transfer to similar colored
This commit is contained in:
parent
bf08756a82
commit
af43dc1d60
3 changed files with 14 additions and 4 deletions
|
@ -3,9 +3,10 @@
|
|||
*/
|
||||
package resonantinduction.electrical.tesla;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import mffs.api.fortron.IServerThread;
|
||||
import net.minecraft.server.ServerListenThread;
|
||||
|
@ -21,7 +22,7 @@ public class TeslaGrid
|
|||
private static final TeslaGrid INSTANCE_CLIENT = new TeslaGrid();
|
||||
private static final TeslaGrid INSTANCE_SERVER = new TeslaGrid();
|
||||
|
||||
private final Set<ITesla> tileEntities = new HashSet<ITesla>();
|
||||
private final Set<ITesla> tileEntities = Collections.newSetFromMap(new WeakHashMap<ITesla, Boolean>());
|
||||
|
||||
public void register(ITesla iTesla)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@ import calclavia.lib.multiblock.reference.IMultiBlockStructure;
|
|||
import calclavia.lib.multiblock.reference.MultiBlockHandler;
|
||||
import calclavia.lib.network.IPacketReceiver;
|
||||
import calclavia.lib.network.IPacketSender;
|
||||
import calclavia.lib.network.PacketHandler;
|
||||
import calclavia.lib.prefab.tile.TileElectrical;
|
||||
import calclavia.lib.render.EnumColor;
|
||||
|
||||
|
@ -187,7 +188,7 @@ public class TileTesla extends TileElectrical implements IMultiBlockStructure<Ti
|
|||
/**
|
||||
* Make sure Tesla is not part of this tower.
|
||||
*/
|
||||
if (!this.connectedTeslas.contains(otherTesla) && otherTesla.canTeslaTransfer(this))
|
||||
if (!connectedTeslas.contains(otherTesla) && otherTesla != this && otherTesla.canTeslaTransfer(this) && canTeslaTransfer((TileEntity) otherTesla))
|
||||
{
|
||||
teslaToTransfer.add(otherTesla);
|
||||
}
|
||||
|
@ -275,6 +276,7 @@ public class TileTesla extends TileElectrical implements IMultiBlockStructure<Ti
|
|||
@Override
|
||||
public boolean canTeslaTransfer(TileEntity tileEntity)
|
||||
{
|
||||
|
||||
if (tileEntity instanceof TileTesla)
|
||||
{
|
||||
TileTesla otherTesla = (TileTesla) tileEntity;
|
||||
|
@ -287,6 +289,7 @@ public class TileTesla extends TileElectrical implements IMultiBlockStructure<Ti
|
|||
}
|
||||
|
||||
return canReceive && tileEntity != getMultiBlock().get() && !this.outputBlacklist.contains(tileEntity);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -325,6 +328,9 @@ public class TileTesla extends TileElectrical implements IMultiBlockStructure<Ti
|
|||
data.add(this.canReceive);
|
||||
data.add(this.attackEntities);
|
||||
data.add(this.linked != null);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
getMultiBlock().save(nbt);
|
||||
data.add(nbt);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
|
@ -349,6 +355,7 @@ public class TileTesla extends TileElectrical implements IMultiBlockStructure<Ti
|
|||
this.canReceive = data.readBoolean();
|
||||
this.attackEntities = data.readBoolean();
|
||||
this.isLinkedClient = data.readBoolean();
|
||||
getMultiBlock().load(PacketHandler.readNBTTagCompound(data));
|
||||
break;
|
||||
case 2:
|
||||
this.isTransfering = data.readBoolean();
|
||||
|
@ -527,6 +534,7 @@ public class TileTesla extends TileElectrical implements IMultiBlockStructure<Ti
|
|||
this.linked = new Vector3(nbt.getInteger("link_x"), nbt.getInteger("link_y"), nbt.getInteger("link_z"));
|
||||
this.linkDim = nbt.getInteger("linkDim");
|
||||
}
|
||||
getMultiBlock().load(nbt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -547,6 +555,7 @@ public class TileTesla extends TileElectrical implements IMultiBlockStructure<Ti
|
|||
nbt.setInteger("link_z", (int) this.linked.z);
|
||||
nbt.setInteger("linkDim", this.linkDim);
|
||||
}
|
||||
getMultiBlock().save(nbt);
|
||||
}
|
||||
|
||||
public void setLink(Vector3 vector3, int dimID, boolean setOpponent)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ba68b2470ce81b56a7f9dd201586ccaba32b9764
|
||||
Subproject commit def05c696b12c72fd9e0d34d2e201ca695ef1ad9
|
Loading…
Reference in a new issue