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

The following examples show how to use net.minecraft.init.Items#WOODEN_SWORD . 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: DamageableShapelessOreRecipeTest.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void test_useUpItem()
{
    DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"),
                                                                           new int[] {60}, new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD));
    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(3, new ItemStack(Items.WOODEN_SWORD));

    assertTrue(recipe.matches(inv, null));
    NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
    assertTrue(remaining.get(3).isEmpty());
}
 
Example 2
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 3
Source File: DamageableShapedOreRecipeTest.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void test_useUpItem()
{
    ShapedOreRecipe recipe = new DamageableShapedOreRecipe(new ResourceLocation("group"),
                                                           new int[] {60}, new ItemStack(Blocks.DIRT),
                                                           "A",
                                                           'A', new ItemStack(Items.WOODEN_SWORD));

    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);

    inv.setInventorySlotContents(0, new ItemStack(Items.WOODEN_SWORD));
    assertTrue(recipe.matches(inv, null));

    NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
    assertTrue(remaining.get(0).isEmpty());
}
 
Example 4
Source File: EntityFallenKnight.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
private ItemStack getSwordForLevel(int swordLevel) {
  ////have a better chance of not getting a wooden or stone sword
  if(swordLevel < 2) {
    swordLevel += rand.nextInt(isHardDifficulty() ? 3 : 2);
    swordLevel = Math.min(swordLevel, 2);
  }
  switch (swordLevel) {
  case 0:
    return new ItemStack(Items.WOODEN_SWORD);
  case 1:
    return new ItemStack(Items.STONE_SWORD);
  case 2:
    return new ItemStack(Items.IRON_SWORD);
  case 4:
    return new ItemStack(Items.DIAMOND_SWORD);
  }
  return new ItemStack(Items.IRON_SWORD);
}
 
Example 5
Source File: ItemWeapon.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack getSwordByQuality(Quality quality){
	switch (quality) {
	case DIAMOND: return new ItemStack(Items.DIAMOND_SWORD);
	case GOLD: return new ItemStack(Items.GOLDEN_SWORD);
	case IRON: return new ItemStack(Items.IRON_SWORD);
	case STONE: return new ItemStack(Items.STONE_SWORD);
	default: return new ItemStack(Items.WOODEN_SWORD);
	}
}