Jump to content

Sheilds


ashtonr12

Recommended Posts

I have my shield that you can currently block with it and take reduced damage,

i would like my shield to take damage when right clicked but i cant find out how anywhere in the existing code,

i would alos like th resitance potion effect to last as long as i hold down right click and again i couldn't find any similar or same code in the existing code, so if anyone could show me some ways of doing this i would be very grateful.

 

package ashtonsmod.common;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class DarkShield extends Item
{
    public DarkShield(int par1)
    {
        super(par1);
        this.maxStackSize = 1;
        this.setMaxDamage(200);
    }
   
    @Override
  	public String getTextureFile(){
  		return CommonProxy.items_png;   
}    
    @SideOnly(Side.CLIENT)

    /**
     * Returns True is the item is renderer in full 3D when hold.
     */
    public boolean isFull3D()
    {
        return true;
    }

    /**
     * returns the action that specifies what animation to play when the items is being used
     */
    public EnumAction getItemUseAction(ItemStack par1ItemStack)
    {
        return EnumAction.block;
    }

    /**
     * How long it takes to use or consume an item
     */
    public int getMaxItemUseDuration(ItemStack par1ItemStack)
    {
        return 72000;
    }

    /**
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
     */
    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
        par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 10, 5));
        return par1ItemStack;
        
        
    }



}

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

ok so i fixed the damage on right click but i cant make the duration of the potion effect equal the length of the player holding right click.

 

updated code;

 

package ashtonsmod.common;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class DarkShield extends Item
{
    public DarkShield(int par1)
    {
        super(par1);
        this.maxStackSize = 1;
        this.setMaxDamage(200);
    }
   
    @Override
  	public String getTextureFile(){
  		return CommonProxy.items_png;   
}    
    @SideOnly(Side.CLIENT)

    /**
     * Returns True is the item is renderer in full 3D when hold.
     */
    public boolean isFull3D()
    {
        return true;
    }

    /**
     * returns the action that specifies what animation to play when the items is being used
     */
    public EnumAction getItemUseAction(ItemStack par1ItemStack)
    {
        return EnumAction.block;
    }

    /**
     * How long it takes to use or consume an item
     */
    public int getMaxItemUseDuration(ItemStack par1ItemStack)
    {
        return 72000;
    }

    /**
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
     */
    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
        par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
        par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 10, 5));
        par1ItemStack.damageItem(1, par3EntityPlayer);
        return par1ItemStack;
        
    }



}

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

ok so this has been up for about two days, so clearly this is not a common topic, does anyone know a workaround like increaseing the resistance whilst block with a specific item or something like this?

Use examples, i have aspergers.

Examples make sense to me.

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.

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.