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