public static void e(ItemStack var0) {
   NBTTagCompound var1 = var0.a("BlockEntityTag", false);
   if (var1 != null && var1.hasKeyOfType("Patterns", 9)) {
     NBTTagList var2 = var1.getList("Patterns", 10);
     if (var2.size() > 0) {
       var2.a(var2.size() - 1);
       if (var2.isEmpty()) {
         var0.getTag().remove("BlockEntityTag");
         if (var0.getTag().isEmpty()) {
           var0.setTag((NBTTagCompound) null);
         }
       }
     }
   }
 }
  public static void a(Map map, ItemStack itemstack) {
    NBTTagList nbttaglist = new NBTTagList();
    Iterator iterator = map.keySet().iterator();

    while (iterator.hasNext()) {
      int i = ((Integer) iterator.next()).intValue();
      NBTTagCompound nbttagcompound = new NBTTagCompound();

      nbttagcompound.setShort("id", (short) i);
      nbttagcompound.setShort("lvl", (short) ((Integer) map.get(Integer.valueOf(i))).intValue());
      nbttaglist.add(nbttagcompound);
      if (itemstack.getItem() == Items.ENCHANTED_BOOK) {
        Items.ENCHANTED_BOOK.a(
            itemstack,
            new EnchantmentInstance(i, ((Integer) map.get(Integer.valueOf(i))).intValue()));
      }
    }

    if (nbttaglist.size() > 0) {
      if (itemstack.getItem() != Items.ENCHANTED_BOOK) {
        itemstack.a("ench", (NBTBase) nbttaglist);
      }
    } else if (itemstack.hasTag()) {
      itemstack.getTag().remove("ench");
    }
  }
Beispiel #3
0
  public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
    if (!world.isStatic) {
      // CraftBukkit start - Drop item in code above, not here
      // if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) {
      if (false) {
        // CraftBukkit end
        TileEntity tileentity = world.getTileEntity(blockposition);

        if (tileentity instanceof TileEntitySkull) {
          TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
          ItemStack itemstack =
              new ItemStack(Items.SKULL, 1, this.getDropData(world, blockposition));

          if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
            itemstack.setTag(new NBTTagCompound());
            NBTTagCompound nbttagcompound = new NBTTagCompound();

            GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
            itemstack.getTag().set("SkullOwner", nbttagcompound);
          }

          a(world, blockposition, itemstack);
        }
      }

      super.remove(world, blockposition, iblockdata);
    }
  }
Beispiel #4
0
  @Override
  public void d(ItemStack itemstack, World world, EntityHuman entityhuman) {
    if (itemstack.hasTag() && itemstack.getTag().getBoolean("map_is_scaling")) {
      WorldMap worldmap = Items.MAP.getSavedMap(itemstack, world);

      world =
          world.getServer().getServer().worlds.get(0); // CraftBukkit - use primary world for maps

      itemstack.setData(world.b("map"));
      WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData());

      worldmap1.scale = (byte) (worldmap.scale + 1);
      if (worldmap1.scale > 4) {
        worldmap1.scale = 4;
      }

      worldmap1.centerX = worldmap.centerX;
      worldmap1.centerZ = worldmap.centerZ;
      worldmap1.map = worldmap.map;
      worldmap1.c();
      world.a("map_" + itemstack.getData(), worldmap1);

      // CraftBukkit start
      MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView);
      Bukkit.getServer().getPluginManager().callEvent(event);
      // CraftBukkit end
    }
  }
  public static List h(ItemStack var0) {
    ArrayList var1 = Lists.newArrayList();
    var1.addAll(i(var0).b());
    if (var0.hasTag() && var0.getTag().hasOfType("CustomPotionEffects", 9)) {
      NBTTagList var2 = var0.getTag().getList("CustomPotionEffects", 10);

      for (int var3 = 0; var3 < var2.getSize(); ++var3) {
        NBTTagCompound var4 = var2.getCompound(var3);
        MobEffect var5 = MobEffect.b(var4);
        if (var5 != null) {
          var1.add(var5);
        }
      }
    }

    return var1;
  }
  public static ItemStack a(ItemStack var0, class_acd var1) {
    MinecraftKey var2 = (MinecraftKey) class_acd.a.getKey(var1);
    if (var2 != null) {
      NBTTagCompound var3 = var0.hasTag() ? var0.getTag() : new NBTTagCompound();
      var3.put("Potion", var2.toString());
      var0.setTag(var3);
    }

    return var0;
  }
  /** Called whenever the block is removed. */
  @Override
  public void remove(World par1World, int par2, int par3, int par4) {
    if (!c) {
      TileEntityIronFurnace tileentityfurnace =
          (TileEntityIronFurnace) par1World.getTileEntity(par2, par3, par4);

      if (tileentityfurnace != null) {
        label0:
        for (int i = 0; i < tileentityfurnace.getSize(); i++) {
          ItemStack itemstack = tileentityfurnace.getItem(i);

          if (itemstack == null) {
            continue;
          }

          float f = a.nextFloat() * 0.8F + 0.1F;
          float f1 = a.nextFloat() * 0.8F + 0.1F;
          float f2 = a.nextFloat() * 0.8F + 0.1F;

          do {
            if (itemstack.count <= 0) {
              continue label0;
            }

            int j = a.nextInt(21) + 10;

            if (j > itemstack.count) {
              j = itemstack.count;
            }

            itemstack.count -= j;
            EntityItem entityitem =
                new EntityItem(
                    par1World,
                    par2 + f,
                    par3 + f1,
                    par4 + f2,
                    new ItemStack(itemstack.id, j, itemstack.getData()));

            if (itemstack.hasTag()) {
              entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone());
            }

            float f3 = 0.05F;
            entityitem.motX = (float) a.nextGaussian() * f3;
            entityitem.motY = (float) a.nextGaussian() * f3 + 0.2F;
            entityitem.motZ = (float) a.nextGaussian() * f3;
            par1World.addEntity(entityitem);
          } while (true);
        }
      }
    }

    super.remove(par1World, par2, par3, par4);
  }
  public void a(ItemStack var1) {
    this.patterns = null;
    if (var1.hasTag() && var1.getTag().hasKeyOfType("BlockEntityTag", 10)) {
      NBTTagCompound var2 = var1.getTag().getCompound("BlockEntityTag");
      if (var2.hasKey("Patterns")) {
        this.patterns = (NBTTagList) var2.getList("Patterns", 10).clone();
      }

      if (var2.hasKeyOfType("Base", 99)) {
        this.color = var2.getInt("Base");
      } else {
        this.color = var1.getData() & 15;
      }
    } else {
      this.color = var1.getData() & 15;
    }

    this.h = null;
    this.i = null;
    this.j = "";
    this.g = true;
  }
Beispiel #9
0
  public ItemStack a(InventoryCrafting inventorycrafting) {
    ItemStack itemstack = this.b().cloneItemStack();

    if (this.e) {
      for (int i = 0; i < inventorycrafting.getSize(); ++i) {
        ItemStack itemstack1 = inventorycrafting.getItem(i);

        if (itemstack1 != null && itemstack1.hasTag()) {
          itemstack.setTag((NBTTagCompound) itemstack1.getTag().clone());
        }
      }
    }

    return itemstack;
  }
Beispiel #10
0
  // CraftBukkit start - Special case dropping so we can get info from the tile entity
  public void dropNaturally(
      World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
    if (world.random.nextFloat() < f) {
      ItemStack itemstack = new ItemStack(Items.SKULL, 1, this.getDropData(world, blockposition));
      TileEntitySkull tileentityskull = (TileEntitySkull) world.getTileEntity(blockposition);

      if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
        itemstack.setTag(new NBTTagCompound());
        NBTTagCompound nbttagcompound = new NBTTagCompound();

        GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
        itemstack.getTag().set("SkullOwner", nbttagcompound);
      }

      a(world, blockposition, itemstack);
    }
  }
Beispiel #11
0
  public void die() {
    if (this.h) {
      for (int i = 0; i < this.getSize(); ++i) {
        ItemStack itemstack = this.getItem(i);

        if (itemstack != null) {
          float f = this.random.nextFloat() * 0.8F + 0.1F;
          float f1 = this.random.nextFloat() * 0.8F + 0.1F;
          float f2 = this.random.nextFloat() * 0.8F + 0.1F;

          while (itemstack.count > 0) {
            int j = this.random.nextInt(21) + 10;

            if (j > itemstack.count) {
              j = itemstack.count;
            }

            itemstack.count -= j;
            EntityItem entityitem =
                new EntityItem(
                    this.world,
                    this.locX + (double) f,
                    this.locY + (double) f1,
                    this.locZ + (double) f2,
                    new ItemStack(itemstack.id, j, itemstack.getData()));

            if (itemstack.hasTag()) {
              entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone());
            }

            float f3 = 0.05F;

            entityitem.motX = (double) ((float) this.random.nextGaussian() * f3);
            entityitem.motY = (double) ((float) this.random.nextGaussian() * f3 + 0.2F);
            entityitem.motZ = (double) ((float) this.random.nextGaussian() * f3);
            this.world.addEntity(entityitem);
          }
        }
      }
    }

    super.die();
    if (this.g != null) {
      this.g.a();
    }
  }
  public void remove(World world, int i, int j, int k) {
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);

    if (tileentitydispenser != null) {
      for (int l = 0; l < tileentitydispenser.getSize(); ++l) {
        ItemStack itemstack = tileentitydispenser.getItem(l);

        if (itemstack != null) {
          float f = this.a.nextFloat() * 0.8F + 0.1F;
          float f1 = this.a.nextFloat() * 0.8F + 0.1F;
          float f2 = this.a.nextFloat() * 0.8F + 0.1F;

          while (itemstack.count > 0) {
            int i1 = this.a.nextInt(21) + 10;

            if (i1 > itemstack.count) {
              i1 = itemstack.count;
            }

            itemstack.count -= i1;
            EntityItem entityitem =
                new EntityItem(
                    world,
                    (double) ((float) i + f),
                    (double) ((float) j + f1),
                    (double) ((float) k + f2),
                    new ItemStack(itemstack.id, i1, itemstack.getData()));

            if (itemstack.hasTag()) {
              entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone());
            }

            float f3 = 0.05F;

            entityitem.motX = (double) ((float) this.a.nextGaussian() * f3);
            entityitem.motY = (double) ((float) this.a.nextGaussian() * f3 + 0.2F);
            entityitem.motZ = (double) ((float) this.a.nextGaussian() * f3);
            world.addEntity(entityitem);
          }
        }
      }
    }

    super.remove(world, i, j, k);
  }
Beispiel #13
0
  @Override
  public boolean a(InventoryCrafting inventorycrafting, World world) {
    a = null;
    int i = 0;
    int j = 0;
    int k = 0;
    int l = 0;
    int i1 = 0;
    int j1 = 0;

    for (int k1 = 0; k1 < inventorycrafting.getSize(); ++k1) {
      ItemStack itemstack = inventorycrafting.getItem(k1);

      if (itemstack != null) {
        if (itemstack.getItem() == Items.SULPHUR) {
          ++j;
        } else if (itemstack.getItem() == Items.FIREWORKS_CHARGE) {
          ++l;
        } else if (itemstack.getItem() == Items.INK_SACK) {
          ++k;
        } else if (itemstack.getItem() == Items.PAPER) {
          ++i;
        } else if (itemstack.getItem() == Items.GLOWSTONE_DUST) {
          ++i1;
        } else if (itemstack.getItem() == Items.DIAMOND) {
          ++i1;
        } else if (itemstack.getItem() == Items.FIREBALL) {
          ++j1;
        } else if (itemstack.getItem() == Items.FEATHER) {
          ++j1;
        } else if (itemstack.getItem() == Items.GOLD_NUGGET) {
          ++j1;
        } else {
          if (itemstack.getItem() != Items.SKULL) return false;

          ++j1;
        }
      }
    }

    i1 += k + j1;
    if (j <= 3 && i <= 1) {
      NBTTagCompound nbttagcompound;
      NBTTagCompound nbttagcompound1;

      if (j >= 1 && i == 1 && i1 == 0) {
        a = new ItemStack(Items.FIREWORKS);
        if (l > 0) {
          nbttagcompound = new NBTTagCompound();
          nbttagcompound1 = new NBTTagCompound();
          NBTTagList nbttaglist = new NBTTagList();

          for (int l1 = 0; l1 < inventorycrafting.getSize(); ++l1) {
            ItemStack itemstack1 = inventorycrafting.getItem(l1);

            if (itemstack1 != null
                && itemstack1.getItem() == Items.FIREWORKS_CHARGE
                && itemstack1.hasTag()
                && itemstack1.getTag().hasKeyOfType("Explosion", 10)) {
              nbttaglist.add(itemstack1.getTag().getCompound("Explosion"));
            }
          }

          nbttagcompound1.set("Explosions", nbttaglist);
          nbttagcompound1.setByte("Flight", (byte) j);
          nbttagcompound.set("Fireworks", nbttagcompound1);
          a.setTag(nbttagcompound);
        }

        return true;
      } else if (j == 1 && i == 0 && l == 0 && k > 0 && j1 <= 1) {
        a = new ItemStack(Items.FIREWORKS_CHARGE);
        nbttagcompound = new NBTTagCompound();
        nbttagcompound1 = new NBTTagCompound();
        byte b0 = 0;
        ArrayList arraylist = new ArrayList();

        for (int i2 = 0; i2 < inventorycrafting.getSize(); ++i2) {
          ItemStack itemstack2 = inventorycrafting.getItem(i2);

          if (itemstack2 != null) {
            if (itemstack2.getItem() == Items.INK_SACK) {
              arraylist.add(Integer.valueOf(ItemDye.c[itemstack2.getData()]));
            } else if (itemstack2.getItem() == Items.GLOWSTONE_DUST) {
              nbttagcompound1.setBoolean("Flicker", true);
            } else if (itemstack2.getItem() == Items.DIAMOND) {
              nbttagcompound1.setBoolean("Trail", true);
            } else if (itemstack2.getItem() == Items.FIREBALL) {
              b0 = 1;
            } else if (itemstack2.getItem() == Items.FEATHER) {
              b0 = 4;
            } else if (itemstack2.getItem() == Items.GOLD_NUGGET) {
              b0 = 2;
            } else if (itemstack2.getItem() == Items.SKULL) {
              b0 = 3;
            }
          }
        }

        int[] aint = new int[arraylist.size()];

        for (int j2 = 0; j2 < aint.length; ++j2) {
          aint[j2] = ((Integer) arraylist.get(j2)).intValue();
        }

        nbttagcompound1.setIntArray("Colors", aint);
        nbttagcompound1.setByte("Type", b0);
        nbttagcompound.set("Explosion", nbttagcompound1);
        a.setTag(nbttagcompound);
        return true;
      } else if (j == 0 && i == 0 && l == 1 && k > 0 && k == i1) {
        ArrayList arraylist1 = new ArrayList();

        for (int k2 = 0; k2 < inventorycrafting.getSize(); ++k2) {
          ItemStack itemstack3 = inventorycrafting.getItem(k2);

          if (itemstack3 != null) {
            if (itemstack3.getItem() == Items.INK_SACK) {
              arraylist1.add(Integer.valueOf(ItemDye.c[itemstack3.getData()]));
            } else if (itemstack3.getItem() == Items.FIREWORKS_CHARGE) {
              a = itemstack3.cloneItemStack();
              a.count = 1;
            }
          }
        }

        int[] aint1 = new int[arraylist1.size()];

        for (int l2 = 0; l2 < aint1.length; ++l2) {
          aint1[l2] = ((Integer) arraylist1.get(l2)).intValue();
        }

        if (a != null && a.hasTag()) {
          NBTTagCompound nbttagcompound2 = a.getTag().getCompound("Explosion");

          if (nbttagcompound2 == null) return false;
          else {
            nbttagcompound2.setIntArray("FadeColors", aint1);
            return true;
          }
        } else return false;
      } else return false;
    } else return false;
  }
  public UseResult interactWith(
      ItemStack var1,
      EntityHuman var2,
      World var3,
      BlockPosition var4,
      EnumUsedHand var5,
      EnumDirection var6,
      float var7,
      float var8,
      float var9) {
    if (var6 == EnumDirection.DOWN) {
      return UseResult.CANT_USE;
    } else {
      boolean var10 = var3.getType(var4).getBlock().isReplaceable(var3, var4);
      BlockPosition var11 = var10 ? var4 : var4.shift(var6);
      if (!var2.a(var11, var6, var1)) {
        return UseResult.CANT_USE;
      } else {
        BlockPosition var12 = var11.up();
        boolean var13 =
            !var3.isEmpty(var11) && !var3.getType(var11).getBlock().isReplaceable(var3, var11);
        var13 |= !var3.isEmpty(var12) && !var3.getType(var12).getBlock().isReplaceable(var3, var12);
        if (var13) {
          return UseResult.CANT_USE;
        } else {
          double var14 = (double) var11.getX();
          double var16 = (double) var11.getY();
          double var18 = (double) var11.getZ();
          List var20 =
              var3.getEntities(
                  (Entity) null,
                  (AxisAlignedBB)
                      AxisAlignedBB.a(
                          var14, var16, var18, var14 + 1.0D, var16 + 2.0D, var18 + 1.0D));
          if (!var20.isEmpty()) {
            return UseResult.CANT_USE;
          } else {
            if (!var3.isClientSide) {
              var3.setAir(var11);
              var3.setAir(var12);
              EntityArmorStand var21 =
                  new EntityArmorStand(var3, var14 + 0.5D, var16, var18 + 0.5D);
              float var22 =
                  (float)
                          MathHelper.floor(
                              (MathHelper.clampAngle(var2.yaw - 180.0F) + 22.5F) / 45.0F)
                      * 45.0F;
              var21.setPositionRotation(var14 + 0.5D, var16, var18 + 0.5D, var22, 0.0F);
              this.a(var21, var3.random);
              NBTTagCompound var23 = var1.getTag();
              if (var23 != null && var23.hasOfType("EntityTag", 10)) {
                NBTTagCompound var24 = new NBTTagCompound();
                var21.d(var24);
                var24.copyFrom(var23.getCompound("EntityTag"));
                var21.f(var24);
              }

              var3.addEntity((Entity) var21);
            }

            --var1.count;
            return UseResult.SUCCESS;
          }
        }
      }
    }
  }
  public boolean a(class_yg var1, World var2) {
    this.a = null;
    int var3 = 0;
    int var4 = 0;
    int var5 = 0;
    int var6 = 0;
    int var7 = 0;
    int var8 = 0;

    for (int var9 = 0; var9 < var1.getSize(); ++var9) {
      ItemStack var10 = var1.getItem(var9);
      if (var10 != null) {
        if (var10.getItem() == Items.GUNPOWDER) {
          ++var4;
        } else if (var10.getItem() == Items.FIREWORK_CHARGE) {
          ++var6;
        } else if (var10.getItem() == Items.DYE) {
          ++var5;
        } else if (var10.getItem() == Items.PAPER) {
          ++var3;
        } else if (var10.getItem() == Items.GLOWSTONE_DUST) {
          ++var7;
        } else if (var10.getItem() == Items.DIAMOND) {
          ++var7;
        } else if (var10.getItem() == Items.FIRE_CHARGE) {
          ++var8;
        } else if (var10.getItem() == Items.FEATHER) {
          ++var8;
        } else if (var10.getItem() == Items.GOLD_NUGGEST) {
          ++var8;
        } else {
          if (var10.getItem() != Items.SKULL) {
            return false;
          }

          ++var8;
        }
      }
    }

    var7 += var5 + var8;
    if (var4 <= 3 && var3 <= 1) {
      NBTTagCompound var16;
      NBTTagCompound var19;
      if (var4 >= 1 && var3 == 1 && var7 == 0) {
        this.a = new ItemStack(Items.FIREWORKS);
        if (var6 > 0) {
          var16 = new NBTTagCompound();
          var19 = new NBTTagCompound();
          NBTTagList var25 = new NBTTagList();

          for (int var22 = 0; var22 < var1.getSize(); ++var22) {
            ItemStack var26 = var1.getItem(var22);
            if (var26 != null
                && var26.getItem() == Items.FIREWORK_CHARGE
                && var26.hasTag()
                && var26.getTag().hasOfType("Explosion", 10)) {
              var25.add((NBTTag) var26.getTag().getCompound("Explosion"));
            }
          }

          var19.put((String) "Explosions", (NBTTag) var25);
          var19.put("Flight", (byte) var4);
          var16.put((String) "Fireworks", (NBTTag) var19);
          this.a.setTag(var16);
        }

        return true;
      } else if (var4 == 1 && var3 == 0 && var6 == 0 && var5 > 0 && var8 <= 1) {
        this.a = new ItemStack(Items.FIREWORK_CHARGE);
        var16 = new NBTTagCompound();
        var19 = new NBTTagCompound();
        byte var23 = 0;
        ArrayList var12 = Lists.newArrayList();

        for (int var13 = 0; var13 < var1.getSize(); ++var13) {
          ItemStack var14 = var1.getItem(var13);
          if (var14 != null) {
            if (var14.getItem() == Items.DYE) {
              var12.add(Integer.valueOf(ItemDye.a[var14.i() & 15]));
            } else if (var14.getItem() == Items.GLOWSTONE_DUST) {
              var19.put("Flicker", true);
            } else if (var14.getItem() == Items.DIAMOND) {
              var19.put("Trail", true);
            } else if (var14.getItem() == Items.FIRE_CHARGE) {
              var23 = 1;
            } else if (var14.getItem() == Items.FEATHER) {
              var23 = 4;
            } else if (var14.getItem() == Items.GOLD_NUGGEST) {
              var23 = 2;
            } else if (var14.getItem() == Items.SKULL) {
              var23 = 3;
            }
          }
        }

        int[] var24 = new int[var12.size()];

        for (int var27 = 0; var27 < var24.length; ++var27) {
          var24[var27] = ((Integer) var12.get(var27)).intValue();
        }

        var19.put("Colors", var24);
        var19.put("Type", var23);
        var16.put((String) "Explosion", (NBTTag) var19);
        this.a.setTag(var16);
        return true;
      } else if (var4 == 0 && var3 == 0 && var6 == 1 && var5 > 0 && var5 == var7) {
        ArrayList var15 = Lists.newArrayList();

        for (int var17 = 0; var17 < var1.getSize(); ++var17) {
          ItemStack var11 = var1.getItem(var17);
          if (var11 != null) {
            if (var11.getItem() == Items.DYE) {
              var15.add(Integer.valueOf(ItemDye.a[var11.i() & 15]));
            } else if (var11.getItem() == Items.FIREWORK_CHARGE) {
              this.a = var11.clone();
              this.a.count = 1;
            }
          }
        }

        int[] var18 = new int[var15.size()];

        for (int var20 = 0; var20 < var18.length; ++var20) {
          var18[var20] = ((Integer) var15.get(var20)).intValue();
        }

        if (this.a != null && this.a.hasTag()) {
          NBTTagCompound var21 = this.a.getTag().getCompound("Explosion");
          if (var21 == null) {
            return false;
          } else {
            var21.put("FadeColors", var18);
            return true;
          }
        } else {
          return false;
        }
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
 public static class_acd i(ItemStack var0) {
   return !var0.hasTag() ? class_acf.a : class_acd.a(var0.getTag().getString("Potion"));
 }