mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-21 15:59:33 +00:00
68 lines
3.4 KiB
Diff
68 lines
3.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Thu, 27 Jan 2022 20:11:05 +0800
|
|
Subject: [PATCH] Player can edit sign
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/SignBlock.java b/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
|
index ed3d78494735ceda14ad0ea23adeadc374f3b35e..d0e9fd987687d6a0642a9e312668697f98106a0a 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java
|
|
@@ -3,6 +3,7 @@ package net.minecraft.world.level.block;
|
|
import net.minecraft.advancements.CriteriaTriggers;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
+import net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.sounds.SoundSource;
|
|
@@ -73,6 +74,7 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
|
|
boolean bl2 = itemStack.is(Items.GLOW_INK_SAC);
|
|
boolean bl3 = itemStack.is(Items.INK_SAC);
|
|
boolean bl4 = (bl2 || bl || bl3) && player.getAbilities().mayBuild;
|
|
+ boolean bl7 = itemStack.is(Items.AIR); // Leaves - Player can edit sign
|
|
if (world.isClientSide) {
|
|
return bl4 ? InteractionResult.SUCCESS : InteractionResult.CONSUME;
|
|
} else {
|
|
@@ -82,6 +84,14 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
|
|
} else {
|
|
SignBlockEntity signBlockEntity = (SignBlockEntity)blockEntity;
|
|
boolean bl5 = signBlockEntity.hasGlowingText();
|
|
+ // Leaves start - Player can edit sign
|
|
+ if (top.leavesmc.leaves.LeavesConfig.playerCanEditSign && bl7 && !signBlockEntity.isEditable) {
|
|
+ signBlockEntity.setEditable(true);
|
|
+ signBlockEntity.setAllowedPlayerEditor(player.getUUID());
|
|
+ ((ServerPlayer) player).connection.send(new ClientboundOpenSignEditorPacket(pos));
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // Leaves end - Player can edit sign
|
|
if ((!bl2 || !bl5) && (!bl3 || bl5)) {
|
|
if (bl4) {
|
|
boolean bl6;
|
|
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
index 4c290eb2d4abf9e9b923b8d0878f319328b7cf8c..d6abf25f70f6f5a19787c72e87fddd2801b47def 100644
|
|
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
@@ -93,7 +93,9 @@ public final class LeavesConfig {
|
|
|
|
private static void updateConfigVersion(final YamlConfiguration config) {
|
|
if (configVersion < CURRENT_CONFIG_VERSION) {
|
|
+ playerCanEditSign = config.getBoolean("settings.player-can-edit-sign", playerCanEditSign);
|
|
|
|
+ config.set("settings.player-can-edit-sign", null);
|
|
}
|
|
}
|
|
|
|
@@ -132,6 +134,11 @@ public final class LeavesConfig {
|
|
return LeavesConfig.config.getString(path, dfl);
|
|
}
|
|
|
|
+ public static boolean playerCanEditSign = true;
|
|
+ private static void playerCanEditSign() {
|
|
+ playerCanEditSign = getBoolean("settings.modify.player-can-edit-sign", playerCanEditSign);
|
|
+ }
|
|
+
|
|
public static final class WorldConfig {
|
|
|
|
public final String worldName;
|