-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(code): Update project to 24w36a.
- Loading branch information
Showing
11 changed files
with
199 additions
and
2 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
19 changes: 19 additions & 0 deletions
19
kore/src/main/kotlin/io/github/ayfri/kore/arguments/EquipmentSlot.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,19 @@ | ||
package io.github.ayfri.kore.arguments | ||
|
||
import io.github.ayfri.kore.serializers.LowercaseSerializer | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable(EquipmentSlot.Companion.EquipmentSlotSerializer::class) | ||
enum class EquipmentSlot { | ||
HEAD, | ||
CHEST, | ||
LEGS, | ||
FEET, | ||
BODY, | ||
MAINHAND, | ||
OFFHAND; | ||
|
||
companion object { | ||
data object EquipmentSlotSerializer : LowercaseSerializer<EquipmentSlot>(entries) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
kore/src/main/kotlin/io/github/ayfri/kore/arguments/components/types/EquippableComponent.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,41 @@ | ||
package io.github.ayfri.kore.arguments.components.types | ||
|
||
import io.github.ayfri.kore.arguments.EquipmentSlot | ||
import io.github.ayfri.kore.arguments.components.ComponentsScope | ||
import io.github.ayfri.kore.arguments.types.EntityTypeOrTagArgument | ||
import io.github.ayfri.kore.arguments.types.resources.ModelArgument | ||
import io.github.ayfri.kore.arguments.types.resources.SoundEventArgument | ||
import io.github.ayfri.kore.generated.ComponentTypes | ||
import io.github.ayfri.kore.serializers.InlinableList | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class EquippableComponent( | ||
var slot: EquipmentSlot, | ||
@SerialName("equip_sound") | ||
var equipSound: SoundEventArgument? = null, | ||
var model: ModelArgument, | ||
@SerialName("allowed_entities") | ||
var allowedEntities: InlinableList<EntityTypeOrTagArgument>? = null, | ||
var dispensable: Boolean? = null, | ||
) : Component() | ||
|
||
fun ComponentsScope.equippable( | ||
slot: EquipmentSlot, | ||
model: ModelArgument, | ||
init: EquippableComponent.() -> Unit = {}, | ||
) = apply { | ||
this[ComponentTypes.EQUIPPABLE] = EquippableComponent(slot, model = model).apply(init) | ||
} | ||
|
||
fun ComponentsScope.equippable( | ||
slot: EquipmentSlot, | ||
model: String, | ||
namespace: String = "minecraft", | ||
init: EquippableComponent.() -> Unit = {}, | ||
) = equippable(slot, ModelArgument(model, namespace), init) | ||
|
||
fun EquippableComponent.allowedEntities(vararg entities: EntityTypeOrTagArgument) = apply { | ||
allowedEntities = entities.toList() | ||
} |
12 changes: 12 additions & 0 deletions
12
kore/src/main/kotlin/io/github/ayfri/kore/arguments/components/types/GliderComponent.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,12 @@ | ||
package io.github.ayfri.kore.arguments.components.types | ||
|
||
import io.github.ayfri.kore.arguments.components.ComponentsScope | ||
import io.github.ayfri.kore.generated.ComponentTypes | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data object GliderComponent : Component() | ||
|
||
fun ComponentsScope.glider() = apply { | ||
this[ComponentTypes.GLIDER] = GliderComponent | ||
} |
25 changes: 25 additions & 0 deletions
25
kore/src/main/kotlin/io/github/ayfri/kore/arguments/components/types/ItemModelComponent.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 io.github.ayfri.kore.arguments.components.types | ||
|
||
import io.github.ayfri.kore.arguments.components.ComponentsScope | ||
import io.github.ayfri.kore.arguments.types.resources.ItemArgument | ||
import io.github.ayfri.kore.arguments.types.resources.ModelArgument | ||
import io.github.ayfri.kore.generated.ComponentTypes | ||
import io.github.ayfri.kore.serializers.InlineSerializer | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable(with = ItemModelComponent.Companion.ItemModelComponentSerializer::class) | ||
data class ItemModelComponent(var model: ModelArgument) : Component() { | ||
companion object { | ||
object ItemModelComponentSerializer : InlineSerializer<ItemModelComponent, ModelArgument>( | ||
ModelArgument.serializer(), | ||
ItemModelComponent::model | ||
) | ||
} | ||
} | ||
|
||
fun ComponentsScope.itemModel(model: ModelArgument) = apply { | ||
this[ComponentTypes.ITEM_MODEL] = ItemModelComponent(model) | ||
} | ||
|
||
fun ComponentsScope.itemModel(model: String, namespace: String = "minecraft") = itemModel(ModelArgument(model, namespace)) | ||
fun ComponentsScope.itemModel(model: ItemArgument) = itemModel(ModelArgument(model.asId().substringAfter(":"), model.namespace)) |
23 changes: 23 additions & 0 deletions
23
.../src/main/kotlin/io/github/ayfri/kore/arguments/components/types/TooltipStyleComponent.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,23 @@ | ||
package io.github.ayfri.kore.arguments.components.types | ||
|
||
import io.github.ayfri.kore.arguments.components.ComponentsScope | ||
import io.github.ayfri.kore.arguments.types.resources.ModelArgument | ||
import io.github.ayfri.kore.generated.ComponentTypes | ||
import io.github.ayfri.kore.serializers.InlineSerializer | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable(with = TooltipStyleComponent.Companion.TooltipStyleComponentSerializer::class) | ||
data class TooltipStyleComponent(var model: ModelArgument) : Component() { | ||
companion object { | ||
object TooltipStyleComponentSerializer : InlineSerializer<TooltipStyleComponent, ModelArgument>( | ||
ModelArgument.serializer(), | ||
TooltipStyleComponent::model | ||
) | ||
} | ||
} | ||
|
||
fun ComponentsScope.tooltipStyle(model: ModelArgument) = apply { | ||
this[ComponentTypes.TOOLTIP_STYLE] = TooltipStyleComponent(model) | ||
} | ||
|
||
fun ComponentsScope.tooltipStyle(model: String, namespace: String = "minecraft") = tooltipStyle(ModelArgument(model, namespace)) |
17 changes: 17 additions & 0 deletions
17
kore/src/main/kotlin/io/github/ayfri/kore/arguments/types/resources/ModelArgument.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,17 @@ | ||
package io.github.ayfri.kore.arguments.types.resources | ||
|
||
import io.github.ayfri.kore.arguments.Argument | ||
import io.github.ayfri.kore.arguments.types.ResourceLocationArgument | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable(with = Argument.ArgumentSerializer::class) | ||
interface ModelArgument : ResourceLocationArgument { | ||
companion object { | ||
operator fun invoke(model: String, namespace: String = "minecraft") = object : ModelArgument { | ||
override val name = model | ||
override val namespace = namespace | ||
} | ||
} | ||
} | ||
|
||
fun model(model: String, namespace: String = "minecraft") = ModelArgument(model, namespace) |
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
1 change: 0 additions & 1 deletion
1
kore/src/test/kotlin/io/github/ayfri/kore/arguments/components/ComponentTests.kt
This file was deleted.
Oops, something went wrong.
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