Posted July 22, 20178 yr 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, 20178 yr by _Bedrockbreaker_ Added [Solved] Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
July 22, 20178 yr EntityPlayer#capabilities.isCreativeMode should tell you if the player is in creative for spectator mode.
July 22, 20178 yr EntityPlayer::isCreative EntityPlayer::isSpectator Or if you want to be more thorough: PlayerInteractionManager::getGameType
July 24, 20178 yr Author 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. Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
July 24, 20178 yr Author 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). Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
July 24, 20178 yr Author Yes, just realized that, zombie crashed the game. hehe. Now if I could check if the player is actually flying would be nice. Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
July 24, 20178 yr Author 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/
July 24, 20178 yr Author 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? Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
July 24, 20178 yr 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, 20178 yr by Jay Avery
July 25, 20178 yr Author Ahhhhh! Thank you for helping! I had actually never seen the two colon notation before, but your explanation was extremely helpful. Professional Hot Garbage Programmer. https://github.com/Bedrockbreaker/
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.