本文整理汇总了Java中net.minecraftforge.event.AnvilUpdateEvent类的典型用法代码示例。如果您正苦于以下问题:Java AnvilUpdateEvent类的具体用法?Java AnvilUpdateEvent怎么用?Java AnvilUpdateEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnvilUpdateEvent类属于net.minecraftforge.event包,在下文中一共展示了AnvilUpdateEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
}
示例4: 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);
}
}
示例5: onRepairUpdate
import net.minecraftforge.event.AnvilUpdateEvent; //导入依赖的package包/类
@SubscribeEvent
public void onRepairUpdate(AnvilUpdateEvent event)
{
ItemStack right = event.right;
ItemStack left = event.left;
if (right.getItem().equals(TwistedSouls.Registry.SHARD) && left.getItem().equals(TwistedSouls.Registry.SHARD) && right.getItemDamage() != 0)
{
ItemStack output = new ItemStack(TwistedSouls.Registry.SHARD);
int rightKill = right.getMaxDamage() - right.getItemDamage();
int leftKill = left.getMaxDamage() - left.getItemDamage();
ItemShard.SoulData rightData = ItemShard.SoulData.deserialize(right);
ItemShard.SoulData leftData = ItemShard.SoulData.deserialize(left);
output.setTagCompound(right.getTagCompound());
output.setItemDamage(output.getMaxDamage() - (rightKill + leftKill));
event.output = output;
event.cost = leftData.getTier() + rightData.getTier();
}
}
示例6: 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);
}
}
}
示例7: reforge
import net.minecraftforge.event.AnvilUpdateEvent; //导入依赖的package包/类
@SubscribeEvent
public void reforge(AnvilUpdateEvent event) {
ItemStack right = event.right;
ItemStack left = event.left;
if (!ItemUtil.is(left, this)) return;
ItemStack held = get(left);
if (held == null) return;
ItemStack template = getRepairItem(held);
if (!ItemUtil.is(right, template.getItem())) return;
if (right.getItemDamage() != 0) return;
// Check for enchants? Previous repairs? Nah.
held.setItemDamage(0);
int oldCost = held.getRepairCost();
if (oldCost > 0) {
held.setRepairCost(oldCost / 2);
}
event.output = held.copy();
event.cost = 30;
event.materialCost = 1;
}
示例8: handleAnvilGem
import net.minecraftforge.event.AnvilUpdateEvent; //导入依赖的package包/类
public void handleAnvilGem(ItemStack leftInput, Item leftItem, ItemStack rightInput, Item rightItem, AnvilUpdateEvent event)
{
if (!(leftItem instanceof ItemEnchantmentGem) && rightItem instanceof ItemEnchantmentGem)
{
ItemEnchantmentGem gem = (ItemEnchantmentGem) rightItem;
if (!rightInput.isItemEnchanted())
{
if (leftItem.isItemTool(leftInput) && leftInput.getItemDamage() < (leftInput.getMaxDamage() / 4))
{
handleEnchantGem(leftInput, leftItem, rightInput, gem, event);
}
}
else if (rightInput.isItemEnchanted())
{
handleEnchantTool(leftInput, leftItem, rightInput, gem, event);
}
}
}
示例9: handleEnchantGem
import net.minecraftforge.event.AnvilUpdateEvent; //导入依赖的package包/类
public void handleEnchantGem(ItemStack toolStack, Item tool, ItemStack gemStack, ItemEnchantmentGem gem, AnvilUpdateEvent event)
{
Enchantment enchant = gem.getGemEnchantment();
int enchantID = enchant.effectId;
Map enchantMap = EnchantmentHelper.getEnchantments(toolStack);
if (enchantMap.containsKey(enchantID))
{
int level = ((Integer) enchantMap.get(enchantID));
ItemStack outputStack = new ItemStack(gem);
outputStack.addEnchantment(enchant, level);
event.output = outputStack;
event.cost = getEnchantmentCost(enchant, level);
event.materialCost = 1;
}
}
示例10: handleEnchantTool
import net.minecraftforge.event.AnvilUpdateEvent; //导入依赖的package包/类
public void handleEnchantTool(ItemStack toolStack, Item tool, ItemStack gemStack, ItemEnchantmentGem gem, AnvilUpdateEvent event)
{
Enchantment enchant = gem.getGemEnchantment();
int enchantID = enchant.effectId;
Map enchantMap = EnchantmentHelper.getEnchantments(gemStack);
if (!EnchantmentHelper.getEnchantments(toolStack).containsKey(enchantID) && enchantMap.containsKey(enchantID)
&& enchant.canApply(toolStack))
{
int level = ((Integer) enchantMap.get(enchantID));
ItemStack outputStack = toolStack.copy();
outputStack.addEnchantment(enchant, level);
event.output = outputStack;
event.cost = getEnchantmentCost(enchant, level);
event.materialCost = 1;
}
}
示例11: 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);
}
示例12: 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);
}
}
示例13: 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);
}
}
示例14: 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()));
}
示例15: 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));
}