2020-03-10 12:01:15 +01:00
|
|
|
From 02692be9ad22aecba400483042971666046d8af9 Mon Sep 17 00:00:00 2001
|
2018-07-15 03:53:17 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Fri, 18 Mar 2016 20:16:03 -0400
|
|
|
|
Subject: [PATCH] Add World Util Methods
|
|
|
|
|
|
|
|
Methods that can be used for other patches to help improve logic.
|
|
|
|
|
2019-12-13 02:18:18 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2020-03-10 12:01:15 +01:00
|
|
|
index 6e68c013a..c2039d0e4 100644
|
2019-12-13 02:18:18 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2020-03-10 12:01:15 +01:00
|
|
|
@@ -222,6 +222,18 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2019-12-13 02:18:18 +01:00
|
|
|
|
|
|
|
return chunk == null ? null : chunk.getFluid(blockposition);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public boolean isLoadedAndInBounds(BlockPosition blockposition) {
|
|
|
|
+ return getWorldBorder().isInBounds(blockposition) && getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) != null;
|
|
|
|
+ }
|
|
|
|
+ public Chunk getChunkIfLoaded(BlockPosition blockposition) {
|
|
|
|
+ return getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // reduces need to do isLoaded before getType
|
|
|
|
+ public IBlockData getTypeIfLoadedAndInBounds(BlockPosition blockposition) {
|
|
|
|
+ return getWorldBorder().isInBounds(blockposition) ? getTypeIfLoaded(blockposition) : null;
|
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
|
|
|
|
@Override
|
2019-05-06 01:24:37 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldBorder.java b/src/main/java/net/minecraft/server/WorldBorder.java
|
2020-03-10 12:01:15 +01:00
|
|
|
index 020e5c171..4ee13ac45 100644
|
2019-05-06 01:24:37 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldBorder.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldBorder.java
|
|
|
|
@@ -19,6 +19,7 @@ public class WorldBorder {
|
|
|
|
|
|
|
|
public WorldBorder() {}
|
|
|
|
|
|
|
|
+ public final boolean isInBounds(BlockPosition blockposition) { return this.a(blockposition); } // Paper - OBFHELPER
|
|
|
|
public boolean a(BlockPosition blockposition) {
|
|
|
|
return (double) (blockposition.getX() + 1) > this.c() && (double) blockposition.getX() < this.e() && (double) (blockposition.getZ() + 1) > this.d() && (double) blockposition.getZ() < this.f();
|
|
|
|
}
|
2018-07-15 03:53:17 +02:00
|
|
|
--
|
2020-01-28 20:43:57 +01:00
|
|
|
2.25.0
|
2018-07-15 03:53:17 +02:00
|
|
|
|