Search in sources :

Example 1 with net.minecraft.server.v1_15_R1

use of net.minecraft.server.v1_15_R1 in project solinia3-core by mixxit.

the class EntityUtils method DistanceOverAggroLimit.

public static double DistanceOverAggroLimit(LivingEntity attacker, LivingEntity aggroCheckEntity) {
    double distance = attacker.getLocation().distance(aggroCheckEntity.getLocation());
    if (distance > 100D)
        return 100D - distance;
    net.minecraft.server.v1_15_R1.EntityLiving entity = ((org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity) aggroCheckEntity).getHandle();
    if (entity == null)
        return 0D;
    if (entity.getAttributeInstance(GenericAttributes.FOLLOW_RANGE) == null)
        return 0D;
    double distanceLimit = entity.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).getValue();
    if (distance > distanceLimit)
        return distance - distanceLimit;
    return 0D;
}
Also used : EntityLiving(net.minecraft.server.v1_15_R1.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity)

Example 2 with net.minecraft.server.v1_15_R1

use of net.minecraft.server.v1_15_R1 in project solinia3-core by mixxit.

the class SpecialEffectUtils method playLightningStrike.

public static void playLightningStrike(Entity entity) {
    try {
        Location loc = entity.getLocation();
        net.minecraft.server.v1_15_R1.WorldServer world = ((CraftWorld) loc.getWorld()).getHandle();
        EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ(), true, true);
        world.strikeLightning(lightning);
        new CraftLightningStrike(world.getServer(), lightning);
        return;
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : EntityLightning(net.minecraft.server.v1_15_R1.EntityLightning) CraftLightningStrike(org.bukkit.craftbukkit.v1_15_R1.entity.CraftLightningStrike) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld) Location(org.bukkit.Location)

Example 3 with net.minecraft.server.v1_15_R1

use of net.minecraft.server.v1_15_R1 in project solinia3-core by mixxit.

the class ItemStackUtils method IsDisplayItem.

public static boolean IsDisplayItem(ItemStack itemStack) {
    // Also check nbttag
    if (itemStack == null)
        return false;
    boolean isDisplayItem = itemStack.getItemMeta().getDisplayName().startsWith("Display Item: ");
    if (isDisplayItem)
        return isDisplayItem;
    // Classic method
    net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
    String isMerchant = compound.getString("merchant");
    return Boolean.parseBoolean(isMerchant);
}
Also used : NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound)

Example 4 with net.minecraft.server.v1_15_R1

use of net.minecraft.server.v1_15_R1 in project InteractionVisualizer by LOOHP.

the class V1_15 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_15_R1.BlockPosition blockpos = new net.minecraft.server.v1_15_R1.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 : CraftMagicNumbers(org.bukkit.craftbukkit.v1_15_R1.util.CraftMagicNumbers) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) Item(org.bukkit.entity.Item) 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) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) InteractionVisualizer(com.loohp.interactionvisualizer.InteractionVisualizer) EntityItem(net.minecraft.server.v1_15_R1.EntityItem) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld) Entity(org.bukkit.entity.Entity) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) ItemSlot(com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) PacketType(com.comphenix.protocol.PacketType) VoxelShape(net.minecraft.server.v1_15_R1.VoxelShape) CraftItem(org.bukkit.craftbukkit.v1_15_R1.entity.CraftItem) Collectors(java.util.stream.Collectors) ItemStack(org.bukkit.inventory.ItemStack) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) PacketContainer(com.comphenix.protocol.events.PacketContainer) List(java.util.List) CraftChunk(org.bukkit.craftbukkit.v1_15_R1.CraftChunk) WorldServer(net.minecraft.server.v1_15_R1.WorldServer) VoxelShape(net.minecraft.server.v1_15_R1.VoxelShape) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) WorldServer(net.minecraft.server.v1_15_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Example 5 with net.minecraft.server.v1_15_R1

use of net.minecraft.server.v1_15_R1 in project Atlas by funkemunky.

the class BlockBox1_15_R1 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
    final net.minecraft.server.v1_15_R1.World world = ((org.bukkit.craftbukkit.v1_15_R1.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_15_R1.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_15_R1.Block vblock = iblockData.getBlock();
    BlockPosition blockPos = new BlockPosition(x, y, z);
    VoxelShape shape = vblock.a(iblockData, world, blockPos, VoxelShapeCollision.a());
    List<AxisAlignedBB> boxes = shape.d();
    if (boxes.size() == 0) {
        return BlockData.getData(block.getType()).getBox(block, ProtocolVersion.getGameVersion());
    } else if (boxes.size() == 1) {
        AxisAlignedBB box = boxes.get(0);
        return new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
    } else {
        ComplexCollisionBox complexBox = new ComplexCollisionBox();
        for (AxisAlignedBB box : boxes) {
            complexBox.add(new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ));
        }
        return complexBox;
    }
}
Also used : ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) CraftBlock(org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock) World(net.minecraft.server.v1_15_R1.World) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_15_R1(net.minecraft.server.v1_15_R1) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Aggregations

NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)9 CraftItemStack (org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack)6 net.minecraft.server.v1_15_R1 (net.minecraft.server.v1_15_R1)5 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)4 CraftWorld (org.bukkit.craftbukkit.v1_15_R1.CraftWorld)3 CraftEntity (org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity)3 Player (org.bukkit.entity.Player)3 UUID (java.util.UUID)2 Nullable (javax.annotation.Nullable)2 EntityLiving (net.minecraft.server.v1_15_R1.EntityLiving)2 EntityPlayer (net.minecraft.server.v1_15_R1.EntityPlayer)2 Location (org.bukkit.Location)2 Material (org.bukkit.Material)2 ItemStack (org.bukkit.inventory.ItemStack)2 ItemMeta (org.bukkit.inventory.meta.ItemMeta)2 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)1 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)1 PacketType (com.comphenix.protocol.PacketType)1 PacketContainer (com.comphenix.protocol.events.PacketContainer)1 ItemSlot (com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot)1