mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-21 15:59:33 +00:00
67 lines
3.7 KiB
Diff
67 lines
3.7 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 47a17f5086a2dc4eb9a72ef9a8ab51e09b273e21..db6cac634120fee0ffc5dbc5c8f06b40aa294ad3 100644
|
|
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
@@ -83,6 +83,11 @@ public final class LeavesConfig {
|
|
LeavesConfig.config.set(path, value);
|
|
}
|
|
|
|
+ public static boolean playerCanEditSign = true;
|
|
+ private static void playerCanEditSign() {
|
|
+ playerCanEditSign = getBoolean("settings.player-can-edit-sign", playerCanEditSign);
|
|
+ }
|
|
+
|
|
static boolean getBoolean(final String path, final boolean dfl) {
|
|
LeavesConfig.config.addDefault(path, Boolean.valueOf(dfl));
|
|
return LeavesConfig.config.getBoolean(path, dfl);
|
|
@@ -141,7 +146,7 @@ public final class LeavesConfig {
|
|
public void load() {
|
|
for (final Method method : LeavesConfig.WorldConfig.class.getDeclaredMethods()) {
|
|
if (method.getReturnType() != void.class || method.getParameterCount() != 0 ||
|
|
- !Modifier.isPrivate(method.getModifiers()) || Modifier.isStatic(method.getModifiers())) {
|
|
+ !Modifier.isPrivate(method.getModifiers()) || Modifier.isStatic(method.getModifiers())) {
|
|
continue;
|
|
}
|
|
|