Minecraft(我的世界)中文论坛

标题: [techne wiki]如何使用modloader生成实体(做企鹅第二篇)

作者: DJXGAME    时间: 2012-7-29 01:06
标题: [techne wiki]如何使用modloader生成实体(做企鹅第二篇)
本帖最后由 DJXGAME 于 2013-1-30 17:00 编辑

原文地址: http://minecraftmodding.wikkii.com/wiki/Making_an_new_entity_using_modloader_(Penguin)
PS:为方便大家使用,所有关键位置均使用中英双语翻译。

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



Modloader


  1. package net.minecraft.src;
  2. import java.util.*;
  3. import java.util.Map;

  4. public class mod_Penguin extends BaseMod
  5. {
  6.         
  7.     public mod_Penguin()
  8.     {
  9.                 ModLoader.RegisterEntityID(EntityPenguin.class, "Penguin", ModLoader.getUniqueEntityId()); //This registers the entity
  10.                
  11.                 ModLoader.AddSpawn("Penguin", 3, EnumCreatureType.creature,new BiomeGenBase[] {
  12.                                 BiomeGenBase.iceDesert,
  13.                                 BiomeGenBase.taiga,
  14.                                 BiomeGenBase.tundra                          
  15.                 });

  16.                               
  17.   
  18.     }
  19.         
  20.         // RENDERERS
  21.         public void AddRenderer(Map map)
  22.     {
  23.         map.put(EntityPenguin.class, new RenderPenguin(new ModelPenguin(), 0.5F)); // this assigns the Entity class to the renderer and model class.
  24.     }

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

  29. }
复制代码
  1. ModLoader.AddSpawn(java.lang.String entityName, int weightedProb, lg spawnList, new BiomeGenBase[] { biomes })
复制代码

[/spoiler]
这一段代码是将该生物添加至Minecraft的生成名单中,其中
"WeightedPro"代表着该生物的生成几率。
"SpawnList"代表生物种类
"BiomeGenBase"为指向生物所在生物群戏的指针。

[/spoiler]


生成实体(entity)文件

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

  1. package net.minecraft.src;

  2. public class EntityPenguin extends EntityAnimals
  3. {

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

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

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

  18.     protected String getLivingSound()
  19.     {
  20.         return null; //Living sound of the mob
  21.     }

  22.     protected String getHurtSound()
  23.     {
  24.         return null; //Hurt sound of the mob
  25.     }

  26.     protected String getDeathSound()
  27.     {
  28.         return null; //Death sound of the mob
  29.     }

  30.     protected float getSoundVolume()
  31.     {
  32.         return 0.4F;
  33.     }

  34.     protected int getDropItemId()
  35.     {
  36.         return 0; //this is the item id of the drop for example  Item.porkchop.shiftedIndex
  37.     }
  38. }
复制代码

企鹅模型

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


企鹅模型的渲染


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


  1. package net.minecraft.src;


  2. public class RenderPenguin extends RenderLiving
  3. {

  4.     public RenderPenguin(ModelBase modelbase, float f)
  5.     {
  6.         super(modelbase, f);
  7.     }

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

  13.     public void doRenderLiving(EntityLiving entityliving, double d, double d1, double d2,
  14.             float f, float f1)
  15.     {
  16.         func_177_a((EntityPenguin)entityliving, d, d1, d2, f, f1);
  17.     }

  18.     public void doRender(Entity entity, double d, double d1, double d2,
  19.             float f, float f1)
  20.     {
  21.         func_177_a((EntityPenguin)entity, d, d1, d2, f, f1);
  22.     }
  23. }
复制代码




作者: R小U明B    时间: 2012-7-29 01:14
编程小白撸过
作者: jianghr    时间: 2012-7-29 01:37
暂时没有编mod的打算,先围观一下,近期快点撸个不正经的过山车骗个勋章才好。
你有做个过山车的打算吗?
作者: DJXGAME    时间: 2012-7-29 01:39
jianghr 发表于 2012-7-29 01:37
暂时没有编mod的打算,先围观一下,近期快点撸个不正经的过山车骗个勋章才好。
你有做个过山车的打算吗?

哦吼吼,我的wiki翻译实验用过山车已经交上去了~~~~
作者: DJXGAME    时间: 2012-7-29 01:40
jianghr 发表于 2012-7-29 01:37
暂时没有编mod的打算,先围观一下,近期快点撸个不正经的过山车骗个勋章才好。
你有做个过山车的打算吗?

人家是辅修英语的工科电脑小白痴啦……
作者: jianghr    时间: 2012-7-29 01:44
DJXGAME 发表于 2012-7-29 01:39
哦吼吼,我的wiki翻译实验用过山车已经交上去了~~~~

哦,我倒没想起来……那贴我还回过的。目前我的构思相当不靠谱,过"山"车只是很小一部分,多数在摆弄机关结构。
作者: DJXGAME    时间: 2012-7-29 01:45
jianghr 发表于 2012-7-29 01:44
哦,我倒没想起来……那贴我还回过的。目前我的构思相当不靠谱,过"山"车只是很小一部分,多数在摆弄机关 ...

可以多分支有剧情的过山车吧~~~
作者: jianghr    时间: 2012-7-29 01:55
DJXGAME 发表于 2012-7-29 01:45
可以多分支有剧情的过山车吧~~~

额,机关的布线比较大,多分支就绕到一起去了,还是随便软件导入几张像素画忽悠忽悠吧。
矿车不抗炸真纠结,你翻译肯定实验过,我校对也实验了,不然埋一堆TNT把连车带人炸得各种飞。
作者: DJXGAME    时间: 2012-7-29 01:58
jianghr 发表于 2012-7-29 01:55
额,机关的布线比较大,多分支就绕到一起去了,还是随便软件导入几张像素画忽悠忽悠吧。
矿车不抗炸真纠 ...

那个燃烧的矿车我至今未成功……你不妨以那个为切入点~~~
作者: jianghr    时间: 2012-7-29 02:04
DJXGAME 发表于 2012-7-29 01:58
那个燃烧的矿车我至今未成功……你不妨以那个为切入点~~~

猫小沫签名里的存档共享里的过山车有一直烧的矿车。他说是为了点亮便于大家看到。你可以看看,不过存档解开1G多,1.1转换1.2.5我是花了至少半小时。
作者: jacky1440    时间: 2012-7-29 09:36
这个我会~{:10_492:}
支持~
作者: scott    时间: 2012-7-29 11:59
做个him吧      
作者: 圣灵玫瑰灬梦    时间: 2012-8-1 21:34
小白撸过顺便学一学
作者: lokbb111    时间: 2012-8-21 20:21
很棒的紋理喔!
作者: 公猫    时间: 2012-8-24 17:16
继续看不懂。。。
作者: jiawen123    时间: 2014-2-23 19:08
好难懂哦。。。{:10_495:}
作者: 459266263    时间: 2016-1-31 12:44
顶一个,最近想自制模型放进npcmod里面,但是不知道怎么弄成class文件...毕竟我是小白,话说挖坟应该没事吧...这么好的帖子