Search in sources :

Example 11 with net.minecraft.server.v1_14_R1

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

the class BlockBox1_14_R1 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(Block block) {
    final net.minecraft.server.v1_14_R1.World world = ((org.bukkit.craftbukkit.v1_14_R1.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_14_R1.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_14_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_14_R1.block.CraftBlock) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_14_R1(net.minecraft.server.v1_14_R1)

Example 12 with net.minecraft.server.v1_14_R1

use of net.minecraft.server.v1_14_R1 in project SimplePets by brainsynder-Dev.

the class EntityControllerPet method repeatTask.

@Override
public void repeatTask() {
    super.repeatTask();
    if (!this.isInvisible())
        this.setInvisible(true);
    if (!isSilent())
        this.setSilent(true);
    if (getPet() != null)
        if (isBaby())
            setBaby((getPet().getPetType() instanceof ShulkerDefault));
    Player p = getPet().getOwner();
    if (this.displayEntity != null) {
        if (this.displayEntity.isValid()) {
            net.minecraft.server.v1_14_R1.Entity entity = ((CraftEntity) displayEntity).getHandle();
            if (!displayEntity.getPassengers().isEmpty()) {
                if (displayRider == null)
                    displayRider = displayEntity.getPassengers().get(0);
                entity = ((CraftEntity) displayRider).getHandle();
            }
            updateName(entity);
            reloadLocation();
            if (!canIgnoreVanish()) {
                if (((CraftPlayer) p).getHandle().isInvisible() != entity.isInvisible())
                    entity.setInvisible(!entity.isInvisible());
            }
        }
    }
    PetDefault type = getVisibleEntity().getPet().getPetType();
    double current = getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
    double rideSpeed = type.getRideSpeed();
    double walkSpeed = type.getSpeed();
    if (isOwnerRiding()) {
        if (current != rideSpeed)
            getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(rideSpeed);
    } else {
        if (current != walkSpeed)
            getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(walkSpeed);
    }
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) net.minecraft.server.v1_14_R1(net.minecraft.server.v1_14_R1) PetDefault(simplepets.brainsynder.pet.PetDefault) ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) CraftEntity(org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer)

Example 13 with net.minecraft.server.v1_14_R1

use of net.minecraft.server.v1_14_R1 in project SilkSpawners by timbru31.

the class NMSHandler method getVanillaEggNBTEntityID.

@Override
public String getVanillaEggNBTEntityID(final ItemStack item) {
    net.minecraft.server.v1_14_R1.ItemStack itemStack = null;
    final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    NBTTagCompound tag = itemStack.getTag();
    if (tag == null || !tag.hasKey("EntityTag")) {
        final MinecraftKey vanillaKey = IRegistry.ITEM.getKey(itemStack.getItem());
        if (vanillaKey != null) {
            return vanillaKey.getKey().replace("minecraft:", "").replace("_spawn_egg", "");
        }
    } else {
        tag = tag.getCompound("EntityTag");
        if (tag.hasKey("id")) {
            return tag.getString("id").replace("minecraft:", "");
        }
    }
    return null;
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_14_R1.NBTTagCompound) MinecraftKey(net.minecraft.server.v1_14_R1.MinecraftKey)

Aggregations

NBTTagCompound (net.minecraft.server.v1_14_R1.NBTTagCompound)6 CraftItemStack (org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack)5 net.minecraft.server.v1_14_R1 (net.minecraft.server.v1_14_R1)4 CraftEntity (org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity)3 CraftPlayer (org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer)3 Player (org.bukkit.entity.Player)3 Nullable (javax.annotation.Nullable)2 Material (org.bukkit.Material)2 Block (org.bukkit.block.Block)2 CraftChunk (org.bukkit.craftbukkit.v1_14_R1.CraftChunk)2 ItemStack (org.bukkit.inventory.ItemStack)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 InteractionVisualizer (com.loohp.interactionvisualizer.InteractionVisualizer)1 BlockPosition (com.loohp.interactionvisualizer.objectholders.BlockPosition)1 BoundingBox (com.loohp.interactionvisualizer.objectholders.BoundingBox)1 ChunkPosition (com.loohp.interactionvisualizer.objectholders.ChunkPosition)1