Improve connecting of cables
This commit is contained in:
@@ -44,12 +44,12 @@ public class BlockCable extends BlockBase
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
return super.getActualState(state, world, pos)
|
||||
.withProperty(NORTH, TileCable.isCable(world, pos.north()))
|
||||
.withProperty(EAST, TileCable.isCable(world, pos.east()))
|
||||
.withProperty(SOUTH, TileCable.isCable(world, pos.south()))
|
||||
.withProperty(WEST, TileCable.isCable(world, pos.west()))
|
||||
.withProperty(UP, TileCable.isCable(world, pos.up()))
|
||||
.withProperty(DOWN, TileCable.isCable(world, pos.down()));
|
||||
.withProperty(NORTH, TileCable.hasConnectionWith(world, pos.north()))
|
||||
.withProperty(EAST, TileCable.hasConnectionWith(world, pos.east()))
|
||||
.withProperty(SOUTH, TileCable.hasConnectionWith(world, pos.south()))
|
||||
.withProperty(WEST, TileCable.hasConnectionWith(world, pos.west()))
|
||||
.withProperty(UP, TileCable.hasConnectionWith(world, pos.up()))
|
||||
.withProperty(DOWN, TileCable.hasConnectionWith(world, pos.down()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,35 +5,19 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import storagecraft.block.BlockCable;
|
||||
|
||||
public class TileCable extends TileBase
|
||||
{
|
||||
public static boolean isCable(IBlockAccess world, BlockPos pos)
|
||||
public static boolean hasConnectionWith(IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
return world.getBlockState(pos).getBlock() instanceof BlockCable;
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
public boolean hasConnection(EnumFacing dir)
|
||||
{
|
||||
if (!isEnabled())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isCable(worldObj, pos.offset(dir)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntity tile = worldObj.getTileEntity(pos.offset(dir));
|
||||
|
||||
return tile instanceof TileMachine || tile instanceof TileController;
|
||||
return tile instanceof TileCable || tile instanceof TileMachine || tile instanceof TileController;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return !worldObj.isBlockPowered(pos);
|
||||
return true; // @TODO
|
||||
}
|
||||
|
||||
public void addMachines(List<BlockPos> visited, List<TileMachine> machines, TileController controller)
|
||||
@@ -52,17 +36,17 @@ public class TileCable extends TileBase
|
||||
{
|
||||
BlockPos newPos = pos.offset(dir);
|
||||
|
||||
boolean found = false;
|
||||
boolean alreadyVisited = false;
|
||||
|
||||
for (BlockPos visitedBlock : visited)
|
||||
{
|
||||
if (visitedBlock.equals(newPos))
|
||||
{
|
||||
found = true;
|
||||
alreadyVisited = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
if (alreadyVisited)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user