From f7576c652a0d2bb0b36c49940fcf61587d2a09c2 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 29 Mar 2017 12:12:31 +0200 Subject: [PATCH] Added the ability to disconnect laser relys Closes #698 --- .../api/laser/ILaserRelayConnectionHandler.java | 2 ++ .../mod/items/ItemLaserWrench.java | 2 +- .../misc/apiimpl/LaserRelayConnectionHandler.java | 13 ++++++++++++- .../assets/actuallyadditions/lang/en_US.lang | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java b/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java index 334751875..27cbbdb7e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java @@ -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 removeIfConnected); + void removeConnection(World world, BlockPos firstRelay, BlockPos secondRelay); LaserType getTypeFromLaser(TileEntity tile); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java index 5853792fa..7377fc70f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java @@ -59,7 +59,7 @@ public class ItemLaserWrench extends ItemBase{ int lowestRange = Math.min(relay.getMaxRange(), savedRelay.getMaxRange()); 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"); ((TileEntityLaserRelay)savedTile).sendUpdate(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/LaserRelayConnectionHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/LaserRelayConnectionHandler.java index 2ecccbe1d..8f96bb448 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/LaserRelayConnectionHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/LaserRelayConnectionHandler.java @@ -128,6 +128,11 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH */ @Override 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)){ return false; } @@ -145,7 +150,13 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH } //The same Network else if(firstNetwork == secondNetwork){ - return false; + if(removeIfConnected){ + this.removeConnection(world, firstRelay, secondRelay); + return true; + } + else{ + return false; + } } //Both relays have laserRelayNetworks else if(firstNetwork != null && secondNetwork != null){ diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index f9ae71bff..7599785eb 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -1057,7 +1057,7 @@ booklet.actuallyadditions.chapter.hairBalls.text.2=Balls of Fur are an booklet.actuallyadditions.chapter.laserIntro.name=Intro to Laser Relays booklet.actuallyadditions.chapter.laserIntro.text.1=Laser Relays exist in different variants, however, they all have the same basic functionality. A Laser Relay can be connected to one ore more other laser relays using a Laser Wrench. This can be achieved by right-clicking the first relay and then right-clicking the second one. There can be an infinite number of interconnected Laser Relays, making what is called a Network or System. Such a network will have no predefined starting or end point, but instead, booklet.actuallyadditions.chapter.laserIntro.text.2=every Laser Relay has access to interact with all of the other ones in different ways. Connecting two Laser Relays has some restrictions, however. First of all, two connected Laser Relays must be at most blocks apart from each other. Additionally, two Laser Relays of a different type cannot be connected to one another. View the other items in this chapter to find out more about different types of Laser Relays! -booklet.actuallyadditions.chapter.laserIntro.text.3=Hovering over Laser Relays with the Laser Wrench will also bring up useful information like the energy flow configuration or the priority configuration. +booklet.actuallyadditions.chapter.laserIntro.text.3=Hovering over Laser Relays with the Laser Wrench will also bring up useful information like the energy flow configuration or the priority configuration. Additionally, linking two already connected Laser Relays will cause them to disconnect. booklet.actuallyadditions.chapter.laserRelays.name=Energy Laser Relays booklet.actuallyadditions.chapter.laserRelays.text.1=The Energy Laser Relay is a block that can wirelessly transfer CF. When placing a Power Generator or Receiver next to the relay, it can receive Power from any other relay in the network and send power to any other relay as well. During an energy transfer, they have a slight Energy Loss, but nothing to worry about, especially because it's per transfer, so it doesn't matter how many Lasers are inbetween two machines, the loss will always be the same amount.