实体类
- package fenglin.huaji.Animal.funny;
- import net.minecraft.entity.EntityType;
- import net.minecraft.entity.ai.attributes.Attributes;
- import net.minecraft.entity.monster.MonsterEntity;
- import net.minecraft.world.World;
- @SuppressWarnings("ALL")
- public class Entity extends MonsterEntity {
- public Entity(EntityType<? extends MonsterEntity> type, World worldIn) {
- super(type, worldIn);
- this.experienceValue = 14;
- this.getAttributeManager().createInstanceIfAbsent(Attributes.MAX_HEALTH);
- this.getAttributeManager().createInstanceIfAbsent(Attributes.ARMOR);
- this.getAttributeManager().createInstanceIfAbsent(Attributes.MOVEMENT_SPEED);
- this.getAttributeManager().createInstanceIfAbsent(Attributes.ATTACK_DAMAGE);
- }
- }
复制代码
Envent 类
- <blockquote> @Mod.EventBusSubscriber(modid = Utils.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
复制代码 model类
- package fenglin.huaji.Animal.funny;
- import com.mojang.blaze3d.matrix.MatrixStack;
- import com.mojang.blaze3d.vertex.IVertexBuilder;
- import net.minecraft.client.renderer.entity.model.EntityModel;
- import net.minecraft.client.renderer.model.ModelRenderer;
- import javax.annotation.ParametersAreNonnullByDefault;
- public class model extends EntityModel<Entity> {
- private final ModelRenderer body;
- public model() {
- textureWidth = 128;
- textureHeight = 128;
- body = new ModelRenderer(this, 0, 0);
- body.addBox(-16.0F, -16.0F, 0.0F, 32.0F, 16.0F, 32.0F);
- }
- @Override
- @ParametersAreNonnullByDefault
- public void setRotationAngles(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
- }
- @Override
- @ParametersAreNonnullByDefault
- public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
- body.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn);
- }
- }
复制代码 Registry 类
- package fenglin.huaji.Animal.funny;
- import fenglin.huaji.Utils;
- import net.minecraft.entity.EntityClassification;
- import net.minecraft.entity.EntityType;
- import net.minecraftforge.fml.RegistryObject;
- import net.minecraftforge.registries.DeferredRegister;
- import net.minecraftforge.registries.ForgeRegistries;
- public class Registry {
- public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, Utils.MOD_ID);
- public static final RegistryObject<EntityType<Entity>> entity_small_mcbbswiki_monster = ENTITY_TYPES.register("funny",
- () -> EntityType.Builder.create(Entity::new, EntityClassification.MISC).size(1F, 0.5F).build("huaji:funny"));
- }
复制代码 render类
- package fenglin.huaji.Animal.funny;
- import fenglin.huaji.Utils;
- import net.minecraft.client.renderer.entity.EntityRendererManager;
- import net.minecraft.client.renderer.entity.MobRenderer;
- import net.minecraft.entity.monster.MonsterEntity;
- import net.minecraft.util.ResourceLocation;
- import javax.annotation.Nonnull;
- import javax.annotation.ParametersAreNonnullByDefault;
- public class render extends MobRenderer<Entity, model> {
- public render(EntityRendererManager renderManagerIn) {
- super(renderManagerIn, new model(), 2F);
- }
- public render(EntityRendererManager renderManagerIn, model entityModelIn, float shadowSizeIn) {
- super(renderManagerIn, entityModelIn, shadowSizeIn);
- }
- @Override
- @Nonnull
- @ParametersAreNonnullByDefault
- public ResourceLocation getEntityTexture(Entity entity) {
- return new ResourceLocation(Utils.MOD_ID, "textures/entity/obsidian_animal.png");
- }
- }
复制代码 资源文件目录
总线
- public huaji(){
- IEventBus eventBus=FMLJavaModLoadingContext.get().getModEventBus();
复制代码 |