Minecraft 1.20.x Forge模组开发 03.动画生物实体

本教程详细介绍了如何在Minecraft 1.20.x Forge模组中创建一个具有丰富动画效果的生物实体。通过使用GeckoLib,从模型制作、代码编写到资源包的配置,一步步教你如何实现生物的各种状态动画,并添加刷怪蛋及设定掉落物。
摘要由CSDN通过智能技术生成

我们本次尝试在1.20的模组中添加一个能够具有各种动画效果动作的生物实体。在这里插入图片描述

效果展示 效果展示 效果展示

1.首先,为了实现这些动画效果,我们需要首先使用到一个模组:geckolib(下载地址)

找到项目的build.gradle文件,在repositoriesdependencies中添加依赖。

repositories {
   

    //添加这个
    maven {
   
        name = 'GeckoLib'
        url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
    }
    
}
dependencies {
   
    minecraft 'net.minecraftforge:forge:1.20-46.0.14'
       
    //添加这个
    implementation fg.deobf('software.bernie.geckolib:geckolib-forge-1.20:4.2')

}

在这里插入图片描述

之后点击Load Gradle按钮重新构建项目

在这里插入图片描述

2.之后,与之前的教程一样,我们需要在blockbench中制作一个模组中的生物实体:

进入软件后我们要找到一个插件按钮,然后再搜索栏中输入GeckoLib Animation Utils,并下载这个插件

cr6.png

将我们制作好的生物实体进行模型转换工作,找到Convert Project,之后选择Geckolib Animated Model

cr7.png

在这之后,你会发现你的生物实体栏多了一个Animate栏,点击进去:

sam.jpg

具体动作制作的视频:Blockbench动画制作

在制作好所有的动画后我们导出模型和动画json文件。

在这里插入图片描述

3.模型制作完成,接下来需要制作生物实体类,因为我们的生物的动作有很多,所以要在生物的不同状态时做出对应的动作。

EntitySamca.java

package com.joy187.re8joymod.entity;

import java.util.EnumSet;

import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.Goal;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.animal.IronGolem;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.monster.Vex;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.raid.Raider;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import software.bernie.geckolib.animatable.GeoEntity;
import software.bernie.geckolib.core.animatable.GeoAnimatable;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
import software.bernie.geckolib.core.animation.AnimatableManager;
import software.bernie.geckolib.core.animation.AnimationController;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.core.animation.RawAnimation;
import software.bernie.geckolib.core.object.PlayState;
import software.bernie.geckolib.util.GeckoLibUtil;


public class EntitySamca extends Vex implements GeoEntity {
   

    private AnimatableInstanceCache factory = GeckoLibUtil.createInstanceCache(this);

    private static final RawAnimation AIM_LEFT_HAND = RawAnimation.begin().thenPlay("pose.aim.left");

    public EntitySamca(EntityType<? extends Vex> type, Level worldIn) {
   
        super(type, worldIn);
        this.xpReward = 20;
    }
	//依次设置生物的血量、攻击伤害、移速、击退抗性
    public static AttributeSupplier.Builder prepareAttributes() {
   
        return Monster.createMonsterAttributes().add(Attributes.MAX_HEALTH, 35.0D).
                add(Attributes.ATTACK_DAMAGE, 8.5D).
                add(Attributes.MOVEMENT_SPEED, 0.28D).
                add(Attributes.KNOCKBACK_RESISTANCE, 0.15D);
    }
	//生物AI设置
    protected void registerGoals() {
   
        super.registerGoals();
        this.goalSelector.addGoal(0, new FloatGoal(this)); //可游泳
        this.goalSelector.addGoal(4, new EntitySamca.ChargeAttackGoal()); //目标选择
        this
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jay_fearless

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值