Minecraft Blogs

Minecraft Mod Coding Tips

  • 2
  • 1
  • 2
avatar Crafte_Family
Level 12 : Journeyman Explorer
1
This is a blog on Minecraft Modding. I am using ModLoader and this is for 1.3.2.
I am not sure if the coding is the same for 1.4.2.
*This is not a tutorial on how to make a mod, this is just for making some useful code*


---------------Tip Number One---------------
To add a potion effect to a food item, type this in or copy and paste it :

.setPotionEffect(Potion.moveSpeed.id, 60, 10, 10)

The "60" is how many seconds the potion buff will last, I am not too sure what the last "10" means. This potion is level 10.. This is code to add a speed boost for 60 seconds. I will add another potion effect code :

.setPotionEffect(Potion.heal.id, 30, 2, 10)

This is the Instant Health buff, and it will last 30 seconds. It is level 3. I guess if you type in "0" for the second number, it will be level one. So 2 would be level 3.

---------------Tip Number Two---------------
This tip is going to be on how to make a custom ore generate through-out the world, and what item it will drop.
First, create a new .class file, and copy all of this in :

package net.minecraft.src;
import java.util.Random;

public class [new class name] extends Block {

public [new class name](int i, int j) {
super(i, j, Material.iron);

}

public int idDropped(int i, Random random, int j){
return mod_[mod name].[Item name the block will drop].shiftedIndex;

}

public int quantityDropped(Random par1Random){
return 1;
}
}

The "return 1;" means the number of items this block will drop when it is mined.
Now it is the code for the ore generation :

public void generateSurface(World world, Random random, int i, int j){

for(int a = 0; a < 25; a++){
int PosX = i + random.nextInt(16);
int PosY = random.nextInt(64);
int PosZ = j + random.nextInt(16);

(new WorldGenMinable([Blockname].blockID, 12)).generate(world, random, PosX, PosY, PosZ);


"(64)" will allow the ore to generate, along with the other "int Pos" letters. The number 12 means that there will be 12 blocks in one vain. The 25 is a percentage of how common it is. Say, if you put 50, it would be WAY easier to find than coal, and putting something low like 2 would be rarer than Diamond.
-------------------------------------------------------
I hope this 2 tips helped some new coders! I will be posting more soon!
Tags

1
10/18/2012 8:35 pm
Level 26 : Expert Dragonborn
TheMinerScrollsV
Thanks!
1
10/19/2012 2:21 pm
Level 12 : Journeyman Explorer
Crafte_Family
No problem!
Planet Minecraft Logo

Website

© 2010 - 2020
www.planetminecraft.com

Welcome