mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 20:30:28 +01:00
9889c651ce
I managed to move it, yet forgot to actually fix it up...
96 lines
5.0 KiB
Diff
96 lines
5.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
|
Date: Fri, 24 Jul 2020 15:56:05 -0700
|
|
Subject: [PATCH] Fix some rails connecting improperly
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BlockMinecartDetector.java b/src/main/java/net/minecraft/world/level/block/BlockMinecartDetector.java
|
|
index 61c4a57174237f5f77d841bb2274ace6297db8a4..27573a0334b06f4b6ada672057695d8f8a2bcfc4 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/BlockMinecartDetector.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BlockMinecartDetector.java
|
|
@@ -71,6 +71,7 @@ public class BlockMinecartDetector extends BlockMinecartTrackAbstract {
|
|
|
|
private void a(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
|
if (this.canPlace(iblockdata, world, blockposition)) {
|
|
+ if (iblockdata.getBlock() != this) { return; } // Paper - not our block, don't do anything
|
|
boolean flag = (Boolean) iblockdata.get(BlockMinecartDetector.POWERED);
|
|
boolean flag1 = false;
|
|
List<EntityMinecartAbstract> list = this.a(world, blockposition, EntityMinecartAbstract.class, (Predicate) null);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BlockMinecartTrackAbstract.java b/src/main/java/net/minecraft/world/level/block/BlockMinecartTrackAbstract.java
|
|
index f65a53347f26affd1ce8d79527a6486e6bf8fbdd..0545dd68ea1f0a27739fac1a358c7def849e6b6a 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/BlockMinecartTrackAbstract.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BlockMinecartTrackAbstract.java
|
|
@@ -62,6 +62,7 @@ public abstract class BlockMinecartTrackAbstract extends Block {
|
|
iblockdata = this.a(world, blockposition, iblockdata, true);
|
|
if (this.c) {
|
|
iblockdata.doPhysics(world, blockposition, this, blockposition, flag);
|
|
+ iblockdata = world.getType(blockposition); // Paper - don't desync, update again
|
|
}
|
|
|
|
return iblockdata;
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/MinecartTrackLogic.java b/src/main/java/net/minecraft/world/level/block/MinecartTrackLogic.java
|
|
index 8a8e3af0290a9483ee59d5fab061a9a9f5613f0a..436cfcde89aa780bcd58150f6167a365d8d955bc 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/MinecartTrackLogic.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/MinecartTrackLogic.java
|
|
@@ -12,13 +12,19 @@ import net.minecraft.world.level.block.state.properties.BlockPropertyTrackPositi
|
|
|
|
public class MinecartTrackLogic {
|
|
|
|
- private final World a;
|
|
- private final BlockPosition b;
|
|
+ private final World a; public final World getWorld() { return this.a; } // Paper - OBFHELPER
|
|
+ private final BlockPosition b; public final BlockPosition getPos() { return this.b; } // Paper - OBFHELPER
|
|
private final BlockMinecartTrackAbstract c;
|
|
- private IBlockData d;
|
|
+ private IBlockData d; public final IBlockData getRailState() { return this.d; } // Paper - OBFHELPER
|
|
private final boolean e;
|
|
private final List<BlockPosition> f = Lists.newArrayList();
|
|
|
|
+ // Paper start - prevent desync
|
|
+ public boolean isValid() {
|
|
+ return this.getWorld().getType(this.getPos()).getBlock() == this.getRailState().getBlock();
|
|
+ }
|
|
+ // Paper end - prevent desync
|
|
+
|
|
public MinecartTrackLogic(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
|
this.a = world;
|
|
this.b = blockposition;
|
|
@@ -153,6 +159,11 @@ public class MinecartTrackLogic {
|
|
}
|
|
|
|
private void c(MinecartTrackLogic minecarttracklogic) {
|
|
+ // Paper start - prevent desync
|
|
+ if (!this.isValid() || !minecarttracklogic.isValid()) {
|
|
+ return;
|
|
+ }
|
|
+ // Paper end - prevent desync
|
|
this.f.add(minecarttracklogic.b);
|
|
BlockPosition blockposition = this.b.north();
|
|
BlockPosition blockposition1 = this.b.south();
|
|
@@ -347,11 +358,16 @@ public class MinecartTrackLogic {
|
|
this.d = (IBlockData) this.d.set(this.c.d(), blockpropertytrackposition1);
|
|
if (flag1 || this.a.getType(this.b) != this.d) {
|
|
this.a.setTypeAndData(this.b, this.d, 3);
|
|
+ // Paper start - prevent desync
|
|
+ if (!this.isValid()) {
|
|
+ return this;
|
|
+ }
|
|
+ // Paper end - prevent desync
|
|
|
|
for (int i = 0; i < this.f.size(); ++i) {
|
|
MinecartTrackLogic minecarttracklogic = this.b((BlockPosition) this.f.get(i));
|
|
|
|
- if (minecarttracklogic != null) {
|
|
+ if (minecarttracklogic != null && minecarttracklogic.isValid()) { // Paper - prevent desync
|
|
minecarttracklogic.d();
|
|
if (minecarttracklogic.b(this)) {
|
|
minecarttracklogic.c(this);
|
|
@@ -364,6 +380,6 @@ public class MinecartTrackLogic {
|
|
}
|
|
|
|
public IBlockData c() {
|
|
- return this.d;
|
|
+ return this.getWorld().getType(this.getPos()); // Paper - prevent desync
|
|
}
|
|
}
|