mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-21 15:01:35 +01:00
Fix some rails connecting improperly
This commit is contained in:
parent
5f6808db9a
commit
07d11145d9
@ -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;
|
@ -8,17 +8,25 @@
|
|||||||
|
|
||||||
public class DetectorRailBlock extends BaseRailBlock {
|
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<AbstractMinecart> list = this.getInteractingMinecartOfType(world, pos, AbstractMinecart.class, (entity) -> {
|
||||||
|
@@ -88,7 +90,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState iblockdata1;
|
BlockState iblockdata1;
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (flag != flag1) {
|
+ if (flag != flag1) {
|
||||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
|
+ 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);
|
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 15 : 0, flag1 ? 15 : 0);
|
||||||
+ world.getCraftServer().getPluginManager().callEvent(eventRedstone);
|
+ world.getCraftServer().getPluginManager().callEvent(eventRedstone);
|
||||||
+
|
|
||||||
+ flag1 = eventRedstone.getNewCurrent() > 0;
|
+ flag1 = eventRedstone.getNewCurrent() > 0;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
@ -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<BlockPos> 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
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user