9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2026-01-04 15:41:31 +00:00
Files
LeavesMC/leaves-server/minecraft-patches/features/0055-No-block-update-command.patch
MC_XiaoHei 7d3dad94c9 feat: new command system (#714)
* feat: neo command

* feat: add action part

* fix: fix bot action command

* feat: finish perms system, fix bugs

* feat: add bot config command

* feat: switch to new bot command

* fix: fix suppress annotation

* feat: add bot remove, fix stupid me

* feat: add show all config

* feat: finish leaves command

* refactor: refactor command

* refactor: remove unused check

* refactor: refactor

* fix: fix logic

* refactor: format

* fix: fix msg

* refactor: better msg

* feat: custom bot action

* feat: rename patch

* fix: fix bot command register

* refactor: format & refactor code

* Some format

* refactor: refactor config and action

* refactor: use paper command api

* refactor: use paper command api

* feat: use raycasting in mount action

* feat: try to impl custom

* Revert "feat: try to impl custom"

This reverts commit b658777341.

* chore: format

---------

Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com>
2025-10-01 16:10:56 +08:00

98 lines
6.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <58360096+s-yh-china@users.noreply.github.com>
Date: Mon, 3 Feb 2025 19:16:16 +0800
Subject: [PATCH] No block update command
diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java
index 3a1108b1e98629a7d2ade8c25a604175cedcd42e..fc205e54941d40a5583129b0c6540950f97a6b49 100644
--- a/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -401,7 +401,7 @@ public class ServerPlayerGameMode {
org.bukkit.block.BlockState state = bblock.getState();
this.level.captureDrops = new java.util.ArrayList<>();
// CraftBukkit end
- BlockState blockState1 = block.playerWillDestroy(this.level, pos, blockState, this.player);
+ BlockState blockState1 = org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate() ? blockState : block.playerWillDestroy(this.level, pos, blockState, this.player); // Leaves - no block update
boolean flag = this.level.removeBlock(pos, false);
if (SharedConstants.DEBUG_BLOCK_BREAK) {
LOGGER.info("server broke {} {} -> {}", pos, blockState1, this.level.getBlockState(pos));
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 2518ddaa6bd35e6df88ce74531b772a7a1017e66..f8e23a0a2a0b0680c277b4c2cb1fd5922bb939da 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -1042,6 +1042,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@Override
public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) {
+ // Leaves start - no block update
+ if (org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate()) {
+ flags = flags & ~1 | net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE;
+ }
+ // Leaves end - no block update
// CraftBukkit start - tree generation
if (this.captureTreeGeneration) {
// Paper start - Protect Bedrock and End Portal/Frames from being destroyed
@@ -1143,6 +1148,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
BlockState state = newState;
BlockState blockState = oldState;
BlockState blockState1 = currentState;
+ // Leaves start - no block update
+ if (org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate()) {
+ flags = flags & ~1 | net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE;
+ }
+ // Leaves end - no block update
if (blockState1 == state) {
if (blockState != blockState1) {
this.setBlocksDirty(pos, blockState, blockState1);
@@ -1161,7 +1171,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
if ((flags & 16) == 0 && recursionLeft > 0) {
int i = flags & -34;
-
+ // Leaves start - no block update
+ if (org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate()) {
+ this.updatePOIOnBlockStateChange(pos, blockState, blockState1);
+ return;
+ }
+ // Leaves end - no block update
// CraftBukkit start
blockState.updateIndirectNeighbourShapes(this, pos, i, recursionLeft - 1); // Don't call an event for the old block to limit event spam
boolean cancelledUpdates = false; // Paper - Fix block place logic
diff --git a/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/net/minecraft/world/level/block/piston/PistonBaseBlock.java
index 26c9ee02de0d5d9f556c947b5461cd10cd03d649..3de51052525e5bc1e35418caa7d904ab441f3769 100644
--- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -105,6 +105,7 @@ public class PistonBaseBlock extends DirectionalBlock {
}
private void checkIfExtend(Level level, BlockPos pos, BlockState state) {
+ if (org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update
Direction direction = state.getValue(FACING);
boolean neighborSignal = this.getNeighborSignal(level, pos, direction);
if (neighborSignal && !state.getValue(EXTENDED)) {
diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java
index 8942aa2ca4796c7c36c0955141627ea905e0ec64..dc0137ed3aecc783654c30889649584d6fb761a6 100644
--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
@@ -34,6 +34,11 @@ public interface NeighborUpdater {
static void executeShapeUpdate(
LevelAccessor level, Direction direction, BlockPos pos, BlockPos neighborPos, BlockState neighborState, int flags, int recursionLeft
) {
+ // Leaves start - no block update
+ if (org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate()) {
+ flags = flags & ~1 | net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE;
+ }
+ // Leaves end - no block update
BlockState blockState = level.getBlockState(pos);
if ((flags & 128) == 0 || !blockState.is(Blocks.REDSTONE_WIRE)) {
BlockState blockState1 = blockState.updateShape(level, level, pos, direction, neighborPos, neighborState, level.getRandom());
@@ -48,6 +53,7 @@ public interface NeighborUpdater {
static void executeUpdate(Level level, BlockState state, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston, BlockPos sourcePos) {
// Paper end - Add source block to BlockPhysicsEvent
+ if (org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update
try {
// CraftBukkit start
org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(state), org.bukkit.craftbukkit.block.CraftBlock.at(level, sourcePos)); // Paper - Add source block to BlockPhysicsEvent