Search in sources :

Example 1 with AxisAlignedBB

use of net.minecraft.server.v1_14_R1.AxisAlignedBB in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method getNearbyItems.

@Override
public Stream<Item> getNearbyItems(Location location, int range, boolean onlyChunk, KeySet blacklisted, KeySet whitelisted) {
    World world = ((CraftWorld) location.getWorld()).getHandle();
    List<Entity> entityList = new ArrayList<>();
    if (onlyChunk) {
        Chunk chunk = ((CraftChunk) location.getChunk()).getHandle();
        for (int i = 0; i < chunk.entitySlices.length; i++) entityList.addAll(chunk.entitySlices[i]);
        entityList = entityList.stream().filter(entity -> entity instanceof EntityItem).collect(Collectors.toList());
    } else {
        AxisAlignedBB boundingBox = new AxisAlignedBB(location.getX() + range, location.getY() + range, location.getZ() + range, location.getX() - range, location.getY() - range, location.getZ() - range);
        entityList = world.getEntities(null, boundingBox, entity -> entity instanceof EntityItem);
    }
    return entityList.stream().map(entity -> (Item) entity.getBukkitEntity()).filter(item -> !blacklisted.contains(item.getItemStack()) && (whitelisted.isEmpty() || whitelisted.contains(item.getItemStack())));
}
Also used : AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) InventoryHolder(com.bgsoftware.wildchests.objects.inventory.InventoryHolder) DataInputStream(java.io.DataInputStream) AxisAlignedBB(net.minecraft.server.v1_16_R3.AxisAlignedBB) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Entity(net.minecraft.server.v1_16_R3.Entity) Item(org.bukkit.entity.Item) Inventory(org.bukkit.inventory.Inventory) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) ArrayList(java.util.ArrayList) Location(org.bukkit.Location) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) BigInteger(java.math.BigInteger) ChestType(com.bgsoftware.wildchests.api.objects.ChestType) KeySet(com.bgsoftware.wildchests.key.KeySet) Material(org.bukkit.Material) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) NBTTagList(net.minecraft.server.v1_16_R3.NBTTagList) TileEntityChest(net.minecraft.server.v1_16_R3.TileEntityChest) World(net.minecraft.server.v1_16_R3.World) HumanEntity(org.bukkit.entity.HumanEntity) EntityItem(net.minecraft.server.v1_16_R3.EntityItem) DataOutput(java.io.DataOutput) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) EntityHuman(net.minecraft.server.v1_16_R3.EntityHuman) BlockPosition(net.minecraft.server.v1_16_R3.BlockPosition) Collectors(java.util.stream.Collectors) Particle(org.bukkit.Particle) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) Base64(java.util.Base64) List(java.util.List) Stream(java.util.stream.Stream) NBTReadLimiter(net.minecraft.server.v1_16_R3.NBTReadLimiter) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) NBTCompressedStreamTools(net.minecraft.server.v1_16_R3.NBTCompressedStreamTools) Entity(net.minecraft.server.v1_16_R3.Entity) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) HumanEntity(org.bukkit.entity.HumanEntity) Item(org.bukkit.entity.Item) EntityItem(net.minecraft.server.v1_16_R3.EntityItem) ArrayList(java.util.ArrayList) World(net.minecraft.server.v1_16_R3.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) Chunk(net.minecraft.server.v1_16_R3.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) EntityItem(net.minecraft.server.v1_16_R3.EntityItem)

Example 2 with AxisAlignedBB

use of net.minecraft.server.v1_14_R1.AxisAlignedBB in project InteractionVisualizer by LOOHP.

the class V1_11 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_11_R1.BlockPosition blockpos = new net.minecraft.server.v1_11_R1.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    AxisAlignedBB box = world.getType(blockpos).d(world, blockpos);
    List<BoundingBox> boxes = new ArrayList<>(1);
    boxes.add(new BoundingBox(box.a + pos.getX(), box.b + pos.getY(), box.c + pos.getZ(), box.d + pos.getX(), box.e + pos.getY(), box.f + pos.getZ()));
    return boxes;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_11_R1.AxisAlignedBB) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) ArrayList(java.util.ArrayList) WorldServer(net.minecraft.server.v1_11_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld)

Example 3 with AxisAlignedBB

use of net.minecraft.server.v1_14_R1.AxisAlignedBB in project InteractionVisualizer by LOOHP.

the class V1_12 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_12_R1.BlockPosition blockpos = new net.minecraft.server.v1_12_R1.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    AxisAlignedBB box = world.getType(blockpos).d(world, blockpos);
    List<BoundingBox> boxes = new ArrayList<>(1);
    boxes.add(new BoundingBox(box.a + pos.getX(), box.b + pos.getY(), box.c + pos.getZ(), box.d + pos.getX(), box.e + pos.getY(), box.f + pos.getZ()));
    return boxes;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_12_R1.AxisAlignedBB) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) ArrayList(java.util.ArrayList) WorldServer(net.minecraft.server.v1_12_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 4 with AxisAlignedBB

use of net.minecraft.server.v1_14_R1.AxisAlignedBB in project MechanicsMain by WeaponMechanics.

the class v1_9_R2 method getHitBox.

@Override
public HitBox getHitBox(org.bukkit.entity.Entity entity) {
    if (entity.isInvulnerable() || !entity.getType().isAlive() || entity.isDead())
        return null;
    AxisAlignedBB aabb = ((CraftEntity) entity).getHandle().getBoundingBox();
    HitBox hitBox = new HitBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
    hitBox.setLivingEntity((LivingEntity) entity);
    if (entity instanceof ComplexLivingEntity && WeaponMechanics.getBasicConfigurations().getBool("Check_Accurate_Hitboxes", true)) {
        for (ComplexEntityPart entityPart : ((ComplexLivingEntity) entity).getParts()) {
            AxisAlignedBB boxPart = ((CraftEntity) entityPart).getHandle().getBoundingBox();
            hitBox.addVoxelShapePart(new HitBox(boxPart.a, boxPart.b, boxPart.c, boxPart.d, boxPart.e, boxPart.f));
        }
    }
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_9_R2.AxisAlignedBB) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) ComplexEntityPart(org.bukkit.entity.ComplexEntityPart) ComplexLivingEntity(org.bukkit.entity.ComplexLivingEntity)

Example 5 with AxisAlignedBB

use of net.minecraft.server.v1_14_R1.AxisAlignedBB in project MechanicsMain by WeaponMechanics.

the class v1_11_R1 method getHitBox.

@Override
public HitBox getHitBox(org.bukkit.entity.Entity entity) {
    if (entity.isInvulnerable() || !entity.getType().isAlive() || entity.isDead())
        return null;
    AxisAlignedBB aabb = ((CraftEntity) entity).getHandle().getBoundingBox();
    HitBox hitBox = new HitBox(aabb.a, aabb.b, aabb.c, aabb.d, aabb.e, aabb.f);
    hitBox.setLivingEntity((LivingEntity) entity);
    if (entity instanceof ComplexLivingEntity && WeaponMechanics.getBasicConfigurations().getBool("Check_Accurate_Hitboxes", true)) {
        for (ComplexEntityPart entityPart : ((ComplexLivingEntity) entity).getParts()) {
            AxisAlignedBB boxPart = ((CraftEntity) entityPart).getHandle().getBoundingBox();
            hitBox.addVoxelShapePart(new HitBox(boxPart.a, boxPart.b, boxPart.c, boxPart.d, boxPart.e, boxPart.f));
        }
    }
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_11_R1.AxisAlignedBB) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) ComplexEntityPart(org.bukkit.entity.ComplexEntityPart) ComplexLivingEntity(org.bukkit.entity.ComplexLivingEntity)

Aggregations

List (java.util.List)25 Entity (org.bukkit.entity.Entity)23 Iterator (java.util.Iterator)21 ArrayList (java.util.ArrayList)14 AxisAlignedBB (net.minecraft.server.v1_12_R1.AxisAlignedBB)14 AxisAlignedBB (net.minecraft.server.v1_10_R1.AxisAlignedBB)13 HitBox (me.deecaad.weaponmechanics.weapon.projectile.HitBox)12 AxisAlignedBB (net.minecraft.server.v1_11_R1.AxisAlignedBB)12 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)11 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)11 AxisAlignedBB (net.minecraft.server.v1_8_R3.AxisAlignedBB)9 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)8 LivingEntity (org.bukkit.entity.LivingEntity)8 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)7 AxisAlignedBB (net.minecraft.server.v1_16_R3.AxisAlignedBB)7 AxisAlignedBB (net.minecraft.server.v1_9_R2.AxisAlignedBB)7 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)6 BoundingBox (net.citizensnpcs.api.util.BoundingBox)5 Location (org.bukkit.Location)5 AxisAlignedBB (net.minecraft.server.v1_13_R2.AxisAlignedBB)4