Skip to content

Commit 5aaacc4

Browse files
Merge branch '1.19.2/main' into 1.20.1/main
2 parents 66d7711 + 331adfe commit 5aaacc4

File tree

9 files changed

+110
-51
lines changed

9 files changed

+110
-51
lines changed

changelogs/1.5.4-beta.1.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Additions
2+
* Allow floaters and balloons on non eureka ships to function. [95eabc9](https://github.com/ValkyrienSkies/Eureka/commit/95eabc914f2463bec933ae00f196dcd70152d197)
3+
* Added config `AllowFloatersAndBalloonsOnNonEurekaShips` default value true.
4+
* Added config `PassiveBallonMinHeight` default value 64.
5+
* Added config `PassiveBallonMaxHeight ` default value 400.
6+
# Changes
7+
* Remove duplicate linearBaseSpeed config. [13c5899](https://github.com/ValkyrienSkies/Eureka/commit/13c5899e305346046a293e82a852e95934038b59)
8+
* `baseSpeed` was removed.
9+
* `linearCasualSpeed` was renamed to `linearBaseSpeed` to make it clearer.
10+
* Floater buoyancy changes [38e7940](https://github.com/ValkyrienSkies/Eureka/commit/38e79406cad6ae1436ccf8bcddfcaf0489531506)
11+
* Renamed `floaterBuoyantFactorPerKg` to `floaterBuoyantLift`, set its default value to `2000` from `3333` (scaled), and removed a "divide by 15" instruction from it.
12+
* Default `maxFloaterBuoyantFactor` changed from `1.0` to `0.1`
13+
* Allow seats to be 0.5 blocks below the helm. [99f5ce0](https://github.com/ValkyrienSkies/Eureka/commit/99f5ce0081cd239af680ac66b83e8bc52fa4f608)
14+
# Fixes
15+
* Fixed maxBalloonsPerEngine not working while player is on helm. [13c5899](https://github.com/ValkyrienSkies/Eureka/commit/13c5899e305346046a293e82a852e95934038b59)
16+
* Fixed mod-icon missing from fabric [5f50e26](https://github.com/ValkyrienSkies/Eureka/commit/5f50e260f997f0ff96d5ad59b30306d60af136b4)

common/src/main/java/org/valkyrienskies/eureka/mixin/client/PlayerEntityModelMixin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public void setupAnim(final T livingEntity,
2828
final CallbackInfo info) {
2929
final Entity vehicle = livingEntity.getVehicle();
3030
if (vehicle instanceof ShipMountingEntity) {
31-
if (vehicle.level().getBlockState(vehicle.blockPosition()).isAir()) {
31+
var pos = vehicle.position();
32+
if (Math.abs((pos.x + .5) % 1.0) < .05 && Math.abs((pos.z + .5) % 1.0) < .05) {
3233
this.riding = false;
3334
}
3435
}

common/src/main/kotlin/org/valkyrienskies/eureka/EurekaConfig.kt

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,23 @@ object EurekaConfig {
5959
val engineBoostExponentialPower = 0.000001
6060

6161
@JsonSchema(description = "Max speed of a ship with engines (actual max speed varies with engines and mass.)")
62-
val maxSpeedFromEngines = 16.0
62+
val maxSpeedFromEngines = 12.0
6363

6464
@JsonSchema(description = "Max reverse speed of a ship with engines")
65-
val maxReverseSpeedFromEngines = 8.0
65+
val maxReverseSpeedFromEngines = 5.0
6666

6767
@JsonSchema(description = "The speed at which the ship stabilizes")
6868
var stabilizationSpeed = 10.0
6969

70-
@JsonSchema(description = "The amount extra that each floater will make the ship float, per kg mass")
71-
var floaterBuoyantFactorPerKg = 50_000.0
70+
@JsonSchema(description = "How how much force is Kg each floater supports")
71+
var floaterBuoyantLift = 2_000.0
7272

7373
@JsonSchema(description = "The maximum amount extra each floater will multiply the buoyant force by, irrespective of mass")
74-
var maxFloaterBuoyantFactor = 1.0
74+
var maxFloaterBuoyantFactor = 0.1
7575

7676
@JsonSchema(description = "how much the mass decreases the speed.")
7777
var speedMassScale = 1.0
7878

79-
// The velocity any ship at least can move at.
80-
@JsonSchema(description = "The speed a ship with no engines can move at")
81-
var baseSpeed = 3.0
82-
8379
// Sensitivity of the up/down impulse buttons.
8480
// TODO maybe should be moved to VS2 client-side config?
8581
@JsonSchema(description = "Vertical sensitivity when ascending")
@@ -95,6 +91,15 @@ object EurekaConfig {
9591
@JsonSchema(description = "Ascend and descend acceleration")
9692
var elevationSnappiness = 1.0
9793

94+
@JsonSchema(description = "Allows ships without a helm (passive ships) to use floaters and balloons")
95+
var AllowFloatersAndBalloonsOnNonEurekaShips = true
96+
97+
@JsonSchema(description = "The height where balloons starts to loose effectiveness on ships without a helm")
98+
var PassiveBallonMinHeight = 64.0
99+
100+
@JsonSchema(description = "The height where balloons effectiveness is zero on ships without a helm")
101+
var PassiveBallonMaxHeight = 400.0
102+
98103
// Allow Eureka controlled ships to be affected by fluid drag
99104
@JsonSchema(description = "Allow Eureka controlled ships to be affected by fluid drag")
100105
var doFluidDrag = false
@@ -141,12 +146,12 @@ object EurekaConfig {
141146
@JsonSchema(description = "Base mass for linear acceleration in Kg.")
142147
var linearBaseMass = 50.0
143148

144-
//when value is same as linearMaxMass, actual value will be 1/3. actual value will be close to linearMaxMass when 5 times over
145-
@JsonSchema(description = "Max smoothing value, will smooth out before reaching max value.")
149+
// when value is same as linearMaxMass. actual value will be close to linearMaxMass when 5 times over
150+
@JsonSchema(description = "Max mass for the linear stabilisation, will smooth out before reaching max value.")
146151
var linearMaxMass = 10000.0
147152

148153
@JsonSchema(description = "Max unscaled speed in m/s without engines.")
149-
var linearCasualSpeed = 3.0
154+
var linearBaseSpeed = 3.0
150155

151156
// Anti-velocity mass relevance when stopping the ship
152157
// Max 10.0 (means no mass irrelevance)

common/src/main/kotlin/org/valkyrienskies/eureka/block/ShipHelmBlock.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import org.valkyrienskies.eureka.blockentity.ShipHelmBlockEntity
3030
import org.valkyrienskies.eureka.ship.EurekaShipControl
3131
import org.valkyrienskies.eureka.util.DirectionalShape
3232
import org.valkyrienskies.eureka.util.RotShapes
33-
import org.valkyrienskies.mod.common.ValkyrienSkiesMod
33+
import org.valkyrienskies.mod.common.entity.ShipMountingEntity
3434
import org.valkyrienskies.mod.common.getShipManagingPos
3535
import org.valkyrienskies.mod.common.getShipObjectManagingPos
3636
import java.awt.TextComponent
@@ -63,7 +63,7 @@ class ShipHelmBlock(properties: Properties, val woodType: IWoodType) : BaseEntit
6363

6464
level.getShipManagingPos(pos)?.getAttachment<EurekaShipControl>()?.let { control ->
6565

66-
if (control.helms <= 1 && control.seatedPlayer?.vehicle?.type == ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE) {
66+
if (control.helms <= 1 && control.seatedPlayer?.vehicle is ShipMountingEntity) {
6767
control.seatedPlayer!!.unRide()
6868
control.seatedPlayer = null
6969
}

common/src/main/kotlin/org/valkyrienskies/eureka/blockentity/ShipHelmBlockEntity.kt

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import net.minecraft.world.level.block.entity.BlockEntity
2020
import net.minecraft.world.level.block.state.BlockState
2121
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
2222
import net.minecraft.world.level.block.state.properties.Half
23+
import net.minecraft.world.phys.Vec3
2324
import org.joml.Vector3d
2425
import org.joml.Vector3dc
2526
import org.valkyrienskies.core.api.ships.ServerShip
@@ -63,20 +64,36 @@ class ShipHelmBlockEntity(pos: BlockPos, state: BlockState) :
6364
fun spawnSeat(blockPos: BlockPos, state: BlockState, level: ServerLevel): ShipMountingEntity {
6465
val newPos = blockPos.relative(state.getValue(HorizontalDirectionalBlock.FACING))
6566
val newState = level.getBlockState(newPos)
66-
val newShape = newState.getShape(level, newPos)
67-
val newBlock = newState.block
68-
var height = 0.5
67+
var height = 0.0
6968
if (!newState.isAir) {
7069
height = if (
71-
newBlock is StairBlock &&
70+
newState.block is StairBlock &&
7271
(!newState.hasProperty(StairBlock.HALF) || newState.getValue(StairBlock.HALF) == Half.BOTTOM)
7372
)
7473
0.5 // Valid StairBlock
7574
else
76-
newShape.max(Axis.Y)
75+
newState.getShape(level, newPos).max(Axis.Y)
76+
} else {
77+
val stateBelow = level.getBlockState(BlockPos(newPos.x, newPos.y - 1, newPos.z))
78+
79+
// If block below expected seat is valid slab or stair, move seat down one block
80+
val shapeHeight = stateBelow.getShape(level, newPos).max(Axis.Y)
81+
// if block is slab or higher
82+
if (shapeHeight >= 0.5 && shapeHeight < 1.0) {
83+
height = shapeHeight - 1.0
84+
}
7785
}
86+
7887
val entity = ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE.create(level)!!.apply {
79-
val seatEntityPos: Vector3dc = Vector3d(newPos.x + .5, (newPos.y - .5) + height, newPos.z + .5)
88+
89+
val offset =
90+
if (height > 0.15)
91+
// when seated, place player 0.1m closer to helm
92+
state.getValue(HorizontalDirectionalBlock.FACING).normal.toDoubles().scale(-0.1).add(.5, height - .5, .5)
93+
else
94+
Vec3(.5, height + 0.1, .5)
95+
96+
val seatEntityPos: Vector3dc = Vector3d(newPos.x + offset.x, newPos.y + offset.y, newPos.z + offset.z)
8097
moveTo(seatEntityPos.x(), seatEntityPos.y(), seatEntityPos.z())
8198

8299
lookAt(

common/src/main/kotlin/org/valkyrienskies/eureka/ship/EurekaShipControl.kt

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
8686
if (helms < 1) {
8787
// Enable fluid drag if all the helms have been destroyed
8888
physShip.doFluidDrag = true
89+
90+
if (EurekaConfig.SERVER.AllowFloatersAndBalloonsOnNonEurekaShips) {
91+
val mass = physShip.mass
92+
val velY = physShip.velocity.y()
93+
94+
var balloonForce = getBalloonForce()
95+
// balloon force 100% at y 100, 0% at y 320
96+
// the "velY * 10" reduces bobbing by sampling the height position in the future
97+
balloonForce *= 1 - Math.clamp(0.0, 1.0, (physShip.transform.positionInWorld.y() + velY * 10 - EurekaConfig.SERVER.PassiveBallonMinHeight) / (EurekaConfig.SERVER.PassiveBallonMaxHeight - EurekaConfig.SERVER.PassiveBallonMinHeight))
98+
balloonForce = min(balloonForce, max(getIdealUpwardForce(EurekaConfig.SERVER.balloonElevationMaxSpeed, velY, mass), 0.0))
99+
physShip.applyInvariantForce(Vector3d(0.0, balloonForce, 0.0))
100+
101+
physShip.buoyantFactor = getFloaterFactor(mass)
102+
}
103+
89104
return
90105
}
91106
// Disable fluid drag when helms are present, because it makes ships hard to drive
@@ -96,21 +111,8 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
96111
val moiTensor = physShip.momentOfInertia
97112
val omega: Vector3dc = physShip.omega
98113
val vel: Vector3dc = physShip.velocity
99-
var balloonForceProvided = balloons * forcePerBalloon
100114

101-
if (EurekaConfig.SERVER.maxBalloonsPerEngine > 0) {
102-
balloonForceProvided *= min(
103-
1.0,
104-
( extraForceLinear * EurekaConfig.SERVER.maxBalloonsPerEngine ) / ( EurekaConfig.SERVER.enginePowerLinear * balloons )
105-
)
106-
}
107-
108-
val buoyantFactorPerFloater = min(
109-
EurekaConfig.SERVER.floaterBuoyantFactorPerKg / 15.0 / mass,
110-
EurekaConfig.SERVER.maxFloaterBuoyantFactor
111-
)
112-
113-
physShip.buoyantFactor = 1.0 + floaters * buoyantFactorPerFloater
115+
physShip.buoyantFactor = getFloaterFactor(mass)
114116

115117
// region Aligning
116118

@@ -189,12 +191,8 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
189191
idealUpwardVel = getPlayerUpwardVel(control, mass)
190192
}
191193

192-
// region Elevation
193-
val idealUpwardForce = (idealUpwardVel.y() - vel.y() - (GRAVITY / EurekaConfig.SERVER.elevationSnappiness)) *
194-
mass * EurekaConfig.SERVER.elevationSnappiness
195-
196194
physShip.applyInvariantForce(Vector3d(0.0,
197-
min(balloonForceProvided, max(idealUpwardForce, 0.0)) +
195+
min(getBalloonForce(), max(getIdealUpwardForce(idealUpwardVel.y(), vel.y(), mass), 0.0)) +
198196
// Add drag to the y-component
199197
vel.y() * -mass,
200198
0.0)
@@ -204,6 +202,30 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
204202
physShip.isStatic = anchored
205203
}
206204

205+
private fun getBalloonForce(): Double {
206+
// Disable if maxBalloonsPerEngine <= 0
207+
if (EurekaConfig.SERVER.maxBalloonsPerEngine > 0) {
208+
// remove power from unpowered balloons
209+
return balloons * forcePerBalloon * min(
210+
1.0,
211+
// (currentTotalEnginePower * maxBalloonsPerEngine) / (enginePowerAtMaxHeat * balloonsCount)
212+
( extraForceLinear * EurekaConfig.SERVER.maxBalloonsPerEngine ) / ( EurekaConfig.SERVER.enginePowerLinear * balloons )
213+
)
214+
}
215+
return balloons * forcePerBalloon
216+
}
217+
218+
private fun getFloaterFactor(mass: Double): Double {
219+
return 1.0 + floaters * min(
220+
EurekaConfig.SERVER.floaterBuoyantLift / mass,
221+
EurekaConfig.SERVER.maxFloaterBuoyantFactor
222+
)
223+
}
224+
225+
private fun getIdealUpwardForce(idealUpwardVelY: Double, velY: Double, mass: Double): Double {
226+
return (idealUpwardVelY - velY - (GRAVITY / EurekaConfig.SERVER.elevationSnappiness)) * mass * EurekaConfig.SERVER.elevationSnappiness
227+
}
228+
207229
private fun getControlData(player: SeatedControllingPlayer): ControlData {
208230

209231
val currentControlData = ControlData.create(player)
@@ -300,28 +322,26 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
300322
)
301323

302324
oldSpeed = oldSpeed * (1 - s) + control.forwardImpulse.toDouble() * s // from -1 to 1.
303-
var speed = oldSpeed * EurekaConfig.SERVER.linearCasualSpeed / 3 // 1 unit -> 3m/s
325+
var speed = oldSpeed * EurekaConfig.SERVER.linearBaseSpeed
304326

305327
if (extraForceLinear != 0.0) {
306328
// engine boost
307-
val boost = max((extraForceLinear - EurekaConfig.SERVER.enginePowerLinear * EurekaConfig.SERVER.engineBoostOffset) * EurekaConfig.SERVER.engineBoost, 0.0)
308-
extraForceLinear += boost + boost * boost * EurekaConfig.SERVER.engineBoostExponentialPower
309-
extraForceLinear /= scaledMass
329+
var boost = max((extraForceLinear - EurekaConfig.SERVER.enginePowerLinear * EurekaConfig.SERVER.engineBoostOffset) * EurekaConfig.SERVER.engineBoost, 0.0)
330+
boost = extraForceLinear + boost + boost * boost * EurekaConfig.SERVER.engineBoostExponentialPower
331+
boost /= scaledMass
310332

311333
speed += if (speed < 0) {
312-
smoothingATanMax(EurekaConfig.SERVER.maxReverseSpeedFromEngines, extraForceLinear * oldSpeed)
334+
smoothingATanMax(EurekaConfig.SERVER.maxReverseSpeedFromEngines, boost * oldSpeed)
313335
} else {
314-
smoothingATanMax(EurekaConfig.SERVER.maxSpeedFromEngines, extraForceLinear * oldSpeed)
336+
smoothingATanMax(EurekaConfig.SERVER.maxSpeedFromEngines, boost * oldSpeed)
315337
}
316338
}
317339

318-
forwardVector.mul(speed)
319-
320340
val playerUpDirection = physShip.transform.shipToWorldRotation.transform(Vector3d(0.0, 1.0, 0.0))
321341
val velOrthogonalToPlayerUp = vel.sub(playerUpDirection.mul(playerUpDirection.dot(vel)), Vector3d())
322342

323343
// This is the speed that the ship is always allowed to go out, without engines
324-
val baseForwardVel = forwardVector.mul(EurekaConfig.SERVER.baseSpeed)
344+
val baseForwardVel = forwardVector.mul(speed)
325345
val forwardForce = baseForwardVel.sub(velOrthogonalToPlayerUp).mul(scaledMass)
326346

327347
return forwardForce

fabric/src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"issues": "https://github.com/ValkyrienSkies/Eureka/issues"
2222
},
2323
"license": "Apache-2.0",
24-
"icon": "assets/vs_eureka/icon.png",
24+
"icon": "icon.png",
2525
"environment": "*",
2626
"entrypoints": {
2727
"main": [

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G
22
# Identity
33
mod_name=eureka
44
mod_id=vs_eureka
5-
eureka_version=1.5.3-beta.3
5+
eureka_version=1.5.4-beta.3
66
enabled_platforms=fabric,forge
77
archives_base_name=eureka-1201
88
maven_group=org.valkyrienskies

0 commit comments

Comments
 (0)