169 lines
10 KiB
Diff
169 lines
10 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cryptite <cryptite@gmail.com>
|
|
Date: Mon, 10 Apr 2023 07:29:11 -0500
|
|
Subject: [PATCH] Set BlockData without light updates
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
|
index 877498729c66de9aa6a27c9148f7494d7895615c..63959d7f15c682c2935f872d50de03fdacf95db4 100644
|
|
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
|
@@ -235,7 +235,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); // Slice
|
|
}
|
|
}
|
|
|
|
@@ -310,7 +310,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) { // Slice
|
|
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 ea8a0961190e9aafda4fed6fecd85097c141040a..d4af10645b74514a79cb41f428534cfe6d1e9058 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -903,12 +903,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
|
|
@@ -1099,7 +1099,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(GameEvent.BLOCK_DESTROY, pos, GameEvent.Context.of(breakingEntity, iblockdata));
|
|
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 d4cbff18adb62073a1dceb189043789620af6877..413eb8d315f5da04c69e082654e74054055705d6 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
@@ -194,7 +194,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); // Slice
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
index 1a17875426468b287c8ea3f559ea516d0218f7a0..84a1150438dc8cdd8a6d3ad92e6bf2c4ad5f7cf0 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
|
@@ -287,7 +287,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 24ba4e1fd80d8effc8e70224103d3b93d69cb2ac..cb2826852ea38850eb0c553ab3b626253fd8e7a2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
@@ -182,15 +182,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
|
|
@@ -204,7 +209,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 cfd1c68d7ad23ef20242306d7d8148921d697ca5..3403033b4c292089c8cae03977034fbb20c30796 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
|
@@ -217,7 +217,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 23ee60e8843a6a05e7ae6512248a57ec2a08321b..c5e1afb7d5fa630ed85a739d5aada79297257d72 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
|
@@ -245,7 +245,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;
|
|
}
|
|
|