Got network split and merge working
This commit is contained in:
parent
da4d87d6b5
commit
34881cb453
9 changed files with 119 additions and 183 deletions
|
@ -1,6 +1,6 @@
|
||||||
package resonantinduction;
|
package resonantinduction;
|
||||||
|
|
||||||
import resonantinduction.wire.part.FlatWire;
|
import resonantinduction.wire.part.PartFlatWire;
|
||||||
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;
|
||||||
|
@ -14,7 +14,6 @@ public class MultipartRI implements IPartFactory
|
||||||
{
|
{
|
||||||
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_flat_wire" });
|
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_flat_wire" });
|
||||||
MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.wire.part.TraitConductor");
|
MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.wire.part.TraitConductor");
|
||||||
//MultipartGenerator.registerTrait("resonantinduction.wire.part.ITest", "resonantinduction.wire.part.TraitTest");
|
|
||||||
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.part.TraitEnergySink");
|
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.part.TraitEnergySink");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +22,7 @@ public class MultipartRI implements IPartFactory
|
||||||
{
|
{
|
||||||
if (name.equals("resonant_induction_flat_wire"))
|
if (name.equals("resonant_induction_flat_wire"))
|
||||||
{
|
{
|
||||||
return new FlatWire();
|
return new PartFlatWire();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
package resonantinduction.wire;
|
|
||||||
|
|
||||||
import universalelectricity.api.energy.IConductor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A connector for {EnergyNetwork}.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface IAdvancedConductor extends IConductor
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The insulatation methods.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isInsulated();
|
|
||||||
|
|
||||||
public void setInsulated(boolean insulated);
|
|
||||||
|
|
||||||
public int getInsulationColor();
|
|
||||||
|
|
||||||
public void setInsulationColor(int dye);
|
|
||||||
|
|
||||||
public EnumWireMaterial getMaterial();
|
|
||||||
}
|
|
|
@ -13,7 +13,7 @@ import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonantinduction.ResonantInduction;
|
import resonantinduction.ResonantInduction;
|
||||||
import resonantinduction.TabRI;
|
import resonantinduction.TabRI;
|
||||||
import resonantinduction.Utility;
|
import resonantinduction.Utility;
|
||||||
import resonantinduction.wire.part.FlatWire;
|
import resonantinduction.wire.part.PartFlatWire;
|
||||||
import resonantinduction.wire.render.RenderFlatWire;
|
import resonantinduction.wire.render.RenderFlatWire;
|
||||||
import universalelectricity.api.energy.UnitDisplay;
|
import universalelectricity.api.energy.UnitDisplay;
|
||||||
import universalelectricity.api.energy.UnitDisplay.Unit;
|
import universalelectricity.api.energy.UnitDisplay.Unit;
|
||||||
|
@ -49,7 +49,7 @@ public class ItemWire extends JItemMultiPart
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatWire wire = (FlatWire) MultiPartRegistry.createPart("resonant_induction_flat_wire", false);
|
PartFlatWire wire = (PartFlatWire) MultiPartRegistry.createPart("resonant_induction_flat_wire", false);
|
||||||
|
|
||||||
if (wire != null)
|
if (wire != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package resonantinduction.wire.part;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import universalelectricity.api.energy.IEnergyInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface ITest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Adds energy to an block. Returns the quantity of energy that was accepted. This should always
|
|
||||||
* return 0 if the block cannot be externally charged.
|
|
||||||
*
|
|
||||||
* @param from Orientation the energy is sent in from.
|
|
||||||
* @param receive Maximum amount of energy (joules) to be sent into the block.
|
|
||||||
* @param doReceive If false, the charge will only be simulated.
|
|
||||||
* @return Amount of energy that was accepted by the block.
|
|
||||||
*/
|
|
||||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive);
|
|
||||||
|
|
||||||
}
|
|
|
@ -13,9 +13,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import resonantinduction.wire.EnumWireMaterial;
|
import resonantinduction.wire.EnumWireMaterial;
|
||||||
import resonantinduction.wire.IAdvancedConductor;
|
|
||||||
import universalelectricity.api.CompatibilityModule;
|
import universalelectricity.api.CompatibilityModule;
|
||||||
import universalelectricity.api.energy.IConductor;
|
|
||||||
import codechicken.lib.data.MCDataInput;
|
import codechicken.lib.data.MCDataInput;
|
||||||
import codechicken.lib.data.MCDataOutput;
|
import codechicken.lib.data.MCDataOutput;
|
||||||
|
|
||||||
|
@ -23,7 +21,7 @@ import codechicken.lib.data.MCDataOutput;
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class PartWireBase extends PartConductor implements IAdvancedConductor
|
public abstract class PartAdvancedWire extends PartConductor
|
||||||
{
|
{
|
||||||
public static final int DEFAULT_COLOR = 16;
|
public static final int DEFAULT_COLOR = 16;
|
||||||
public int dyeID = DEFAULT_COLOR;
|
public int dyeID = DEFAULT_COLOR;
|
||||||
|
@ -37,15 +35,15 @@ public abstract class PartWireBase extends PartConductor implements IAdvancedCon
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnectTo(Object obj)
|
public boolean canConnectTo(Object obj)
|
||||||
{
|
{
|
||||||
if (obj instanceof IAdvancedConductor)
|
if (obj instanceof PartFlatWire)
|
||||||
{
|
{
|
||||||
IAdvancedConductor wire = (IAdvancedConductor) obj;
|
PartFlatWire wire = (PartFlatWire) obj;
|
||||||
|
|
||||||
if (wire.getMaterial() == getMaterial())
|
if (wire.getMaterial() == getMaterial())
|
||||||
{
|
{
|
||||||
if (this.isInsulated() && wire.isInsulated())
|
if (this.isInsulated() && wire.isInsulated())
|
||||||
{
|
{
|
||||||
return this.getInsulationColor() == wire.getInsulationColor();
|
return this.getColor() == wire.getColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -70,47 +68,36 @@ public abstract class PartWireBase extends PartConductor implements IAdvancedCon
|
||||||
return this.getMaterial().maxAmps;
|
return this.getMaterial().maxAmps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* Material Methods
|
||||||
|
*/
|
||||||
public EnumWireMaterial getMaterial()
|
public EnumWireMaterial getMaterial()
|
||||||
{
|
{
|
||||||
return material;
|
return this.material;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaterialFromID(int id)
|
public void setMaterial(EnumWireMaterial material)
|
||||||
{
|
{
|
||||||
material = EnumWireMaterial.values()[id];
|
this.material = material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaterial(int id)
|
||||||
|
{
|
||||||
|
this.setMaterial(EnumWireMaterial.values()[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaterialID()
|
public int getMaterialID()
|
||||||
{
|
{
|
||||||
return material.ordinal();
|
return this.material.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public boolean isInsulated()
|
* Insulation Methods
|
||||||
{
|
*/
|
||||||
return isInsulated;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInsulationColor()
|
|
||||||
{
|
|
||||||
return isInsulated ? dyeID : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInsulationColor(int dye)
|
|
||||||
{
|
|
||||||
dyeID = dye;
|
|
||||||
tile().notifyPartChange(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInsulated(boolean insulated)
|
public void setInsulated(boolean insulated)
|
||||||
{
|
{
|
||||||
isInsulated = insulated;
|
this.isInsulated = insulated;
|
||||||
dyeID = DEFAULT_COLOR;
|
this.dyeID = DEFAULT_COLOR;
|
||||||
tile().notifyPartChange(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInsulated(int dyeColour)
|
public void setInsulated(int dyeColour)
|
||||||
|
@ -120,15 +107,22 @@ public abstract class PartWireBase extends PartConductor implements IAdvancedCon
|
||||||
tile().notifyPartChange(this);
|
tile().notifyPartChange(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInsulated()
|
public boolean isInsulated()
|
||||||
{
|
{
|
||||||
setInsulated(true);
|
return this.isInsulated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDye(int dye)
|
/**
|
||||||
|
* Wire Coloring Methods
|
||||||
|
*/
|
||||||
|
public int getColor()
|
||||||
{
|
{
|
||||||
dyeID = dye;
|
return this.isInsulated ? this.dyeID : -1;
|
||||||
tile().notifyPartChange(this);
|
}
|
||||||
|
|
||||||
|
public void setColor(int dye)
|
||||||
|
{
|
||||||
|
this.dyeID = dye;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,7 +135,7 @@ public abstract class PartWireBase extends PartConductor implements IAdvancedCon
|
||||||
{
|
{
|
||||||
if (item.itemID == Item.dyePowder.itemID && isInsulated())
|
if (item.itemID == Item.dyePowder.itemID && isInsulated())
|
||||||
{
|
{
|
||||||
setDye(item.getItemDamage());
|
setColor(item.getItemDamage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (item.itemID == Block.cloth.blockID)
|
else if (item.itemID == Block.cloth.blockID)
|
||||||
|
@ -198,7 +192,7 @@ public abstract class PartWireBase extends PartConductor implements IAdvancedCon
|
||||||
@Override
|
@Override
|
||||||
public void readDesc(MCDataInput packet)
|
public void readDesc(MCDataInput packet)
|
||||||
{
|
{
|
||||||
this.setMaterialFromID(packet.readByte());
|
this.setMaterial(packet.readByte());
|
||||||
this.dyeID = packet.readByte();
|
this.dyeID = packet.readByte();
|
||||||
this.isInsulated = packet.readBoolean();
|
this.isInsulated = packet.readBoolean();
|
||||||
}
|
}
|
||||||
|
@ -224,7 +218,7 @@ public abstract class PartWireBase extends PartConductor implements IAdvancedCon
|
||||||
public void load(NBTTagCompound nbt)
|
public void load(NBTTagCompound nbt)
|
||||||
{
|
{
|
||||||
super.load(nbt);
|
super.load(nbt);
|
||||||
setMaterialFromID(nbt.getInteger("typeID"));
|
setMaterial(nbt.getInteger("typeID"));
|
||||||
this.isInsulated = nbt.getBoolean("isInsulated");
|
this.isInsulated = nbt.getBoolean("isInsulated");
|
||||||
this.dyeID = nbt.getInteger("dyeID");
|
this.dyeID = nbt.getInteger("dyeID");
|
||||||
}
|
}
|
|
@ -15,7 +15,6 @@ import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import resonantinduction.Utility;
|
import resonantinduction.Utility;
|
||||||
import resonantinduction.wire.EnumWireMaterial;
|
import resonantinduction.wire.EnumWireMaterial;
|
||||||
import resonantinduction.wire.IAdvancedConductor;
|
|
||||||
import resonantinduction.wire.render.RenderFlatWire;
|
import resonantinduction.wire.render.RenderFlatWire;
|
||||||
import codechicken.lib.colour.Colour;
|
import codechicken.lib.colour.Colour;
|
||||||
import codechicken.lib.data.MCDataInput;
|
import codechicken.lib.data.MCDataInput;
|
||||||
|
@ -46,7 +45,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
* @author Modified by Calclavia, MrTJP
|
* @author Modified by Calclavia, MrTJP
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusion
|
public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormalOcclusion
|
||||||
{
|
{
|
||||||
public static Cuboid6[][] selectionBounds = new Cuboid6[3][6];
|
public static Cuboid6[][] selectionBounds = new Cuboid6[3][6];
|
||||||
public static Cuboid6[][] occlusionBounds = new Cuboid6[3][6];
|
public static Cuboid6[][] occlusionBounds = new Cuboid6[3][6];
|
||||||
|
@ -84,17 +83,17 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
*/
|
*/
|
||||||
public int connMap;
|
public int connMap;
|
||||||
|
|
||||||
public FlatWire()
|
public PartFlatWire()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlatWire(int typeID)
|
public PartFlatWire(int typeID)
|
||||||
{
|
{
|
||||||
this(EnumWireMaterial.values()[typeID]);
|
this(EnumWireMaterial.values()[typeID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlatWire(EnumWireMaterial type)
|
public PartFlatWire(EnumWireMaterial type)
|
||||||
{
|
{
|
||||||
material = type;
|
material = type;
|
||||||
}
|
}
|
||||||
|
@ -184,8 +183,6 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getNetwork().split(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,9 +205,10 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
updateExternalConnections();
|
updateExternalConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.recalculateConnections();
|
|
||||||
tile().markDirty();
|
tile().markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.recalculateConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -281,9 +279,8 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
if (!world().isRemote)
|
if (!world().isRemote)
|
||||||
{
|
{
|
||||||
System.out.println(this.getNetwork());
|
System.out.println(this.getNetwork());
|
||||||
this.getConnections();
|
|
||||||
this.recalculateConnections();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.activate(player, part, item);
|
return super.activate(player, part, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +313,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
if (this.canConnectTo(tp))
|
if (this.canConnectTo(tp))
|
||||||
{
|
{
|
||||||
this.connections[absDir] = tp;
|
this.connections[absDir] = tp;
|
||||||
this.getNetwork().merge(((FlatWire) tp).getNetwork());
|
this.getNetwork().merge(((PartFlatWire) tp).getNetwork());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,7 +335,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
if (this.canConnectTo(tp))
|
if (this.canConnectTo(tp))
|
||||||
{
|
{
|
||||||
this.connections[absDir] = tp;
|
this.connections[absDir] = tp;
|
||||||
this.getNetwork().merge(((FlatWire) tp).getNetwork());
|
this.getNetwork().merge(((PartFlatWire) tp).getNetwork());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +358,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
if (this.canConnectTo(tp))
|
if (this.canConnectTo(tp))
|
||||||
{
|
{
|
||||||
this.connections[absSide] = tp;
|
this.connections[absSide] = tp;
|
||||||
this.getNetwork().merge(((FlatWire) tp).getNetwork());
|
this.getNetwork().merge(((PartFlatWire) tp).getNetwork());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -513,7 +510,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
{
|
{
|
||||||
int absDir = Rotation.rotateSide(side, r);
|
int absDir = Rotation.rotateSide(side, r);
|
||||||
TMultiPart facePart = tile().partMap(absDir);
|
TMultiPart facePart = tile().partMap(absDir);
|
||||||
if (facePart != null && (!(facePart instanceof FlatWire) || !canConnectTo((FlatWire) facePart)))
|
if (facePart != null && (!(facePart instanceof PartFlatWire) || !canConnectTo((PartFlatWire) facePart)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (tile().partMap(PartMap.edgeBetween(side, absDir)) != null)
|
if (tile().partMap(PartMap.edgeBetween(side, absDir)) != null)
|
||||||
|
@ -544,14 +541,14 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
{
|
{
|
||||||
TMultiPart tp = t.partMap(absDir ^ 1);
|
TMultiPart tp = t.partMap(absDir ^ 1);
|
||||||
|
|
||||||
if (tp instanceof FlatWire)
|
if (tp instanceof PartFlatWire)
|
||||||
{
|
{
|
||||||
boolean b = ((FlatWire) tp).connectCorner(this, Rotation.rotationTo(absDir ^ 1, side ^ 1));
|
boolean b = ((PartFlatWire) tp).connectCorner(this, Rotation.rotationTo(absDir ^ 1, side ^ 1));
|
||||||
|
|
||||||
if (b)
|
if (b)
|
||||||
{
|
{
|
||||||
// let them connect to us
|
// let them connect to us
|
||||||
if (tp instanceof FlatWire && !renderThisCorner((FlatWire) tp))
|
if (tp instanceof PartFlatWire && !renderThisCorner((PartFlatWire) tp))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -590,9 +587,9 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
{
|
{
|
||||||
TMultiPart tp = t.partMap(side);
|
TMultiPart tp = t.partMap(side);
|
||||||
|
|
||||||
if (tp instanceof FlatWire)
|
if (this.canConnectTo(tp))
|
||||||
{
|
{
|
||||||
return ((FlatWire) tp).connectStraight(this, (r + 2) % 4);
|
return ((PartFlatWire) tp).connectStraight(this, (r + 2) % 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -613,9 +610,9 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
|
|
||||||
TMultiPart tp = tile().partMap(absDir);
|
TMultiPart tp = tile().partMap(absDir);
|
||||||
|
|
||||||
if (tp instanceof FlatWire)
|
if (this.canConnectTo(tp))
|
||||||
{
|
{
|
||||||
return ((FlatWire) tp).connectInternal(this, Rotation.rotationTo(absDir, side));
|
return ((PartFlatWire) tp).connectInternal(this, Rotation.rotationTo(absDir, side));
|
||||||
}
|
}
|
||||||
|
|
||||||
return connectInternalOverride(tp, r);
|
return connectInternalOverride(tp, r);
|
||||||
|
@ -628,31 +625,31 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
|
|
||||||
public boolean connectCenter()
|
public boolean connectCenter()
|
||||||
{
|
{
|
||||||
TMultiPart t = tile().partMap(6);
|
TMultiPart tp = tile().partMap(6);
|
||||||
|
|
||||||
if (t instanceof FlatWire)
|
if (this.canConnectTo(tp))
|
||||||
{
|
{
|
||||||
return ((FlatWire) t).connectInternal(this, side);
|
return ((PartFlatWire) tp).connectInternal(this, side);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean renderThisCorner(IAdvancedConductor part)
|
public boolean renderThisCorner(PartFlatWire part)
|
||||||
{
|
{
|
||||||
if (!(part instanceof FlatWire))
|
if (!(part instanceof PartFlatWire))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FlatWire wire = (FlatWire) part;
|
PartFlatWire wire = (PartFlatWire) part;
|
||||||
if (wire.getThickness() == getThickness())
|
if (wire.getThickness() == getThickness())
|
||||||
return side < wire.side;
|
return side < wire.side;
|
||||||
|
|
||||||
return wire.getThickness() > getThickness();
|
return wire.getThickness() > getThickness();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean connectCorner(IAdvancedConductor wire, int r)
|
public boolean connectCorner(PartFlatWire wire, int r)
|
||||||
{
|
{
|
||||||
if (canConnectTo(wire) && maskOpen(r))
|
if (this.canConnectTo(wire) && maskOpen(r))
|
||||||
{
|
{
|
||||||
int oldConn = connMap;
|
int oldConn = connMap;
|
||||||
connMap |= 0x1 << r;
|
connMap |= 0x1 << r;
|
||||||
|
@ -666,9 +663,9 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean connectStraight(IAdvancedConductor wire, int r)
|
public boolean connectStraight(PartFlatWire wire, int r)
|
||||||
{
|
{
|
||||||
if (canConnectTo(wire) && maskOpen(r))
|
if (this.canConnectTo(wire) && maskOpen(r))
|
||||||
{
|
{
|
||||||
int oldConn = connMap;
|
int oldConn = connMap;
|
||||||
connMap |= 0x10 << r;
|
connMap |= 0x10 << r;
|
||||||
|
@ -679,9 +676,9 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean connectInternal(IAdvancedConductor wire, int r)
|
public boolean connectInternal(PartFlatWire wire, int r)
|
||||||
{
|
{
|
||||||
if (canConnectTo(wire))
|
if (this.canConnectTo(wire))
|
||||||
{
|
{
|
||||||
int oldConn = connMap;
|
int oldConn = connMap;
|
||||||
connMap |= 0x100 << r;
|
connMap |= 0x100 << r;
|
||||||
|
@ -756,7 +753,7 @@ public class FlatWire extends PartWireBase implements TFacePart, JNormalOcclusio
|
||||||
|
|
||||||
public int getThickness()
|
public int getThickness()
|
||||||
{
|
{
|
||||||
return 0;
|
return this.isInsulated ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -56,19 +56,32 @@ public class TraitConductor extends TileMultipart implements IConductor
|
||||||
@Override
|
@Override
|
||||||
public Object[] getConnections()
|
public Object[] getConnections()
|
||||||
{
|
{
|
||||||
|
for (IConductor conductor : this.interfaces)
|
||||||
|
{
|
||||||
|
return conductor.getConnections();
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnergyNetwork getNetwork()
|
public IEnergyNetwork getNetwork()
|
||||||
{
|
{
|
||||||
|
for (IConductor conductor : this.interfaces)
|
||||||
|
{
|
||||||
|
return conductor.getNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNetwork(IEnergyNetwork network)
|
public void setNetwork(IEnergyNetwork network)
|
||||||
{
|
{
|
||||||
|
for (IConductor conductor : this.interfaces)
|
||||||
|
{
|
||||||
|
conductor.setNetwork(network);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,19 +101,13 @@ public class TraitConductor extends TileMultipart implements IConductor
|
||||||
@Override
|
@Override
|
||||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
||||||
{
|
{
|
||||||
/*TMultiPart part = partMap(from.ordinal());
|
TMultiPart part = this.partMap(from.ordinal());
|
||||||
|
|
||||||
if (part != null)
|
if (this.interfaces.contains(part))
|
||||||
{
|
{
|
||||||
for (IConductor conductor : this.interfaces)
|
((IConductor) part).onReceiveEnergy(from, receive, doReceive);
|
||||||
{
|
|
||||||
if (conductor == part)
|
|
||||||
{
|
|
||||||
conductor.onReceiveEnergy(from, receive, doReceive);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,13 +120,37 @@ public class TraitConductor extends TileMultipart implements IConductor
|
||||||
@Override
|
@Override
|
||||||
public long getEnergyLoss()
|
public long getEnergyLoss()
|
||||||
{
|
{
|
||||||
return 0;
|
long energyLoss = 0;
|
||||||
|
|
||||||
|
if (this.interfaces.size() > 0)
|
||||||
|
{
|
||||||
|
for (IConductor conductor : this.interfaces)
|
||||||
|
{
|
||||||
|
energyLoss += conductor.getEnergyLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
energyLoss /= this.interfaces.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
return energyLoss;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getEnergyCapacitance()
|
public long getEnergyCapacitance()
|
||||||
{
|
{
|
||||||
return 0;
|
long capacitance = 0;
|
||||||
|
|
||||||
|
if (this.interfaces.size() > 0)
|
||||||
|
{
|
||||||
|
for (IConductor conductor : this.interfaces)
|
||||||
|
{
|
||||||
|
capacitance += conductor.getEnergyCapacitance();
|
||||||
|
}
|
||||||
|
|
||||||
|
capacitance /= this.interfaces.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
return capacitance;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package resonantinduction.wire.part;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import codechicken.multipart.TMultiPart;
|
|
||||||
import codechicken.multipart.TileMultipart;
|
|
||||||
|
|
||||||
public class TraitTest extends TileMultipart implements ITest
|
|
||||||
{
|
|
||||||
public Set<ITest> interfaces = new HashSet<ITest>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
|
|
||||||
{
|
|
||||||
|
|
||||||
TMultiPart part = partMap(from.ordinal());
|
|
||||||
|
|
||||||
if (part != null)
|
|
||||||
{
|
|
||||||
for (ITest conductor : this.interfaces)
|
|
||||||
{
|
|
||||||
if (conductor == part)
|
|
||||||
{
|
|
||||||
((ITest) conductor).onReceiveEnergy(from, receive, doReceive);
|
|
||||||
System.out.println("RECEIVING");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@ import java.util.LinkedList;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.util.Icon;
|
import net.minecraft.util.Icon;
|
||||||
import resonantinduction.wire.part.FlatWire;
|
import resonantinduction.wire.part.PartFlatWire;
|
||||||
import codechicken.lib.lighting.LightModel;
|
import codechicken.lib.lighting.LightModel;
|
||||||
import codechicken.lib.math.MathHelper;
|
import codechicken.lib.math.MathHelper;
|
||||||
import codechicken.lib.render.CCModel;
|
import codechicken.lib.render.CCModel;
|
||||||
|
@ -398,7 +398,7 @@ public class RenderFlatWire
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int modelKey(FlatWire w)
|
public static int modelKey(PartFlatWire w)
|
||||||
{
|
{
|
||||||
return modelKey(w.side, w.getThickness(), w.connMap);
|
return modelKey(w.side, w.getThickness(), w.connMap);
|
||||||
}
|
}
|
||||||
|
@ -411,7 +411,7 @@ public class RenderFlatWire
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void render(FlatWire w, Vector3 pos)
|
public static void render(PartFlatWire w, Vector3 pos)
|
||||||
{
|
{
|
||||||
IVertexModifier m = w.getColour().pack() == -1 ? ColourModifier.instance : new ColourMultiplier(w.getColour());
|
IVertexModifier m = w.getColour().pack() == -1 ? ColourModifier.instance : new ColourMultiplier(w.getColour());
|
||||||
CCModel model = getOrGenerateModel(modelKey(w));
|
CCModel model = getOrGenerateModel(modelKey(w));
|
||||||
|
@ -427,7 +427,7 @@ public class RenderFlatWire
|
||||||
m.render(t, new IconTransformation(icon));
|
m.render(t, new IconTransformation(icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderBreakingOverlay(Icon icon, FlatWire wire)
|
public static void renderBreakingOverlay(Icon icon, PartFlatWire wire)
|
||||||
{
|
{
|
||||||
int key = modelKey(wire);
|
int key = modelKey(wire);
|
||||||
int side = (key >> 8) % 6;
|
int side = (key >> 8) % 6;
|
||||||
|
|
Loading…
Reference in a new issue