_Bedrockbreaker_ Posted July 22, 2017 Posted July 22, 2017 (edited) 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 July 26, 2017 by _Bedrockbreaker_ Added [Solved] Quote Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
Silly511 Posted July 22, 2017 Posted July 22, 2017 EntityPlayer#capabilities.isCreativeMode should tell you if the player is in creative for spectator mode. Quote
V0idWa1k3r Posted July 22, 2017 Posted July 22, 2017 EntityPlayer::isCreative EntityPlayer::isSpectator Or if you want to be more thorough: PlayerInteractionManager::getGameType Quote
_Bedrockbreaker_ Posted July 24, 2017 Author Posted July 24, 2017 Silly511, its not showing anything with capabilities, other than has/getCapability, but that takes a weird argument, and V0idWa1k3r, It says target type of the expression must be a functional interface. Quote Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
_Bedrockbreaker_ Posted July 24, 2017 Author Posted July 24, 2017 I seem to have just fixed it with ((EntityPlayer) entityIn).isCreative() ( the original entity could be any entity when it touches the web-like block). Quote Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
_Bedrockbreaker_ Posted July 24, 2017 Author Posted July 24, 2017 Yes, just realized that, zombie crashed the game. hehe. Now if I could check if the player is actually flying would be nice. Quote Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
_Bedrockbreaker_ Posted July 24, 2017 Author Posted July 24, 2017 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? Quote Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
_Bedrockbreaker_ Posted July 24, 2017 Author Posted July 24, 2017 so if assign player by EntityPlayer player = (EntityPlayer) entityIn; //entityIn could be any entity, but its checked beforehand that it is a player And then use if (player::capabilites.isFlying) { //stuff } It should theoretically work? Quote Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
Jay Avery Posted July 24, 2017 Posted July 24, 2017 (edited) 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 July 24, 2017 by Jay Avery Quote
_Bedrockbreaker_ Posted July 25, 2017 Author Posted July 25, 2017 Ahhhhh! Thank you for helping! I had actually never seen the two colon notation before, but your explanation was extremely helpful. Quote Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
Recommended Posts
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.