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

The following examples show how to use net.minecraft.init.Items#GOLDEN_SWORD . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
	boolean foundJar = false;
	boolean foundSword = false;

	for (int i = 0; i < inv.getSizeInventory(); i++) {
		ItemStack stack = inv.getStackInSlot(i);
		if (stack.getItem() == ModItems.JAR_ITEM) {
			if (stack.getItemDamage() == 2)
				foundJar = true;

		} else if (stack.getItem() == Items.GOLDEN_SWORD)
			foundSword = true;
	}
	return foundJar && foundSword;
}
 
Example 2
@Nonnull
@Override
public NonNullList<ItemStack> getRemainingItems(@Nonnull InventoryCrafting inv) {
	NonNullList<ItemStack> remainingItems = ForgeHooks.defaultRecipeGetRemainingItems(inv);

	ItemStack sword;
	for (int i = 0; i < inv.getSizeInventory(); i++) {
		ItemStack stack = inv.getStackInSlot(i);
		if (stack.getItem() == Items.GOLDEN_SWORD) {
			sword = stack.copy();
			sword.setItemDamage(sword.getItemDamage() + 1);
			if (sword.getItemDamage() > sword.getMaxDamage()) sword = null;
			if (sword != null) {
				remainingItems.set(i, sword);
			}
			break;
		}
	}

	return remainingItems;
}
 
Example 3
@Override
public List<ItemStack> complete(QuestData quest, List<ItemStack> items) {
	if (!quest.getCompleted()) {
		return null;
	}

	Province province = loadProvince(quest.getPlayer().world, quest.getPlayer().getPosition());

	if (province == null || province.id == null || !province.id.equals(quest.getProvinceId())) {
		return null;
	}

	PlayerCivilizationCapability playerCiv = PlayerCivilizationCapabilityImpl.get(quest.getPlayer());

	playerCiv.adjustReputation(quest.getCiv(), new DataWrapper().setData(quest).getRewardRep());

	if (playerCiv.getReputation(province.civilization) > 100 && quest.getPlayer().world.rand.nextInt(10) > 8) {
		ItemStack sword = new ItemStack(Items.GOLDEN_SWORD);
		sword.setStackDisplayName("Golden Sword of " + province.name);
		items.add(sword);
	}

	List<ItemStack> rewards = getRewardItems(quest);
	if (rewards != null) {
		items.addAll(rewards);
	}

	return items;
}
 
Example 4
protected void addGoldenSword(QuestData data, List<ItemStack> in) {
	ItemStack sword = new ItemStack(Items.GOLDEN_SWORD);
	sword.addEnchantment(Enchantment.getEnchantmentByID(16), 5);
	sword.addEnchantment(Enchantment.getEnchantmentByID(21), 3);
	Province inProvince = PlayerCivilizationCapabilityImpl.get(data.getPlayer()).getInCivilization();
	if (inProvince.id.equals(data.getProvinceId())) {
		// TODO lang
		sword.setStackDisplayName("Golden Sword of " + inProvince.name);
	}
	in.add(sword);
}
 
Example 5
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);
	}
}