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


Java AnvilUpdateEvent.getRight方法代码示例

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


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

示例1: onAnvilUpdate

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

    if (left.getItem() instanceof IAnvilRepairable)
    {
        IAnvilRepairable repairable = (IAnvilRepairable) left.getItem();

        // Advanced Ender Alloy
        if (repairable.isRepairItem(left, right))
        {
            this.fullyRepairItem(event, repairable, 1, 15);
        }
        else if (right.getItem() == Items.ENCHANTED_BOOK)
        {
            this.enchantItem(event, repairable, (ItemEnchantedBook) right.getItem());
        }
        else
        {
            // Cancel vanilla behaviour, otherwise it would allow repairing tools with another tool (and lose the modules)
            event.setCanceled(true);
        }
    }
}
 
开发者ID:maruohon,项目名称:enderutilities,代码行数:27,代码来源:AnvilUpdateEventHandler.java

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

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

import net.minecraftforge.event.AnvilUpdateEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void anvilEvent(AnvilUpdateEvent event)
{
	ItemStack leftInput = event.getLeft();
	ItemStack rightInput = event.getRight();

	if (leftInput == null || rightInput == null)
	{
		return;
	}

	int[] ids = OreDictionary.getOreIDs(rightInput);
	for (int i = 0; i < ids.length; i++)
	{
		if (OreDictionary.getOreName(ids[i]).equals("ingotDarkSteel") || OreDictionary.getOreName(ids[i]).equals("blockDarkSteel"))
		{
			handleRepair(leftInput, rightInput, event);
			return;
		}
	}
	handleUpgrade(leftInput, rightInput, event);
}
 
开发者ID:VapourDrive,项目名称:Hammerz,代码行数:23,代码来源:AnvilEvent.java

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

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

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

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

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