geforkt von Mirrors/Paper
34731dd04e
Instead of overriding add within the queue, never add runnables to the queue if the light queue is disabled. This change is made to make timings reports and stacktraces less confusing for administrators, who prior to this change, would have seen the lighting queue referenced in both, regardless of whether or not it was enabled. This change should not affect performance, nor is it made with the intent to.
124 Zeilen
5.2 KiB
Diff
124 Zeilen
5.2 KiB
Diff
From 722ea2a8bface335c87958b7c9337c9e96000c81 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/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
|
index cc4a9dbe..84a88056 100644
|
|
--- a/src/main/java/net/minecraft/server/Chunk.java
|
|
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
|
@@ -581,6 +581,7 @@ public class Chunk {
|
|
|
|
}
|
|
|
|
+ public final int getLightSubtracted(BlockPosition blockposition, int i) { return this.a(blockposition, i); } // Paper - OBFHELPER
|
|
public int a(BlockPosition blockposition, int i) {
|
|
int j = blockposition.getX() & 15;
|
|
int k = blockposition.getY();
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 6be9c181..9339bf83 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -77,7 +77,7 @@ public abstract class World implements IBlockAccess {
|
|
public final List<Entity> j = Lists.newArrayList();
|
|
protected final IntHashMap<Entity> entitiesById = new IntHashMap();
|
|
private final long K = 16777215L;
|
|
- private int L;
|
|
+ private int L; private int getSkylightSubtracted() { return this.L; } // Paper - OBFHELPER
|
|
protected int l = (new Random()).nextInt();
|
|
protected final int m = 1013904223;
|
|
protected float n;
|
|
@@ -156,6 +156,12 @@ public abstract class World implements IBlockAccess {
|
|
return (CraftServer) Bukkit.getServer();
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public Chunk getChunkIfLoaded(BlockPosition blockposition) {
|
|
+ return this.chunkProvider.getLoadedChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public Chunk getChunkIfLoaded(int x, int z) {
|
|
return ((ChunkProviderServer) this.chunkProvider).getChunkIfLoaded(x, z);
|
|
}
|
|
@@ -686,10 +692,46 @@ public abstract class World implements IBlockAccess {
|
|
}
|
|
}
|
|
|
|
+ // Paper start - test if meets light level, return faster
|
|
+ // logic copied from below
|
|
+ public boolean isLightLevel(BlockPosition blockposition, int level) {
|
|
+ if (isValidLocation(blockposition)) {
|
|
+ if (this.getType(blockposition).f()) {
|
|
+ if (this.c(blockposition.up(), false) >= level) {
|
|
+ return true;
|
|
+ }
|
|
+ if (this.c(blockposition.east(), false) >= level) {
|
|
+ return true;
|
|
+ }
|
|
+ if (this.c(blockposition.west(), false) >= level) {
|
|
+ return true;
|
|
+ }
|
|
+ if (this.c(blockposition.south(), false) >= level) {
|
|
+ return true;
|
|
+ }
|
|
+ if (this.c(blockposition.north(), false) >= level) {
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+ } else {
|
|
+ if (blockposition.getY() >= 256) {
|
|
+ blockposition = new BlockPosition(blockposition.getX(), 255, blockposition.getZ());
|
|
+ }
|
|
+
|
|
+ Chunk chunk = this.getChunkAtWorldCoords(blockposition);
|
|
+ return chunk.getLightSubtracted(blockposition, this.getSkylightSubtracted()) >= level;
|
|
+ }
|
|
+ } else {
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public int getLightLevel(BlockPosition blockposition) {
|
|
return this.c(blockposition, true);
|
|
}
|
|
|
|
+ public final int getLight(BlockPosition blockposition, boolean checkNeighbors) { return this.c(blockposition, checkNeighbors); } // Paper - OBFHELPER
|
|
public int c(BlockPosition blockposition, boolean flag) {
|
|
if (blockposition.getX() >= -30000000 && blockposition.getZ() >= -30000000 && blockposition.getX() < 30000000 && blockposition.getZ() < 30000000) {
|
|
if (flag && this.getType(blockposition).f()) {
|
|
@@ -805,6 +847,27 @@ public abstract class World implements IBlockAccess {
|
|
return this.worldProvider.o()[this.getLightLevel(blockposition)];
|
|
}
|
|
|
|
+ // Paper start - reduces need to do isLoaded before getType
|
|
+ public IBlockData getTypeIfLoaded(BlockPosition blockposition) {
|
|
+ // CraftBukkit start - tree generation
|
|
+ if (captureTreeGeneration) {
|
|
+ Iterator<BlockState> it = capturedBlockStates.iterator();
|
|
+ while (it.hasNext()) {
|
|
+ BlockState previous = it.next();
|
|
+ if (previous.getX() == blockposition.getX() && previous.getY() == blockposition.getY() && previous.getZ() == blockposition.getZ()) {
|
|
+ return CraftMagicNumbers.getBlock(previous.getTypeId()).fromLegacyData(previous.getRawData());
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+ Chunk chunk = this.getChunkIfLoaded(blockposition);
|
|
+ if (chunk != null) {
|
|
+ return this.isValidLocation(blockposition) ? chunk.getBlockData(blockposition) : Blocks.AIR.getBlockData();
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public IBlockData getType(BlockPosition blockposition) {
|
|
// CraftBukkit start - tree generation
|
|
if (captureTreeGeneration) {
|
|
--
|
|
2.15.1.windows.2
|
|
|