mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 23:09:34 +00:00
175 lines
10 KiB
Diff
175 lines
10 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Fri, 7 Jul 2023 21:27:24 +0800
|
|
Subject: [PATCH] No block update command
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index a90c6b1cfc9c3f99712afa1d7a3ed93fb02f4bfd..66b95197df737fac490a1b22949ab3855a7fce59 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -2481,6 +2481,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
|
|
@Override
|
|
public void blockUpdated(BlockPos pos, Block block) {
|
|
+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update
|
|
if (!this.isDebug()) {
|
|
// CraftBukkit start
|
|
if (populating) {
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
index 4697df75fdee2023c41260bed211e3e3d90d2b9b..8c9bc54a7007b0c5ae1c8576aeca5d05a55613d1 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
@@ -459,7 +459,7 @@ public final class ItemStack {
|
|
net.minecraft.world.level.block.state.BlockState block = world.getBlockState(newblockposition);
|
|
|
|
if (!(block.getBlock() instanceof BaseEntityBlock)) { // Containers get placed automatically
|
|
- block.getBlock().onPlace(block, world, newblockposition, oldBlock, true, context); // Paper - pass context
|
|
+ if (!top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) block.getBlock().onPlace(block, world, newblockposition, oldBlock, true, context); // Paper - pass context // Leaves - no block update
|
|
}
|
|
|
|
world.notifyAndUpdatePhysics(newblockposition, null, oldBlock, block, world.getBlockState(newblockposition), updateFlag, 512); // send null chunk as chunk.k() returns false by this point
|
|
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
|
index 6f005cc4b90d2610c8a2ce246f29156132e68267..00989bd8ba9953353a213d57c5ff81f7d2f07773 100644
|
|
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
|
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
|
@@ -485,7 +485,7 @@ public class LevelChunk extends ChunkAccess {
|
|
} else {
|
|
// CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
|
|
if (!this.level.isClientSide && doPlace && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) {
|
|
- iblockdata.onPlace(this.level, blockposition, iblockdata1, flag);
|
|
+ if (!top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) iblockdata.onPlace(this.level, blockposition, iblockdata1, flag); // Leaves - no block update
|
|
}
|
|
|
|
if (iblockdata.hasBlockEntity()) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
|
index 3cf6e62ceb555eedf133e0ba82445caadaab7743..8c3c9c64ea9de68a57d18164e016602016a79406 100644
|
|
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
|
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
|
@@ -521,6 +521,7 @@ public abstract class FlowingFluid extends Fluid {
|
|
|
|
@Override
|
|
public void tick(Level world, BlockPos pos, FluidState state) {
|
|
+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update
|
|
if (!state.isSource()) {
|
|
FluidState fluid1 = this.getNewLiquid(world, pos, world.getBlockState(pos));
|
|
int i = this.getSpreadDelay(world, pos, state, fluid1);
|
|
diff --git a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
|
index 598dc0d3a2b9387e76d7e4e19e54c4573a24bc54..dda7e3c78aa62636a1f6834392df87a8bc428f04 100644
|
|
--- a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
|
+++ b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
|
|
@@ -46,6 +46,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
|
|
}
|
|
|
|
private void addAndRun(BlockPos pos, CollectingNeighborUpdater.NeighborUpdates entry) {
|
|
+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update
|
|
boolean bl = this.count > 0;
|
|
boolean bl2 = this.maxChainedNeighborUpdates >= 0 && this.count >= this.maxChainedNeighborUpdates;
|
|
++this.count;
|
|
diff --git a/src/main/java/net/minecraft/world/level/redstone/InstantNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/InstantNeighborUpdater.java
|
|
index 2708251ebc1995e71fb0e5dca9e158a3005f8a8a..e28351b379677fec356b6efec2d882ee20e7bd48 100644
|
|
--- a/src/main/java/net/minecraft/world/level/redstone/InstantNeighborUpdater.java
|
|
+++ b/src/main/java/net/minecraft/world/level/redstone/InstantNeighborUpdater.java
|
|
@@ -15,17 +15,20 @@ public class InstantNeighborUpdater implements NeighborUpdater {
|
|
|
|
@Override
|
|
public void shapeUpdate(Direction direction, BlockState neighborState, BlockPos pos, BlockPos neighborPos, int flags, int maxUpdateDepth) {
|
|
+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update
|
|
NeighborUpdater.executeShapeUpdate(this.level, direction, neighborState, pos, neighborPos, flags, maxUpdateDepth - 1);
|
|
}
|
|
|
|
@Override
|
|
public void neighborChanged(BlockPos pos, Block sourceBlock, BlockPos sourcePos) {
|
|
+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update
|
|
BlockState blockState = this.level.getBlockState(pos);
|
|
this.neighborChanged(blockState, pos, sourceBlock, sourcePos, false);
|
|
}
|
|
|
|
@Override
|
|
public void neighborChanged(BlockState state, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
|
|
+ if (top.leavesmc.leaves.command.NoBlockUpdateCommand.isNoBlockUpdate()) return; // Leaves - no block update
|
|
NeighborUpdater.executeUpdate(this.level, state, pos, sourceBlock, sourcePos, notify);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
index b10e20e7b504d15d1388fa620b8021a0652b5b3e..117ab409df92a5d96568becaf58ea3a6a24c19a6 100644
|
|
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
@@ -11,6 +11,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|
import top.leavesmc.leaves.command.LeavesCommand;
|
|
import top.leavesmc.leaves.bot.BotCommand;
|
|
import top.leavesmc.leaves.bot.agent.Actions;
|
|
+import top.leavesmc.leaves.command.NoBlockUpdateCommand;
|
|
import top.leavesmc.leaves.profile.LeavesMinecraftSessionService;
|
|
import top.leavesmc.leaves.util.MathUtils;
|
|
import top.leavesmc.leaves.protocol.CarpetServerProtocol.CarpetRule;
|
|
@@ -82,6 +83,10 @@ public final class LeavesConfig {
|
|
commands.put("bot", new BotCommand("bot"));
|
|
Actions.registerAll();
|
|
}
|
|
+
|
|
+ if (LeavesConfig.noBlockUpdateCommand) {
|
|
+ commands.put("blockupdate", new NoBlockUpdateCommand("blockupdate"));
|
|
+ }
|
|
}
|
|
|
|
public static void load(final YamlConfiguration config) {
|
|
diff --git a/src/main/java/top/leavesmc/leaves/command/NoBlockUpdateCommand.java b/src/main/java/top/leavesmc/leaves/command/NoBlockUpdateCommand.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..819d5a5383dc6978f53645b727722fa924b7a505
|
|
--- /dev/null
|
|
+++ b/src/main/java/top/leavesmc/leaves/command/NoBlockUpdateCommand.java
|
|
@@ -0,0 +1,52 @@
|
|
+package top.leavesmc.leaves.command;
|
|
+
|
|
+import net.kyori.adventure.text.Component;
|
|
+import net.kyori.adventure.text.JoinConfiguration;
|
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.command.Command;
|
|
+import org.bukkit.command.CommandSender;
|
|
+import org.bukkit.permissions.Permission;
|
|
+import org.bukkit.permissions.PermissionDefault;
|
|
+import org.bukkit.plugin.PluginManager;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+import top.leavesmc.leaves.LeavesConfig;
|
|
+
|
|
+import java.util.List;
|
|
+
|
|
+public class NoBlockUpdateCommand extends Command {
|
|
+
|
|
+ private static boolean noBlockUpdate = false;
|
|
+
|
|
+ public NoBlockUpdateCommand(@NotNull String name) {
|
|
+ super(name);
|
|
+ this.description = "No Block Update Command";
|
|
+ this.usageMessage = "/blockupdate";
|
|
+ this.setPermission("bukkit.command.blockupdate");
|
|
+ final PluginManager pluginManager = Bukkit.getServer().getPluginManager();
|
|
+ if (pluginManager.getPermission("bukkit.command.blockupdate") == null) {
|
|
+ pluginManager.addPermission(new Permission("bukkit.command.blockupdate", PermissionDefault.OP));
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
|
|
+ return List.of();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
|
+ if (!testPermission(sender)) return true;
|
|
+ noBlockUpdate = !noBlockUpdate;
|
|
+ Bukkit.broadcast(Component.join(JoinConfiguration.noSeparators(),
|
|
+ Component.text("Block update status: ", NamedTextColor.GRAY),
|
|
+ Component.text(!noBlockUpdate, noBlockUpdate ? NamedTextColor.AQUA : NamedTextColor.GRAY)
|
|
+ ), "bukkit.command.blockupdate");
|
|
+
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ public static boolean isNoBlockUpdate() {
|
|
+ return LeavesConfig.noBlockUpdateCommand && noBlockUpdate;
|
|
+ }
|
|
+}
|