149 lines
8.8 KiB
Diff
149 lines
8.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Tom <cryptite@gmail.com>
|
|
Date: Wed, 22 Sep 2021 09:41:27 -0500
|
|
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 21d1e0c9c471e9e556b5bd70166a769b46105c7a..d46dc12001bd46596c3bb2e24144bbe4d2d3a5e1 100644
|
|
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
|
@@ -241,7 +241,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);
|
|
}
|
|
}
|
|
|
|
@@ -298,7 +298,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 9cafd000b3533ed9fd35df2ec880f55e262084fb..8420d615867faa717266d1edfa5a469df1b1e43f 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -541,12 +541,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
|
|
@@ -593,7 +593,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
} else {
|
|
BlockState iblockdata2 = this.getBlockState(pos);
|
|
|
|
- if ((flags & 128) == 0 && iblockdata2 != iblockdata1 && (iblockdata2.getLightBlock((BlockGetter) this, pos) != iblockdata1.getLightBlock((BlockGetter) this, pos) || iblockdata2.getLightEmission() != iblockdata1.getLightEmission() || iblockdata2.useShapeForLightOcclusion() || iblockdata1.useShapeForLightOcclusion())) {
|
|
+ if (checkLight && (flags & 128) == 0 && iblockdata2 != iblockdata1 && (iblockdata2.getLightBlock((BlockGetter) this, pos) != iblockdata1.getLightBlock((BlockGetter) this, pos) || iblockdata2.getLightEmission() != iblockdata1.getLightEmission() || iblockdata2.useShapeForLightOcclusion() || iblockdata1.useShapeForLightOcclusion())) {
|
|
this.getProfiler().push("queueCheckLight");
|
|
this.getChunkSource().getLightEngine().checkBlock(pos);
|
|
this.getProfiler().pop();
|
|
@@ -740,7 +740,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 b6825cd32033cac34c74af1f8c980ed7fb97a754..d2dfbfa0d58b94ce583992aa56f5b0e28d4b31f2 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 8c30e28b97ac7e8b54322c903e0b75ee8135620b..64cc26d146afba7c6ecb0d3052776837a41a5618 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
@@ -197,7 +197,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/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
index 6f01af8cc3f9ed4d2eaa3304990ca33f8692a453..f374d5d6fc3ac9187236d141931c3c57ddd57865 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
@@ -178,11 +178,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);
|
|
}
|
|
|
|
public boolean setTypeAndData(final net.minecraft.world.level.block.state.BlockState blockData, final boolean applyPhysics) {
|
|
+ return setTypeAndData(blockData, applyPhysics, true);
|
|
+ }
|
|
+
|
|
+ public boolean setTypeAndData(final net.minecraft.world.level.block.state.BlockState blockData, final boolean applyPhysics, boolean checkLight) {
|
|
net.minecraft.world.level.block.state.BlockState old = this.getNMS();
|
|
// 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
|
|
@@ -197,7 +206,7 @@ public class CraftBlock implements Block {
|
|
if (applyPhysics) {
|
|
return this.world.setBlock(position, blockData, 3);
|
|
} else {
|
|
- boolean success = this.world.setBlock(position, blockData, 2 | 16 | 1024); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
|
|
+ boolean success = this.world.setBlock(position, blockData, 2 | 16 | 1024, checkLight); // NOTIFY | NO_OBSERVER | NO_PLACE (custom)
|
|
if (success && this.world instanceof net.minecraft.world.level.Level) {
|
|
this.world.getMinecraftWorld().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 950d4381459d31d02acf55c4aef4f5e33367748b..0b09b06b3d9fe2cce5c6cbf70a4b84ff8edc2085 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
|
@@ -231,7 +231,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;
|
|
}
|
|
|