From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 2 Dec 2016 00:11:43 -0500 Subject: [PATCH] Optimize Level.hasChunkAt(BlockPosition)Z Reduce method invocations for World.isLoaded(BlockPosition)Z diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java index 57856f334370da394e9119fb1f8c7fb9c4916aa3..b2b0dea688df220a06abd458ac47aae3d67a7797 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -342,6 +342,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return chunk == null ? null : chunk.getFluidState(blockposition); } + @Override + public final boolean hasChunkAt(BlockPos pos) { + return getChunkIfLoaded(pos.getX() >> 4, pos.getZ() >> 4) != null; // Paper - Perf: Optimize Level.hasChunkAt(BlockPosition)Z + } + public final boolean isLoadedAndInBounds(BlockPos blockposition) { // Paper - final for inline return getWorldBorder().isWithinBounds(blockposition) && getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) != null; }