Jump to content

Recommended Posts

Posted

So my goal is to make a item that can random into other item that I made when player rightclick on it

So I create class (which is item) that have random generator of with list of item (it also other item that I made) I want it to become by using 

int rand = generator.nextInt

then I try to code when player rightclick on item it will start doing random then pick a item from "rand" then put in player inventory

public void onItemRightClick(World worldIn, PlayerEntity player, Hand handIn)

but after this code I stuck because I don't know which code or how should I use 

I try using player.addItemtoInventory or dropItem which seem to require ItemStack in () instead, so I try create new class and put same rand code in it, but it seem to can only pick one of item instead of full of item list to do random

so I have no idea anymore what I supported to do

I need really advice on this

ps. my reference also 1.12.2 version so I encounter lot of problem even if try to copy it as well

Posted (edited)

Pretty easy, actually. You've got the random generation down, don't change it, as for the PlayerEntity#dropItem method requiring an ItemStack, if you took literally 1 second to look at ItemStack, you'd see that it has a constructor that takes in an Item.

  

19 minutes ago, Darkrider000 said:

ps. my reference also 1.12.2 version so I encounter lot of problem even if try to copy it as well

 

If you can solve a crossword puzzle, you can translate 1.12 item code to 1.15, barely anything had changed (excluding metadata, of course).

Edited by Novârch

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

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.