package net.minecraft.src;
public class mod_GhostStick extends BaseMod {
public static final Item ghoststickItem = new Item(3000) .setItemName ("Ghost Stick");
public mod_GhostStick()
{
ModLoader.AddName(ghoststickItem, "Ghost Stick");
ghoststickItem.iconIndex = ModLoader.addOverride("/gui/items.png", "/textures/ghoststick.png");
ModLoader.AddRecipe(new ItemStack(ghoststickItem, 1), new Object[] {
" X ", Character.valueOf('X'), Block.dirt
});
}
public String Version()
{
return "Version 0.1 Dev";
}
}
Bam.
So whats with the tutorials all having the "ItemExample" and mod_Example, and then within the code randomly having "exampleItem." Is there any reason for this? Why can't (in my code) ghoststickItem be ItemGhostStick?
And what folder in MCP do I place my texture in?
1. MCP/lib
2. MCP/bin/minecraft
3. MCP/temp/bin/minecraft
Because EVERY SINGLE TUTORIAL says something different, or nothing at all.
And last, I followed a tutorial on how to make right clicking while holding an item spawn an animal.
So here is the code within my ItemGhostStick. (lol?)
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
{
if(!world.multiplayerWorld)
{
EntityLiving entityliving = (EntityLiving)EntityList.createEntityInWorld("Pig", entityplayer.worldObj);
entityliving.setLocationAndAngles(i, j + 1, k, 0F, 0F);
entityplayer.worldObj.entityJoinedWorld(entityliving);
itemstack.damageItem(1, entityplayer);
entityplayer.swingItem();
}
return true;
}
}
And last, I followed a tutorial on how to make right clicking while holding an item spawn an animal.
So here is the code within my ItemGhostStick. (lol?)
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
{
if(!world.multiplayerWorld)
{
EntityLiving entityliving = (EntityLiving)EntityList.createEntityInWorld("Pig", entityplayer.worldObj);
entityliving.setLocationAndAngles(i, j + 1, k, 0F, 0F);
entityplayer.worldObj.entityJoinedWorld(entityliving);
itemstack.damageItem(1, entityplayer);
entityplayer.swingItem();
}
return true;
}
}
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
{
if(!world.multiplayerWorld)
{
EntityPig pig = new EntityPig(world);
pig.setLocationAndAngles(i, j + 1, k, entityplayer.rotationYaw + 180F, -entityplayer.rotationPitch);
world.entityJoinedWorld(pig);
}
itemstack.damageItem(1, entityplayer);
return true;
}
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
{
if(!world.multiplayerWorld)
{
EntityPig pig = new EntityPig(world);
pig.setLocationAndAngles(i, j + 1, k, entityplayer.rotationYaw + 180F, -entityplayer.rotationPitch);
world.entityJoinedWorld(pig);
}
itemstack.damageItem(1, entityplayer);
return true;
}
No, I tried yours, and then yours with "onItemRightClick" and both did nothing at all.
Although your code does make a lot more sense to me than the one I had. I think this tutorial is flawed because I followed it word by word...
Edit: Here's the tutorial if you want to look at it.
public static final Item ghoststickItem = new Item(3000) .setItemName ("Ghost Stick");
will need to be changed to this:
public static final ItemGhostStick ghoststickItem = new Item(3000) .setItemName ("Ghost Stick");
If you use the first (wrong) line, it is created as an "Item" type, with no specifics about its nature, its abilities, stacksize, etc.
If you use the second (correct) line, it is created as an "ItemGhostStick" type, which will then have the proerties and methods you have defined in your code. Until you do that, nothing you write within your ItemGhostStick.java will have any effect.
public static final Item ghoststickItem = new Item(3000) .setItemName ("Ghost Stick");
will need to be changed to this:
public static final ItemGhostStick ghoststickItem = new Item(3000) .setItemName ("Ghost Stick");
If you use the first (wrong) line, it is created as an "Item" type, with no specifics about its nature, its abilities, stacksize, etc.
If you use the second (correct) line, it is created as an "ItemGhostStick" type, which will then have the proerties and methods you have defined in your code. Until you do that, nothing you write within your ItemGhostStick.java will have any effect.
Hmm that makes sense, but
== MCP v4.4 ==
> Recompiling client...
"C:\Program Files\Java\jdk1.6.0_26\bin\javac.exe" -g -source 1.6 -target 1.6 -cl
asspath "lib/;lib/*;jars/bin/minecraft.jar;jars/bin/jinput.jar;jars/bin/lwjgl.ja
r;jars/bin/lwjgl_util.jar" -sourcepath src/minecraft -d bin/minecraft src/minecr
aft\net\minecraft\client\*.java src/minecraft\net\minecraft\isom\*.java src/mine
craft\net\minecraft\src\*.java conf/patches/*.java failed.
Return code : 1
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\mod_GhostStick.java:5: incompatible types
found : net.minecraft.src.Item
required: net.minecraft.src.ItemGhostStick
public static final ItemGhostStick ghoststickItem = new Item(3000) .setItemName
("Ghost Stick");
^
1 error
==================
> Done in 9.51 seconds
> Recompiling server...
> Done in 8.12 seconds
Press any key to continue . . .
== MCP v4.4 ==
> Recompiling client...
"C:\Program Files\Java\jdk1.6.0_26\bin\javac.exe" -g -source 1.6 -target 1.6 -cl
asspath "lib/;lib/*;jars/bin/minecraft.jar;jars/bin/jinput.jar;jars/bin/lwjgl.ja
r;jars/bin/lwjgl_util.jar" -sourcepath src/minecraft -d bin/minecraft src/minecr
aft\net\minecraft\client\*.java src/minecraft\net\minecraft\isom\*.java src/mine
craft\net\minecraft\src\*.java conf/patches/*.java failed.
Return code : 1
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\mod_GhostStick.java:5: incompatible types
found : net.minecraft.src.Item
required: net.minecraft.src.ItemGhostStick
public static final ItemGhostStick ghoststickItem = new Item(3000) .setItemName
("Ghost Stick");
^
1 error
==================
> Done in 9.51 seconds
> Recompiling server...
> Done in 8.12 seconds
Press any key to continue . . .
Missed something else, here's the corrected line:
public static final ItemGhostStick ghoststickItem = new ItemGhostStick(3000) .setItemName ("Ghost Stick");
The last change I had you make was actually changing it from storing an Item to storing an ItemGhostStick, but that require that an ItemGhostStick is created.
You also need to change the Item(3000) constructor to be the ItemGhostStick(3000) constructor so you are creating a ItemGhostStick rather than an Item.
public static final ItemGhostStick ghoststickItem = new ItemGhostStick(3000) .setItemName ("Ghost Stick");
The last change I had you make was actually changing it from storing an Item to storing an ItemGhostStick, but that require that an ItemGhostStick is created.
You also need to change the Item(3000) constructor to be the ItemGhostStick(3000) constructor so you are creating a ItemGhostStick rather than an Item.
Still makes sense, but didn't do the trick :sad.gif:
Oh right, it was there previously I think but here you go.
package net.minecraft.src;
import java.util.Random;
public class ItemGhostStick extends Item
{
public ItemGhostStick(int i)
{
super(i);
maxStackSize = 1;
setMaxDamage(8);
}
public boolean onItemRightClick(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
{
if(!world.multiplayerWorld)
{
EntityLiving entityliving = (EntityLiving)EntityList.createEntityInWorld("Pig", entityplayer.worldObj);
entityliving.setLocationAndAngles(i, j + 1, k, 0F, 0F);
entityplayer.worldObj.entityJoinedWorld(entityliving);
itemstack.damageItem(1, entityplayer);
entityplayer.swingItem();
}
return true;
}
}
The one other thing was the "onItemRightClick" could also be "onItemUse" and I don't know which to use.
Edit: I was also curious why the if statement was referring to "multiplayer," but the mod tutorial was for singleplayer.
Should be onItemRightClick. Also looking back at some of my code from before, this is the way I constructed my custom item:
public static final Item wand = new ItemWand(31000).setItemName("Wand");
So it does need to be an Item(I made a mistake in what I told you before) but it needs to be constructed from the ItemGhostStick constructor you wrote. Sorry for the confusion XD
Edit: The if statement is for the cases the item is used in multiplayer. Then minecraft sends a message to the server indicating that this item was used by this player, and the single player item itself should not handle the spawn logic in this case. The server handles it.
Bam.
So whats with the tutorials all having the "ItemExample" and mod_Example, and then within the code randomly having "exampleItem." Is there any reason for this? Why can't (in my code) ghoststickItem be ItemGhostStick?
And what folder in MCP do I place my texture in?
1. MCP/lib
2. MCP/bin/minecraft
3. MCP/temp/bin/minecraft
Because EVERY SINGLE TUTORIAL says something different, or nothing at all.
And last, I followed a tutorial on how to make right clicking while holding an item spawn an animal.
So here is the code within my ItemGhostStick. (lol?)
Thanks :biggrin.gif:
public static final Item ghoststickItem = new Item(3000) .setItemName ("Ghost Stick");
the mod_ItemExample is the mod name, the exampleItem is the Item name
Q2:
MCP/bin/minecraft
Q3:
Ive never heard of anything like that so I can't help :sad.gif:
Ok thanks :smile.gif:
All I really need to know now is the third one.
And... where's your problem with this?
It recompiles fine, but going in game and right clicking does nothing.
No, I tried yours, and then yours with "onItemRightClick" and both did nothing at all.
Although your code does make a lot more sense to me than the one I had. I think this tutorial is flawed because I followed it word by word...
Edit: Here's the tutorial if you want to look at it.
Scroll down to "HOCKEYPOWWA97's Tutorials"
will need to be changed to this:
If you use the first (wrong) line, it is created as an "Item" type, with no specifics about its nature, its abilities, stacksize, etc.
If you use the second (correct) line, it is created as an "ItemGhostStick" type, which will then have the proerties and methods you have defined in your code. Until you do that, nothing you write within your ItemGhostStick.java will have any effect.
Hmm that makes sense, but
Missed something else, here's the corrected line:
The last change I had you make was actually changing it from storing an Item to storing an ItemGhostStick, but that require that an ItemGhostStick is created.
You also need to change the Item(3000) constructor to be the ItemGhostStick(3000) constructor so you are creating a ItemGhostStick rather than an Item.
Still makes sense, but didn't do the trick :sad.gif:
Error Log:
And heres the updateed code just in case:
In order to use the Class ItemGhostStick it has to exist. So make it first ^^
For example:
ItemGhostStick.java
You didn't create a class, did you?
Screw that above.
setItemName is returning an Item, therefore you have to cast.
So do:
That one didn't produce an error, but right clicking or doing any action with it fails to do anything. Hmm.
Oh right, it was there previously I think but here you go.
The one other thing was the "onItemRightClick" could also be "onItemUse" and I don't know which to use.
Edit: I was also curious why the if statement was referring to "multiplayer," but the mod tutorial was for singleplayer.
Should be onItemRightClick. Also looking back at some of my code from before, this is the way I constructed my custom item:
So it does need to be an Item(I made a mistake in what I told you before) but it needs to be constructed from the ItemGhostStick constructor you wrote. Sorry for the confusion XD
onItemRightClick is this function:
Not the one you posted above. Do it like this:
Haven't tested it, but it should work ^^
Edit: The if statement is for the cases the item is used in multiplayer. Then minecraft sends a message to the server indicating that this item was used by this player, and the single player item itself should not handle the spawn logic in this case. The server handles it.
But in the cmd window its saying:
lol, doesn't really make a difference but interesting nonetheless.
Thanks for the help everyone :smile.gif: