Updated UE

This commit is contained in:
Calclavia 2013-12-20 21:59:52 +08:00
parent 3f2e74299b
commit f8bfa1ddde
30 changed files with 167 additions and 138 deletions

View file

@ -19,7 +19,7 @@ import resonantinduction.render.RenderTesla;
import resonantinduction.render.RenderWire; import resonantinduction.render.RenderWire;
import resonantinduction.tesla.TileEntityTesla; import resonantinduction.tesla.TileEntityTesla;
import resonantinduction.wire.TileEntityWire; import resonantinduction.wire.TileEntityWire;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;

View file

@ -10,7 +10,7 @@ import resonantinduction.battery.ContainerBattery;
import resonantinduction.battery.TileEntityBattery; import resonantinduction.battery.TileEntityBattery;
import resonantinduction.multimeter.ContainerMultimeter; import resonantinduction.multimeter.ContainerMultimeter;
import resonantinduction.multimeter.TileEntityMultimeter; import resonantinduction.multimeter.TileEntityMultimeter;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.IGuiHandler;
/** /**

View file

@ -41,9 +41,9 @@ import resonantinduction.wire.BlockWire;
import resonantinduction.wire.EnumWireMaterial; import resonantinduction.wire.EnumWireMaterial;
import resonantinduction.wire.ItemBlockWire; import resonantinduction.wire.ItemBlockWire;
import resonantinduction.wire.TileEntityWire; import resonantinduction.wire.TileEntityWire;
import universalelectricity.compatibility.Compatibility; import universalelectricity.api.Compatibility;
import universalelectricity.api.vector.Vector3;
import universalelectricity.core.item.IItemElectric; import universalelectricity.core.item.IItemElectric;
import universalelectricity.core.vector.Vector3;
import basiccomponents.api.BasicRegistry; import basiccomponents.api.BasicRegistry;
import calclavia.lib.UniversalRecipe; import calclavia.lib.UniversalRecipe;
import calclavia.lib.network.PacketHandler; import calclavia.lib.network.PacketHandler;
@ -310,8 +310,6 @@ public class ResonantInduction
LOGGER.severe("Failed to initiate Resonant Induction multipart module."); LOGGER.severe("Failed to initiate Resonant Induction multipart module.");
} }
} }
Compatibility.initiate();
} }
@EventHandler @EventHandler

View file

@ -11,7 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.base.ListUtil; import resonantinduction.base.ListUtil;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
public class BatteryUpdateProtocol public class BatteryUpdateProtocol
{ {

View file

@ -7,8 +7,8 @@ import java.util.Set;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import resonantinduction.base.ListUtil; import resonantinduction.base.ListUtil;
import universalelectricity.api.vector.Vector3;
import universalelectricity.core.item.IItemElectric; import universalelectricity.core.item.IItemElectric;
import universalelectricity.core.vector.Vector3;
public class SynchronizedBatteryData public class SynchronizedBatteryData
{ {

View file

@ -22,10 +22,10 @@ import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.api.ICapacitor; import resonantinduction.api.ICapacitor;
import resonantinduction.base.ListUtil; import resonantinduction.base.ListUtil;
import universalelectricity.api.vector.Vector3;
import universalelectricity.compatibility.TileEntityUniversalElectrical; import universalelectricity.compatibility.TileEntityUniversalElectrical;
import universalelectricity.core.electricity.ElectricityPack; import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.item.IItemElectric; import universalelectricity.core.item.IItemElectric;
import universalelectricity.core.vector.Vector3;
import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.IPacketSender; import calclavia.lib.network.IPacketSender;

View file

@ -11,7 +11,7 @@ import resonantinduction.ResonantInduction;
import resonantinduction.base.BlockBase; import resonantinduction.base.BlockBase;
import resonantinduction.entangler.ItemCoordLink; import resonantinduction.entangler.ItemCoordLink;
import resonantinduction.render.BlockRenderingHandler; import resonantinduction.render.BlockRenderingHandler;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -11,7 +11,7 @@ import java.util.Set;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
/** /**
* Uses the well known A* Pathfinding algorithm. * Uses the well known A* Pathfinding algorithm.

View file

@ -3,7 +3,7 @@
*/ */
package resonantinduction.contractor; package resonantinduction.contractor;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
/** /**
* @author Calclavia * @author Calclavia

View file

@ -23,7 +23,7 @@ import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.tesla.TileEntityTesla; import resonantinduction.tesla.TileEntityTesla;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.InventoryHelper; import calclavia.lib.InventoryHelper;
import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.IPacketSender; import calclavia.lib.network.IPacketSender;

View file

@ -9,7 +9,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 resonantinduction.base.ItemBase; import resonantinduction.base.ItemBase;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -6,7 +6,7 @@ package resonantinduction.entangler;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
/** /**
* @author Calclavia * @author Calclavia

View file

@ -4,7 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
/** /**
* *

View file

@ -6,15 +6,15 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import universalelectricity.api.IEnergyInterface;
import universalelectricity.api.IVoltage;
import universalelectricity.api.UniversalClass; import universalelectricity.api.UniversalClass;
import universalelectricity.api.electricity.IVoltage;
import universalelectricity.api.energy.IEnergyInterface;
import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorHelper;
import universalelectricity.core.block.IConductor; import universalelectricity.core.block.IConductor;
import universalelectricity.core.electricity.ElectricityHelper; import universalelectricity.core.electricity.ElectricityHelper;
import universalelectricity.core.electricity.ElectricityPack; import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.grid.IElectricityNetwork; import universalelectricity.core.grid.IEnergyNetwork;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
/** /**
* Meant to replace the furnace class. * Meant to replace the furnace class.
@ -72,7 +72,7 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEne
{ {
if (this.furnaceBurnTime > 0) if (this.furnaceBurnTime > 0)
{ {
this.produceUE(direction); this.energyBuffer += ResonantInduction.FURNACE_WATTAGE / 20;
} }
hasRequest = true; hasRequest = true;
@ -139,41 +139,6 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEne
} }
} }
/**
* Produces UE power towards a specific direction.
*
* @param outputDirection - The output direction.
*/
public boolean produceUE(ForgeDirection outputDirection)
{
if (!this.worldObj.isRemote && outputDirection != null && outputDirection != ForgeDirection.UNKNOWN)
{
float provide = this.onReceiveEnergy(null, Integer.MAX_VALUE, false);
if (provide > 0)
{
TileEntity outputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection);
IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(outputTile, outputDirection);
if (outputNetwork != null)
{
ElectricityPack powerRequest = outputNetwork.getRequest(this);
if (powerRequest.getWatts() > 0)
{
ElectricityPack sendPack = ElectricityPack.getFromWatts(provide, this.getVoltage(null));
float rejectedPower = outputNetwork.produce(sendPack, this);
this.onExtractEnergy(outputDirection.getOpposite(), (int) (sendPack.getWatts() - rejectedPower), true);
}
return true;
}
}
}
return false;
}
@Override @Override
public boolean canConnect(ForgeDirection direction) public boolean canConnect(ForgeDirection direction)
{ {

View file

@ -27,7 +27,7 @@ import net.minecraft.world.World;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -10,8 +10,8 @@ import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.battery.ContainerBattery; import resonantinduction.battery.ContainerBattery;
import resonantinduction.battery.TileEntityBattery; import resonantinduction.battery.TileEntityBattery;
import universalelectricity.core.electricity.ElectricityDisplay; import universalelectricity.api.electricity.ElectricityDisplay;
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit; import universalelectricity.api.electricity.ElectricityDisplay.ElectricUnit;
public class GuiBattery extends GuiContainer public class GuiBattery extends GuiContainer
{ {

View file

@ -4,8 +4,8 @@ import java.util.HashMap;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.ForgeSubscribe;
import universalelectricity.core.electricity.ElectricalEvent.ElectricityProductionEvent; import universalelectricity.api.electricity.ElectricalEvent.EnergyUpdateEvent;
import universalelectricity.core.grid.IElectricityNetwork; import universalelectricity.core.grid.IEnergyNetwork;
/** /**
* @author Calclavia * @author Calclavia
@ -13,12 +13,12 @@ import universalelectricity.core.grid.IElectricityNetwork;
*/ */
public class MultimeterEventHandler public class MultimeterEventHandler
{ {
private static final HashMap<IElectricityNetwork, Float> networkEnergyCache = new HashMap<IElectricityNetwork, Float>(); private static final HashMap<IEnergyNetwork, Integer> networkEnergyCache = new HashMap<IEnergyNetwork, Integer>();
private static long lastCheckTime = 0; private static long lastCheckTime = 0;
public static HashMap<IElectricityNetwork, Float> getCache(World worldObj) public static HashMap<IEnergyNetwork, Float> getCache(World worldObj)
{ {
HashMap<IElectricityNetwork, Float> returnCache = (HashMap<IElectricityNetwork, Float>) networkEnergyCache.clone(); HashMap<IEnergyNetwork, Float> returnCache = (HashMap<IEnergyNetwork, Float>) networkEnergyCache.clone();
if (Math.abs(worldObj.getWorldTime() - lastCheckTime) >= 40) if (Math.abs(worldObj.getWorldTime() - lastCheckTime) >= 40)
{ {
@ -30,13 +30,13 @@ public class MultimeterEventHandler
} }
@ForgeSubscribe @ForgeSubscribe
public void event(ElectricityProductionEvent evt) public void event(EnergyUpdateEvent evt)
{ {
IElectricityNetwork network = evt.network; IEnergyNetwork network = evt.network;
if (evt.electricityPack.getWatts() != 0) if (network.getDistribution(null) != 0)
{ {
networkEnergyCache.put(network, evt.electricityPack.getWatts()); networkEnergyCache.put(network, network.getDistribution(null));
} }
} }
} }

View file

@ -25,7 +25,7 @@ import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.battery.TileEntityBattery; import resonantinduction.battery.TileEntityBattery;
import resonantinduction.model.ModelBattery; import resonantinduction.model.ModelBattery;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -11,8 +11,8 @@ import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.model.ModelMultimeter; import resonantinduction.model.ModelMultimeter;
import resonantinduction.multimeter.TileEntityMultimeter; import resonantinduction.multimeter.TileEntityMultimeter;
import universalelectricity.core.electricity.ElectricityDisplay; import universalelectricity.api.electricity.ElectricityDisplay;
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit; import universalelectricity.api.electricity.ElectricityDisplay.ElectricUnit;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -14,7 +14,7 @@ import org.lwjgl.opengl.GL11;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.wire.PartConductor; import resonantinduction.wire.PartConductor;
import resonantinduction.wire.PartWire; import resonantinduction.wire.PartWire;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
import codechicken.lib.colour.Colour; import codechicken.lib.colour.Colour;
import codechicken.lib.colour.ColourRGBA; import codechicken.lib.colour.ColourRGBA;
import codechicken.lib.lighting.LightModel; import codechicken.lib.lighting.LightModel;

View file

@ -11,7 +11,7 @@ import resonantinduction.model.ModelInsulation;
import resonantinduction.model.ModelWire; import resonantinduction.model.ModelWire;
import resonantinduction.wire.EnumWireMaterial; import resonantinduction.wire.EnumWireMaterial;
import resonantinduction.wire.TileEntityWire; import resonantinduction.wire.TileEntityWire;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -13,7 +13,7 @@ import resonantinduction.ResonantInduction;
import resonantinduction.base.BlockBase; import resonantinduction.base.BlockBase;
import resonantinduction.entangler.ItemCoordLink; import resonantinduction.entangler.ItemCoordLink;
import resonantinduction.render.BlockRenderingHandler; import resonantinduction.render.BlockRenderingHandler;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -23,9 +23,9 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.api.ITesla; import resonantinduction.api.ITesla;
import universalelectricity.api.vector.Vector3;
import universalelectricity.compatibility.TileEntityUniversalElectrical; import universalelectricity.compatibility.TileEntityUniversalElectrical;
import universalelectricity.core.electricity.ElectricityPack; import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.vector.Vector3;
import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.IPacketSender; import calclavia.lib.network.IPacketSender;

View file

@ -4,7 +4,7 @@ import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.Vector3;
/** /**
* An enumerator for different wire materials. The metadata of the wire determines the type of the * An enumerator for different wire materials. The metadata of the wire determines the type of the

View file

@ -7,8 +7,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import universalelectricity.core.electricity.ElectricityDisplay; import universalelectricity.api.electricity.ElectricityDisplay;
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit; import universalelectricity.api.electricity.ElectricityDisplay.ElectricUnit;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;

View file

@ -12,8 +12,8 @@ import net.minecraftforge.common.Configuration;
import resonantinduction.ResonantInduction; import resonantinduction.ResonantInduction;
import resonantinduction.TabRI; import resonantinduction.TabRI;
import resonantinduction.render.RenderPartWire; import resonantinduction.render.RenderPartWire;
import universalelectricity.core.electricity.ElectricityDisplay; import universalelectricity.api.electricity.ElectricityDisplay;
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit; import universalelectricity.api.electricity.ElectricityDisplay.ElectricUnit;
import codechicken.lib.vec.BlockCoord; import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3; import codechicken.lib.vec.Vector3;
import codechicken.multipart.JItemMultiPart; import codechicken.multipart.JItemMultiPart;

View file

@ -2,23 +2,83 @@ package resonantinduction.wire;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.block.IConductor; import universalelectricity.api.IConnector;
import universalelectricity.core.block.IConnector; import universalelectricity.api.INetworkProvider;
import universalelectricity.core.block.INetworkProvider; import universalelectricity.api.energy.IConductor;
import universalelectricity.core.electricity.NetworkLoader; import universalelectricity.api.energy.IEnergyInterface;
import universalelectricity.core.grid.IElectricityNetwork; import universalelectricity.api.vector.Vector3;
import universalelectricity.core.vector.Vector3; import universalelectricity.api.vector.VectorHelper;
import universalelectricity.core.vector.VectorHelper; import universalelectricity.core.grid.EnergyNetworkLoader;
import universalelectricity.core.grid.IEnergyNetwork;
import codechicken.multipart.TileMultipart; import codechicken.multipart.TileMultipart;
public abstract class PartConductor extends PartAdvanced implements IConductor public abstract class PartConductor extends PartAdvanced implements IConductor
{ {
private IElectricityNetwork network; private IEnergyNetwork network;
private int buffer = 0;
public TileEntity[] adjacentConnections = null; public TileEntity[] adjacentConnections = null;
public byte currentWireConnections = 0x00; public byte currentWireConnections = 0x00;
public byte currentAcceptorConnections = 0x00; public byte currentAcceptorConnections = 0x00;
@Override
public int onReceiveEnergy(ForgeDirection from, int receive, boolean doReceive)
{
int energyReceived = Math.min(this.getEnergyCapacitance() - this.buffer, receive);
if (doReceive)
{
this.buffer += energyReceived;
}
return energyReceived;
}
@Override
public int onExtractEnergy(ForgeDirection from, int request, boolean doExtract)
{
int energyExtracted = Math.min(this.buffer, request);
if (doExtract)
{
this.buffer -= energyExtracted;
}
return energyExtracted;
}
@Override
public void distribute()
{
Object[] receivers = this.getAdjacentConnections();
int energyUsed = 0;
for (int i = 0; i < receivers.length; i++)
{
ForgeDirection direction = ForgeDirection.getOrientation(i);
Object receiver = receivers[i];
if (receiver instanceof IEnergyInterface && !(receiver instanceof IConductor))
{
energyUsed += ((IEnergyInterface) receiver).onReceiveEnergy(direction.getOpposite(), this.getNetwork().getDistribution(this), true);
}
}
this.onExtractEnergy(null, energyUsed, true);
}
@Override
public int getEnergyLoss()
{
return 0;
}
@Override
public int getEnergyCapacitance()
{
return 0;
}
public byte getAllCurrentConnections() public byte getAllCurrentConnections()
{ {
return (byte) (currentWireConnections | currentAcceptorConnections); return (byte) (currentWireConnections | currentAcceptorConnections);
@ -30,16 +90,23 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
return ((connections & tester) > 0); return ((connections & tester) > 0);
} }
@Override
public void onMoved()
{
this.refresh();
}
@Override @Override
public void bind(TileMultipart t) public void bind(TileMultipart t)
{ {
if(tile() != null && network != null) if (tile() != null && network != null)
{ {
getNetwork().getConductors().remove(tile()); getNetwork().getConnectors().remove(tile());
super.bind(t); super.bind(t);
getNetwork().getConductors().add((IConductor) tile()); getNetwork().getConnectors().add((IConductor) tile());
} }
else { else
{
super.bind(t); super.bind(t);
} }
} }
@ -47,7 +114,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
@Override @Override
public void preRemove() public void preRemove()
{ {
if(!world().isRemote && tile() instanceof IConductor) if (!world().isRemote && tile() instanceof IConductor)
{ {
getNetwork().split((IConductor) tile()); getNetwork().split((IConductor) tile());
} }
@ -62,11 +129,11 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
} }
@Override @Override
public IElectricityNetwork getNetwork() public IEnergyNetwork getNetwork()
{ {
if(network == null && tile() instanceof IConductor) if (network == null && tile() instanceof IConductor)
{ {
setNetwork(NetworkLoader.getNewNetwork((IConductor)tile())); setNetwork(EnergyNetworkLoader.getNewNetwork((IConductor) tile()));
} }
return network; return network;
@ -76,16 +143,16 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
{ {
boolean notPrevented = !isConnectionPrevented(tile, side); boolean notPrevented = !isConnectionPrevented(tile, side);
if(tile instanceof IConnector) if (tile instanceof IConnector)
{ {
notPrevented &= ((IConnector)tile).canConnect(side.getOpposite()); notPrevented &= ((IConnector) tile).canConnect(side.getOpposite());
} }
return notPrevented; return notPrevented;
} }
@Override @Override
public void setNetwork(IElectricityNetwork net) public void setNetwork(IEnergyNetwork net)
{ {
network = net; network = net;
} }
@ -106,11 +173,11 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
{ {
byte connections = 0x00; byte connections = 0x00;
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{ {
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side); TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
if(tileEntity instanceof INetworkProvider && canConnectBothSides(tileEntity, side)) if (tileEntity instanceof INetworkProvider && canConnectBothSides(tileEntity, side))
{ {
connections |= 1 << side.ordinal(); connections |= 1 << side.ordinal();
} }
@ -123,11 +190,11 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
{ {
byte connections = 0x00; byte connections = 0x00;
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{ {
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side); TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
if(isValidAcceptor(tileEntity) && canConnectBothSides(tileEntity, side)) if (isValidAcceptor(tileEntity) && canConnectBothSides(tileEntity, side))
{ {
connections |= 1 << side.ordinal(); connections |= 1 << side.ordinal();
} }
@ -144,46 +211,44 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
return tile instanceof IConnector; return tile instanceof IConnector;
} }
@Override
public void refresh() public void refresh()
{ {
if(!world().isRemote) if (!world().isRemote)
{ {
adjacentConnections = null; adjacentConnections = null;
byte possibleWireConnections = getPossibleWireConnections(); byte possibleWireConnections = getPossibleWireConnections();
byte possibleAcceptorConnections = getPossibleAcceptorConnections(); byte possibleAcceptorConnections = getPossibleAcceptorConnections();
if(possibleWireConnections != currentWireConnections) if (possibleWireConnections != currentWireConnections)
{ {
byte or = (byte) (possibleWireConnections | currentWireConnections); byte or = (byte) (possibleWireConnections | currentWireConnections);
if(or != possibleWireConnections) // Connections have been removed if (or != possibleWireConnections) // Connections have been removed
{ {
getNetwork().split((IConductor) tile()); getNetwork().split((IConductor) tile());
setNetwork(null); setNetwork(null);
} }
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{ {
if(connectionMapContainsSide(possibleWireConnections, side)) if (connectionMapContainsSide(possibleWireConnections, side))
{ {
TileEntity tileEntity = VectorHelper.getConnectorFromSide(world(), new Vector3(tile()), side); TileEntity tileEntity = VectorHelper.getConnectorFromSide(world(), new Vector3(tile()), side);
if(tileEntity instanceof INetworkProvider) if (tileEntity instanceof IConductor)
{ {
getNetwork().merge(((INetworkProvider) tileEntity).getNetwork()); getNetwork().merge(((IConductor) tileEntity).getNetwork());
} }
} }
} }
currentWireConnections = possibleWireConnections; this.currentWireConnections = possibleWireConnections;
} }
currentAcceptorConnections = possibleAcceptorConnections; this.currentAcceptorConnections = possibleAcceptorConnections;
getNetwork().refresh(); this.sendDescUpdate();
sendDescUpdate();
} }
tile().markRender(); tile().markRender();
@ -196,22 +261,22 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
@Override @Override
public TileEntity[] getAdjacentConnections() public TileEntity[] getAdjacentConnections()
{ {
if(adjacentConnections == null) if (this.adjacentConnections == null)
{ {
adjacentConnections = new TileEntity[6]; this.adjacentConnections = new TileEntity[6];
for(byte i = 0; i < 6; i++) for (byte i = 0; i < 6; i++)
{ {
ForgeDirection side = ForgeDirection.getOrientation(i); ForgeDirection side = ForgeDirection.getOrientation(i);
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side); TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
if(isCurrentlyConnected(side)) if (isCurrentlyConnected(side))
{ {
adjacentConnections[i] = tileEntity; this.adjacentConnections[i] = tileEntity;
} }
} }
} }
return adjacentConnections; return this.adjacentConnections;
} }
public boolean isCurrentlyConnected(ForgeDirection side) public boolean isCurrentlyConnected(ForgeDirection side)
@ -250,4 +315,5 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
super.onNeighborChanged(); super.onNeighborChanged();
refresh(); refresh();
} }
} }

View file

@ -12,10 +12,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import universalelectricity.compatibility.Compatibility; import universalelectricity.api.Compatibility;
import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorHelper;
import universalelectricity.core.electricity.ElectricityPack; import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.PowerReceiver;

View file

@ -21,7 +21,7 @@ import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.render.RenderPartWire; import resonantinduction.render.RenderPartWire;
import universalelectricity.compatibility.Compatibility; import universalelectricity.api.Compatibility;
import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler;
import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput; import codechicken.lib.data.MCDataOutput;

View file

@ -8,11 +8,11 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.compatibility.Compatibility; import universalelectricity.api.Compatibility;
import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorHelper;
import universalelectricity.compatibility.TileEntityUniversalConductor; import universalelectricity.compatibility.TileEntityUniversalConductor;
import universalelectricity.core.block.INetworkProvider; import universalelectricity.core.block.INetworkProvider;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler;
import calclavia.lib.network.IPacketReceiver; import calclavia.lib.network.IPacketReceiver;
import calclavia.lib.network.IPacketSender; import calclavia.lib.network.IPacketSender;