I have created this/these tutorial(s) to cover topics that some users and newer modders might need help in. These topics will cover all aspects of modding, Please request a mod if you want to see one!!
The current tutorials:
1. How to make a mob drop and item without death.
2.How to check the Players current item.Click Here.
3.How to make a block or item drop 1 or more items.Click Here.
4.Structures and World Generation.Click Here.
Expect a new tutorial every day!!
How to make a mob drop and item without death:
Prerequisites:
An Entity that will spawn in the map and having a way to find it.
Small knowledge of using booleans and ints.
Optional:
Be able to give me a (+1) if this tutorial was helpful
There is a method built into Entity called
dropItem(i, j)
It will require 2 ints:
One int(i) will be the Item/Blocks name. For example Block.dirt.blockID or Item.appleGold.shiftedIndex.
The other int(j) will be used for the amount dropped per use. For example if int i was Block.dirt.blockID and int j was 4,
Each interaction would drop 4(f) dirt(i).
This is a good example of how to use this method.
This is the cows interact method(Without modification).
This is the cows Interact method when I inserted the new method we learned about(dropItem).This will make your mob drop the item and specified amount when right clicked.
There is a way we can check the player's current item in Minecraft, This can be used to make a door that needs a key to be opened. Or to fill a bucket with
water. Here is how we can check that.
First we need to create an object for the player's current held item.
This is basiclly is saying "If the player DOES have a current item, We can excute the code in the {} brackets.
And if we do not have an item in our hand, We can do something else, Or return false without doing anything.
Here is how to use this code to actually excute somthing usefull.
This will check if the player is holding a stick, And if he is when the method is excuted it will drop a golden apple. This could be used in onUpdate, Interact,
or onBlockDestroyedByPlayer. These are only a few examples.
This will convert the current item into a different item. I am not sure how this will work with items that are stackable. Use this at your own risk.
How to make a block or item drop more than one item when destroyed or clicked.
Ok remember the method
dropItem(int i, int j)
Well we are going to use this again. This time we are not using the Method interact with this though. This time we are using a method called
public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l){}
So heres what you have to do, Just put dropItem(int i, int j) inside the BlockDestroyed method. Then when that block is destroyed, it will drop the item and
amount of your choice. int i will be the item or block you want. int j will be the amount you want. You can also insert another int their or a random seeded number.
HELP
This can also be used to make an item drop an item or block. Just changed the method BlockDestroyed to
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
You may need to delete the ItemStack before the methods name. Just put in the dropBlock method. Anyways this will make your item when right clicked drop any block or item
of your choice.
Here is one Way. You add these To your EntityMagma.java File :3
public boolean interact(EntityPlayer entityplayer)
{
entityplayer.addChatMessage("<"+this.getEntityString()+"> Ima Firin' Ma Lazor !!!");
return true;
}
And here is another way !
public boolean interact(EntityPlayer entityplayer)
{
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("I love Minecraft :3");
return true;
}
Alright guys in this tutorial we are going to be creating this:
I will put a video in this spoiler later.
Heres how to code it:
Ok guys for starters we are going to need a way to see if our code works, So we need to open dirt.java.
We opened you are going to want to open another file. Block.java. Look for this code:
public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
{
}
It should be around line 416. Then you need to place that method in Block.dirt.
Now if you use eclispe I want you to add this inside your method.
int a = 0;
a++;
if(a == 1){
System.out.println("int a = " + a);
}
When we destroy the dirt. In the console we should see this:
int a = 1
If you see that, it means you are doing good so far. Trust me it will get harder. Now we are going to need
a method to check blocks and to set blocks. To set a block we use.
world.setBlock(i, j, k, l);
To check a block we use.
world.getBlockId(i, j, k);
With these 2 method we can create anything. This tutorial is getting long so open this spoiler:
Ok now we need to learn how to actually understand how to set these blocks. So heres what we should do.Add this code to dirt's DestroyedByPlayer method.
world.setBlock(i, j + 1, k, Block.tnt.blockID);
Now you can test it if you want. It will not explode or anything but, it will set a tnt above the destroyed dirt.
Let me teach you about the ints i, j, k, and l. int i is the x-axis on your map. j is the y-axis on your map. k is the z-axis on your map.
l is the block set relevant to these ints'. So now that we kind of understand that, test out that method. It should do this:
This:
Will turn into this.
Now if we do this:
world.setBlock(i+1, j, k, Block.tnt.blockID);
It will set a tnt 1 x poistion away from the destroyed dirt.If we do this.
world.setBlock(i, j, k + 1, Block.tnt.blockID);
It will set a tnt one z poistion away from the destroyed dirt.
You can also set them in the opisite direction.
world.setBlock(i - 1, j - 1, k - 1, Block.tnt.blockID);
To set a row of blocks with a single line of code do this.
Now i1, j1, k1 can be named whatever you want. Just makes it easier. This will set a line of blocks along the said poistion. It will start with whatever
number the int equals. If the int equals -1 it will start 1 to the negative direction moving in the positive direction.
If you say int = -5; int < 4, -5 would be the starting poisition and 4 would be the end. Making it 10 blocks long.
Is it possible to make a Item or Block that when placed can Build a custom structure ( like a schematic)? Also would like to see how to get making a village with Mob paths/assignments(Guards,Farming,Selling). Really want to learn how that all works.
i want (2.) How to do custom world generation(Structures) fastest as possible so i can learn how to generate a castle or just a building please xD that sounded noobish :tongue.gif:
Well, I promise that will be done today or tommorow, Working on placing new Tile Entites, and chest in custiom structures.
Is it possible to make a Item or Block that when placed can Build a custom structure ( like a schematic)? Also would like to see how to get making a village with Mob paths/assignments(Guards,Farming,Selling). Really want to learn how that all works.
Of course it is possible. This is very easy, working with ints i, j, k,(Used for world generation and structures.) are simple enough to implement in blocks. The entity AI for the Npc/Mobs wouldnt be that hard. That tutorial will come later this month.
Remember to bump and give me some (+1) (+1) (+1)'s On as many posts as possible. It encourages me to make tutorials, and shows me that you guys like them and want more!!
The current tutorials:
1. How to make a mob drop and item without death.
2.How to check the Players current item.Click Here.
3.How to make a block or item drop 1 or more items.Click Here.
4.Structures and World Generation.Click Here.
Expect a new tutorial every day!!
How to make a mob drop and item without death:
Prerequisites:
An Entity that will spawn in the map and having a way to find it.
Small knowledge of using booleans and ints.
Optional:
Be able to give me a (+1) if this tutorial was helpful
There is a method built into Entity called
It will require 2 ints:
One int(i) will be the Item/Blocks name. For example Block.dirt.blockID or Item.appleGold.shiftedIndex.
The other int(j) will be used for the amount dropped per use. For example if int i was Block.dirt.blockID and int j was 4,
Each interaction would drop 4(f) dirt(i).
This is a good example of how to use this method.
This is the cows interact method(Without modification).
This is the cows Interact method when I inserted the new method we learned about(dropItem).This will make your mob drop the item and specified amount when right clicked.
Notice I added it in the 3rd line of the method.
Seeking more help.
This method could be used on the
or
Of course you would need to use ints to declare when the items would be dropped like how it is used in EntityChicken.
Next tutorials(In order):
(1.) How to checks player current item.
(2.) How to do custom world generation(Structures)
(3.) How to spawn mobs with a certain item and block.
Please comment if I helped you so this can stay on the first page of the tutorials!!
There is a way we can check the player's current item in Minecraft, This can be used to make a door that needs a key to be opened. Or to fill a bucket with
water. Here is how we can check that.
First we need to create an object for the player's current held item.
You can rename the "itemstack" to anything. Dont rename anything else.
Then we can use that object to check OR set the players current item.
This is basiclly is saying "If the player DOES have a current item, We can excute the code in the {} brackets.
And if we do not have an item in our hand, We can do something else, Or return false without doing anything.
Here is how to use this code to actually excute somthing usefull.
This will check if the player is holding a stick, And if he is when the method is excuted it will drop a golden apple. This could be used in onUpdate, Interact,
or onBlockDestroyedByPlayer. These are only a few examples.
If you want you could also do this.
This will convert the current item into a different item. I am not sure how this will work with items that are stackable. Use this at your own risk.
How to make a block or item drop more than one item when destroyed or clicked.
Ok remember the method Well we are going to use this again. This time we are not using the Method interact with this though. This time we are using a method called So heres what you have to do, Just put dropItem(int i, int j) inside the BlockDestroyed method. Then when that block is destroyed, it will drop the item and
amount of your choice. int i will be the item or block you want. int j will be the amount you want. You can also insert another int their or a random seeded number.
HELP
This can also be used to make an item drop an item or block. Just changed the method BlockDestroyed to You may need to delete the ItemStack before the methods name. Just put in the dropBlock method. Anyways this will make your item when right clicked drop any block or item
of your choice.
By TwoGunnedPanda ! Builder4Free Is The Guy That Made me modder, Use These tutorials..
& Advanced Mob!!
EntityMagma
mod_Magma
RenderMagma
Here is one Way. You add these To your EntityMagma.java File :3
And here is another way !
First in your entityMagma, Where it says
Add " npcName = "Magma Dude"; " to there so it will then look like :
And add this at the bottom Like it shows Above in the Mob Human tutorial. You can just copy those, They have everything already.
The code :
Then In the class called RenderMagma.java ad this.
FINISHED PROJECT !
Name above Head !
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Talking On right click !
IF THIS HAS ANY ERROR'S MESSAGE ME !! I WILL FIX THEM..
You should totally read this. and check out my record label that i created once i left the minecraft community lol
You should totally read this. and check out my record label that i created once i left the minecraft community lol
Alright guys in this tutorial we are going to be creating this:
I will put a video in this spoiler later.
Heres how to code it:
Ok guys for starters we are going to need a way to see if our code works, So we need to open dirt.java.
We opened you are going to want to open another file. Block.java. Look for this code:
It should be around line 416. Then you need to place that method in Block.dirt.
Now if you use eclispe I want you to add this inside your method. When we destroy the dirt. In the console we should see this:
If you see that, it means you are doing good so far. Trust me it will get harder. Now we are going to need
a method to check blocks and to set blocks. To set a block we use. To check a block we use. With these 2 method we can create anything. This tutorial is getting long so open this spoiler:
Ok now we need to learn how to actually understand how to set these blocks. So heres what we should do.Add this code to dirt's DestroyedByPlayer method. Now you can test it if you want. It will not explode or anything but, it will set a tnt above the destroyed dirt.
Let me teach you about the ints i, j, k, and l. int i is the x-axis on your map. j is the y-axis on your map. k is the z-axis on your map.
l is the block set relevant to these ints'. So now that we kind of understand that, test out that method. It should do this:
This:
Will turn into this.
Now if we do this: It will set a tnt 1 x poistion away from the destroyed dirt.If we do this. It will set a tnt one z poistion away from the destroyed dirt.
You can also set them in the opisite direction. To set a row of blocks with a single line of code do this. Now i1, j1, k1 can be named whatever you want. Just makes it easier. This will set a line of blocks along the said poistion. It will start with whatever
number the int equals. If the int equals -1 it will start 1 to the negative direction moving in the positive direction.
If you say int = -5; int < 4, -5 would be the starting poisition and 4 would be the end. Making it 10 blocks long.
Adding some world generation; mob generation; and some extra entity tutorials. Remember to bump this and to give me some (+1)
Well, I promise that will be done today or tommorow, Working on placing new Tile Entites, and chest in custiom structures.
Of course it is possible. This is very easy, working with ints i, j, k,(Used for world generation and structures.) are simple enough to implement in blocks. The entity AI for the Npc/Mobs wouldnt be that hard. That tutorial will come later this month.
Remember to bump and give me some (+1) (+1) (+1)'s On as many posts as possible. It encourages me to make tutorials, and shows me that you guys like them and want more!!
xD thats way to easy, But if you really want it Sure!!
No problem, Be sure to come here every once in a while for more tutorials.
I just made a tutorial, I will make it tommorow or another time.