Move getting a network node/network from a tile to util class + move setOwner/getOwner to API
This commit is contained in:
@@ -51,10 +51,5 @@ public final class RS {
|
||||
@EventHandler
|
||||
public void onServerStarting(FMLServerStartingEvent e) {
|
||||
e.registerServerCommand(new CommandCreateDisk());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFingerprintViolation(FMLFingerprintViolationEvent e) {
|
||||
FMLLog.bigWarning("Invalid fingerprint detected for the Refined Storage jar file! The file " + e.getSource().getName() + " may have been tampered with. This version will NOT be supported!");
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a node in the network.
|
||||
@@ -87,4 +88,15 @@ public interface INetworkNode {
|
||||
* @return the id of this node as specified in {@link INetworkNodeRegistry}
|
||||
*/
|
||||
ResourceLocation getId();
|
||||
|
||||
/**
|
||||
* @param owner the owner
|
||||
*/
|
||||
void setOwner(@Nullable UUID owner);
|
||||
|
||||
/**
|
||||
* @return the owner
|
||||
*/
|
||||
@Nullable
|
||||
UUID getOwner();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.raoulvdberge.refinedstorage.api.network.INetworkNodeGraphListener;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNodeVisitor;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
@@ -18,8 +18,6 @@ import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY;
|
||||
|
||||
public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
private INetwork network;
|
||||
private Set<INetworkNode> nodes = Sets.newConcurrentHashSet();
|
||||
@@ -39,15 +37,9 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
|
||||
Operator operator = new Operator(action);
|
||||
|
||||
TileEntity tile = world.getTileEntity(origin);
|
||||
if (tile != null) {
|
||||
tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, null).ifPresent(proxy -> {
|
||||
INetworkNode node = proxy.getNode();
|
||||
|
||||
if (node instanceof INetworkNodeVisitor) {
|
||||
((INetworkNodeVisitor) node).visit(operator);
|
||||
}
|
||||
});
|
||||
INetworkNode originNode = NetworkUtils.getNodeFromTile(world.getTileEntity(origin));
|
||||
if (originNode instanceof INetworkNodeVisitor) {
|
||||
((INetworkNodeVisitor) originNode).visit(operator);
|
||||
}
|
||||
|
||||
Visitor currentVisitor;
|
||||
@@ -134,31 +126,29 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
public void apply(World world, BlockPos pos, @Nullable Direction side) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile != null) {
|
||||
tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, side).ifPresent(otherNodeProxy -> {
|
||||
INetworkNode otherNode = otherNodeProxy.getNode();
|
||||
INetworkNode otherNode = NetworkUtils.getNodeFromTile(tile);
|
||||
|
||||
if (otherNode.getNetwork() != null && !otherNode.getNetwork().equals(network)) {
|
||||
if (action == Action.PERFORM) {
|
||||
dropConflictingBlock(world, tile.getPos());
|
||||
}
|
||||
|
||||
return;
|
||||
if (otherNode != null) {
|
||||
if (otherNode.getNetwork() != null && !otherNode.getNetwork().equals(network)) {
|
||||
if (action == Action.PERFORM) {
|
||||
dropConflictingBlock(world, pos);
|
||||
}
|
||||
|
||||
if (foundNodes.add(otherNode)) {
|
||||
if (!nodes.contains(otherNode)) {
|
||||
// We can't let the node connect immediately
|
||||
// We can only let the node connect AFTER the nodes list has changed in the graph
|
||||
// This is so that storage nodes can refresh the item/fluid cache, and the item/fluid cache will notice it then (otherwise not)
|
||||
newNodes.add(otherNode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
previousNodes.remove(otherNode);
|
||||
|
||||
toCheck.add(new Visitor(otherNode, world, pos, side, tile));
|
||||
if (foundNodes.add(otherNode)) {
|
||||
if (!nodes.contains(otherNode)) {
|
||||
// We can't let the node connect immediately
|
||||
// We can only let the node connect AFTER the nodes list has changed in the graph
|
||||
// This is so that storage nodes can refresh the item/fluid cache, and the item/fluid cache will notice it then (otherwise not)
|
||||
newNodes.add(otherNode);
|
||||
}
|
||||
});
|
||||
|
||||
previousNodes.remove(otherNode);
|
||||
|
||||
toCheck.add(new Visitor(otherNode, world, pos, side, tile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,13 +180,11 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
} else {
|
||||
for (Direction checkSide : Direction.values()) {
|
||||
if (checkSide != side) { // Avoid going backward
|
||||
tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, checkSide).ifPresent(nodeOnSideProxy -> {
|
||||
INetworkNode nodeOnSide = nodeOnSideProxy.getNode();
|
||||
INetworkNode nodeOnSide = NetworkUtils.getNodeFromTile(tile);
|
||||
|
||||
if (nodeOnSide == node) {
|
||||
operator.apply(world, pos.offset(checkSide), checkSide.getOpposite());
|
||||
}
|
||||
});
|
||||
if (nodeOnSide == node) {
|
||||
operator.apply(world, pos.offset(checkSide), checkSide.getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
@@ -39,51 +36,20 @@ public class NetworkNodeListener {
|
||||
if (!e.getWorld().isRemote() && e.getEntity() instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) e.getEntity();
|
||||
|
||||
TileEntity placed = e.getWorld().getTileEntity(e.getPos());
|
||||
INetworkNode placed = NetworkUtils.getNodeFromTile(e.getWorld().getTileEntity(e.getPos()));
|
||||
|
||||
if (placed != null) {
|
||||
placed.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY).ifPresent(proxy -> {
|
||||
discoverNode(e.getWorld(), e.getPos());
|
||||
discoverNode(e.getWorld(), e.getPos());
|
||||
|
||||
if (proxy.getNode() instanceof NetworkNode) {
|
||||
((NetworkNode) proxy.getNode()).setOwner(player.getGameProfile().getId());
|
||||
}
|
||||
placed.setOwner(player.getGameProfile().getId());
|
||||
|
||||
for (Direction facing : Direction.values()) {
|
||||
TileEntity side = e.getWorld().getTileEntity(e.getBlockSnapshot().getPos().offset(facing));
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(e.getWorld().getTileEntity(e.getBlockSnapshot().getPos().offset(facing)));
|
||||
|
||||
if (side != null) {
|
||||
INetworkNodeProxy neighborProxy = side.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite()).orElse(null);
|
||||
if (node != null && node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, player)) {
|
||||
WorldUtils.sendNoPermissionMessage(player);
|
||||
|
||||
if (neighborProxy != null) {
|
||||
INetworkNode node = neighborProxy.getNode();
|
||||
|
||||
if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, player)) {
|
||||
WorldUtils.sendNoPermissionMessage(player);
|
||||
|
||||
e.setCanceled(true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void discoverNode(IWorld world, BlockPos pos) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
TileEntity tile = world.getTileEntity(pos.offset(facing));
|
||||
|
||||
if (tile != null) {
|
||||
INetworkNodeProxy proxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite()).orElse(null);
|
||||
if (proxy != null) {
|
||||
INetworkNode node = proxy.getNode();
|
||||
|
||||
if (node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().getWorld(), node.getNetwork().getPosition());
|
||||
e.setCanceled(true);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -92,21 +58,27 @@ public class NetworkNodeListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void discoverNode(IWorld world, BlockPos pos) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(world.getTileEntity(pos.offset(facing)));
|
||||
|
||||
if (node != null && node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().getWorld(), node.getNetwork().getPosition());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockBreak(BlockEvent.BreakEvent e) {
|
||||
if (!e.getWorld().isRemote()) {
|
||||
TileEntity tile = e.getWorld().getTileEntity(e.getPos());
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(e.getWorld().getTileEntity(e.getPos()));
|
||||
|
||||
if (tile != null) {
|
||||
tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY).ifPresent(nodeProxy -> {
|
||||
INetworkNode node = nodeProxy.getNode();
|
||||
if (node != null && node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) {
|
||||
WorldUtils.sendNoPermissionMessage(e.getPlayer());
|
||||
|
||||
if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) {
|
||||
WorldUtils.sendNoPermissionMessage(e.getPlayer());
|
||||
|
||||
e.setCanceled(true);
|
||||
}
|
||||
});
|
||||
e.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,12 +251,14 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(@Nullable UUID owner) {
|
||||
this.owner = owner;
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public UUID getOwner() {
|
||||
return owner;
|
||||
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class RootNetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
private final INetwork network;
|
||||
@@ -31,6 +33,17 @@ public class RootNetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(@Nullable UUID owner) {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public UUID getOwner() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 0;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage.externalstorage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.tile.InterfaceTile;
|
||||
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -18,9 +18,9 @@ import java.util.function.Supplier;
|
||||
public class ItemExternalStorageProvider implements IExternalStorageProvider<ItemStack> {
|
||||
@Override
|
||||
public boolean canProvide(TileEntity tile, Direction direction) {
|
||||
INetworkNodeProxy nodeProxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, direction.getOpposite()).orElse(null);
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(tile);
|
||||
|
||||
if (nodeProxy != null && nodeProxy.getNode() instanceof IStorageProvider) {
|
||||
if (node instanceof IStorageProvider) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@ package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.render.Styles;
|
||||
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -12,7 +11,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -72,19 +70,7 @@ public abstract class NetworkItem extends EnergyItem implements INetworkItemProv
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity node = nodeWorld.getTileEntity(new BlockPos(getX(stack), getY(stack), getZ(stack)));
|
||||
if (node == null) {
|
||||
onError.accept(notFound);
|
||||
return;
|
||||
}
|
||||
|
||||
INetworkNodeProxy proxy = node.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY).orElse(null);
|
||||
if (proxy == null) {
|
||||
onError.accept(notFound);
|
||||
return;
|
||||
}
|
||||
|
||||
INetwork network = proxy.getNode().getNetwork();
|
||||
INetwork network = NetworkUtils.getNetworkFromNode(NetworkUtils.getNodeFromTile(nodeWorld.getTileEntity(new BlockPos(getX(stack), getY(stack), getZ(stack)))));
|
||||
if (network == null) {
|
||||
onError.accept(notFound);
|
||||
return;
|
||||
@@ -106,30 +92,22 @@ public abstract class NetworkItem extends EnergyItem implements INetworkItemProv
|
||||
public ActionResultType onItemUse(ItemUseContext ctx) {
|
||||
ItemStack stack = ctx.getPlayer().getHeldItem(ctx.getHand());
|
||||
|
||||
TileEntity tile = ctx.getWorld().getTileEntity(ctx.getPos());
|
||||
if (tile != null) {
|
||||
INetworkNodeProxy proxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY).orElse(null);
|
||||
INetwork network = NetworkUtils.getNetworkFromNode(NetworkUtils.getNodeFromTile(ctx.getWorld().getTileEntity(ctx.getPos())));
|
||||
if (network != null) {
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
if (proxy != null) {
|
||||
INetwork network = proxy.getNode().getNetwork();
|
||||
|
||||
if (network != null) {
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
if (tag == null) {
|
||||
tag = new CompoundNBT();
|
||||
}
|
||||
|
||||
tag.putInt(NBT_NODE_X, network.getPosition().getX());
|
||||
tag.putInt(NBT_NODE_Y, network.getPosition().getY());
|
||||
tag.putInt(NBT_NODE_Z, network.getPosition().getZ());
|
||||
tag.putString(NBT_DIMENSION, DimensionType.getKey(ctx.getWorld().getDimension().getType()).toString());
|
||||
|
||||
stack.setTag(tag);
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
if (tag == null) {
|
||||
tag = new CompoundNBT();
|
||||
}
|
||||
|
||||
tag.putInt(NBT_NODE_X, network.getPosition().getX());
|
||||
tag.putInt(NBT_NODE_Y, network.getPosition().getY());
|
||||
tag.putInt(NBT_NODE_Z, network.getPosition().getZ());
|
||||
tag.putString(NBT_DIMENSION, DimensionType.getKey(ctx.getWorld().getDimension().getType()).toString());
|
||||
|
||||
stack.setTag(tag);
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.PASS;
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Rotation;
|
||||
|
||||
@@ -29,18 +28,11 @@ public class WrenchItem extends Item {
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
TileEntity tile = ctx.getWorld().getTileEntity(ctx.getPos());
|
||||
INetwork network = NetworkUtils.getNetworkFromNode(NetworkUtils.getNodeFromTile(ctx.getWorld().getTileEntity(ctx.getPos())));
|
||||
if (network != null && !network.getSecurityManager().hasPermission(Permission.BUILD, ctx.getPlayer())) {
|
||||
WorldUtils.sendNoPermissionMessage(ctx.getPlayer());
|
||||
|
||||
if (tile != null) {
|
||||
INetworkNodeProxy proxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, ctx.getFace().getOpposite()).orElse(null);
|
||||
|
||||
if (proxy != null &&
|
||||
proxy.getNode().getNetwork() != null &&
|
||||
!proxy.getNode().getNetwork().getSecurityManager().hasPermission(Permission.BUILD, ctx.getPlayer())) {
|
||||
WorldUtils.sendNoPermissionMessage(ctx.getPlayer());
|
||||
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
BlockState state = ctx.getWorld().getBlockState(ctx.getPos());
|
||||
|
||||
@@ -85,7 +85,7 @@ public class InputConfigurationScreen extends BaseScreen {
|
||||
ItemListLine line = new ItemListLine();
|
||||
|
||||
for (Item item : ItemTags.getCollection().get(owningTag).getAllElements()) {
|
||||
if (itemCount > 0 && itemCount % 7 == 0) {
|
||||
if (itemCount > 0 && itemCount % 8 == 0) {
|
||||
lines.add(line);
|
||||
line = new ItemListLine();
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class InputConfigurationScreen extends BaseScreen {
|
||||
FluidListLine line = new FluidListLine();
|
||||
|
||||
for (Fluid fluid : FluidTags.getCollection().get(owningTag).getAllElements()) {
|
||||
if (fluidCount > 0 && fluidCount % 7 == 0) {
|
||||
if (fluidCount > 0 && fluidCount % 8 == 0) {
|
||||
lines.add(line);
|
||||
line = new FluidListLine();
|
||||
}
|
||||
@@ -337,7 +337,7 @@ public class InputConfigurationScreen extends BaseScreen {
|
||||
for (ItemStack item : items) {
|
||||
renderItem(x + 3, y, item);
|
||||
|
||||
x += 18;
|
||||
x += 17;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ public class InputConfigurationScreen extends BaseScreen {
|
||||
InputConfigurationScreen.this.renderTooltip(item, mx, my, RenderUtils.getTooltipFromItem(item));
|
||||
}
|
||||
|
||||
x += 18;
|
||||
x += 17;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,7 +367,7 @@ public class InputConfigurationScreen extends BaseScreen {
|
||||
for (FluidStack fluid : fluids) {
|
||||
FluidRenderer.INSTANCE.render(x + 3, y, fluid);
|
||||
|
||||
x += 18;
|
||||
x += 17;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ public class InputConfigurationScreen extends BaseScreen {
|
||||
InputConfigurationScreen.this.renderTooltip(mx, my, fluid.getDisplayName().getFormattedText());
|
||||
}
|
||||
|
||||
x += 18;
|
||||
x += 17;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.Network;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.RootNetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.block.ControllerBlock;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
||||
@@ -29,8 +30,6 @@ import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY;
|
||||
|
||||
public class ControllerTile extends BaseTile implements INetworkNodeProxy<RootNetworkNode>, IRedstoneConfigurable {
|
||||
public static final TileDataParameter<Integer, ControllerTile> REDSTONE_MODE = RedstoneMode.createParameter();
|
||||
public static final TileDataParameter<Integer, ControllerTile> ENERGY_USAGE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNetwork().getEnergyUsage());
|
||||
@@ -156,7 +155,7 @@ public class ControllerTile extends BaseTile implements INetworkNodeProxy<RootNe
|
||||
return energyProxyCap.cast();
|
||||
}
|
||||
|
||||
if (cap == NETWORK_NODE_PROXY_CAPABILITY) {
|
||||
if (cap == NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY) {
|
||||
return networkNodeProxyCap.cast();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,16 +4,14 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingManager;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.item.WirelessCraftingMonitorItem;
|
||||
import com.raoulvdberge.refinedstorage.network.craftingmonitor.WirelessCraftingMonitorSettingsUpdateMessage;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
@@ -100,15 +98,7 @@ public class WirelessCraftingMonitor implements ICraftingMonitor {
|
||||
World world = DimensionManager.getWorld(server, nodeDimension, true, true);
|
||||
|
||||
if (world != null) {
|
||||
TileEntity tile = world.getTileEntity(nodePos);
|
||||
|
||||
if (tile != null) {
|
||||
INetworkNodeProxy proxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY).orElse(null);
|
||||
|
||||
if (proxy != null) {
|
||||
return proxy.getNode().getNetwork();
|
||||
}
|
||||
}
|
||||
return NetworkUtils.getNetworkFromNode(NetworkUtils.getNodeFromTile(world.getTileEntity(nodePos)));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -5,17 +5,16 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.*;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener.FluidGridStorageCacheListener;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.inventory.item.FilterItemHandler;
|
||||
import com.raoulvdberge.refinedstorage.item.WirelessFluidGridItem;
|
||||
import com.raoulvdberge.refinedstorage.network.grid.WirelessFluidGridSettingsUpdateMessage;
|
||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||
import com.raoulvdberge.refinedstorage.screen.grid.GridScreen;
|
||||
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
@@ -24,7 +23,6 @@ import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
@@ -95,15 +93,7 @@ public class WirelessFluidGrid implements INetworkAwareGrid {
|
||||
World world = DimensionManager.getWorld(server, nodeDimension, true, true);
|
||||
|
||||
if (world != null) {
|
||||
TileEntity tile = world.getTileEntity(nodePos);
|
||||
|
||||
if (tile != null) {
|
||||
INetworkNodeProxy proxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY).orElse(null);
|
||||
|
||||
if (proxy != null) {
|
||||
return proxy.getNode().getNetwork();
|
||||
}
|
||||
}
|
||||
return NetworkUtils.getNetworkFromNode(NetworkUtils.getNodeFromTile(world.getTileEntity(nodePos)));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -5,17 +5,16 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.*;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCacheListener;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.listener.ItemGridStorageCacheListener;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.inventory.item.FilterItemHandler;
|
||||
import com.raoulvdberge.refinedstorage.item.WirelessGridItem;
|
||||
import com.raoulvdberge.refinedstorage.network.grid.WirelessGridSettingsUpdateMessage;
|
||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||
import com.raoulvdberge.refinedstorage.screen.grid.GridScreen;
|
||||
import com.raoulvdberge.refinedstorage.util.NetworkUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
@@ -24,7 +23,6 @@ import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
@@ -97,16 +95,7 @@ public class WirelessGrid implements INetworkAwareGrid {
|
||||
World world = DimensionManager.getWorld(server, nodeDimension, true, true);
|
||||
|
||||
if (world != null) {
|
||||
TileEntity tile = world.getTileEntity(nodePos);
|
||||
|
||||
// TODO Create helper to get INetworkNodeProxy of tile
|
||||
if (tile != null) {
|
||||
INetworkNodeProxy proxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY).orElse(null);
|
||||
|
||||
if (proxy != null) {
|
||||
return proxy.getNode().getNetwork();
|
||||
}
|
||||
}
|
||||
return NetworkUtils.getNetworkFromNode(NetworkUtils.getNodeFromTile(world.getTileEntity(nodePos)));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.util;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
@@ -10,7 +11,31 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class NetworkUtils {
|
||||
@Nullable
|
||||
public static INetworkNode getNodeFromTile(@Nullable TileEntity tile) {
|
||||
if (tile != null) {
|
||||
INetworkNodeProxy proxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY).orElse(null);
|
||||
|
||||
if (proxy != null) {
|
||||
return proxy.getNode();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static INetwork getNetworkFromNode(@Nullable INetworkNode node) {
|
||||
if (node != null) {
|
||||
return node.getNetwork();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean attemptModify(World world, BlockPos pos, Direction facing, PlayerEntity player, Runnable action) {
|
||||
return attempt(world, pos, facing, player, action, Permission.MODIFY);
|
||||
}
|
||||
@@ -20,22 +45,14 @@ public class NetworkUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
INetwork network = getNetworkFromNode(getNodeFromTile(world.getTileEntity(pos)));
|
||||
|
||||
if (tile != null) {
|
||||
INetworkNodeProxy proxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, facing).orElse(null);
|
||||
if (network != null) {
|
||||
for (Permission permission : permissionsRequired) {
|
||||
if (!network.getSecurityManager().hasPermission(permission, player)) {
|
||||
WorldUtils.sendNoPermissionMessage(player);
|
||||
|
||||
if (proxy != null) {
|
||||
INetworkNode node = proxy.getNode();
|
||||
|
||||
if (node.getNetwork() != null) {
|
||||
for (Permission permission : permissionsRequired) {
|
||||
if (!node.getNetwork().getSecurityManager().hasPermission(permission, player)) {
|
||||
WorldUtils.sendNoPermissionMessage(player);
|
||||
|
||||
return true; // Avoid placing blocks
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user