Search in sources :

Example 1 with net.minecraft.server.v1_12_R1

use of net.minecraft.server.v1_12_R1 in project acidisland by tastybento.

the class NMSHandler method isPotion.

/* (non-Javadoc)
     * @see com.wasteofplastic.askyblock.nms.NMSAbstraction#isPotion(org.bukkit.inventory.ItemStack)
     */
@Override
public boolean isPotion(ItemStack item) {
    // Bukkit.getLogger().info("DEBUG:item = " + item);
    if (item.getType().equals(Material.POTION)) {
        net.minecraft.server.v1_12_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
        NBTTagCompound tag = stack.getTag();
        /*
            for (String list : tag.c()) {
                Bukkit.getLogger().info("DEBUG: list = " + list);
            }*/
        if (tag != null && (!tag.getString("Potion").equalsIgnoreCase("minecraft:water") || tag.getString("Potion").isEmpty())) {
            return true;
        }
    }
    return false;
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound)

Example 2 with net.minecraft.server.v1_12_R1

use of net.minecraft.server.v1_12_R1 in project acidisland by tastybento.

the class NMSHandler method setFlowerPotBlock.

/* (non-Javadoc)
     * @see com.wasteofplastic.askyblock.nms.NMSAbstraction#setBlock(org.bukkit.block.Block, org.bukkit.inventory.ItemStack)
     */
@Override
public void setFlowerPotBlock(final Block block, final ItemStack itemStack) {
    if (block.getType().equals(Material.FLOWER_POT)) {
        Location loc = block.getLocation();
        CraftWorld cw = (CraftWorld) block.getWorld();
        BlockPosition bp = new BlockPosition(loc.getX(), loc.getY(), loc.getZ());
        TileEntityFlowerPot te = (TileEntityFlowerPot) cw.getHandle().getTileEntity(bp);
        // Bukkit.getLogger().info("Debug: flowerpot materialdata = " + (new ItemStack(potItem, 1,(short) potItemData).toString()));
        net.minecraft.server.v1_12_R1.ItemStack cis = CraftItemStack.asNMSCopy(itemStack);
        te.setContents(cis);
        te.update();
    }
}
Also used : BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) TileEntityFlowerPot(net.minecraft.server.v1_12_R1.TileEntityFlowerPot) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) Location(org.bukkit.Location)

Example 3 with net.minecraft.server.v1_12_R1

use of net.minecraft.server.v1_12_R1 in project NoCheatPlus by NoCheatPlus.

the class BlockCacheCBDev method fetchBounds.

@Override
public double[] fetchBounds(final int x, final int y, final int z) {
    final Material id = getType(x, y, z);
    @SuppressWarnings("deprecation") final net.minecraft.server.v1_12_R1.Block block = net.minecraft.server.v1_12_R1.Block.getById(id.getId());
    if (block == null) {
        // TODO: Convention for null blocks -> full ?
        return null;
    }
    final BlockPosition pos = new BlockPosition(x, y, z);
    // TODO: Deprecation warning below (reason / substitute?).
    @SuppressWarnings("deprecation") final AxisAlignedBB bb = block.b(iBlockAccess.getType(pos), iBlockAccess, pos);
    if (bb == null) {
        // Special case.
        return new double[] { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 };
    // return null;
    }
    // minX, minY, minZ, maxX, maxY, maxZ
    return new double[] { bb.a, bb.b, bb.c, bb.d, bb.e, bb.f };
}
Also used : AxisAlignedBB(net.minecraft.server.v1_12_R1.AxisAlignedBB) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) Material(org.bukkit.Material)

Example 4 with net.minecraft.server.v1_12_R1

use of net.minecraft.server.v1_12_R1 in project NoCheatPlus by NoCheatPlus.

the class BlockCacheCBDev method standsOnEntity.

@Override
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ) {
    try {
        // TODO: Find some simplification!
        final net.minecraft.server.v1_12_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
        final AxisAlignedBB box = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
        @SuppressWarnings("rawtypes") final List list = world.getEntities(mcEntity, box);
        @SuppressWarnings("rawtypes") final Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            final net.minecraft.server.v1_12_R1.Entity other = (net.minecraft.server.v1_12_R1.Entity) iterator.next();
            if (mcEntity == other || !(other instanceof EntityBoat) && !(other instanceof EntityShulker)) {
                // && !(other instanceof EntityMinecart)) continue;
                continue;
            }
            if (minY >= other.locY && minY - other.locY <= 0.7) {
                return true;
            }
            // Still check this for some reason.
            final AxisAlignedBB otherBox = other.getBoundingBox();
            if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) {
                continue;
            } else {
                return true;
            }
        }
    } catch (Throwable t) {
    // Ignore exceptions (Context: DisguiseCraft).
    }
    return false;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_12_R1.AxisAlignedBB) Entity(org.bukkit.entity.Entity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) TileEntity(net.minecraft.server.v1_12_R1.TileEntity) EntityBoat(net.minecraft.server.v1_12_R1.EntityBoat) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) Iterator(java.util.Iterator) List(java.util.List) EntityShulker(net.minecraft.server.v1_12_R1.EntityShulker)

Example 5 with net.minecraft.server.v1_12_R1

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

the class Item method getNBT.

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

Aggregations

NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)13 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)6 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)5 NBTTagString (net.minecraft.server.v1_12_R1.NBTTagString)5 ItemStack (org.bukkit.inventory.ItemStack)5 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)4 ListTag (com.wasteofplastic.org.jnbt.ListTag)4 StringTag (com.wasteofplastic.org.jnbt.StringTag)4 Tag (com.wasteofplastic.org.jnbt.Tag)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)4 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)4 ArrayList (java.util.ArrayList)3 AxisAlignedBB (net.minecraft.server.v1_12_R1.AxisAlignedBB)3 NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)3 ItemMeta (org.bukkit.inventory.meta.ItemMeta)3 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)2 IBlockData (net.minecraft.server.v1_12_R1.IBlockData)2 TileEntityFlowerPot (net.minecraft.server.v1_12_R1.TileEntityFlowerPot)2