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

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

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.

  • Author

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

 

 

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.

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.

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.