Java 类net.minecraftforge.event.entity.player.AnvilRepairEvent 实例源码

项目:uniquecrops    文件:UCEventHandlerServer.java   
@SubscribeEvent
public void setUpgradeChance(AnvilRepairEvent event) {

    ItemStack output = event.getItemResult();
    EntityPlayer player = event.getEntityPlayer();
    if (output == null)
        return;
    if (player == null)
        return;

    if (player.worldObj.isRemote)
        return;

    if (output.getItem() instanceof IBookUpgradeable) {
        int upgradelevel = NBTUtils.getInt(output, ItemGeneric.TAG_UPGRADE, -1);
        if (upgradelevel == 10) {
            Random rand = new Random();
            if (rand.nextBoolean() == false && !player.worldObj.isRemote) {
                player.addChatMessage(new TextComponentString(TextFormatting.RED + "You attempt to refine this item, but it breaks.."));
                output.stackSize = 0;
            }
        }
    }
}
项目:VillagerTweaks    文件:WorldEventHandler.java   
/**
 * Fired when the player removes a "repaired" item from the Anvil's Output slot.
 * 
 */
@SubscribeEvent
public void onAnvilRepair(AnvilRepairEvent event)
{
    Item item1 = event.left == null ? null : event.left.getItem();
    Item item2 = event.right == null ? null : event.right.getItem();
    Item pumpkin = Item.getItemFromBlock(Blocks.pumpkin);

    // Check if the player combined a pumpkin and an enchanted book
    if (event.output.getItem() == pumpkin &&
            (item1 == pumpkin || item1 == Items.enchanted_book) &&
            (item2 == pumpkin || item2 == Items.enchanted_book)) {

        // Gives the achievement
        event.entityPlayer.triggerAchievement(MyAchievements.EnchantPumpkin);

    }

}
项目:Twisted-Souls    文件:CommonProxy.java   
@SubscribeEvent
public void onRepairUpdate(AnvilRepairEvent 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)
    {
        int rightKill = right.getMaxDamage() - right.getItemDamage();
        int leftKill = left.getMaxDamage() - left.getItemDamage();
        event.output.setTagCompound(right.getTagCompound());
        event.output.setItem(TwistedSouls.Registry.SHARD);
        event.output.setItemDamage(right.getMaxDamage() - (rightKill + leftKill));
    }
}
项目:CustomWorldGen    文件:ForgeHooks.java   
public static float onAnvilRepair(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
{
    AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);
    MinecraftForge.EVENT_BUS.post(e);
    return e.getBreakChance();
}
项目:TRHS_Club_Mod_2016    文件:ForgeHooks.java   
public static float onAnvilRepair(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
{
    AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);
    MinecraftForge.EVENT_BUS.post(e);
    return e.breakChance;
}
项目:CauldronGit    文件:ForgeHooks.java   
public static float onAnvilRepair(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
{
    AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);
    MinecraftForge.EVENT_BUS.post(e);
    return e.breakChance;
}
项目:Skills    文件:EventHandler.java   
@SubscribeEvent
public void onAnvilRepair(AnvilRepairEvent event)
{

}
项目:Cauldron    文件:ForgeHooks.java   
public static float onAnvilRepair(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
{
    AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);
    MinecraftForge.EVENT_BUS.post(e);
    return e.breakChance;
}
项目:Cauldron    文件:ForgeHooks.java   
public static float onAnvilRepair(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
{
    AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);
    MinecraftForge.EVENT_BUS.post(e);
    return e.breakChance;
}
项目:Cauldron    文件:ForgeHooks.java   
public static float onAnvilRepair(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
{
    AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);
    MinecraftForge.EVENT_BUS.post(e);
    return e.breakChance;
}