railcraft-reborn / railcraft

Redefine your rails
Other
83 stars 18 forks source link

Coupler track only decouple in powered state. #166

Closed vexxmage closed 7 months ago

vexxmage commented 7 months ago

The Issue Coupler track in decouple mode would decouble in an unpowerstate.

The Proposal Only decouple on powered state.

Possible Side Effects Uses may not be expecting the change.

Edivad99 commented 7 months ago

Thanks for discovering this bug. Instead of checking if the block is powered only when it is in decoupling mode, it is better to put the control for all. Move control here: https://github.com/railcraft-reborn/railcraft/blob/c6187b18c84de0cc696b3610bc0e3209dc955133/src/main/java/mods/railcraft/world/level/block/track/outfitted/CouplerTrackBlock.java#L71

if (this.isPowered(blockState, level, pos)) {
  level.getBlockEntity(pos, RailcraftBlockEntityTypes.COUPLER_TRACK.get())
      .ifPresent(lockingTrack -> lockingTrack.minecartPassed(cart));
}
vexxmage commented 7 months ago

Sorry I missed that. cheers.