Jump to content

Recommended Posts

Posted (edited)

So I'm trying to make a custom chestplate that spawns a sword when you sneak and right click but before i even reach the part about the summoning sword I want to make sure that its actually checking if im wearing it and if that's working So my current two problems are:
it won't do the command I'm asking it to do so i could make sure it actually works
I can't seem to find a way to make it so it would do it when i right click it i know onItemRightClick but that's "onItem".

 

package com.izako.HunterX.items.armor;

import com.izako.HunterX.init.ModItems;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;

public class HanzoArmorBase extends ArmorBaseSkin {

	public HanzoArmorBase(String name, String pathName, ArmorMaterial material, int renderIndex,
			EntityEquipmentSlot equipmentSlot) {
		super(name, pathName, material, renderIndex, equipmentSlot);
	}

	public void onArmorTickUpdate(World world, EntityPlayer playerIn, ItemStack itemStack, EnumHand handIn) {
			while (playerIn.isSneaking()) {

				playerIn.setHealth(playerIn.getHealth() - 1);
				playerIn.sendMessage(new TextComponentString("woah there fella"));
			}

		}

	}

 

Edited by izako
Posted (edited)

1.

10 minutes ago, izako said:

ArmorBaseSkin

Do not create "base" classes (ItemBase, BlockBase, etc). Do not abuse inheritance to write less code.

 

2. Remember to check the side by using World#isRemote.

 

3.

10 minutes ago, izako said:

while (playerIn.isSneaking())

Are you sure you want to use a while loop there?

(Hint: no)

 

4. Annotates your methods that are meant to override methods from the parent class with the @Override annotation (onArmorTickUpdate in this case).

This is leading to your current problem, as the method signature of your onArmorTickUpdate method does not match that of its super method.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted
32 minutes ago, DavidM said:

1.

Do not create "base" classes (ItemBase, BlockBase, etc). Do not abuse inheritance to write less code.

  

 2. Remember to check the side by using World#isRemote.

  

3.

Are you sure you want to use a while loop there?

 (Hint: no)

 

4. Annotates your methods that are meant to override methods from the parent class with the @Override annotation (onArmorTickUpdate in this case).

 This is leading to your current problem, as the method signature of your onArmorTickUpdate method does not match that of its super method.

i did everything you said and i made it extend ItemArmor instead and added all missing code but it still doesn't seem to work at all it gives no mention of what i asked of it 

 

*id post a pastebin but its not allowed in my country and my vpn isn't working currently*

 

HanzoArmorBase.txt

Posted
38 minutes ago, DavidM said:

Annotates your methods that are meant to override methods from the parent class with the @Override annotation (onArmorTickUpdate in this case).

You still did not annotate your onArmorTickUpdate method with the @Override annotation.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted
6 minutes ago, DavidM said:

You still did not annotate your onArmorTickUpdate method with the @Override annotation.

that just gave me the error "The method onArmorTickUpdate(World, EntityPlayer, ItemStack, EnumHand) of type HanzoArmorBase must override or implement a supertype method"

 

Posted (edited)
27 minutes ago, izako said:

that just gave me the error "The method onArmorTickUpdate(World, EntityPlayer, ItemStack, EnumHand) of type HanzoArmorBase must override or implement a supertype method"

That is suppose to happen; the @Override annotation should give a compile-time error when the method associated with it does not override a super method.

Make sure the return type and parameters of your onArmorTickUpdate matches the return type and parameters of the onArmorTickUpdate method in the class you are overriding.

 

If you still cannot understand what you are suppose to do, the I'm afraid you might not be ready to make Minecraft mods. You should have basic Java knowledge, which includes overriding and inheritance, before attempting to make a mod. I would recommend looking up some Java tutorials in order to get familiar with Java before making mods.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted
2 hours ago, DavidM said:

That is suppose to happen; the @Override annotation should give a compile-time error when the method associated with it does not override a super method.

Make sure the return type and parameters of your onArmorTickUpdate matches the return type and parameters of the onArmorTickUpdate method in the class you are overriding.

 

If you still cannot understand what you are suppose to do, the I'm afraid you might not be ready to make Minecraft mods. You should have basic Java knowledge, which includes overriding and inheritance, before attempting to make a mod. I would recommend looking up some Java tutorials in order to get familiar with Java before making mods.

thanks it worked i was just using the wrong method it was actually onArmorTick not onArmorTickUpdate

Posted
6 hours ago, izako said:

thanks it worked i was just using the wrong method it was actually onArmorTick not onArmorTickUpdate

That's exactly why you should use the @Override annotation.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.