Fixed bug where players couldn't place regular blocks next to secured networks, fixes #1332

This commit is contained in:
raoulvdberge
2017-06-29 11:03:20 +02:00
parent 09bf16bebf
commit 7800184744
2 changed files with 18 additions and 13 deletions

View File

@@ -2,6 +2,7 @@
### 1.5.6 ### 1.5.6
- Updated Forge to stable 2387 (raoulvdberge) - Updated Forge to stable 2387 (raoulvdberge)
- Fixed bug where players couldn't place regular blocks next to secured networks (raoulvdberge)
- Removed Processing Pattern Encoder, that functionality is now available in the Pattern Grid (raoulvdberge) - Removed Processing Pattern Encoder, that functionality is now available in the Pattern Grid (raoulvdberge)
### 1.5.5 ### 1.5.5

View File

@@ -16,34 +16,38 @@ public class NetworkNodeListener {
@SubscribeEvent @SubscribeEvent
public void onWorldTick(TickEvent.WorldTickEvent e) { public void onWorldTick(TickEvent.WorldTickEvent e) {
if (!e.world.isRemote) { if (!e.world.isRemote) {
e.world.profiler.startSection("network node ticking");
if (e.phase == TickEvent.Phase.END) { if (e.phase == TickEvent.Phase.END) {
e.world.profiler.startSection("network node ticking");
for (INetworkNode node : API.instance().getNetworkNodeManager(e.world).all()) { for (INetworkNode node : API.instance().getNetworkNodeManager(e.world).all()) {
node.update(); node.update();
} }
}
e.world.profiler.endSection(); e.world.profiler.endSection();
}
} }
} }
@SubscribeEvent @SubscribeEvent
public void onBlockPlace(BlockEvent.PlaceEvent e) { public void onBlockPlace(BlockEvent.PlaceEvent e) {
if (!e.getWorld().isRemote) { if (!e.getWorld().isRemote) {
for (EnumFacing facing : EnumFacing.VALUES) { TileEntity placed = e.getWorld().getTileEntity(e.getPos());
TileEntity tile = e.getWorld().getTileEntity(e.getBlockSnapshot().getPos().offset(facing));
if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite())) { if (placed != null && placed.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null)) {
INetworkNodeProxy nodeProxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite()); for (EnumFacing facing : EnumFacing.VALUES) {
INetworkNode node = nodeProxy.getNode(); TileEntity side = e.getWorld().getTileEntity(e.getBlockSnapshot().getPos().offset(facing));
if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) { if (side != null && side.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite())) {
RSUtils.sendNoPermissionMessage(e.getPlayer()); INetworkNodeProxy nodeProxy = side.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite());
INetworkNode node = nodeProxy.getNode();
e.setCanceled(true); if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) {
RSUtils.sendNoPermissionMessage(e.getPlayer());
return; e.setCanceled(true);
return;
}
} }
} }
} }