Too slippery

- Sliding on contraptions now takes its slope into account
- Gantry Carriages are now less prone to break when moved near other blocks
This commit is contained in:
simibubi 2021-04-01 17:43:39 +02:00
parent c21a8bcbde
commit 6c942be7f5
3 changed files with 18 additions and 7 deletions

View file

@ -285,13 +285,16 @@ public class ContraptionCollider {
}
if (bounce == 0 && slide > 0 && hasNormal && anyCollision && rotation.hasVerticalRotation()) {
Vec3d motionIn = entityMotionNoTemporal.mul(0, 1, 0)
double slideFactor = collisionNormal.mul(1, 0, 1)
.length() * 1.25f;
Vec3d motionIn = entityMotionNoTemporal.mul(0, .9, 0)
.add(0, -.01f, 0);
Vec3d slideNormal = collisionNormal.crossProduct(motionIn.crossProduct(collisionNormal))
.normalize();
entity.setMotion(entityMotion.mul(.8, 0, .8)
.add(slideNormal.scale((.2f + slide) * motionIn.length())
.add(0, -0.1, 0)));
Vec3d newMotion = entityMotion.mul(.85, 0, .85)
.add(slideNormal.scale((.2f + slide) * motionIn.length() * slideFactor)
.add(0, -.1f - collisionNormal.y * .125f, 0));
entity.setMotion(newMotion);
entityMotion = entity.getMotion();
}

View file

@ -43,7 +43,7 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
super.updateNeighbors(stateIn, worldIn, pos, flags);
withTileEntityDo(worldIn, pos, GantryCarriageTileEntity::checkValidGantryShaft);
}
@Override
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) {
super.onBlockAdded(state, worldIn, pos, oldState, isMoving);
@ -82,9 +82,10 @@ public class GantryCarriageBlock extends DirectionalAxisKineticBlock implements
}
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, BlockPos p_220069_5_,
public void neighborChanged(BlockState state, World world, BlockPos pos, Block p_220069_4_, BlockPos updatePos,
boolean p_220069_6_) {
if (!isValidPosition(state, world, pos))
if (updatePos.equals(pos.offset(state.get(FACING)
.getOpposite())) && !isValidPosition(state, world, pos))
world.destroyBlock(pos, true);
}

View file

@ -36,6 +36,13 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp
if (shouldAssemble())
queueAssembly();
}
@Override
public void initialize() {
super.initialize();
if (!getBlockState().isValidPosition(world, pos))
world.destroyBlock(pos, true);
}
public void queueAssembly() {
assembleNextTick = true;