Skip to content

Commit

Permalink
Fix stock stuck on pitch rounding errors
Browse files Browse the repository at this point in the history
This also fixes stock breaking unexpected blocks on slopes
  • Loading branch information
cam72cam committed Dec 14, 2023
1 parent 4e438de commit cdaaa44
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ public Configuration(EntityCoupleableRollingStock stock) {
width = stock.getDefinition().getWidth(gauge);
length = stock.getDefinition().getLength(gauge);
height = stock.getDefinition().getHeight(gauge);
double pitchOffset = (Math.abs(Math.sin(Math.toRadians(stock.getRotationPitch())) * length));
bounds = s -> stock.getDefinition().getBounds(s.yaw, gauge)
.offset(s.position.add(0, -(s.position.y % 1) - (Math.abs(Math.sin(Math.toRadians(stock.getRotationPitch())) * length)), 0))
.offset(s.position.add(0, -(s.position.y % 1) - pitchOffset, 0))
.contract(new Vec3d(0, 0, 0.5 * gauge.scale()));
//.contract(new Vec3d(0, 0.5 * this.gauge.scale(), 0))
//.offset(new Vec3d(0, 0.5 * this.gauge.scale(), 0));
Expand Down Expand Up @@ -286,8 +287,10 @@ public void calculateBlockCollisions(List<Vec3i> blocksAlreadyBroken) {
trackToUpdate.add(bp);
} else {
if (Config.ConfigDamage.TrainsBreakBlocks && !BlockUtil.isIRRail(config.world, bp.up())) {
interferingBlocks.add(bp);
interferingResistance += config.world.getBlockHardness(bp);
if (bp.y >= position.y - (position.y % 1)) { // Prevent it from breaking blocks under the pitched train (bb expanded)
interferingBlocks.add(bp);
interferingResistance += config.world.getBlockHardness(bp);
}
}
}
}
Expand Down

0 comments on commit cdaaa44

Please sign in to comment.