Optimize SectionLightStorage#cancelSectionUpdates loop
This commit is contained in:
parent
1ef8b75cbb
commit
33307fb1bd
5 changed files with 82 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
--- a/net/minecraft/world/lighting/BlockLightEngine.java
|
||||
+++ b/net/minecraft/world/lighting/BlockLightEngine.java
|
||||
@@ -4,6 +4,7 @@
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
+import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.SectionPos;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
@@ -117,4 +118,11 @@
|
||||
this.field_215627_c.func_215532_c();
|
||||
this.func_215469_a(Long.MAX_VALUE, p_215623_1_.func_218275_a(), 15 - p_215623_2_, true);
|
||||
}
|
||||
+
|
||||
+ // FORGE START
|
||||
+
|
||||
+ @Override
|
||||
+ public int queuedUpdateSize() {
|
||||
+ return field_215627_c.queuedUpdateSize();
|
||||
+ }
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
--- a/net/minecraft/world/lighting/LevelBasedGraph.java
|
||||
+++ b/net/minecraft/world/lighting/LevelBasedGraph.java
|
||||
@@ -210,4 +210,18 @@
|
||||
protected abstract void func_215476_a(long p_215476_1_, int p_215476_3_);
|
||||
|
||||
protected abstract int func_215480_b(long p_215480_1_, long p_215480_3_, int p_215480_5_);
|
||||
+
|
||||
+ // FORGE START
|
||||
+
|
||||
+ protected int queuedUpdateSize() {
|
||||
+ return field_215488_c.size();
|
||||
+ }
|
||||
+
|
||||
+ public void bulkCancel(java.util.function.LongPredicate pred) {
|
||||
+ ((Long2ByteOpenHashMap)field_215488_c).keySet().forEach((long l) -> {
|
||||
+ if (pred.test(l)) {
|
||||
+ func_215479_e(l);
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
--- a/net/minecraft/world/lighting/LightEngine.java
|
||||
+++ b/net/minecraft/world/lighting/LightEngine.java
|
||||
@@ -216,4 +216,8 @@
|
||||
long i = SectionPos.func_218169_f(SectionPos.func_218166_b(p_223129_1_.field_77276_a, 0, p_223129_1_.field_77275_b));
|
||||
this.field_215627_c.func_223113_c(i, p_223129_2_);
|
||||
}
|
||||
+
|
||||
+ // FORGE START
|
||||
+
|
||||
+ public abstract int queuedUpdateSize();
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
--- a/net/minecraft/world/lighting/SectionLightStorage.java
|
||||
+++ b/net/minecraft/world/lighting/SectionLightStorage.java
|
||||
@@ -154,6 +154,11 @@
|
||||
int j = SectionPos.func_218142_c(SectionPos.func_218144_c(p_215528_2_));
|
||||
int k = SectionPos.func_218142_c(SectionPos.func_218153_d(p_215528_2_));
|
||||
|
||||
+ // FORGE: Optimize loop when lighting update count is lower than section size
|
||||
+ if (p_215528_1_.queuedUpdateSize() < 16 * 16 * 16) {
|
||||
+ p_215528_1_.bulkCancel(l -> SectionPos.func_218169_f(l) == p_215528_2_);
|
||||
+ return;
|
||||
+ }
|
||||
for(int l = 0; l < 16; ++l) {
|
||||
for(int i1 = 0; i1 < 16; ++i1) {
|
||||
for(int j1 = 0; j1 < 16; ++j1) {
|
|
@ -0,0 +1,14 @@
|
|||
--- a/net/minecraft/world/lighting/SkyLightEngine.java
|
||||
+++ b/net/minecraft/world/lighting/SkyLightEngine.java
|
||||
@@ -229,4 +229,11 @@
|
||||
public String func_215614_b(long p_215614_1_) {
|
||||
return super.func_215614_b(p_215614_1_) + (this.field_215627_c.func_215549_m(p_215614_1_) ? "*" : "");
|
||||
}
|
||||
+
|
||||
+ // FORGE START
|
||||
+
|
||||
+ @Override
|
||||
+ public int queuedUpdateSize() {
|
||||
+ return 0;
|
||||
+ }
|
||||
}
|
Loading…
Reference in a new issue