Create a minecraft mod that adds a custom entity with custom model, texture and…
- User
Create a minecraft mod that adds a custom entity with custom model, texture and animations. Write it for fabric. Create the entire project structure, each code and file. The texture, animations and model eill be placed inside of the project at where you tell them to at the specified file name. The name of the entity will be Tricky. It is an annoying mob that attacks you and then runs away very fast.
Assistant
Minecraft Fabric Mod: Tricky Entity
I'll create a complete Fabric mod that adds a custom mob called "Tricky" with custom model, texture, and animations. Here's the full project structure and all necessary files.
Project Structure
tricky-mod/ ├── build.gradle ├── gradle.properties ├── settings.gradle ├── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── com/ │ │ │ └── example/ │ │ │ └── trickymod/ │ │ │ ├── TrickyMod.java │ │ │ ├── entity/ │ │ │ │ ├── TrickyEntity.java │ │ │ │ └── TrickyRenderer.java │ │ │ └── client/ │ │ │ └── model/ │ │ │ └── TrickyModel.java │ │ └── resources/ │ │ ├── assets/ │ │ │ └── trickymod/ │ │ │ ├── lang/ │ │ │ │ └── en_us.json │ │ │ ├── models/ │ │ │ │ └── entity/ │ │ │ │ └── tricky.json │ │ │ ├── textures/ │ │ │ │ └── entity/ │ │ │ │ └── tricky.png │ │ │ └── animations/ │ │ │ └── tricky.animation.json │ │ ├── fabric.mod.json │ │ └── data/ │ │ └── trickymod/ │ │ ├── loot_tables/ │ │ │ └── entities/ │ │ │ └── tricky.json │ │ └── entity/ │ │ └── tricky.jsonFiles
1. Gradle Configuration
build.gradle
plugins { id 'fabric-loom' version '1.3-SNAPSHOT' id 'maven-publish' } version = project.mod_version group = project.maven_group repositories { maven { url "https://maven.shedaniel.me/" } maven { url "https://maven.terraformersmc.com/releases/" } } dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" // For entity models and animations modImplementation "net.fabricmc:fabric-rendering-entities-v1:${project.fabric_version}" modImplementation "net.fabricmc:fabric-rendering-data-attachment-v1:${project.fabric_version}" } processResources { inputs.property "version", project.version filteringCharset "UTF-8" filesMatching("fabric.mod.json") { expand "version": project.version } } def targetJavaVersion = 17 tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { it.options.release = targetJavaVersion } } java { withSourcesJar() } jar { from("LICENSE") { rename { "${it}_${project.archivesBaseName}" } } }gradle.properties
# Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G # Fabric Properties maven_group=com.example mod_version=1.0.0 minecraft_version=1.20.1 yarn_mappings=1.20.1+build.10 loader_version=0.14.22 fabric_version=0.88.1+1.20.1settings.gradle
rootProject.name = 'trickymod'2. Mod Main Class
src/main/java/com/example/trickymod/TrickyMod.java
package com.example.trickymod; import com.example.trickymod.entity.TrickyEntity; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityType; import net.minecraft.entity.SpawnGroup; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; public class TrickyMod implements ModInitializer { public static final String MOD_ID = "trickymod"; public static final EntityType<TrickyEntity> TRICKY = Registry.register( Registries.ENTITY_TYPE, new Identifier(MOD_ID, "tricky"), FabricEntityTypeBuilder.create(SpawnGroup.MONSTER, TrickyEntity::new) .dimensions(EntityDimensions.fixed(0.6f, 1.8f)) .build() ); @Override public void onInitialize() { FabricDefaultAttributeRegistry.register(TRICKY, TrickyEntity.createTrickyAttributes()); } }3. Entity Class
src/main/java/com/example/trickymod/entity/TrickyEntity.java
package com.example.trickymod.entity; 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.player.PlayerEntity; import net.minecraft.world.World; public class TrickyEntity extends HostileEntity { private int cooldown = 0; public TrickyEntity(EntityType<? extends HostileEntity> entityType, World world) { super(entityType, world); } public static DefaultAttributeContainer createTrickyAttributes() { return HostileEntity.createHostileAttributes() .add(EntityAttributes.GENERIC_MAX_HEALTH, 10.0) .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.35) .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 2.0) .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 16.0) .build(); } @Override protected void initGoals() { this.goalSelector.add(0, new SwimGoal(this)); this.goalSelector.add(1, new MeleeAttackGoal(this, 1.0, false)); this.goalSelector.add(2, new FleeEntityGoal<>(this, PlayerEntity.class, 10.0f, 1.5, 2.0)); this.goalSelector.add(3, new WanderAroundFarGoal(this, 1.0)); this.goalSelector.add(4, new LookAtEntityGoal(this, PlayerEntity.class, 8.0f)); this.goalSelector.add(5, new LookAroundGoal(this)); this.targetSelector.add(1, new RevengeGoal(this)); this.targetSelector.add(2, new ActiveTargetGoal<>(this, PlayerEntity.class, true)); } @Override public void tick() { super.tick(); if (cooldown > 0) { cooldown--; if (cooldown == 0) { this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).setBaseValue(0.35); } } } @Override public boolean tryAttack(PlayerEntity target) { boolean attacked = super.tryAttack(target); if (attacked) { // After attacking, run away very fast this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED).setBaseValue(0.7); cooldown = 100; // 5 seconds cooldown } return attacked; } }4. Model and Renderer
src/main/java/com/example/trickymod/client/model/TrickyModel.java
package com.example.trickymod.client.model; import net.minecraft.client.model.*; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; public class TrickyModel<T extends Entity> extends EntityModel<T> { private final ModelPart head; private final ModelPart body; private final ModelPart left_arm; private final ModelPart right_arm; private final ModelPart left_leg; private final ModelPart right_leg; public TrickyModel(ModelPart root) { this.head = root.getChild("head"); this.body = root.getChild("body"); this.left_arm = root
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.