Jump to content

[1.10.2] Starter Items // After eating get item


terraya

Recommended Posts

Hello Dear Community,

 

i got 2 questions,

 

how to make "Starter Items" , what i mean with "Starter Items" is that when a "new" player joins the server he get items i select.

 

another thing,

im doing a "Devil fruits" mod with many new sword/armors etc .. BUT well,

how 2 code an item and on "rightclick" i eat it or i use it and it will give me some new items.

 

so well "On Rightclick" ... but i cant find any function or any tut. for this kind of thing and as i know there is no item in Minecraft which does what i need :S

Link to comment
Share on other sites

how to make "Starter Items" , what i mean with "Starter Items" is that when a "new" player joins the server he get items i select.

There are two parts to this:

  • Storing whether a player has received the item
  • Giving the item to a player when they log in

 

To store per-player data, you can either use the

EntityPlayer.PERSISTED_NBT_TAG

sub-compound of

Entity#getEntityData

or the Capability System. The entity NBT should only be used to store simple data like a flag that's only set once; for anything more complex or frequently accessed you should use capabilities instead.

 

To do something when a player logs in, use

PlayerEvent.PlayerLoggedInEvent

.

 

I have an example of this using entity NBT here.

 

 

im doing a "Devil fruits" mod with many new sword/armors etc .. BUT well,

how 2 code an item and on "rightclick" i eat it or i use it and it will give me some new items.

 

ItemSoup

does this by overriding

Item#onItemUseFinish

to call the super method and then return an

ItemStack

of

Items.BOWL

, replacing the original

ItemStack

in the player's inventory.

 

If you need to give the player multiple items or your food stacks, simply add the items to their inventory from this method instead of returning a new

ItemStack

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

so i want to make him get "Multiple Items" ,

 

this works so far:

 

	@Override
    public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
    {
        super.onItemUseFinish(stack, worldIn, entityLiving);
        return new ItemStack(Items.BOW);      
    }

 

but what do you mean by " this method instead of returning a new ItemStack" , everytime i remove "return" it just show me an error up -_-

 

 

Link to comment
Share on other sites

so i want to make him get "Multiple Items" ,

 

this works so far:

 

	@Override
    public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
    {
        super.onItemUseFinish(stack, worldIn, entityLiving);
        return new ItemStack(Items.BOW);      
    }

 

but what do you mean by " this method instead of returning a new ItemStack" , everytime i remove "return" it just show me an error up -_-

if (entityLiving instanceof EntityPlayer) {
     ((EntityPlayer) entityLiving).inventory.addItemStackToInventory(new ItemStack(...);
}

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.

Link to comment
Share on other sites

so i want to make him get "Multiple Items" ,

 

this works so far:

 

	@Override
    public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
    {
        super.onItemUseFinish(stack, worldIn, entityLiving);
        return new ItemStack(Items.BOW);      
    }

 

but what do you mean by " this method instead of returning a new ItemStack" , everytime i remove "return" it just show me an error up -_-

 

Add the item(s) to the player's inventory, then return the

ItemStack

argument instead of creating and returning a new

ItemStack

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.