- UID
- 876
- 在线时间
- 0 小时
- 最后登录
- 2019-1-14
- 注册时间
- 2011-6-19
- 宅魂
- 4869 点
- 贡献
- 10625 点
- 宅币
- 104074 枚
- 宅の石(入宅度)
- 130 块
- 元气(技能点)
- 174 点
- 活跃
- 134 ℃
- 听众
- 44
- 收听
- 20
签到天数: 25 天 连续签到: 1 天 [LV.4]偶尔看看III
最终章
☆非拔作不Ctrl★
- 积分
- 159739
|
使用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
|
|