Jump to content

Recommended Posts

Posted

How would one test for the armor a player is wearing and if say the player was wearing a full set of diamond armor give some effect or buff?

The seven became one and the one became two.

Posted

If you have a reference to the player, check their equipment slots. There are four of them.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
@SubscribeEvent
	public void onDamage(LivingDamageEvent event) {
		EntityPlayer player;
		List<ItemStack> armor = null;
		
		if(event.getEntity() instanceof EntityPlayer) {
			player = (EntityPlayer) event.getEntity();
			armor = (List<ItemStack>) player.getArmorInventoryList();
		}
		if(!armor.isEmpty()) {
			if(armor.get(0) == new ItemStack(ItemInit.BOOTS_MERTHEW)) {
				if(armor.get(1) == new ItemStack(ItemInit.LEGGINGS_MERTHEW)) {
					if(armor.get(2) == new ItemStack(ItemInit.CHESTPLATE_MERTHEW)) {
						if(armor.get(3) == new ItemStack(ItemInit.HELM_MERTHEW)) {
							event.setAmount(0);
						}
					}
				}
			}
		}
	}

This is what i was trying to do, what am i doing wrong?
if you need the git hub: https://github.com/Merthew/MerthewMod/

The seven became one and the one became two.

Posted

wrong code.. srry

@Override
	public void onArmorTick(final World world, final EntityPlayer player, final ItemStack itemStack) {
		List<ItemStack> narmor = new ArrayList<ItemStack>();
		narmor.add(new ItemStack(ItemInit.BOOTS_MERTHEW));
		narmor.add(new ItemStack(ItemInit.LEGGINGS_MERTHEW));
		narmor.add(new ItemStack(ItemInit.CHESTPLATE_MERTHEW));
		narmor.add(new ItemStack(ItemInit.HELM_MERTHEW));
		
		List<ItemStack> armor = (List<ItemStack>) player.getArmorInventoryList();
		
		if(armor.get(0) == narmor.get(3)) {
			if (!player.isPotionActive(potionEffect.getPotion())) { // If the Potion isn't currently active,
				player.addPotionEffect(new PotionEffect(potionEffect)); // Apply a copy of the PotionEffect to the player
			}
		}
	}

 

The seven became one and the one became two.

Posted

What if they are wearing only a chestplate? Is the list still 4 items long?

Are the items in the right order?

if(armor.get(0) == narmor.get(3))

This will never be true.

 

You should be using EntityPlayer#getItemStackFromSlot(EntityEquipmentSlot)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
7 hours ago, Merthew said:

Thanks, i never knew about many of the methods you so far have helped with.

To compare ItemStacks you need to compare the item and the metadata. ItemStack#getItem and ItemStack.getMetadata() It is also possible to use the utility functions in the ItemStack class. ItemStack.are.....

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • hey sorry for the late response, i fixed all the links in my most recent post if you want to take a look at those it has the log and crash file both there and then the crash that happened yesterday  
    • https://api.mclo.gs/1/raw/bRL0d6K Thanks i didnt know the way to share. Here it is.
    • Add the crash-report or latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here  
    • I've been constructing a custom mod pack for my friend's and I that is create and decoration focused. I have a whole catalogue of mods and I'm not smart enough to what's conflicting or how to fix said conflicts.      
    • Hello. I want to write a client mod (for version 1.12.2), which simply print "Break!" in the game console when some player (not only me) breaks a block. I used this documentation, but I ran into a problem. Here is the mod code: @Mod(modid = ExampleMod.MODID, name = ExampleMod.NAME, version = ExampleMod.VERSION) public class ExampleMod { public static final String MODID = "examplemod"; public static final String NAME = "Example Mod"; public static final String VERSION = "1.0"; private static final Logger logger = LogManager.getLogger(ExampleMod.MODID); @Mod.EventHandler public void init(FMLInitializationEvent event) { logger.info("Started"); } } @Mod.EventBusSubscriber(modid = ExampleMod.MODID) class TestHandler { private static final Logger logger = LogManager.getLogger(ExampleMod.MODID); @SubscribeEvent public static void onBlockBreak(BlockEvent.BreakEvent event) { logger.info("Break!"); } } The problem is that the mod works in singleplayer mode, but stops working when I go to the server. In multiplayer, I do not receive block breaking events, either from other players or from myself. It seems to me that the mod is loaded as a server one. But I did not find a way to explicitly indicate that the mod should be loaded as a client one.
×
×
  • Create New...

Important Information

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