mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-18 00:25:30 +01:00
Merge pull request #115 from iamceph/master
Add ability to get Block type from given position
This commit is contained in:
commit
73c53a9b17
@ -18,6 +18,7 @@ import net.minestom.server.instance.block.CustomBlock;
|
||||
import net.minestom.server.network.packet.server.play.ChunkDataPacket;
|
||||
import net.minestom.server.network.packet.server.play.UpdateLightPacket;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.MathUtils;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import net.minestom.server.utils.Position;
|
||||
|
@ -9,6 +9,7 @@ import net.minestom.server.data.Data;
|
||||
import net.minestom.server.data.SerializableData;
|
||||
import net.minestom.server.data.SerializableDataImpl;
|
||||
import net.minestom.server.entity.pathfinding.PFBlockDescription;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.block.CustomBlock;
|
||||
import net.minestom.server.instance.palette.PaletteStorage;
|
||||
import net.minestom.server.network.packet.server.play.ChunkDataPacket;
|
||||
|
@ -607,6 +607,28 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
unloadChunk(chunk);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets block from given position.
|
||||
*
|
||||
* @param position position to get from
|
||||
* @return Block at given position.
|
||||
*/
|
||||
public Block getBlock(BlockPosition position) {
|
||||
return getBlock(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Block type from given coordinates.
|
||||
*
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param z z coordinate
|
||||
* @return Block at given position.
|
||||
*/
|
||||
public Block getBlock(int x, int y, int z) {
|
||||
return Block.fromStateId(getBlockStateId(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the block state id at the given position.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user