In these tutorials i will be teaching you how to mod Minecraft.
I will try to use ONLY Modloader, but i may eventually add forge later.
I am a member/leader of cube modding. We are dedicated to making quality mods and quality tutorials. Be sure to check us out here!
How to install Mods in Minecraft :
Mac -
If you are running OS X Lion or later, open up the application Terminal
Copy and paste this line of code into terminal -
[code]chflags nohidden ~/Library/[/code]
After that, navigate to your Users folder.
Go to YOUR user file < Library < Application Support < Minecraft
From there, open your Bin folder. Locate your minecraft.jar and re-name it to minecraft.zip
Double click the .zip file and a folder will appear.
Rename the new folder to minecraft.jar
Open up the new folder and delete the file META-INF
From here on, download a mod, open it, and copy+paste the .zip files into your minecraft folder.
PROFIT
Windows -
Search for the file %APPDATA%
Locate your .minecraft folder
Locate your Bin Folder
Open the minecraft.jar file with WinRAR/7Zip
Delete META-INF
Drag your mod class files into it
PROFIT
There are other Java Programs out there, but Eclipse is the best, especially for MCP.
Setting up MCP-
d9b_RVpAYvc
Tutorial 1 - Blocks
Mod_ File
[code]package net.minecraft.src
public class mod_BlockTut extends BaseMod
{
public static final Blockname = new BlockName(160, 0).setBlockName("BlockName(Anything)").setHardness(3F).setResistance(4F).setLightValue(1F);
//Register the block code
//What this means: SetHardness chooses how hard the block is, the resistance is almost the same thing, and the light value is how much light it gives off.
public void load()
{
Name.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/block.png");
ModLoader.registerBlock(BlockName);
ModLoader.addName(nameHere, "Tutorial Block (Ingame name)");
ModLoader.addRecipe(new ItemStack(nameHere, 1), new Object [] {"#", Character.valueOf('#'), Block.dirt});
//Register the texture and override terrain.png
//Register the block, add the name, and add the recipe.
}
public String getVersion()
{
return "Tutorail for 1.4.7";
}
}[/code] BlockTutorial File
[code]package net.minecraft.src;
import java.util.Random;
public class BlockTutorial extends Block
{
public BlockTutorial(int i, int j)
{
super(i, j, Material.wood);
}
public int idDropped(int i, Random random, int j)
{
return mod_Block.NameHere.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
//The # of items dropped
} [/code]
Tutorial 2 - Crafting
Mod_ File
[code]ModLoader.addRecipe(new ItemStack(itemtoreceive, quantity), new Object [] {"#@#", "%%%", "@#@", Character.valueOf('#'), Block.wood, Character.valueOf('@'), Block.dirt, Character.valueOf('%'), Item.blockDiamonds});
//Register the recipe[/code]
'ModLoader.addRecipe' is just the ModLoader method for adding a recipe.'(new ItemStack(itemtoreceive, quantity), new Object []' creates a new inventory stack of the item in brackets, and add the number after the item name to the quantity of the stack.'{"#@#", "%%%", "@#@", ' is the actual recipe of the item. The first set of quotes is the first row in the crafting table, the second set of quotes is the second row, and so on.'Character.valueOf('$'), Block.gold... ' means to associate the name of the block/item, with the symbol in brackets, and then that symbol in the recipe.
Tutorial 3 - Smelting
Mod_ File
[code]ModLoader.addSmelting(Block.oreDiamond.blockID, new ItemStack(Item.ingotIron, 1), 1.0F);
//Diamond ore ---> Iron Ingot[/code]
Tutorial 4 - Food
Mod_ File
[code]package net.minecraft.src
public class mod_foodtut Extends Basemod
public static final Item <Item Name> = new ItemFood(5001, 4, 1F, false).setItemName("<namehere>");
//Register the ItemFood
public void load()
{
.iconIndex = ModLoader.addOverride("/gui/items.png","/path/image.png");
//override the items.png
ModLoader.addName(, "InGame Name Here");
ModLoader.addRecipe(new ItemStack(Namehere, 1), new Object [] {"#", "#",Character.valueOf('#'), Block.dirt});
//This says override the items.png and make it a different file. Than you add the recipe, look at previous tutorials.
}
{
public String getVersion()
{
}
}{[/code]
Tutorial 5 - Achievements
[code]package net.minecraft.src;
public class mod_AchievementTut extends BaseMod
{
public static final Achievement AchievementTut = new Achievement(4560, "AchievementTut", 5, 7, Item.iron, null).registerAchievement();
public void load()
{
ModLoader.addAchievementDesc(AchievementTut, "AchievementTut", "Achievement Sub-Name");
}
public void takenFromCrafting(EntityPlayer entityplayer, ItemStack itemstack, IInventory iinventory)
{
if(itemstack.itemID == Block.fence.blockID)
{
entityplayer.addStat(AchievementTut, 1);
}
}
public String getVersion()
{
return "1.4.7";
}
}[/code]
Tutorial 7 - Commands (MODLOADER)
Files needed -
NEW FILE - Command<Name>.java ServerCommandManager.java
Mod_Commands
Were going to be making a CommandSuicide tutorial. This will add the /suicide command.
CommandSuicide.java -
[code]package net.minecraft.src;
// Add the package
public class CommandSuicide extends CommandBase
{
public String getCommandName()
{
return "suicide";
}
// This is the command, its what you put after the '/'
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
{
EntityPlayer var3 = getCommandSenderAsPlayer(par1ICommandSender);
//gets the Players Entity, so it will kill them. If you wish to kill cows, it would be EntityCows and some more //code.
var3.attackEntityFrom(DamageSource.outOfWorld, 1000);
//Its saying to attack the entity and label the DamageSource. Check DamageSource.java for more info. 1000 // is the damage it gives.
par1ICommandSender.sendChatToPlayer("Player Commited Suicide");
// The message that appears in chat.
}
}
Expect more! This is just a simple tutorial!
ServerCommandManager.java -
[code]
//Add this line of code -
this.registerCommand(new CommandSuicide());
// this Registers the Command, CommandSuicide.[/code]
Mod_ File -
Just add
[code]ModLoader.addCommand (new CommandSuicide());[/code]
Congrats!
[/code]
Tutorial 8 -Fuels (MODLOADER)
Mod_ File
[code]package net.minecraft.src;
public class mod_FuleTut extends BaseMod
{
public static final Item foodTut = new Item(4999).setItemName("foodTut");
public void load()
{
nameHere.iconIndex = ModLoader.addOverride("/gui/items.png", "/foodTut.png");
ModLoader.addName(nameHere, "FoodTut");
ModLoader.addRecipe(new ItemStack(nameHere, 1), new Object [] {"#", '#', Block.grass.blockID});
}
public int addFuel(int i, int j){if(i == foodtut.shiftedIndex){return 2750;
}
return 0;
}
public String getVersion(){return "1.3.2 Food tutorial";}}[/code] Tutorial 9 - NPC's (MODLOADER)
Mod_ File
[code]package net.minecraft.src;
import java.util.Random;
import java.util.Map;
import java.util.List;
import java.util.jar.*;
import java.util.*;
import java.util.logging.*;
import java.util.concurrent.*;
import java.awt.datatransfer.*;
import java.awt.geom.*;
import java.util.zip.*;
import java.awt.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import net.minecraft.client.Minecraft;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class mod_NPC extends BaseMod {
public String getVersion() {
return "NPC Mod For Minecraft 1.3.2";}
public void load() {
}
public void addRenderer(Map map) {
map.put(EntityNPC.class, new RenderBiped(new ModelBiped(), 0.5F));
ModLoader.registerEntityID(EntityNPC.class, "NPC", 231);
ModLoader.addSpawn(EntityNPC.class, 4, 4, 10, EnumCreatureType.creature);
//4,4,10 are the spawn rates. 231 is the ID
}
}[/code]
EntityNPC.java
[code]package net.minecraft.src;
import java.util.Random;
public class EntityNPC extends EntityCreature
{
public EntityNPC(World world)
{
super(world);
texture = "/mob/NPC.png";
//the texture
moveSpeed = 0.5F;
//move speed
attackStrength = 4; //take this line out if this class doesn't extend EntityMob.
}
public int getMaxHealth()
{
return 10;
//the health (every 1 is HALF a point!)
}
protected String getLivingSound()
{
return "mob.villager.default";
}
protected String getHurtSound()
{
return "mob.villager.defaulthurt";
}
protected String getDeathSound()
{
return "mob.villager.defaultdeath";
}
//sounds
protected int getDropItemId()
{
return Item.ingotgold.shiftedIndex;
}
//what it drops
protected boolean canDespawn()
{
return true;
}
}[/code]
Tutorial 9 - Stairs
Mod_ File
[code]package net.minecraft.src;
public class mod_Stairs extends BaseMod
{
public static final Block tutorialstair= new BlockTutorialStair(170, 0).setBlockName("tutorialstair").setHardness(5F).setResistance(4F);
public void load()
{
nameHere.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/tutorialstair.png");
ModLoader.registerBlock(tutorialstair);
ModLoader.addName(nameHere, "Tutorial Stair");
ModLoader.addRecipe(new ItemStack(tutorialstair, 3), new Object [] {"# ", "## ", "###", Character.valueOf('#'), Block.fire});
}
public String getVersion()
{
return "Stairs Tutorial 1.3.2";
}
}[/code]
BlockTutorialStair file
[code]package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class BlockTutorialStair extends Block
{
private static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}};
private boolean field_72156_cr = false;
private int field_72160_cs = 0;
protected BlockTutorialStair(int i, int j)
{
super(i, j, Material.rock);
this.setLightOpacity(255);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Updates the blocks boundary depending on the blocs current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
if (this.field_72156_cr)
{
this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2));
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
/**
* Is this block opaque (transparent) and a full 1m cube? This determines whether or not to render the shared face of them
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block (stairs are 10)
*/
public int getRenderType()
{
return 10;
}
/**
* if the specified block is in the given AABB, add its collision bounding box to the given list
*/
public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
{
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
float var10 = 0.0F;
float var11 = 0.5F;
float var12 = 0.5F;
float var13 = 1.0F;
if ((var8 & 4) != 0)
{
var10 = 0.5F;
var11 = 1.0F;
var12 = 0.0F;
var13 = 0.5F;
}
this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
if (var9 == 0)
{
this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 1)
{
this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 2)
{
this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 3)
{
this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4;
if (var6 == 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7);
}
if (var6 == 1)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7);
}
if (var6 == 2)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7);
}
if (var6 == 3)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7);
}
}
public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8)
{
if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D)
{
int var9 = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4);
}
}
/**
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,
* x, y, z, startVec, endVec
*/
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
{
MovingObjectPosition[] var7 = new MovingObjectPosition[8];
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
boolean var10 = (var8 & 4) == 4;
int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)];
this.field_72156_cr = true;
int var14;
int var15;
int var16;
for (int var12 = 0; var12 < 8; ++var12)
{
this.field_72160_cs = var12;
int[] var13 = var11;
var14 = var11.length;
for (var15 = 0; var15 < var14; ++var15)
{
var16 = var13[var15];
if (var16 == var12)
{
;
}
}
var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
int[] var21 = var11;
int var24 = var11.length;
for (var14 = 0; var14 < var24; ++var14)
{
var15 = var21[var14];
var7[var15] = null;
}
MovingObjectPosition var23 = null;
double var22 = 0.0D;
MovingObjectPosition[] var25 = var7;
var16 = var7.length;
for (int var17 = 0; var17 < var16; ++var17)
{
MovingObjectPosition var18 = var25[var17];
if (var18 != null)
{
double var19 = var18.hitVec.squareDistanceTo(par6Vec3);
if (var19 > var22)
{
var23 = var18;
var22 = var19;
}
}
}
return var23;
}
}[/code]
Tutorial 10 - World Generation
Note - I currently dont have this written out, but thanks to Namore77 and Cube Modding for these tutorials!
World Generation #1
World Generation #2
Tutorial 11 - Enum/Custom Item (Custom materials)
EnumAToolMaterial.java
[code]package net.minecraft.src;
public enum EnumAToolMaterial
{
Sword1(0, 59, 2.0F, 0, 15),
Pick1(1, 131, 4.0F, 1, 5),
Spade1(2, 250, 6.0F, 2, 14),
Axe1(3, 1561, 8.0F, 3, 10),
/**
* The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD)
*/
private final int harvestLevel;
/**
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
*/
private final int maxUses;
/**
* The strength of this tool material against blocks which it is effective against.
*/
private final float efficiencyOnProperMaterial;
/** Damage versus entities. */
private final int damageVsEntity;
/** Defines the natural enchantability factor of the material. */
private final int enchantability;
private EnumAToolMaterial(int par3, int par4, float par5, int par6, int par7)
{
this.harvestLevel = par3;
this.maxUses = par4;
this.efficiencyOnProperMaterial = par5;
this.damageVsEntity = par6;
this.enchantability = par7;
}
/**
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
*/
public int getMaxUses()
{
return this.maxUses;
}
/**
* The strength of this tool material against blocks which it is effective against.
*/
public float getEfficiencyOnProperMaterial()
{
return this.efficiencyOnProperMaterial;
}
/**
* Damage versus entities.
*/
public int getDamageVsEntity()
{
return this.damageVsEntity;
}
/**
* The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD)
*/
public int getHarvestLevel()
{
return this.harvestLevel;
}
/**
* Return the natural enchantability factor of the material.
*/
public int getEnchantability()
{
return this.enchantability;
}
}[/code]
ItemSword1.java
[code]package net.minecraft.src;
public class ItemSword1 extends Item
{
private int weaponDamage;
private final EnumAToolMaterial toolMaterial;
public ItemSword1(int par1, EnumAToolMaterial par2EnumToolMaterial)
{
super(par1);
this.toolMaterial = par2EnumToolMaterial;
this.maxStackSize = 1;
this.setMaxDamage(par2EnumToolMaterial.getMaxUses());
this.setTabToDisplayOn(CreativeTabs.tabCombat);
this.weaponDamage = 4 + par2EnumToolMaterial.getDamageVsEntity();
}
/**
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
* sword
*/
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
{
return par2Block.blockID == Block.web.blockID ? 15.0F : 1.5F;
}
/**
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
* the damage on the stack.
*/
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
par1ItemStack.damageItem(1, par3EntityLiving);
return true;
}
public boolean func_77660_a(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving)
{
if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D)
{
par1ItemStack.damageItem(2, par7EntityLiving);
}
return true;
}
/**
* Returns the damage against a given entity.
*/
public int getDamageVsEntity(Entity par1Entity)
{
return this.weaponDamage;
}
/**
* Returns True is the item is renderer in full 3D when hold.
*/
public boolean isFull3D()
{
return true;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.block;
}
/**
* How long it takes to use or consume an item
*/
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 72000;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
return par1ItemStack;
}
/**
* Returns if the item (tool) can harvest results from the block type.
*/
public boolean canHarvestBlock(Block par1Block)
{
return par1Block.blockID == Block.web.blockID;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return this.toolMaterial.getEnchantability();
}
public String func_77825_f()
{
return this.toolMaterial.toString();
}
}[/code]
Tutorial 12 - Grenades Note - I tried a few new things towards the bottom of this file, I'll go more in-depth with them later. Its for the console/crash reports.
Mod_Grenades
[code]package net.minecraft.src;
import java.util.Map;
import net.minecraft.client.Minecraft;
public class mod_Grenades extends BaseMod
{
public static final Item Grenade = (new ItemGrenade(12000)).setItemName("grenade");
Minecraft mc;
public void load()
{
try
{
this.WNDATA(0, true);
this.WNDATA(1, true);
this.WNDATA(2, true);
this.initializeThrowableExplosives();
this.addRecipes();
}
catch (Exception var2)
{
System.out.println(var2.getMessage());
}
}
public void initializeThrowableExplosives()
{
ModLoader.addName(Grenade, "Grenade");
Grenade.iconIndex = ModLoader.addOverride("/gui/items.png", "/grenade.png");
}
public void addRecipes()
{
ModLoader.addRecipe(new ItemStack(mod_Grenade.Grenade, 3), new Object [] {"###", "%@%", "XXX", Character.valueOf('#'), Item.ingotIron, Character.valueOf('@'), Item.redstone, Character.valueOf('%'), Item.gunpowder, Character.valueOf('X'), Block.cobblestone});
}
public void WNDATA(int var1, boolean var2)
{
if (var1 == 0 && var2)
{
System.out.println("** Initializing Minecraft mod!!**" );
System.out.println("** Made by Jdembo/Giraffestock! **");
}
if (var1 == 1)
{
System.out.println("** Loading Mod **");
}
else if (var1 == 2)
{
System.out.println("** Loading Grenades **");
}
if (!var2)
{
System.out.println("** Loading complete **");
}
}
public String getVersion()
{
return "Minecraft Mod Tutorial by Jdembo/Giraffestock!";
}
}[/code]
ItemGrenade -
[code]package net.minecraft.src;
public class ItemGrenade extends Item
{
public static int GrenadeID;
public ItemGrenade(int var1)
{
super(var1);
this.maxStackSize = 16;
GrenadeID = this.shiftedIndex;
this.setTabToDisplayOn(CreativeTabs.tabCombat);
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3)
{
if (!var3.capabilities.isCreativeMode)
{
--var1.stackSize;
}
if (!var2.isRemote)
{
var2.spawnEntityInWorld(new EntityGrenade(var2, var3));
}
return var1;
}
}[/code]
EntityGrenade -
[code]package net.minecraft.src;
public class EntityGrenade extends EntityItem
{
double bounceFactor;
int fuse;
boolean exploded;
boolean collided;
boolean stopped;
public EntityGrenade(World var1)
{
super(var1);
this.setSize(0.5F, 0.5F);
this.yOffset = this.height / 2.0F;
this.item = new ItemStack(Item.itemsList[ItemGrenade.GrenadeID]);
this.bounceFactor = 0.6D;
this.exploded = false;
this.stopped = false;
this.fuse = 0;
// if you notice the Grenade not disappearing, try adding this method below - setDead();
}
public EntityGrenade(World var1, double var2, double var4, double var6, float var8, float var9, double var10, int var12)
{
this(var1);
this.setRotation(var8, 0.0F);
double var13 = (double)(-MathHelper.sin(var8 * (float)Math.PI / 180.0F));
double var15 = (double)MathHelper.cos(var8 * (float)Math.PI / 180.0F);
this.motionX = var10 * var13 * (double)MathHelper.cos(var9 / 180.0F * (float)Math.PI);
this.motionY = -var10 * (double)MathHelper.sin(var9 / 180.0F * (float)Math.PI);
this.motionZ = var10 * var15 * (double)MathHelper.cos(var9 / 180.0F * (float)Math.PI);
this.setPosition(var2 + var13 * 0.8D, var4, var6 + var15 * 0.8D);
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.fuse = var12;
}
public EntityGrenade(World var1, Entity var2)
{
this(var1, var2.posX, var2.posY, var2.posZ, var2.rotationYaw, var2.rotationPitch, 0.5D, 50);
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolve[/spoiler]s to
* prevent them from trampling crops
*/
protected boolean canTriggerWalking()
{
return false;
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
if (this.fuse-- <= 0)
{
this.explode();
}
if (!this.stopped && !this.exploded)
{
double var1 = this.motionX;
double var3 = this.motionY;
double var5 = this.motionZ;
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
boolean var7 = false;
if (this.motionX != var1)
{
this.motionX = -var1;
var7 = true;
}
if (this.motionZ != var5)
{
this.motionZ = -var5;
}
if (this.motionY != var3)
{
this.motionY = -var3;
var7 = true;
}
else
{
this.motionY -= 0.04D;
}
if (var7)
{
this.motionX *= this.bounceFactor;
this.motionY *= this.bounceFactor;
this.motionZ *= this.bounceFactor;
}
this.motionX *= 0.99D;
this.motionY *= 0.99D;
this.motionZ *= 0.99D;
if (this.onGround && this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ < 0.02D)
{
this.stopped = true;
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
}
}
}
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer var1) {}
protected void explode()
{
if (!this.exploded)
{
this.exploded = true;
this.worldObj.createExplosion((Entity)null, this.posX, this.posY, this.posZ, 3.0F);
}
}
public boolean attackEntity(Entity var1, int var2)
{
super.attackEntityFrom(DamageSource.causeThrownDamage(var1, var1), var2);
this.explode();
return false;
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound var1)
{
super.writeEntityToNBT(var1);
var1.setByte("Fuse", (byte)this.fuse);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound var1)
{
super.readEntityFromNBT(var1);
this.fuse = var1.getByte("Fuse");
}
}[/code]
Tutorial 13 - Making custom models with Techne Note - This was made for Cube Modding by KarryBird, I am the creator of CubeModding and have permission to use this.
Text-based coming soon!
Download Techne here Tutorial #1 -
Tutorial #2 -
Tutorial #3 -
Tutorial 14 -
Mod_ File
[code]package net.minecraft.src;
import java.util.Random;
public class mod_Tutorial extends BaseMod
{
public static final BiomeGenBase Test = (new BiomeGenTest(40)).setBiomeName("Test");
public void load()
{
}
{
ModLoader.addBiome(Test);
}
public String getVersion()
{
return "1.4.5";
}
public static void generateSurface(World world, Random rand, int chunkX, int chunkZ)
{
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(chunkX, chunkZ);
WorldGenTest tree = new WorldGenTest();
if(biome instanceof BiomeGenTest)
{
for(int x = 0; x < 8; x++)
{
tree = new WorldGenTest();
int Xcoord = chunkX + rand.nextInt(16);
int Zcoord = chunkZ + rand.nextInt(16);
int i = world.getHeightValue(Xcoord, Zcoord);
tree.generate(world, rand, Xcoord, i, Zcoord);
}
}
}
}[/code]
Tutorial 15 - Creative World Presets (vanilla)
This is a very simple process, which is fun to try out and use
You need the file GuiFlatPresets.java
[code]//Scroll down to this part:
static
{
addPreset("Classic Flat", Block.grass.blockID, BiomeGenBase.plains, Arrays.asList(new String[] {"village"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Block.grass.blockID), new FlatLayerInfo(2, Block.dirt.blockID), new FlatLayerInfo(1, Block.bedrock.blockID)});
//Simply copy it over.
// Classic Flat is its name, Block.grass.blockID is the block that is shown in the meny. BiomeGenBase.plains is what mobs can spawn there/weather. 'Village' means a village can spawn there. Look at other examples for more things to add. 1, Block.grass.blockID is stating that there should be one layer of grass, and so on.
Hope this helped :)
}[/code]
To Do -
Armor
Enum's (already started)
Mobs
Signatures-
Need Help?
Please put any errors/code in a spoiler! If you dont follow this, you WILL be ignored.
This block tutorial doesn't seem to work for me. Could you take a look at this code for me please?
mod java
package net.minecraft.src;
public class mod_DiaryofaMinecrafter
{
public static final Block coalBlock = new coalBlock(160, ModLoader.addOverride("/terrain.png", "/Blocks/coalBlock.png")).setBlockName("coalBlock").setHardness(3F);
public void load()
{
ModLoader.registerBlock(coalBlock);
ModLoader.addName(coalBlock, "Coal Block");
ModLoader.addRecipe(new ItemStack(coalBlock, 1), new Object[]{
"ccc", "c c", "ccc", Character.valueOf('c'), Item.coal
});
}
public String getVersion()
{
return "v 0.1";
}
}
block java
package net.minecraft.src;
import java.util.Random;
public class coalBlock extends Block
{
protected coalBlock(int i, int j)
{
super (i,j,Material.iron);
}
public int idDropped(int i, Random random, int j)
{
return mod_DiaryofaMinecrafter.coalBlock.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
}
It seems like it should work, but maybe Modloader (1.3.1) changed the block code more than i thought. Lemme check it out, sorry about that!
Ive got the same problem as AskMikeIfYaMAD, with the code:
Mod_BlockLight
package net.minecraft.src
[i]Create the package[/i]
public class mod_BlockLight extends BaseMod
{
public static final BlockLight = new BlockLight(160, 0).setBlockName("BlockLight").setHardness(3F).setResistance(2F).setLightValue(8F);
[i]Register the block code[/i]
[i]What this means. SetHardness chooses how hard the block is, the resistance is almost the same thing, and the light value is how much light it gives off. [/i]
public void load()
{
Light.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/BlockLight.png");
ModLoader.registerBlock(Light);
ModLoader.addName(BlockLight, "Fancy Light");
ModLoader.addRecipe(new ItemStack(BlockLight, 8), new Object [] {"@@@", "@#@", "@@@", Character.valueOf('@'), Block.glass, Character.valueOf('#')});
[i]Add the recipe[/i]
}
public String getVersion()
{
return "Fancy Light Loading, Loaded successfully, Have Fun :D";
}
}
BlockLight:
package net.minecraft.src;
import java.util.Random;
public class BlockLight extends Block
{
public BlockLight(int i, int j)
{
super(i, j, Material.stone);
}
public int idDropped(int i, Random random, int j)
{
return mod_Block.Light.160;
}
public int quantityDropped(Random random)
{
return 1;
}
}
And here are the MCP errors:
== MCP 7.0 (data: 7.0a, client: 1.3.1, server: 1.3.1) ==
# found jad, ff, jad patches, ff patches, osx patches, srgs, name csvs, doc csvs, param csvs, renumber csv, astyle, astyle config
== Recompiling client ==
> Cleaning bin
> Recompiling
'"javac" -Xlint:-options -deprecation -g -source 1.6 -target 1.6 -classpath "lib:lib/*:jars/bin/minec...' failed : 1
== ERRORS FOUND ==
src/minecraft/net/minecraft/src/BlockLight.java:11: ';' expected
return mod_Block.Light.160;
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:1: ';' expected
package net.minecraft.src
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:5: <identifier> expected
public static final BlockLight = new BlockLight(160, 0).setBlockName("BlockLight").setHardness(3F).setResistance(2F).setLightValue(8F);
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: illegal start of type
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: illegal start of type
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: ']' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: illegal start of type
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: <identifier> expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: illegal start of type
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: <identifier> expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: <identifier> expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: illegal start of expression
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: not a statement
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: illegal start of expression
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: not a statement
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: ';' expected
^
36 errors
==================
!! Can not find server sources, try decompiling !!
But, I had the same problem when i was modding for 1.2.5, so I have no idea whats going on.
Rollback Post to RevisionRollBack
Get it here: Click here! Wan't to see my Youtube Videos? Well, I'm plazmacatcher, check it out
Ive got the same problem as AskMikeIfYaMAD, with the code:
Mod_BlockLight
package net.minecraft.src
[i]Create the package[/i]
public class mod_BlockLight extends BaseMod
{
public static final BlockLight = new BlockLight(160, 0).setBlockName("BlockLight").setHardness(3F).setResistance(2F).setLightValue(8F);
[i]Register the block code[/i]
[i]What this means. SetHardness chooses how hard the block is, the resistance is almost the same thing, and the light value is how much light it gives off. [/i]
public void load()
{
Light.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/BlockLight.png");
ModLoader.registerBlock(Light);
ModLoader.addName(BlockLight, "Fancy Light");
ModLoader.addRecipe(new ItemStack(BlockLight, 8), new Object [] {"@@@", "@#@", "@@@", Character.valueOf('@'), Block.glass, Character.valueOf('#')});
[i]Add the recipe[/i]
}
public String getVersion()
{
return "Fancy Light Loading, Loaded successfully, Have Fun :D";
}
}
BlockLight:
package net.minecraft.src;
import java.util.Random;
public class BlockLight extends Block
{
public BlockLight(int i, int j)
{
super(i, j, Material.stone);
}
public int idDropped(int i, Random random, int j)
{
return mod_Block.Light.160;
}
public int quantityDropped(Random random)
{
return 1;
}
}
And here are the MCP errors:
== MCP 7.0 (data: 7.0a, client: 1.3.1, server: 1.3.1) ==
# found jad, ff, jad patches, ff patches, osx patches, srgs, name csvs, doc csvs, param csvs, renumber csv, astyle, astyle config
== Recompiling client ==
> Cleaning bin
> Recompiling
'"javac" -Xlint:-options -deprecation -g -source 1.6 -target 1.6 -classpath "lib:lib/*:jars/bin/minec...' failed : 1
== ERRORS FOUND ==
src/minecraft/net/minecraft/src/BlockLight.java:11: ';' expected
return mod_Block.Light.160;
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:1: ';' expected
package net.minecraft.src
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:5: <identifier> expected
public static final BlockLight = new BlockLight(160, 0).setBlockName("BlockLight").setHardness(3F).setResistance(2F).setLightValue(8F);
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: illegal start of type
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: illegal start of type
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: ']' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: illegal start of type
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:6: <identifier> expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: illegal start of type
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: <identifier> expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:7: <identifier> expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: illegal start of expression
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: not a statement
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: ';' expected
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: illegal start of expression
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: not a statement
^
src/minecraft/net/minecraft/src/Mod_BlockLight.java:15: ';' expected
^
36 errors
==================
!! Can not find server sources, try decompiling !!
But, I had the same problem when i was modding for 1.2.5, so I have no idea whats going on.
Are you sure you decompile the newest version of mod loader?
After armor tutorial can you do a mob tutorial? My mob that i created in 1.2.5 doesn't work and crashes when it spawns.
I dont think Mob code with Modloader was edited, but you need to recompile it with the new MCP for it to work.
Also, its on the To-Do List, so please check that out!
This May Be Helpful For When You Do Your NPC Tutorial, Here Is The Error Log In Eclipse When Trying To Run The Test:
(From When I Logged Into The Internal Server)
INFO: Player291[/127.0.0.1:0] logged in with entity id 191 at (-280.5, 69.62000000476837, 43.5)
Skipping Entity with id -71
java.lang.NullPointerException
at net.minecraft.src.NetClientHandler.handleMobSpawn(NetClientHandler.java:730)
at net.minecraft.src.Packet24MobSpawn.processPacket(Packet24MobSpawn.java:137)
at net.minecraft.src.MemoryConnection.processReadPackets(MemoryConnection.java:70)
at net.minecraft.src.NetClientHandler.processReadPackets(NetClientHandler.java:89)
at net.minecraft.src.WorldClient.tick(WorldClient.java:63)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1760)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:821)
at net.minecraft.client.Minecraft.run(Minecraft.java:751)
at java.lang.Thread.run(Unknown Source)
Aug 07, 2012 5:14:49 PM net.minecraft.server.MinecraftServer stopServer
INFO: Stopping server
Aug 07, 2012 5:14:49 PM net.minecraft.server.MinecraftServer stopServer
INFO: Saving players
Aug 07, 2012 5:14:49 PM net.minecraft.server.MinecraftServer stopServer
INFO: Saving worlds
Aug 07, 2012 5:14:49 PM net.minecraft.server.MinecraftServer saveAllDimensions
INFO: Saving chunks for level 'New World'/net.minecraft.src.WorldProviderSurface@7e486e52
Aug 07, 2012 5:14:53 PM net.minecraft.server.MinecraftServer saveAllDimensions
INFO: Saving chunks for level 'New World'/net.minecraft.src.WorldProviderHell@25b7a7ad
Aug 07, 2012 5:14:53 PM net.minecraft.server.MinecraftServer saveAllDimensions
INFO: Saving chunks for level 'New World'/net.minecraft.src.WorldProviderEnd@3c616233
Im Not Sure How To Fix It And I Was Hoping This May Help You Figure Out How To Fix The NPC Spawning.
Also, it seems that everything else works apart from blocks. I have made tools ( as you might have seen on my banner), items, recipes, food even, but every time I try to code a block, it just won't work and gives me the same errors
Rollback Post to RevisionRollBack
Get it here: Click here! Wan't to see my Youtube Videos? Well, I'm plazmacatcher, check it out
Copy and paste this line of code into terminal -
[code]chflags nohidden ~/Library/[/code]
After that, navigate to your Users folder.
Go to YOUR user file < Library < Application Support < Minecraft
From there, open your Bin folder. Locate your minecraft.jar and re-name it to minecraft.zip
Double click the .zip file and a folder will appear.
Rename the new folder to minecraft.jar
Open up the new folder and delete the file META-INF
From here on, download a mod, open it, and copy+paste the .zip files into your minecraft folder.
PROFIT
Locate your .minecraft folder
Locate your Bin Folder
Open the minecraft.jar file with WinRAR/7Zip
Delete META-INF
Drag your mod class files into it
PROFIT
Requirements-
Eclipse ( PREFERRED ) /Editrocket - ( Used for writing Java )
Downloads:
Editrocket Downloads
Eclipse Downloads
MCP ( Minecraft Coder Pack)- ( MCP 7.0 is best )
MCP Downloads
There are other Java Programs out there, but Eclipse is the best, especially for MCP.
Setting up MCP-
d9b_RVpAYvc
Mod_ File
[code]package net.minecraft.src public class mod_BlockTut extends BaseMod { public static final Blockname = new BlockName(160, 0).setBlockName("BlockName(Anything)").setHardness(3F).setResistance(4F).setLightValue(1F); //Register the block code //What this means: SetHardness chooses how hard the block is, the resistance is almost the same thing, and the light value is how much light it gives off. public void load() { Name.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/block.png"); ModLoader.registerBlock(BlockName); ModLoader.addName(nameHere, "Tutorial Block (Ingame name)"); ModLoader.addRecipe(new ItemStack(nameHere, 1), new Object [] {"#", Character.valueOf('#'), Block.dirt}); //Register the texture and override terrain.png //Register the block, add the name, and add the recipe. } public String getVersion() { return "Tutorail for 1.4.7"; } }[/code]
BlockTutorial File
[code]package net.minecraft.src; import java.util.Random; public class BlockTutorial extends Block { public BlockTutorial(int i, int j) { super(i, j, Material.wood); } public int idDropped(int i, Random random, int j) { return mod_Block.NameHere.blockID; } public int quantityDropped(Random random) { return 1; } //The # of items dropped } [/code]
Mod_ File
[code]ModLoader.addRecipe(new ItemStack(itemtoreceive, quantity), new Object [] {"#@#", "%%%", "@#@", Character.valueOf('#'), Block.wood, Character.valueOf('@'), Block.dirt, Character.valueOf('%'), Item.blockDiamonds}); //Register the recipe[/code]
That recipe would create -
Wood, Dirt, Wood
Diamond Block Diamond Block DIamond Block
Dirt Wood Dirt
'ModLoader.addRecipe' is just the ModLoader method for adding a recipe.'(new ItemStack(itemtoreceive, quantity), new Object []' creates a new inventory stack of the item in brackets, and add the number after the item name to the quantity of the stack.'{"#@#", "%%%", "@#@", ' is the actual recipe of the item. The first set of quotes is the first row in the crafting table, the second set of quotes is the second row, and so on.'Character.valueOf('$'), Block.gold... ' means to associate the name of the block/item, with the symbol in brackets, and then that symbol in the recipe.
Tutorial 3 - Smelting
Mod_ File
[code]ModLoader.addSmelting(Block.oreDiamond.blockID, new ItemStack(Item.ingotIron, 1), 1.0F); //Diamond ore ---> Iron Ingot[/code]
Tutorial 4 - Food
Mod_ File
[code]package net.minecraft.src public class mod_foodtut Extends Basemod public static final Item <Item Name> = new ItemFood(5001, 4, 1F, false).setItemName("<namehere>"); //Register the ItemFood public void load() { .iconIndex = ModLoader.addOverride("/gui/items.png","/path/image.png"); //override the items.png ModLoader.addName(, "InGame Name Here"); ModLoader.addRecipe(new ItemStack(Namehere, 1), new Object [] {"#", "#",Character.valueOf('#'), Block.dirt}); //This says override the items.png and make it a different file. Than you add the recipe, look at previous tutorials. } { public String getVersion() { } }{[/code]
Tutorial 5 - Achievements
Tutorial 7 - Commands (MODLOADER)
Files needed -
NEW FILE - Command<Name>.java
ServerCommandManager.javaMod_Commands
Were going to be making a CommandSuicide tutorial. This will add the /suicide command.
CommandSuicide.java -
[code]package net.minecraft.src; // Add the package public class CommandSuicide extends CommandBase { public String getCommandName() { return "suicide"; } // This is the command, its what you put after the '/' public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) { EntityPlayer var3 = getCommandSenderAsPlayer(par1ICommandSender); //gets the Players Entity, so it will kill them. If you wish to kill cows, it would be EntityCows and some more //code. var3.attackEntityFrom(DamageSource.outOfWorld, 1000); //Its saying to attack the entity and label the DamageSource. Check DamageSource.java for more info. 1000 // is the damage it gives. par1ICommandSender.sendChatToPlayer("Player Commited Suicide"); // The message that appears in chat. } } Expect more! This is just a simple tutorial! ServerCommandManager.java - [code] //Add this line of code - this.registerCommand(new CommandSuicide()); // this Registers the Command, CommandSuicide.[/code]
Mod_ File -
Just add
[code]ModLoader.addCommand (new CommandSuicide());[/code]
Congrats!
[/code]
Tutorial 8 - Fuels (MODLOADER)
Mod_ File
[code]package net.minecraft.src; public class mod_FuleTut extends BaseMod { public static final Item foodTut = new Item(4999).setItemName("foodTut"); public void load() { nameHere.iconIndex = ModLoader.addOverride("/gui/items.png", "/foodTut.png"); ModLoader.addName(nameHere, "FoodTut"); ModLoader.addRecipe(new ItemStack(nameHere, 1), new Object [] {"#", '#', Block.grass.blockID}); } public int addFuel(int i, int j){if(i == foodtut.shiftedIndex){return 2750; } return 0; } public String getVersion(){return "1.3.2 Food tutorial";}}[/code]
Tutorial 9 - NPC's (MODLOADER)
Mod_ File
[code]package net.minecraft.src; import java.util.Random; import java.util.Map; import java.util.List; import java.util.jar.*; import java.util.*; import java.util.logging.*; import java.util.concurrent.*; import java.awt.datatransfer.*; import java.awt.geom.*; import java.util.zip.*; import java.awt.*; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import net.minecraft.client.Minecraft; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; public class mod_NPC extends BaseMod { public String getVersion() { return "NPC Mod For Minecraft 1.3.2";} public void load() { } public void addRenderer(Map map) { map.put(EntityNPC.class, new RenderBiped(new ModelBiped(), 0.5F)); ModLoader.registerEntityID(EntityNPC.class, "NPC", 231); ModLoader.addSpawn(EntityNPC.class, 4, 4, 10, EnumCreatureType.creature); //4,4,10 are the spawn rates. 231 is the ID } }[/code]
EntityNPC.java
[code]package net.minecraft.src; import java.util.Random; public class EntityNPC extends EntityCreature { public EntityNPC(World world) { super(world); texture = "/mob/NPC.png"; //the texture moveSpeed = 0.5F; //move speed attackStrength = 4; //take this line out if this class doesn't extend EntityMob. } public int getMaxHealth() { return 10; //the health (every 1 is HALF a point!) } protected String getLivingSound() { return "mob.villager.default"; } protected String getHurtSound() { return "mob.villager.defaulthurt"; } protected String getDeathSound() { return "mob.villager.defaultdeath"; } //sounds protected int getDropItemId() { return Item.ingotgold.shiftedIndex; } //what it drops protected boolean canDespawn() { return true; } }[/code]
Tutorial 9 - Stairs
Mod_ File
BlockTutorialStair file
[code]package net.minecraft.src; import java.util.List; import java.util.Random; public class BlockTutorialStair extends Block { private static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}}; private boolean field_72156_cr = false; private int field_72160_cs = 0; protected BlockTutorialStair(int i, int j) { super(i, j, Material.rock); this.setLightOpacity(255); this.setCreativeTab(CreativeTabs.tabBlock); } /** * Updates the blocks boundary depending on the blocs current state. Args: world, x, y, z */ public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { if (this.field_72156_cr) { this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2)); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } } /** * Is this block opaque (transparent) and a full 1m cube? This determines whether or not to render the shared face of them * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return false; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } /** * The type of render function that is called for this block (stairs are 10) */ public int getRenderType() { return 10; } /** * if the specified block is in the given AABB, add its collision bounding box to the given list */ public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = var8 & 3; float var10 = 0.0F; float var11 = 0.5F; float var12 = 0.5F; float var13 = 1.0F; if ((var8 & 4) != 0) { var10 = 0.5F; var11 = 1.0F; var12 = 0.0F; var13 = 0.5F; } this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); if (var9 == 0) { this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 1) { this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 2) { this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 3) { this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } /** public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) { int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4; if (var6 == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7); } if (var6 == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7); } if (var6 == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7); } if (var6 == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7); } } public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8) { if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D) { int var9 = par1World.getBlockMetadata(par2, par3, par4); par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4); } } /** * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world, * x, y, z, startVec, endVec */ public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) { MovingObjectPosition[] var7 = new MovingObjectPosition[8]; int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = var8 & 3; boolean var10 = (var8 & 4) == 4; int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)]; this.field_72156_cr = true; int var14; int var15; int var16; for (int var12 = 0; var12 < 8; ++var12) { this.field_72160_cs = var12; int[] var13 = var11; var14 = var11.length; for (var15 = 0; var15 < var14; ++var15) { var16 = var13[var15]; if (var16 == var12) { ; } } var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3); } int[] var21 = var11; int var24 = var11.length; for (var14 = 0; var14 < var24; ++var14) { var15 = var21[var14]; var7[var15] = null; } MovingObjectPosition var23 = null; double var22 = 0.0D; MovingObjectPosition[] var25 = var7; var16 = var7.length; for (int var17 = 0; var17 < var16; ++var17) { MovingObjectPosition var18 = var25[var17]; if (var18 != null) { double var19 = var18.hitVec.squareDistanceTo(par6Vec3); if (var19 > var22) { var23 = var18; var22 = var19; } } } return var23; } }[/code]
Tutorial 10 - World Generation
Note - I currently dont have this written out, but thanks to Namore77 and Cube Modding for these tutorials!
World Generation #1
World Generation #2
Tutorial 11 - Enum/Custom Item (Custom materials)
EnumAToolMaterial.java
[code]package net.minecraft.src; public enum EnumAToolMaterial { Sword1(0, 59, 2.0F, 0, 15), Pick1(1, 131, 4.0F, 1, 5), Spade1(2, 250, 6.0F, 2, 14), Axe1(3, 1561, 8.0F, 3, 10), /** * The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD) */ private final int harvestLevel; /** * The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32) */ private final int maxUses; /** * The strength of this tool material against blocks which it is effective against. */ private final float efficiencyOnProperMaterial; /** Damage versus entities. */ private final int damageVsEntity; /** Defines the natural enchantability factor of the material. */ private final int enchantability; private EnumAToolMaterial(int par3, int par4, float par5, int par6, int par7) { this.harvestLevel = par3; this.maxUses = par4; this.efficiencyOnProperMaterial = par5; this.damageVsEntity = par6; this.enchantability = par7; } /** * The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32) */ public int getMaxUses() { return this.maxUses; } /** * The strength of this tool material against blocks which it is effective against. */ public float getEfficiencyOnProperMaterial() { return this.efficiencyOnProperMaterial; } /** * Damage versus entities. */ public int getDamageVsEntity() { return this.damageVsEntity; } /** * The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD) */ public int getHarvestLevel() { return this.harvestLevel; } /** * Return the natural enchantability factor of the material. */ public int getEnchantability() { return this.enchantability; } }[/code]
ItemSword1.java
[code]package net.minecraft.src; public class ItemSword1 extends Item { private int weaponDamage; private final EnumAToolMaterial toolMaterial; public ItemSword1(int par1, EnumAToolMaterial par2EnumToolMaterial) { super(par1); this.toolMaterial = par2EnumToolMaterial; this.maxStackSize = 1; this.setMaxDamage(par2EnumToolMaterial.getMaxUses()); this.setTabToDisplayOn(CreativeTabs.tabCombat); this.weaponDamage = 4 + par2EnumToolMaterial.getDamageVsEntity(); } /** * Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if * sword */ public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block) { return par2Block.blockID == Block.web.blockID ? 15.0F : 1.5F; } /** * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise * the damage on the stack. */ public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving) { par1ItemStack.damageItem(1, par3EntityLiving); return true; } public boolean func_77660_a(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving) { if ((double)Block.blocksList[par3].getBlockHardness(par2World, par4, par5, par6) != 0.0D) { par1ItemStack.damageItem(2, par7EntityLiving); } return true; } /** * Returns the damage against a given entity. */ public int getDamageVsEntity(Entity par1Entity) { return this.weaponDamage; } /** * Returns True is the item is renderer in full 3D when hold. */ public boolean isFull3D() { return true; } /** * returns the action that specifies what animation to play when the items is being used */ public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.block; } /** * How long it takes to use or consume an item */ public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); return par1ItemStack; } /** * Returns if the item (tool) can harvest results from the block type. */ public boolean canHarvestBlock(Block par1Block) { return par1Block.blockID == Block.web.blockID; } /** * Return the enchantability factor of the item, most of the time is based on material. */ public int getItemEnchantability() { return this.toolMaterial.getEnchantability(); } public String func_77825_f() { return this.toolMaterial.toString(); } }[/code]
Note - I tried a few new things towards the bottom of this file, I'll go more in-depth with them later. Its for the console/crash reports.
Mod_Grenades
[code]package net.minecraft.src; import java.util.Map; import net.minecraft.client.Minecraft; public class mod_Grenades extends BaseMod { public static final Item Grenade = (new ItemGrenade(12000)).setItemName("grenade"); Minecraft mc; public void load() { try { this.WNDATA(0, true); this.WNDATA(1, true); this.WNDATA(2, true); this.initializeThrowableExplosives(); this.addRecipes(); } catch (Exception var2) { System.out.println(var2.getMessage()); } } public void initializeThrowableExplosives() { ModLoader.addName(Grenade, "Grenade"); Grenade.iconIndex = ModLoader.addOverride("/gui/items.png", "/grenade.png"); } public void addRecipes() { ModLoader.addRecipe(new ItemStack(mod_Grenade.Grenade, 3), new Object [] {"###", "%@%", "XXX", Character.valueOf('#'), Item.ingotIron, Character.valueOf('@'), Item.redstone, Character.valueOf('%'), Item.gunpowder, Character.valueOf('X'), Block.cobblestone}); } public void WNDATA(int var1, boolean var2) { if (var1 == 0 && var2) { System.out.println("** Initializing Minecraft mod!!**" ); System.out.println("** Made by Jdembo/Giraffestock! **"); } if (var1 == 1) { System.out.println("** Loading Mod **"); } else if (var1 == 2) { System.out.println("** Loading Grenades **"); } if (!var2) { System.out.println("** Loading complete **"); } } public String getVersion() { return "Minecraft Mod Tutorial by Jdembo/Giraffestock!"; } }[/code]
ItemGrenade -
[code]package net.minecraft.src; public class ItemGrenade extends Item { public static int GrenadeID; public ItemGrenade(int var1) { super(var1); this.maxStackSize = 16; GrenadeID = this.shiftedIndex; this.setTabToDisplayOn(CreativeTabs.tabCombat); } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack var1, World var2, EntityPlayer var3) { if (!var3.capabilities.isCreativeMode) { --var1.stackSize; } if (!var2.isRemote) { var2.spawnEntityInWorld(new EntityGrenade(var2, var3)); } return var1; } }[/code]
EntityGrenade -
[code]package net.minecraft.src; public class EntityGrenade extends EntityItem { double bounceFactor; int fuse; boolean exploded; boolean collided; boolean stopped; public EntityGrenade(World var1) { super(var1); this.setSize(0.5F, 0.5F); this.yOffset = this.height / 2.0F; this.item = new ItemStack(Item.itemsList[ItemGrenade.GrenadeID]); this.bounceFactor = 0.6D; this.exploded = false; this.stopped = false; this.fuse = 0; // if you notice the Grenade not disappearing, try adding this method below - setDead(); } public EntityGrenade(World var1, double var2, double var4, double var6, float var8, float var9, double var10, int var12) { this(var1); this.setRotation(var8, 0.0F); double var13 = (double)(-MathHelper.sin(var8 * (float)Math.PI / 180.0F)); double var15 = (double)MathHelper.cos(var8 * (float)Math.PI / 180.0F); this.motionX = var10 * var13 * (double)MathHelper.cos(var9 / 180.0F * (float)Math.PI); this.motionY = -var10 * (double)MathHelper.sin(var9 / 180.0F * (float)Math.PI); this.motionZ = var10 * var15 * (double)MathHelper.cos(var9 / 180.0F * (float)Math.PI); this.setPosition(var2 + var13 * 0.8D, var4, var6 + var15 * 0.8D); this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; this.fuse = var12; } public EntityGrenade(World var1, Entity var2) { this(var1, var2.posX, var2.posY, var2.posZ, var2.rotationYaw, var2.rotationPitch, 0.5D, 50); } /** * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolve[/spoiler]s to * prevent them from trampling crops */ protected boolean canTriggerWalking() { return false; } /** * Called to update the entity's position/logic. */ public void onUpdate() { if (this.fuse-- <= 0) { this.explode(); } if (!this.stopped && !this.exploded) { double var1 = this.motionX; double var3 = this.motionY; double var5 = this.motionZ; this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; this.moveEntity(this.motionX, this.motionY, this.motionZ); boolean var7 = false; if (this.motionX != var1) { this.motionX = -var1; var7 = true; } if (this.motionZ != var5) { this.motionZ = -var5; } if (this.motionY != var3) { this.motionY = -var3; var7 = true; } else { this.motionY -= 0.04D; } if (var7) { this.motionX *= this.bounceFactor; this.motionY *= this.bounceFactor; this.motionZ *= this.bounceFactor; } this.motionX *= 0.99D; this.motionY *= 0.99D; this.motionZ *= 0.99D; if (this.onGround && this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ < 0.02D) { this.stopped = true; this.motionX = 0.0D; this.motionY = 0.0D; this.motionZ = 0.0D; } } } /** * Called by a player entity when they collide with an entity */ public void onCollideWithPlayer(EntityPlayer var1) {} protected void explode() { if (!this.exploded) { this.exploded = true; this.worldObj.createExplosion((Entity)null, this.posX, this.posY, this.posZ, 3.0F); } } public boolean attackEntity(Entity var1, int var2) { super.attackEntityFrom(DamageSource.causeThrownDamage(var1, var1), var2); this.explode(); return false; } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound var1) { super.writeEntityToNBT(var1); var1.setByte("Fuse", (byte)this.fuse); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound var1) { super.readEntityFromNBT(var1); this.fuse = var1.getByte("Fuse"); } }[/code]
Tutorial 13 - Making custom models with Techne
Note - This was made for Cube Modding by KarryBird, I am the creator of CubeModding and have permission to use this.
Text-based coming soon!
Download Techne here
Tutorial #1 -
Tutorial #2 -
Tutorial #3 -
Tutorial 14 -
Mod_ File
[code]package net.minecraft.src; import java.util.Random; public class mod_Tutorial extends BaseMod { public static final BiomeGenBase Test = (new BiomeGenTest(40)).setBiomeName("Test"); public void load() { } { ModLoader.addBiome(Test); } public String getVersion() { return "1.4.5"; } public static void generateSurface(World world, Random rand, int chunkX, int chunkZ) { BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(chunkX, chunkZ); WorldGenTest tree = new WorldGenTest(); if(biome instanceof BiomeGenTest) { for(int x = 0; x < 8; x++) { tree = new WorldGenTest(); int Xcoord = chunkX + rand.nextInt(16); int Zcoord = chunkZ + rand.nextInt(16); int i = world.getHeightValue(Xcoord, Zcoord); tree.generate(world, rand, Xcoord, i, Zcoord); } } } }[/code]
This is a very simple process, which is fun to try out and use
You need the file GuiFlatPresets.java
[code]//Scroll down to this part: static { addPreset("Classic Flat", Block.grass.blockID, BiomeGenBase.plains, Arrays.asList(new String[] {"village"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Block.grass.blockID), new FlatLayerInfo(2, Block.dirt.blockID), new FlatLayerInfo(1, Block.bedrock.blockID)}); //Simply copy it over. // Classic Flat is its name, Block.grass.blockID is the block that is shown in the meny. BiomeGenBase.plains is what mobs can spawn there/weather. 'Village' means a village can spawn there. Look at other examples for more things to add. 1, Block.grass.blockID is stating that there should be one layer of grass, and so on. Hope this helped :) }[/code]
Armor
Enum's (already started)
Mobs
Signatures-
Need Help?
Please put any errors/code in a spoiler!
If you dont follow this, you WILL be ignored.
Blarg.
My dev log: rand.nextInt()
Well, Modloader 1.3 is now out, so let me update (and add more! )
It seems like it should work, but maybe Modloader (1.3.1) changed the block code more than i thought. Lemme check it out, sorry about that!
No problem! Im glad to help
Mod_BlockLight
BlockLight:
And here are the MCP errors:
But, I had the same problem when i was modding for 1.2.5, so I have no idea whats going on.
Get it here: Click here! Wan't to see my Youtube Videos? Well, I'm plazmacatcher, check it out
Are you sure you decompile the newest version of mod loader?
Will do
Actually, im going to have that take priority. You don't see many armor tutorials D:
I dont think Mob code with Modloader was edited, but you need to recompile it with the new MCP for it to work.
Also, its on the To-Do List, so please check that out!
Oh, thats odd. Does it crash? Or does the error just appear in the console?
May i please see your code?
Will add When i get back -
Commands ( Made an API )
Add in creative mode ( Made an API )
(From When I Logged Into The Internal Server)
Im Not Sure How To Fix It And I Was Hoping This May Help You Figure Out How To Fix The NPC Spawning.
Matix.
Get it here: Click here! Wan't to see my Youtube Videos? Well, I'm plazmacatcher, check it out
Get it here: Click here! Wan't to see my Youtube Videos? Well, I'm plazmacatcher, check it out