Jump to content

[1.12] [Solved] Get the players gamemode


_Bedrockbreaker_

Recommended Posts

Since 1.12, (at least) the entityPlayerMP.theItem...blah blah... Something or other.... Seems to have been removed to test the players gamemode. So how can I do this in 1.12? Trying to make a cobweb-like object, but with a lesser effect. Also needs to not slow down players in creative. The slow down works fine though.

Edited by _Bedrockbreaker_
Added [Solved]

Professional Hot Garbage Programmer.

https://github.com/Bedrockbreaker/

Link to comment
Share on other sites

I am sorry, but I can't seem to find anything on EntityPlayer::capabilities at all. Nothing is showing up if I hit ctrl+space and if I manually type it out, it says "The target type of this expression must be a functional interface". Would you care to enlighten me on what and how to use the two colons, and why capabilities is not showing up?

Professional Hot Garbage Programmer.

https://github.com/Bedrockbreaker/

Link to comment
Share on other sites

No, you just use a dot in place of the :: or #, like this: player.capabilities.isFlying.

 

It's just that when talking about methods and fields, it's useful to be able to distinguish at a glance whether we're talking about something static where you actually call it on the class (like EntityPlayer.staticVariable), or about something which must be called on an instance (like player.capabilities).

 

Because an instance of something is (usually) stored in a variable, and a variable could have any name, it's potentially ambiguous to invent a variable name without specifying what class the object is an instance of. I could say "you need to use variable.capabilities", and you might rightly ask "but what is variable?". Or I could say "you need to use EntityPlayer.capabilities", and then you might come back and say "my IDE tells me I can't access a non-static field statically", because you'd get errors if you typed in exactly that. So the alternative to these two possibly-confusing approaches is to use the class name (which makes it clear what kind of object we're using) and use a hash or double-colon in place of the dot (which represents the fact that it should be called on an instance of the class).

Edited by Jay Avery
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.