Java Reference
In-Depth Information
public void stuck(Player player) {
Location loc = player.getLocation();
int playerX = ( int ) loc.getX();
int playerY = ( int ) loc.getY();
int playerZ = ( int ) loc.getZ();
loc.setX(playerX + 0.5); loc.setY(playerY); loc.setZ(playerZ + 0.5);
player.teleportTo(loc);
int[][] offsets = {
//x, y, z
{0, -1, 0},
{0, 2, 0},
{1, 0, 0},
{1, 1, 0},
{-1, 0, 0},
{-1, 1, 0},
{0, 0, 1},
{0, 1, 1},
{0, 0, -1},
{0, 1, -1},
};
for ( int i = 0; i < offsets.length; i++) {
int x = offsets[i][0];
int y = offsets[i][1];
int z = offsets[i][2];
setBlockAt( new Location(x+playerX, y+playerY, z+playerZ),
BlockType.Stone);
}
}
}
Compile and deploy the Stuck plugin and give it a try. What happens if the
player is standing on the ground or up in the air? What does it look like from
the player's point of view, inside the blocks?
Try This Yourself
In the Stuck plugin, we've encased a player in the minimum number of blocks
needed to enclose the player. But from the outside, it makes kind of a weird-
looking shape.
So here's what you need to do: add extra blocks so that the player is encased
in a solid rectangle, measuring three blocks wide, three blocks deep, and four
blocks tall. Add the extra blocks to the list of block offsets, then recompile
and deploy and see if you've put the extra blocks in the right places. From
the outside, it should look like a solid, rectangular block.
 
 
Search WWH ::




Custom Search