-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.20.1/new-api' into 1.20.1/main
- Loading branch information
Showing
30 changed files
with
407 additions
and
283 deletions.
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
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
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
7 changes: 7 additions & 0 deletions
7
common/src/main/kotlin/org/valkyrienskies/mod/api/SeatedControllingPlayer.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
20 changes: 20 additions & 0 deletions
20
common/src/main/kotlin/org/valkyrienskies/mod/api/ValkyrienSkies.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@file:JvmName("ValkyrienSkies") | ||
package org.valkyrienskies.mod.api | ||
|
||
import net.minecraft.core.BlockPos | ||
import net.minecraft.world.level.ChunkPos | ||
import net.minecraft.world.level.Level | ||
import org.valkyrienskies.core.api.ships.LoadedShip | ||
import org.valkyrienskies.core.api.ships.Ship | ||
|
||
val vsApi: VsApi @JvmName("getApi") get() = TODO() | ||
|
||
fun Level?.getShipManagingBlock(pos: BlockPos?) = vsApi.getShipManagingBlock(this, pos) | ||
fun Level?.getShipManagingBlock(x: Int, y: Int, z: Int) = getShipManagingChunk(x shr 4, z shr 4) | ||
|
||
fun Level?.getLoadedShipManagingBlock(pos: BlockPos?): LoadedShip? = TODO() | ||
|
||
fun Level?.getDeadShipManagingBlock(pos: BlockPos?): Ship? = TODO() | ||
|
||
fun Level?.getShipManagingChunk(pos: ChunkPos?) = vsApi.getShipManagingChunk(this, pos) | ||
fun Level?.getShipManagingChunk(chunkX: Int, chunkZ: Int) = vsApi.getShipManagingChunk(this, chunkX, chunkZ) |
56 changes: 56 additions & 0 deletions
56
common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.valkyrienskies.mod.api | ||
|
||
import net.minecraft.client.gui.screens.Screen | ||
import net.minecraft.client.multiplayer.ClientLevel | ||
import net.minecraft.core.BlockPos | ||
import net.minecraft.world.level.ChunkPos | ||
import net.minecraft.world.level.Level | ||
import net.minecraft.server.level.ServerLevel | ||
import net.minecraft.world.entity.Entity | ||
|
||
import org.jetbrains.annotations.ApiStatus.* | ||
import org.valkyrienskies.core.api.VsCoreApi | ||
import org.valkyrienskies.core.api.event.ListenableEvent | ||
import org.valkyrienskies.core.api.ships.* | ||
import org.valkyrienskies.mod.api.events.PostRenderShipEvent | ||
import org.valkyrienskies.mod.api.events.PreRenderShipEvent | ||
import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent | ||
|
||
@NonExtendable | ||
interface VsApi : VsCoreApi { | ||
|
||
/** | ||
* This event gets called when it's time to register physics block states for Minecraft block states. | ||
*/ | ||
@get:Experimental | ||
val registerBlockStateEvent: ListenableEvent<RegisterBlockStateEvent> | ||
|
||
@get:Experimental | ||
val preRenderShipEvent: ListenableEvent<PreRenderShipEvent> | ||
|
||
@get:Experimental | ||
val postRenderShipEvent: ListenableEvent<PostRenderShipEvent> | ||
|
||
fun isShipMountingEntity(entity: Entity): Boolean | ||
|
||
@Deprecated(message = "The legacy VS config system will be replaced soon. " + | ||
"Migrate to another config library, or the new system when it's released. ") | ||
fun createConfigScreenLegacy(parent: Screen, vararg configs: Class<*>): Screen | ||
|
||
/** | ||
* Get the ship with the chunk claim that contains [pos], if it exists. | ||
* | ||
* If either parameter is null, this will return null. | ||
* | ||
* @param level The [Level] to look for the ship in. If [level] is a | ||
* [ServerLevel], this will return a [ServerShip]. If [level] is a | ||
* [ClientLevel], this will return a [ClientShip]. | ||
* | ||
* @param pos A block position in the Shipyard | ||
*/ | ||
fun getShipManagingBlock(level: Level?, pos: BlockPos?): Ship? | ||
|
||
fun getShipManagingChunk(level: Level?, pos: ChunkPos?): Ship? | ||
|
||
fun getShipManagingChunk(level: Level?, chunkX: Int, chunkZ: Int): Ship? | ||
} |
6 changes: 6 additions & 0 deletions
6
common/src/main/kotlin/org/valkyrienskies/mod/api/events/PostRenderShipEvent.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.valkyrienskies.mod.api.events | ||
|
||
import org.jetbrains.annotations.ApiStatus.Experimental | ||
|
||
@Experimental | ||
interface PostRenderShipEvent |
6 changes: 6 additions & 0 deletions
6
common/src/main/kotlin/org/valkyrienskies/mod/api/events/PreRenderShipEvent.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.valkyrienskies.mod.api.events | ||
|
||
import org.jetbrains.annotations.ApiStatus.Experimental | ||
|
||
@Experimental | ||
interface PreRenderShipEvent |
25 changes: 25 additions & 0 deletions
25
common/src/main/kotlin/org/valkyrienskies/mod/api/events/RegisterBlockStateEvent.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.valkyrienskies.mod.api.events | ||
|
||
import net.minecraft.world.level.block.state.BlockState | ||
import org.jetbrains.annotations.ApiStatus.Experimental | ||
import org.valkyrienskies.core.api.physics.blockstates.LiquidState | ||
import org.valkyrienskies.core.api.physics.blockstates.SolidState | ||
|
||
@Experimental | ||
interface RegisterBlockStateEvent { | ||
|
||
fun newLiquidStateBuilder(): LiquidState.Builder | ||
fun buildLiquidState(block: LiquidState.Builder.() -> Unit): LiquidState | ||
fun newSolidStateBuilder(): SolidState.Builder | ||
fun buildSolidState(block: SolidState.Builder.() -> Unit): SolidState | ||
|
||
fun register(state: BlockState, solidState: SolidState) | ||
fun register(state: BlockState, liquidState: LiquidState) | ||
|
||
/** | ||
* Registers the Minecraft [state] to be represented by [LiquidState] and [SolidState] in the same block. | ||
* This is useful for e.g., a waterlogged chest, where the [liquidState] would be water and the [solidState] would | ||
* be the chest shape. | ||
*/ | ||
fun register(state: BlockState, liquidState: LiquidState, solidState: SolidState) | ||
} |
36 changes: 36 additions & 0 deletions
36
common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/RegisterBlockStateEventImpl.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.valkyrienskies.mod.api_impl.events | ||
|
||
import net.minecraft.world.level.block.state.BlockState | ||
import org.valkyrienskies.core.api.physics.blockstates.LiquidState | ||
import org.valkyrienskies.core.api.physics.blockstates.SolidState | ||
import org.valkyrienskies.core.apigame.physics.blockstates.VsBlockState | ||
import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent | ||
import org.valkyrienskies.mod.common.ValkyrienSkiesMod.vsCore | ||
|
||
class RegisterBlockStateEventImpl : RegisterBlockStateEvent { | ||
val toRegister = mutableListOf<Pair<BlockState, VsBlockState>>() | ||
|
||
override fun newLiquidStateBuilder(): LiquidState.Builder = | ||
vsCore.newLiquidStateBuilder() | ||
|
||
override fun buildLiquidState(block: LiquidState.Builder.() -> Unit): LiquidState = | ||
vsCore.newLiquidStateBuilder().apply(block).build() | ||
|
||
override fun newSolidStateBuilder(): SolidState.Builder = | ||
vsCore.newSolidStateBuilder() | ||
|
||
override fun buildSolidState(block: SolidState.Builder.() -> Unit): SolidState = | ||
vsCore.newSolidStateBuilder().apply(block).build() | ||
|
||
override fun register(state: BlockState, solidState: SolidState) { | ||
toRegister.add(Pair(state, VsBlockState(solidState, null))) | ||
} | ||
|
||
override fun register(state: BlockState, liquidState: LiquidState) { | ||
toRegister.add(Pair(state, VsBlockState(null, liquidState))) | ||
} | ||
|
||
override fun register(state: BlockState, liquidState: LiquidState, solidState: SolidState) { | ||
toRegister.add(Pair(state, VsBlockState(solidState, liquidState))) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VsApiImpl.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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.valkyrienskies.mod.api_impl.events | ||
|
||
import net.minecraft.client.gui.screens.Screen | ||
import net.minecraft.core.BlockPos | ||
import net.minecraft.world.entity.Entity | ||
import net.minecraft.world.level.ChunkPos | ||
import net.minecraft.world.level.Level | ||
import org.valkyrienskies.core.api.ships.Ship | ||
import org.valkyrienskies.core.util.events.EventEmitterImpl | ||
import org.valkyrienskies.mod.api.VsApi | ||
import org.valkyrienskies.mod.api.events.PostRenderShipEvent | ||
import org.valkyrienskies.mod.api.events.PreRenderShipEvent | ||
import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent | ||
import org.valkyrienskies.mod.common.entity.ShipMountingEntity | ||
import org.valkyrienskies.mod.common.getShipManagingPos | ||
import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig | ||
|
||
class VsApiImpl : VsApi { | ||
|
||
override val registerBlockStateEvent = EventEmitterImpl<RegisterBlockStateEvent>() | ||
override val preRenderShipEvent = EventEmitterImpl<PreRenderShipEvent>() | ||
override val postRenderShipEvent = EventEmitterImpl<PostRenderShipEvent>() | ||
|
||
override fun isShipMountingEntity(entity: Entity): Boolean { | ||
return entity is ShipMountingEntity | ||
} | ||
|
||
override fun createConfigScreenLegacy(parent: Screen, vararg configs: Class<*>): Screen { | ||
return VSClothConfig.createConfigScreenFor(parent, *configs) | ||
} | ||
|
||
|
||
override fun getShipManagingBlock(level: Level?, pos: BlockPos?): Ship? { | ||
return pos?.let { level?.getShipManagingPos(it) } | ||
} | ||
|
||
override fun getShipManagingChunk(level: Level?, pos: ChunkPos?): Ship? { | ||
return pos?.let { level?.getShipManagingPos(it) } | ||
} | ||
|
||
override fun getShipManagingChunk(level: Level?, chunkX: Int, chunkZ: Int): Ship? { | ||
return level?.getShipManagingPos(chunkX, chunkZ) | ||
} | ||
} |
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
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
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
Oops, something went wrong.