Skip to content

Commit 8f2be77

Browse files
LexManosJonathing
authored andcommitted
Fixes to redstone updates for comparators and update order
1 parent f2c46fc commit 8f2be77

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- a/net/minecraft/core/Direction.java
2+
+++ b/net/minecraft/core/Direction.java
3+
@@ -42,6 +_,11 @@
4+
private final Direction.AxisDirection f_122344_;
5+
private final Vec3i f_122345_;
6+
private static final Direction[] f_122346_ = values();
7+
+ // In vanilla updates are notified only on the horizontal plane, in Forge we also notify up and down
8+
+ private static final Direction[] UPDATE_ORDER = Stream.concat(Plane.HORIZONTAL.m_122557_(), Plane.VERTICAL.m_122557_()).toArray(Direction[]::new);
9+
+ public static final Direction[] getUpdateOrder() {
10+
+ return UPDATE_ORDER.clone();
11+
+ }
12+
private static final Direction[] f_122348_ = Arrays.stream(f_122346_).sorted(Comparator.comparingInt((p_235687_) -> {
13+
return p_235687_.f_122339_;
14+
})).toArray((p_235681_) -> {

patches/minecraft/net/minecraft/world/level/Level.java.patch

+7-2
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,13 @@
212212
}
213213

214214
public boolean m_46753_(BlockPos p_46754_) {
215-
@@ -769,16 +_,15 @@
215+
@@ -769,17 +_,20 @@
216216
public abstract Scoreboard m_6188_();
217217

218218
public void m_46717_(BlockPos p_46718_, Block p_46719_) {
219219
- for(Direction direction : Direction.Plane.HORIZONTAL) {
220-
+ for(Direction direction : Direction.values()) {
220+
+ var updateOrder = net.minecraftforge.common.ForgeConfig.SERVER.fixNeighborUpdateOrder.get() ? Direction.getUpdateOrder() : Direction.values();
221+
+ for(Direction direction : updateOrder) {
221222
BlockPos blockpos = p_46718_.m_121945_(direction);
222223
if (this.m_46805_(blockpos)) {
223224
BlockState blockstate = this.m_8055_(blockpos);
@@ -230,9 +231,13 @@
230231
blockstate = this.m_8055_(blockpos);
231232
- if (blockstate.m_60713_(Blocks.f_50328_)) {
232233
+ if (blockstate.getWeakChanges(this, blockpos)) {
234+
+ // Forge: Replace Level#neighborChanged with BlockState#onNeighborChange. Boolean.valueOf(false) is used to account for problematic mixins (see #10402).
235+
+ if (Boolean.valueOf(false))
233236
this.m_213960_(blockstate, blockpos, p_46719_, p_46718_, false);
237+
+ blockstate.onNeighborChange(this, blockpos, p_46718_);
234238
}
235239
}
240+
}
236241
@@ -863,6 +_,18 @@
237242

238243
public BiomeManager m_7062_() {

src/main/java/net/minecraftforge/common/ForgeConfig.java

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public static class Server {
3434

3535
public final BooleanValue useItemWithDurationZero;
3636

37+
public final BooleanValue fixNeighborUpdateOrder;
38+
3739
Server(ForgeConfigSpec.Builder builder) {
3840
builder.comment("Server configuration settings")
3941
.push("server");
@@ -82,6 +84,11 @@ public static class Server {
8284
.translation("forge.configgui.useItemWithDurationZero")
8385
.define("useItemWithDurationZero", false);
8486

87+
fixNeighborUpdateOrder = builder
88+
.comment("Set this to true to fix the neighbor update order to match vanilla.")
89+
.translation("forge.configgui.fixNeighborUpdateOrder")
90+
.define("fixNeighborUpdateOrder", false);
91+
8592
builder.pop();
8693
}
8794

src/main/resources/assets/forge/lang/en_us.json

+2
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@
189189
"forge.configgui.showLoadWarnings": "Show Load Warnings",
190190
"forge.configgui.allowMipmapLowering.tooltip": "When enabled, Forge will allow mipmaps to be lowered in real-time. This is the default behavior in vanilla. Use this if you experience issues with resource packs that use textures lower than 8x8.",
191191
"forge.configgui.allowMipmapLowering": "Allow mipmap lowering",
192+
"forge.configgui.fixNeighborUpdateOrder": "Fix Neighbor Update Order",
193+
"forge.configgui.fixNeighborUpdateOrder.tooltip": "Set this to true to fix the neighbor update order to match vanilla.",
192194

193195
"forge.configgui.disableVersionCheck.tooltip": "Set to true to disable Forge version check mechanics. Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github.",
194196
"forge.configgui.disableVersionCheck": "Disable Forge Version Check",

0 commit comments

Comments
 (0)