Skip to content

Commit

Permalink
Old BlockEntity behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Aug 13, 2024
1 parent 8be1ec2 commit 8019141
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 19 deletions.
33 changes: 19 additions & 14 deletions patches/server/0006-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ index a108ebfe472c908e86e0af2cfd9cb63083f58eb5..f97b2cb3ea855e6e250cabf357a050cd

this.setPvpAllowed(dedicatedserverproperties.pvp);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c8b82bc41f2042bb4b067f06265a3a22e51f7629..a02aafe76e1bd09e0f62a4b0bed648553ef92d47 100644
index f6de1c6e8fd9086b7bd725f75ee2606583591d6a..a45a6fa9a2338626ba0d08061f327d41ac457f14 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1098,6 +1098,7 @@ public final class CraftServer implements Server {
Expand All @@ -65,7 +65,7 @@ index c8b82bc41f2042bb4b067f06265a3a22e51f7629..a02aafe76e1bd09e0f62a4b0bed64855
@Override
public void restart() {
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index c2c421b1caf76b40542fdc436801accbe97a38cb..29f139fb4d70a9a362ac0a30579eb0b47676cbf6 100644
index d97771ecaf06b92d92b5ca0224ae0866e36703a6..439305bb4f5ce232aa6237276c121d53054ab2a7 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -168,6 +168,14 @@ public class Main {
Expand All @@ -85,10 +85,10 @@ index c2c421b1caf76b40542fdc436801accbe97a38cb..29f139fb4d70a9a362ac0a30579eb0b4
.withRequiredArg()
diff --git a/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/src/main/java/org/leavesmc/leaves/LeavesConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..f554b8e61a31c307bb46fa007c54f2b842be4dfc
index 0000000000000000000000000000000000000000..abba58d7b3711db8372ffa3de1c47a13b23a284f
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/LeavesConfig.java
@@ -0,0 +1,939 @@
@@ -0,0 +1,944 @@
+package org.leavesmc.leaves;
+
+import com.destroystokyo.paper.util.SneakyThrow;
Expand Down Expand Up @@ -315,6 +315,9 @@ index 0000000000000000000000000000000000000000..f554b8e61a31c307bb46fa007c54f2b8
+ @GlobalConfig(name = "fix-fortress-mob-spawn", category = {"modify", "minecraft-old"})
+ public static boolean fixFortressMobSpawn = false;
+
+ @GlobalConfig(name = "old-block-entity-behaviour", category = {"modify", "minecraft-old"})
+ public static boolean oldBlockEntityBehaviour = false;
+
+ // Leaves end - modify - minecraft-old
+
+ // Leaves start - modify - elytra-aeronautics
Expand Down Expand Up @@ -832,7 +835,7 @@ index 0000000000000000000000000000000000000000..f554b8e61a31c307bb46fa007c54f2b8
+
+ private static class AlternativePlaceVerify extends ConfigVerify.EnumConfigVerify<AlternativePlaceType> {
+ @Override
+ public void runAfterLoader(Enum<AlternativePlaceType> value) {
+ public void runAfterLoader(Enum<AlternativePlaceType> value, boolean firstLoad) {
+ if (value != AlternativePlaceType.NONE) {
+ disableDistanceCheckForUseItem = true;
+ }
Expand Down Expand Up @@ -869,15 +872,17 @@ index 0000000000000000000000000000000000000000..f554b8e61a31c307bb46fa007c54f2b8
+
+ private static class AutoUpdateVerify extends ConfigVerify.BooleanConfigVerify {
+ @Override
+ public void runAfterLoader(Boolean value) {
+ org.leavesmc.leaves.util.LeavesUpdateHelper.init();
+ if (value) {
+ LeavesLogger.LOGGER.warning("Auto-Update is not completely safe. Enabling it may cause data security problems!");
+ public void runAfterLoader(Boolean value, boolean firstLoad) {
+ if (firstLoad) {
+ org.leavesmc.leaves.util.LeavesUpdateHelper.init();
+ if (value) {
+ LeavesLogger.LOGGER.warning("Auto-Update is not completely safe. Enabling it may cause data security problems!");
+ }
+ }
+ }
+ }
+
+ @GlobalConfig(name = "download-source", category = {"misc", "auto-update"}, verify = DownloadSourceVerify.class)
+ @GlobalConfig(name = "download-source", category = {"misc", "auto-update"}, lock = true, verify = DownloadSourceVerify.class)
+ public static String autoUpdateSource = "application";
+
+ public static class DownloadSourceVerify extends ConfigVerify.StringConfigVerify {
Expand Down Expand Up @@ -1463,7 +1468,7 @@ index 0000000000000000000000000000000000000000..3ddeff82e31178c9c1bb1737c9a28a81
+}
diff --git a/src/main/java/org/leavesmc/leaves/config/ConfigVerify.java b/src/main/java/org/leavesmc/leaves/config/ConfigVerify.java
new file mode 100644
index 0000000000000000000000000000000000000000..e3cfc606222f27f029ff8e4d1fd370685e76e325
index 0000000000000000000000000000000000000000..4594434e120f2a42481112c4c68ab53b844fba6f
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/config/ConfigVerify.java
@@ -0,0 +1,93 @@
Expand All @@ -1485,7 +1490,7 @@ index 0000000000000000000000000000000000000000..e3cfc606222f27f029ff8e4d1fd37068
+ return List.of("<value>");
+ }
+
+ default void runAfterLoader(E value) {
+ default void runAfterLoader(E value, boolean firstLoad) {
+ }
+
+ class BooleanConfigVerify implements ConfigVerify<Boolean> {
Expand Down Expand Up @@ -1649,7 +1654,7 @@ index 0000000000000000000000000000000000000000..67d4365d25714c3732274e5ab21981a3
+}
diff --git a/src/main/java/org/leavesmc/leaves/config/GlobalConfigManager.java b/src/main/java/org/leavesmc/leaves/config/GlobalConfigManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..0addf5a2f5e015b73b8a02e8f3eef79790eb4587
index 0000000000000000000000000000000000000000..b77e7d9e0870f6a72795cee32e779548989e85b0
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/config/GlobalConfigManager.java
@@ -0,0 +1,192 @@
Expand Down Expand Up @@ -1727,7 +1732,7 @@ index 0000000000000000000000000000000000000000..0addf5a2f5e015b73b8a02e8f3eef797
+ }
+ }
+
+ verifiedConfigs.forEach((path, config) -> config.verify.runAfterLoader(config.get()));
+ verifiedConfigs.forEach((path, config) -> config.verify.runAfterLoader(config.get(), firstLoad));
+
+ firstLoad = false;
+ LeavesConfig.save();
Expand Down
14 changes: 9 additions & 5 deletions patches/server/0054-Syncmatica-Protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Syncmatica Protocol
This patch is Powered by Syncmatica(https://github.com/End-Tech/syncmatica)

diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index c87dc4d99e7ea8395145946c9c5cc5e73113cb23..32d8d22f5e08f6ebdd06b5057fe1b0451acdf1f2 100644
index 1e71c352529afaa73cef3b9ea08098d9a86f6589..f893f841509017d61b496e712c12b578d4d69345 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -314,6 +314,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
Expand Down Expand Up @@ -1335,10 +1335,10 @@ index 0000000000000000000000000000000000000000..d7a3c85df0f5950f3f0c69c33fa5d809
+}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java
new file mode 100644
index 0000000000000000000000000000000000000000..d0ceb4079680c0eaef362ab3fddce60ff5b839a3
index 0000000000000000000000000000000000000000..0d93792de3a12a450f5da1705cff95274360a9c4
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java
@@ -0,0 +1,123 @@
@@ -0,0 +1,127 @@
+package org.leavesmc.leaves.protocol.syncmatica;
+
+import org.jetbrains.annotations.NotNull;
Expand All @@ -1359,6 +1359,7 @@ index 0000000000000000000000000000000000000000..d0ceb4079680c0eaef362ab3fddce60f
+ public static final String PROTOCOL_ID = "syncmatica";
+ public static final String PROTOCOL_VERSION = "leaves-syncmatica-1.1.0";
+
+ private static boolean loaded = false;
+ private static final File litematicFolder = new File("." + File.separator + "syncmatics");
+ private static final PlayerIdentifierProvider playerIdentifierProvider = new PlayerIdentifierProvider();
+ private static final CommunicationManager communicationManager = new CommunicationManager();
Expand Down Expand Up @@ -1391,8 +1392,11 @@ index 0000000000000000000000000000000000000000..d0ceb4079680c0eaef362ab3fddce60f
+ }
+
+ public static void init() {
+ litematicFolder.mkdirs();
+ syncmaticManager.startup();
+ if (!loaded) {
+ litematicFolder.mkdirs();
+ syncmaticManager.startup();
+ loaded = true;
+ }
+ }
+
+ @NotNull
Expand Down
88 changes: 88 additions & 0 deletions patches/server/0133-Old-BlockEntity-behaviour.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <[email protected]>
Date: Wed, 14 Aug 2024 01:48:14 +0800
Subject: [PATCH] Old BlockEntity behaviour


diff --git a/src/main/java/net/minecraft/world/level/block/ChiseledBookShelfBlock.java b/src/main/java/net/minecraft/world/level/block/ChiseledBookShelfBlock.java
index ca3a8ead09cf0d3c1352ac266b749bc0bca2ff9a..b705ee10371e77d027b88afc790f346f20c0087f 100644
--- a/src/main/java/net/minecraft/world/level/block/ChiseledBookShelfBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ChiseledBookShelfBlock.java
@@ -197,6 +197,13 @@ public class ChiseledBookShelfBlock extends BaseEntityBlock {
}

chiseledBookShelfBlockEntity.clearContent();
+ // Leaves start - behaviour 1.21.1-
+ if (org.leavesmc.leaves.LeavesConfig.oldBlockEntityBehaviour) {
+ bl = false;
+ world.updateNeighbourForOutputSignal(pos, this);
+ break label32;
+ }
+ // Leaves end - behaviour 1.21.1-
bl = true;
break label32;
}
diff --git a/src/main/java/net/minecraft/world/level/block/LecternBlock.java b/src/main/java/net/minecraft/world/level/block/LecternBlock.java
index 0c52e1f8bc233bb66e53f4c69e1d8757382bbe81..142009c9eeca22e42ed3ff04cf8f1ba623d6254b 100644
--- a/src/main/java/net/minecraft/world/level/block/LecternBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LecternBlock.java
@@ -209,10 +209,11 @@ public class LecternBlock extends BaseEntityBlock {
this.popBook(state, world, pos);
}

- super.onRemove(state, world, pos, newState, moved);
+ if (!org.leavesmc.leaves.LeavesConfig.oldBlockEntityBehaviour) super.onRemove(state, world, pos, newState, moved); // Leaves - behaviour 1.21.1-
if ((Boolean) state.getValue(LecternBlock.POWERED)) {
world.updateNeighborsAt(pos.below(), this);
}
+ if (org.leavesmc.leaves.LeavesConfig.oldBlockEntityBehaviour) super.onRemove(state, world, pos, newState, moved); // Leaves - behaviour 1.21.1-

}
}
diff --git a/src/main/java/net/minecraft/world/level/block/SculkSensorBlock.java b/src/main/java/net/minecraft/world/level/block/SculkSensorBlock.java
index 8d57c68d2f20f7c0d5c1be5d5b12e6926aad8c58..f1341d0f6545dfb13d14a37a68fda5b3403604b5 100644
--- a/src/main/java/net/minecraft/world/level/block/SculkSensorBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SculkSensorBlock.java
@@ -150,10 +150,11 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg
@Override
protected void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean moved) {
if (!state.is(newState.getBlock())) {
- super.onRemove(state, world, pos, newState, moved);
+ if (!org.leavesmc.leaves.LeavesConfig.oldBlockEntityBehaviour) super.onRemove(state, world, pos, newState, moved); // Leaves - behaviour 1.21.1-
if (SculkSensorBlock.getPhase(state) == SculkSensorPhase.ACTIVE) {
SculkSensorBlock.updateNeighbours(world, pos, state);
}
+ if (org.leavesmc.leaves.LeavesConfig.oldBlockEntityBehaviour) super.onRemove(state, world, pos, newState, moved); // Leaves - behaviour 1.21.1-

}
}
diff --git a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
index e70bf963cd960098709262b0a0b34e62562313d8..14286ebb28c467e1948601407466a31320cfd6e9 100644
--- a/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ShulkerBoxBlock.java
@@ -173,10 +173,11 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
protected void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean moved) {
if (!state.is(newState.getBlock())) {
BlockEntity blockEntity = world.getBlockEntity(pos);
- super.onRemove(state, world, pos, newState, moved);
+ if (!org.leavesmc.leaves.LeavesConfig.oldBlockEntityBehaviour) super.onRemove(state, world, pos, newState, moved); // Leaves - behaviour 1.21.1-
if (blockEntity instanceof ShulkerBoxBlockEntity) {
world.updateNeighbourForOutputSignal(pos, state.getBlock());
}
+ if (org.leavesmc.leaves.LeavesConfig.oldBlockEntityBehaviour) super.onRemove(state, world, pos, newState, moved); // Leaves - behaviour 1.21.1-
}
}

diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
index f2ef63d69bfc6fb3b3dc4b3b2938733d1c371746..e6c67426c9ea76eae2c677d796d0db579acaed6e 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -67,7 +67,7 @@ public abstract class BlockEntity {
}

public boolean isValidBlockState(BlockState state) {
- return this.type.isValid(state);
+ return org.leavesmc.leaves.LeavesConfig.oldBlockEntityBehaviour || this.type.isValid(state); // Leaves - behaviour 1.21.1-
}

public static BlockPos getPosFromTag(CompoundTag nbt) {

0 comments on commit 8019141

Please sign in to comment.