Skip to content

Commit

Permalink
Update AbstractItemNetwork.java
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchampions committed Sep 1, 2024
1 parent f3a6003 commit 8712cd5
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javax.annotation.Nullable;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
Expand Down Expand Up @@ -42,16 +43,18 @@ protected AbstractItemNetwork(Location regulator) {
protected Optional<Block> getAttachedBlock(Location l) {
if (l.getWorld().isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4)) {
Block block = l.getBlock();
BlockFace cached = connectorCache.get(l);
if (block.getType() == Material.PLAYER_WALL_HEAD) {
BlockFace cached = connectorCache.get(l);

if (cached != null) {
return Optional.of(block.getRelative(cached));
}
if (cached != null) {
return Optional.of(block.getRelative(cached));
}

BlockFace face =
((Directional) block.getBlockData()).getFacing().getOppositeFace();
connectorCache.put(l, face);
return Optional.of(block.getRelative(face));
BlockFace face =
((Directional) block.getBlockData()).getFacing().getOppositeFace();
connectorCache.put(l, face);
return Optional.of(block.getRelative(face));
}
}

return Optional.empty();
Expand Down

0 comments on commit 8712cd5

Please sign in to comment.