Java 类net.minecraft.item.ItemFireworkCharge 实例源码

项目:Production-Line    文件:MixinTileEntityFurnace.java   
@Inject(method = "update", at = @At("RETURN"))
private void onUpdate(CallbackInfo callbackInfo) {
    if (!this.world.isRemote) {
        if (this.isBurning()) {
            ItemStack itemStack = this.furnaceItemStacks[0];
            if (itemStack != null) {
                if (itemStack.getItem() instanceof ItemBlock) {
                    Block block = ((ItemBlock) itemStack.getItem()).block;
                    if (block.getMaterial(block.getStateFromMeta(itemStack.getMetadata())) == Material.TNT) {
                        this.doExplosion();
                    }
                } else if (itemStack.getItem() == Items.GUNPOWDER) {
                    this.doExplosion();
                } else if (itemStack.getItem() instanceof ItemFirework || itemStack.getItem()
                        instanceof ItemFireworkCharge) {
                    this.doExplosion();
                }
            }
        }
    }
}
项目:SimpleCorn    文件:MyFireworkItem.java   
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn,List<String> tooltip, boolean advanced) {
    if (stack.hasTagCompound())
       {
           NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("Fireworks");

           if (nbttagcompound != null)
           {
               if (nbttagcompound.hasKey("Flight", 99))
               {
                   tooltip.add(I18n.translateToLocal("item.fireworks.flight") + " " + nbttagcompound.getByte("Flight"));
               }

               NBTTagList nbttaglist = nbttagcompound.getTagList("Explosions", 10);

               if (nbttaglist != null && !nbttaglist.hasNoTags())
               {
                       NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(1);
                       List<String> list = Lists.<String>newArrayList();
                       ItemFireworkCharge.addExplosionInfo(nbttagcompound1, list);

                       if (!list.isEmpty())
                       {
                           for (int j = 1; j < ((List)list).size(); ++j)
                           {
                               list.set(j, "  " + list.get(j));
                           }

                           tooltip.addAll(list);
                       }
                   tooltip.add("Popcorn");
               }
           }
       }
   }
项目:RuneCraftery    文件:ItemFirework.java   
@SideOnly(Side.CLIENT)
public void func_77624_a(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) {
   if(p_77624_1_.func_77942_o()) {
      NBTTagCompound var5 = p_77624_1_.func_77978_p().func_74775_l("Fireworks");
      if(var5 != null) {
         if(var5.func_74764_b("Flight")) {
            p_77624_3_.add(StatCollector.func_74838_a("item.fireworks.flight") + " " + var5.func_74771_c("Flight"));
         }

         NBTTagList var6 = var5.func_74761_m("Explosions");
         if(var6 != null && var6.func_74745_c() > 0) {
            for(int var7 = 0; var7 < var6.func_74745_c(); ++var7) {
               NBTTagCompound var8 = (NBTTagCompound)var6.func_74743_b(var7);
               ArrayList var9 = new ArrayList();
               ItemFireworkCharge.func_92107_a(var8, var9);
               if(var9.size() > 0) {
                  for(int var10 = 1; var10 < var9.size(); ++var10) {
                     var9.set(var10, "  " + (String)var9.get(var10));
                  }

                  p_77624_3_.addAll(var9);
               }
            }
         }

      }
   }
}
项目:morecommands    文件:CommandFirework.java   
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
    Entity entity = params.length > 2 ? null : 
        isSenderOfEntityType(sender.getMinecraftISender(), Entity.class) ? 
        getSenderAsEntity(sender.getMinecraftISender(), Entity.class) : null;
    BlockPos spawn = null;

    if (params.length > 2)
        spawn = getCoordFromParams(sender.getMinecraftISender(), params, 0);
    else
        spawn = entity == null ? sender.getPosition() : EntityUtils.traceBlock(entity, 128.0D);

    if (spawn == null) 
        throw new CommandException("command.firework.notFound", sender);

    Random rand = new Random();
    RecipeFireworks recipe = (RecipeFireworks) CraftingManager.REGISTRY.getObject(new ResourceLocation("fireworks"));

    if (recipe != null) {
        InventoryCrafting inv = new InventoryCrafting(new Container()
        {
            public boolean canInteractWith(EntityPlayer playerIn) {return false;}
        }, 3, 3);

        ItemStack dye;
        ItemStack output;

        do {
            for (int i = 0; i < inv.getSizeInventory(); ++i) inv.setInventorySlotContents(i, null);

            dye = new ItemStack(Items.DYE, 1, rand.nextInt(MAX_DYE_TYPES));

            inv.setInventorySlotContents(0, dye);
            inv.setInventorySlotContents(1, new ItemStack(Items.GUNPOWDER));

            if (rand.nextBoolean())
                inv.setInventorySlotContents(2, new ItemStack(shapeModifiers.get(rand.nextInt(shapeModifiers.size()))));

            if (rand.nextBoolean())
                inv.setInventorySlotContents(3, new ItemStack(effectModifiers.get(rand.nextInt(effectModifiers.size()))));
        }
        while (!recipe.matches(inv, sender.getMinecraftISender().getEntityWorld()));

        output = recipe.getRecipeOutput();

        if (output.getItem() instanceof ItemFireworkCharge) {
            do {
                for (int i = 0; i < inv.getSizeInventory(); ++i) inv.setInventorySlotContents(i, null);

                inv.setInventorySlotContents(0, output);
                inv.setInventorySlotContents(1, new ItemStack(Items.PAPER));

                int gunpowder = rand.nextInt(MAX_GUNPOWDER);
                for (int i = 0; i < gunpowder; i++) inv.setInventorySlotContents(2 + i, new ItemStack(Items.GUNPOWDER));
            }
            while (!recipe.matches(inv, sender.getMinecraftISender().getEntityWorld()));

            output = recipe.getRecipeOutput();

            if (output.getItem() instanceof ItemFirework) {
                ItemFirework firework = (ItemFirework) output.getItem();

                EntityFireworkRocket rocket = new EntityFireworkRocket(sender.getWorld(), spawn.getX(), spawn.getY(), spawn.getZ(), output);;
                sender.getWorld().spawnEntity(rocket);
            }
        }
    }

    return null;
}