Java Code Examples for net.minecraft.init.Items.APPLE

The following are Jave code examples for showing how to use APPLE of the net.minecraft.init.Items class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: customstuff4   File: ItemHelperTests.java   View Source Code Vote up 6 votes
@Test
public void test_getDroppedStacks_simple()
{
    BlockDrop drop1 = new BlockDrop(new WrappedItemStackConstant(new ItemStack(Items.APPLE)), IntRange.create(1, 1));
    BlockDrop drop2 = new BlockDrop(new WrappedItemStackConstant(new ItemStack(Items.STICK)), IntRange.create(2, 2));

    List<ItemStack> drops = ItemHelper.getDroppedStacks(new BlockDrop[] {drop1, drop2});
    ItemStack stack1 = drops.get(0);
    ItemStack stack2 = drops.get(1);

    assertSame(Items.APPLE, stack1.getItem());
    assertEquals(1, stack1.getCount());

    assertSame(Items.STICK, stack2.getItem());
    assertEquals(2, stack2.getCount());
}
 
Example 2
Project: customstuff4   File: ItemHelperTests.java   View Source Code Vote up 6 votes
@Test
public void test_getDroppedStacks_range()
{
    BlockDrop drop1 = new BlockDrop(new WrappedItemStackConstant(new ItemStack(Items.APPLE)), IntRange.create(1, 10));
    BlockDrop drop2 = new BlockDrop(new WrappedItemStackConstant(new ItemStack(Items.STICK)), IntRange.create(11, 20));

    List<ItemStack> drops = ItemHelper.getDroppedStacks(new BlockDrop[] {drop1, drop2});
    ItemStack stack1 = drops.get(0);
    ItemStack stack2 = drops.get(1);

    assertSame(Items.APPLE, stack1.getItem());
    assertTrue(stack1.getCount() >= 1 && stack1.getCount() <= 10);

    assertSame(Items.STICK, stack2.getItem());
    assertTrue(stack2.getCount() >= 11 && stack2.getCount() <= 20);
}
 
Example 3
Project: customstuff4   File: DamageableShapelessOreRecipeTest.java   View Source Code Vote up 6 votes
private void doTest(boolean inOrder, boolean enoughDamage)
{
    DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"),
                                                                           new int[] {enoughDamage ? 5 : 5000, 0},
                                                                           new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD), new ItemStack(Items.APPLE));
    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(inOrder ? 3 : 4, new ItemStack(Items.WOODEN_SWORD));
    inv.setInventorySlotContents(inOrder ? 4 : 3, new ItemStack(Items.APPLE));

    assertSame(enoughDamage, recipe.matches(inv, null));

    if (enoughDamage)
    {
        NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
        assertSame(Items.WOODEN_SWORD, remaining.get(inOrder ? 3 : 4).getItem());
        assertEquals(5, remaining.get(inOrder ? 3 : 4).getItemDamage());
    }
}
 
Example 4
Project: customstuff4   File: BlockSnowTest.java   View Source Code Vote up 6 votes
@Test
public void test_getDrops()
{
    ContentBlockSnow content = new ContentBlockSnow();
    content.id = "test_getDrops";
    content.snowball = new WrappedItemStackConstant(new ItemStack(Items.APPLE, 3));
    content.drop = Attribute.constant(new BlockDrop[] {new BlockDrop(new WrappedItemStackConstant(new ItemStack(Items.STICK)), IntRange.create(2, 2))});

    Block block = content.createBlock();

    NonNullList<ItemStack> drops = NonNullList.create();
    block.getDrops(drops, null, null, block.getDefaultState().withProperty(BlockSnow.LAYERS, 5), 0);
    ItemStack drop1 = drops.get(0);
    ItemStack drop2 = drops.get(1);

    assertEquals(2, drops.size());

    assertSame(Items.APPLE, drop1.getItem());
    assertEquals(18, drop1.getCount());

    assertSame(Items.STICK, drop2.getItem());
    assertEquals(2, drop2.getCount());
}
 
Example 5
Project: customstuff4   File: ShapelessRecipeTests.java   View Source Code Vote up 6 votes
@Test
public void test_addRecipe()
{
    ShapelessRecipe recipe = new ShapelessRecipe();
    recipe.recipeList = new ResourceLocation("testmod:recipes");
    recipe.items.add(new RecipeInputImpl("stickWood"));
    recipe.result = new WrappedItemStackConstant(new ItemStack(Items.APPLE));

    int prevRecipes = CraftingManagerCS4.getRecipes(recipe.recipeList).size();

    recipe.addRecipe();

    int newRecipes = CraftingManagerCS4.getRecipes(recipe.recipeList).size();

    assertEquals(prevRecipes + 1, newRecipes);
}
 
Example 6
Project: customstuff4   File: ShapedRecipeTests.java   View Source Code Vote up 6 votes
@Test
public void test_addRecipe() throws Exception
{
    ShapedRecipe recipe = new ShapedRecipe();
    recipe.recipeList = new ResourceLocation("testmod:recipes");
    recipe.shape = new String[] {"a"};
    recipe.items.put('a', new RecipeInputImpl("stickWood"));
    recipe.result = new WrappedItemStackConstant(new ItemStack(Items.APPLE));

    int prevRecipes = CraftingManagerCS4.getRecipes(recipe.recipeList).size();

    recipe.addRecipe();

    int newRecipes = CraftingManagerCS4.getRecipes(recipe.recipeList).size();

    assertEquals(prevRecipes + 1, newRecipes);
}
 
Example 7
Project: customstuff4   File: ItemHelperTests.java   View Source Code Vote up 5 votes
@Test
public void test_getDroppedStacks_emptyStack()
{
    BlockDrop drop = new BlockDrop(new WrappedItemStackConstant(new ItemStack(Items.APPLE)), IntRange.create(0, 0));

    List<ItemStack> drops = ItemHelper.getDroppedStacks(new BlockDrop[] {drop});

    assertTrue(drops.isEmpty());
}
 
Example 8
Project: customstuff4   File: ShiftClickRuleTest.java   View Source Code Vote up 5 votes
@Test
public void test_canApplyWithFilter() throws Exception
{
    ShiftClickRule rule = new ShiftClickRule();
    rule.from = new int[] {0, 3};
    rule.to = new int[] {5, 10};
    rule.filter = stack -> stack.getItem() == Items.APPLE;

    assertTrue(rule.canApply(0, new ItemStack(Items.APPLE)));
    assertFalse(rule.canApply(0, new ItemStack(Items.STICK)));
}
 
Example 9
Project: TheOink   File: OinkSausage.java   View Source Code Vote up 5 votes
@Override
public void onLivingUpdate() {
    super.onLivingUpdate();
    //Item stuff
    List<Item> listItems = ImmutableList.copyOf(Item.REGISTRY);
    //Random rand2 = new Random();
    int listSize = listItems.size();
    int randomInt = rand.nextInt(listSize);


    if(!this.world.isRemote && timeToDiamond == 0 || timeToDiamond == -1){
        Item item = new Item();
        if(!listItems.isEmpty()) {
            item = listItems.get(randomInt);
        }
        if(item.toString().equals("net.minecraft.item.null")){
            item = Items.APPLE;
        }

        this.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
        this.dropItem(item, 1);
        this.timeToDiamond = this.rand.nextInt(6000) + 6000;

    }

    if(!world.isRemote && timeToDiamond > 0){
        timeToDiamond--;
        //System.out.println("SAUSAGE Time set to:" + timeToDiamond);

        //System.out.println(item);
    }
}
 
Example 10
Project: CraftTweaker-Advancements   File: AdvancementManagerWrapper.java   View Source Code Vote up 5 votes
@Override
  public void reload() {

if (this.parent != null) {
	
	this.parent.reload();
}

CRTADV.log.info("Hooking into advancements. {} existing advancements found.", Iterables.size(AdvancementManager.ADVANCEMENT_LIST.getAdvancements()));

      Map<ResourceLocation, Advancement.Builder> map = new HashMap<>();
      TextComponentString hello = new TextComponentString("hello");
      ItemStack icon = new ItemStack(Items.APPLE);
      DisplayInfo inf = new DisplayInfo(icon, hello, hello, null, FrameType.GOAL, true, true, false);
      AdvancementRewards rewardsIn = new AdvancementRewards(5, new ResourceLocation[0], new ResourceLocation[0], FunctionObject.CacheableFunction.EMPTY);
      Map<String, Criterion> crit = new HashMap<>();
      crit.put("test", new Criterion(new PlacedBlockTrigger.Instance(Blocks.DIAMOND_BLOCK, null, LocationPredicate.ANY, ItemPredicate.ANY)));
      Advancement advancement = new Advancement(new ResourceLocation("test"), AdvancementManager.ADVANCEMENT_LIST.getAdvancement(new ResourceLocation("minecraft:story/upgrade_tools")), inf, rewardsIn, crit, new String[0][0]);
      map.put(new ResourceLocation("test"), advancement.copy());
      System.out.println(AdvancementManager.ADVANCEMENT_LIST.getAdvancements());
      AdvancementManager.ADVANCEMENT_LIST.loadAdvancements(map);
      System.out.println(AdvancementManager.ADVANCEMENT_LIST.getAdvancements());
      
      for (Advancement advancement1 : ADVANCEMENT_LIST.getRoots())
      {
          if (advancement1.getDisplay() != null)
          {
              AdvancementTreeNode.layout(advancement1);
          }
      }
      
CRTADV.log.info("{} advancements found.", Iterables.size(AdvancementManager.ADVANCEMENT_LIST.getAdvancements()));
  }
 
Example 11
Project: Backmemed   File: CreativeTabs.java   View Source Code Vote up 4 votes
public ItemStack getTabIconItem()
{
    return new ItemStack(Items.APPLE);
}
 
Example 12
Project: CustomWorldGen   File: CreativeTabs.java   View Source Code Vote up 4 votes
@SideOnly(Side.CLIENT)
public Item getTabIconItem()
{
    return Items.APPLE;
}