Search in sources :

Example 6 with BoundingBox

use of com.loohp.interactionvisualizer.objectholders.BoundingBox in project InteractionVisualizer by LOOHP.

the class V1_16_2 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_16_R2.BlockPosition blockpos = new net.minecraft.server.v1_16_R2.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    VoxelShape shape = world.getType(blockpos).getShape(world, blockpos);
    return shape.d().stream().map(each -> new BoundingBox(each.minX + pos.getX(), each.minY + pos.getY(), each.minZ + pos.getZ(), each.maxX + pos.getX(), each.maxY + pos.getY(), each.maxZ + pos.getZ())).collect(Collectors.toList());
}
Also used : BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) Item(org.bukkit.entity.Item) WorldServer(net.minecraft.server.v1_16_R2.WorldServer) EnumItemSlot(net.minecraft.server.v1_16_R2.EnumItemSlot) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) World(org.bukkit.World) CraftMagicNumbers(org.bukkit.craftbukkit.v1_16_R2.util.CraftMagicNumbers) WrappedIterable(com.loohp.interactionvisualizer.objectholders.WrappedIterable) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) PacketPlayOutEntityEquipment(net.minecraft.server.v1_16_R2.PacketPlayOutEntityEquipment) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) Entity(org.bukkit.entity.Entity) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) CraftChunk(org.bukkit.craftbukkit.v1_16_R2.CraftChunk) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) Collectors(java.util.stream.Collectors) Pair(com.mojang.datafixers.util.Pair) ItemStack(org.bukkit.inventory.ItemStack) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld) PacketContainer(com.comphenix.protocol.events.PacketContainer) List(java.util.List) EntityItem(net.minecraft.server.v1_16_R2.EntityItem) CraftItem(org.bukkit.craftbukkit.v1_16_R2.entity.CraftItem) VoxelShape(net.minecraft.server.v1_16_R2.VoxelShape) VoxelShape(net.minecraft.server.v1_16_R2.VoxelShape) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) WorldServer(net.minecraft.server.v1_16_R2.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 7 with BoundingBox

use of com.loohp.interactionvisualizer.objectholders.BoundingBox in project InteractionVisualizer by LOOHP.

the class V1_16_4 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_16_R3.BlockPosition blockpos = new net.minecraft.server.v1_16_R3.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    VoxelShape shape = world.getType(blockpos).getShape(world, blockpos);
    return shape.d().stream().map(each -> new BoundingBox(each.minX + pos.getX(), each.minY + pos.getY(), each.minZ + pos.getZ(), each.maxX + pos.getX(), each.maxY + pos.getY(), each.maxZ + pos.getZ())).collect(Collectors.toList());
}
Also used : BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) Item(org.bukkit.entity.Item) EnumItemSlot(net.minecraft.server.v1_16_R3.EnumItemSlot) ArrayList(java.util.ArrayList) PacketPlayOutEntityEquipment(net.minecraft.server.v1_16_R3.PacketPlayOutEntityEquipment) Block(org.bukkit.block.Block) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) World(org.bukkit.World) WrappedIterable(com.loohp.interactionvisualizer.objectholders.WrappedIterable) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) EntityItem(net.minecraft.server.v1_16_R3.EntityItem) Entity(org.bukkit.entity.Entity) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) VoxelShape(net.minecraft.server.v1_16_R3.VoxelShape) CraftItem(org.bukkit.craftbukkit.v1_16_R3.entity.CraftItem) Collectors(java.util.stream.Collectors) Pair(com.mojang.datafixers.util.Pair) ItemStack(org.bukkit.inventory.ItemStack) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) PacketContainer(com.comphenix.protocol.events.PacketContainer) List(java.util.List) CraftMagicNumbers(org.bukkit.craftbukkit.v1_16_R3.util.CraftMagicNumbers) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) VoxelShape(net.minecraft.server.v1_16_R3.VoxelShape) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 8 with BoundingBox

use of com.loohp.interactionvisualizer.objectholders.BoundingBox in project InteractionVisualizer by LOOHP.

the class V1_17 method getBoundingBoxes.

@SuppressWarnings("unchecked")
public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.core.BlockPosition blockpos = new net.minecraft.core.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    try {
        VoxelShape shape = (VoxelShape) blockDataGetShape.invoke(worldServerGetType.invoke(blockpos), world, blockpos);
        return ((List<AxisAlignedBB>) voxelShapeGetAABBList.invoke(shape)).stream().map(each -> new BoundingBox(each.a + pos.getX(), each.b + pos.getY(), each.c + pos.getZ(), each.d + pos.getX(), each.e + pos.getY(), each.f + pos.getZ())).collect(Collectors.toList());
    } catch (Exception e) {
        List<BoundingBox> boxes = new ArrayList<>();
        boxes.add(BoundingBox.of(pos.getBlock()));
        return boxes;
    }
}
Also used : BlockData(net.minecraft.world.level.block.state.BlockBase.BlockData) WorldServer(net.minecraft.server.level.WorldServer) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) IBlockAccess(net.minecraft.world.level.IBlockAccess) Item(org.bukkit.entity.Item) PacketPlayOutEntityDestroy(net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy) PacketPlayOutEntityEquipment(net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) Chunk(net.minecraft.world.level.chunk.Chunk) CraftItem(org.bukkit.craftbukkit.v1_17_R1.entity.CraftItem) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) World(org.bukkit.World) Map(java.util.Map) WrappedIterable(com.loohp.interactionvisualizer.objectholders.WrappedIterable) Method(java.lang.reflect.Method) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CraftChunk(org.bukkit.craftbukkit.v1_17_R1.CraftChunk) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) EntityItem(net.minecraft.world.entity.item.EntityItem) LevelEntityGetter(net.minecraft.world.level.entity.LevelEntityGetter) CraftMagicNumbers(org.bukkit.craftbukkit.v1_17_R1.util.CraftMagicNumbers) InteractionVisualizer(com.loohp.interactionvisualizer.InteractionVisualizer) Entity(org.bukkit.entity.Entity) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) AxisAlignedBB(net.minecraft.world.phys.AxisAlignedBB) PacketType(com.comphenix.protocol.PacketType) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) Pair(com.mojang.datafixers.util.Pair) ItemStack(org.bukkit.inventory.ItemStack) InvocationTargetException(java.lang.reflect.InvocationTargetException) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) PacketContainer(com.comphenix.protocol.events.PacketContainer) List(java.util.List) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) EnumItemSlot(net.minecraft.world.entity.EnumItemSlot) CraftItemStack(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) WorldServer(net.minecraft.server.level.WorldServer) InvocationTargetException(java.lang.reflect.InvocationTargetException) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) ArrayList(java.util.ArrayList) List(java.util.List) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 9 with BoundingBox

use of com.loohp.interactionvisualizer.objectholders.BoundingBox in project InteractionVisualizer by LOOHP.

the class V1_18 method getBoundingBoxes.

@SuppressWarnings("unchecked")
public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.core.BlockPosition blockpos = new net.minecraft.core.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    VoxelShape shape = world.a_(blockpos).j(world, blockpos);
    try {
        return ((List<AxisAlignedBB>) voxelShapeGetAABBList.invoke(shape)).stream().map(each -> new BoundingBox(each.a + pos.getX(), each.b + pos.getY(), each.c + pos.getZ(), each.d + pos.getX(), each.e + pos.getY(), each.f + pos.getZ())).collect(Collectors.toList());
    } catch (Exception e) {
        List<BoundingBox> boxes = new ArrayList<>();
        boxes.add(BoundingBox.of(pos.getBlock()));
        return boxes;
    }
}
Also used : WorldServer(net.minecraft.server.level.WorldServer) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) Item(org.bukkit.entity.Item) CraftItemStack(org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack) PacketPlayOutEntityDestroy(net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy) PacketPlayOutEntityEquipment(net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) CraftMagicNumbers(org.bukkit.craftbukkit.v1_18_R1.util.CraftMagicNumbers) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) World(org.bukkit.World) WrappedIterable(com.loohp.interactionvisualizer.objectholders.WrappedIterable) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld) Method(java.lang.reflect.Method) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) CraftChunk(org.bukkit.craftbukkit.v1_18_R1.CraftChunk) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) EntityItem(net.minecraft.world.entity.item.EntityItem) InteractionVisualizer(com.loohp.interactionvisualizer.InteractionVisualizer) Entity(org.bukkit.entity.Entity) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) AxisAlignedBB(net.minecraft.world.phys.AxisAlignedBB) PacketType(com.comphenix.protocol.PacketType) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) Pair(com.mojang.datafixers.util.Pair) ItemStack(org.bukkit.inventory.ItemStack) InvocationTargetException(java.lang.reflect.InvocationTargetException) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) PacketContainer(com.comphenix.protocol.events.PacketContainer) List(java.util.List) PersistentEntitySectionManager(net.minecraft.world.level.entity.PersistentEntitySectionManager) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) Collections(java.util.Collections) EnumItemSlot(net.minecraft.world.entity.EnumItemSlot) CraftItem(org.bukkit.craftbukkit.v1_18_R1.entity.CraftItem) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) WorldServer(net.minecraft.server.level.WorldServer) InvocationTargetException(java.lang.reflect.InvocationTargetException) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) ArrayList(java.util.ArrayList) List(java.util.List) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 10 with BoundingBox

use of com.loohp.interactionvisualizer.objectholders.BoundingBox in project InteractionVisualizer by LOOHP.

the class V1_18_2 method getBoundingBoxes.

@SuppressWarnings("unchecked")
public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.core.BlockPosition blockpos = new net.minecraft.core.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    VoxelShape shape = world.a_(blockpos).j(world, blockpos);
    try {
        return ((List<AxisAlignedBB>) voxelShapeGetAABBList.invoke(shape)).stream().map(each -> new BoundingBox(each.a + pos.getX(), each.b + pos.getY(), each.c + pos.getZ(), each.d + pos.getX(), each.e + pos.getY(), each.f + pos.getZ())).collect(Collectors.toList());
    } catch (Exception e) {
        List<BoundingBox> boxes = new ArrayList<>();
        boxes.add(BoundingBox.of(pos.getBlock()));
        return boxes;
    }
}
Also used : WorldServer(net.minecraft.server.level.WorldServer) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) Item(org.bukkit.entity.Item) PacketPlayOutEntityDestroy(net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy) PacketPlayOutEntityEquipment(net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_18_R2.CraftChunk) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) World(org.bukkit.World) WrappedIterable(com.loohp.interactionvisualizer.objectholders.WrappedIterable) Method(java.lang.reflect.Method) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) EntityItem(net.minecraft.world.entity.item.EntityItem) InteractionVisualizer(com.loohp.interactionvisualizer.InteractionVisualizer) Entity(org.bukkit.entity.Entity) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) CraftItem(org.bukkit.craftbukkit.v1_18_R2.entity.CraftItem) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) AxisAlignedBB(net.minecraft.world.phys.AxisAlignedBB) PacketType(com.comphenix.protocol.PacketType) Collectors(java.util.stream.Collectors) Pair(com.mojang.datafixers.util.Pair) ItemStack(org.bukkit.inventory.ItemStack) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) PacketContainer(com.comphenix.protocol.events.PacketContainer) CraftMagicNumbers(org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers) List(java.util.List) CraftItemStack(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) EnumItemSlot(net.minecraft.world.entity.EnumItemSlot) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) WorldServer(net.minecraft.server.level.WorldServer) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) ArrayList(java.util.ArrayList) List(java.util.List) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld)

Aggregations

BoundingBox (com.loohp.interactionvisualizer.objectholders.BoundingBox)14 BlockPosition (com.loohp.interactionvisualizer.objectholders.BlockPosition)13 PacketContainer (com.comphenix.protocol.events.PacketContainer)11 List (java.util.List)11 Material (org.bukkit.Material)11 World (org.bukkit.World)11 ItemStack (org.bukkit.inventory.ItemStack)11 ChunkPosition (com.loohp.interactionvisualizer.objectholders.ChunkPosition)10 NMSTileEntitySet (com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet)10 TileEntity (com.loohp.interactionvisualizer.objectholders.TileEntity)10 TileEntityType (com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType)10 ValuePairs (com.loohp.interactionvisualizer.objectholders.ValuePairs)10 WrappedIterable (com.loohp.interactionvisualizer.objectholders.WrappedIterable)10 Collectors (java.util.stream.Collectors)10 Block (org.bukkit.block.Block)10 Entity (org.bukkit.entity.Entity)10 Item (org.bukkit.entity.Item)10 EquipmentSlot (org.bukkit.inventory.EquipmentSlot)10 ArrayList (java.util.ArrayList)9 PacketType (com.comphenix.protocol.PacketType)7