fix covers not preventing netrwork connections
This commit is contained in:
@@ -3,6 +3,7 @@ package com.refinedmods.refinedstorage.api.network.node;
|
|||||||
import com.refinedmods.refinedstorage.api.network.INetwork;
|
import com.refinedmods.refinedstorage.api.network.INetwork;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -91,6 +92,15 @@ public interface INetworkNode {
|
|||||||
*/
|
*/
|
||||||
ResourceLocation getId();
|
ResourceLocation getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param direction the direction
|
||||||
|
* @return whether a network signal can be conducted in the given direction.
|
||||||
|
*/
|
||||||
|
|
||||||
|
default boolean canConduct(Direction direction) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param owner the owner
|
* @param owner the owner
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package com.refinedmods.refinedstorage.apiimpl.network.node;
|
|||||||
import com.refinedmods.refinedstorage.RS;
|
import com.refinedmods.refinedstorage.RS;
|
||||||
import com.refinedmods.refinedstorage.api.network.node.ICoverable;
|
import com.refinedmods.refinedstorage.api.network.node.ICoverable;
|
||||||
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||||
import com.refinedmods.refinedstorage.util.WorldUtils;
|
import com.refinedmods.refinedstorage.apiimpl.network.node.cover.CoverType;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -19,6 +20,11 @@ public class CableNetworkNode extends NetworkNode implements ICoverable {
|
|||||||
this.coverManager = new CoverManager(this);
|
this.coverManager = new CoverManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canConduct(Direction direction) {
|
||||||
|
return !coverManager.hasCover(direction) || coverManager.getCover(direction).getType() == CoverType.HOLLOW;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
return RS.SERVER_CONFIG.getCable().getUsage();
|
return RS.SERVER_CONFIG.getCable().getUsage();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.refinedmods.refinedstorage.apiimpl.API;
|
|||||||
import com.refinedmods.refinedstorage.block.BaseBlock;
|
import com.refinedmods.refinedstorage.block.BaseBlock;
|
||||||
import com.refinedmods.refinedstorage.block.NetworkNodeBlock;
|
import com.refinedmods.refinedstorage.block.NetworkNodeBlock;
|
||||||
import com.refinedmods.refinedstorage.tile.config.RedstoneMode;
|
import com.refinedmods.refinedstorage.tile.config.RedstoneMode;
|
||||||
|
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -224,18 +225,20 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
|||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param direction the direction
|
@Override
|
||||||
* @return whether a network signal can be conducted in the given direction.
|
public boolean canConduct(Direction direction) {
|
||||||
*/
|
|
||||||
protected boolean canConduct(Direction direction) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(Operator operator) {
|
public void visit(Operator operator) {
|
||||||
for (Direction facing : Direction.values()) {
|
for (Direction facing : Direction.values()) {
|
||||||
if (canConduct(facing)) {
|
INetworkNode oppositeNode = NetworkUtils.getNodeFromTile(world.getTileEntity(pos.offset(facing)));
|
||||||
|
if (oppositeNode == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (canConduct(facing) && oppositeNode.canConduct(facing.getOpposite())) {
|
||||||
operator.apply(world, pos.offset(facing), facing.getOpposite());
|
operator.apply(world, pos.offset(facing), facing.getOpposite());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class RelayNetworkNode extends NetworkNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canConduct(Direction direction) {
|
public boolean canConduct(Direction direction) {
|
||||||
return canUpdate();
|
return canUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class WirelessTransmitterNetworkNode extends NetworkNode implements IWire
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canConduct(Direction direction) {
|
public boolean canConduct(Direction direction) {
|
||||||
return Direction.DOWN.equals(direction);
|
return Direction.DOWN.equals(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user