178 lines
11 KiB
Diff
178 lines
11 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Tom <cryptite@gmail.com>
|
|
Date: Mon, 28 Feb 2022 08:40:41 -0600
|
|
Subject: [PATCH] Set BlockData without light update
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
|
index 1e656438d9ee89b97c660f3b3ec671be6546c6b7..787c14495616c2ccc6cbb41a44010f1ede1ff16d 100644
|
|
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
|
@@ -225,7 +225,7 @@ public class WorldGenRegion implements WorldGenLevel {
|
|
Block.dropResources(iblockdata, this.level, pos, tileentity, breakingEntity, ItemStack.EMPTY);
|
|
}
|
|
|
|
- return this.setBlock(pos, Blocks.AIR.defaultBlockState(), 3, maxUpdateDepth);
|
|
+ return this.setBlock(pos, Blocks.AIR.defaultBlockState(), 3, maxUpdateDepth, true);
|
|
}
|
|
}
|
|
|
|
@@ -300,7 +300,7 @@ public class WorldGenRegion implements WorldGenLevel {
|
|
}
|
|
|
|
@Override
|
|
- public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
|
|
+ public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight) {
|
|
if (!this.ensureCanWrite(pos)) {
|
|
return false;
|
|
} else {
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 160c0f37aa3aaf7598f852acf9bd444f79444c97..8b6ea24dc8d0286c0814c86dcf4c51cacc572854 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -495,12 +495,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
}
|
|
|
|
@Override
|
|
- public final boolean setBlock(BlockPos pos, BlockState state, int flags) { // Paper - final for inline
|
|
- return this.setBlock(pos, state, flags, 512);
|
|
+ public final boolean setBlock(BlockPos pos, BlockState state, int flags, boolean checkLight) { // Paper - final for inline
|
|
+ return this.setBlock(pos, state, flags, 512, checkLight);
|
|
}
|
|
|
|
@Override
|
|
- public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
|
|
+ public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight) {
|
|
// CraftBukkit start - tree generation
|
|
if (this.captureTreeGeneration) {
|
|
// Paper start
|
|
@@ -547,7 +547,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
} else {
|
|
BlockState iblockdata2 = this.getBlockState(pos);
|
|
|
|
- if ((flags & 128) == 0 && iblockdata2 != iblockdata1 && (iblockdata2.getLightBlock(this, pos) != iblockdata1.getLightBlock(this, pos) || iblockdata2.getLightEmission() != iblockdata1.getLightEmission() || iblockdata2.useShapeForLightOcclusion() || iblockdata1.useShapeForLightOcclusion())) {
|
|
+ if (checkLight && (flags & 128) == 0 && iblockdata2 != iblockdata1 && (iblockdata2.getLightBlock(this, pos) != iblockdata1.getLightBlock(this, pos) || iblockdata2.getLightEmission() != iblockdata1.getLightEmission() || iblockdata2.useShapeForLightOcclusion() || iblockdata1.useShapeForLightOcclusion())) {
|
|
this.getProfiler().push("queueCheckLight");
|
|
this.getChunkSource().getLightEngine().checkBlock(pos);
|
|
this.getProfiler().pop();
|
|
@@ -694,7 +694,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
Block.dropResources(iblockdata, this, pos, tileentity, breakingEntity, ItemStack.EMPTY);
|
|
}
|
|
|
|
- boolean flag1 = this.setBlock(pos, fluid.createLegacyBlock(), 3, maxUpdateDepth);
|
|
+ boolean flag1 = this.setBlock(pos, fluid.createLegacyBlock(), 3, maxUpdateDepth, true);
|
|
|
|
if (flag1) {
|
|
this.gameEvent(breakingEntity, GameEvent.BLOCK_DESTROY, pos);
|
|
diff --git a/src/main/java/net/minecraft/world/level/LevelWriter.java b/src/main/java/net/minecraft/world/level/LevelWriter.java
|
|
index 134e5ec79bf2dddd4e31930f8a7cb2c02fa29518..fd72d278a2719911a46b6bc9e7da2dc24bbe681e 100644
|
|
--- a/src/main/java/net/minecraft/world/level/LevelWriter.java
|
|
+++ b/src/main/java/net/minecraft/world/level/LevelWriter.java
|
|
@@ -7,10 +7,14 @@ import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
public interface LevelWriter {
|
|
|
|
- boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth);
|
|
+ boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight);
|
|
|
|
default boolean setBlock(BlockPos pos, BlockState state, int flags) {
|
|
- return this.setBlock(pos, state, flags, 512);
|
|
+ return this.setBlock(pos, state, flags, 512, true);
|
|
+ }
|
|
+
|
|
+ default boolean setBlock(BlockPos pos, BlockState state, int flags, boolean checkLight) {
|
|
+ return this.setBlock(pos, state, flags, 512, checkLight);
|
|
}
|
|
|
|
boolean removeBlock(BlockPos pos, boolean move);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
index a80f4dc0a642c744223a155232291ace6e007636..fda1cb8ac3fa78375d90d6bc9f05a78f58d18193 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
@@ -196,7 +196,7 @@ public class Block extends BlockBehaviour implements ItemLike {
|
|
world.destroyBlock(pos, (flags & 32) == 0, (Entity) null, maxUpdateDepth);
|
|
}
|
|
} else {
|
|
- world.setBlock(pos, newState, flags & -33, maxUpdateDepth);
|
|
+ world.setBlock(pos, newState, flags & -33, maxUpdateDepth, true);
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
index e231636403a70f28e7e4bf51542608872234ce94..47b067f820dbe1d6304e30721afd7a8fd05d2032 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
@@ -270,7 +270,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
|
BlockPos pos = new BlockPos(x, y, z);
|
|
net.minecraft.world.level.block.state.BlockState old = this.getHandle().getBlockState(pos);
|
|
|
|
- CraftBlock.setTypeAndData(world, pos, old, ((CraftBlockData) blockData).getState(), true);
|
|
+ CraftBlock.setTypeAndData(world, pos, old, ((CraftBlockData) blockData).getState(), true, true);
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
index a52e76c8870b1dd578c4332930c6f2fd3b31d471..1ed2dcb6f28a391689b5dd10073422bae1dcd8bb 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
@@ -187,15 +187,20 @@ public class CraftBlock implements Block {
|
|
|
|
@Override
|
|
public void setBlockData(BlockData data, boolean applyPhysics) {
|
|
+ setBlockData(data, applyPhysics, true);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setBlockData(BlockData data, boolean applyPhysics, boolean checkLight) {
|
|
Preconditions.checkArgument(data != null, "BlockData cannot be null");
|
|
- this.setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
|
|
+ this.setTypeAndData(((CraftBlockData) data).getState(), applyPhysics, checkLight);
|
|
}
|
|
|
|
- boolean setTypeAndData(final net.minecraft.world.level.block.state.BlockState blockData, final boolean applyPhysics) {
|
|
- return CraftBlock.setTypeAndData(this.world, this.position, this.getNMS(), blockData, applyPhysics);
|
|
+ boolean setTypeAndData(final net.minecraft.world.level.block.state.BlockState blockData, final boolean applyPhysics, boolean checkLight) {
|
|
+ return CraftBlock.setTypeAndData(this.world, this.position, this.getNMS(), blockData, applyPhysics, checkLight);
|
|
}
|
|
|
|
- public static boolean setTypeAndData(LevelAccessor world, BlockPos position, net.minecraft.world.level.block.state.BlockState old, net.minecraft.world.level.block.state.BlockState blockData, boolean applyPhysics) {
|
|
+ public static boolean setTypeAndData(LevelAccessor world, BlockPos position, net.minecraft.world.level.block.state.BlockState old, net.minecraft.world.level.block.state.BlockState blockData, boolean applyPhysics, boolean checkLight) {
|
|
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup
|
|
if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
|
|
// SPIGOT-4612: faster - just clear tile
|
|
@@ -209,7 +214,7 @@ public class CraftBlock implements Block {
|
|
if (applyPhysics) {
|
|
return world.setBlock(position, blockData, 3);
|
|
} else {
|
|
- boolean success = world.setBlock(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
|
|
+ boolean success = world.setBlock(position, blockData, 2 | 16 | 1024, checkLight); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
|
|
if (success && world instanceof net.minecraft.world.level.Level) {
|
|
world.getMinecraftWorld().sendBlockUpdated(
|
|
position,
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
index 966ac60daebb7bb211ab8096fc0c5f33db67320a..d68b046e30d0f3d186ed90b7c36086ccd889de1f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
@@ -213,7 +213,7 @@ public class CraftBlockState implements BlockState {
|
|
}
|
|
|
|
net.minecraft.world.level.block.state.BlockState newBlock = this.data;
|
|
- block.setTypeAndData(newBlock, applyPhysics);
|
|
+ block.setTypeAndData(newBlock, applyPhysics, true);
|
|
if (access instanceof net.minecraft.world.level.Level) {
|
|
this.world.getHandle().sendBlockUpdated(
|
|
position,
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
|
index 34e2e14ebb007cceb8b64d3eb321646e834215d4..c0428b6e1cc9f2ca84b3ee718e28b15ce496261c 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
|
@@ -238,7 +238,7 @@ public class DummyGeneratorAccess implements WorldGenLevel {
|
|
}
|
|
|
|
@Override
|
|
- public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
|
|
+ public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, boolean checkLight) {
|
|
return false;
|
|
}
|
|
|