For all of you who are not using Eclipse or NetBeans or some other Java IDE... Go download one of them (I prefer Eclipse) they make it so much easier... don't use notepad++
I'm not very good at explaining things so you may have to have some knowledge about modding.
Basic Tutorials:
Start With This as your mod_ class. Used For everything.
package net.minecraft.src;
import java.util.Random;
import net.minecraft.client.Minecraft;
public class mod_Example extends BaseMod
{
private Minecraft mc = ModLoader.getMinecraftInstance(); //declares a variable you can use for minecraft
public void load()
{
ModLoader.SetInGUIHook(this, true, false);
ModLoader.SetInGameHook(this, true, false);
world = ModLoader.getMinecraftInstance().theWorld;
}
public String getVersion()
{
return "Tuts by jamolnng 1.0.0";
}
protected static World world; //Add this to every mod_ Class because you will most likely need it for everything that involves modding
}
Basic Block:
Add this into your mod_ class
public static final Block newBlock = new BlockNew(150 /*Block ID, can be as high as 256 or as low as 126 */, ModLoader.addOverride("/terrain.png", "/newBlock.png")).setHardness(3F).setResistance(5F).setBlockName("newBlock");
Then add this to your constructor public void load();
ModLoader.RegisterBlock(newBlock);
ModLoader.AddName(newBlock, "Your new block");
Then make a new class and call it BlockNew and have it look like this
package net.minecraft.src;
import java.util.Random;
public class BlockNew extends Block
{
public BlockNew(int i, int j)
{
super(i, j, Material.rock);
}
public int idDropped(int i, Random random, int j)
{
return mod_Example.newBlock.BlockID;
}
}
Making Block Drop Item:
Instead of this in your block class:
public int idDropped(int i, Random random, int j)
{
return mod_Example.newItem.BlockID;
}
Use This:
public int idDropped(int i, Random random, int j)
{
return mod_Example.newItem.shiftedIndex;
}
Basic Item:
Add this into your mod_ class
public static final Item newItem = new Item(1500)).setItemName("newBlock");
Then add this to your constructor public void load();
ModLoader.AddName(newItem, "Your new item");
newItem.iconIndex = ModLoader.addOverride("/gui/items.png", "/newItem.png");
Block effects. Just add these to your block class choose which ever you like.
Add import
import net.minecraft.client.Minecraft;
private Minecraft mc = ModLoader.getMinecraftInstance(); //Always Add to use effects
public void onEntityWalking(World world, int i, int j, int k, Entity entity)
{
entity.motionY += 1.0;
entity.fallDistance = 0.0F;
entity.isInWeb = true;
mc.thePlayer.setHealth(20);
mc.thePlayer.isImmuneToFire = true;
//Those are just some, you can look around and try out others
}
Making Blocks render different without ModelBlock classes
Simple Way
Ok I'm going to make it simpler than most people have said. This should help a lot of people. Here is a simple block class with the code to make the block long and thin. Feel free to mess around with it.
package net.minecraft.src;
public class BlockAsdf extends Block{
public boolean renderAsNormalBlock()
{
return false;
}
public boolean isOpaqueCube()
{
return false;
}
public BlockAsdf(int i, int j, Material material)
{
super(i, j, material.glass);
setBlockBounds(0.0F, 0.0F, 0.3F, 1.0F, 0.4F, 0.7F);
}
}
This part basically tells the game not to render the block as a normal block and then tells it that the block texture does not cover the block below it so you can't see through the map
public boolean renderAsNormalBlock()
{
return false;
}
public boolean isOpaqueCube()
{
return false;
}
Explanation of the code:
The first number
0.0F
Is the length of the block from 1 edge.
The second number
0.0F
Is the height off the ground.
The third number
0.3F
Is the widht of the block from 1 edge.
The fourth number
1.0F
Is the length of the block.
The fifth number
0.4F
Is the height of the block.
The sixth number
0.7F
Is width of the block
Making a block spawn blocks
You will need to add this method to your Block class
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
{
}
GUI TUTORIALS (Includes how to add your blocks to the Creative Gui)
Okay well first of all here is the basic code set up for a GUI:
package net.minecraft.src;
import java.awt.Color;
import java.io.IOException;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.src.GuiButton;
public class GuiExample extends GuiScreen
{
public GuiExample(World world1, mod_Gui mod_Gui /*It doesn't have to be mod_Gui it can be whatever your mod_ class is named */, Minecraft minecraft)
{
mc = minecraft;
world = world1;
}
public void initGui() //For buttons and text entries
{
controlList.clear(); //clears the screen so your gui can open
}
protected void actionPerformed(GuiButton guibutton) //Actions taken by the gui (mostly for gui buttons)
{
}
public void onGuiClosed() //states what happens when the gui is closed
{
}
public void drawScreen(int i, int j, float f) //What is displayed in the gui
{
drawDefaultBackground();
for(int k = 0; k < controlList.size(); k++)
{
GuiButton guibutton = (GuiButton)controlList.get(k);
guibutton.drawButton(mc, i, j);
}
super.drawScreen(i, j, f);
}
public boolean doesGuiPauseGame()
{
return false; //as it says, registers if the gui pauses the game.
}
private World world;
private Minecraft mc; //Variable for minecraft
private GuiButton guibutton;
public mod_Gui mod_gui; /* Same as before, It doesn't have to be mod_Gui it can be whatever your mod_ class is named */
}
Basic Gui Stuff
And then if you want to add a button, add this code to initGui()
controlList.add(guibutton1 = new GuiButton(1 /* Gui button number */, width / 2 - 100, height / 2 + 100, 200, 20, "Your Text Here"));
Then to make that button do something add this to actionPerformed(GuiButton guibutton)
if(!guibutton.enabled) //You only have to add the method if(!guibutton.enabled) once
{
return;
}
if(guibutton.id == 1 /* The number corresponds with the gui button number */)
{
mc.thePlayer.setHealth(20); //Heals The Player
}
To add text to the GUI add this to drawScreen(int i, int j, float f)
Now on to your mod_ class, this is an example of what all you should have for your gui
package net.minecraft.src;
import java.util.Random;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.GuiScreen;
import java.awt.Color;
import javax.swing.text.html.parser.Entity;
public class mod_Gui extends BaseMod
{
private Minecraft mc = ModLoader.getMinecraftInstance(); //declares a variable you can use for minecraft
public void load()
{
ModLoader.SetInGUIHook(this, true, false);
ModLoader.SetInGameHook(this, true, false);
world = ModLoader.getMinecraftInstance().theWorld;
ModLoader.RegisterKey(this, this.key, false); //Registers the keybinding
ModLoader.AddLocalization("Open GUI", "Open GUI"); //Puts the keybinding in the Controls menu
}
public void KeyboardEvent(KeyBinding keybinding)
{
if(mc.currentScreen == null && keybinding == this.key)
{
mc.displayGuiScreen(new GuiExample(world, this, mc)); //Tell it that if your keybinding key is pressed then it will open the gui
}
}
public String getVersion()
{
return "GUI Tuts by jamolnng 1.0.0";
}
protected static World world; //Add this to every mod_ Class because you will most likely need it for everything that involves modding
private static GuiScreen guiscreen; //Always good to have
protected KeyBinding key = new KeyBinding("Open GUI", Keyboard.KEY_V); //This is what you use to open your GUI.
}
if(guiscreen instanceof GuiContainer) //Can be whatever gui you want it to be
{
mc.fontRenderer.drawString("Your Stuff", guiscreen.width / 2 - 68, 4, Color.WHITE.getRGB());
}
Adding Block To Creative Gui
Make a boolean called areBlocksAdded
private boolean areBlocksAdded = false;
And Import this:
import java.util.List;
Then Follow This
Use This Code Inside Of public boolean OnTickInGUI(float f, Minecraft minecraft, GuiScreen guiscreen)
if((guiscreen instanceof GuiContainerCreative) && !minecraft.theWorld.multiplayerWorld)
{
if(areBlocksAdded == false)
{
Container container = ((GuiContainer)guiscreen).inventorySlots;
List list = ((ContainerCreative)container).itemList;
list.add(new ItemStack(mod_Example.yourBlock, 1)); //Use For Each Block You Want To Add
}
areBlocksAdded = true;
}
else
{
areBlocksAdded = false;
}
Simple Jet-Pack (Based off of the one in my mod WyldeMod)
All of this code goes in your mod_ class within:
public class mod_YourMod extends BaseMod
Make sure you have a chest armor piece made that you want to use for the jet pack.
You will need to add this to your mod_ class. You can find it in BaseMod.java. Make sure you have Minecraft imported (import src.minecraft.client.Minecraft;)
public boolean OnTickInGame(float f, Minecraft minecraft)
{
}
To make it simple add this short bit of code to that method
people might not understand what you mean if they are new in modding but i like the way you do it :smile.gif:
a green + from me!
Shh, don't tell them this...but I don't like newbies... they scare me. So they can go learn how to mod and then come back. But I might edit it a little to make it easier to understand.
warning: [options] bootstrap class path not set in conjunction with -source 1.6
src\minecraft\net\minecraft\src\BlockSalt.java:14: error: cannot find symbol
return mod_salt.saltBlock.BlockID;
^
symbol: variable BlockID
location: variable saltBlock of type Block
is it possible to display a Symbol instead of a text?
but it guess i know it already i have to make my own buttonGui.
am I right?
Well the easiest way to do it would be just to add an image over the top of the button, otherwise you would probably have to use a whole lot of code to have the picture be part of the button. I'm not quite sure though, I haven't tried.
For all of you who are not using Eclipse or NetBeans or some other Java IDE... Go download one of them (I prefer Eclipse) they make it so much easier... don't use notepad++
I'm not very good at explaining things so you may have to have some knowledge about modding.
Basic Tutorials:
Start With This as your mod_ class. Used For everything.
Basic Block:
Add this into your mod_ class
Then add this to your constructor public void load();
Then make a new class and call it BlockNew and have it look like this
Making Block Drop Item:
Instead of this in your block class:
Use This:
Basic Item:
Add this into your mod_ class
Then add this to your constructor public void load();
Block effects. Just add these to your block class choose which ever you like.
Add import
Making Blocks render different without ModelBlock classes
Simple Way
Ok I'm going to make it simpler than most people have said. This should help a lot of people. Here is a simple block class with the code to make the block long and thin. Feel free to mess around with it.
This is the part where the block shape is added:
This part basically tells the game not to render the block as a normal block and then tells it that the block texture does not cover the block below it so you can't see through the map
Explanation of the code:
The first number Is the length of the block from 1 edge.
The second number Is the height off the ground.
The third number Is the widht of the block from 1 edge.
The fourth number Is the length of the block.
The fifth number Is the height of the block.
The sixth number Is width of the block
Making a block spawn blocks
You will need to add this method to your Block class
Within that method add this
Where i = the blocks current X-axis position
Where j = the blocks current Y-axis position (or height)
Where k = the blocks current Z-axis position
So if you want the block to spawn 1 block above your block it would look like this
GUI TUTORIALS (Includes how to add your blocks to the Creative Gui)
Okay well first of all here is the basic code set up for a GUI:
Basic Gui Stuff
And then if you want to add a button, add this code to initGui()
Then to make that button do something add this to actionPerformed(GuiButton guibutton)
To add text to the GUI add this to drawScreen(int i, int j, float f)
Now on to your mod_ class, this is an example of what all you should have for your gui
Add this to your mod_ class
And then just add this within that method
Make a boolean called areBlocksAdded
And Import this:
Then Follow This
Use This Code Inside Of public boolean OnTickInGUI(float f, Minecraft minecraft, GuiScreen guiscreen)
Simple Jet-Pack (Based off of the one in my mod WyldeMod)
All of this code goes in your mod_ class within:
Make sure you have a chest armor piece made that you want to use for the jet pack.
You will need to add this to your mod_ class. You can find it in BaseMod.java. Make sure you have Minecraft imported (import src.minecraft.client.Minecraft;)
To make it simple add this short bit of code to that method
This lets you use legs/boots/chest/helm item slot without typing a lot of stuff out.
Then for the registering if the player is wearing the jet pack, use this withing the same method
Now just so you don't die when using the jet pack use this.
Now for the fun stuff.
Add this next stuff to that if statement we just added:
This tells the game that if there is no gui open and the player is pressing the jump key that what ever is inside the code will happen
Finally for the flight part, add this to that last if statement
This sets a max speed on how fast the player can go up and tells the game to make the player go up
There you should have a simple jet pack.
If this helped remember to click the +
Post anything you would like to see in the comments
If you truly do not understand something and you have tried to fix it yourself, just send me a PM and I will gladly be willing to help you.
jamolnng
Follow @jamolnng
The best way to contact me is via twitter.
Shh, don't tell them this...but I don't like newbies... they scare me. So they can go learn how to mod and then come back. But I might edit it a little to make it easier to understand.
Follow @jamolnng
The best way to contact me is via twitter.
Follow @jamolnng
The best way to contact me is via twitter.
> Recompiling client...
javac.exe -g -source 1.6 -target 1.6 -classpath "lib/;lib/*;jars/bin/minecraft.j
ar;jars/bin/jinput.jar;jars/bin/lwjgl.jar;jars/bin/lwjgl_util.jar" -sourcepath s
rc/minecraft -d bin/minecraft src/minecraft\net\minecraft\client\*.java src/mine
craft\net\minecraft\src\*.java conf/patches/*.java failed.
Return code : 1
== ERRORS FOUND ==
warning: [options] bootstrap class path not set in conjunction with -source 1.6
src\minecraft\net\minecraft\src\BlockSalt.java:14: error: cannot find symbol
return mod_salt.saltBlock.BlockID;
^
symbol: variable BlockID
location: variable saltBlock of type Block
return mod_Example.newBlock.BlockID;
this should be
return mod_Example.newBlock.blockID;
case sensitive.
Well the easiest way to do it would be just to add an image over the top of the button, otherwise you would probably have to use a whole lot of code to have the picture be part of the button. I'm not quite sure though, I haven't tried.
Follow @jamolnng
The best way to contact me is via twitter.
jamolnng :wub.gif:
Follow @jamolnng
The best way to contact me is via twitter.
Follow @jamolnng
The best way to contact me is via twitter.
I know it is Paraknights code. Go look at his mod page "Development has been handed over to jamolnng."
http://www.minecraftforum.net/topic/542774-100-❖-pk-mods-❖-now-recruiting/page__hl__paraknight#jetpack
jamolnng :wub.gif:
Follow @jamolnng
The best way to contact me is via twitter.
Very good choice :smile.gif:
jamolnng :wub.gif:
Follow @jamolnng
The best way to contact me is via twitter.
~MrX
Edit: i believe no one has given you any but!!!!!! here have some of mine :wink.gif:
I prefer +'s in place of diamond :tongue.gif: anyways I already have enough diamonds.
jamolnng :wub.gif:
Follow @jamolnng
The best way to contact me is via twitter.
jamolnng :wub.gif:
Follow @jamolnng
The best way to contact me is via twitter.
I might, I actually haven't ever made a mob before
Follow @jamolnng
The best way to contact me is via twitter.
Okay, cool.