Skip to content

Commit

Permalink
Misc Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePlasticPotato committed Dec 28, 2024
1 parent 38dc79c commit fe7e250
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fe7e250

Please sign in to comment.