Help with making a weapon tool

Started by enderandy05 on

Topic category: Help with modding (Java Edition)

Last seen on 22:55, 8. Jun 2019
Joined Aug 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Help with making a weapon tool

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.

Last seen on 17:49, 25. Mar 2021
Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
For making the item wielding
Mon, 10/02/2017 - 10:36

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.

Last seen on 16:24, 5. Jan 2018
Joined Sep 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:For making the item wielding
Mon, 10/02/2017 - 13:10

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

Last seen on 22:55, 8. Jun 2019
Joined Aug 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:For making the item wielding
Mon, 10/02/2017 - 20:59

@#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'.
 

Last seen on 22:55, 8. Jun 2019
Joined Aug 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:For making the item wielding
Tue, 10/03/2017 - 03:40

@#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