当前位置: 首页>>代码示例>>Java>>正文


Java AnvilUpdateEvent.setMaterialCost方法代码示例

本文整理汇总了Java中net.minecraftforge.event.AnvilUpdateEvent.setMaterialCost方法的典型用法代码示例。如果您正苦于以下问题:Java AnvilUpdateEvent.setMaterialCost方法的具体用法?Java AnvilUpdateEvent.setMaterialCost怎么用?Java AnvilUpdateEvent.setMaterialCost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.AnvilUpdateEvent的用法示例。


在下文中一共展示了AnvilUpdateEvent.setMaterialCost方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: anvilChange

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void anvilChange(AnvilUpdateEvent ev)
{
    ItemStack left = ev.getLeft();
    ItemStack right = ev.getRight();
    if (left.getCount() <= 0 || left.getItem() != belt)
        return;
    if (right.getCount() <= 0 || right.getItem() != pouch)
        return;
    int cost = ItemToolBelt.getUpgradeXP(left);
    if (cost < 0)
    {
        ev.setCanceled(true);
        return;
    }
    ev.setCost(cost);
    ev.setMaterialCost(1);

    ev.setOutput(ItemToolBelt.upgrade(left));
}
 
开发者ID:gigaherz,项目名称:ToolBelt,代码行数:21,代码来源:ToolBelt.java

示例2: fullyRepairItem

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
private void fullyRepairItem(AnvilUpdateEvent event, IAnvilRepairable repairable, int materialCost, int xpCost)
{
    ItemStack repaired = event.getLeft().copy();

    if (repairable.repairItem(repaired, -1))
    {
        event.setMaterialCost(materialCost);
        event.setCost(xpCost);
        event.setOutput(repaired);

        this.updateItemName(event, repaired);
    }
    else
    {
        event.setCanceled(true);
    }
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:18,代码来源:AnvilUpdateEventHandler.java

示例3: eventAnvil

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void eventAnvil(AnvilUpdateEvent event) {

    // Check what items are in slot left & right
    if (event.getLeft() == null || event.getRight() == null) { return; }
    if (event.getLeft().getItem() instanceof ItemProgram && event.getLeft().getMetadata() == 0 && event.getRight().getItem() instanceof ItemNeedle && event.getRight().getMetadata() == 1) {

        //
        ItemStack output = new ItemStack(ModItems.sc_program, 1 ,1);
        NBTTagCompound nbt = output.getTagCompound();

        if (event.getRight().getTagCompound() == null || !event.getRight().getTagCompound().hasKey("entity")) { return; }
        if (nbt == null) { output.setTagCompound(nbt = new NBTTagCompound()); }

        String outputString = I18n.format("statclock.translate.program") + ": " + event.getRight().getTagCompound().getString("entity") + " " + I18n.format("statclock.translate.kills");

        nbt.setInteger(event.getRight().getTagCompound().getString("entity") + "Kills", 0);
        output.setTagCompound(nbt);
        output.setStackDisplayName("§6" + outputString);

        event.setOutput(output);
        event.setCost(1);
        event.setMaterialCost(1);

    }

}
 
开发者ID:lucidagrande,项目名称:statclock,代码行数:28,代码来源:EventProgram.java

示例4: onAnvilUpdate

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAnvilUpdate (AnvilUpdateEvent event) {
    for (final IAnvilRecipe recipe : MMDLibRegistry.getAnvilRecipes())
        if (recipe.isValidRecipe(event.getLeft(), event.getRight(), event.getName())) {
            event.setCost(recipe.getExperienceCost(event.getLeft(), event.getRight(), event.getName()));
            event.setMaterialCost(recipe.getMaterialCost(event.getLeft(), event.getRight(), event.getName()));
            event.setOutput(recipe.getOutput(event.getLeft(), event.getRight(), event.getName()));
            return;
        }
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:MMDLib-old,代码行数:11,代码来源:ForgeEventHandler.java

示例5: onAnvilUpdate

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAnvilUpdate (AnvilUpdateEvent event) {

    for (final IAnvilRecipe recipe : BookshelfRegistry.getAnvilRecipes()) {
        if (recipe.isValidRecipe(event.getLeft(), event.getRight(), event.getName())) {
            event.setCost(recipe.getExperienceCost(event.getLeft(), event.getRight(), event.getName()));
            event.setMaterialCost(recipe.getMaterialCost(event.getLeft(), event.getRight(), event.getName()));
            event.setOutput(recipe.getOutput(event.getLeft(), event.getRight(), event.getName()));
            return;
        }
    }
}
 
开发者ID:Darkhax-Minecraft,项目名称:Bookshelf,代码行数:13,代码来源:Bookshelf.java

示例6: handleUpgrade

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
public void handleUpgrade(ItemStack leftInput, ItemStack rightInput, AnvilUpdateEvent event)
{
	if (leftInput.getItem() == HZ_Items.ItemHammer && rightInput.func_190916_E() == 1 && HammerInfoHandler.isStackDarkSteelHammer(leftInput))
	{
		ItemStack Output = leftInput.copy();

		List<IUpgrade> upgrades = UpgradeManager.getInstance().getUpgradeList();
		Iterator<IUpgrade> iterator = upgrades.iterator();

		while (iterator.hasNext())
		{
			IUpgrade upgrade = iterator.next();
			if (rightInput.getItem() == upgrade.getItem().getItem() && rightInput.getItemDamage() == upgrade.getItem().getItemDamage())
			{
				NBTTagCompound tagCompound = RandomUtils.getNBT(Output);
				if (tagCompound.getInteger(ItemHammer.Key_Empower) == upgrade.getLevel() - 1)
				{
					tagCompound.setInteger(ItemHammer.Key_Empower, upgrade.getLevel());

					Output.setTagCompound(tagCompound);
					if(rightInput.getItem() instanceof IEnergyContainerItem)
					{
						IEnergyContainerItem item = (IEnergyContainerItem) rightInput.getItem();
						int energy = item.getEnergyStored(rightInput);
						if(Output.getItem() instanceof ItemHammer)
						{
							NBTTagCompound finalCompound = RandomUtils.getNBT(Output);
							int hammerEnergy = finalCompound.getInteger(ItemHammer.Tag_DarkSteelEnergy);
							if(hammerEnergy + energy > EnergyHandler.getMaxEnergyStored(Output))
							{
								finalCompound.setInteger(ItemHammer.Tag_DarkSteelEnergy, EnergyHandler.getMaxEnergyStored(Output));
							}
							else
							{
								finalCompound.setInteger(ItemHammer.Tag_DarkSteelEnergy, hammerEnergy + energy);
							}

						}
					}
					event.setCost(upgrade.getCost());
					event.setMaterialCost(1);
					event.setOutput(Output);
					return;
				}
			}
		}
	}

}
 
开发者ID:VapourDrive,项目名称:Hammerz,代码行数:50,代码来源:AnvilEvent.java

示例7: upgradeKits

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void upgradeKits(AnvilUpdateEvent event){
	if(!(event.getRight().getItem() instanceof ItemUpgradeKit)) return;

	int cost = 0;

	float f = (float)(event.getLeft().getMaxDamage() - event.getLeft().getItemDamage()) / (float)event.getLeft().getMaxDamage();

	if(f >= 0)
		cost = 10;
	if(f >= 0.1f)
		cost = 9;
	if(f >= 0.2f)
		cost = 8;
	if(f >= 0.3f)
		cost = 7;
	if(f >= 0.4f)
		cost = 6;
	if(f >= 0.5f)
		cost = 5;
	if(f >= 0.6f)
		cost = 4;
	if(f >= 0.7f)
		cost = 3;
	if(f >= 0.8f)
		cost = 2;
	if(f >= 0.9f)
		cost = 1;

	ItemStack stack = UpgradeKitRecipes.instance().getUpgrade((ItemUpgradeKit)event.getRight().getItem(), event.getLeft());

	if(!stack.isEmpty()){

		if(StringUtils.isNullOrEmpty(event.getName())){
			if(event.getLeft().hasDisplayName()){
				cost += 1;
				stack.clearCustomName();
			}
		} else if(!event.getName().equals(event.getLeft().getDisplayName())){
			cost += 1;
			stack.setStackDisplayName(event.getName());
		}

		for(int i : EnchantmentHelper.getEnchantments(event.getLeft()).values())
			cost += i;

		EnchantmentHelper.setEnchantments(EnchantmentHelper.getEnchantments(event.getLeft()), stack);
		stack.setCount(event.getLeft().getCount());
		event.setOutput(stack);
	}

	event.setMaterialCost(1);
	event.setCost(cost == 0 ? 1 : cost);
}
 
开发者ID:Shinoow,项目名称:AbyssalCraft,代码行数:55,代码来源:AbyssalCraftEventHooks.java

示例8: onAnvilEvent

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAnvilEvent(AnvilUpdateEvent event)
{
	Iterator iterator;
	String rightSlotItemName;
	int rightSlotItemDamage;
	String staffFragmentItemName;
	MobSettings mobConfig;

	if (event.getLeft() == null || event.getLeft().stackSize != 1 ||
	    event.getLeft().getItem() != (Item)ModItems.mobSpawningStaff ||
	    event.getRight() == null ||
	    !ItemNBTHelper.getString(event.getLeft(), Names.NBTTags.STAFF_MOB_TO_SPAWN).isEmpty())
	{
		return;
	}

	rightSlotItemName = Item.REGISTRY.getNameForObject(event.getRight().getItem()).toString();
	rightSlotItemDamage = event.getRight().getItemDamage();
	staffFragmentItemName = Item.REGISTRY.getNameForObject(ModItems.staffFragment).toString();
	iterator = MobList.mobList.values().iterator();

	while (iterator.hasNext())
	{
		mobConfig = (MobSettings)iterator.next();

		if (mobConfig.enableStaffCreationPrimaryItem && (mobConfig.staffCreationPrimaryItem.equals(rightSlotItemName)
		 && mobConfig.staffCreationPrimaryItemDamage == rightSlotItemDamage)
		 && event.getRight().stackSize >= mobConfig.staffCreationPrimaryItemAmount)
		{
			LogHelper.info("Primary item enabled for entity " + MobList.getKey(mobConfig));
			event.setOutput(event.getLeft().copy());
			ItemNBTHelper.setString(event.getOutput(), Names.NBTTags.STAFF_MOB_TO_SPAWN, MobList.getKey(mobConfig));
			event.getOutput().getItem().setMaxDamage(mobConfig.staffCreationPrimaryItemUses);
			event.setCost(mobConfig.staffCreationPrimaryItemLevels);
			event.setMaterialCost(mobConfig.staffCreationPrimaryItemAmount);
			return;
		}
		else if (mobConfig.enableStaffCreationSecondaryItem && (mobConfig.staffCreationSecondaryItem.equals(rightSlotItemName)
		  && mobConfig.staffCreationSecondaryItemDamage == rightSlotItemDamage)
		  && event.getRight().stackSize >= mobConfig.staffCreationSecondaryItemAmount)
		{
			LogHelper.info("Secondary item enabled for entity " + MobList.getKey(mobConfig));
			event.setOutput(event.getLeft().copy());
			ItemNBTHelper.setString(event.getOutput(), Names.NBTTags.STAFF_MOB_TO_SPAWN, MobList.getKey(mobConfig));
			event.getOutput().getItem().setMaxDamage(mobConfig.staffCreationSecondaryItemUses);
			event.setCost(mobConfig.staffCreationSecondaryItemLevels);
			event.setMaterialCost(mobConfig.staffCreationSecondaryItemAmount);
			return;
		}
		else if (Settings.General.enableStaffFragmentItem && (rightSlotItemName.equals(staffFragmentItemName)) && ItemNBTHelper.hasTag(event.getRight(), Names.NBTTags.FRAGMENT_IS_FOR_MOB)
		  && (event.getRight().stackSize >= mobConfig.staffFragmentAnvilAmount) && (ItemNBTHelper.getString(event.getRight(), Names.NBTTags.FRAGMENT_IS_FOR_MOB).equals(MobList.getKey(mobConfig))))
		{
			event.setOutput(event.getLeft().copy());
			ItemNBTHelper.setString(event.getOutput(), Names.NBTTags.STAFF_MOB_TO_SPAWN, ItemNBTHelper.getString(event.getRight(), Names.NBTTags.FRAGMENT_IS_FOR_MOB));
			event.getOutput().getItem().setMaxDamage(mobConfig.staffFragmentAnvilUses);
			event.setCost(mobConfig.staffFragmentAnvilLevels);
			event.setMaterialCost(mobConfig.staffFragmentAnvilAmount);
			return;
		}
	}
}
 
开发者ID:TheMuso,项目名称:MobsOnYourTerms,代码行数:63,代码来源:AnvilHandler.java


注:本文中的net.minecraftforge.event.AnvilUpdateEvent.setMaterialCost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。