Discussion in 'Plugin Development' started by Hotshot, Dec 28, 2011.
Is there any way to set a block so that a player can walk through it?
You could change the blocks to air for that player (still not sure if this will work)
player.sendBlockChange(location, Material.AIR, 0);
//EDIT: Or teleport the player to the other side of the wall as soon as he touches it.
Whats the event to see if the player is touching it?
//EDIT: I like the set to air idea though, I think I might go with that. Dont think theres any way to do this without client editing.
A pretty bad way i suppose, would be to use onPlayerMove, and each time check the blocks infront of them and if the blocks are not air, set there type to air. But save there data in a hashmap or something. That way you can replace them once the player has passed. Tbh i would put them in a hashmap and just use a bukkit scheduler to replace them, because i wouldnt know any other way.
The teleporting the player sounds a wee bit easier.
Also how do you get the location of where the players crosshairs are? I cant find anything in the java docs. getCompassTarget() sounds like it, but im pretty sure that its not it.
EDIT: Nvm, I found it. Its a method inherited from LivingEntity class. getTargetBlock()
I meant I didnt think there was a way to walk through walls without client editing.
Tricking the client into thinking the block would be air isn't enough. Even though the player is then able to walk into that block, but the server side noclip-check automatically teleports them back because the block is - in fact - still a solid one.
Teleporting would be a ton easier. If you want to stick to that solution, you'd have to do it the other way: Set the actual block to air, and send the block that was previously there to all other players. Then have fun with keeping it updated with new players joining, teleports, chunk unloads/loads and stuff
And the ultra-pr0 g4ng5ta way would be to hack into the server noclip check and take control over that, now have fun with that
Separate names with a comma.