aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/potatocrime/registry/PotatoRegistry.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-04-01 21:57:16 +0200
committerLinnea Gräf <nea@nea.moe>2024-04-01 21:57:16 +0200
commitab30c1128b42eed24d0decf9ecf9e6a2c98a79e2 (patch)
treee0b23161678b97c09e89fda00dfa5f3d7569238f /src/main/kotlin/moe/nea/potatocrime/registry/PotatoRegistry.kt
parent0fe5e487922a6ff50b9c415b9384157fbd64b2b5 (diff)
downloadpotato-crimes-ab30c1128b42eed24d0decf9ecf9e6a2c98a79e2.tar.gz
potato-crimes-ab30c1128b42eed24d0decf9ecf9e6a2c98a79e2.tar.bz2
potato-crimes-ab30c1128b42eed24d0decf9ecf9e6a2c98a79e2.zip
Add potato guard
Diffstat (limited to 'src/main/kotlin/moe/nea/potatocrime/registry/PotatoRegistry.kt')
-rw-r--r--src/main/kotlin/moe/nea/potatocrime/registry/PotatoRegistry.kt28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/main/kotlin/moe/nea/potatocrime/registry/PotatoRegistry.kt b/src/main/kotlin/moe/nea/potatocrime/registry/PotatoRegistry.kt
index 2e5fa5f..53944f3 100644
--- a/src/main/kotlin/moe/nea/potatocrime/registry/PotatoRegistry.kt
+++ b/src/main/kotlin/moe/nea/potatocrime/registry/PotatoRegistry.kt
@@ -2,16 +2,25 @@ package moe.nea.potatocrime.registry
import com.mojang.serialization.Codec
import moe.nea.potatocrime.PotatoCrime
+import moe.nea.potatocrime.entity.PotatoGuardEntity
import moe.nea.potatocrime.item.ContrabandItem
+import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup
+import net.fabricmc.fabric.api.`object`.builder.v1.entity.FabricEntityTypeBuilder
import net.minecraft.component.DataComponentType
+import net.minecraft.entity.EntityDimensions
+import net.minecraft.entity.SpawnGroup
import net.minecraft.item.Item
+import net.minecraft.item.ItemStack
import net.minecraft.network.codec.PacketCodecs
import net.minecraft.registry.Registries
import net.minecraft.registry.Registry
+import net.minecraft.registry.RegistryKeys
+import net.minecraft.registry.tag.TagKey
import net.minecraft.util.Identifier
object PotatoRegistry {
private val delayedRegistries = mutableListOf<() -> Unit>()
+ private val items = mutableListOf<Item>()
fun registerAll() {
delayedRegistries.forEach { it.invoke() }
}
@@ -23,15 +32,32 @@ object PotatoRegistry {
return t
}
- private fun <T : Item> item(name: String, t: T): T = register(Registries.ITEM, name, t)
+ private fun <T : Item> item(name: String, t: T): T = register(Registries.ITEM, name, t).also(items::add)
private fun <T> dataComponent(name: String, block: (DataComponentType.Builder<T>) -> DataComponentType.Builder<T>) =
register(
Registries.DATA_COMPONENT_TYPE, name,
block(DataComponentType.builder()).build()
)
+ fun identifier(name: String) = Identifier(PotatoCrime.modId, name)
+
+ val group = register(Registries.ITEM_GROUP, "default_group", FabricItemGroup.builder()
+ .icon { ItemStack(contraband) }
+ .displayName(PotatoTranslations.itemGroup.format())
+ .entries { _, entries ->
+ items.forEach(entries::add)
+ }
+ .build())
+ val carrotIshItems = TagKey.of(RegistryKeys.ITEM, identifier("carrotish"))
val contraband = item("contraband", ContrabandItem())
val contrabandData = dataComponent("contraband_data") {
it.codec(Codec.INT).packetCodec(PacketCodecs.VAR_INT)
}
+ val potatoGuard = register(
+ Registries.ENTITY_TYPE, "potato_guard",
+ FabricEntityTypeBuilder.create(SpawnGroup.CREATURE, ::PotatoGuardEntity)
+ .dimensions(EntityDimensions.fixed(1f, 3f))
+ .build()
+ )
+
} \ No newline at end of file