Merge pull request #115 from iamceph/master

Add ability to get Block type from given position
This commit is contained in:
TheMode 2021-01-26 10:04:29 +01:00 committed by GitHub
commit 73c53a9b17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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.
*