Added the ability to disconnect laser relys

Closes #698
This commit is contained in:
Ellpeck 2017-03-29 12:12:31 +02:00
parent ab5a4d29b1
commit f7576c652a
4 changed files with 16 additions and 3 deletions

View file

@ -35,6 +35,8 @@ public interface ILaserRelayConnectionHandler{
boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender); boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender);
boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender, boolean removeIfConnected);
void removeConnection(World world, BlockPos firstRelay, BlockPos secondRelay); void removeConnection(World world, BlockPos firstRelay, BlockPos secondRelay);
LaserType getTypeFromLaser(TileEntity tile); LaserType getTypeFromLaser(TileEntity tile);

View file

@ -59,7 +59,7 @@ public class ItemLaserWrench extends ItemBase{
int lowestRange = Math.min(relay.getMaxRange(), savedRelay.getMaxRange()); int lowestRange = Math.min(relay.getMaxRange(), savedRelay.getMaxRange());
int range = lowestRange*lowestRange; int range = lowestRange*lowestRange;
if(ItemPhantomConnector.getStoredWorld(stack) == world && savedRelay.type == relay.type && distanceSq <= range && ActuallyAdditionsAPI.connectionHandler.addConnection(savedPos, pos, relay.type, world)){ if(ItemPhantomConnector.getStoredWorld(stack) == world && savedRelay.type == relay.type && distanceSq <= range && ActuallyAdditionsAPI.connectionHandler.addConnection(savedPos, pos, relay.type, world, false, true)){
ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored");
((TileEntityLaserRelay)savedTile).sendUpdate(); ((TileEntityLaserRelay)savedTile).sendUpdate();

View file

@ -128,6 +128,11 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
*/ */
@Override @Override
public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender){ public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender){
return this.addConnection(firstRelay, secondRelay, type, world, suppressConnectionRender, false);
}
@Override
public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender, boolean removeIfConnected){
if(firstRelay == null || secondRelay == null || firstRelay == secondRelay || firstRelay.equals(secondRelay)){ if(firstRelay == null || secondRelay == null || firstRelay == secondRelay || firstRelay.equals(secondRelay)){
return false; return false;
} }
@ -145,8 +150,14 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH
} }
//The same Network //The same Network
else if(firstNetwork == secondNetwork){ else if(firstNetwork == secondNetwork){
if(removeIfConnected){
this.removeConnection(world, firstRelay, secondRelay);
return true;
}
else{
return false; return false;
} }
}
//Both relays have laserRelayNetworks //Both relays have laserRelayNetworks
else if(firstNetwork != null && secondNetwork != null){ else if(firstNetwork != null && secondNetwork != null){
mergeNetworks(firstNetwork, secondNetwork, world); mergeNetworks(firstNetwork, secondNetwork, world);

View file

@ -1057,7 +1057,7 @@ booklet.actuallyadditions.chapter.hairBalls.text.2=<item>Balls of Fur<r> are an
booklet.actuallyadditions.chapter.laserIntro.name=Intro to Laser Relays booklet.actuallyadditions.chapter.laserIntro.name=Intro to Laser Relays
booklet.actuallyadditions.chapter.laserIntro.text.1=<item>Laser Relays<r> exist in <imp>different variants<r>, however, they all have the same basic functionality. <n>A <item>Laser Relay<r> can be connected to one ore more other laser relays using a <item>Laser Wrench<r>. This can be achieved by <imp>right-clicking<r> the first relay and then right-clicking the second one. There can be an <imp>infinite number<r> of interconnected Laser Relays, making what is called a <item>Network<r> or <item>System<r>. Such a network will have no predefined starting or end point, but instead, booklet.actuallyadditions.chapter.laserIntro.text.1=<item>Laser Relays<r> exist in <imp>different variants<r>, however, they all have the same basic functionality. <n>A <item>Laser Relay<r> can be connected to one ore more other laser relays using a <item>Laser Wrench<r>. This can be achieved by <imp>right-clicking<r> the first relay and then right-clicking the second one. There can be an <imp>infinite number<r> of interconnected Laser Relays, making what is called a <item>Network<r> or <item>System<r>. Such a network will have no predefined starting or end point, but instead,
booklet.actuallyadditions.chapter.laserIntro.text.2=every <item>Laser Relay<r> has <imp>access to interact with all of the other ones<r> in different ways. <n>Connecting two <item>Laser Relays<r> has some restrictions, however. First of all, two connected <item>Laser Relays<r> must be <imp>at most <range> blocks apart<r> from each other. <n>Additionally, two <item>Laser Relays<r> of a <imp>different type<r> cannot be connected to one another. <n><n><i>View the other items in this chapter to find out more about different types of Laser Relays! booklet.actuallyadditions.chapter.laserIntro.text.2=every <item>Laser Relay<r> has <imp>access to interact with all of the other ones<r> in different ways. <n>Connecting two <item>Laser Relays<r> has some restrictions, however. First of all, two connected <item>Laser Relays<r> must be <imp>at most <range> blocks apart<r> from each other. <n>Additionally, two <item>Laser Relays<r> of a <imp>different type<r> cannot be connected to one another. <n><n><i>View the other items in this chapter to find out more about different types of Laser Relays!
booklet.actuallyadditions.chapter.laserIntro.text.3=<imp>Hovering over<r> Laser Relays with the <item>Laser Wrench<r> will also bring up useful information like the <imp>energy flow configuration<r> or the <imp>priority configuration<r>. booklet.actuallyadditions.chapter.laserIntro.text.3=<imp>Hovering over<r> Laser Relays with the <item>Laser Wrench<r> will also bring up useful information like the <imp>energy flow configuration<r> or the <imp>priority configuration<r>. <n><n>Additionally, linking two <imp>already connected<r> Laser Relays will cause them to <imp>disconnect<r>.
booklet.actuallyadditions.chapter.laserRelays.name=Energy Laser Relays booklet.actuallyadditions.chapter.laserRelays.name=Energy Laser Relays
booklet.actuallyadditions.chapter.laserRelays.text.1=The <item>Energy Laser Relay<r> is a block that can <imp>wirelessly transfer CF<r>. <n>When placing a Power Generator or Receiver next to the relay, it can receive Power <imp>from any other relay<r> in the network and send power <imp>to any other relay<r> as well. <n>During an energy transfer, they have a slight <imp>Energy Loss<r>, but nothing to worry about, especially because it's <imp>per transfer<r>, so it doesn't matter how many Lasers are inbetween two machines, the loss will <imp>always be the same amount<r>. booklet.actuallyadditions.chapter.laserRelays.text.1=The <item>Energy Laser Relay<r> is a block that can <imp>wirelessly transfer CF<r>. <n>When placing a Power Generator or Receiver next to the relay, it can receive Power <imp>from any other relay<r> in the network and send power <imp>to any other relay<r> as well. <n>During an energy transfer, they have a slight <imp>Energy Loss<r>, but nothing to worry about, especially because it's <imp>per transfer<r>, so it doesn't matter how many Lasers are inbetween two machines, the loss will <imp>always be the same amount<r>.