aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PotatoGuard.bbmodel1
-rw-r--r--PotatoGuard.java39
-rw-r--r--build.gradle1
-rwxr-xr-xgen_model.sh3
-rw-r--r--gradle.properties2
-rw-r--r--potato guard.pngbin0 -> 387 bytes
-rw-r--r--src/client/kotlin/moe/nea/potatocrime/PotatoCrimeClient.kt16
-rw-r--r--src/client/kotlin/moe/nea/potatocrime/client/entity/PotatoGuardRenderer.kt95
-rw-r--r--src/client/resources/assets/potato-crime/textures/entity/potato_guard.pngbin0 -> 385 bytes
-rw-r--r--src/main/generated/assets/potato-crime/lang/en_us.json2
-rw-r--r--src/main/generated/data/potato-crime/tags/items/carrotish.json8
-rw-r--r--src/main/kotlin/moe/nea/potatocrime/PotatoCrime.kt3
-rw-r--r--src/main/kotlin/moe/nea/potatocrime/PotatoCrimeDataGenerator.kt18
-rw-r--r--src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt50
-rw-r--r--src/main/kotlin/moe/nea/potatocrime/registry/PotatoRegistry.kt28
-rw-r--r--src/main/kotlin/moe/nea/potatocrime/registry/PotatoTranslations.kt1
16 files changed, 260 insertions, 7 deletions
diff --git a/PotatoGuard.bbmodel b/PotatoGuard.bbmodel
new file mode 100644
index 0000000..d444dd3
--- /dev/null
+++ b/PotatoGuard.bbmodel
@@ -0,0 +1 @@
+{"meta":{"format_version":"4.9","model_format":"modded_entity","box_uv":true},"name":"PotatoGuard","model_identifier":"PotatoGuard","modded_entity_version":"1.17","modded_entity_flip_y":true,"visible_box":[1,1,0],"variable_placeholders":"","variable_placeholder_buttons":[],"timeline_setups":[],"unhandled_root_fields":{},"resolution":{"width":128,"height":128},"elements":[{"name":"Bottom","box_uv":true,"rescale":false,"locked":false,"render_order":"default","allow_mirror_modeling":true,"from":[-7,24,-7],"to":[7,45,7],"autouv":0,"color":0,"origin":[0,11,0],"uv_offset":[0,37],"faces":{"north":{"uv":[14,51,28,72],"texture":0},"east":{"uv":[0,51,14,72],"texture":0},"south":{"uv":[42,51,56,72],"texture":0},"west":{"uv":[28,51,42,72],"texture":0},"up":{"uv":[28,51,14,37],"texture":0},"down":{"uv":[42,37,28,51],"texture":0}},"type":"cube","uuid":"0f55f4a3-0d72-5c6d-982e-684ce663c320"},{"name":"Middle","box_uv":true,"rescale":false,"locked":false,"render_order":"default","allow_mirror_modeling":true,"from":[-8,2,-8],"to":[8,23,8],"autouv":0,"color":0,"origin":[0,11,0],"faces":{"north":{"uv":[16,16,32,37],"texture":0},"east":{"uv":[0,16,16,37],"texture":0},"south":{"uv":[48,16,64,37],"texture":0},"west":{"uv":[32,16,48,37],"texture":0},"up":{"uv":[32,16,16,0],"texture":0},"down":{"uv":[48,0,32,16],"texture":0}},"type":"cube","uuid":"24f11f33-7c43-7252-45b8-1ee95e8b8cd2"},{"name":"Head","box_uv":true,"rescale":false,"locked":false,"render_order":"default","allow_mirror_modeling":true,"from":[-4,46,-4],"to":[4,59,4],"autouv":0,"color":0,"origin":[0,54.5,0],"uv_offset":[56,29],"faces":{"north":{"uv":[64,37,72,50],"texture":0},"east":{"uv":[56,37,64,50],"texture":0},"south":{"uv":[80,37,88,50],"texture":0},"west":{"uv":[72,37,80,50],"texture":0},"up":{"uv":[72,37,64,29],"texture":0},"down":{"uv":[80,29,72,37],"texture":0}},"type":"cube","uuid":"4b524bf5-e2c0-3deb-49ed-5f0ca886e2bd"}],"outliner":[{"name":"PotatoGuard","origin":[0,23.5,0],"color":0,"uuid":"c81dfe05-4f02-f636-f659-d539b5f26ebe","export":true,"mirror_uv":false,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["0f55f4a3-0d72-5c6d-982e-684ce663c320","24f11f33-7c43-7252-45b8-1ee95e8b8cd2"]},{"name":"PotatoHead","origin":[0,52.5,0],"color":0,"uuid":"055e3b4f-4b0e-77e2-9db5-c5bc30945efd","export":true,"mirror_uv":false,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["4b524bf5-e2c0-3deb-49ed-5f0ca886e2bd"]}],"textures":[{"path":"/home/nea/src/potato-crime/potato guard.png","name":"potato guard.png","folder":"block","namespace":"","id":"0","width":128,"height":128,"uv_width":128,"uv_height":128,"particle":false,"layers_enabled":false,"sync_to_project":"","render_mode":"default","render_sides":"auto","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"internal":true,"saved":true,"uuid":"3fc7db74-a9df-c21d-dcb8-2ef89d2fab22","relative_path":"../potato guard.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAANpSURBVHhe7ZzBTsNQEANbwf9/MQh66AFBqdK3Jmaa6YlDnteyJxskQs+n4eft4/QxlBgdfz2fziOBgx8ehycAbIIEgN3f2L0AjCNkCwgAu7+xewEYR8gWEAB2f2P3AjCOkC0gAOz+xu4FYBwhW0AA2P2N3QvAOEK2gACw+xu7F4BxhGwBAWD3N3YvAOMI2QLn9p9z2/Ed/X0CATj4CyUCIADdV7p8BHQTcAO4AdwA3XuwO90N4AZwA3Tvwe50N4AbwA3QvQe7090AbgA3QPce7E53A7gBjr0Bpvcf/Y9Jh98AAlD+9+5pAe3zboB2A+X5AlAuoD1eANoNlOcLQLmA9ngBaDdQno8HYDW/vV8mXQ16b5/f81z1vdrLo+eWXwvfO9jVIPf2KQCPIrjxegHYGNSDl7kBroG9XJJ4v37j4defH8zzx+Wr4E7nbj0vAFuTWrxOABaDSz1L/R3gfgFugBCgv8m4AUIBrwbpBnAD+GXWdxjwERDaUD4C/mmQWx4Bl8fLzc/l7Piz+ugaD94o4AbYGNTqZQKwmty3c6tBbtkAIYs3ZVZ9/6Wnr9pPvwH2CpI65+lfCv3vd2AbHAFoN1CeLwDlAtrjBaDdQHm+AJQLaI8XgHYD5fkCUC6gPV4A2g2U5wtAuYD2eAFoN1CeLwDlAtrjBaDdQHm+AJQLaI8XgHYD5fkCUC6gPV4A2g2U5wtAuYD2eAFoN1CeLwDlAtrjBaDdQHm+AJQLaI9ffiu4bdz5mQQEIJMjVkUAsNVljAtAJkesigBgq8sYF4BMjlgVAcBWlzEuAJkcsSoCgK0uY1wAMjliVQQAW13GuABkcsSqCAC2uoxxAcjkiFURAGx1GeMCkMkRqyIA2OoyxgUgkyNWRQCw1WWMC0AmR6yKAGCryxgXgEyOWBUBwFaXMS4AmRyxKgKArS5jXAAyOWJVBABbXca4AGRyxKoIALa6jHEByOSIVREAbHUZ4wKQyRGrIgDY6jLGBSCTI1ZFALDVZYwLQCZHrIoAYKvLGBeATI5YFQHAVpcxLgCZHLEqAoCtLmNcADI5YlUEAFtdxrgAZHLEqggAtrqMcQHI5IhVEQBsdRnjApDJEasiANjqMsYFIJMjVkUAsNVljAtAJkesigBgq8sYF4BMjlgVAcBWlzEuAJkcsSqf7n8FkBXKfiQAAAAASUVORK5CYII="}],"fabricOptions":{"header":"package com.example.mod;","entity":"Entity","render":"","members":""}} \ No newline at end of file
diff --git a/PotatoGuard.java b/PotatoGuard.java
new file mode 100644
index 0000000..8f69300
--- /dev/null
+++ b/PotatoGuard.java
@@ -0,0 +1,39 @@
+// Made with Blockbench 4.9.4
+// Exported for Minecraft version 1.17 or later with Mojang mappings
+// Paste this class into your mod and generate all required imports
+
+
+public class PotatoGuard<T extends Entity> extends EntityModel<T> {
+ // This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor
+ public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation("modid", "potatoguard"), "main");
+ private final ModelPart PotatoGuard;
+ private final ModelPart PotatoHead;
+
+ public PotatoGuard(ModelPart root) {
+ this.PotatoGuard = root.getChild("PotatoGuard");
+ this.PotatoHead = root.getChild("PotatoHead");
+ }
+
+ public static LayerDefinition createBodyLayer() {
+ MeshDefinition meshdefinition = new MeshDefinition();
+ PartDefinition partdefinition = meshdefinition.getRoot();
+
+ PartDefinition PotatoGuard = partdefinition.addOrReplaceChild("PotatoGuard", CubeListBuilder.create().texOffs(0, 37).addBox(-7.0F, -21.5F, -7.0F, 14.0F, 21.0F, 14.0F, new CubeDeformation(0.0F))
+ .texOffs(0, 0).addBox(-8.0F, 0.5F, -8.0F, 16.0F, 21.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 0.5F, 0.0F));
+
+ PartDefinition PotatoHead = partdefinition.addOrReplaceChild("PotatoHead", CubeListBuilder.create().texOffs(56, 29).addBox(-4.0F, -6.5F, -4.0F, 8.0F, 13.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, -28.5F, 0.0F));
+
+ return LayerDefinition.create(meshdefinition, 128, 128);
+ }
+
+ @Override
+ public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
+
+ }
+
+ @Override
+ public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
+ PotatoGuard.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
+ PotatoHead.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
+ }
+} \ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 39dcdf4..70d830f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -12,6 +12,7 @@ base {
}
repositories {
+ mavenLocal()
}
loom {
diff --git a/gen_model.sh b/gen_model.sh
new file mode 100755
index 0000000..f7202ea
--- /dev/null
+++ b/gen_model.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+awk '/ PartDefinition partdefinition = meshdefinition.getRoot\(\);/{flag=1;next}/ \}/{flag=0;next} flag' PotatoGuard.java \
+| sed 's/PartDefinition/ModelPartData/;s/partdefinition/modelPartData/;s/addOrReplaceChild/addChild/;s/CubeListBuilder/ModelPartBuilder/;s/texOffs/uv/g;s/addBox/cuboid/g;s/CubeDeformation/Dilation/g;s/LayerDefinition.create/TexturedModelData.of/;s/meshdefinition/modelData/g;s/PartPose.offset/ModelTransform.pivot/'
diff --git a/gradle.properties b/gradle.properties
index eb3491a..3870ec8 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -5,7 +5,7 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=24w14potato
-yarn_mappings=24w14potato+build.3
+yarn_mappings=24w14potato+build.local
loader_version=0.15.9
#Fabric api
diff --git a/potato guard.png b/potato guard.png
new file mode 100644
index 0000000..345f0c0
--- /dev/null
+++ b/potato guard.png
Binary files differ
diff --git a/src/client/kotlin/moe/nea/potatocrime/PotatoCrimeClient.kt b/src/client/kotlin/moe/nea/potatocrime/PotatoCrimeClient.kt
index b724800..baba5d2 100644
--- a/src/client/kotlin/moe/nea/potatocrime/PotatoCrimeClient.kt
+++ b/src/client/kotlin/moe/nea/potatocrime/PotatoCrimeClient.kt
@@ -1,9 +1,19 @@
package moe.nea.potatocrime
+import moe.nea.potatocrime.client.entity.PotatoGuardModel
+import moe.nea.potatocrime.client.entity.PotatoGuardRenderer
+import moe.nea.potatocrime.registry.PotatoRegistry
import net.fabricmc.api.ClientModInitializer
+import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry
+import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry
+
object PotatoCrimeClient : ClientModInitializer {
- override fun onInitializeClient() {
- // This entrypoint is suitable for setting up client-specific logic, such as rendering.
- }
+ override fun onInitializeClient() {
+ EntityRendererRegistry.register(PotatoRegistry.potatoGuard, ::PotatoGuardRenderer)
+ EntityModelLayerRegistry.registerModelLayer(
+ PotatoGuardRenderer.modelLayer,
+ PotatoGuardModel::getTexturedModelData
+ )
+ }
} \ No newline at end of file
diff --git a/src/client/kotlin/moe/nea/potatocrime/client/entity/PotatoGuardRenderer.kt b/src/client/kotlin/moe/nea/potatocrime/client/entity/PotatoGuardRenderer.kt
new file mode 100644
index 0000000..c22e2e0
--- /dev/null
+++ b/src/client/kotlin/moe/nea/potatocrime/client/entity/PotatoGuardRenderer.kt
@@ -0,0 +1,95 @@
+package moe.nea.potatocrime.client.entity
+
+import moe.nea.potatocrime.entity.PotatoGuardEntity
+import moe.nea.potatocrime.registry.PotatoRegistry
+import net.minecraft.client.model.*
+import net.minecraft.client.render.VertexConsumer
+import net.minecraft.client.render.entity.EntityRendererFactory
+import net.minecraft.client.render.entity.MobEntityRenderer
+import net.minecraft.client.render.entity.model.EntityModel
+import net.minecraft.client.render.entity.model.EntityModelLayer
+import net.minecraft.client.util.math.MatrixStack
+import net.minecraft.util.Identifier
+
+
+class PotatoGuardRenderer(context: EntityRendererFactory.Context) :
+ MobEntityRenderer<PotatoGuardEntity, PotatoGuardModel>(
+ context,
+ PotatoGuardModel(context.getPart(modelLayer)),
+ 0.5f
+ ) {
+ companion object {
+ val modelLayer = EntityModelLayer(PotatoRegistry.identifier("potato_guard"), "main")
+ }
+
+ override fun getTexture(entity: PotatoGuardEntity): Identifier {
+ return PotatoRegistry.identifier("textures/entity/potato_guard.png")
+ }
+}
+
+class PotatoGuardModel(val part: ModelPart) : EntityModel<PotatoGuardEntity>() {
+ val PotatoGuard = part.getChild("PotatoGuard")
+ val PotatoHead = part.getChild("PotatoHead")
+
+ companion object {
+ fun getTexturedModelData(): TexturedModelData {
+ val modelData = ModelData()
+ val modelPartData = modelData.root
+ val PotatoGuard = modelPartData.addChild(
+ "PotatoGuard",
+ ModelPartBuilder.create().uv(0, 37).cuboid(-7.0f, -21.5f, -7.0f, 14.0f, 21.0f, 14.0f, Dilation(0.0f))
+ .uv(0, 0).cuboid(-8.0f, 0.5f, -8.0f, 16.0f, 21.0f, 16.0f, Dilation(0.0f)),
+ ModelTransform.pivot(0.0f, 0.5f, 0.0f)
+ )
+
+ val PotatoHead = modelPartData.addChild(
+ "PotatoHead",
+ ModelPartBuilder.create().uv(56, 29).cuboid(-4.0f, -6.5f, -4.0f, 8.0f, 13.0f, 8.0f, Dilation(0.0f)),
+ ModelTransform.pivot(0.0f, -28.5f, 0.0f)
+ )
+
+ return TexturedModelData.of(modelData, 128, 128)
+
+ }
+ }
+
+ override fun render(
+ matrices: MatrixStack?,
+ vertices: VertexConsumer?,
+ light: Int,
+ overlay: Int,
+ red: Float,
+ green: Float,
+ blue: Float,
+ alpha: Float
+ ) {
+ listOf(PotatoGuard, PotatoHead).forEach {
+ it.render(matrices, vertices, light, overlay, red, green, blue, alpha)
+ }
+ }
+ fun lerpAngle(angleOne: Float, angleTwo: Float, magnitude: Float): Float {
+ var f = (magnitude - angleTwo) % 6.2831855f
+ if (f < -3.1415927f) {
+ f += 6.2831855f
+ }
+
+ if (f >= 3.1415927f) {
+ f -= 6.2831855f
+ }
+
+ return angleTwo + angleOne * f
+ }
+
+ override fun setAngles(
+ entity: PotatoGuardEntity?,
+ limbAngle: Float,
+ limbDistance: Float,
+ animationProgress: Float,
+ headYaw: Float,
+ headPitch: Float
+ ) {
+ PotatoHead.yaw = headYaw / 180 * Math.PI.toFloat()
+ PotatoHead.pitch = headPitch / 180 * Math.PI.toFloat()
+// PotatoGuard.setAngles(limbAngle, 0F, 0F)
+ }
+} \ No newline at end of file
diff --git a/src/client/resources/assets/potato-crime/textures/entity/potato_guard.png b/src/client/resources/assets/potato-crime/textures/entity/potato_guard.png
new file mode 100644
index 0000000..3cfa2f1
--- /dev/null
+++ b/src/client/resources/assets/potato-crime/textures/entity/potato_guard.png
Binary files differ
diff --git a/src/main/generated/assets/potato-crime/lang/en_us.json b/src/main/generated/assets/potato-crime/lang/en_us.json
index 4a5dee4..7a5c3e9 100644
--- a/src/main/generated/assets/potato-crime/lang/en_us.json
+++ b/src/main/generated/assets/potato-crime/lang/en_us.json
@@ -1,5 +1,7 @@
{
+ "entity.potato-crime.potato_guard": "Potato Guard",
"item.potato-crime.contraband": "Contraband",
"potato-crime.text.fill-level": "Hidden carrots: %s/1000.",
+ "potato-crime.text.item-group": "Potato Crimes",
"potato-crime.text.no-carrots": "No carrots to deposit."
} \ No newline at end of file
diff --git a/src/main/generated/data/potato-crime/tags/items/carrotish.json b/src/main/generated/data/potato-crime/tags/items/carrotish.json
new file mode 100644
index 0000000..d8737d8
--- /dev/null
+++ b/src/main/generated/data/potato-crime/tags/items/carrotish.json
@@ -0,0 +1,8 @@
+{
+ "values": [
+ "minecraft:carrot",
+ "minecraft:carrot_on_a_stick",
+ "minecraft:golden_carrot",
+ "minecraft:orange_dye"
+ ]
+} \ No newline at end of file
diff --git a/src/main/kotlin/moe/nea/potatocrime/PotatoCrime.kt b/src/main/kotlin/moe/nea/potatocrime/PotatoCrime.kt
index a421e35..5d0cddc 100644
--- a/src/main/kotlin/moe/nea/potatocrime/PotatoCrime.kt
+++ b/src/main/kotlin/moe/nea/potatocrime/PotatoCrime.kt
@@ -1,7 +1,9 @@
package moe.nea.potatocrime
+import moe.nea.potatocrime.entity.PotatoGuardEntity
import moe.nea.potatocrime.registry.PotatoRegistry
import net.fabricmc.api.ModInitializer
+import net.fabricmc.fabric.api.`object`.builder.v1.entity.FabricDefaultAttributeRegistry
import org.slf4j.LoggerFactory
object PotatoCrime : ModInitializer {
@@ -15,5 +17,6 @@ object PotatoCrime : ModInitializer {
// Proceed with mild caution.
logger.info("Hello Fabric world!")
PotatoRegistry.registerAll()
+ FabricDefaultAttributeRegistry.register(PotatoRegistry.potatoGuard, PotatoGuardEntity.createMobAttributes())
}
} \ No newline at end of file
diff --git a/src/main/kotlin/moe/nea/potatocrime/PotatoCrimeDataGenerator.kt b/src/main/kotlin/moe/nea/potatocrime/PotatoCrimeDataGenerator.kt
index 09c9469..3e87a49 100644
--- a/src/main/kotlin/moe/nea/potatocrime/PotatoCrimeDataGenerator.kt
+++ b/src/main/kotlin/moe/nea/potatocrime/PotatoCrimeDataGenerator.kt
@@ -8,13 +8,16 @@ import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider
import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider
+import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider
import net.minecraft.data.client.BlockStateModelGenerator
import net.minecraft.data.client.ItemModelGenerator
import net.minecraft.data.client.Models
import net.minecraft.data.server.recipe.RecipeExporter
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder
+import net.minecraft.item.Item
import net.minecraft.item.Items
import net.minecraft.recipe.book.RecipeCategory
+import net.minecraft.registry.RegistryKeys
import net.minecraft.registry.RegistryWrapper
import java.util.concurrent.CompletableFuture
@@ -24,6 +27,19 @@ class PotatoCrimeDataGenerator : DataGeneratorEntrypoint {
pack.addProvider(::NameProvider)
pack.addProvider(::RecipeProvider)
pack.addProvider(::DefaultModels)
+ pack.addProvider(::TagProvider)
+ }
+}
+
+class TagProvider(
+ output: FabricDataOutput?, registriesFuture: CompletableFuture<RegistryWrapper.WrapperLookup>?,
+) : FabricTagProvider<Item>(output, RegistryKeys.ITEM, registriesFuture) {
+ override fun configure(wrapperLookup: RegistryWrapper.WrapperLookup) {
+ getOrCreateTagBuilder(PotatoRegistry.carrotIshItems)
+ .add(Items.CARROT)
+ .add(Items.CARROT_ON_A_STICK)
+ .add(Items.GOLDEN_CARROT)
+ .add(Items.ORANGE_DYE)
}
}
@@ -36,7 +52,6 @@ class RecipeProvider(
.input(Items.PAPER, 3)
.input(Items.BROWN_DYE)
.input(Items.CARROT)
- .criterion(hasItem(Items.PAPER), conditionsFromItem(Items.PAPER))
.criterion(hasItem(Items.CARROT), conditionsFromItem(Items.CARROT))
.offerTo(exporter)
}
@@ -60,6 +75,7 @@ class NameProvider(dataOutput: FabricDataOutput, registryLookup: CompletableFutu
registryLookup: RegistryWrapper.WrapperLookup,
translationBuilder: TranslationBuilder
) {
+ translationBuilder.add(PotatoRegistry.potatoGuard, "Potato Guard")
translationBuilder.add(PotatoRegistry.contraband, "Contraband")
PotatoTranslations.allTranslations.forEach {
translationBuilder.add(it.translationKey, it.default)
diff --git a/src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt b/src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt
index b7282ea..33ea7d1 100644
--- a/src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt
+++ b/src/main/kotlin/moe/nea/potatocrime/entity/PotatoGuard.kt
@@ -1,3 +1,51 @@
package moe.nea.potatocrime.entity
-import net.minecraft.entity.LivingEntity
+import moe.nea.potatocrime.registry.PotatoRegistry
+import net.minecraft.entity.EntityType
+import net.minecraft.entity.ai.goal.*
+import net.minecraft.entity.attribute.DefaultAttributeContainer
+import net.minecraft.entity.attribute.EntityAttributes
+import net.minecraft.entity.mob.HostileEntity
+import net.minecraft.entity.mob.PathAwareEntity
+import net.minecraft.entity.player.PlayerEntity
+import net.minecraft.world.World
+
+class PotatoGuardEntity(entityType: EntityType<out PotatoGuardEntity>, world: World?) :
+ PathAwareEntity(entityType, world) {
+ companion object {
+ fun createMobAttributes(): DefaultAttributeContainer.Builder {
+ return HostileEntity.createHostileAttributes()
+ .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 35.0)
+ .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.4)
+ .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 10.0)
+ .add(EntityAttributes.GENERIC_ARMOR, 4.0)
+ .add(EntityAttributes.GENERIC_MAX_HEALTH, 40.0)
+ }
+ }
+
+
+ override fun initGoals() {
+ goalSelector.add(3, MeleeAttackGoal(this, 1.0, false))
+ goalSelector.add(8, LookAroundGoal(this))
+ goalSelector.add(7, WanderAroundFarGoal(this, 1.0))
+ goalSelector.add(6, object : Goal() {
+ override fun canStart(): Boolean {
+ return this@PotatoGuardEntity.target == null && this@PotatoGuardEntity.getRandom().nextFloat() < 0.01
+ }
+ })
+ targetSelector.add(
+ 1,
+ ActiveTargetGoal(
+ this,
+ PlayerEntity::class.java,
+ true
+ ) { player ->
+ (player as PlayerEntity)
+ .inventory
+ .getMatchingStacks { it.isIn(PotatoRegistry.carrotIshItems) }
+ .isNotEmpty()
+ }
+ )
+ }
+
+}
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
diff --git a/src/main/kotlin/moe/nea/potatocrime/registry/PotatoTranslations.kt b/src/main/kotlin/moe/nea/potatocrime/registry/PotatoTranslations.kt
index 062c88d..8d7fd19 100644
--- a/src/main/kotlin/moe/nea/potatocrime/registry/PotatoTranslations.kt
+++ b/src/main/kotlin/moe/nea/potatocrime/registry/PotatoTranslations.kt
@@ -19,6 +19,7 @@ object PotatoTranslations {
}
val noCarrotsToDeposit = PT("no-carrots", "No carrots to deposit.")
+ val itemGroup = PT("item-group", "Potato Crimes")
val contrabandFillText = PT("fill-level", "Hidden carrots: %s/1000.")
} \ No newline at end of file