Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi,

is there a methode, that detects, when a player is hit by an arrow? Just as an Enderman... (it changes its position when it's hit by an arrow. Does anyone has an idea?

 

PS: Sorry for my bad English...  :-[

  • Author

Ok, thanks, but how can I put this into my class? I want to use it, if the player wears the full armor. Here is the code:

package de.mod.minecraft.items;

import java.util.List;

import com.sun.corba.se.impl.javax.rmi.CORBA.Util;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import Main;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;

public class ObsidianArmor extends ItemArmor {

public ObsidianArmor(ArmorMaterial material, int id,int typ) {
	super(material, id, typ);
	this.setCreativeTab(CreativeTabs.tabCombat);

}

@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot,	String type) {
	if(stack.getItem() == Main.obsidianHelmet || stack.getItem() == Main.obsidianChestplate || stack.getItem() == Main.obsidianBoots)
        {
            return Main.MODID+":textures/models/armor/obsidianArmor1.png";
        }
        if(stack.getItem() == Main.obsidianLeggins)
        {
            return Main.MODID+":textures/models/armor/obsidianArmor2.png";
        } else
        {
            return null;
        }
}

@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1){
	if(this == Main.obsidianHelmet){
		this.itemIcon = par1.registerIcon(Main.MODID+":obsidianHelmet");
	}
	if(this == Main.obsidianChestplate){
		this.itemIcon = par1.registerIcon(Main.MODID+":obsidianChestplate");
	}
	if(this == Main.obsidianLeggins){
		this.itemIcon = par1.registerIcon(Main.MODID+":obsidianLeggins");
	}
	if(this == Main.obsidianBoots){
		this.itemIcon = par1.registerIcon(Main.MODID+":obsidianBoots");
	}



}

@Override
public void onArmorTick(World world, EntityPlayer player,ItemStack itemStack) {
	super.onArmorTick(world, player, itemStack);

                //
	ItemStack helmet = player.getCurrentArmor(3);
	ItemStack chestplate = player.getCurrentArmor(2);
	ItemStack leggins = player.getCurrentArmor(1);
	ItemStack boots = player.getCurrentArmor(0);	
                //returns true if the player wears the armor	
	if(helmet != null && helmet.getItem()==Main.obsidianHelmet && chestplate != null && chestplate.getItem() == Main.obsidianChestplate && leggins != null && leggins.getItem()==Main.obsidianLeggins && boots != null && boots.getItem() == Main.obsidianBoots){
		...
	}
}


}

 

 

I want, that the player gets no damage, when he's hit by an arrow and wearing the whole armor (in this case, it's the obsidian armor).

Thanks in advance...

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.