Skip to content

Commit

Permalink
Merge branch '1.18.x/main' into 1.18.x/WoodType-Compat
Browse files Browse the repository at this point in the history
  • Loading branch information
millennIumAMbiguity committed Oct 28, 2024
2 parents 559c36f + 7caa63d commit d0e8ba7
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 161 deletions.
8 changes: 8 additions & 0 deletions changelogs/1.5.2-beta.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Additions
* Added french translation [#381](https://github.com/ValkyrienSkies/Eureka/pull/381)
* Added block tags for assembly blacklist [#413](https://github.com/ValkyrienSkies/Eureka/pull/413) *(tag available here `data/vs_eureka/tags/blocks/assemble_blacklist.json`)*
# Changes
* Stability decreases with high speed on low mass [#371](https://github.com/ValkyrienSkies/Eureka/pull/371)
* Cleansed the blacklist config [#413](https://github.com/ValkyrienSkies/Eureka/pull/413) *(for now the blacklist config is still supported, use blacklist block tag instead)*
# Fixes
* Improved fuel compatibility [#406](https://github.com/ValkyrienSkies/Eureka/pull/406)
107 changes: 7 additions & 100 deletions common/src/main/kotlin/org/valkyrienskies/eureka/EurekaConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ object EurekaConfig {

// Instability scaled with mass and squared speed
@JsonSchema(description = "Stronger stabilization with higher mass, less at higher speeds.")
var scaledInstability = 1000.0
var scaledInstability = 70.0

// Unscaled linear instability cased by speed
@JsonSchema(description = "Less stabilization at higher speed.")
var unscaledInstability = 0.271828
var unscaledInstability = 0.1

@JsonSchema(description = "How fast a ship will stop and accelerate.")
var linearMassScaling = 0.0002
Expand All @@ -151,104 +151,6 @@ object EurekaConfig {
@JsonSchema(description = "Chance for popped balloons to pop adjacent balloons, per side")
var popSideBalloonChance = 0.3

// Blacklist of blocks that don't get added for ship building
@JsonSchema(description = "Blacklist of blocks that don't get assembled")
var blockBlacklist = setOf(
"vs_eureka:ship_helm",
"minecraft:dirt",
"minecraft:grass_block",
"minecraft:grass_path",
"minecraft:stone",
"minecraft:bedrock",
"minecraft:sand",
"minecraft:gravel",
"minecraft:water",
"minecraft:flowing_water",
"minecraft:lava",
"minecraft:flowing_lava",
"minecraft:lily_pad",
"minecraft:coarse_dirt",
"minecraft:podzol",
"minecraft:granite",
"minecraft:diorite",
"minecraft:andesite",
"minecraft:deepslate",
"minecraft:tuff",
"minecraft:crimson_nylium",
"minecraft:warped_nylium",
"minecraft:red_sand",
"minecraft:sandstone",
"minecraft:end_stone",
"minecraft:red_sandstone",
"minecraft:blackstone",
"minecraft:netherrack",
"minecraft:soul_sand",
"minecraft:soul_soil",
"minecraft:grass",
"minecraft:fern",
"minecraft:dead_bush",
"minecraft:seagrass",
"minecraft:tall_seagrass",
"minecraft:sea_pickle",
"minecraft:kelp",
"minecraft:bamboo",
"minecraft:dandelion",
"minecraft:poppy",
"minecraft:blue_orchid",
"minecraft:allium",
"minecraft:azure_bluet",
"minecraft:red_tulip",
"minecraft:orange_tulip",
"minecraft:white_tulip",
"minecraft:pink_tulip",
"minecraft:oxeye_daisy",
"minecraft:cornflower",
"minecraft:lily_of_the_valley",
"minecraft:brown_mushroom",
"minecraft:red_mushroom",
"minecraft:crimson_fungus",
"minecraft:warped_fungus",
"minecraft:crimson_roots",
"minecraft:warped_roots",
"minecraft:nether_sprouts",
"minecraft:weeping_vines",
"minecraft:twisting_vines",
"minecraft:chorus_plant",
"minecraft:chorus_flower",
"minecraft:snow",
"minecraft:snow_block",
"minecraft:cactus",
"minecraft:vine",
"minecraft:sunflower",
"minecraft:lilac",
"minecraft:rose_bush",
"minecraft:peony",
"minecraft:tall_grass",
"minecraft:large_fern",
"minecraft:air",
"minecraft:ice",
"minecraft:packed_ice",
"minecraft:blue_ice",
"minecraft:portal",
"minecraft:bedrock",
"minecraft:end_portal_frame",
"minecraft:end_portal",
"minecraft:end_gateway",
"minecraft:portal",
"minecraft:oak_sapling",
"minecraft:spruce_sapling",
"minecraft:birch_sapling",
"minecraft:jungle_sapling",
"minecraft:acacia_sapling",
"minecraft:dark_oak_sapling",
"minecraft:oak_leaves",
"minecraft:spruce_leaves",
"minecraft:birch_leaves",
"minecraft:jungle_leaves",
"minecraft:acacia_leaves",
"minecraft:dark_oak_leaves"
)

@JsonSchema(description = "Whether the ship helm assembles diagonally connected blocks or not")
val diagonals = true

Expand All @@ -263,5 +165,10 @@ object EurekaConfig {

@JsonSchema(description = "Maximum number of blocks allowed in a ship. Set to 0 for no limit")
val maxShipBlocks = 32 * 32 * 32

// TODO: Remove blockBlacklist
// Blacklist of blocks that don't get added for ship building
@JsonSchema(description = "Blacklist of blocks that don't get assembled (Use Block Tag instead)")
var blockBlacklist : Set<String> = emptySet()
}
}
4 changes: 2 additions & 2 deletions common/src/main/kotlin/org/valkyrienskies/eureka/EurekaMod.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.valkyrienskies.eureka

import org.valkyrienskies.core.impl.config.VSConfigClass
import org.valkyrienskies.mod.common.ValkyrienSkiesMod

object EurekaMod {
const val MOD_ID = "vs_eureka"
Expand All @@ -13,7 +13,7 @@ object EurekaMod {
EurekaScreens.register()
EurekaEntities.register()
EurekaWeights.register()
VSConfigClass.registerConfig("vs_eureka", EurekaConfig::class.java)
ValkyrienSkiesMod.vsCore.registerConfigLegacy("vs_eureka", EurekaConfig::class.java)
}

@JvmStatic
Expand Down
11 changes: 0 additions & 11 deletions common/src/main/kotlin/org/valkyrienskies/eureka/EurekaWeights.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,10 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties
import org.valkyrienskies.core.apigame.world.chunks.BlockType
import org.valkyrienskies.mod.common.BlockStateInfo
import org.valkyrienskies.mod.common.BlockStateInfoProvider
import org.valkyrienskies.physics_api.Lod1BlockStateId
import org.valkyrienskies.physics_api.Lod1LiquidBlockStateId
import org.valkyrienskies.physics_api.Lod1SolidBlockStateId
import org.valkyrienskies.physics_api.voxel.Lod1LiquidBlockState
import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState

object EurekaWeights : BlockStateInfoProvider {
override val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>>
get() = emptyList()
override val liquidBlockStates: List<Lod1LiquidBlockState>
get() = emptyList()
override val priority: Int
get() = 200
override val solidBlockStates: List<Lod1SolidBlockState>
get() = emptyList()

override fun getBlockStateMass(blockState: BlockState): Double? {
if (blockState.block == EurekaBlocks.BALLAST.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import net.minecraft.world.damagesource.DamageSource
import net.minecraft.world.entity.Entity
import net.minecraft.world.entity.projectile.Projectile
import net.minecraft.world.level.Level
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.phys.BlockHitResult
Expand Down Expand Up @@ -48,7 +47,7 @@ class BalloonBlock(properties: Properties) : Block(properties) {
if (level.isClientSide) return

level.destroyBlock(hit.blockPos, false)
Direction.values().forEach {
Direction.entries.forEach {
val neighbor = hit.blockPos.relative(it)
if (level.getBlockState(neighbor).block == this &&
level.random.nextFloat() < EurekaConfig.SERVER.popSideBalloonChance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import net.minecraft.core.Registry
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.TextComponent
import net.minecraft.network.chat.TranslatableComponent
import net.minecraft.resources.ResourceLocation
import net.minecraft.server.level.ServerLevel
import net.minecraft.tags.TagKey
import net.minecraft.world.MenuProvider
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.entity.player.Player
import net.minecraft.world.inventory.AbstractContainerMenu
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.HorizontalDirectionalBlock
import net.minecraft.world.level.block.StairBlock
import net.minecraft.world.level.block.entity.BlockEntity
Expand All @@ -23,9 +26,9 @@ import org.joml.Vector3d
import org.joml.Vector3dc
import org.valkyrienskies.core.api.ships.ServerShip
import org.valkyrienskies.core.api.ships.getAttachment
import org.valkyrienskies.core.impl.util.logger
import org.valkyrienskies.eureka.EurekaBlockEntities
import org.valkyrienskies.eureka.EurekaConfig
import org.valkyrienskies.eureka.EurekaMod
import org.valkyrienskies.eureka.block.ShipHelmBlock
import org.valkyrienskies.eureka.gui.shiphelm.ShipHelmScreenMenu
import org.valkyrienskies.eureka.ship.EurekaShipControl
Expand All @@ -35,6 +38,10 @@ import org.valkyrienskies.mod.common.entity.ShipMountingEntity
import org.valkyrienskies.mod.common.getShipObjectManagingPos
import org.valkyrienskies.mod.common.util.toDoubles
import org.valkyrienskies.mod.common.util.toJOMLD
import org.valkyrienskies.mod.util.logger

var ASSEMBLE_BLACKLIST: TagKey<Block> =
TagKey.create(Registry.BLOCK_REGISTRY, ResourceLocation(EurekaMod.MOD_ID, "assemble_blacklist"))

class ShipHelmBlockEntity(pos: BlockPos, state: BlockState) :
BlockEntity(EurekaBlockEntities.SHIP_HELM.get(), pos, state), MenuProvider {
Expand Down Expand Up @@ -122,14 +129,26 @@ class ShipHelmBlockEntity(pos: BlockPos, state: BlockState) :
val blockState = level.getBlockState(blockPos)
if (blockState.block !is ShipHelmBlock) return

var helmCount = 0
val builtShip = ShipAssembler.collectBlocks(
level,
blockPos
) { !it.isAir && !EurekaConfig.SERVER.blockBlacklist.contains(Registry.BLOCK.getKey(it.block).toString()) }
) {
val allowed = !it.isAir && !it.`is`(ASSEMBLE_BLACKLIST) &&
// TODO: Remove blockBlacklist
!(EurekaConfig.SERVER.blockBlacklist.isNotEmpty() && EurekaConfig.SERVER.blockBlacklist.contains(Registry.BLOCK.getKey(it.block).toString()))
// This isn't the best way to count helms, but it'll work I promise!
if (allowed && it.block is ShipHelmBlock) {
helmCount++
}
return@collectBlocks allowed
}

if (builtShip == null) {
player.sendMessage(TextComponent("Ship is too big! Max size is ${EurekaConfig.SERVER.maxShipBlocks} blocks (changeable in the config)"), Util.NIL_UUID)
logger.warn("Failed to assemble ship for ${player.name.string}")
} else {
EurekaShipControl.getOrCreate(builtShip).helms = helmCount
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.valkyrienskies.core.api.ships.ServerTickListener
import org.valkyrienskies.core.api.ships.ShipForcesInducer
import org.valkyrienskies.core.api.ships.getAttachment
import org.valkyrienskies.core.api.ships.saveAttachment
import org.valkyrienskies.core.impl.game.ships.PhysShipImpl
import org.valkyrienskies.eureka.EurekaConfig
import org.valkyrienskies.mod.api.SeatedControllingPlayer
import org.valkyrienskies.mod.common.util.toJOMLD
Expand Down Expand Up @@ -92,13 +91,11 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
// Disable fluid drag when helms are present, because it makes ships hard to drive
physShip.doFluidDrag = EurekaConfig.SERVER.doFluidDrag

physShip as PhysShipImpl

val ship = ship ?: return
val mass = physShip.inertia.shipMass
val moiTensor = physShip.inertia.momentOfInertiaTensor
val omega: Vector3dc = physShip.poseVel.omega
val vel: Vector3dc = physShip.poseVel.vel
val mass = physShip.mass
val moiTensor = physShip.momentOfInertia
val omega: Vector3dc = physShip.omega
val vel: Vector3dc = physShip.velocity
val balloonForceProvided = balloons * forcePerBalloon

val buoyantFactorPerFloater = min(
Expand All @@ -123,7 +120,7 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {

// region Aligning

val invRotation = physShip.poseVel.rot.invert(Quaterniond())
val invRotation = physShip.transform.shipToWorldRotation.invert(Quaterniond())
val invRotationAxisAngle = AxisAngle4d(invRotation)
// Floor makes a number 0 to 3, which corresponds to direction
val alignTarget = floor((invRotationAxisAngle.angle / (PI * 0.5)) + 4.5).toInt() % 4
Expand Down Expand Up @@ -233,16 +230,16 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
return currentControlData
}

private fun applyPlayerControl(control: ControlData, physShip: PhysShipImpl) {
private fun applyPlayerControl(control: ControlData, physShip: PhysShip) {

val ship = ship ?: return
val transform = physShip.transform
val aabb = ship.worldAABB
val center = transform.positionInWorld

// region Player controlled rotation
val moiTensor = physShip.inertia.momentOfInertiaTensor
val omega: Vector3dc = physShip.poseVel.omega
val moiTensor = physShip.momentOfInertia
val omega: Vector3dc = physShip.omega

val largestDistance = run {
var dist = center.distance(aabb.minX(), center.y(), aabb.minZ())
Expand Down Expand Up @@ -277,42 +274,42 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {
physShip.applyInvariantForce(getPlayerForwardVel(control, physShip))
}

private fun getPlayerControlledBanking(control: ControlData, physShip: PhysShipImpl, moiTensor: Matrix3dc, strength: Double): Vector3d {
private fun getPlayerControlledBanking(control: ControlData, physShip: PhysShip, moiTensor: Matrix3dc, strength: Double): Vector3d {
val rotationVector = control.seatInDirection.normal.toJOMLD()
physShip.poseVel.transformDirection(rotationVector)
physShip.transform.shipToWorldRotation.transform(rotationVector)
rotationVector.y = 0.0
rotationVector.mul(strength * 1.5)

physShip.poseVel.rot.transform(
physShip.transform.shipToWorldRotation.transform(
moiTensor.transform(
physShip.poseVel.rot.transformInverse(rotationVector)
physShip.transform.shipToWorldRotation.transformInverse(rotationVector)
)
)

return rotationVector
}

// Player controlled forward and backward thrust
private fun getPlayerForwardVel(control: ControlData, physShip: PhysShipImpl): Vector3d {
private fun getPlayerForwardVel(control: ControlData, physShip: PhysShip): Vector3d {

val scaledMass = physShip.inertia.shipMass * EurekaConfig.SERVER.speedMassScale
val vel: Vector3dc = physShip.poseVel.vel
val scaledMass = physShip.mass * EurekaConfig.SERVER.speedMassScale
val vel: Vector3dc = physShip.velocity

// region Player controlled forward and backward thrust
val forwardVector = control.seatInDirection.normal.toJOMLD()
physShip.poseVel.rot.transform(forwardVector)
physShip.transform.shipToWorldRotation.transform(forwardVector)
forwardVector.normalize()

val s = 1 / smoothingATanMax(
EurekaConfig.SERVER.linearMaxMass,
physShip.inertia.shipMass * EurekaConfig.SERVER.linearMassScaling + EurekaConfig.SERVER.linearBaseMass
physShip.mass * EurekaConfig.SERVER.linearMassScaling + EurekaConfig.SERVER.linearBaseMass
)

val maxSpeed = EurekaConfig.SERVER.linearMaxSpeed / 15
oldSpeed = max(min(oldSpeed * (1 - s) + control.forwardImpulse.toDouble() * s, maxSpeed), -maxSpeed)
forwardVector.mul(oldSpeed)

val playerUpDirection = physShip.poseVel.transformDirection(Vector3d(0.0, 1.0, 0.0))
val playerUpDirection = physShip.transform.shipToWorldRotation.transform(Vector3d(0.0, 1.0, 0.0))
val velOrthogonalToPlayerUp = vel.sub(playerUpDirection.mul(playerUpDirection.dot(vel)), Vector3d())

// This is the speed that the ship is always allowed to go out, without engines
Expand All @@ -321,8 +318,8 @@ class EurekaShipControl : ShipForcesInducer, ServerTickListener {

if (extraForceLinear != 0.0) {
// engine boost
val boost = max((extraForceLinear - EurekaConfig.SERVER.enginePowerLinear * EurekaConfig.SERVER.engineBoostOffset) * EurekaConfig.SERVER.engineBoost, 0.0);
extraForceLinear += boost + boost * boost * EurekaConfig.SERVER.engineBoostExponentialPower;
val boost = max((extraForceLinear - EurekaConfig.SERVER.enginePowerLinear * EurekaConfig.SERVER.engineBoostOffset) * EurekaConfig.SERVER.engineBoost, 0.0)
extraForceLinear += boost + boost * boost * EurekaConfig.SERVER.engineBoostExponentialPower

// This is the maximum speed we want to go in any scenario (when not sprinting)
val idealForwardVel = Vector3d(forwardVector).mul(EurekaConfig.SERVER.maxCasualSpeed)
Expand Down
Loading

0 comments on commit d0e8ba7

Please sign in to comment.