有爱,有技术,有你^_^)y
╱人◕‿‿◕人╲订下契约(注册新用户)

合作站点账号登陆

QQ登录

只需一步,快速开始

快捷导航
查看: 1451|回复: 3
收起左侧

[技巧分享] 【Techne 教程】使用Modloader生成实体(企鹅篇)

[复制链接]

签到天数: 25 天

连续签到: 1 天

[LV.4]偶尔看看III

481

主题

519

好友

15万

积分

最终章

☆非拔作不Ctrl★

积分
159739
发表于 2012-7-30 14:58:01 | 显示全部楼层 |阅读模式

╱人◕‿‿◕人╲定下契约

您需要 登录 才可以下载或查看,没有账号?╱人◕‿‿◕人╲订下契约(注册新用户)

x
使用Modloader生成实体(企鹅篇)


Modloader

新建一个java文件,并命名为"mod_Penguin.java"

[mw_shl_code=java,true]package net.minecraft.src;
import java.util.*;
import java.util.Map;

public class mod_Penguin extends BaseMod
{
        
    public mod_Penguin()
    {
                ModLoader.RegisterEntityID(EntityPenguin.class, "Penguin", ModLoader.getUniqueEntityId()); //This registers the entity
               
                ModLoader.AddSpawn("Penguin", 3, EnumCreatureType.creature,new BiomeGenBase[] {
                                BiomeGenBase.iceDesert,
                                BiomeGenBase.taiga,
                                BiomeGenBase.tundra                          
                });

                              
  
    }
        
        // RENDERERS
        public void AddRenderer(Map map)
    {
        map.put(EntityPenguin.class, new RenderPenguin(new ModelPenguin(), 0.5F)); // this assigns the Entity class to the renderer and model class.
    }

    public String Version()
    {
        return "Penguin Mod 1.0"; //this can be whatever you like
    }

}[/mw_shl_code]

[mw_shl_code=java,true]ModLoader.AddSpawn(java.lang.String entityName, int weightedProb, lg spawnList, new BiomeGenBase[] { biomes })[/mw_shl_code]

这一段代码是将该生物添加至Minecraft的生成名单中,其中
"WeightedPro"代表着该生物的生成几率。
"SpawnList"代表生物种类
  • EnumCreatureType.creature 为动物(典型生物:猪)
  • EnumCreatureType.monster 为敌人(典型生物:僵尸)
  • ENumCreatureType.watercreature 为水生生物(典型生物:墨鱼)
"BiomeGenBase"为指向生物所在生物群戏的指针。
  • BiomeGenBase.savanna        热带草原
  • BiomeGenBase.swampland    沼泽
  • BiomeGenBase.shrubland      灌木林地
  • BiomeGenBase.plains             平原
  • BiomeGenBase.iceDesert       冰漠
  • BiomeGenBase.taiga              针叶林
  • BiomeGenBase.forest            森林
  • BiomeGenBase.seasonalForest      季节性森林
  • BiomeGenBase.rainforest      雨林
  • BiomeGenBase.desert           沙漠

生成实体(entity)文件


实体文件决定了该生物所使用的材质、声音、AI、掉落物以及其他您所希望实现的功能

[mw_shl_code=java,true]package net.minecraft.src;

public class EntityPenguin extends EntityAnimals
{

    public EntityPenguin(World world)
    {
        super(world);
        texture = "Penguin/Penguin.png"; //this set the texture the mobs going to use
        setSize(1.5F, 1.9F); // this sets the HIT AREA of the mob.
    }

    public void writeEntityToNBT(NBTTagCompound nbttagcompound)
    {
        super.writeEntityToNBT(nbttagcompound); // this saves the mob to disk
    }

    public void readEntityFromNBT(NBTTagCompound nbttagcompound)
    {
        super.readEntityFromNBT(nbttagcompound); // this loads the mob from disk
    }

    protected String getLivingSound()
    {
        return null; //Living sound of the mob
    }

    protected String getHurtSound()
    {
        return null; //Hurt sound of the mob
    }

    protected String getDeathSound()
    {
        return null; //Death sound of the mob
    }

    protected float getSoundVolume()
    {
        return 0.4F;
    }

    protected int getDropItemId()
    {
        return 0; //this is the item id of the drop for example  Item.porkchop.shiftedIndex
    }
}[/mw_shl_code]

企鹅模型


以前文所述的企鹅模型为例,如果需要也可以在此处下载。



企鹅模型的渲染



如果不熟悉操作请不要编辑此处!!

[mw_shl_code=java,true]package net.minecraft.src;


public class RenderPenguin extends RenderLiving
{

    public RenderPenguin(ModelBase modelbase, float f)
    {
        super(modelbase, f);
    }

    public void func_177_a(EntityPenguin entitypenguin, double d, double d1, double d2,
            float f, float f1)
    {
        super.doRenderLiving(entitypenguin, d, d1, d2, f, f1);
    }

    public void doRenderLiving(EntityLiving entityliving, double d, double d1, double d2,
            float f, float f1)
    {
        func_177_a((EntityPenguin)entityliving, d, d1, d2, f, f1);
    }

    public void doRender(Entity entity, double d, double d1, double d2,
            float f, float f1)
    {
        func_177_a((EntityPenguin)entity, d, d1, d2, f, f1);
    }
}[/mw_shl_code]

原文地址:http://www.mcbbs.net/thread-37432-1-1.html

Techne教程总汇帖:https://www.gn00.com/t-88994-1-1.html
补档?不存在的
回复

使用道具 举报

该用户从未签到

388

主题

2042

好友

10万

积分

懒人

积分
104579
发表于 2012-7-31 09:41:54 | 显示全部楼层
@3*wz
签名被小宅喵吞掉了~~~~(>_<)~~~~
回复 支持 反对

使用道具 举报

该用户从未签到

3

主题

26

好友

3064

积分

序章

积分
3064
发表于 2016-10-11 11:59:06 | 显示全部楼层
额,这个那个、这是什么代码
签名被小宅喵吞掉了~~~~(>_<)~~~~
回复 支持 反对

使用道具 举报

签到天数: 2 天

连续签到: 1 天

[LV.1]初来乍到

1

主题

0

好友

1357

积分

Continue

积分
1357
发表于 2017-10-27 22:44:07 | 显示全部楼层
感觉好复杂,不过,感谢分享~
签名被小宅喵吞掉了~~~~(>_<)~~~~
回复 支持 反对

使用道具 举报

本版积分规则

小黑屋|手机版|技术宅(基宅) ( 粤ICP备18082987号-1 | 浙公网安备 33010902001746号 )

GMT+8, 2024-4-25 21:38 , Processed in 0.612413 second(s), 16 queries , Redis On.

Copyright © 2018 技术宅社区

Powered by Discuz! X3.5

快速回复 返回顶部 返回列表