Skip to content

Commit

Permalink
Fix light patch (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
uRyanxD committed May 17, 2023
1 parent 8b97cd9 commit c675d1a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions patches/server/0074-Optimize-light-level-comparisons.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ index b91b2200d56d9f0b4a50293fbc497a7aca7b9cec..f9429059302cfeba9d7ea6c1cb7f0dbe

if (i < 7) {
diff --git a/src/main/java/net/minecraft/server/BlockGrass.java b/src/main/java/net/minecraft/server/BlockGrass.java
index 844ad30fd55cd8fed6e9b6c1d9f964a72a501b16..b8e0984efc52026c52d6426814316ca0f8720fae 100644
index 844ad30fd55cd8fed6e9b6c1d9f964a72a501b16..f38d0bf6a2b85ea0757319acb07fe32088481cd6 100644
--- a/src/main/java/net/minecraft/server/BlockGrass.java
+++ b/src/main/java/net/minecraft/server/BlockGrass.java
@@ -29,7 +29,8 @@ public class BlockGrass extends Block implements IBlockFragilePlantElement {
Expand All @@ -31,7 +31,7 @@ index 844ad30fd55cd8fed6e9b6c1d9f964a72a501b16..b8e0984efc52026c52d6426814316ca0
// CraftBukkit start
// world.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
org.bukkit.World bworld = world.getWorld();
@@ -44,13 +45,18 @@ public class BlockGrass extends Block implements IBlockFragilePlantElement {
@@ -44,13 +45,23 @@ public class BlockGrass extends Block implements IBlockFragilePlantElement {
}
// CraftBukkit end
} else {
Expand All @@ -44,13 +44,16 @@ index 844ad30fd55cd8fed6e9b6c1d9f964a72a501b16..b8e0984efc52026c52d6426814316ca0
+ // PandaSpigot end
for (int i = 0; i < Math.min(4, Math.max(20, (int) (4 * 100F / world.growthOdds))); ++i) { // Spigot
BlockPosition blockposition1 = blockposition.a(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
- Block block = world.getType(blockposition1.up()).getBlock();
Block block = world.getType(blockposition1.up()).getBlock();
- IBlockData iblockdata1 = world.getType(blockposition1);
-
- if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && block.p() <= 2) {
+ // PandaSpigot start
+ IBlockData iblockdata1 = world.getTypeIfLoaded(blockposition1.up());
+ if (iblockdata1 != null && iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.isLightLevel(blockposition1.up(),4) && iblockdata1.getBlock().p() <= 2) {
+ IBlockData iblockdata1 = world.getTypeIfLoaded(blockposition1);
+ if (iblockdata1 == null) {
+ return;
+ }

- if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && world.getLightLevel(blockposition1.up()) >= 4 && block.p() <= 2) {
+ if (iblockdata1.getBlock() == Blocks.DIRT && iblockdata1.get(BlockDirt.VARIANT) == BlockDirt.EnumDirtVariant.DIRT && block.p() <= 2 && world.isLightLevel(blockposition1.up(), 4)) {
+ // PandaSpigot end
// CraftBukkit start
// world.setTypeUpdate(blockposition1, Blocks.GRASS.getBlockData());
Expand Down Expand Up @@ -123,20 +126,20 @@ index 9fefb867bca8685b7c571dda0d05091c05d335d6..4bf4de3ddb13718a854b4e9c6eeb2483
}

diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
index 6d3b002bc768e32f4cc95c9f37b274baf5dc4599..6ee7736feeab1727ffb058c1782b25f0172cb8c5 100644
index 6d3b002bc768e32f4cc95c9f37b274baf5dc4599..5165f6e66431079ae756a0c967ca8c9cae466a29 100644
--- a/src/main/java/net/minecraft/server/EntityZombie.java
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
@@ -182,7 +182,7 @@ public class EntityZombie extends EntityMonster {
int j1 = j + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);
int k1 = k + MathHelper.nextInt(this.random, 7, 40) * MathHelper.nextInt(this.random, -1, 1);

- if (World.a((IBlockAccess) this.world, new BlockPosition(i1, j1 - 1, k1)) && this.world.getLightLevel(new BlockPosition(i1, j1, k1)) < 10) {
+ if (World.a((IBlockAccess) this.world, new BlockPosition(i1, j1 - 1, k1)) && this.world.isLightLevel(new BlockPosition(i1, j1, k1), 10)) { // PandaSpigot - Use isLightLevel
+ if (World.a((IBlockAccess) this.world, new BlockPosition(i1, j1 - 1, k1)) && !this.world.isLightLevel(new BlockPosition(i1, j1, k1), 10)) { // PandaSpigot - Use isLightLevel
entityzombie.setPosition((double) i1, (double) j1, (double) k1);
if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.a(entityzombie.getBoundingBox(), (Entity) entityzombie) && this.world.getCubes(entityzombie, entityzombie.getBoundingBox()).isEmpty() && !this.world.containsLiquid(entityzombie.getBoundingBox())) {
this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index b75d78da71f24a0b02bf709d026389add0556489..bc1600fceb936cce60dabd5896a507dfda86ad60 100644
index ad97333c47582cb96709b478eb93659f16b717bf..a92b1eb303e01bc42157fe384279d7ad42be03f8 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -93,7 +93,7 @@ public abstract class World implements IBlockAccess {
Expand Down

0 comments on commit c675d1a

Please sign in to comment.