Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/src/main/java/net/minecraft/server/IBlockData.java b/src/main/java/net/minecraft/server/IBlockData.java
index b39554faf23..2c128feb0f8 100644
--- a/src/main/java/net/minecraft/server/IBlockData.java
+++ b/src/main/java/net/minecraft/server/IBlockData.java
@@ -72,6 +72,7 @@ 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);
}
@@ -85,7 +86,7 @@ public class IBlockData extends BlockDataAbstract<Block, IBlockData> implements
return this.c == null || this.c.h;
}
- public final boolean g() { // Paper
+ public final boolean shapeAffectsLight() { return this.e; } public final boolean g() { // Paper - OBFHELPER
return this.e;
}
@@ -153,7 +154,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 o() { // Paper
+ public final boolean canOcclude() { return canOcclude; } 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 86868bedc65..73553e1b13f 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
+ // private final MutableInt mutableint = new MutableInt(); // Paper // No longer used
public LightEngineBlock(ILightAccess ilightaccess) {
super(ilightaccess, EnumSkyBlock.BLOCK, new LightEngineStorageBlock(ilightaccess));
@@ -49,12 +49,13 @@ 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, mutableint); // Paper
- int blockedLight = mutableint.getValue(); // Paper
+ IBlockData iblockdata = this.getBlockOptimized(jx, jy, jz); // Paper
+ int blockedLight = iblockdata.getBlockedLight(); // Paper
if (blockedLight >= 15) { // Paper
return 15;
} else {
- IBlockData iblockdata1 = this.getBlockOptimized(ix, iy, iz); // Paper
+ iblockdata = getBlockDataForOcclusion(iblockdata); // Paper
+ IBlockData iblockdata1 = getBlockDataForOcclusion(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 5a6a21c9a13..36abed4e32d 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 pos = d; // Paper
+ protected final BlockPosition.MutableBlockPosition d = new BlockPosition.MutableBlockPosition();
private final long[] g = new long[2];
private final IChunkAccess[] h = new IChunkAccess[2]; // Paper
@@ -100,20 +100,22 @@ 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.b(this.a.getWorld(), this.pos));
- return iblockdata.o() && iblockdata.g() ? iblockdata : Blocks.AIR.getBlockData();
+ mutableint.setValue(iblockdata.getBlockedLight());
+ return iblockdata;
}
}
+
+ 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 {
- IBlockData iblockdata = iblockaccess.getType(x, y, z);
- return iblockdata.o() && iblockdata.g() ? iblockdata : Blocks.AIR.getBlockData();
+ return iblockaccess.getType(x, y, z);
}
}
// Paper end
diff --git a/src/main/java/net/minecraft/server/LightEngineSky.java b/src/main/java/net/minecraft/server/LightEngineSky.java
index 3d508fdb0ea..309201c484c 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
+ //private final MutableInt mutableint = new MutableInt(); // Paper - unused
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, mutableint);
- int blockedLight = mutableint.getValue();
+ IBlockData iblockdata = this.getBlockOptimized(jx, jy, jz);
+ int blockedLight = iblockdata.getBlockedLight();
if (blockedLight >= 15) {
// Paper end
return 15;
@@ -56,7 +56,8 @@ public final class LightEngineSky extends LightEngineLayer<LightEngineStorageSky
enumdirection = EnumDirection.a(j2, k2, l2);
}
- IBlockData iblockdata1 = i == Long.MAX_VALUE ? Blocks.AIR.getBlockData() : this.getBlockOptimized(ix, iy, iz); // Paper
+ iblockdata = getBlockDataForOcclusion(iblockdata); // Paper
+ IBlockData iblockdata1 = i == Long.MAX_VALUE ? Blocks.AIR.getBlockData() : getBlockDataForOcclusion(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
You can’t perform that action at this time.