转载请注明原帖地址
一.设置MCP
需要的东西:
MCP:http://mcp.ocean-labs.de/index.php/MCP_Releases
干净的MINECRAFT
官方服务端
JDK6
先把MCP解压了(我解压到了C盘 C:\MCP),复制BIN和RESOURCE和官方服务端到MCP目录里的jars文件夹(C:\MCP\JARS)然后点开decompile.bat,完成
二.制作新的合成公式
打开mcp里的src文件夹(MCP\src\minecraft\net\minecraft\src)找到CraftingManage.java,打开(记事本都行的),可以看到类似于这个的代码
- addRecipe(new ItemStack(Block.trapdoor, 1), new Object[] {
- "###", "###", Character.valueOf('#'), Block.planks
- });
假如我想做1个沙换1个TNT的公式,代码如下
- addRecipe(new ItemStack(Block.TNT, 1), new Object[] {
- "#", Character.valueOf('#'), Block.sand
- });
写好后就可以测试了,打开MCP目录下的recompile.bat,让它检查错误,检查完成后可以打开startclient.bat进入游戏测试,测试完成后打开mcp目录下的reobfuscate.bat,让它把刚刚修改的文件打包,打包完后的文件可以在reobf文件夹找到
三.制作一个新方块
新建一个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 0;
- }
- }
新的方块就做好了,接下来是将其添加到游戏中,打开Block.java,大概720+行,找到
- public static final Block trapdoor;
在这句代码下面添加上
- public static final Block example;
然后继续往下翻,找到
- trapdoor = (new BlockTrapDoor(96, Material.wood)).setHardness(3F).setStepSound(soundWoodFootstep).setBlockName("trapdoor").disableStats().disableNeighborNotifyOnMetadataChange();
在下面添加上
- example = (new BlockExample(111, 49)).setHardness(1.5F).setResistance(5000000F).setStepSound(soundStoneFootstep);
111为方块的ID(97-255为空方块ID),49为材质编号(可以参考别的方块),setHardness(1.5F)为挖时的速度(1.5F为手挖石头的速度),setResistance(5000000F)是方块的抗炸强度(也可以参考别的方块的数值),setStepSound(soundStoneFootstep)是踩在方块上的脚步声(这里是石头的)
最后,打开recompile检查吧
四.添加一个新物品
新建一个ItemTest.java(名字还是自己改),在里面写上
- package net.minecraft.src;
-
- public class ItemTest extends Item
- {
-
- public ItemExample(int i, int k)
- {
- super(i);
- maxStackSize = 64;
- }
- //这里可以自己添加代码
- }
- public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
- {
- itemstack.stackSize--;
- world.playSoundAtEntity(entityplayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
- if(!world.multiplayerWorld)
- {
- world.entityJoinedWorld(new EntityArrow(world, entityplayer));
- }
- return itemstack;
- }
这条代码使手持此物品时右键可以扔出箭
好了 接下来就要把新物品添加进游戏了 打开Item.java 找到这条代码
- public static Item recordCat = (new ItemRecord(2001, "cat")).setIconCoord(1, 15).setItemName("record");
在这条代码下面添加一句
- public static Item test = (new ItemTest(120, 0)).setIconCoord(5, 5).setItemName("example");
注意! 120不是物品的真正ID,物品的真正ID为120+256 , (5, 5)是物品的材质(可以参考前面的物品)
现在可以打开recompile.bat检查代码了
五.削弱enderman
首先,我们打开EntityEnderman.java ,然后从第326行开始,你可以看到如下代码
- field_35186_b = new boolean[256];
- field_35186_b[Block.stone.blockID] = true;
- field_35186_b[Block.grass.blockID] = true;
- field_35186_b[Block.dirt.blockID] = true;
- field_35186_b[Block.cobblestone.blockID] = true;
- field_35186_b[Block.planks.blockID] = true;
- field_35186_b[Block.sand.blockID] = true;
- field_35186_b[Block.gravel.blockID] = true;
- field_35186_b[Block.oreGold.blockID] = true;
- field_35186_b[Block.oreIron.blockID] = true;
- field_35186_b[Block.oreCoal.blockID] = true;
- field_35186_b[Block.wood.blockID] = true;
- field_35186_b[Block.leaves.blockID] = true;
- field_35186_b[Block.sponge.blockID] = true;
- field_35186_b[Block.glass.blockID] = true;
- field_35186_b[Block.oreLapis.blockID] = true;
- field_35186_b[Block.blockLapis.blockID] = true;
- field_35186_b[Block.sandStone.blockID] = true;
- field_35186_b[Block.cloth.blockID] = true;
- field_35186_b[Block.plantYellow.blockID] = true;
- field_35186_b[Block.plantRed.blockID] = true;
- field_35186_b[Block.mushroomBrown.blockID] = true;
- field_35186_b[Block.mushroomRed.blockID] = true;
- field_35186_b[Block.blockGold.blockID] = true;
- field_35186_b[Block.blockSteel.blockID] = true;
- field_35186_b[Block.brick.blockID] = true;
- field_35186_b[Block.tnt.blockID] = true;
- field_35186_b[Block.bookShelf.blockID] = true;
- field_35186_b[Block.cobblestoneMossy.blockID] = true;
- field_35186_b[Block.oreDiamond.blockID] = true;
- field_35186_b[Block.blockDiamond.blockID] = true;
- field_35186_b[Block.workbench.blockID] = true;
- field_35186_b[Block.oreRedstone.blockID] = true;
- field_35186_b[Block.oreRedstoneGlowing.blockID] = true;
- field_35186_b[Block.ice.blockID] = true;
- field_35186_b[Block.cactus.blockID] = true;
- field_35186_b[Block.blockClay.blockID] = true;
- field_35186_b[Block.pumpkin.blockID] = true;
- field_35186_b[Block.netherrack.blockID] = true;
- field_35186_b[Block.slowSand.blockID] = true;
- field_35186_b[Block.glowStone.blockID] = true;
- field_35186_b[Block.pumpkinLantern.blockID] = true;
- field_35186_b[Block.field_35285_bn.blockID] = true;
- field_35186_b[Block.field_35286_bo.blockID] = true;
- field_35186_b[Block.field_35287_bp.blockID] = true;
- field_35186_b[Block.field_35281_bs.blockID] = true;
这些就是enderman可以拿起的方块, 根据谷歌翻译,我们可以知道true的意思是行的而false的意思是不行的。所以 如果我想要让enderman拿不起什么的石头的话,可以这样改:
- field_35186_b[Block.stone.blockID] = false;
我们还可以修改它的一些基础数值来玩
- field_35187_a = false;
- field_35184_d = 0;
- field_35185_e = 0;
- texture = "/mob/enderman.png";
- moveSpeed = 0.2F;
- attackStrength = 5;
- setSize(0.6F, 2.9F);
- stepHeight = 1.0F;
前三个我暂时没看明白,texture是皮肤的路径,moveSpeed为移动速度,attackStrength为攻击威力(试试改成负数),setSize是改大小(皮肤不会改变 占地变了而已),stepHeight为它的身高(貌似0.5F等于1格)
放个挺好玩的代码
public boolean interact(EntityPlayer entityplayer)
{
this.motionY += 1;
return true;
}
在entityenderman.java里加入这条即可,功能为右键enderman后他的y坐标+1 也就是飞起来