mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-19 17:15:23 +01:00
10502558e9
2 people had issues where some plugin is doing some reallly insane NMS hackery that created invalid worlds, which caused some errors... Really don't understand what in the world they did, but putting in a dumb guard that shouldn't even be necessary to just not send the sound effect rather than erroring.
43 lines
2.1 KiB
Diff
43 lines
2.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
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.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 6e7d3573ed6f58a9c5f29c8b1b49746f13e21dc7..a721ad8addfd5a47608e304b372762d3ca89fa65 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -223,6 +223,18 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
|
|
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
|
|
diff --git a/src/main/java/net/minecraft/server/WorldBorder.java b/src/main/java/net/minecraft/server/WorldBorder.java
|
|
index 3db276f176301ebf15d5a2ba44d0edb5c7ec6097..73730fe25c84a867b8d95525c9d76d60a5797396 100644
|
|
--- 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();
|
|
}
|