From d9695923d8bf50cfe5be7d6df04e2e70c120a237 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 30 Mar 2017 18:11:42 +0200 Subject: [PATCH] possibly fixed laser relays sometimes disconnecting (finally? D:) --- .../mod/blocks/BlockLaserRelay.java | 8 ++++++ .../mod/tile/TileEntityLaserRelay.java | 26 ------------------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java index 1b2f9b42b..263818fa2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.laser.Network; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; @@ -273,6 +274,13 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ } } + @Override + public void breakBlock(World world, BlockPos pos, IBlockState state){ + super.breakBlock(world, pos, state); + + ActuallyAdditionsAPI.connectionHandler.removeRelayFromNetwork(pos, world); + } + public enum Type{ ENERGY_BASIC, ENERGY_ADVANCED, diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java index f7ae735fb..0143eed07 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java @@ -28,8 +28,6 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.IItemHandler; -import java.util.Set; - public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{ public static final int MAX_DISTANCE = 15; @@ -41,8 +39,6 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{ private int changeAmountAtCaching = -1; private int lastRange; - private Set tempConnectionStorage; - public TileEntityLaserRelay(String name, LaserType type){ super(1, name); this.type = type; @@ -153,28 +149,6 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{ return this.cachedNetwork; } - @Override - public void invalidate(){ - super.invalidate(); - //This is because Minecraft randomly invalidates tiles on world join and then validates them again - //We need to compensate for this so that connections don't get broken randomly - this.tempConnectionStorage = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(this.pos, this.world); - - ActuallyAdditionsAPI.connectionHandler.removeRelayFromNetwork(this.pos, this.world); - } - - @Override - public void validate(){ - if(this.tempConnectionStorage != null){ - for(IConnectionPair pair : this.tempConnectionStorage){ - ActuallyAdditionsAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], pair.getType(), this.world, pair.doesSuppressRender()); - } - this.tempConnectionStorage = null; - } - - super.validate(); - } - @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox(){