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


Java AnvilUpdateEvent.setCost方法代码示例

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


在下文中一共展示了AnvilUpdateEvent.setCost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: handleAnvilEvent

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void handleAnvilEvent(AnvilUpdateEvent event)
{
	if (SocketRecipe.isValidInput(event.getLeft(), event.getRight()))
	{
		ItemStack output = event.getLeft().copy();
		NBTTagCompound socketTag = (NBTTagCompound) output.getTagCompound().getTag("sockets");
		
		SocketUtil.setSocket(socketTag, "diamond", SocketUtil.getFirstAvailableSlotNumber(socketTag));
		
		output.getTagCompound().setTag("sockets", socketTag);
		
		event.setOutput(output);
		event.setCost(0);
	}
}
 
开发者ID:MikeLydeamore,项目名称:Jewelcrafting,代码行数:17,代码来源:AnvilEventHandler.java

示例3: onAnvilUpdate

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

    ItemStack shard = event.getLeft();
    ItemStack mat = event.getRight();
    ItemStack artifact = ModItems.brokenArtifact.getInnerStack(shard);
    if (!artifact.isEmpty() && mat.getItem() == artifact.getItem() && !mat.isItemDamaged()) {
        ItemStack innercopy = artifact.copy();
        innercopy.setItemDamage(0);
        innercopy.setRepairCost(innercopy.getRepairCost() / 2); //TODO: make this configurable??
        event.setOutput(innercopy);
        event.setCost(35);
    }
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:17,代码来源:ToolShardRepairHandler.java

示例4: AnvilUpdate

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void AnvilUpdate(AnvilUpdateEvent event)
{
	ItemStack rightItem = event.getRight();
	ItemStack leftItem = event.getLeft();
	
	if ((rightItem.getItem() == Item.getItemFromBlock(ModRegistry.CompressedStoneBlock())
			&& rightItem.getMetadata() == BlockCompressedStone.EnumType.TRIPLE_COMPRESSED_STONE.getMetadata())
		|| (leftItem.getItem() == Item.getItemFromBlock(ModRegistry.CompressedStoneBlock())
			&& leftItem.getMetadata() == BlockCompressedStone.EnumType.TRIPLE_COMPRESSED_STONE.getMetadata()))
	{
		if (rightItem.getItem() == ModRegistry.Bulldozer() || leftItem.getItem() == ModRegistry.Bulldozer())
		{
			event.setCost(4);
			ItemStack bulldozer = rightItem.getItem() == ModRegistry.Bulldozer() ? rightItem : leftItem;
							
			ItemStack outputStack = new ItemStack(ModRegistry.Bulldozer());
			ModRegistry.Bulldozer().setPoweredValue(outputStack, true);
			outputStack.setItemDamage(0);
			event.setOutput(outputStack);
		}
	}
}
 
开发者ID:Brian-Wuest,项目名称:MC-Prefab,代码行数:24,代码来源:ModEventHandler.java

示例5: 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

示例6: updateItemName

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
private void updateItemName(AnvilUpdateEvent event, ItemStack outputStack)
{
    String name = event.getName();

    if (StringUtils.isBlank(name) == false)
    {
        outputStack.setStackDisplayName(name);
        event.setCost(event.getCost() + 1);
    }
    else if (outputStack.hasDisplayName())
    {
        // Remove the custom name
        outputStack.clearCustomName();
        event.setCost(event.getCost() + 1);
    }
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:17,代码来源:AnvilUpdateEventHandler.java

示例7: handleAnvilEvent

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void handleAnvilEvent(AnvilUpdateEvent evt) {
  if (Prep.isInvalid(evt.getLeft()) || evt.getLeft().getCount() != 1 || evt.getLeft().getItem() != block_powered_spawner.getItem()) {
    return;
  }
  if (Prep.isInvalid(evt.getRight()) || evt.getRight().getCount() != 1 || evt.getRight().getItem() != ModObject.itemBrokenSpawner.getItem()) {
    return;
  }

  CapturedMob spawnerType = CapturedMob.create(evt.getRight());
  if (spawnerType == null || isBlackListed(spawnerType.getEntityName())) {
    return;
  }

  evt.setCost(SpawnerConfig.powerSpawnerAddSpawnerCost.get());
  evt.setOutput(evt.getLeft().copy());
  evt.getOutput().setTagCompound(spawnerType.toNbt(evt.getOutput().getTagCompound()));
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:19,代码来源:BlockPoweredSpawner.java

示例8: handleRepair

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
private static void handleRepair(AnvilUpdateEvent evt) {
  ItemStack targetStack = evt.getLeft();
  ItemStack ingots = evt.getRight();

  // repair event
  IDarkSteelItem targetItem = (IDarkSteelItem) targetStack.getItem();
  int maxIngots = targetItem.getIngotsRequiredForFullRepair();

  double damPerc = (double) targetStack.getItemDamage() / targetStack.getMaxDamage();
  int requiredIngots = (int) Math.ceil(damPerc * maxIngots);
  if (ingots.getCount() > requiredIngots) {
    return;
  }

  int damageAddedPerIngot = (int) Math.ceil((double) targetStack.getMaxDamage() / maxIngots);
  int totalDamageRemoved = damageAddedPerIngot * ingots.getCount();

  ItemStack resultStack = targetStack.copy();
  resultStack.setItemDamage(Math.max(0, resultStack.getItemDamage() - totalDamageRemoved));

  evt.setOutput(resultStack);
  evt.setCost(ingots.getCount() + (int) Math.ceil(getEnchantmentRepairCost(resultStack) / 2));
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:24,代码来源:DarkSteelRecipeManager.java

示例9: 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

示例10: onArtifactBreak

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onArtifactBreak(AnvilUpdateEvent event)
{
    if(event.getLeft().isEmpty() || event.getRight().isEmpty())
        return;

    ItemStack tool = event.getLeft();
    ItemStack mat = event.getRight();
    if(ItemUtil.isTool(tool.getItem()) && mat.getItem() == Items.FLINT)
    {
        event.setOutput(ModItems.brokenArtifact.makeFrom(tool));
        event.setCost(1);
    }
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:15,代码来源:ToolShardRepairHandler.java

示例11: 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

示例12: 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

示例13: handleUpgrade

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
private static void handleUpgrade(AnvilUpdateEvent evt) {
  for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) {
    if (upgrade.isUpgradeItem(evt.getRight()) && upgrade.canAddToItem(evt.getLeft())) {
      ItemStack res = new ItemStack(evt.getLeft().getItem(), 1, evt.getLeft().getItemDamage());
      final NBTTagCompound tagCompound = evt.getLeft().getTagCompound();
      if (tagCompound != null) {
        res.setTagCompound(tagCompound.copy());
      }
      upgrade.addToItem(res);
      evt.setOutput(res);
      evt.setCost(upgrade.getLevelCost());
      return;
    }
  }
}
 
开发者ID:SleepyTrousers,项目名称:EnderIO,代码行数:16,代码来源:DarkSteelRecipeManager.java

示例14: onAnvil

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

    AnvilRecipe eventIn = new AnvilRecipe(event.getLeft(), event.getRight(), event.getOutput(), event.getCost(), false);

    for(AnvilRecipe recipe : AnvilRecipes.getRecipes()){

        if(eventIn.equals(recipe)){

            event.setCost(recipe.getCost());
            event.setOutput(recipe.getOutput().copy());
            return;

        }

    }

}
 
开发者ID:lazerzes,项目名称:Anvil-Enchantments,代码行数:19,代码来源:EventListener.java

示例15: 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


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