Search in sources :

Example 16 with net.minecraft.server.v1_12_R1

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

the class NMSHandler method setPotion.

/* (non-Javadoc)
     * @see com.wasteofplastic.acidisland.nms.NMSAbstraction#setPotion(com.wasteofplastic.org.jnbt.Tag)
     */
@SuppressWarnings({ "unchecked" })
@Override
public ItemStack setPotion(Material material, Tag itemTags, ItemStack chestItem) {
    Map<String, Tag> cont = (Map<String, Tag>) ((CompoundTag) itemTags).getValue();
    if (cont != null) {
        if (((CompoundTag) itemTags).getValue().containsKey("tag")) {
            Map<String, Tag> contents = (Map<String, Tag>) ((CompoundTag) itemTags).getValue().get("tag").getValue();
            StringTag stringTag = ((StringTag) contents.get("Potion"));
            if (stringTag != null) {
                String tag = ((StringTag) contents.get("Potion")).getValue();
                // Bukkit.getLogger().info("DEBUG: potioninfo found: " + tag);
                net.minecraft.server.v1_12_R1.ItemStack stack = CraftItemStack.asNMSCopy(chestItem);
                NBTTagCompound tagCompound = stack.getTag();
                if (tagCompound == null) {
                    tagCompound = new NBTTagCompound();
                }
                tagCompound.setString("Potion", tag);
                stack.setTag(tagCompound);
                return CraftItemStack.asBukkitCopy(stack);
            }
        }
    }
    // Schematic is old, the potions do not have tags
    // Set it to zero so that the potion bottles don't look like giant purple and black blocks
    chestItem.setDurability((short) 0);
    Bukkit.getLogger().warning("Potion in schematic is pre-V1.9 format and will just be water.");
    return chestItem;
}
Also used : StringTag(com.wasteofplastic.org.jnbt.StringTag) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) ListTag(com.wasteofplastic.org.jnbt.ListTag) StringTag(com.wasteofplastic.org.jnbt.StringTag) CompoundTag(com.wasteofplastic.org.jnbt.CompoundTag) Tag(com.wasteofplastic.org.jnbt.Tag) HashMap(java.util.HashMap) Map(java.util.Map)

Example 17 with net.minecraft.server.v1_12_R1

use of net.minecraft.server.v1_12_R1 in project askyblock 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 18 with net.minecraft.server.v1_12_R1

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

the class NMSHandler method setBlockSuperFast.

@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_12_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_12_R1.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
    int combined = blockId + (data << 12);
    IBlockData ibd = net.minecraft.server.v1_12_R1.Block.getByCombinedId(combined);
    if (applyPhysics) {
        w.setTypeAndData(bp, ibd, 3);
    } else {
        w.setTypeAndData(bp, ibd, 2);
    }
    chunk.a(bp, ibd);
}
Also used : IBlockData(net.minecraft.server.v1_12_R1.IBlockData) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld)

Example 19 with net.minecraft.server.v1_12_R1

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

the class NMSHandler method setPotion.

/* (non-Javadoc)
     * @see com.wasteofplastic.acidisland.nms.NMSAbstraction#setPotion(com.wasteofplastic.org.jnbt.Tag)
     */
@SuppressWarnings({ "unchecked" })
@Override
public ItemStack setPotion(Material material, Tag itemTags, ItemStack chestItem) {
    Map<String, Tag> cont = (Map<String, Tag>) ((CompoundTag) itemTags).getValue();
    if (cont != null) {
        if (((CompoundTag) itemTags).getValue().containsKey("tag")) {
            Map<String, Tag> contents = (Map<String, Tag>) ((CompoundTag) itemTags).getValue().get("tag").getValue();
            StringTag stringTag = ((StringTag) contents.get("Potion"));
            if (stringTag != null) {
                String tag = ((StringTag) contents.get("Potion")).getValue();
                // Bukkit.getLogger().info("DEBUG: potioninfo found: " + tag);
                net.minecraft.server.v1_12_R1.ItemStack stack = CraftItemStack.asNMSCopy(chestItem);
                NBTTagCompound tagCompound = stack.getTag();
                if (tagCompound == null) {
                    tagCompound = new NBTTagCompound();
                }
                tagCompound.setString("Potion", tag);
                stack.setTag(tagCompound);
                return CraftItemStack.asBukkitCopy(stack);
            }
        }
    }
    // Schematic is old, the potions do not have tags
    // Set it to zero so that the potion bottles don't look like giant purple and black blocks
    chestItem.setDurability((short) 0);
    Bukkit.getLogger().warning("Potion in schematic is pre-V1.9 format and will just be water.");
    return chestItem;
}
Also used : StringTag(com.wasteofplastic.org.jnbt.StringTag) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) ListTag(com.wasteofplastic.org.jnbt.ListTag) StringTag(com.wasteofplastic.org.jnbt.StringTag) CompoundTag(com.wasteofplastic.org.jnbt.CompoundTag) Tag(com.wasteofplastic.org.jnbt.Tag) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with net.minecraft.server.v1_12_R1

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

the class NMSHandler method getSpawnEgg.

/**
 * Get spawn egg
 * @param type
 * @param amount
 * @return
 */
public ItemStack getSpawnEgg(EntityType type, int amount) {
    // Bukkit.getLogger().info("DEBUG: setting spawn egg " + type.toString());
    ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
    net.minecraft.server.v1_12_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
    NBTTagCompound tagCompound = stack.getTag();
    if (tagCompound == null) {
        tagCompound = new NBTTagCompound();
    }
    // Bukkit.getLogger().info("DEBUG: tag = " + tagCompound);
    NBTTagCompound id = new NBTTagCompound();
    if (!bToMConversion.containsKey(type)) {
        id.setString("id", "minecraft:" + type.toString().toLowerCase());
    } else {
        id.setString("id", "minecraft:" + bToMConversion.get(type));
    }
    tagCompound.set("EntityTag", id);
    stack.setTag(tagCompound);
    // Bukkit.getLogger().info("DEBUG: after tag = " + tagCompound);
    return CraftItemStack.asBukkitCopy(stack);
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack)

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