Fixed connections to machines
This commit is contained in:
parent
6923d89fd1
commit
4210d15f1a
4 changed files with 23 additions and 28 deletions
|
@ -21,6 +21,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
|
@ -28,7 +29,7 @@ import cofh.api.energy.IEnergyHandler;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
|
||||
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerEmitter, IPowerReceptor, IEnergyTile, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
|
||||
{
|
||||
/** How much energy is stored in this block. */
|
||||
public double electricityStored;
|
||||
|
@ -156,7 +157,12 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
@Override
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side)
|
||||
{
|
||||
return powerHandler.getPowerReceiver();
|
||||
if(getConsumingSides().contains(side))
|
||||
{
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void reconfigure()
|
||||
|
@ -317,7 +323,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return !getOutputtingSides().contains(side);
|
||||
return getConsumingSides().contains(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -350,4 +356,10 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
|
||||
return amount-toUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEmitPowerFrom(ForgeDirection side)
|
||||
{
|
||||
return getOutputtingSides().contains(side);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,9 @@ package mekanism.common.tileentity;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.Tier.EnergyCubeTier;
|
||||
|
@ -18,7 +16,6 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
|
@ -26,7 +23,7 @@ import dan200.computer.api.IComputerAccess;
|
|||
import dan200.computer.api.ILuaContext;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
||||
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPowerReceptor, IPeripheral, IRedstoneControl
|
||||
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPeripheral, IRedstoneControl
|
||||
{
|
||||
/** This Energy Cube's tier. */
|
||||
public EnergyCubeTier tier = EnergyCubeTier.BASIC;
|
||||
|
|
|
@ -17,6 +17,7 @@ import mekanism.common.Mekanism;
|
|||
import mekanism.common.tileentity.TileEntityElectricBlock;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
|
@ -132,7 +133,8 @@ public final class CableUtils
|
|||
|
||||
if((outputter instanceof ICableOutputter && ((ICableOutputter)outputter).canOutputTo(orientation.getOpposite())) ||
|
||||
(outputter instanceof IEnergySource && ((IEnergySource)outputter).emitsEnergyTo(tileEntity, orientation.getOpposite())) ||
|
||||
(outputter instanceof IEnergyHandler && ((IEnergyHandler)outputter).canInterface(orientation.getOpposite())))
|
||||
(outputter instanceof IEnergyHandler && ((IEnergyHandler)outputter).canInterface(orientation.getOpposite())) ||
|
||||
(outputter instanceof IPowerEmitter && ((IPowerEmitter)outputter).canEmitPowerFrom(orientation.getOpposite())))
|
||||
{
|
||||
outputters[orientation.ordinal()] = outputter;
|
||||
}
|
||||
|
@ -194,14 +196,11 @@ public final class CableUtils
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else if(tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IGridTransmitter) && MekanismUtils.useBuildCraft())
|
||||
else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildCraft())
|
||||
{
|
||||
if(!(tileEntity instanceof IEnergyAcceptor) || ((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(null, side.getOpposite()))
|
||||
if(((IPowerReceptor)tileEntity).getPowerReceiver(side.getOpposite()) != null)
|
||||
{
|
||||
if(!(tileEntity instanceof IEnergySource) || ((IEnergySource)tileEntity).emitsEnergyTo(null, side.getOpposite()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
package mekanism.generators.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import ic2.api.tile.IEnergyStorage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.energy.ICableOutputter;
|
||||
import mekanism.client.sound.IHasSound;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
|
@ -16,14 +12,11 @@ import mekanism.common.PacketHandler;
|
|||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.tileentity.TileEntityElectricBlock;
|
||||
import mekanism.common.tileentity.TileEntityUniversalCable;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
@ -33,7 +26,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import dan200.computer.api.IComputerAccess;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
||||
public abstract class TileEntityGenerator extends TileEntityElectricBlock implements IPowerReceptor, IPeripheral, IActiveState, IHasSound, IRedstoneControl, IPowerEmitter
|
||||
public abstract class TileEntityGenerator extends TileEntityElectricBlock implements IPowerReceptor, IPeripheral, IActiveState, IHasSound, IRedstoneControl
|
||||
{
|
||||
/** Output per tick this generator can transfer. */
|
||||
public double output;
|
||||
|
@ -276,12 +269,6 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
|
|||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEmitPowerFrom(ForgeDirection side)
|
||||
{
|
||||
return getOutputtingSides().contains(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void reconfigure()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue