From fe7e25030a3098c1e782269593548a15d5e23008 Mon Sep 17 00:00:00 2001 From: ThePlasticPotato Date: Sat, 28 Dec 2024 12:01:26 -0500 Subject: [PATCH] Misc Fixes --- .../valkyrienskies/mod/common/assembly/ShipAssembly.kt | 9 +++++---- .../mod/common/util/EntityDraggingInformation.kt | 4 +++- .../org/valkyrienskies/mod/common/util/EntityLerper.kt | 4 ++++ .../kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt | 2 +- gradle.properties | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt index 436aea8e6..24bfc05ad 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt @@ -19,6 +19,7 @@ import org.valkyrienskies.core.impl.game.ships.ShipData import org.valkyrienskies.core.impl.game.ships.ShipDataCommon import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet +import org.valkyrienskies.mod.api.vsApi import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.executeIf import org.valkyrienskies.mod.common.isTickingChunk @@ -93,7 +94,7 @@ fun createNewShipWithBlocks( // well now it doesnt kekw //(ship as ShipDataCommon).transform = (ship.transform).withTransformFrom(positionInWorld = centerBlockPosInWorld) - (ship as ShipDataCommon).setFromTransform(ship.transform.copy(position = centerBlockPosInWorld)) + (ship as ShipDataCommon).setFromTransform(vsApi.transformFactory.create(centerBlockPosInWorld, ship.transform.rotation, ship.transform.scaling, ship.transform.positionInShip)) level.server.executeIf( // This condition will return true if all modified chunks have been both loaded AND // chunk update packets were sent to players @@ -132,14 +133,14 @@ fun createNewShipWithStructure( blocks.placeInWorld(level, BlockPos(lowerCornerInShip.toMinecraft()), BlockPos(lowerCornerInShip.toMinecraft()), StructurePlaceSettings(), level.random, Block.UPDATE_ALL) val diff = higherCorner.subtract(lowerCorner) - val centerPos = lowerCorner.toJOMLD().add(diff.x / 2.0, diff.y / 2.0, diff.z / 2.0) + val centerPos = lowerCorner.toJOMLD().add(diff.x + 1 / 2.0, diff.y + 1 / 2.0, diff.z + 1 / 2.0) // The ship's position has shifted from the center block since we assembled the ship, compensate for that val centerBlockPosInWorld = ship.inertiaData.centerOfMass.sub(centerPos, Vector3d()) .add(ship.transform.positionInWorld) // Put the ship into the compensated position, so that all the assembled blocks stay in the same place level.shipObjectWorld - .teleportShip(ship, ShipTeleportDataImpl(newPos = centerBlockPosInWorld.add(0.0, 0.0, 0.0, Vector3d()), newPosInShip = ship.inertiaData.centerOfMass)) + .teleportShip(ship, ShipTeleportDataImpl(newPos = centerBlockPosInWorld.add(0.5, 128.5 - centerBlockPosInWorld.y, 0.5, Vector3d()), newPosInShip = ship.inertiaData.centerOfMass)) for (x in lowerCorner.x..higherCorner.x) { @@ -149,7 +150,7 @@ fun createNewShipWithStructure( val blockEntity: BlockEntity? = level.getBlockEntity(BlockPos(x, y, z)) Clearable.tryClear(blockEntity) level.removeBlockEntity(BlockPos(x, y, z)) - level.setBlock(BlockPos(x, y, z), Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS) + level.getChunk(x,z).setBlockState(BlockPos(x,y,z), org.valkyrienskies.mod.util.AIR, false) //level.getChunk(BlockPos(x, y, z)).setBlockState(BlockPos(x, y, z), Blocks.AIR.defaultBlockState(), false) } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt index 915f9a0d3..974e1e5e1 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt @@ -10,9 +10,11 @@ import org.valkyrienskies.core.api.ships.properties.ShipId class EntityDraggingInformation { var addedMovementLastTick: Vector3dc = Vector3d() var addedYawRotLastTick: Double = 0.0 + var changedShipLastTick = false var lastShipStoodOn: ShipId? = null set(value) { ticksSinceStoodOnShip = 0 + changedShipLastTick = field != value && field != null field = value } var ticksSinceStoodOnShip: Int = 0 @@ -57,7 +59,7 @@ class EntityDraggingInformation { companion object { // Max number of ticks we will drag an entity after the entity has jumped off the ship - private const val TICKS_TO_DRAG_ENTITIES = 40 + private const val TICKS_TO_DRAG_ENTITIES = 25 } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityLerper.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityLerper.kt index 53562a0fb..50574d973 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityLerper.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityLerper.kt @@ -22,6 +22,10 @@ object EntityLerper { } val ship = refship as ClientShip if (dragInfo.lerpSteps > 0) { + if (dragInfo.changedShipLastTick) { + dragInfo.lerpSteps = 1 + dragInfo.changedShipLastTick = false + } val currentX: Double = dragInfo.relativePositionOnShip?.x() ?: return val currentY: Double = dragInfo.relativePositionOnShip!!.y() val currentZ: Double = dragInfo.relativePositionOnShip!!.z() diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt b/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt index 068c55533..d06cc44d2 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.chunk.LevelChunk import org.valkyrienskies.core.api.ships.ServerShip -private val AIR = Blocks.AIR.defaultBlockState() +val AIR = Blocks.AIR.defaultBlockState() /** * Relocate block diff --git a/gradle.properties b/gradle.properties index d8a3d4c91..c2be7df06 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-i-build.1598+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+774ec4e001 +vs_core_version=1.1.0+36a4890e15 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false