-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/kotlin/cc/tweaked_programs/partnership/main/compat/boatism/BoatismCompat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package cc.tweaked_programs.partnership.main.compat.boatism | ||
|
||
import net.minecraft.world.entity.Entity | ||
import net.minecraft.world.entity.vehicle.Boat | ||
|
||
|
||
open class BoatismCompat { | ||
open fun isEngine(entity: Entity): Boolean = false | ||
open fun calculateThrust(boat: Boat): Float = 0.0f | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/cc/tweaked_programs/partnership/main/compat/boatism/BoatismImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
package cc.tweaked_programs.partnership.main.compat.boatism | ||
|
||
import net.minecraft.world.entity.Entity | ||
import net.minecraft.world.entity.vehicle.Boat | ||
import net.shirojr.boatism.entity.custom.BoatEngineEntity | ||
import net.shirojr.boatism.util.BoatEngineCoupler | ||
import net.shirojr.boatism.util.EntityHandler | ||
import java.util.* | ||
import kotlin.jvm.optionals.getOrNull | ||
|
||
class BoatismImpl : BoatismCompat() { | ||
override fun isEngine(entity: Entity): Boolean = (entity is BoatEngineEntity) | ||
override fun calculateThrust(boat: Boat): Float { | ||
val coupler = boat as BoatEngineCoupler | ||
var speed = 0.0f | ||
coupler.`boatism$getBoatEngineEntityUuid`()?.let { uuid: Optional<UUID> -> | ||
{ | ||
EntityHandler.getBoatEngineEntityFromUuid(uuid.getOrNull(), boat.level(), boat.position(), 10)?.also { | ||
val thrust = it.get().engineHandler.calculateThrustModifier(boat) | ||
val powerLevel = it.get().powerLevel * 0.008f | ||
speed = powerLevel * thrust | ||
} | ||
} | ||
} | ||
return speed | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters