If you are reading this, you must have knowledge of setting up MCP, in this tutorial, it is only CODING not setting things up!
Welcome to T90's Modding tutorials! These tutorials are for modding, nothing else. I hope you enjoy!
Here's a modloader template I made!
package net.minecraft.src;
import java.util.*;
public class mod_Example extends BaseMod
{
@Override
public void load()
{
}
@Override
public String getVersion()
{
return("1.1.0");
}
}
How this functions:
The getVersion is the mod version, change it to watever you want EX. return("Minecraft Mod | Minecraft 1.1");
The load function is where you put most of the code for example, you have to put ModLoader.AddName(); , ModLoader.RegisterBlock(); and other things in it.
Change the mod_Example to the mod_ file you made!
Let's get to modding shall we? These are the current tutorials, more to come. I hope it helps!
You must have your mod_ file ready!
To start off. Make a new file named BlockNewBlock. Name "NewBlock" to whatever you want it to be.
Add this code into the file,
package net.minecraft.src;
import java.util.*;
public class BlockNewBlock extends Block
{
protected BlockNewBlock(int i, int j)
{
super(i, j, Material.ground);
}
public int quantityDropped(Random random)
{
return 1;
}
}
Change the NewBlock again to the name of the file. The Material.ground is the material of the block. There are different types of materials for example, the basic ones are in this spoiler:
The quantityDropped is the amount of block dropped from the block's destruction.
If you want it to drop a different block or item, add this function into the class
public int idDropped(int i, Random random)
{
return Item.stick.shiftedIndex;
}
You can surf the Item.java and the Block.java for different things! Remember if it's and item, add .shiftedIndex at the end and if it is a Block, add .blockID at the end for them to work!
Now, go into your mod_ file and add this into your file
public static final Block block_name = (new BlockNewBlock(150, 0)).setHardness(0.5F).setResistance(1.0F).setStepSound(Block.soundGravelFootstep).setBlockName("block_name");
block_name is the variable name, change it to watever you want. Change the "BlockNewBlock" into the file you created. 150 is the blockID, change it but do not exceed 250. The hardness and resistance are selfExplanatory but resistance is the amount it could get hit by TNT. setSound is the sound made when it is stepped on.
Now, you have to register the block, add it's texture and it's hover name!
To do that, you have to add these code into your load() function. You have heard of the loadd function right?!
ModLoader.RegisterBlock(block_name);
ModLoader.AddName(block_name, "The Hover Text");
block_name.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/BLOCK.png");
RegisterBlock is registering the block into the game. Add Name is adding it's hover name. and Finally the blockIndexInTexture is getting overridden using ModLoader's cool function. addOverride. If it were an item, you would change the /terrain.png into /gui/items.png, we will get into that later. Finally, change the /BLOCK.png into the block's image that goes into the jar! Also change the block_name into the variable you made in the previous step.
You have finished the block tutorial! :biggrin.gif:
Making an item is much simplistic than making a block, so this will be a very short tutorial.
Add this code into your mod_ file.
public static final Item itemName = (new Item(10000)).setItemName("itemName");
Change itemName into the item variable you want, the 10000 is the item id, I recommend having item id's from 260-10000.
Now, add these lines of code into your load function.
Almost the same as blocks but without the Registeration.
You have finished the simple item tutorial!
Add these codes into your load function.
Crafting
ModLoader.AddRecipe(new ItemStack(itemExample, 4), new Object[]{
"X", Character.valueOf('X'), block
});
itemExample is the item or block that is the final result and 4 is the amount.
block is the block or item in the recipe itself, you can add more by adding more of them like this :
The recipe itself is in the quotes change the shape and size to make the recipe! a block pick example! Spaces count as an empty space.
ModLoader.AddRecipe(new ItemStack(itemExample, 4), new Object[]{
"XXX", " Y ", " Y ", Character.valueOf('X'), block, Character.valueOf('Y'), block2
});
Furnace
ModLoader.AddSmelting(blockExample.blockID, new ItemStack(itemExample, 1));
blockExample is the block that smelts, I recommend using a block as the smelting item.
itemExample is the item that is the final result, change 1 to change how much comes out!
You have finished this tutorial!
First off, make 2 new files named BlockLiquidNAMEStill and BlockLiquidNameFlow.
Change the NAME to watever you want.
Paste into the BlockLiquidNAMEStill file this code
package net.minecraft.src;
import java.util.Random;
public class BlockLiquidNAMEStill extends BlockFluid
{
protected BlockLiquidNAMEStill(int i, Material material)
{
super(i, material);
setTickOnLoad(false);
if(material == Material.lava)
{
setTickOnLoad(true);
}
}
public int colorMultiplier(IBlockAccess iblockaccess, int i, int j, int k)
{
return 0x36A1FF;
}
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
{
super.onNeighborBlockChange(world, i, j, k, l);
if(world.getBlockId(i, j, k) == blockID)
{
func_30004_j(world, i, j, k);
}
}
private void func_30004_j(World world, int i, int j, int k)
{
int l = world.getBlockMetadata(i, j, k);
world.editingBlocks = true;
world.setBlockAndMetadata(i, j, k, blockID - 1, l);
world.markBlocksDirty(i, j, k, i, j, k);
world.scheduleBlockUpdate(i, j, k, blockID - 1, tickRate());
world.editingBlocks = false;
}
public void updateTick(World world, int i, int j, int k, Random random)
{
if(blockMaterial == Material.lava)
{
int l = random.nextInt(3);
for(int i1 = 0; i1 < l; i1++)
{
i += random.nextInt(3) - 1;
j++;
k += random.nextInt(3) - 1;
int j1 = world.getBlockId(i, j, k);
if(j1 == 0)
{
if(func_301_k(world, i - 1, j, k) || func_301_k(world, i + 1, j, k) || func_301_k(world, i, j, k - 1) || func_301_k(world, i, j, k + 1) || func_301_k(world, i, j - 1, k) || func_301_k(world, i, j + 1, k))
{
world.setBlockWithNotify(i, j, k, Block.fire.blockID);
return;
}
continue;
}
if(Block.blocksList[j1].blockMaterial.getIsSolid())
{
return;
}
}
}
}
private boolean func_301_k(World world, int i, int j, int k)
{
return world.getBlockMaterial(i, j, k).getCanBurn();
}
}
Change the BlockLiquidNAMEStill into your file name.
Now Paste into the BlockLiquidNAMEFlow this code
NOTE: You can play around with the code to see how it works, It would take tons of paragraphs just to explain how this works.
package net.minecraft.src;
import java.util.Random;
public class BlockLiquidNAMEFlow extends BlockFluid
{
int numAdjacentSources;
boolean isOptimalFlowDirection[];
int flowCost[];
protected BlockLiquidNAMEFlow(int i, Material material)
{
super(i, material);
numAdjacentSources = 0;
isOptimalFlowDirection = new boolean[4];
flowCost = new int[4];
}
public int colorMultiplier(IBlockAccess iblockaccess, int i, int j, int k)
{
return 0x36A1FF;
}
private void func_30003_j(World world, int i, int j, int k)
{
int l = world.getBlockMetadata(i, j, k);
world.setBlockAndMetadata(i, j, k, blockID + 1, l);
world.markBlocksDirty(i, j, k, i, j, k);
world.markBlockNeedsUpdate(i, j, k);
}
public void updateTick(World world, int i, int j, int k, Random random)
{
int l = getFlowDecay(world, i, j, k);
byte byte0 = 1;
if(blockMaterial == Material.lava && !world.worldProvider.isHellWorld)
{
byte0 = 2;
}
boolean flag = true;
if(l > 0)
{
int i1 = -100;
numAdjacentSources = 0;
i1 = getSmallestFlowDecay(world, i - 1, j, k, i1);
i1 = getSmallestFlowDecay(world, i + 1, j, k, i1);
i1 = getSmallestFlowDecay(world, i, j, k - 1, i1);
i1 = getSmallestFlowDecay(world, i, j, k + 1, i1);
int j1 = i1 + byte0;
if(j1 >= 8 || i1 < 0)
{
j1 = -1;
}
if(getFlowDecay(world, i, j + 1, k) >= 0)
{
int l1 = getFlowDecay(world, i, j + 1, k);
if(l1 >= 8)
{
j1 = l1;
} else
{
j1 = l1 + 8;
}
}
if(numAdjacentSources >= 2 && blockMaterial == Material.water)
{
if(world.getBlockMaterial(i, j - 1, k).isSolid())
{
j1 = 0;
} else
if(world.getBlockMaterial(i, j - 1, k) == blockMaterial && world.getBlockMetadata(i, j, k) == 0)
{
j1 = 0;
}
}
if(blockMaterial == Material.lava && l < 8 && j1 < 8 && j1 > l && random.nextInt(4) != 0)
{
j1 = l;
flag = false;
}
if(j1 != l)
{
l = j1;
if(l < 0)
{
world.setBlockWithNotify(i, j, k, 0);
} else
{
world.setBlockMetadataWithNotify(i, j, k, l);
world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
world.notifyBlocksOfNeighborChange(i, j, k, blockID);
}
} else
if(flag)
{
func_30003_j(world, i, j, k);
}
} else
{
func_30003_j(world, i, j, k);
}
if(liquidCanDisplaceBlock(world, i, j - 1, k))
{
if(blockMaterial == Material.lava && world.getBlockMaterial(i, j - 1, k) == Material.water)
{
world.setBlockWithNotify(i, j - 1, k, Block.stone.blockID);
triggerLavaMixEffects(world, i, j - 1, k);
return;
}
if(l >= 8)
{
world.setBlockAndMetadataWithNotify(i, j - 1, k, blockID, l);
} else
{
world.setBlockAndMetadataWithNotify(i, j - 1, k, blockID, l + 8);
}
} else
if(l >= 0 && (l == 0 || blockBlocksFlow(world, i, j - 1, k)))
{
boolean aflag[] = getOptimalFlowDirections(world, i, j, k);
int k1 = l + byte0;
if(l >= 8)
{
k1 = 1;
}
if(k1 >= 8)
{
return;
}
if(aflag[0])
{
flowIntoBlock(world, i - 1, j, k, k1);
}
if(aflag[1])
{
flowIntoBlock(world, i + 1, j, k, k1);
}
if(aflag[2])
{
flowIntoBlock(world, i, j, k - 1, k1);
}
if(aflag[3])
{
flowIntoBlock(world, i, j, k + 1, k1);
}
}
}
private void flowIntoBlock(World world, int i, int j, int k, int l)
{
if(liquidCanDisplaceBlock(world, i, j, k))
{
int i1 = world.getBlockId(i, j, k);
if(i1 > 0)
{
if(blockMaterial == Material.lava)
{
triggerLavaMixEffects(world, i, j, k);
} else
{
Block.blocksList[i1].dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
}
}
world.setBlockAndMetadataWithNotify(i, j, k, blockID, l);
}
}
private int calculateFlowCost(World world, int i, int j, int k, int l, int i1)
{
int j1 = 1000;
for(int k1 = 0; k1 < 4; k1++)
{
if(k1 == 0 && i1 == 1 || k1 == 1 && i1 == 0 || k1 == 2 && i1 == 3 || k1 == 3 && i1 == 2)
{
continue;
}
int l1 = i;
int i2 = j;
int j2 = k;
if(k1 == 0)
{
l1--;
}
if(k1 == 1)
{
l1++;
}
if(k1 == 2)
{
j2--;
}
if(k1 == 3)
{
j2++;
}
if(blockBlocksFlow(world, l1, i2, j2) || world.getBlockMaterial(l1, i2, j2) == blockMaterial && world.getBlockMetadata(l1, i2, j2) == 0)
{
continue;
}
if(!blockBlocksFlow(world, l1, i2 - 1, j2))
{
return l;
}
if(l >= 4)
{
continue;
}
int k2 = calculateFlowCost(world, l1, i2, j2, l + 1, k1);
if(k2 < j1)
{
j1 = k2;
}
}
return j1;
}
private boolean[] getOptimalFlowDirections(World world, int i, int j, int k)
{
for(int l = 0; l < 4; l++)
{
flowCost[l] = 1000;
int j1 = i;
int i2 = j;
int j2 = k;
if(l == 0)
{
j1--;
}
if(l == 1)
{
j1++;
}
if(l == 2)
{
j2--;
}
if(l == 3)
{
j2++;
}
if(blockBlocksFlow(world, j1, i2, j2) || world.getBlockMaterial(j1, i2, j2) == blockMaterial && world.getBlockMetadata(j1, i2, j2) == 0)
{
continue;
}
if(!blockBlocksFlow(world, j1, i2 - 1, j2))
{
flowCost[l] = 0;
} else
{
flowCost[l] = calculateFlowCost(world, j1, i2, j2, 1, l);
}
}
int i1 = flowCost[0];
for(int k1 = 1; k1 < 4; k1++)
{
if(flowCost[k1] < i1)
{
i1 = flowCost[k1];
}
}
for(int l1 = 0; l1 < 4; l1++)
{
isOptimalFlowDirection[l1] = flowCost[l1] == i1;
}
return isOptimalFlowDirection;
}
private boolean blockBlocksFlow(World world, int i, int j, int k)
{
int l = world.getBlockId(i, j, k);
if(l == Block.doorWood.blockID || l == Block.doorSteel.blockID || l == Block.signPost.blockID || l == Block.ladder.blockID || l == Block.reed.blockID)
{
return true;
}
if(l == 0)
{
return false;
}
Material material = Block.blocksList[l].blockMaterial;
if(material == Material.portal)
{
return true;
}
return material.getIsSolid();
}
protected int getSmallestFlowDecay(World world, int i, int j, int k, int l)
{
int i1 = getFlowDecay(world, i, j, k);
if(i1 < 0)
{
return l;
}
if(i1 == 0)
{
numAdjacentSources++;
}
if(i1 >= 8)
{
i1 = 0;
}
return l >= 0 && i1 >= l ? l : i1;
}
private boolean liquidCanDisplaceBlock(World world, int i, int j, int k)
{
Material material = world.getBlockMaterial(i, j, k);
if(material == blockMaterial)
{
return false;
}
if(material == Material.lava)
{
return false;
} else
{
return !blockBlocksFlow(world, i, j, k);
}
}
public void onBlockAdded(World world, int i, int j, int k)
{
super.onBlockAdded(world, i, j, k);
if(world.getBlockId(i, j, k) == blockID)
{
world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
}
}
}
Change the BlockLiquidNAMEFlow again to the file name.
Add these codes into your mod_ file
public static final Block LiquidNameFlow = (new BlockLiquidNAMEFlow(181, Material.water)).setHardness(100F).setLightOpacity(3).setBlockName("LiquidNameFlow").disableStats().setRequiresSelfNotify();
public static final Block LiquidNameStill = (new BlockLiquidNAMEStill(182, Material.water)).setHardness(100F).setLightOpacity(3).setBlockName("LiquidNameStill").disableStats().setRequiresSelfNotify();
Change the things that you wanna change for example the variable name and id. Change BlockLiquidNAMEFlow into your file name and BlockLiquidNAMEStill into the other file name. To change it from lava to water, change the Material to Material.lava or keep it Material.water
Also, you can change the speed, to change speed, all you have to do is add this code into the BlockLiquidNAMEStill
Change the variable and hover text. No need for texture change!
If you wanna change the color, go into your BlockLiquidNAMEStill and BlockLiquidNAMEFlow files and change the 0x36A1FF in color multiplier. You can get colors from http://www.jafar.com/java/csel/index.html copy the hex code into it but replace the # with 0x
You have finished the liquid tutorial!
Add this function into your mod_ file
public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
{
for(int i = 0; i < 12; i++)
{
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(128);
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(mod_NAME.BLOCKNAME.blockID, 9)).generate(world, rand, randPosX, randPosY, randPosZ);
}
}
The 12 is the rarity of the object. 128 is the height of the object. 9 is the amount in the vein. Change the mod_NAMe into your mod_ file name and BLOCKNAME into your block you wanna generate. To add more just copy and paste this into your GenerateSurface FUNCTION
for(int i = 0; i < 12; i++)
{
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(128);
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(mod_NAME.BLOCKNAME2.blockID, 9)).generate(world, rand, randPosX, randPosY, randPosZ);
}
Same thing
To generate a liquid add this into that same function
for(int i = 0; i < 10; i++)
{
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(128);
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenLiquids(mod_NAME.LiquidBLOCKNAME.blockID)).generate(world, rand, randPosX, randPosY, randPosZ);
}
Same thing but you just have to change the mod_NAME into your mod_ file name again and LiquidBLOCKNAME into the liquid you wanna generate .
You have finished this tutorial
Please leave feedback and leave a comment if you want more tutorials, a certain tutorial or help. There is always more to come! :smile.gif:
the last two aren't really doing much, you're just providing code to copy, so they're not really tutorials, personally I only like tutorials where the maker FULLY explains the topic and what everything does
the last two aren't really doing much, you're just providing code to copy, so they're not really tutorials, personally I only like tutorials where the maker FULLY explains the topic and what everything does
When I try to runclient from MCP I get this error in the cmd window
== MCP 5.6 (data: 5.6, client: 1.1, server: 1.1) ==
[00:41:32] 27 achievements
[00:41:32] 174 recipes
[00:41:33] ModLoader 1.1 Initializing...
[00:41:33] Mod Initialized: mod_Weed 1.0.0
[00:41:33] Overriding /gui/items.png with /mod/EmptyPipe.png @ 38. 85 left.
[00:41:33] Overriding /gui/items.png with /mod/FullPipe.png @ 102. 84 left.
[00:41:33] Overriding /gui/items.png with /mod/Weed.png @ 118. 83 left.
[00:41:33] Exception in thread "Minecraft main thread" java.lang.ExceptionI
ializerError
[00:41:33] at net.minecraft.client.Minecraft.startGame(Minecraft.java:
[00:41:33] at net.minecraft.client.Minecraft.run(Minecraft.java:620)
[00:41:33] at java.lang.Thread.run(Thread.java:662)
[00:41:33] Caused by: java.lang.RuntimeException: java.lang.NullPointerExce
[00:41:33] at net.minecraft.src.ModLoader.init(ModLoader.java:745)
[00:41:33] at net.minecraft.src.ModLoader.AddAllRenderers(ModLoader.ja
0)
[00:41:33] at net.minecraft.src.RenderManager.<init>(RenderManager.jav
[00:41:33] at net.minecraft.src.RenderManager.<clinit>(RenderManager.j
)
[00:41:33] ... 3 more
[00:41:33] Caused by: java.lang.NullPointerException
[00:41:33] at net.minecraft.src.CraftingManager.addRecipe(CraftingMana
ava:361)
[00:41:33] at net.minecraft.src.ModLoader.AddRecipe(ModLoader.java:344
[00:41:33] at net.minecraft.src.mod_Weed.load(mod_Weed.java:32)
[00:41:33] at net.minecraft.src.ModLoader.init(ModLoader.java:714)
[00:41:33] ... 6 more
And in Minecraft I get this
Mods loaded: 2
ModLoader 1.1
mod_Weed 1.0.0
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem.
If you wish to report this, please copy this entire text and email it to [email protected].
Please include a description of what you did when the error occured.
--- BEGIN ERROR REPORT 3e00a5f6 --------
Generated 1/17/12 12:41 AM
Minecraft: Minecraft 1.1
OS: Windows 7 (amd64) version 6.1
Java: 1.6.0_27, Sun Microsystems Inc.
VM: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Sun Microsystems Inc.
LWJGL: 2.4.2
OpenGL: GeForce 8800 GT/PCI/SSE2 version 3.3.0, NVIDIA Corporation
java.lang.NullPointerException
at net.minecraft.src.CraftingManager.addRecipe(CraftingManager.java:361)
at net.minecraft.src.ModLoader.AddRecipe(ModLoader.java:344)
at net.minecraft.src.mod_Weed.load(mod_Weed.java:32)
at net.minecraft.src.ModLoader.init(ModLoader.java:714)
at net.minecraft.src.ModLoader.AddAllRenderers(ModLoader.java:150)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:78)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:9)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:316)
at net.minecraft.client.Minecraft.run(Minecraft.java:620)
at java.lang.Thread.run(Thread.java:662)
--- END ERROR REPORT 1332044b ----------
When I try to runclient from MCP I get this error in the cmd window
== MCP 5.6 (data: 5.6, client: 1.1, server: 1.1) ==
[00:41:32] 27 achievements
[00:41:32] 174 recipes
[00:41:33] ModLoader 1.1 Initializing...
[00:41:33] Mod Initialized: mod_Weed 1.0.0
[00:41:33] Overriding /gui/items.png with /mod/EmptyPipe.png @ 38. 85 left.
[00:41:33] Overriding /gui/items.png with /mod/FullPipe.png @ 102. 84 left.
[00:41:33] Overriding /gui/items.png with /mod/Weed.png @ 118. 83 left.
[00:41:33] Exception in thread "Minecraft main thread" java.lang.ExceptionI
ializerError
[00:41:33] at net.minecraft.client.Minecraft.startGame(Minecraft.java:
[00:41:33] at net.minecraft.client.Minecraft.run(Minecraft.java:620)
[00:41:33] at java.lang.Thread.run(Thread.java:662)
[00:41:33] Caused by: java.lang.RuntimeException: java.lang.NullPointerExce
[00:41:33] at net.minecraft.src.ModLoader.init(ModLoader.java:745)
[00:41:33] at net.minecraft.src.ModLoader.AddAllRenderers(ModLoader.ja
0)
[00:41:33] at net.minecraft.src.RenderManager.<init>(RenderManager.jav
[00:41:33] at net.minecraft.src.RenderManager.<clinit>(RenderManager.j
)
[00:41:33] ... 3 more
[00:41:33] Caused by: java.lang.NullPointerException
[00:41:33] at net.minecraft.src.CraftingManager.addRecipe(CraftingMana
ava:361)
[00:41:33] at net.minecraft.src.ModLoader.AddRecipe(ModLoader.java:344
[00:41:33] at net.minecraft.src.mod_Weed.load(mod_Weed.java:32)
[00:41:33] at net.minecraft.src.ModLoader.init(ModLoader.java:714)
[00:41:33] ... 6 more
And in Minecraft I get this
Mods loaded: 2
ModLoader 1.1
mod_Weed 1.0.0
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem.
If you wish to report this, please copy this entire text and email it to [email protected].
Please include a description of what you did when the error occured.
--- BEGIN ERROR REPORT 3e00a5f6 --------
Generated 1/17/12 12:41 AM
Minecraft: Minecraft 1.1
OS: Windows 7 (amd64) version 6.1
Java: 1.6.0_27, Sun Microsystems Inc.
VM: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Sun Microsystems Inc.
LWJGL: 2.4.2
OpenGL: GeForce 8800 GT/PCI/SSE2 version 3.3.0, NVIDIA Corporation
java.lang.NullPointerException
at net.minecraft.src.CraftingManager.addRecipe(CraftingManager.java:361)
at net.minecraft.src.ModLoader.AddRecipe(ModLoader.java:344)
at net.minecraft.src.mod_Weed.load(mod_Weed.java:32)
at net.minecraft.src.ModLoader.init(ModLoader.java:714)
at net.minecraft.src.ModLoader.AddAllRenderers(ModLoader.java:150)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:78)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:9)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:316)
at net.minecraft.client.Minecraft.run(Minecraft.java:620)
at java.lang.Thread.run(Thread.java:662)
--- END ERROR REPORT 1332044b ----------
what's your code? Did you put the textures in the jars/bin/minecraft.jar file?
To run it in MCP, you must put textures in the jars/bin/minecraft,jar file for it to work.
Here's a modloader template I made!
How this functions:
The getVersion is the mod version, change it to watever you want EX. return("Minecraft Mod | Minecraft 1.1");
The load function is where you put most of the code for example, you have to put ModLoader.AddName(); , ModLoader.RegisterBlock(); and other things in it.
Change the mod_Example to the mod_ file you made!
You must have your mod_ file ready!
Add this code into the file,
Change the NewBlock again to the name of the file. The Material.ground is the material of the block. There are different types of materials for example, the basic ones are in this spoiler:
Material.ground
Material.rock
Material.cloth
Material.wood
Material.iron
The quantityDropped is the amount of block dropped from the block's destruction.
If you want it to drop a different block or item, add this function into the class
You can surf the Item.java and the Block.java for different things! Remember if it's and item, add .shiftedIndex at the end and if it is a Block, add .blockID at the end for them to work!
Now, go into your mod_ file and add this into your file
block_name is the variable name, change it to watever you want. Change the "BlockNewBlock" into the file you created. 150 is the blockID, change it but do not exceed 250. The hardness and resistance are selfExplanatory but resistance is the amount it could get hit by TNT. setSound is the sound made when it is stepped on.
Now, you have to register the block, add it's texture and it's hover name!
To do that, you have to add these code into your load() function. You have heard of the loadd function right?!
RegisterBlock is registering the block into the game. Add Name is adding it's hover name. and Finally the blockIndexInTexture is getting overridden using ModLoader's cool function. addOverride. If it were an item, you would change the /terrain.png into /gui/items.png, we will get into that later. Finally, change the /BLOCK.png into the block's image that goes into the jar! Also change the block_name into the variable you made in the previous step.
You have finished the block tutorial! :biggrin.gif:
Making an item is much simplistic than making a block, so this will be a very short tutorial.
Add this code into your mod_ file.
Change itemName into the item variable you want, the 10000 is the item id, I recommend having item id's from 260-10000.
Now, add these lines of code into your load function.
Almost the same as blocks but without the Registeration.
You have finished the simple item tutorial!
Add these codes into your load function.
Crafting
itemExample is the item or block that is the final result and 4 is the amount.
block is the block or item in the recipe itself, you can add more by adding more of them like this :
The recipe itself is in the quotes change the shape and size to make the recipe! a block pick example! Spaces count as an empty space.
Furnace
blockExample is the block that smelts, I recommend using a block as the smelting item.
itemExample is the item that is the final result, change 1 to change how much comes out!
You have finished this tutorial!
Change the NAME to watever you want.
Paste into the BlockLiquidNAMEStill file this code
Change the BlockLiquidNAMEStill into your file name.
Now Paste into the BlockLiquidNAMEFlow this code
NOTE: You can play around with the code to see how it works, It would take tons of paragraphs just to explain how this works.
Change the BlockLiquidNAMEFlow again to the file name.
Add these codes into your mod_ file
Change the things that you wanna change for example the variable name and id. Change BlockLiquidNAMEFlow into your file name and BlockLiquidNAMEStill into the other file name. To change it from lava to water, change the Material to Material.lava or keep it Material.water
Also, you can change the speed, to change speed, all you have to do is add this code into the BlockLiquidNAMEStill
Change the 5 to anything. 5 is water speed
In your load function, add these lines of code:
Change the variable and hover text. No need for texture change!
If you wanna change the color, go into your BlockLiquidNAMEStill and BlockLiquidNAMEFlow files and change the 0x36A1FF in color multiplier. You can get colors from http://www.jafar.com/java/csel/index.html copy the hex code into it but replace the # with 0x
You have finished the liquid tutorial!
Add this function into your mod_ file
The 12 is the rarity of the object. 128 is the height of the object. 9 is the amount in the vein. Change the mod_NAMe into your mod_ file name and BLOCKNAME into your block you wanna generate. To add more just copy and paste this into your GenerateSurface FUNCTION
Same thing
To generate a liquid add this into that same function
Same thing but you just have to change the mod_NAME into your mod_ file name again and LiquidBLOCKNAME into the liquid you wanna generate .
You have finished this tutorial
Please leave feedback and leave a comment if you want more tutorials, a certain tutorial or help. There is always more to come! :smile.gif:
I'll add explanations soon.
sure
And in Minecraft I get this
what's your code? Did you put the textures in the jars/bin/minecraft.jar file?
To run it in MCP, you must put textures in the jars/bin/minecraft,jar file for it to work.
In other words when you try to place a block in it nothing happens.
Sure :biggrin.gif:
'Ill try.
Oh and just a suggestion
Include what the file should look like after all those steps.
Other wise, good tutorial
*side note, hey have you ever used eclipse before? I want to set mine up but it keeps giving me errors...
Also food
You didn't look at the error report right.
This is the error you should have looked for..
The problem is that something is wrong with his recipe code.
Looks like it
Just put in 'This' in the recipe instead of Item.stick or whatever.
This is my file
if you help (Masters) You will be greatly credited in this edition to my mod!
thanks!
Please help please I really don't know anything about this constructer thing.
Didn't find anything searching the forum.