Skip to content

Commit

Permalink
Cleenup and fix for kotlinforforge version
Browse files Browse the repository at this point in the history
  • Loading branch information
millennIumAMbiguity committed Oct 10, 2023
1 parent 235d1b6 commit 8ed34f6
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
@Mixin(PlayerModel.class)
public abstract class PlayerEntityModelMixin<T extends LivingEntity> extends HumanoidModel<T> {

public PlayerEntityModelMixin(ModelPart $$0) {
super($$0);
public PlayerEntityModelMixin(final ModelPart model) {
super(model);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,4 @@ object EurekaBlocks {
items.register(it.name) { BlockItem(it.get(), Item.Properties().tab(EurekaItems.TAB)) }
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ object EurekaConfig {
@JsonSchema(description = "The maximum linear acceleration at any point on the ship caused by helm torque")
var turnAcceleration = 10.0

@JsonSchema(description = "The maximum distance from center of mass to one end of the ship considered by " +
@JsonSchema(
description = "The maximum distance from center of mass to one end of the ship considered by " +
"the turn speed. At it's default of 16, it ensures that really large ships will turn at the same " +
"speed as a ship with a center of mass only 16 blocks away from the farthest point in the ship. " +
"That way, large ships do not turn painfully slowly")
"That way, large ships do not turn painfully slowly"
)
var maxSizeForTurnSpeedPenalty = 16.0

// The strength used when trying to level the ship
Expand Down Expand Up @@ -214,6 +216,6 @@ object EurekaConfig {
val allowDisassembly = true

@JsonSchema(description = "Maximum number of blocks allowed in a ship. Set to 0 for no limit")
val maxShipBlocks = 32*32*32
val maxShipBlocks = 32 * 32 * 32
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.valkyrienskies.eureka

import org.valkyrienskies.core.impl.config.VSConfigClass


object EurekaMod {
const val MOD_ID = "vs_eureka"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ object EurekaWeights : BlockStateInfoProvider {
override fun getBlockStateMass(blockState: BlockState): Double? {
if (blockState.block == EurekaBlocks.BALLAST.get()) {
return EurekaConfig.SERVER.ballastWeight + (EurekaConfig.SERVER.ballastNoWeight - EurekaConfig.SERVER.ballastWeight) * (
(
blockState.getValue(
BlockStateProperties.POWER
) + 1
) / 16.0
)
(
blockState.getValue(
BlockStateProperties.POWER
) + 1
) / 16.0
)
}

return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ class ShipHelmBlock(properties: Properties, val woodType: WoodType) : BaseEntity
}

override fun isPathfindable(
blockState: BlockState,
blockGetter: BlockGetter,
blockPos: BlockPos,
pathComputationType: PathComputationType
blockState: BlockState,
blockGetter: BlockGetter,
blockPos: BlockPos,
pathComputationType: PathComputationType
): Boolean {
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import kotlin.math.ceil
import kotlin.math.max

class EngineBlockEntity(pos: BlockPos, state: BlockState) :
BaseContainerBlockEntity(EurekaBlockEntities.ENGINE.get(), pos, state), StackedContentsCompatible,
BaseContainerBlockEntity(EurekaBlockEntities.ENGINE.get(), pos, state),
StackedContentsCompatible,
WorldlyContainer {

private val ship: ServerShip? get() = (this.level as ServerLevel).getShipManagingPos(this.blockPos)
Expand Down Expand Up @@ -73,7 +74,6 @@ class EngineBlockEntity(pos: BlockPos, state: BlockState) :
if (!fuel.isEmpty && lastFuelValue <= EurekaConfig.SERVER.engineMinCapacity - fuelLeft) {
consumeFuel()
}

} else if (!fuel.isEmpty) {
consumeFuel()
}
Expand All @@ -91,7 +91,7 @@ class EngineBlockEntity(pos: BlockPos, state: BlockState) :
// Avoid fluctuations in speed
var effectiveHeat = 1f
if (heat < maxEffectiveFuel) {
effectiveHeat = heat / 100f;
effectiveHeat = heat / 100f
}

eurekaShipControl.power += lerp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ShipHelmBlockEntity(pos: BlockPos, state: BlockState) :

fun startRiding(player: Player, force: Boolean, blockPos: BlockPos, state: BlockState, level: ServerLevel): Boolean {

for (i in seats.size-1 downTo 0) {
for (i in seats.size - 1 downTo 0) {
if (!seats[i].isVehicle) {
seats[i].kill()
seats.removeAt(i)
Expand Down Expand Up @@ -128,7 +128,7 @@ class ShipHelmBlockEntity(pos: BlockPos, state: BlockState) :
blockPos
) { !it.isAir && !EurekaConfig.SERVER.blockBlacklist.contains(Registry.BLOCK.getKey(it.block).toString()) }

if (builtShip == null){
if (builtShip == null) {
player.sendMessage(TextComponent("Ship is too big! Max size is ${EurekaConfig.SERVER.maxShipBlocks} blocks (changable in the config)"), Util.NIL_UUID)
logger.warn("Failed to assemble ship for ${player.name.string}")
}
Expand Down Expand Up @@ -179,17 +179,15 @@ class ShipHelmBlockEntity(pos: BlockPos, state: BlockState) :

fun sit(player: Player, force: Boolean = false): Boolean {
// If player is already controlling the ship, open the helm menu
if (!force && player.vehicle?.type == ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE && seats.contains(player.vehicle as ShipMountingEntity))
{
if (!force && player.vehicle?.type == ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE && seats.contains(player.vehicle as ShipMountingEntity)) {
player.openMenu(this)
return true
}

//val seat = spawnSeat(blockPos, blockState, level as ServerLevel)
//control?.seatedPlayer = player
//return player.startRiding(seat, force)
// val seat = spawnSeat(blockPos, blockState, level as ServerLevel)
// control?.seatedPlayer = player
// return player.startRiding(seat, force)
return startRiding(player, force, blockPos, blockState, level as ServerLevel)

}
private val logger by logger()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class CreativeTabs {
.createCreativeTab(id, stack)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ interface DeferredRegister<T> : Iterable<RegistrySupplier<T>> {
.findFirst()
.orElseThrow { NullPointerException("Failed to load service for DeferredRegisterBackend") }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ interface RegistrySupplier<T> {

val name: String
fun get(): T

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import org.valkyrienskies.eureka.registry.DeferredRegister

interface DeferredRegisterBackend {
fun <T> makeDeferredRegister(id: String, registry: ResourceKey<Registry<T>>): DeferredRegister<T>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import net.minecraft.world.item.ItemStack

interface EurekaPlatformHelper {
fun createCreativeTab(id: ResourceLocation, stack: () -> ItemStack): CreativeModeTab
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class EurekaShipControl : ShipForcesInducer {
private var alignTarget = 0
val canDisassemble
get() = ship != null &&
disassembling &&
abs(angleUntilAligned) < DISASSEMBLE_THRESHOLD &&
positionUntilAligned.distanceSquared(this.ship!!.transform.positionInWorld) < 4.0
disassembling &&
abs(angleUntilAligned) < DISASSEMBLE_THRESHOLD &&
positionUntilAligned.distanceSquared(this.ship!!.transform.positionInWorld) < 4.0
val aligningTo: Direction get() = Direction.from2DDataValue(alignTarget)
var consumed = 0f
private set
Expand Down Expand Up @@ -104,7 +104,6 @@ class EurekaShipControl : ShipForcesInducer {
val vel: Vector3dc = physShip.poseVel.vel
val balloonForceProvided = balloons * forcePerBalloon


val buoyantFactorPerFloater = min(
EurekaConfig.SERVER.floaterBuoyantFactorPerKg / 15 / mass,
EurekaConfig.SERVER.maxFloaterBuoyantFactor
Expand Down Expand Up @@ -174,10 +173,10 @@ class EurekaShipControl : ShipForcesInducer {
// the player pressed the cruise button
isCruising = !isCruising
showCruiseStatus()
} else if (!player.cruise
&& isCruising
&& (player.leftImpulse != 0.0f || player.sprintOn || player.upImpulse != 0.0f || player.forwardImpulse != 0.0f)
&& currentControlData != controlData
} else if (!player.cruise &&
isCruising &&
(player.leftImpulse != 0.0f || player.sprintOn || player.upImpulse != 0.0f || player.forwardImpulse != 0.0f) &&
currentControlData != controlData
) {
// The player pressed another button
isCruising = false
Expand Down Expand Up @@ -214,7 +213,7 @@ class EurekaShipControl : ShipForcesInducer {

val maxLinearAcceleration = EurekaConfig.SERVER.turnAcceleration
val maxLinearSpeed = EurekaConfig.SERVER.turnSpeed +
extraForce / EurekaConfig.SERVER.enginePower * EurekaConfig.SERVER.engineTurnPower
extraForce / EurekaConfig.SERVER.enginePower * EurekaConfig.SERVER.engineTurnPower

// acceleration = alpha * r
// therefore: maxAlpha = maxAcceleration / r
Expand Down Expand Up @@ -289,9 +288,10 @@ class EurekaShipControl : ShipForcesInducer {
if (control.upImpulse != 0.0f) {
idealUpwardVel = Vector3d(0.0, 1.0, 0.0)
.mul(control.upImpulse.toDouble())
.mul(EurekaConfig.SERVER.baseImpulseElevationRate +
// Smoothing for how the elevation scales as you approaches the balloonElevationMaxSpeed
smoothing(2.0, EurekaConfig.SERVER.balloonElevationMaxSpeed, balloonForceProvided / mass)
.mul(
EurekaConfig.SERVER.baseImpulseElevationRate +
// Smoothing for how the elevation scales as you approaches the balloonElevationMaxSpeed
smoothing(2.0, EurekaConfig.SERVER.balloonElevationMaxSpeed, balloonForceProvided / mass)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ object RotShapes {
min(z1, z2) / 16,
max(x1, x2) / 16,
max(y1, y2) / 16,
max(z1, z2) / 16)
max(z1, z2) / 16
)
}

private class Union(val shapes: List<RotShape>) : RotShape {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ object ShipAssembler {
.translate(-positionInShip.x(), -positionInShip.y(), -positionInShip.z())
}


val alloc0 = Vector3d()

// Direction comes from direction ship is aligning to
Expand Down Expand Up @@ -180,7 +179,7 @@ object ShipAssembler {
return false
}
}
if (EurekaConfig.SERVER.maxShipBlocks > 0){
if (EurekaConfig.SERVER.maxShipBlocks > 0) {
logger.info("Assembled ship with ${blocks.size} blocks, out of ${EurekaConfig.SERVER.maxShipBlocks} allowed")
}
return true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.valkyrienskies.eureka.fabric;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.jvm.functions.Function0;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
Expand All @@ -8,26 +11,24 @@
import org.valkyrienskies.eureka.registry.DeferredRegister;
import org.valkyrienskies.eureka.registry.RegistrySupplier;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class DeferredRegisterImpl<T> implements DeferredRegister<T> {
private final String modId;
private final Registry<T> registry;
private final List<RegistrySupplier<T>> everMade = new ArrayList<>();

public DeferredRegisterImpl(String modId, ResourceKey<Registry<T>> registry) {
public DeferredRegisterImpl(final String modId, final ResourceKey<Registry<T>> registry) {
this.modId = modId;
this.registry = (Registry<T>) Registry.REGISTRY.get(registry.location());
}

@NotNull
@Override
public <I extends T> RegistrySupplier<I> register(@NotNull String name, @NotNull Function0<? extends I> builder) {
I result = Registry.register(registry, new ResourceLocation(modId, name), builder.invoke());
public <I extends T> RegistrySupplier<I> register(
@NotNull final String name,
@NotNull final Function0<? extends I> builder) {
final I result = Registry.register(registry, new ResourceLocation(modId, name), builder.invoke());

RegistrySupplier<I> r = new RegistrySupplier<I>() {
final RegistrySupplier<I> r = new RegistrySupplier<I>() {

@NotNull
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@ public void onInitializeClient() {
);

ModelLoadingRegistry.INSTANCE.registerModelProvider((manager, out) -> {
for (WoodType woodType : WoodType.values()) {
out.accept(new ResourceLocation(EurekaMod.MOD_ID, "block/" + woodType.getResourceName() + "_ship_helm_wheel"));
for (final WoodType woodType : WoodType.values()) {
out.accept(new ResourceLocation(
EurekaMod.MOD_ID,
"block/" + woodType.getResourceName() + "_ship_helm_wheel"
));
}
});

WheelModels.INSTANCE.setModelGetter(woodType ->
BakedModelManagerHelper.getModel(Minecraft.getInstance().getModelManager(),
new ResourceLocation(EurekaMod.MOD_ID, "block/" + woodType.getResourceName() + "_ship_helm_wheel")));
new ResourceLocation(
EurekaMod.MOD_ID,
"block/" + woodType.getResourceName() + "_ship_helm_wheel"
)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public class DeferredRegisterBackendFabric implements DeferredRegisterBackend {

@NotNull
@Override
public <T> DeferredRegister<T> makeDeferredRegister(@NotNull String id, @NotNull ResourceKey<Registry<T>> registry) {
public <T> DeferredRegister<T> makeDeferredRegister(
@NotNull final String id,
@NotNull final ResourceKey<Registry<T>> registry) {
return new DeferredRegisterImpl<>(id, registry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
public class EurekaPlatformHelperFabric implements EurekaPlatformHelper {
@NotNull
@Override
public CreativeModeTab createCreativeTab(@NotNull ResourceLocation id, @NotNull Function0<ItemStack> stack) {
public CreativeModeTab createCreativeTab(
@NotNull final ResourceLocation id,
@NotNull final Function0<ItemStack> stack) {
return FabricItemGroupBuilder.build(id, stack::invoke);
}
}
2 changes: 1 addition & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies {
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }

implementation 'thedarkcolour:kotlinforforge:3.12.0'
implementation("thedarkcolour:kotlinforforge:${rootProject.forge_kotlin_version}")
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ architectury_version=4.10.86
fabric_loader_version=0.14.10
fabric_api_version=0.59.0+1.18.2
forge_version=1.18.2-40.1.85
forge_kotlin_version=3.6.0
forge_kotlin_version=3.11.0
kotlin_version=1.9.10
cloth_config_version=6.4.90
# Maven publishing
Expand Down

0 comments on commit 8ed34f6

Please sign in to comment.