[needs testing] Fix linear actuator offset logic and fix clamps to be of more logical value #8838
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Known issues
none atm
This is a three part fix
clamp(getSpeed(), -.49, .49)
around the code base forLinearActuatorBlockEntity
MechanicalPistonBlockEntity
GantryShaftBlockEntity
Collectively, these affect:
PulleyBlockEntity
extends LinearActuatorBEMechanicalPistonBlockEntity
extends LinearActuatorBE#getMovementSpeedGantryShaftBlockEntity
has its own clampHowever, this clamp affects rpms above 250 because
convertToLinear
divides rpm by 512, which means0.49 * 512 = 250.88
.Slightly related, but this 0.49 clamp is also responsible for the incorrect block speed in the fandom wiki as they used
(0.49 * 20) / 256 = 0.03828125
https://create.fandom.com/wiki/Gantry_Carriage
However, this clamp value did not make sense, so I changed it to 1 (as in maximum movement speed is 1 blocks per tick), and any value above 1 was unstable from my testing.
Create/src/main/java/com/simibubi/create/content/contraptions/piston/LinearActuatorBlockEntity.java
Lines 317 to 325 in e0c859a
where the code uses a newOffset, offset pair
Create/src/main/java/com/simibubi/create/content/contraptions/piston/LinearActuatorBlockEntity.java
Lines 124 to 130 in e0c859a
Create/src/main/java/com/simibubi/create/content/contraptions/ContraptionCollider.java
Lines 715 to 719 in e0c859a
Removing this check seems to produce correct behaviorThis is incorrect behavior. Imagine a contraption that is perfectly aligned with the world. It intersects only one block, not two. this is because positive direction requires
ceil
while negative direction requiresfloor
. This pr implements the ceil partI have tested RPMS up to 512 by changing the game config and rope pulleys, mechanical pistons, and gantry carriages all worked fine up to 512RPM.
However, this PR includes a rather big line change in
ContraptionCollider
and I have not tested how the other contraptions will behave to this change.TL;DR: fixed offset logic which allows linear actuator contraptions to stop at the correct block, especially at high rpms, adjust clamp so that it scales linearly up to 512RPM instead of 250RPM, removed possibly broken check for contraption colliding
TL;DR 2: there were more bugs related to integer alignments, specifically when contraptions were exactly aligned with the block, causing 256rpm to not behave correctly with linear actuators. That has also been addressed