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

The following examples show how to use net.minecraft.init.Items#BOW . 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: FuelTests.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBurnTimeWithNbt()
{
    Fuel fuel = gson.fromJson("{ \"item\": {\"item\" : \"minecraft:bow\", \"nbt\":\"{AInt:1}\" }, \"burnTime\":1337 }", Fuel.class);
    fuel.init(InitPhase.PRE_INIT, new TestContentHelper("{}", TestContent.class));

    ItemStack stack = new ItemStack(Items.BOW);
    stack.setTagCompound(new NBTTagCompound());
    stack.getTagCompound().setInteger("AInt", 1);

    assertFalse(fuel.appliesToStack(new ItemStack(Items.BOW)));
    assertTrue(fuel.appliesToStack(stack));
}
 
Example 2
Source File: FuelTests.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBurnTimeWithWrongNbt()
{
    Fuel fuel = gson.fromJson("{ \"item\": {\"item\" : \"minecraft:bow\", \"nbt\":\"{AInt:1}\" }, \"burnTime\":1337 }", Fuel.class);
    fuel.init(InitPhase.PRE_INIT, new TestContentHelper("{}", TestContent.class));

    ItemStack stack = new ItemStack(Items.BOW);
    stack.setTagCompound(new NBTTagCompound());
    stack.getTagCompound().setInteger("AInt", 2);

    assertFalse(fuel.appliesToStack(stack));
}
 
Example 3
Source File: ShopkeeperTradesForFire.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack level2Bow() {
	ItemStack stack = new ItemStack(Items.BOW);
	stack.setStackDisplayName("Apollo Bow");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(48), 5);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(50), 1);
	return stack;
}
 
Example 4
Source File: ItemSpecialty.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack getBow(Random rand, Quality quality){
	
	ItemStack item = new ItemStack(Items.BOW);
	
	switch(quality){
	case WOOD:
	case STONE:
		item.addEnchantment(Enchant.getEnchant(Enchant.POWER), 1 + rand.nextInt(3));
		item.addEnchantment(Enchant.getEnchant(Enchant.UNBREAKING), 1);
		Loot.setItemName(item, "Yew Longbow");
		Loot.setItemLore(item, "Superior craftsmanship", TextFormat.DARKGREEN);
		return item;
	case IRON:
		item.addEnchantment(Enchant.getEnchant(Enchant.POWER), 1 + rand.nextInt(3));
		item.addEnchantment(Enchant.getEnchant(Enchant.UNBREAKING), 1 + rand.nextInt(3));
		Loot.setItemName(item, "Laminated Bow");
		Loot.setItemLore(item, "Highly polished", TextFormat.DARKGREEN);
		return item;
	case GOLD:
		item.addEnchantment(Enchant.getEnchant(Enchant.POWER), 3 + rand.nextInt(3));
		if(rand.nextBoolean()){
			item.addEnchantment(Enchant.getEnchant(Enchant.INFINITY), 1);
		}
		item.addEnchantment(Enchant.getEnchant(Enchant.UNBREAKING), 1 + rand.nextInt(3));
		Loot.setItemName(item, "Recurve Bow");
		Loot.setItemLore(item, "Beautifully crafted", TextFormat.DARKGREEN);
		return item;
	case DIAMOND:
		item.addEnchantment(Enchant.getEnchant(Enchant.POWER), 3 + rand.nextInt(3));
		item.addEnchantment(Enchant.getEnchant(Enchant.FLAME), 1);
		item.addEnchantment(Enchant.getEnchant(Enchant.INFINITY), 1);
		item.addEnchantment(Enchant.getEnchant(Enchant.UNBREAKING), getUnbreakingLevel(quality, rand));
		item.addEnchantment(Enchant.getEnchant(Enchant.MENDING), 1);
		Loot.setItemName(item, "Eldritch Bow");
		Loot.setItemLore(item, "Warm to the touch", TextFormat.DARKGREEN);
		return item;
	default:
		return null;
	}
}
 
Example 5
Source File: ShopkeeperTradesForWind.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private static ItemStack level1Bow() {
	ItemStack stack = new ItemStack(Items.BOW);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(49), 1);
	return stack;
}
 
Example 6
Source File: ShopkeeperTradesForWind.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private static ItemStack level2Bow() {
	ItemStack stack = new ItemStack(Items.BOW);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(49), 2);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(48), 1);
	return stack;
}
 
Example 7
Source File: ShopkeeperTradesForFire.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private static ItemStack level1Bow() {
	ItemStack stack = new ItemStack(Items.BOW);
	stack.setStackDisplayName("Agni Bow");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(50), 1);
	return stack;
}
 
Example 8
Source File: EssentialsMissingHandlerClient.java    From Cyberware with MIT License 4 votes vote down vote up
private void renderItemInFirstPerson(float partialTicks)
{
	ItemRenderer ir = mc.getItemRenderer();
	AbstractClientPlayer abstractclientplayer = mc.thePlayer;
	float f = abstractclientplayer.getSwingProgress(partialTicks);
	EnumHand enumhand = (EnumHand)Objects.firstNonNull(abstractclientplayer.swingingHand, EnumHand.MAIN_HAND);
	float f1 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks;
	float f2 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks;
	boolean flag = true;
	boolean flag1 = true;

	if (abstractclientplayer.isHandActive())
	{
		ItemStack itemstack = abstractclientplayer.getActiveItemStack();

		if (itemstack != null && itemstack.getItem() == Items.BOW) //Forge: Data watcher can desync and cause this to NPE...
		{
			EnumHand enumhand1 = abstractclientplayer.getActiveHand();
			flag = enumhand1 == EnumHand.MAIN_HAND;
			flag1 = !flag;
		}
	}

	rotateArroundXAndY(f1, f2);
	setLightmap();
	rotateArm(partialTicks);
	GlStateManager.enableRescaleNormal();

	ItemStack itemStackMainHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 3);
	ItemStack itemStackOffHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 4);
	float equippedProgressMainHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 5);
	float prevEquippedProgressMainHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 6);
	float equippedProgressOffHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 7);
	float prevEquippedProgressOffHand = ReflectionHelper.getPrivateValue(ItemRenderer.class, ir, 8);

	RenderCyberlimbHand.INSTANCE.itemStackMainHand = itemStackMainHand;
	RenderCyberlimbHand.INSTANCE.itemStackOffHand = itemStackOffHand;

	if (flag && !missingSecondArm)
	{
		float f3 = enumhand == EnumHand.MAIN_HAND ? f : 0.0F;
		float f5 = 1.0F - (prevEquippedProgressMainHand + (equippedProgressMainHand - prevEquippedProgressMainHand) * partialTicks);
		RenderCyberlimbHand.INSTANCE.leftRobot = hasRoboLeft;
		RenderCyberlimbHand.INSTANCE.rightRobot = hasRoboRight;
		RenderCyberlimbHand.INSTANCE.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.MAIN_HAND, f3, itemStackMainHand, f5);
	}

	if (flag1 && !missingArm)
	{
		float f4 = enumhand == EnumHand.OFF_HAND ? f : 0.0F;
		float f6 = 1.0F - (prevEquippedProgressOffHand + (equippedProgressOffHand - prevEquippedProgressOffHand) * partialTicks);
		RenderCyberlimbHand.INSTANCE.leftRobot = hasRoboLeft;
		RenderCyberlimbHand.INSTANCE.rightRobot = hasRoboRight;
		RenderCyberlimbHand.INSTANCE.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.OFF_HAND, f4, itemStackOffHand, f6);
	}

	GlStateManager.disableRescaleNormal();
	RenderHelper.disableStandardItemLighting();
}
 
Example 9
Source File: RenderWitherWitch.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public void doRenderLayer(EntityWitherWitch entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_,
        float p_177141_6_, float p_177141_7_, float scale) {
      ItemStack itemstack = entitylivingbaseIn.getHeldItem(EnumHand.MAIN_HAND);

      if (itemstack != null) {
        GlStateManager.color(1.0F, 1.0F, 1.0F);
        GlStateManager.pushMatrix();

        if (this.witchRenderer.getMainModel().isChild) {
          GlStateManager.translate(0.0F, 0.625F, 0.0F);
          GlStateManager.rotate(-20.0F, -1.0F, 0.0F, 0.0F);
          float f = 0.5F;
          GlStateManager.scale(f, f, f);
        }

        ((ModelWitch) this.witchRenderer.getMainModel()).villagerNose.postRender(0.0625F);
        GlStateManager.translate(-0.0625F, 0.53125F, 0.21875F);
        Item item = itemstack.getItem();
        Minecraft minecraft = Minecraft.getMinecraft();
      //TODO: method is gone, so skip?
//        if (item instanceof ItemBlock && minecraft.getBlockRendererDispatcher().isEntityBlockAnimated(Block.getBlockFromItem(item))) {
//          GlStateManager.translate(0.0F, 0.0625F, -0.25F);
//          GlStateManager.rotate(30.0F, 1.0F, 0.0F, 0.0F);
//          GlStateManager.rotate(-5.0F, 0.0F, 1.0F, 0.0F);
//          float f4 = 0.375F;
//          GlStateManager.scale(f4, -f4, f4);
//        } else 
          if (item == Items.BOW) {
          GlStateManager.translate(0.0F, 0.125F, -0.125F);
          GlStateManager.rotate(-45.0F, 0.0F, 1.0F, 0.0F);
          float f1 = 0.625F;
          GlStateManager.scale(f1, -f1, f1);
          GlStateManager.rotate(-100.0F, 1.0F, 0.0F, 0.0F);
          GlStateManager.rotate(-20.0F, 0.0F, 1.0F, 0.0F);
        } else if (item.isFull3D()) {
          if (item.shouldRotateAroundWhenRendering()) {
            GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
            GlStateManager.translate(0.0F, -0.0625F, 0.0F);
          }

          this.witchRenderer.transformHeldFull3DItemLayer();
          GlStateManager.translate(0.0625F, -0.125F, 0.0F);
          float f2 = 0.625F;
          GlStateManager.scale(f2, -f2, f2);
          GlStateManager.rotate(0.0F, 1.0F, 0.0F, 0.0F);
          GlStateManager.rotate(0.0F, 0.0F, 1.0F, 0.0F);
        } else {
          GlStateManager.translate(0.1875F, 0.1875F, 0.0F);
          float f3 = 0.875F;
          GlStateManager.scale(f3, f3, f3);
          GlStateManager.rotate(-20.0F, 0.0F, 0.0F, 1.0F);
          GlStateManager.rotate(-60.0F, 1.0F, 0.0F, 0.0F);
          GlStateManager.rotate(-30.0F, 0.0F, 0.0F, 1.0F);
        }

        GlStateManager.rotate(-15.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(40.0F, 0.0F, 0.0F, 1.0F);
        minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND);
        GlStateManager.popMatrix();
      }
    }
 
Example 10
Source File: EntityFallenKnight.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
private boolean isRanged() {
  ItemStack itemstack = getHeldItem(EnumHand.MAIN_HAND);
  return itemstack != null && itemstack.getItem() == Items.BOW;
}
 
Example 11
Source File: ItemWeapon.java    From minecraft-roguelike with GNU General Public License v3.0 3 votes vote down vote up
public static ItemStack getBow(Random rand, int level, boolean enchant){
	
	if(rand.nextInt(20 + (level * 10)) == 0){
		return ItemSpecialty.getRandomItem(Equipment.BOW, rand, level);
	}
	
	ItemStack bow = new ItemStack(Items.BOW);
	
	if(enchant && rand.nextInt(6 - level) == 0){
		Enchant.enchantItem(rand, bow, Enchant.getLevel(rand, level));
	}
	
	return bow;
	
}