Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4ff5100
test ballooner code
PriestOfFern Oct 26, 2024
8a6053b
Fixed sussy gas function i think maybe probably
ThePlasticPotato Oct 26, 2024
87174de
Fixed position i think
ThePlasticPotato Oct 27, 2024
2d662ed
Triple to Vector3i
ThePlasticPotato Oct 27, 2024
b62247f
Experimental duct network heat changes
ThePlasticPotato Nov 1, 2024
200c17c
it booms
ThePlasticPotato Nov 1, 2024
170580e
minor fix to null error
PriestOfFern Nov 9, 2024
0b13bcb
minor logging + oops fix
PriestOfFern Nov 9, 2024
770fd0c
Improve DuctNetworkImpl comments for better readability
PriestOfFern Nov 10, 2024
2199ea1
Fix formula being slightly wrong
PriestOfFern Nov 10, 2024
4e842c8
fix another formula being wrong
PriestOfFern Nov 10, 2024
67740f1
The great volume extinction of '84
PriestOfFern Nov 11, 2024
e7155bc
Anti-volumification: Electric bogaloo
PriestOfFern Nov 11, 2024
7d7307b
Network stability achieved!
ThePlasticPotato Nov 26, 2024
e61906b
Gas nozzle updates
ThePlasticPotato Nov 26, 2024
4e4a1a8
a
ThePlasticPotato Nov 26, 2024
876c999
Fix null pointer exception
PriestOfFern Nov 26, 2024
dfa381a
Fix gas nozzle shaft facing rotation
PriestOfFern Nov 26, 2024
1c081ec
Gas Nozzle Dial rendering
PriestOfFern Nov 26, 2024
c74dcb6
New formulas, leaking start, issue with NaN to be resolved
ThePlasticPotato Nov 27, 2024
dc3e7fc
merge conflicts smh
ThePlasticPotato Nov 27, 2024
76e5732
Fix PocketForcesController Null pointer error
PriestOfFern Nov 27, 2024
ca03926
Big changes.
ThePlasticPotato Nov 28, 2024
293340c
Merge branch '1.18.x/main' into 1.18.x/bloon
ThePlasticPotato Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.valkyrienskies.clockwork

import org.valkyrienskies.clockwork.util.DoubleAvgAugmentation
import org.valkyrienskies.clockwork.util.DoubleAvgComponentAugmentation
import org.valkyrienskies.core.api.world.connectivity.DoubleAugmentation
import org.valkyrienskies.core.api.world.connectivity.DoubleComponentAugmentation
import org.valkyrienskies.core.apigame.world.ServerShipWorldCore
Expand All @@ -8,18 +10,26 @@ object ClockworkAugmentations {
private val augmentKeys: HashMap<String, DoubleAugmentation> = HashMap()
private val componentAugmentKeys: HashMap<String, DoubleComponentAugmentation> = HashMap()

fun registerAugmentation(key: String, shipObjectWorld: ServerShipWorldCore) {
fun registerSumAugmentation(key: String, shipObjectWorld: ServerShipWorldCore) {
augmentKeys[key] = shipObjectWorld.createDoubleSumAugmentation("clockwork", key)
}

fun registerAvgAugmentation(key: String, shipObjectWorld: ServerShipWorldCore) {
augmentKeys[key] = DoubleAvgAugmentation("clockwork:$key")
}

fun getAugmentation(key: String): DoubleAugmentation {
return augmentKeys[key] ?: error("No augmentation found with key $key")
}

fun registerComponentAugmentation(key: String, shipObjectWorld: ServerShipWorldCore) {
fun registerComponentSumAugmentation(key: String, shipObjectWorld: ServerShipWorldCore) {
componentAugmentKeys[key] = shipObjectWorld.createDoubleSumComponentAugmentation("clockwork", key)
}

fun registerComponentAvgAugmentation(key: String, shipObjectWorld: ServerShipWorldCore) {
componentAugmentKeys[key] = DoubleAvgComponentAugmentation("clockwork:$key")
}

fun getComponentAugmentation(key: String): DoubleComponentAugmentation {
return componentAugmentKeys[key] ?: error("No component augmentation found with key $key")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ package org.valkyrienskies.clockwork

import com.jozufozu.flywheel.api.MaterialManager
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance
import com.simibubi.create.AllBlocks
import com.simibubi.create.Create
import com.simibubi.create.content.fluids.pump.PumpBlockEntity
import com.tterrag.registrate.builders.BlockEntityBuilder
import com.tterrag.registrate.util.entry.BlockEntityEntry
import com.tterrag.registrate.util.nullness.NonNullFunction
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
Expand Down Expand Up @@ -46,6 +42,9 @@ import org.valkyrienskies.clockwork.content.logistics.gas.pump.PumpDuctBlockEnti
import org.valkyrienskies.clockwork.content.logistics.gas.pump.PumpDuctCogInstance
import org.valkyrienskies.clockwork.content.logistics.gas.pump.PumpDuctRenderer
import org.valkyrienskies.clockwork.content.logistics.gas.storage.tank.DuctTankBlockEntity
import org.valkyrienskies.clockwork.content.logistics.gas.pockets.nozzle.GasNozzleBlockEntity
import org.valkyrienskies.clockwork.content.logistics.gas.pockets.nozzle.GasNozzleInstance
import org.valkyrienskies.clockwork.content.logistics.gas.pockets.nozzle.GasNozzleRenderer
import java.util.function.BiFunction
import org.valkyrienskies.clockwork.content.logistics.solid.delivery.cannon.DeliveryCannonBlockEntity
import org.valkyrienskies.clockwork.content.logistics.solid.delivery.chute.DeliveryChuteBlockEntity
Expand Down Expand Up @@ -354,6 +353,33 @@ object ClockworkBlockEntities {
}
.register()

@JvmField
val GAS_NOZZLE: BlockEntityEntry<GasNozzleBlockEntity> = ClockworkMod.REGISTRATE
.blockEntity<GasNozzleBlockEntity>("gas_nozzle") { type: BlockEntityType<*>, pos: BlockPos, state: BlockState ->
GasNozzleBlockEntity(
type,
pos,
state
)
}
.instance {
BiFunction<MaterialManager?, GasNozzleBlockEntity?, BlockEntityInstance<in GasNozzleBlockEntity?>> { materialManager: MaterialManager?, blockEntity: GasNozzleBlockEntity? ->
GasNozzleInstance(
materialManager,
blockEntity
)
}
}
.validBlocks(ClockworkBlocks.GAS_NOZZLE)
.renderer {
NonNullFunction<BlockEntityRendererProvider.Context?, BlockEntityRenderer<in GasNozzleBlockEntity?>> { context: BlockEntityRendererProvider.Context? ->
GasNozzleRenderer(
context
)
}
}
.register()

@JvmField
val GOO_BLOCK = ClockworkMod.REGISTRATE.blockEntity<GooBlockEntity>("goo_block") { type: BlockEntityType<*>, pos: BlockPos, state: BlockState ->
GooBlockEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import net.minecraft.world.item.Item
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.level.block.SlabBlock
import net.minecraft.world.level.block.SoundType
import net.minecraft.world.level.block.StairBlock
import net.minecraft.world.level.block.entity.BlockEntityType
import net.minecraft.world.level.block.state.BlockBehaviour
Expand All @@ -35,6 +36,7 @@ import org.valkyrienskies.clockwork.content.contraptions.phys.infuser.PhysicsInf
import org.valkyrienskies.clockwork.content.contraptions.phys.slicker.GooBlock
import org.valkyrienskies.clockwork.content.contraptions.phys.slicker.SlickerBlock
import org.valkyrienskies.clockwork.content.contraptions.propeller.PropellerBearingBlock
import org.valkyrienskies.clockwork.content.kinetics.casing.ExtendedEncasedShaftBlock
import org.valkyrienskies.clockwork.content.curiosities.clock.ClockBlock
import org.valkyrienskies.clockwork.content.kinetics.resistor.RedstoneResistorBlock
import org.valkyrienskies.clockwork.content.kinetics.sequenced_seat.SequencedSeatBlock
Expand All @@ -49,6 +51,7 @@ import org.valkyrienskies.clockwork.content.logistics.solid.delivery.cannon.Deli
import org.valkyrienskies.clockwork.content.logistics.solid.delivery.cannon.DeliveryCannonBlockEntity
import org.valkyrienskies.clockwork.content.logistics.solid.delivery.chute.DeliveryChuteBlock
import org.valkyrienskies.clockwork.content.physicalities.ballast.BallastBlock
import org.valkyrienskies.clockwork.content.logistics.gas.pockets.nozzle.GasNozzleBlock
import org.valkyrienskies.clockwork.content.physicalities.wing.DyedWingBlockItem
import org.valkyrienskies.clockwork.content.physicalities.wing.FlapBlock
import org.valkyrienskies.clockwork.content.physicalities.wing.WingBlock
Expand Down Expand Up @@ -351,6 +354,21 @@ object ClockworkBlocks {
.transform(BlockStressDefaults.setImpact(4.0))
.register()

@JvmField
val GAS_NOZZLE: BlockEntry<GasNozzleBlock> =
REGISTRATE.block<GasNozzleBlock>("gas_nozzle") { properties: BlockBehaviour.Properties? ->
GasNozzleBlock(properties!!)
}
.initialProperties { SharedProperties.stone() }
.transform(TagGen.axeOrPickaxe())
.properties { it.noOcclusion() }
.addLayer { Supplier { RenderType.cutout() } }
.tag(AllTags.AllBlockTags.SAFE_NBT.tag)
.item()
.tab { ClockworkMod.BASE_CREATIVE_TAB }
.model(AssetLookup.customBlockItemModel("gas_nozzle"))
.build()
.register()

@JvmField
val GOO_BLOCK = REGISTRATE.block<GooBlock>("goo_block") { properties: BlockBehaviour.Properties? ->
Expand Down Expand Up @@ -548,6 +566,20 @@ object ClockworkBlocks {
.build()
.register()

@JvmField
val BALLOON_CASING = REGISTRATE.block<ExtendedEncasedShaftBlock>(
"balloon_casing"
) { properties: BlockBehaviour.Properties? ->
ExtendedEncasedShaftBlock.balloon(
properties!!
)
}
.initialProperties { SharedProperties.wooden() }
.item()
.tab { ClockworkMod.BASE_CREATIVE_TAB }
.build()
.register()

@JvmField
val CLOCK: BlockEntry<ClockBlock> = REGISTRATE.block<ClockBlock>(
"clock"
Expand Down Expand Up @@ -593,7 +625,6 @@ object ClockworkBlocks {
.build()
.register()


@JvmStatic
fun register() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ object ClockworkConfig {
@JsonSchema(description = "Max Gravitron mass in 1000 kg")
var maxGravitronMass = 256

@JsonSchema(description = "Force multiplier for balloons. Realism is 1.0, default is 10.0. Range: > 0.0", min = 0.0)
var balloonForceMult: Double = 10.0
@JsonSchema(description = "Force multiplier for balloons. Realism is 1.0, default is 100.0. Range: > 0.0", min = 0.0)
var balloonForceMult: Double = 100.0

@JsonSchema(description = "Leakage rate of pockets. Determines how fast pressure in an unsealed pocket attempts to 'normalize'. Default is 0.5.", min = 0.0, max = 1.0)
var pocketLeakageRate = 0.5
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.valkyrienskies.clockwork

import net.minecraft.world.damagesource.DamageSource

object ClockworkDamageSources {

@JvmStatic
val GAS_EXPLOSION = ClockworkDamageSource("gas_explosion")

@JvmStatic
val GAS_BURN = ClockworkDamageSource("gas_burn")

fun init() {
GAS_EXPLOSION.setExplosion()
}

class ClockworkDamageSource: DamageSource {
constructor(name: String) : super(name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.valkyrienskies.clockwork.content.forces.WanderShipControl
import org.valkyrienskies.clockwork.kelvin.api.DuctNetwork
import org.valkyrienskies.clockwork.kelvin.impl.DuctNetworkImpl
import org.valkyrienskies.clockwork.platform.PlatformUtils
import org.valkyrienskies.core.impl.config.VSConfigClass
import org.valkyrienskies.core.impl.hooks.VSEvents
import org.valkyrienskies.mod.common.ValkyrienSkiesMod
import org.valkyrienskies.mod.common.shipObjectWorld
Expand Down Expand Up @@ -43,7 +42,7 @@ object ClockworkMod {
ClockworkPackets.init()
ClockworkTags.init()
ClockworkWorldgen.init()

ClockworkDamageSources.init()
ValkyrienSkiesMod.vsCore.registerConfigLegacy("clockwork", ClockworkConfig::class.java)

VSEvents.ShipLoadEvent.on { event ->
Expand All @@ -61,10 +60,14 @@ object ClockworkMod {
}

LifecycleEvent.SERVER_STARTED.register {
ClockworkAugmentations.registerComponentAugmentation("temperature", it.shipObjectWorld)
ClockworkAugmentations.registerComponentAugmentation("gas_air", it.shipObjectWorld)
ClockworkAugmentations.registerComponentAugmentation("gas_phlogiston", it.shipObjectWorld)
ClockworkAugmentations.registerComponentAugmentation("gas_helium", it.shipObjectWorld)
ClockworkAugmentations.registerComponentAvgAugmentation("temperature", it.shipObjectWorld)
ClockworkAugmentations.registerComponentAvgAugmentation("pressure", it.shipObjectWorld)
ClockworkAugmentations.registerComponentSumAugmentation("gas_air", it.shipObjectWorld)
ClockworkAugmentations.registerComponentSumAugmentation("gas_phlogiston", it.shipObjectWorld)
ClockworkAugmentations.registerComponentSumAugmentation("gas_helium", it.shipObjectWorld)
//todo: gas registry
ClockworkAugmentations.registerComponentSumAugmentation("airupdated", it.shipObjectWorld)
ClockworkAugmentations.registerSumAugmentation("sealed", it.shipObjectWorld)
}

TickEvent.SERVER_LEVEL_POST.register {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.valkyrienskies.clockwork.content.logistics.gas.filter.FilterClosePack
import org.valkyrienskies.clockwork.content.logistics.gas.filter.FilterScreenOpenPacket
import org.valkyrienskies.clockwork.content.logistics.gas.generation.compressor.AirCompressorPacket
import org.valkyrienskies.clockwork.content.logistics.gas.generation.creative_generator.CreativeGeneratorPacket
import org.valkyrienskies.clockwork.content.logistics.gas.pockets.nozzle.GasNozzlePacket
import org.valkyrienskies.clockwork.content.logistics.solid.delivery.frequency_slot.UpdateFrequencySlotPacket
import org.valkyrienskies.clockwork.content.logistics.solid.delivery.cannon.DeliveryCannonSyncPacket
import org.valkyrienskies.clockwork.content.physicalities.wing.BlockEntityColorPacket
Expand Down Expand Up @@ -63,6 +64,7 @@ enum class ClockworkPackets(

UPDATE_DUCT_EDGE(DuctEdgeSyncPacket::class.java, ::DuctEdgeSyncPacket),
AIR_COMPRESSOR_PACKET(AirCompressorPacket::class.java, ::AirCompressorPacket),
GAS_NOZZLE_PACKET(GasNozzlePacket::class.java, ::GasNozzlePacket)


;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ object ClockworkPartials {

val PUMP_COG: PartialModel = AllPartialModels.MECHANICAL_PUMP_COG

val NOZZLE_DIAL: PartialModel = PartialModel(ClockworkMod.asResource("block/gas_nozzle/dial"))
val NOZZLE_AXIS: PartialModel = PartialModel(ClockworkMod.asResource("block/gas_nozzle/axis"))

val HAND_SECOND: PartialModel = PartialModel(ClockworkMod.asResource("block/clock/hand_second"))
val HAND_MINUTE: PartialModel = PartialModel(ClockworkMod.asResource("block/clock/hand_minute"))
val HAND_HOUR: PartialModel = PartialModel(ClockworkMod.asResource("block/clock/hand_hour"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.valkyrienskies.mod.common.util.toJOMLD
import org.valkyrienskies.mod.util.logger
import java.util.*
import java.util.concurrent.ConcurrentLinkedQueue
import kotlin.collections.HashMap

@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
class DragController : ShipForcesInducer {
Expand All @@ -48,6 +49,9 @@ class DragController : ShipForcesInducer {
@JsonIgnore
private var max_height: Double = 563.0

@JsonIgnore
private var lodDetail: Int = 5

override fun applyForces(physShip: PhysShip) {
val impl = physShip
if (blockUpdateQueue.isNotEmpty()) {
Expand Down Expand Up @@ -80,9 +84,10 @@ class DragController : ShipForcesInducer {
if (drag.isFinite && dragPos.isFinite) {
physShip.applyInvariantForceToPos(drag, dragPos)
}
if (rotDrag.isFinite) {
//dragLogger.info("Center of Pressure: $dragPos")
physShip.applyInvariantTorque(rotDrag)
for (rot in rotDrag) {
if (rot.value.isFinite) {
physShip.applyInvariantForceToPos(rot.value, rot.key)
}
}
}
}
Expand Down Expand Up @@ -256,31 +261,36 @@ class DragController : ShipForcesInducer {
return motionNormal.mul(dragForce, Vector3d())
}

private fun calculateRotationalDrag(ship: PhysShip): Vector3dc {
// val motionVector: Vector3dc = ship.poseVel.omega
// val motionNormal: Vector3dc = motionVector.normalize(Vector3d()).mul(-1.0)
//
// val density = getAirDensityForY(ship.poseVel.pos.y())
//
// var exposedArea = 0.0
//
// for (dir in Direction.values()) {
// val surfaceArea = surfaceAreaByDirection[dir]?: continue
// val dot = motionNormal.dot(dir.normal.toJOMLD())
// if (dot > 0) {
// exposedArea += surfaceArea * dot
// }
// }
//
// val dragForce = DRAG_COEFFICIENT * density * (motionVector.lengthSquared()/2.0) * exposedArea
//
// return motionNormal.mul(dragForce, Vector3d())
private fun calculateRotationalDrag(ship: PhysShip): Map<Vector3dc, Vector3dc> {
val rotationVector: Vector3dc = ship.omega

val density = getAirDensityForY(ship.transform.positionInWorld.y(), max_height)

val totalDragForce: HashMap<Vector3dc, Vector3dc> = HashMap()
val centersOfPressure: EnumMap<Direction, Vector3d> = EnumMap(net.minecraft.core.Direction::class.java)

for ((dir, faces) in exposedFaces.entries) {
if (faces.isEmpty()) continue
val centerOfPressure: Vector3d = Vector3d()
faces.forEach {
centerOfPressure.add(it.x().toDouble(), it.y().toDouble(), it.z().toDouble()).add(0.5, 0.5, 0.5)
.add(dir.normal.toJOMLD().mul(0.5, Vector3d()))
}
centerOfPressure.div(faces.size.toDouble())
centersOfPressure[dir] = centerOfPressure
}

//temporarily just *.99
var resistance = 0.02
for (dir in Direction.values()) {
val centerOfPressure = centersOfPressure[dir]?: continue
val distanceToCenter = centerOfPressure.sub(ship.transform.positionInShip)
val velocityVector : Vector3dc = rotationVector.cross(distanceToCenter, Vector3d())
val dot = velocityVector.normalize(Vector3d()).dot(dir.normal.toJOMLD())
if (dot < 0) continue
val dragForce = DRAG_COEFFICIENT * density * (velocityVector.lengthSquared()/2.0) * (surfaceAreaByDirection[dir]!! * dot)
totalDragForce[centerOfPressure] = velocityVector.normalize(Vector3d()).mul(-1.0).mul(dragForce, Vector3d())
}

return ship.omega.mul(ship.momentOfInertia, Vector3d())
.mul(-resistance)
return totalDragForce
}

private fun calculateDragPosition(ship: PhysShip): Vector3dc {
Expand Down
Loading