Search in sources :

Example 1 with net.minecraft.server.v1_14_R1

use of net.minecraft.server.v1_14_R1 in project Ublisk by Derkades.

the class Item method getNBT.

public NBTTagCompound getNBT() {
    final net.minecraft.server.v1_14_R1.ItemStack nms = CraftItemStack.asNMSCopy(this.item);
    final NBTTagCompound compound = nms.getTag();
    if (compound == null) {
        return new NBTTagCompound();
    } else {
        return compound;
    }
}
Also used : NBTTagCompound(net.minecraft.server.v1_14_R1.NBTTagCompound)

Example 2 with net.minecraft.server.v1_14_R1

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

the class V1_14 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_14_R1.BlockPosition blockpos = new net.minecraft.server.v1_14_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 : BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) VoxelShape(net.minecraft.server.v1_14_R1.VoxelShape) Item(org.bukkit.entity.Item) CraftItem(org.bukkit.craftbukkit.v1_14_R1.entity.CraftItem) EntityItem(net.minecraft.server.v1_14_R1.EntityItem) CraftWorld(org.bukkit.craftbukkit.v1_14_R1.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_14_R1.CraftChunk) Block(org.bukkit.block.Block) CraftMagicNumbers(org.bukkit.craftbukkit.v1_14_R1.util.CraftMagicNumbers) 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) WorldServer(net.minecraft.server.v1_14_R1.WorldServer) InteractionVisualizer(com.loohp.interactionvisualizer.InteractionVisualizer) 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) 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) VoxelShape(net.minecraft.server.v1_14_R1.VoxelShape) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) WorldServer(net.minecraft.server.v1_14_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_14_R1.CraftWorld)

Example 3 with net.minecraft.server.v1_14_R1

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

the class Block_1_14_R1 method getMultiBlockMaskPacket.

private PacketPlayOutMultiBlockChange getMultiBlockMaskPacket(List<Block> blocks, @Nullable IBlockData mask) {
    net.minecraft.server.v1_14_R1.Chunk chunk = ((CraftChunk) blocks.get(0).getChunk()).getHandle();
    // Setup default information
    PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(0, new short[0], chunk);
    PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] changes = new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[blocks.size()];
    for (int i = 0; i < blocks.size(); i++) {
        Block block = blocks.get(i);
        // Where the block is relative to the chunk it is in
        int x = block.getX() & 0xF;
        int y = block.getY();
        int z = block.getZ() & 0xF;
        // Setting the (x, y, z) location into VarInt format
        short location = (short) (x << 12 | y | z << 8);
        // If mask is null, then undo the mask. Otherwise set the mask
        if (mask == null) {
            changes[i] = packet.new MultiBlockChangeInfo(location, chunk);
        } else {
            changes[i] = packet.new MultiBlockChangeInfo(location, mask);
        }
    }
    ReflectionUtil.setField(multiBlockChangeB, packet, changes);
    return packet;
}
Also used : PacketPlayOutMultiBlockChange(net.minecraft.server.v1_14_R1.PacketPlayOutMultiBlockChange) Block(org.bukkit.block.Block) CraftChunk(org.bukkit.craftbukkit.v1_14_R1.CraftChunk)

Example 4 with net.minecraft.server.v1_14_R1

use of net.minecraft.server.v1_14_R1 in project Citizens2 by CitizensDev.

the class NMSImpl method getTargetNavigator.

private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, final Function<NavigationAbstract, Boolean> function) {
    net.minecraft.server.v1_14_R1.Entity raw = getHandle(entity);
    raw.onGround = true;
    // not sure of a better way around this - if onGround is false, then
    // navigation won't execute, and calling entity.move doesn't
    // entirely fix the problem.
    final NavigationAbstract navigation = NMSImpl.getNavigation(entity);
    final float oldWater = raw instanceof EntityPlayer ? ((EntityHumanNPC) raw).a(PathType.WATER) : ((EntityInsentient) raw).a(PathType.WATER);
    if (params.avoidWater() && oldWater >= 0) {
        if (raw instanceof EntityPlayer) {
            ((EntityHumanNPC) raw).a(PathType.WATER, oldWater + 1F);
        } else {
            ((EntityInsentient) raw).a(PathType.WATER, oldWater + 1F);
        }
    }
    return new MCNavigator() {

        float lastSpeed;

        CancelReason reason;

        @Override
        public CancelReason getCancelReason() {
            return reason;
        }

        @Override
        public Iterable<Vector> getPath() {
            return new NavigationIterable(navigation);
        }

        @Override
        public void stop() {
            if (params.debug() && navigation.l() != null) {
                for (Player player : Bukkit.getOnlinePlayers()) {
                    for (int i = 0; i < navigation.l().e(); i++) {
                        PathPoint pp = navigation.l().a(i);
                        org.bukkit.block.Block block = new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()).getBlock();
                        player.sendBlockChange(block.getLocation(), block.getBlockData());
                    }
                }
            }
            if (oldWater >= 0) {
                if (raw instanceof EntityPlayer) {
                    ((EntityHumanNPC) raw).a(PathType.WATER, oldWater);
                } else {
                    ((EntityInsentient) raw).a(PathType.WATER, oldWater);
                }
            }
            stopNavigation(navigation);
        }

        @Override
        public boolean update() {
            if (params.speed() != lastSpeed) {
                if (Messaging.isDebugging() && lastSpeed > 0) {
                    Messaging.debug("Repathfinding " + ((NPCHolder) entity).getNPC().getId() + " due to speed change");
                }
                Entity handle = getHandle(entity);
                EntitySize size = null;
                try {
                    size = (EntitySize) SIZE_FIELD_GETTER.invoke(handle);
                    if (handle instanceof EntityHorse) {
                        SIZE_FIELD_SETTER.invoke(handle, new EntitySize(Math.min(0.99F, size.width), size.height, false));
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
                if (!function.apply(navigation)) {
                    reason = CancelReason.STUCK;
                }
                try {
                    SIZE_FIELD_SETTER.invoke(handle, size);
                } catch (Throwable e) {
                    e.printStackTrace();
                // minecraft requires that an entity fit onto both blocks if width >= 1f, but we'd prefer to
                // make it just fit on 1 so hack around it a bit.
                }
                lastSpeed = params.speed();
            }
            if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
                BlockData data = Material.DANDELION.createBlockData();
                for (Player player : Bukkit.getOnlinePlayers()) {
                    for (int i = 0; i < navigation.l().e(); i++) {
                        PathPoint pp = navigation.l().a(i);
                        player.sendBlockChange(new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()), data);
                    }
                }
            }
            navigation.a(params.speed());
            return NMSImpl.isNavigationFinished(navigation);
        }
    };
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(net.minecraft.server.v1_14_R1.Entity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) PathEntity(net.minecraft.server.v1_14_R1.PathEntity) CraftEntity(org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity) EntityPlayer(net.minecraft.server.v1_14_R1.EntityPlayer) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) AdvancementDataPlayer(net.minecraft.server.v1_14_R1.AdvancementDataPlayer) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) EntitySize(net.minecraft.server.v1_14_R1.EntitySize) EntityInsentient(net.minecraft.server.v1_14_R1.EntityInsentient) NavigationAbstract(net.minecraft.server.v1_14_R1.NavigationAbstract) PathPoint(net.minecraft.server.v1_14_R1.PathPoint) EntityHumanNPC(net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC) PathPoint(net.minecraft.server.v1_14_R1.PathPoint) MCNavigator(net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator) EntityHorse(net.minecraft.server.v1_14_R1.EntityHorse) CancelReason(net.citizensnpcs.api.ai.event.CancelReason) Entity(net.minecraft.server.v1_14_R1.Entity) EntityPlayer(net.minecraft.server.v1_14_R1.EntityPlayer) IBlockData(net.minecraft.server.v1_14_R1.IBlockData) BlockData(org.bukkit.block.data.BlockData) Vector(org.bukkit.util.Vector)

Example 5 with net.minecraft.server.v1_14_R1

use of net.minecraft.server.v1_14_R1 in project BedWars1058 by andrei1058.

the class v1_14_R1 method registerTntWhitelist.

@Override
public void registerTntWhitelist() {
    try {
        Field field = net.minecraft.server.v1_14_R1.Block.class.getDeclaredField("durability");
        field.setAccessible(true);
        field.set(Blocks.END_STONE, 12f);
        field.set(Blocks.GLASS, 300f);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) net.minecraft.server.v1_14_R1(net.minecraft.server.v1_14_R1)

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