第一篇教程
如果编译时出了错误,请把错误报告发上来
一.如何在MCP里装modloader(只需改一下教程1的方法)
先把MCP解压了(我解压到了C盘 C:\MCP),复制BIN和RESOURCE和官方服务端到MCP目录里的jars文件夹(C:\MCP\JARS)然后点开decompile.bat,完成
注意!! 复制BIN之前先在MINECRAFT.JAR里装入modloader并删掉meta-inf文件夹
然后decompile
二.如何用modloader添加一条合成公式
先在src文件夹里创建个名为mod_xxx.java的文件(xxx可以随便改),打开输入
- package net.minecraft.src;
- public class mod_xxx extends BaseMod
- {
- public String Version()
- {
- return "1.0 ";
- }
- public mod_xxx ()
- {
- ModLoader.AddRecipe(new ItemStack(tnt, 1), new Object[] {"s", "s", Character.valueOf('s'), Block.dirt});
- }
-
- }
”public String Version()“为mod的版本号(不可以去掉 否则会崩溃),
ModLoader.AddRecipe(new ItemStack(tnt, 1), new Object[] {"s", "s", Character.valueOf('s'), Block.dirt});
这条就是合成公式啦,“new ItemStack(tnt, 1)”为合成后的物品,”"s", "s", Character.valueOf('s'), Block.dirt“为合成配方(打竖的两个土)
二.用modloader添加一个新方块
我们先新建一个名为Blockexample.java的文件,打开输入
- package net.minecraft.src;
- import java.util.Random;
- public class Blockexample extends Block
- {
- public Blockexample(int i, int j)
- {
- super(i, j, Material.rock);
- }
- public int idDropped(int i, Random random)
- {
- return this.blockID;
- }
- }
其实这里是引用了教程1的代码= =,modloader比MCP方便的原因之一就是添加东东不用怎么修改游戏自带文件,减少冲突
然后我们打开mod_xxx.java,添加一条
public static final Block example = (new Blockexample (114,0)).setHardness(0.3F).setResistance(30F).setBlockName("example");;
“public static final Block example”算是给这方块一个名字,在编mod时和下文用得到,“(new Blockexample (114,0))”是引用blockexample.java文件(刚刚弄的),方块编号为114,之后的那些sethardness之类的在教程1已经讲过
然后再添加
- example.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/xxx/example.png");
- ModLoader.RegisterBlock(example );
- ModLoader.AddRecipe(new ItemStack(example , 1), new Object[]{ "X", Character.valueOf('X'), Block.cobblestone});
- ModLoader.AddName(example , "example");
这个不用说啦,合成公式 “ModLoader.AddName(example , "example");”这个是添加此方块在游戏中的名字(就叫example吧)
完整代码如下:
- package net.minecraft.src;
- public class mod_xxx extends BaseMod
- {
- public static final Block example = (new Blockexample (114,0)).setHardness(0.3F).setResistance(30F).setBlockName("example");;
- public String Version()
- {
- return "1.0 ";
- }
-
- public mod_xxx ()
- {
-
-
- example.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/xxx/example.png");
- ModLoader.RegisterBlock(example );
- ModLoader.AddRecipe(new ItemStack(example , 1), new Object[]{ "X", Character.valueOf('X'), Block.cobblestone});
- ModLoader.AddName(example , "example");
-
-
- }
-
-
- }
三.用modloader制作一个新物品
直接引用教程1的代码吧,把教程1的代码放入src文件夹,打开mod_xxx.java 输入
- public static final Item test = (new ItemExample (3010)).setItemName("test");;
其实与方块的差不多,那就略过吧= =,继续输入
- test.iconIndex = ModLoader.addOverride("/gui/items.png", "/xxx/test.png");
- ModLoader.AddName(test, "test");
- ModLoader.AddRecipe(new ItemStack(test, 1), new Object[] {"s", "s", Character.valueOf('s'), Block.stone});
完整代码如下
- package net.minecraft.src;
- public class mod_xxx extends BaseMod
- {
- public static final Item test = (new ItemExample (3010)).setItemName("test");;
- public String Version()
- {
- return "1.0 ";
- }
-
- public mod_xxx ()
- {
-
- test.iconIndex = ModLoader.addOverride("/gui/items.png", "/xxx/test.png");
- ModLoader.AddName(test, "test");
- ModLoader.AddRecipe(new ItemStack(test, 1), new Object[] {"s", "s", Character.valueOf('s'), Block.stone});
- }
-
- }
四.如何制做一个新的NPC(动物类)
先新建一个EntityXXX.java文件,写上
- // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
- // Jad home page: http://www.kpdus.com/jad.html
- // Decompiler options: packimports(3) braces deadcode
- package net.minecraft.src;
- import java.util.Random;
- // Referenced classes of package net.minecraft.src:
- // EntityAnimal, Item, EntityPlayer, InventoryPlayer,
- // ItemStack, World, NBTTagCompound
- public class EntityXXX extends EntityAnimal
- {
- public EntityXXX(World world)
- {
- super(world);
- texture = "/mob/xxx.png";
- setSize(0.9F, 1.3F);
- }
- public void writeEntityToNBT(NBTTagCompound nbttagcompound)
- {
- super.writeEntityToNBT(nbttagcompound);
- }
- public void readEntityFromNBT(NBTTagCompound nbttagcompound)
- {
- super.readEntityFromNBT(nbttagcompound);
- }
- protected String getLivingSound()
- {
- return "mob.cow";
- }
- protected String getHurtSound()
- {
- return "mob.cowhurt";
- }
- protected String getDeathSound()
- {
- return "mob.cowhurt";
- }
- protected float getSoundVolume()
- {
- return 0.4F;
- }
- protected int getDropItemId()
- {
- return Block.stone.shiftedIndex;
- }
- }
texture = "/mob/xxx.png"; 是NPC的皮肤的路径,setSize(0.9F, 1.3F);是NPC的大小(这是改NPC的实际大小 改显示的大小在render文件里)
然后我们需要模型和render文件,我们需要用到Techne ,可以自己制作模型和render文件
制作完后将render和模型文件放入src文件夹,然后打开mod_xxx.java
加上这句
- ModLoader.RegisterEntityID(EntityXXX.class, "XXX", ModLoader.getUniqueEntityId());
- ModLoader.AddSpawn(EntityXXX.class, 10, EnumCreatureType.creature);
- public void AddRenderer(Map map)
- {
- map.put(EntityXXX.class, new RenderXXX(new ModelXXX(), 0.5F));
- }
完整代码如下
- package net.minecraft.src;
- public class mod_xxxextends BaseMod
- {
- public void AddRenderer(Map map)
- {
- map.put(EntityXXX.class, new RenderXXX(new ModelXXX(), 0.5F));
- }
- public String Version()
- {
- return "1.0 ";
- }
-
-
- public mod_xxx ()
- {
-
- ModLoader.RegisterEntityID(EntityXXX.class, "XXX", ModLoader.getUniqueEntityId());
- ModLoader.AddSpawn(EntityXXX.class, 10, EnumCreatureType.creature);
-
- }
- }
剩下的晚上再更新