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

The following examples show how to use net.minecraft.init.Items#APPLE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockSnowTest.java    From customstuff4 with GNU General Public License v3.0 7 votes vote down vote up
@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 2
Source File: ItemHelperTests.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@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}, 0);
    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 3
Source File: ItemHelperTests.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@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}, 0);
    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 4
Source File: DamageableShapelessOreRecipeTest.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
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 5
Source File: ShapelessRecipeTests.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@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
Source File: ShapedRecipeTests.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void test_addRecipe()
{
    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
Source File: ModGenuinePeoplePersonalities.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static boolean generateComplaint(StringType type, EntityPlayer player, ItemStack stack, EventData data) {
    switch (type) {
        case ACTIVATE:
            if (stack.getItem() == Items.APPLE) {
                switch (data.random.nextInt(5)) {
                    case 0:
                        player.sendMessage(new TextComponentString(obnoxious + "The apple screams, \"No! Think of my children!\""));
                        break;
                    case 1:
                        player.sendMessage(new TextComponentString(obnoxious + "The apple sobs mournfully as it is devoured."));
                        break;
                    case 2:
                        player.sendMessage(new TextComponentString(obnoxious + "The apple seems resigned to its oncoming demise."));
                        break;
                    case 3:
                    case 4:
                        player.sendMessage(new TextComponentString(obnoxious + "The apple seems resigned to its oncoming demise."));
                        break;
                }
                return true;
            } else if (stack.getItem() == Items.FISH || stack.getItem() == Items.PORKCHOP || stack.getItem() == Items.MUTTON || stack.getItem() == Items.BEEF) {
                player.sendMessage(new TextComponentString(obnoxious + String.format("The %s yells, \"Serves you right if you get sick! Bastard.\"", stack.getDisplayName())));
                return true;
            }
    }
    return false;
}
 
Example 8
Source File: ItemHelperTests.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@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}, 0);

    assertTrue(drops.isEmpty());
}
 
Example 9
Source File: ItemHelperTests.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test_getDroppedStacks_withFortune()
{
    BlockDrop drop1 = new BlockDrop(new WrappedItemStackConstant(new ItemStack(Items.APPLE)), IntRange.create(1, 1), IntRange.create(3, 3));

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

    assertEquals(7, stack1.getCount());
}
 
Example 10
Source File: ShiftClickRuleTest.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test_canApplyWithFilter()
{
    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)));
}