Skip to content

Instantly share code, notes, and snippets.

@aikar
Created June 7, 2020 05:01
Show Gist options
  • Save aikar/b70f65e0c55ca447ba750ef9d5640f78 to your computer and use it in GitHub Desktop.
Save aikar/b70f65e0c55ca447ba750ef9d5640f78 to your computer and use it in GitHub Desktop.
diff --git a/src/main/java/net/minecraft/server/IBlockData.java b/src/main/java/net/minecraft/server/IBlockData.java
index 2c128feb0f8..b39554faf23 100644
--- a/src/main/java/net/minecraft/server/IBlockData.java
+++ b/src/main/java/net/minecraft/server/IBlockData.java
@@ -72,7 +72,6 @@ public class IBlockData extends BlockDataAbstract<Block, IBlockData> implements
return this.c != null ? this.c.d : this.getBlock().b(this, iblockaccess, blockposition);
}
- public final int getBlockedLight() { return this.c.e; } // Paper - OBFHELPER - trimmed as its cached
public int b(IBlockAccess iblockaccess, BlockPosition blockposition) {
return this.c != null ? this.c.e : this.getBlock().l(this, iblockaccess, blockposition);
}
@@ -86,7 +85,7 @@ public class IBlockData extends BlockDataAbstract<Block, IBlockData> implements
return this.c == null || this.c.h;
}
- public final boolean shapeAffectsLight() { return this.e; } public final boolean g() { // Paper - OBFHELPER
+ public final boolean g() { // Paper
return this.e;
}
@@ -154,7 +153,7 @@ public class IBlockData extends BlockDataAbstract<Block, IBlockData> implements
return this.c != null ? this.c.c : this.getBlock().k(this, iblockaccess, blockposition);
}
- public final boolean canOcclude() { return canOcclude; } public final boolean o() { // Paper
+ public final boolean o() { // Paper
return canOcclude; // Paper
}
diff --git a/src/main/java/net/minecraft/server/LightEngineBlock.java b/src/main/java/net/minecraft/server/LightEngineBlock.java
index 73553e1b13f..86868bedc65 100644
--- a/src/main/java/net/minecraft/server/LightEngineBlock.java
+++ b/src/main/java/net/minecraft/server/LightEngineBlock.java
@@ -6,7 +6,7 @@ public final class LightEngineBlock extends LightEngineLayer<LightEngineStorageB
private static final EnumDirection[] e = EnumDirection.values();
private final BlockPosition.MutableBlockPosition f = new BlockPosition.MutableBlockPosition();
- // private final MutableInt mutableint = new MutableInt(); // Paper // No longer used
+ private final MutableInt mutableint = new MutableInt(); // Paper
public LightEngineBlock(ILightAccess ilightaccess) {
super(ilightaccess, EnumSkyBlock.BLOCK, new LightEngineStorageBlock(ilightaccess));
@@ -49,13 +49,12 @@ public final class LightEngineBlock extends LightEngineLayer<LightEngineStorageB
return 15;
} else {
//MutableInt mutableint = new MutableInt(); // Paper - share mutableint, single threaded
- IBlockData iblockdata = this.getBlockOptimized(jx, jy, jz); // Paper
- int blockedLight = iblockdata.getBlockedLight(); // Paper
+ IBlockData iblockdata = this.getBlockOptimized(jx, jy, jz, mutableint); // Paper
+ int blockedLight = mutableint.getValue(); // Paper
if (blockedLight >= 15) { // Paper
return 15;
} else {
- iblockdata = getBlockDataForOcclusion(iblockdata); // Paper
- IBlockData iblockdata1 = getBlockDataForOcclusion(this.getBlockOptimized(ix, iy, iz)); // Paper
+ IBlockData iblockdata1 = this.getBlockOptimized(ix, iy, iz); // Paper
VoxelShape voxelshape = this.a(iblockdata1, i, enumdirection);
VoxelShape voxelshape1 = this.a(iblockdata, j, enumdirection.opposite());
diff --git a/src/main/java/net/minecraft/server/LightEngineLayer.java b/src/main/java/net/minecraft/server/LightEngineLayer.java
index 36abed4e32d..5a6a21c9a13 100644
--- a/src/main/java/net/minecraft/server/LightEngineLayer.java
+++ b/src/main/java/net/minecraft/server/LightEngineLayer.java
@@ -11,7 +11,7 @@ public abstract class LightEngineLayer<M extends LightEngineStorageArray<M>, S e
protected final EnumSkyBlock b;
protected final S c;
private boolean f;
- protected final BlockPosition.MutableBlockPosition d = new BlockPosition.MutableBlockPosition();
+ protected final BlockPosition.MutableBlockPosition d = new BlockPosition.MutableBlockPosition(); protected final BlockPosition.MutableBlockPosition pos = d; // Paper
private final long[] g = new long[2];
private final IChunkAccess[] h = new IChunkAccess[2]; // Paper
@@ -100,22 +100,20 @@ public abstract class LightEngineLayer<M extends LightEngineStorageArray<M>, S e
mutableint.setValue(16);
return Blocks.BEDROCK.getBlockData();
} else {
+ this.pos.setValues(x, y, z);
IBlockData iblockdata = iblockaccess.getType(x, y, z);
- mutableint.setValue(iblockdata.getBlockedLight());
- return iblockdata;
+ mutableint.setValue(iblockdata.b(this.a.getWorld(), this.pos));
+ return iblockdata.o() && iblockdata.g() ? iblockdata : Blocks.AIR.getBlockData();
}
}
-
- protected IBlockData getBlockDataForOcclusion(IBlockData iblockdata) {
- return iblockdata.canOcclude() && iblockdata.shapeAffectsLight() ? iblockdata : Blocks.AIR.getBlockData();
- }
protected final IBlockData getBlockOptimized(int x, int y, int z) {
IChunkAccess iblockaccess = this.a(x >> 4, z >> 4);
if (iblockaccess == null) {
return Blocks.BEDROCK.getBlockData();
} else {
- return iblockaccess.getType(x, y, z);
+ IBlockData iblockdata = iblockaccess.getType(x, y, z);
+ return iblockdata.o() && iblockdata.g() ? iblockdata : Blocks.AIR.getBlockData();
}
}
// Paper end
diff --git a/src/main/java/net/minecraft/server/LightEngineSky.java b/src/main/java/net/minecraft/server/LightEngineSky.java
index 309201c484c..3d508fdb0ea 100644
--- a/src/main/java/net/minecraft/server/LightEngineSky.java
+++ b/src/main/java/net/minecraft/server/LightEngineSky.java
@@ -6,7 +6,7 @@ public final class LightEngineSky extends LightEngineLayer<LightEngineStorageSky
private static final EnumDirection[] e = EnumDirection.values();
private static final EnumDirection[] f = new EnumDirection[]{EnumDirection.NORTH, EnumDirection.SOUTH, EnumDirection.WEST, EnumDirection.EAST};
- //private final MutableInt mutableint = new MutableInt(); // Paper - unused
+ private final MutableInt mutableint = new MutableInt(); // Paper
public LightEngineSky(ILightAccess ilightaccess) {
super(ilightaccess, EnumSkyBlock.SKY, new LightEngineStorageSky(ilightaccess));
@@ -33,8 +33,8 @@ public final class LightEngineSky extends LightEngineLayer<LightEngineStorageSky
int jx = (int) (j >> 38);
int jy = (int) ((j << 52) >> 52);
int jz = (int) ((j << 26) >> 38);
- IBlockData iblockdata = this.getBlockOptimized(jx, jy, jz);
- int blockedLight = iblockdata.getBlockedLight();
+ IBlockData iblockdata = this.getBlockOptimized(jx, jy, jz, mutableint);
+ int blockedLight = mutableint.getValue();
if (blockedLight >= 15) {
// Paper end
return 15;
@@ -56,8 +56,7 @@ public final class LightEngineSky extends LightEngineLayer<LightEngineStorageSky
enumdirection = EnumDirection.a(j2, k2, l2);
}
- iblockdata = getBlockDataForOcclusion(iblockdata); // Paper
- IBlockData iblockdata1 = i == Long.MAX_VALUE ? Blocks.AIR.getBlockData() : getBlockDataForOcclusion(this.getBlockOptimized(ix, iy, iz)); // Paper
+ IBlockData iblockdata1 = i == Long.MAX_VALUE ? Blocks.AIR.getBlockData() : this.getBlockOptimized(ix, iy, iz); // Paper
VoxelShape voxelshape;
if (enumdirection != null) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment