Started by
enderandy05
on
Topic category: Help with Minecraft modding (Java Edition)
So, I made an Item a weapon. I made it so when you kill a mob, it strikes lightning a few blocks ahead. When I realized it was an item and not a tool (because the model doesnt look like a sword in your hand), I changed it to a tool and made the type a sword. Only problem is I can't figure out how to make it strike lightning when I kill a mob since it doesn't have the same event things. Is there a way to make it so it strikes lightning when I kill a mob with the tool? If so can someone explain to me how? Or maybe make it so the Item one appears as your wielding a sword.
For making the item wielding like a sword, try to edit the tool value of the item, but I don't know if it works.
Sooo, you can go back to that item, copy the code for striking a lightning on kill, and paste it at your desired spot. It works hopefully :3. Also, it's more fun to make mods, when u code some stuff in there aswell. I mean, they even made a "code" tab for coding :3
@#2 Well, I tried adding the thing I thought was the lightning to the weapon. Here's what I added (it was at the end):
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entity, EntityLivingBase entity2) {
int i = (int) entity.posX;
int j = (int) entity.posY;
int k = (int) entity.posZ;
World world = entity.worldObj;
if (true) {
world.spawnEntityInWorld(new EntityLightningBolt(world, i + (0 * 1), j, k + (0 * 1), false));
And here's what went wrong (whatever this is):
First time (sorry its so goddamn big):
D:\MCreator174\forge\build\sources\main\java\mod\mcreator\mcreator_angelicSword.java:75: error: ';' expected
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entity, EntityLivingBase entity2) {
^
D:\MCreator174\forge\build\sources\main\java\mod\mcreator\mcreator_angelicSword.java:75: error: ';' expected
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entity, EntityLivingBase entity2) {
^
D:\MCreator174\forge\build\sources\main\java\mod\mcreator\mcreator_angelicSword.java:75: error: not a statement
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entity, EntityLivingBase entity2) {
^
D:\MCreator174\forge\build\sources\main\java\mod\mcreator\mcreator_angelicSword.java:75: error: ';' expected
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entity, EntityLivingBase entity2) {
^
D:\MCreator174\forge\build\sources\main\java\mod\mcreator\mcreator_angelicSword.java:75: error: ';' expected
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entity, EntityLivingBase entity2) {
^
D:\MCreator174\forge\build\sources\main\java\mod\mcreator\mcreator_angelicSword.java:85: error: reached end of file while parsing
}
Second time (added @Override before it)
6 errors
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
BUILD FAILED
Execution failed for task ':c> CompilationTotal time: 30.825 secs
failed; see the compiler error output for detaiRun with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
ls.
ompileJava'.
@#1 Doesnt work, already tried it. It still just looks like your holding a 2D brick or something but in the shape of a sword