2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 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-07-23 01:35:44 +02:00
|
|
|
index c2f8b3eecdb9492b800086a81ef5c0c4c34ff8b7..08d9268c6b6883757d6a6f008dda846d34d63dca 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-06-26 18:20:03 +02:00
|
|
|
@@ -285,6 +285,22 @@ 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;
|
|
|
|
+ }
|
2020-06-26 08:29:44 +02:00
|
|
|
+
|
|
|
|
+ public Chunk getChunkIfLoaded(int x, int z) {
|
|
|
|
+ return ((WorldServer) this).getChunkProvider().getChunkAtIfLoadedImmediately(x, z);
|
|
|
|
+ }
|
|
|
|
+ public final Chunk getChunkIfLoaded(BlockPosition blockposition) {
|
|
|
|
+ return ((WorldServer) this).getChunkProvider().getChunkAtIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
2019-12-13 02:18:18 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 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-06-25 13:00:35 +02:00
|
|
|
index d039e715624d33fc3ec9e87d5ad992415e7dc6b9..d5c0d394feaf8bb991245dbdcc6252cf45eac13d 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
|
2020-06-25 13:00:35 +02:00
|
|
|
@@ -21,6 +21,7 @@ public class WorldBorder {
|
2019-05-06 01:24:37 +02:00
|
|
|
|
|
|
|
public WorldBorder() {}
|
|
|
|
|
|
|
|
+ public final boolean isInBounds(BlockPosition blockposition) { return this.a(blockposition); } // Paper - OBFHELPER
|
|
|
|
public boolean a(BlockPosition blockposition) {
|
2020-06-25 13:00:35 +02:00
|
|
|
return (double) (blockposition.getX() + 1) > this.e() && (double) blockposition.getX() < this.g() && (double) (blockposition.getZ() + 1) > this.f() && (double) blockposition.getZ() < this.h();
|
2019-05-06 01:24:37 +02:00
|
|
|
}
|
2020-06-26 08:29:44 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-07-23 01:35:44 +02:00
|
|
|
index 89e960ef91f588f16ca3efde5518e731d6bc29cb..45921bbb8241901743b08aa94fb9700293a724c2 100644
|
2020-06-26 08:29:44 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
@@ -83,7 +83,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
|
|
public final Convertable.ConversionSession convertable;
|
|
|
|
public final UUID uuid;
|
|
|
|
|
|
|
|
- public Chunk getChunkIfLoaded(int x, int z) {
|
|
|
|
+ @Override public Chunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
|
|
|
|
return this.chunkProvider.getChunkAt(x, z, false);
|
|
|
|
}
|
|
|
|
|