Skip to content

Commit

Permalink
aaaa
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-s168 committed Jan 16, 2024
1 parent d1f91e8 commit 749c185
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object TournamentConfig {
var propellerBigForce = 10000.0

@JsonSchema(description = "The max speed of a big propeller at max redstone input")
var propellerBigSpeed = 8.0f
var propellerBigSpeed = 7.0f

@JsonSchema(description = "The acceleration of a big propeller. (deaccel = accel * 2)")
var propellerBigAccel = 0.1f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class PropellerBlockEntity(
): BlockEntity(TournamentBlockEntities.PROPELLER.get(), pos, state) {

var signal: Int = -1
var rotation: Float = 0.0f
var speed: Float = 0.0f
var rotation: Double = 0.0
var speed: Double = 0.0

fun tick(level: Level) {
if (signal == -1) {
Expand All @@ -33,10 +33,10 @@ class PropellerBlockEntity(
speed -= accel * 2
}
if (speed < 0.0f) {
speed = 0.0f
speed = 0.0
}
rotation += speed
rotation %= 360.0f
rotation -= speed
rotation %= 360.0
}

companion object {
Expand All @@ -54,16 +54,16 @@ class PropellerBlockEntity(
ClientboundBlockEntityDataPacket.create(this)

override fun saveAdditional(tag: CompoundTag) {
tag.putFloat("speed", speed)
tag.putFloat("rotation", rotation)
tag.putDouble("speed", speed)
tag.putDouble("rotation", rotation)
tag.putInt("signal", signal)

super.saveAdditional(tag)
}

override fun load(tag: CompoundTag) {
speed = tag.getFloat("speed")
rotation = tag.getFloat("rotation")
speed = tag.getDouble("speed")
rotation = tag.getDouble("rotation")
signal = tag.getInt("signal")

super.load(tag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PropellerBlockEntityRender:
pose.pose {
translate(0.5, 0.5, 0.5)
mulPose(be.blockState.getValue(DirectionalBlock.FACING).opposite.rotation)
pose.mulPose(Vector3f.YP.rotationDegrees(be.rotation))
pose.mulPose(Vector3f.YP.rotationDegrees(be.rotation.toFloat()))
translate(-0.5, -0.5, -0.5)
TournamentModels.PROP_BIG.renderer.render(
pose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package org.valkyrienskies.tournament.ship

import com.fasterxml.jackson.annotation.JsonAutoDetect
import com.fasterxml.jackson.annotation.JsonIgnore
import com.google.common.util.concurrent.AtomicDouble
import net.minecraft.core.BlockPos
import net.minecraft.resources.ResourceKey
import net.minecraft.world.level.Level
import net.minecraft.world.phys.AABB
import org.joml.Vector3d
import org.joml.Vector3i
import org.joml.primitives.AABBd
import org.valkyrienskies.core.api.ships.*
import org.valkyrienskies.core.apigame.world.properties.DimensionId
import org.valkyrienskies.core.impl.game.ships.PhysShipImpl
Expand Down Expand Up @@ -52,7 +53,7 @@ class TournamentShips: ShipForcesInducer {
data class PropellerData(
val pos: Vector3i,
val force: Vector3d,
var speed: Float,
var speed: AtomicDouble,
var touchingWater: Boolean
)

Expand Down Expand Up @@ -80,6 +81,7 @@ class TournamentShips: ShipForcesInducer {
}

propellers.forEach { p ->
// TODO: check if water is on the outside if big propeller
val water = lvl.isWaterAt(
Helper3d
.convertShipToWorldSpace(lvl, p.pos.toDouble())
Expand All @@ -94,7 +96,7 @@ class TournamentShips: ShipForcesInducer {
) as PropellerBlockEntity?

if (be != null) {
p.speed = be.speed
p.speed.set(be.speed)
}
}
}
Expand All @@ -113,9 +115,9 @@ class TournamentShips: ShipForcesInducer {
val tPos = pos.toDouble().add(0.5, 0.5, 0.5).sub(physShip.transform.positionInShip)

if (force.isFinite && (
TournamentConfig.SERVER.thrusterShutoffSpeed == -1.0
|| physShip.poseVel.vel.length() < TournamentConfig.SERVER.thrusterShutoffSpeed
)
TournamentConfig.SERVER.thrusterShutoffSpeed == -1.0
|| physShip.poseVel.vel.length() < TournamentConfig.SERVER.thrusterShutoffSpeed
)
) {
physShip.applyInvariantForceToPos(tForce.mul(TournamentConfig.SERVER.thrusterSpeed * tier), tPos)
}
Expand Down Expand Up @@ -172,7 +174,7 @@ class TournamentShips: ShipForcesInducer {
val tPos = pos.toDouble().add(0.5, 0.5, 0.5).sub(physShip.transform.positionInShip)
val tForce = physShip.transform.shipToWorld.transformDirection(force, Vector3d())

physShip.applyInvariantForceToPos(tForce.mul(speed.toDouble()), tPos)
physShip.applyInvariantForceToPos(tForce.mul(speed.get()), tPos)
}
}

Expand Down Expand Up @@ -231,7 +233,7 @@ class TournamentShips: ShipForcesInducer {
}

fun addPropeller(pos: Vector3i, force: Vector3d) {
propellers.add(PropellerData(pos, force, 0.0f, false))
propellers += PropellerData(pos, force, AtomicDouble(), false)
}

fun removePropeller(pos: Vector3i) {
Expand Down

0 comments on commit 749c185

Please sign in to comment.