Jump to content

[1.7.10] copying damage value from one Item to another Item[SOLVED]


D3_M0N

Recommended Posts

Heyho,

 

iam trying to code a small PvP Mod and i need to copy the damage value from one Bow to another Bow.....

 

ive absolutely no idea how to do this.

 

it needs to work with this:D

 

if(player.getCurrentEquippedItem() != null)

if(hand.getItem() == MyMod.testBow)

{

if(player.inventory.hasItem(Items.arrow)){

player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);

player.inventory.addItemStackToInventory(new ItemStack(Items.bow));

 

Link to comment
Share on other sites

... i got it myself :D

 

int itemDamage = hand.getItemDamage();

if(player.getCurrentEquippedItem() != null)

if(hand.getItem() == MYMod.testBow)

{

if(player.inventory.hasItem(Items.arrow)){

player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);

 

player.inventory.addItemStackToInventory(new ItemStack(Items.bow, 1, (int) itemDamage));

Link to comment
Share on other sites

i think that will not work for my code since i use 2 diferent bows...

 

    public static class Handler implements IMessageHandler<KeyMessage, IMessage>

    {

     

        @Override

        public IMessage onMessage(KeyMessage message, MessageContext ctx)

        {

        //String string = message.text;

 

       

       

EntityPlayer player = ctx.getServerHandler().playerEntity;

ItemStack hand = player.getCurrentEquippedItem();

int itemDamage = hand.getItemDamage();

 

if(player.getCurrentEquippedItem() != null)

if(hand.getItem() == SkyPvP.testBow)

{

if(player.inventory.hasItem(Items.arrow)){

player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);

 

player.inventory.addItemStackToInventory(new ItemStack(Items.bow, 1, (int) itemDamage));

System.out.println("Normal Bow");

}

 

}

else if(hand.getItem() == Items.bow)

{

if(player.inventory.hasItem(SkyPvP.fireArrow1)){

player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);

player.inventory.addItemStackToInventory(new ItemStack(SkyPvP.testBow, 1, (int) itemDamage));

System.out.println("Test Bow");

}

 

 

}

return null;

        }

    }

}

 

 

hmmmm

Link to comment
Share on other sites

yea ive tryed that but i just dont  how i add the "NBTTagList enchantment"

 

NBTTagList enchantment = hand.getEnchantmentTagList();  <----thats what ive tryed

 

 

but i dont know what i need to add here:

 

 

player.inventory.addItemStackToInventory(new ItemStack(Items.bow, 1, (int) itemDamage));

 

 

 

sry that i ask so easy things... 

 

i just dont get it right...

Link to comment
Share on other sites

sry but i think i dont get it....

 

EntityPlayer player = ctx.getServerHandler().playerEntity;

ItemStack hand = player.getCurrentEquippedItem();

 

??? --> ItemStack oldBow = player.getCurrentEquippedItem();

??? --> ItemStack newBow = oldBow.copy();

 

int itemDamage = hand.getItemDamage();

if(player.getCurrentEquippedItem() != null)

if(hand.getItem() == SkyPvP.testBow)

{

if(player.inventory.hasItem(Items.arrow)){

player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);

 

player.inventory.addItemStackToInventory(new ItemStack(Items.bow, 1, (int) itemDamage));

System.out.println("Normal Bow");

}

 

}

else if(hand.getItem() == Items.bow)

{

if(player.inventory.hasItem(SkyPvP.fireArrow1)){

player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);

player.inventory.addItemStackToInventory(new ItemStack(SkyPvP.testBow, 1, (int) itemDamage));

System.out.println("Test Bow");

}

 

 

}

return null;

        }

    }

 

 

newBow.func_150996_a(theOtherBowItem); // setItem

 

ive no idea what to do with this...

 

 

Link to comment
Share on other sites

ok I have now understood the concept

 

but how do I bring it in my code......

 

my code:

 

press button->packethandler:

 

switch the current bow to another bow if my inv has its specific arrow in it.

 

(ich sitze seit heut mittag an dem problem und werd noch wahnsinnig:-()

Link to comment
Share on other sites

Also:

 

deine 3 sachen müssen die hier rein? und wenn ja wo bzw ich brauch ein beispiel da ich noch nicht alles in java/forge verstehe:

 

oder muss ich die sachen in die main modfile packen?

 

    public static class Handler implements IMessageHandler<KeyMessage, IMessage>

    {

     

        @Override

        public IMessage onMessage(KeyMessage message, MessageContext ctx)

        {

        //String string = message.text;

 

       

       

EntityPlayer player = ctx.getServerHandler().playerEntity;

ItemStack hand = player.getCurrentEquippedItem();

int itemDamage = hand.getItemDamage();

if(player.getCurrentEquippedItem() != null)

if(hand.getItem() == SkyPvP.testBow)

{

if(player.inventory.hasItem(Items.arrow)){

player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);

 

player.inventory.addItemStackToInventory(new ItemStack(Items.bow, 1, (int) itemDamage));

System.out.println("Normal Bow");

}

 

}

else if(hand.getItem() == Items.bow)

{

if(player.inventory.hasItem(SkyPvP.fireArrow1)){

player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);

player.inventory.addItemStackToInventory(new ItemStack(SkyPvP.testBow, 1, (int) itemDamage));

System.out.println("Test Bow");

}

 

 

}

return null;

        }

    }

}

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.