From 07d11145d9a67b50ba60b1fb53c8aa3295de4298 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Fri, 24 Jul 2020 15:56:05 -0700 Subject: [PATCH] Fix some rails connecting improperly --- .../level/block/BaseRailBlock.java.patch | 10 ++++ .../level/block/DetectorRailBlock.java.patch | 14 +++-- .../world/level/block/RailState.java.patch | 52 +++++++++++++++++++ 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/BaseRailBlock.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BaseRailBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BaseRailBlock.java.patch new file mode 100644 index 0000000000..9e6c76abd9 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BaseRailBlock.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/block/BaseRailBlock.java ++++ b/net/minecraft/world/level/block/BaseRailBlock.java +@@ -71,6 +71,7 @@ + state = this.updateDir(world, pos, state, true); + if (this.isStraight) { + world.neighborChanged(state, pos, this, null, notify); ++ state = world.getBlockState(pos); // Paper - Fix some rails connecting improperly + } + + return state; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch index c5172657fa..625192a8e8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch @@ -8,17 +8,25 @@ public class DetectorRailBlock extends BaseRailBlock { -@@ -88,7 +89,17 @@ +@@ -77,6 +78,7 @@ + + private void checkPressed(Level world, BlockPos pos, BlockState state) { + if (this.canSurvive(state, world, pos)) { ++ if (state.getBlock() != this) { return; } // Paper - Fix some rails connecting improperly + boolean flag = (Boolean) state.getValue(DetectorRailBlock.POWERED); + boolean flag1 = false; + List list = this.getInteractingMinecartOfType(world, pos, AbstractMinecart.class, (entity) -> { +@@ -88,7 +90,17 @@ } BlockState iblockdata1; + // CraftBukkit start + if (flag != flag1) { + org.bukkit.block.Block block = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); - ++ + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 15 : 0, flag1 ? 15 : 0); + world.getCraftServer().getPluginManager().callEvent(eventRedstone); -+ + + flag1 = eventRedstone.getNewCurrent() > 0; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch new file mode 100644 index 0000000000..b79bfb5efd --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RailState.java.patch @@ -0,0 +1,52 @@ +--- a/net/minecraft/world/level/block/RailState.java ++++ b/net/minecraft/world/level/block/RailState.java +@@ -17,6 +17,12 @@ + private final boolean isStraight; + private final List connections = Lists.newArrayList(); + ++ // Paper start - Fix some rails connecting improperly ++ public boolean isValid() { ++ return this.level.getBlockState(this.pos).getBlock() == this.state.getBlock(); ++ } ++ // Paper end - Fix some rails connecting improperly ++ + public RailState(Level world, BlockPos pos, BlockState state) { + this.level = world; + this.pos = pos; +@@ -141,6 +147,11 @@ + } + + private void connectTo(RailState placementHelper) { ++ // Paper start - Fix some rails connecting improperly ++ if (!this.isValid() || !placementHelper.isValid()) { ++ return; ++ } ++ // Paper end - Fix some rails connecting improperly + this.connections.add(placementHelper.pos); + BlockPos blockPos = this.pos.north(); + BlockPos blockPos2 = this.pos.south(); +@@ -331,10 +342,15 @@ + this.state = this.state.setValue(this.block.getShapeProperty(), railShape2); + if (forceUpdate || this.level.getBlockState(this.pos) != this.state) { + this.level.setBlock(this.pos, this.state, 3); ++ // Paper start - Fix some rails connecting improperly ++ if (!this.isValid()) { ++ return this; ++ } ++ // Paper end - Fix some rails connecting improperly + + for (int i = 0; i < this.connections.size(); i++) { + RailState railState = this.getRail(this.connections.get(i)); +- if (railState != null) { ++ if (railState != null && railState.isValid()) { // Paper - Fix some rails connecting improperly + railState.removeSoftConnections(); + if (railState.canConnectTo(this)) { + railState.connectTo(this); +@@ -347,6 +363,6 @@ + } + + public BlockState getState() { +- return this.state; ++ return this.level.getBlockState(this.pos); // Paper - Fix some rails connecting improperly + } + }