Jump to content

[Forge 1.10] Block that clears player inventory


admiralmattbar

Recommended Posts

Hi All,

 

I'm trying to create a mod for use in Redstone puzzle maps where players can use a block that activates a door and clears their inventory. I am completely at a loss on how to do this. I've been looking throughout the internet and haven't found anything. If any of you have any resources on this I'd appreciate it.

Link to comment
Share on other sites

Hi All,

 

I'm trying to create a mod for use in Redstone puzzle maps where players can use a block that activates a door and clears their inventory. I am completely at a loss on how to do this. I've been looking throughout the internet and haven't found anything. If any of you have any resources on this I'd appreciate it.

Well first you need the a player variable, and once you have one call player.inventory.clear()

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

"Well first you need the a player variable"

 

Sorry, but I'm not sure how to do this. Does this involve messing with NBT commands?

No it does not how do you want the player to clear there inventory?

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

How do you want the player to interact with the block?

Right click it? Step on it?

 

There are method's in the Block class, and more, that will give you the player variable when he/she interacts with your block.

The methods for the mentioned interactions are

onBlockClicked

&

onEntityCollidedWithBlock

.

 

Be sure to cast the

Entity

given from the latter, to

Player

.

 

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Be sure to check types before casting.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.