Jump to content

[1.7.2] When Player Is Hit By Arrow


Recommended Posts

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);


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;

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");


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

Link to comment
Share on other sites

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.

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.


  • Create New...

Important Information

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