Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Fixed camera jitter while on chair
Browse files Browse the repository at this point in the history
  • Loading branch information
Tri0de committed Dec 19, 2020
1 parent ccde3fb commit fced720
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void readSpawnData(ByteBuf additionalData) {
}
}

Optional<BlockPos> getReferencePos() {
public Optional<BlockPos> getReferencePosOptional() {
return Optional.ofNullable(referencePos);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public EntityMountableChair(World world, Vec3d mountPos,

@Override
public void onUpdate() {
if (!getReferencePos().isPresent()) {
if (!getReferencePosOptional().isPresent()) {
// Some error occurred, kill this chair.
new IllegalStateException("Chair mountable entity has no reference position.")
.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.valkyrienskies.mod.common.collision.PhysPolygonCollider;
import org.valkyrienskies.mod.common.collision.Polygon;
import org.valkyrienskies.mod.common.collision.ShipPolygon;
import org.valkyrienskies.mod.common.entity.EntityMountable;
import org.valkyrienskies.mod.common.entity.EntityShipMovementData;
import org.valkyrienskies.mod.common.ships.ShipData;
import org.valkyrienskies.mod.common.ships.ship_transform.ShipTransform;
Expand All @@ -42,6 +43,7 @@
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class EntityCollisionInjector {

Expand Down Expand Up @@ -259,6 +261,19 @@ public static IntermediateMovementVariableStorage alterEntityMovement(Entity ent
entity.setEntityBoundingBox(axisalignedbb);
entity.resetPositionToBB();

// We are on the ship that we are riding
if (entity.ridingEntity instanceof EntityMountable) {
final EntityMountable entityMountable = (EntityMountable) entity.ridingEntity;
if (entityMountable.getReferencePosOptional().isPresent()) {
final Optional<PhysicsObject> physicsObjectOptional = ValkyrienUtils.getPhysoManagingBlock(
entity.world, entityMountable.getReferencePosOptional().get()
);
if (physicsObjectOptional.isPresent()) {
worldBelow = physicsObjectOptional.get();
}
}
}

if (worldBelow == null) {
return null;
}
Expand Down

0 comments on commit fced720

Please sign in to comment.