Fixed framed wire not connecting

This commit is contained in:
Calclavia 2014-01-03 00:42:05 +08:00
parent 794656477a
commit 1338b83a02
6 changed files with 78 additions and 28 deletions

@ -1 +1 @@
Subproject commit 051bbef264186f28303b43eb7f71e523e56d72cc Subproject commit 9fb37199c4375ce8e07576cf843272355b66ad92

View file

@ -4,7 +4,7 @@ import resonantinduction.multimeter.PartMultimeter;
import resonantinduction.transformer.PartTransformer; import resonantinduction.transformer.PartTransformer;
import resonantinduction.wire.flat.PartFlatSwitchWire; import resonantinduction.wire.flat.PartFlatSwitchWire;
import resonantinduction.wire.flat.PartFlatWire; import resonantinduction.wire.flat.PartFlatWire;
import resonantinduction.wire.framed.PartWire; import resonantinduction.wire.framed.PartFramedWire;
import codechicken.multipart.MultiPartRegistry; import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultiPartRegistry.IPartFactory; import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.multipart.MultipartGenerator; import codechicken.multipart.MultipartGenerator;
@ -29,7 +29,7 @@ public class MultipartRI implements IPartFactory
{ {
if (name == "resonant_induction_wire") if (name == "resonant_induction_wire")
{ {
return new PartWire(); return new PartFramedWire();
} }
else if (name == "resonant_induction_flat_wire") else if (name == "resonant_induction_flat_wire")
{ {

View file

@ -19,7 +19,7 @@ import resonantinduction.TabRI;
import resonantinduction.Utility; import resonantinduction.Utility;
import resonantinduction.wire.flat.PartFlatWire; import resonantinduction.wire.flat.PartFlatWire;
import resonantinduction.wire.flat.RenderFlatWire; import resonantinduction.wire.flat.RenderFlatWire;
import resonantinduction.wire.framed.PartWire; import resonantinduction.wire.framed.PartFramedWire;
import resonantinduction.wire.framed.RenderPartWire; import resonantinduction.wire.framed.RenderPartWire;
import universalelectricity.api.energy.UnitDisplay; import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit; import universalelectricity.api.energy.UnitDisplay.Unit;
@ -54,7 +54,7 @@ public class ItemWire extends JItemMultiPart
if (ControlKeyModifer.isControlDown(player)) if (ControlKeyModifer.isControlDown(player))
{ {
PartWire wire = (PartWire) MultiPartRegistry.createPart("resonant_induction_wire", false); PartFramedWire wire = (PartFramedWire) MultiPartRegistry.createPart("resonant_induction_wire", false);
if (wire != null) if (wire != null)
{ {

View file

@ -440,17 +440,20 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
private void disconnect(int i) private void disconnect(int i)
{ {
if (this.connections[i] != null) if (!this.world().isRemote)
{ {
if (this.connections[i] instanceof PartFlatWire) if (this.connections[i] != null)
{ {
PartFlatWire wire = (PartFlatWire) this.connections[i]; if (this.connections[i] instanceof PartFlatWire)
this.connections[i] = null; {
this.getNetwork().split(this, wire); PartFlatWire wire = (PartFlatWire) this.connections[i];
} this.connections[i] = null;
else this.getNetwork().split(this, wire);
{ }
this.connections[i] = null; else
{
this.connections[i] = null;
}
} }
} }
} }

View file

@ -17,6 +17,8 @@ import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.energy.IConductor; import universalelectricity.api.energy.IConductor;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorHelper; import universalelectricity.api.vector.VectorHelper;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.lighting.LazyLightMatrix; import codechicken.lib.lighting.LazyLightMatrix;
import codechicken.lib.raytracer.IndexedCuboid6; import codechicken.lib.raytracer.IndexedCuboid6;
import codechicken.lib.render.CCRenderState; import codechicken.lib.render.CCRenderState;
@ -36,7 +38,7 @@ import codechicken.multipart.TileMultipart;
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 PartWire extends PartAdvancedWire implements TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects public class PartFramedWire extends PartAdvancedWire implements TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
{ {
/** Client Side Connection Check */ /** Client Side Connection Check */
private ForgeDirection testingSide; private ForgeDirection testingSide;
@ -50,17 +52,17 @@ public class PartWire extends PartAdvancedWire implements TSlottedPart, JNormalO
public byte currentWireConnections = 0x00; public byte currentWireConnections = 0x00;
public byte currentAcceptorConnections = 0x00; public byte currentAcceptorConnections = 0x00;
public PartWire() public PartFramedWire()
{ {
super(); super();
} }
public PartWire(int typeID) public PartFramedWire(int typeID)
{ {
this(EnumWireMaterial.values()[typeID]); this(EnumWireMaterial.values()[typeID]);
} }
public PartWire(EnumWireMaterial type) public PartFramedWire(EnumWireMaterial type)
{ {
super(); super();
material = type; material = type;
@ -362,7 +364,7 @@ public class PartWire extends PartAdvancedWire implements TSlottedPart, JNormalO
this.currentAcceptorConnections = possibleAcceptorConnections; this.currentAcceptorConnections = possibleAcceptorConnections;
this.getNetwork().reconstruct(); this.getNetwork().reconstruct();
// this.sendDescUpdate(); this.sendConnectionUpdate();
} }
tile().markRender(); tile().markRender();
@ -375,7 +377,7 @@ public class PartWire extends PartAdvancedWire implements TSlottedPart, JNormalO
@Override @Override
public TileEntity[] getConnections() public TileEntity[] getConnections()
{ {
TileEntity[] cachedConnections = new TileEntity[6]; TileEntity[] connections = new TileEntity[6];
for (byte i = 0; i < 6; i++) for (byte i = 0; i < 6; i++)
{ {
@ -384,11 +386,11 @@ public class PartWire extends PartAdvancedWire implements TSlottedPart, JNormalO
if (isCurrentlyConnected(side)) if (isCurrentlyConnected(side))
{ {
cachedConnections[i] = tileEntity; connections[i] = tileEntity;
} }
} }
return cachedConnections; return connections;
} }
public boolean isCurrentlyConnected(ForgeDirection side) public boolean isCurrentlyConnected(ForgeDirection side)
@ -438,4 +440,49 @@ public class PartWire extends PartAdvancedWire implements TSlottedPart, JNormalO
super.onNeighborChanged(); super.onNeighborChanged();
refresh(); refresh();
} }
/**
* Packets
*/
public void sendConnectionUpdate()
{
tile().getWriteStream(this).writeByte(0).writeByte(this.currentWireConnections).writeByte(this.currentAcceptorConnections);
}
@Override
public void readDesc(MCDataInput packet)
{
super.readDesc(packet);
this.currentWireConnections = packet.readByte();
this.currentAcceptorConnections = packet.readByte();
}
@Override
public void writeDesc(MCDataOutput packet)
{
super.writeDesc(packet);
packet.writeByte(this.currentWireConnections);
packet.writeByte(this.currentAcceptorConnections);
}
@Override
public void read(MCDataInput packet)
{
read(packet, packet.readUByte());
}
@Override
public void read(MCDataInput packet, int packetID)
{
if (packetID == 0)
{
this.currentWireConnections = packet.readByte();
this.currentAcceptorConnections = packet.readByte();
tile().markRender();
}
else
{
super.read(packet, packetID);
}
}
} }

View file

@ -87,7 +87,7 @@ public class RenderPartWire
buffer.flip(); buffer.flip();
} }
public void renderShine(PartWire wire, double x, double y, double z, float f) public void renderShine(PartFramedWire wire, double x, double y, double z, float f)
{ {
if (wire != null) if (wire != null)
{ {
@ -113,7 +113,7 @@ public class RenderPartWire
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{ {
if (PartWire.connectionMapContainsSide(renderSides, side)) if (PartFramedWire.connectionMapContainsSide(renderSides, side))
renderSideShine(side, wire); renderSideShine(side, wire);
} }
CCRenderState.draw(); CCRenderState.draw();
@ -137,7 +137,7 @@ public class RenderPartWire
breakIcon = iconReg.registerIcon(ResonantInduction.PREFIX + "wire"); breakIcon = iconReg.registerIcon(ResonantInduction.PREFIX + "wire");
} }
public void renderStatic(PartWire wire) public void renderStatic(PartFramedWire wire)
{ {
TextureUtils.bindAtlas(0); TextureUtils.bindAtlas(0);
CCRenderState.reset(); CCRenderState.reset();
@ -148,14 +148,14 @@ public class RenderPartWire
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{ {
if (PartWire.connectionMapContainsSide(renderSides, side)) if (PartFramedWire.connectionMapContainsSide(renderSides, side))
{ {
renderSide(side, wire); renderSide(side, wire);
} }
} }
} }
public void renderSide(ForgeDirection side, PartWire wire) public void renderSide(ForgeDirection side, PartFramedWire wire)
{ {
String name = side.name().toLowerCase(); String name = side.name().toLowerCase();
name = name.equals("unknown") ? "center" : name; name = name.equals("unknown") ? "center" : name;
@ -169,7 +169,7 @@ public class RenderPartWire
} }
} }
public void renderSideShine(ForgeDirection side, PartWire wire) public void renderSideShine(ForgeDirection side, PartFramedWire wire)
{ {
String name = side.name().toLowerCase(); String name = side.name().toLowerCase();
name = name.equals("unknown") ? "center" : name; name = name.equals("unknown") ? "center" : name;