So, I've been trying to make a simple mod (my first one that isn't from a tutorial) that adds an item called the "Ghast Blaster." (Ignore the silly name please.) What it does is when the player right clicks, the item launches the same fireball entity used by the Ghast, except from the player. I have everything down except the actual "creation" of the fireball. I am lazy and inexperienced, so I copied the code from the Ghast's attack sequence, but changed a few of the variables to match those of the bow (which also deploys an entity from an item held by the player.) However, the last three variables (d5, d6, d7), don't have an obvious replacement set. How do I rig these parameters to launch from the player?
My code:
package net.minecraft.src;
public class ItemGhastBlaster extends Item{
public ItemGhastBlaster(int i) {
super(i);
setMaxDamage(64);
maxStackSize = 1;
}
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer){
int dmg = 1;
EntityFireball entityfireball = new EntityFireball(world, entityplayer, d5, d6, d7);
world.playSoundAtEntity(entityplayer, "fire.ignite", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
entityplayer.swingItem();
itemstack.damageItem(1, entityplayer);
world.entityJoinedWorld(entityfireball);
return itemstack;
}
}
Rollback Post to RevisionRollBack
My Website. I make mods for Minecraft and am also making my own game.
Okay, new problem. The item is in the game and can be crafted. However, when I right click, there is no epic Ghast fireball and the durability doesn't go down. Any suggestions? My code:
public static final Item GhastBlaster = new Item(4800).setItemName("Ghast Blaster");
You didn't actually make it a "new ItemGhastBlaster" :smile.gif:
I don't get how this would allow it to be crafted and used in-game. The only problem is that it doesn't shoot fireballs when it's in your hand and you right-click. And, even if I was wrong (which I probably am), you didn't actually state how to fix the problem. Like i said in the OP, this is my first mod that isn't from a tutorial.
Rollback Post to RevisionRollBack
My Website. I make mods for Minecraft and am also making my own game.
I don't get how this would allow it to be crafted and used in-game. The only problem is that it doesn't shoot fireballs when it's in your hand and you right-click. And, even if I was wrong (which I probably am), you didn't actually state how to fix the problem. Like i said in the OP, this is my first mod that isn't from a tutorial.
Most items in the game that don't actually do anything and are only used in crafting or smelting - like ingots, sticks, coal, that kind of thing - are instances of just Item. You subclassed Item to make ItemGhastBlaster, as you need to since your item actually does something. The problem is that when you create your item (in the line I pasted) you only used the "Item" class, so your new class isn't actually used. The default Item class doesn't do anything on rightclick, as you've seen, but it's still a valid class and can be crafted. All you need to do is change the "= new Item" to "= new ItemGhastBlaster" so it's your class instead of just an Item. I was trying to express that that's how to fix the problem; I apologize if I was too unclear.
Most items in the game that don't actually do anything and are only used in crafting or smelting - like ingots, sticks, coal, that kind of thing - are instances of just Item. You subclassed Item to make ItemGhastBlaster, as you need to since your item actually does something. The problem is that when you create your item (in the line I pasted) you only used the "Item" class, so your new class isn't actually used. The default Item class doesn't do anything on rightclick, as you've seen, but it's still a valid class and can be crafted. All you need to do is change the "= new Item" to "= new ItemGhastBlaster" so it's your class instead of just an Item. I was trying to express that that's how to fix the problem; I apologize if I was too unclear.
Thanks. That worked. Now, if only I could make the fireballs more accurate...
My code:
My Website. I make mods for Minecraft and am also making my own game.
That *should* fire the fireball in the direction the player is looking.
My Website. I make mods for Minecraft and am also making my own game.
The error is on the first line of your code. My Eclipse says, "Vec3d cannot be resolved to a type." Do you have a fix?
EDIT: Never mind. It was a capitalization problem. :tongue.gif:
My Website. I make mods for Minecraft and am also making my own game.
GhastBlaster.class
mod_MysticItems.class
My Website. I make mods for Minecraft and am also making my own game.
You didn't actually make it a "new ItemGhastBlaster" :smile.gif:
INFORMATION WANTS TO BE WRONG
I don't get how this would allow it to be crafted and used in-game. The only problem is that it doesn't shoot fireballs when it's in your hand and you right-click. And, even if I was wrong (which I probably am), you didn't actually state how to fix the problem. Like i said in the OP, this is my first mod that isn't from a tutorial.
My Website. I make mods for Minecraft and am also making my own game.
Most items in the game that don't actually do anything and are only used in crafting or smelting - like ingots, sticks, coal, that kind of thing - are instances of just Item. You subclassed Item to make ItemGhastBlaster, as you need to since your item actually does something. The problem is that when you create your item (in the line I pasted) you only used the "Item" class, so your new class isn't actually used. The default Item class doesn't do anything on rightclick, as you've seen, but it's still a valid class and can be crafted. All you need to do is change the "= new Item" to "= new ItemGhastBlaster" so it's your class instead of just an Item. I was trying to express that that's how to fix the problem; I apologize if I was too unclear.
INFORMATION WANTS TO BE WRONG
but then again, it is java.
Want the blight town experience? pay someone to throw rocks at you as you tightrope across two buildings.
Want the sens fortress experience? pay someone to throw rocks at you as you tightrope across two buildings.
Want the anor londo experience? pay someone to throw rocks at you as you tightrope across two buildings.
Thanks. That worked. Now, if only I could make the fireballs more accurate...
My Website. I make mods for Minecraft and am also making my own game.