Java 类net.minecraftforge.fml.common.eventhandler.EventPriority 实例源码

项目:Loot-Slash-Conquer    文件:EventItemTooltip.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onItemTooltip(ItemTooltipEvent event)
{
    ArrayList<String> tooltip = (ArrayList<String>) event.getToolTip();
    ItemStack stack = event.getItemStack();
    NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);

    if (event.getEntityPlayer() != null)
    {
        PlayerInformation info = (PlayerInformation) event.getEntityPlayer().getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);

        if (info != null && (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemLEMagical || stack.getItem() instanceof ItemLEBauble))
        {
            Rarity rarity = Rarity.getRarity(nbt);

            if (rarity != Rarity.DEFAULT)
            {
                if (stack.getItem() instanceof ItemSword) drawMelee(tooltip, stack, nbt, event.getEntityPlayer(), info);
                else if (stack.getItem() instanceof ItemArmor) drawArmor(tooltip, stack, nbt, event.getEntityPlayer(), info);
                else if (stack.getItem() instanceof ItemLEMagical) drawMagical(tooltip, stack, nbt, event.getEntityPlayer(), info);
                else if (stack.getItem() instanceof ItemLEBauble) drawBauble(tooltip, stack, nbt, event.getEntityPlayer(), info);
            }
        }
    }
}
项目:Loot-Slash-Conquer    文件:EventLivingHurtAttack.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onLivingAttack(LivingAttackEvent event)
{
    /*
     * Player attacks a monster OR another player
     */
    if (event.getSource().getTrueSource() instanceof EntityPlayer && !event.getSource().getTrueSource().getEntityWorld().isRemote)
    {
        EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
        EntityLivingBase enemy = event.getEntityLiving();
        ItemStack stack = player.inventory.getCurrentItem();
        PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);

        if (playerInfo != null && stack != null && stack.getItem() instanceof ItemSword && !(stack.getItem() instanceof ItemLEAdvancedMelee))
        {
            NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);

            if (playerInfo.getPlayerLevel() >= nbt.getInteger("Level"))
            {
                useWeaponAttributes(event.getAmount(), player, enemy, stack, nbt);
            }
        }
    }
}
项目:BetterThanLlamas    文件:BetterThanLlamas.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onInitGuiPost(GuiScreenEvent.InitGuiEvent.Post event)
{
    if(!hasShownFirstGui)
    {
        hasShownFirstGui = true;

        //Add the layer renderers
        Render renderer = Minecraft.getMinecraft().getRenderManager().getEntityClassRenderObject(EntityLlama.class);
        if(renderer instanceof RenderLlama)
        {
            RenderLlama renderLlama = (RenderLlama)renderer;
            renderLlama.addLayer(new LayerFancyLlama(renderLlama));
        }
    }
}
项目:CharcoalPit    文件:PileIgnitr.java   
@SubscribeEvent(priority=EventPriority.HIGH)
public void placeKiln(PlayerInteractEvent.RightClickBlock event){
    if(event.getWorld().getBlockState(event.getPos()).getBlock()==BlocksRegistry.potteryKiln){
        event.setUseBlock(Result.ALLOW);
    }else if(!event.isCanceled()&&event.getEntityPlayer().isSneaking()&&PotteryKilnRecipe.isValidInput(event.getItemStack())){
        if(event.getFace()==EnumFacing.UP&&event.getWorld().getBlockState(event.getPos()).isSideSolid(event.getWorld(), event.getPos(), EnumFacing.UP)&&
                event.getWorld().getBlockState(event.getPos().offset(EnumFacing.UP)).getBlock().isReplaceable(event.getWorld(), event.getPos().offset(EnumFacing.UP))){
            if(!event.getWorld().isRemote){
                event.getWorld().setBlockState(event.getPos().offset(EnumFacing.UP), BlocksRegistry.potteryKiln.getDefaultState());
                TilePotteryKiln tile=((TilePotteryKiln)event.getWorld().getTileEntity(event.getPos().offset(EnumFacing.UP)));
                event.getEntityPlayer().setHeldItem(event.getHand(), tile.pottery.insertItem(0, event.getItemStack(), false));
                event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_GRAVEL_PLACE, SoundCategory.BLOCKS, 1F, 1F);
                event.getWorld().notifyBlockUpdate(event.getPos().offset(EnumFacing.UP), BlocksRegistry.potteryKiln.getDefaultState(), BlocksRegistry.potteryKiln.getDefaultState(), 2);
            }
            event.setUseBlock(Result.DENY);
            event.setUseItem(Result.DENY);
        }
    }
}
项目:Never-Enough-Currency    文件:KeybindHandler.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public static void onEvent(KeyInputEvent event) {
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.player;

    CartCapability entityData = player.getCapability(Currency.CART_DATA, null);

    boolean isEmpty = true;

    if (entityData != null && entityData.getCart() != null) {
        for (ItemStack stack : entityData.getCart()) {
            if (!stack.isEmpty()) {
                isEmpty = false;
            }
        }
    }

    if (!isEmpty && openList.isPressed()) {
        Minecraft.getMinecraft().player.openGui(Currency.INSTANCE, 5, mc.world, (int) player.posX, (int) player.posY, (int) player.posZ);
    }
}
项目:AuthMod    文件:CommandEvents.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
  public void CommandEvents(CommandEvent evt) {

    if(Main.debug==1)System.out.println(evt.getSender().getName() + " called Command " + evt.getSender().toString());


    if(evt.getSender() instanceof EntityPlayer){
    if(!Main.logged.contains(evt.getSender().getName())){
        //System.out.println(evt.getCommand().getCommandName().toString());
        if(!evt.getCommand().getCommandName().toString().contains("login") && !evt.getCommand().getCommandName().toString().contains("register")){
        evt.setCanceled(true);
        if(Main.passwords.containsKey(evt.getSender().getName())){
            evt.getSender().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("loginmessage")));
        } else {
        evt.getSender().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("registermessage")));
        }
        } 
    }
    }
}
项目:AuthMod    文件:PlayerLoggedOut.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
 public void PlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent evt) {

if(Main.debug==1)System.out.println(evt.player.getName() + " called PlayentLoggedOut");
MinecraftServer minecraftServer = FMLServerHandler.instance().getServer();
String brut = minecraftServer.getPlayerList().getPlayerByUsername(evt.player.getName()).connection.getNetworkManager().getRemoteAddress().toString().replaceAll("/", "");
int lenght = brut.length();
brut = brut.substring(0, lenght-6);


if(Integer.parseInt((String) Main.config.get("iplogin")) > 0 && !Main.ips.containsKey(brut) && Main.logged.contains(evt.player.getName())){
    Main.ips.put(brut, 0);
    }


Main.logged.remove(evt.player.getName());
Main.posX.remove(evt.player.getName());
Main.posY.remove(evt.player.getName());
Main.posZ.remove(evt.player.getName());
Main.time.remove(evt.player.getName());
}
项目:FirstAid    文件:EventHandler.java   
@SubscribeEvent(priority = EventPriority.LOW)
public static void onHeal(LivingHealEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    if (!entity.hasCapability(CapabilityExtendedHealthSystem.INSTANCE, null))
        return;
    event.setCanceled(true);
    if (!FirstAid.activeHealingConfig.allowOtherHealingItems)
        return;
    float amount = event.getAmount();
    //Hacky shit to reduce vanilla regen
    if (FirstAid.activeHealingConfig.allowNaturalRegeneration && Arrays.stream(Thread.currentThread().getStackTrace()).anyMatch(stackTraceElement -> stackTraceElement.getClassName().equals(FoodStats.class.getName())))
        amount = amount * (float) FirstAid.activeHealingConfig.naturalRegenMultiplier;
    else
        amount = amount * (float) FirstAid.activeHealingConfig.otherRegenMultiplier;
    HealthDistribution.distributeHealth(amount, (EntityPlayer) entity, true);
}
项目:Adventurers-Toolbox    文件:SpecialToolAbilityHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWitherBoneHarvestEvent(BlockEvent.HarvestDropsEvent event) {
    if (event.getHarvester() == null) {
        return;
    }

    EntityPlayer player = event.getHarvester();
    ItemStack stack = player.getHeldItemMainhand();

    boolean flag = false;

    if (stack.getItem() instanceof IHaftTool) {
        if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) {
            flag = true;
        }
    }

    if (flag) {
        if (player.dimension != DimensionType.NETHER.getId()) {
            stack.damageItem(7, player);
        }
    }
}
项目:ItemZoom    文件:EventHandler.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void onGuiKeyboardEvent(GuiScreenEvent.KeyboardInputEvent.Post event) {
    if (Keyboard.getEventKeyState()) {
        int eventKey = Keyboard.getEventKey();
        if (KeyBindings.TOGGLE.isActiveAndMatches(eventKey)) {
            Config.toggleEnabled();
            event.setCanceled(true);
        } else if (KeyBindings.ZOOM_IN.isActiveAndMatches(eventKey)) {
            Config.increaseZoom();
            event.setCanceled(true);
        } else if (KeyBindings.ZOOM_OUT.isActiveAndMatches(eventKey)) {
            Config.decreaseZoom();
            event.setCanceled(true);
        }
    }
}
项目:ItemZoom    文件:EventHandler.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void onItemStackTooltip(RenderTooltipEvent.Pre event) {
    if (!Config.isToggledEnabled() && !isEnableKeyHeld()) {
        return;
    }
    ItemStack itemStack = event.getStack();
    //noinspection ConstantConditions
    if (itemStack == null || itemStack.isEmpty()) {
        return;
    }
    if (Config.isJeiOnly() && !ItemStack.areItemStacksEqual(itemStack, JeiCompat.getStackUnderMouse())) {
        return;
    }

    Minecraft minecraft = Minecraft.getMinecraft();
    GuiScreen currentScreen = minecraft.currentScreen;
    if (currentScreen instanceof GuiContainer) {
        GuiContainer guiContainer = (GuiContainer) currentScreen;
        renderZoomedStack(itemStack, guiContainer, minecraft);
    }
}
项目:TextDisplayer    文件:CPSParser.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void onTick(TickEvent.RenderTickEvent event) {
    if (TextDisplayerMod.getInstance().getWebsiteUtils().isDisabled()) return;

    boolean isClickedLeft = Mouse.isButtonDown(0);
    if (isClickedLeft != this.lastLeft) {
        this.lastLeft = isClickedLeft;
        if (isClickedLeft) {
            this.leftClicks.add(System.currentTimeMillis());
        }
    }

    boolean isClickedRight = Mouse.isButtonDown(1);
    if (isClickedRight != this.lastRight) {
        this.lastRight = isClickedRight;
        if (isClickedRight) {
            this.rightClicks.add(System.currentTimeMillis());
        }
    }
}
项目:Mods    文件:TF2EventsCommon.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void craftItem(net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent event) {
    ItemStack withPattern=ItemStack.EMPTY;
    ItemStack noPattern=ItemStack.EMPTY;
    for(int i=0; i<event.craftMatrix.getSizeInventory();i++){
        ItemStack stack=event.craftMatrix.getStackInSlot(i);
        if(!stack.isEmpty() && stack.getItem() instanceof ItemBanner){
            if(TileEntityBanner.getPatterns(stack)>0){
                withPattern=stack;
            }
            else{
                noPattern=stack;
            }
            if(!withPattern.isEmpty()&&!noPattern.isEmpty()){
                withPattern.shrink(1);
            }
        }
    }
}
项目:World-Border    文件:EnderPearlListener.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerPearl(EnderTeleportEvent event)
{
    if ( !(event.getEntityLiving() instanceof EntityPlayerMP) )
        return;

    if ( Config.getKnockBack() == 0.0 || !Config.getDenyEnderpearl() )
        return;

    EntityPlayerMP player = (EntityPlayerMP) event.getEntityLiving();
    Log.trace( "Caught pearl teleport event by %s", player.getDisplayName() );

    Location target = new Location(event, player);
    Location newLoc = BorderCheck.checkPlayer(player, target, true, true);

    if (newLoc != null)
    {
        event.setCanceled(true);
        event.setTargetX(newLoc.posX);
        event.setTargetY(newLoc.posY);
        event.setTargetZ(newLoc.posZ);
    }
}
项目:Better-Than-Bunnies    文件:BetterThanBunnies.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onInitGuiPost(GuiScreenEvent.InitGuiEvent.Post event)
{
    if(!hasShownFirstGui)
    {
        hasShownFirstGui = true;

        //Add the layer renderers
        Render renderer = Minecraft.getMinecraft().getRenderManager().getEntityClassRenderObject(EntityRabbit.class);
        if(renderer instanceof RenderRabbit)
        {
            RenderRabbit renderRabbit = (RenderRabbit)renderer;
            renderRabbit.addLayer(new LayerFancyBunny(renderRabbit));
        }
    }
}
项目:BetterWithAddons    文件:RenewablesHandler.java   
@SubscribeEvent(priority = EventPriority.HIGH)
@SideOnly(Side.CLIENT)
public void renderQuartzTooltip(ItemTooltipEvent event)
{
    ItemStack stack = event.getItemStack();
    if(stack == null)
        return;
    NBTTagCompound compound = stack.getTagCompound();

    if(!stack.isEmpty() && compound != null && compound.hasKey("QuartzCrystal"))
    {
        int growth = compound.getInteger("QuartzCrystalGrowth");
        int souls = compound.getInteger("QuartzSouls");
        event.getToolTip().add(TextFormatting.LIGHT_PURPLE+getSaturationString(growth,false));
        if(souls > 0)
            event.getToolTip().add(TextFormatting.DARK_RED+getSoulString(souls,27,false));
    }
}
项目:BetterWithAddons    文件:JapaneseMobHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void japaneseDeath(LivingDeathEvent event)
{
    EntityLivingBase living = event.getEntityLiving();
    World world = living.world;
    if(!event.isCanceled() && !world.isRemote && living.hasCapability(JAPANESE_MOB_CAP,null))
    {
        JapaneseMob japaneseMob = living.getCapability(JAPANESE_MOB_CAP,null);
        int i = japaneseMob.spirits;

        while (i > 0)
        {
            int j = EntitySpirit.getSpiritSplit(i);
            i -= j;
            world.spawnEntity(new EntitySpirit(world, living.posX, living.posY, living.posZ, j));
        }
    }
}
项目:BetterWithAddons    文件:RotHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
@SideOnly(Side.CLIENT)
public void onToolTip(ItemTooltipEvent event)
{
    ItemStack stack = event.getItemStack();

    if(isRottingItem(stack))
    {
        long timeOfCreation = getCreationDate(stack);
        if(timeOfCreation == -1)
            return;

        for(RotInfo info : rottingItems.get(stack.getItem())) {
            if(info.matches(stack)) {
                String prefix =  I18n.format(info.getUnlocalizedName(stack, timeOfCreation));
                if(prefix.length() > 0)
                    prefix = prefix + " ";

                event.getToolTip().set(0,prefix + event.getToolTip().get(0));
                break;
            }
        }
    }
}
项目:CraftingHarmonics    文件:EventHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerInteractEvent(PlayerInteractEvent.RightClickBlock evt) {
    // Called when right clicking on a block (potentially with something...)
    if(evt.isCanceled()) return;

    // Check if we're cancelling, or if our interaction handler says we should cancel:
    if (!ItemRegistry.instance.shouldCancelUse(evt) && BlockRegistry.instance.handleInteraction(evt)) return;

    evt.setUseItem(Event.Result.DENY);
    evt.setUseBlock(Event.Result.ALLOW);
    evt.setCanceled(true);

    // The game ends up firing the RightClickItem event as well; we set this here to make sure
    // we don't end up doing all the checks/callbacks a second time in that event:
    debounceItemRightClick.set(true);
}
项目:DrawersBits    文件:PlayerEventHandler.java   
@SubscribeEvent(priority = EventPriority.HIGH)
public void interaction(
        final PlayerInteractEvent.LeftClickBlock event )
{
    if (BitDrawers.config.debugTrace) {
        Vec3d vec = event.getHitVec();
        BDLogger.info("Left Click %s %s %f %f %f", resultToString(event.getUseItem()), resultToString(event.getUseBlock()), vec.xCoord, vec.yCoord, vec.zCoord);
    }
    if ( event.getEntityPlayer() != null && event.getUseItem() != Event.Result.DENY )
    {
        final ItemStack is = event.getItemStack();
        if ( is != null && (is.getItem() instanceof ItemChiseledBit) && event.getWorld().isRemote)
        {
            Block target = event.getWorld().getBlockState(event.getPos()).getBlock();
            if (target instanceof BlockBitDrawers) {
                target.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer());
            }
            if (BitDrawers.config.debugTrace)
                BDLogger.info("Bit Left Click");
        }
    }
}
项目:Limited-Lives    文件:EventHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerDeath(LivingDeathEvent event)
{
    if(!event.getEntityLiving().getEntityWorld().isRemote && event.getEntityLiving() instanceof EntityPlayer && !(event.getEntityLiving() instanceof FakePlayer))
    {
        EntityPlayerMP player = (EntityPlayerMP)event.getEntityLiving();
        if(player.interactionManager.getGameType() == GameType.CREATIVE || player.interactionManager.getGameType() == GameType.SPECTATOR)
        {
            return;
        }
        NBTTagCompound tag = EntityHelper.getPlayerPersistentData(player, "LimitedLivesSave");
        int prevDeaths = tag.getInteger("deathCount");
        int liveCount = tag.getInteger("maxLives");
        if(liveCount == 0)
        {
            liveCount = LimitedLives.maxLives;
        }
        tag.setDouble("healthOffset", event.getEntityLiving().getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue() - (20D - (20D * prevDeaths / (double)liveCount)));
        tag.setInteger("deathCount", prevDeaths + 1);
        tag.setInteger("maxLives", LimitedLives.maxLives);
    }
}
项目:ExNihiloAdscensio    文件:HandlerHammer.java   
@SubscribeEvent(priority=EventPriority.LOWEST)
public void hammer(BlockEvent.HarvestDropsEvent event)
{
    if (event.getWorld().isRemote || event.getHarvester() == null || event.isSilkTouching())
        return;

    ItemStack held = event.getHarvester().getHeldItemMainhand();

    if (!isHammer(held))
        return;

    List<ItemStack> rewards = HammerRegistry.getRewardDrops(event.getWorld().rand, event.getState(), ((IHammer) held.getItem()).getMiningLevel(held), event.getFortuneLevel());

    if (rewards != null && rewards.size() > 0)
    {
        event.getDrops().clear();
        event.setDropChance(1.0F);
        event.getDrops().addAll(rewards);
    }
}
项目:Event-Tweaks    文件:ForestEventHandlers.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void HarvestDropsEvent(BlockEvent.HarvestDropsEvent e){
    try {
        if (e != null && e.getHarvester() == null && !e.getDrops().isEmpty() && ((e.getState().getBlock().equals(Blocks.LEAVES))
                || e.getState().getBlock().equals(Blocks.LEAVES2)) && !e.getWorld().isRemote) {
            Block block = Block.getBlockFromItem(e.getDrops().get(0).getItem());
            int meta = e.getDrops().get(0).getMetadata();
            BlockPos pos = findGround(e.getWorld(), e.getPos());
            if (pos != null && e.getWorld() != null) {
                e.getWorld().setBlockState(pos, block.getStateFromMeta(meta));
                deleteCopySapling(e.getWorld(), pos, Item.getItemFromBlock(block));
            }
        }
    }catch(Throwable throwable){
        System.out.println("    EXCEPTION FOUND IN EVENT TWEAKS FOREST REPLANTING: PLEASE REPORT LOGS TO EVENT TWEAKS WITH INFORMATION ON REPRODUCING");
        throwable.printStackTrace();
    }
}
项目:TFICore    文件:EventRainOverride.java   
@SubscribeEvent(priority = EventPriority.NORMAL)
public void rainOverrideGR (TickEvent.ServerTickEvent event) {
    WorldInfo worldinfo = GameInfo.worldInfo;
    GameRules gameRules = GameInfo.gameRules;

    try {
        if (!gameRules.getBoolean("doWeather")) {
            gameRules.setOrCreateGameRule("doWeather", "true");
            gameRules.setOrCreateGameRule("doWeatherCycle", "false");
            LogHelper.info("Switched weather GameRule over to Vanilla GameRule.");
        }
    }
    catch (Exception e) {
        LogHelper.error("Exception in RainOverride: " + e);
    }
}
项目:Factorization    文件:BlockUndo.java   
@SubscribeEvent(priority = EventPriority.LOWEST) // Act after any cancellations
public void recordBlock(BlockEvent.PlaceEvent event) {
    IBlockState bs = event.placedBlock;
    Block block = bs.getBlock();
    if (event.player == null) return;
    if (event.world.isRemote) return;
    if (event.player instanceof FakePlayer) return;
    if (block.getBlockHardness(event.world, event.pos) <= 0F) return;
    if (PlayerUtil.isPlayerCreative(event.player)) return;

    int idmd = hash(bs);
    final ItemStack theItem = toItem(block, event.world, event.pos, bs);
    final PlacedBlock at = new PlacedBlock(FzUtil.getWorldDimension(event.world), event.pos, idmd, theItem);
    markPlacement(event.player, at);
    if (event.player instanceof EntityPlayerMP) {
        send(event.player, at);
    }
}
项目:Gravestone-mod-Extended    文件:GSEventsHandler.java   
@SubscribeEvent(priority = EventPriority.HIGH)
public void onEntityLivingDeath(LivingDeathEvent event) {
    if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
        if (ExtendedConfig.spawnSkullCrawlersAtMobsDeath) {
            if (event.getEntity() instanceof AbstractSkeleton) {
                EntitySkullCrawler crawler;
                if (MobSpawn.isWitherSkeleton((AbstractSkeleton) event.getEntity())) {
                    crawler = new EntityWitherSkullCrawler(event.getEntity().getEntityWorld());
                } else if (MobSpawn.isStraySkeleton((AbstractSkeleton) event.getEntity())) {
                    crawler = new EntityStraySkullCrawler(event.getEntity().getEntityWorld());
                } else {
                    crawler = new EntitySkullCrawler(event.getEntity().getEntityWorld());
                }
                MobSpawn.spawnCrawler(event.getEntity(), crawler);
            } else if (event.getEntity() instanceof EntityZombie) {
                MobSpawn.spawnCrawler(event.getEntity(), new EntityZombieSkullCrawler(event.getEntity().getEntityWorld()));
            }
        }
        if (event.getEntity() instanceof EntityCreeper && ((EntityCreeper) event.getEntity()).getPowered()) {
            // drop creeper statue if entity is a charged creeper
            GSBlock.MEMORIAL.dropCreeperMemorial(event.getEntity().getEntityWorld(), new BlockPos(event.getEntity()));
        }
    }
}
项目:Gravestone-mod-Extended    文件:GSEventsHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void itemFishedEvent(ItemFishedEvent event) {
    ItemStack stack = event.getEntityPlayer().getHeldItemMainhand();

    if (!stack.isEmpty()) {
        NBTTagList nbtList = stack.getEnchantmentTagList();
        for (NBTBase nbt : nbtList) {
            if (((NBTTagCompound) nbt).getInteger("id") == Enchantment.getEnchantmentID(GSEnchantment.CURSE_BROKEN_HOOK)) {
                if (EnchantmentBrokenHookCurse.cancelFishing()) {
                    event.setCanceled(true);
                }
                break;
            }
        }
    }
}
项目:SAO-UI---1.8    文件:IngameGUI.java   
@Override
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled=true)
protected void renderExperience(int width, int height) {
    if (OptionCore.REMOVE_HPXP.getValue() || pre(EXPERIENCE)) return;
    if (!OptionCore.FORCE_HUD.getValue() && !this.mc.playerController.shouldDrawHUD()) return;
    mc.mcProfiler.startSection("expLevel");

    final int offsetR = OptionCore.SAO_UI.getValue() ? HPXP_OFFSET_ORIG_R : HPXP_OFFSET_ALO_R;
    final int offsetD = OptionCore.SAO_UI.getValue() ? HPXP_OFFSET_ORIG_D : HPXP_OFFSET_ALO_D;
    final int offsetHealth = offsetUsername + 113 + (healthBoxes + 2) * 5 + offsetR;
    final String levelStr = StatCollector.translateToLocal("displayLvShort") + ": " + String.valueOf(mc.thePlayer.experienceLevel);
    final int levelStrWidth = fontRenderer.getStringWidth(levelStr);
    final int levelBoxes = (levelStrWidth + 4) / 5;

    GLCore.glAlphaTest(true);
    GLCore.glBlend(true);
    GLCore.glBindTexture(OptionCore.SAO_UI.getValue() ? StringNames.gui : StringNames.guiCustom);
    GLCore.glTexturedRect(offsetHealth, 13 + offsetD, zLevel, 5, 13, 66, 15, 2, 13);
    GLCore.glTexturedRect(offsetHealth + 5, 13 + offsetD, zLevel, levelBoxes * 5, 13, 66, 15, 5, 13);
    GLCore.glTexturedRect(offsetHealth + (1 + levelBoxes) * 5, 13 + offsetD, zLevel, 5, 13, 78, 15, 3, 13);
    GLCore.glString(levelStr, offsetHealth + 5, 16 + offsetD, 0xFFFFFFFF, true);

    mc.mcProfiler.endSection();
    post(EXPERIENCE);
}
项目:DynamicSurroundings    文件:SoundManagerReplacement.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void diagnostics(final DiagnosticEvent.Gather event) {
    final TObjectIntHashMap<String> counts = new TObjectIntHashMap<String>();

    final Iterator<Entry<String, ISound>> iterator = this.playingSounds.entrySet().iterator();
    while (iterator.hasNext()) {
        Entry<String, ISound> entry = iterator.next();
        ISound isound = entry.getValue();
        counts.adjustOrPutValue(isound.getSound().getSoundLocation().toString(), 1, 1);
    }

    final ArrayList<String> results = new ArrayList<String>();
    final TObjectIntIterator<String> itr = counts.iterator();
    while (itr.hasNext()) {
        itr.advance();
        results.add(String.format(TextFormatting.GOLD + "%s: %d", itr.key(), itr.value()));
    }
    Collections.sort(results);
    event.output.addAll(results);

}
项目:CraftingHarmonics    文件:EventHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerInteract(PlayerInteractEvent.EntityInteract evt) {
    if(evt.isCanceled()) return;

    // If we're cancelling on this thread...
    Boolean debounce = debounceEntityInteract.get();
    if(debounce != null && debounce) {
        debounceEntityInteract.set(false);
        evt.setCanceled(true);
        return;
    }

    // We don't care about offhands if we're not cancelling them...
    if(evt.getHand() == EnumHand.OFF_HAND) return;

    // If we pass the check, then we can allow the event to go through...
    if(EntityRegistry.allowInteractionBetween(evt.getTarget(), evt.getEntityPlayer())) return;

    // Otherwise, cancel, and debounce our off-hand click:
    evt.setCanceled(true);
    debounceEntityInteract.set(true);
}
项目:Factorization    文件:MiscClientProxy.java   
@SubscribeEvent(priority = EventPriority.HIGH)
public void addDirectionInfoToDebugScreen(RenderGameOverlayEvent.Text event) {
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.thePlayer;
    float t = 360;
    double yaw = ((player.rotationYaw % t) + t) % t;
    yaw = Math.toRadians(yaw);
    double x = -Math.sin(yaw);
    double z = Math.cos(yaw);

    for (int i = 0; i < event.left.size(); i++) {
        String line = event.left.get(i);
        if (line == null) continue;
        if (line.startsWith("f:")) {
            line += " (" + displ(x) + ", " + displ(z) + ")";
            event.left.set(i, line);
            break;
        }
    }
}
项目:DynamicSurroundings    文件:FogEffectHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void fogColorEvent(final EntityViewRenderEvent.FogColors event) {
    if (doFog()) {
        final IBlockState block = ActiveRenderInfo.getBlockStateAtEntityViewpoint(event.getEntity().world,
                event.getEntity(), (float) event.getRenderPartialTicks());
        if (block.getMaterial() == Material.LAVA || block.getMaterial() == Material.WATER)
            return;

        final Color color = this.scanner.getFogColor(EnvironState.getWorld(),
                (float) event.getRenderPartialTicks());
        if (color != null) {
            event.setRed(color.red);
            event.setGreen(color.green);
            event.setBlue(color.blue);
        }
    }
}
项目:DynamicSurroundings    文件:FogEffectHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void fogRenderEvent(final EntityViewRenderEvent.RenderFogEvent event) {
    if (!doFog() || event.getResult() != Result.DEFAULT)
        return;

    final float planeDistance = this.scanner.getPlaneDistance(event.getFarPlaneDistance());
    if (event.getFogMode() < 0) {
        GlStateManager.setFogStart(0F);
        GlStateManager.setFogEnd(planeDistance);
    } else {
        GlStateManager.setFogStart(planeDistance * this.scanner.getPlaneDistanceScale());
        GlStateManager.setFogEnd(planeDistance);
    }

    event.setResult(Result.ALLOW);
}
项目:DynamicSurroundings    文件:SoundCullHandler.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void soundEvent(final PlaySoundEvent event) {
    if (event.getSound() == null || event.getSound() instanceof ConfigSound)
        return;

    final String resource = event.getSound().getSoundLocation().toString();
    if (this.soundsToBlock.contains(resource)) {
        event.setResultSound(null);
        return;
    }

    if (ModOptions.soundCullingThreshold <= 0)
        return;

    // Get the last time the sound was seen
    final int lastOccurance = this.soundCull.get(resource);
    if (lastOccurance == 0)
        return;

    final int currentTick = EnvironState.getTickCounter();
    if ((currentTick - lastOccurance) < ModOptions.soundCullingThreshold) {
        event.setResultSound(null);
    } else {
        this.soundCull.put(resource, currentTick);
    }
}
项目:DynamicSurroundings    文件:RenderWeather.java   
/**
 * Hook the weather renderer for the loading world.
 */
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void onWorldLoad(@Nonnull final WorldEvent.Load e) {

    if (DSurround.proxy().effectiveSide() == Side.SERVER || !ModOptions.enableWeatherASM)
        return;

    // Only want to hook if the provider doesn't have special
    // weather handling.
    final WorldProvider provider = e.getWorld().provider;
    final String dimName = provider.getDimensionType().getName();
    final IRenderHandler renderer = provider.getWeatherRenderer();
    if (renderer == null) {
        DSurround.log().info("Setting weather renderer for dimension [%s]", dimName);
        provider.setWeatherRenderer(new RenderWeather());
    } else {
        DSurround.log().info("Not hooking weather renderer for dimension [%s] (%s)", dimName, renderer.getClass());
    }
}
项目:Factorization    文件:ItemMatrixProgrammer.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void removeMask(PlayerInteractEvent event) {
    if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) return;
    final EntityPlayer player = event.entityPlayer;
    if (player.worldObj.isRemote) return;
    if (!player.isSneaking()) return;
    if (player.getHeldItem() != null) return;
    final ItemStack helmet = player.getCurrentArmor(3);
    if (helmet == null || !(helmet.getItem() == this)) return;
    if (!isBowed(player)) return;

    player.setCurrentItemOrArmor(4, null);
    player.setCurrentItemOrArmor(0, helmet);
    event.setCanceled(true);
    Core.proxy.updatePlayerInventory(player); // Only seems necessary for removal specifically.
}
项目:DynamicSurroundings    文件:HealthEffectService.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void onLivingHeal(@Nonnull final LivingHealEvent event) {
    if (!ModOptions.enableDamagePopoffs)
        return;

    if (event == null || event.getEntity() == null || event.getEntity().world == null
            || event.getEntity().world.isRemote)
        return;

    // Just in case
    if (event.getAmount() <= 0 || event.getEntityLiving() == null
            || event.getEntityLiving().getHealth() == event.getEntityLiving().getMaxHealth())
        return;

    final Entity entity = event.getEntityLiving();
    final Locus point = new Locus(entity, RANGE);
    final PacketHealthChange packet = new PacketHealthChange(entity.getEntityId(), (float) entity.posX,
            (float) entity.posY + (entity.height / 2.0F), (float) entity.posZ, false, -(int) event.getAmount());
    Network.sendToAllAround(point, packet);
}
项目:HempFarmer    文件:HempFarmer.java   
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public void onItemCraft(ItemCraftedEvent event) {
    Item item = event.crafting.getItem();
    if (item == HFItems.seeds_hemp_crushed || item == HFItems.seeds_indica_crushed
            || item == HFItems.seeds_sativa_crushed) {
        for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) {
            if (event.craftMatrix.getStackInSlot(i) != null) {
                ItemStack stack = event.craftMatrix.getStackInSlot(i);
                if (stack.getItem() instanceof ItemShears) {
                    if (stack.getItemDamage() < stack.getMaxDamage()) {
                        stack.shrink(1);
                        stack.setItemDamage(stack.getItemDamage() + 1);
                        event.craftMatrix.setInventorySlotContents(i, stack);
                    }
                }
            }
        }
    }


}
项目:NotEnoughItems    文件:ContainerEventHandler.java   
@SubscribeEvent (priority = EventPriority.LOWEST, receiveCanceled = true)//We need to be called before JEI.
public void onGuiMouseEventpre(MouseInputEvent.Pre event) {
    if (Mouse.getEventButton() == -1 || event.getGui() == null || !Mouse.getEventButtonState()) {
        return;
    }
    Point mouse = GuiDraw.getMousePosition();
    int eventButton = Mouse.getEventButton();
    if (JEIIntegrationManager.searchBoxOwner == EnumItemBrowser.JEI) {
        GuiTextFieldFilter fieldFilter = JEIIntegrationManager.getTextFieldFilter();
        if (fieldFilter != null && fieldFilter.isMouseOver(mouse.x, mouse.y)) {
            if (eventButton == 0) {
                if (fieldFilter.isFocused() && (System.currentTimeMillis() - lastSearchBoxClickTime < 500)) {//double click
                    NEIClientConfig.world.nbt.setBoolean("searchinventories", !SearchField.searchInventories());
                    NEIClientConfig.world.saveNBT();
                    lastSearchBoxClickTime = 0L;
                } else {
                    lastSearchBoxClickTime = System.currentTimeMillis();
                }
            } else if (eventButton == 1) {
                NEIClientConfig.setSearchExpression("", false);
                LayoutManager.searchField.setText("", false);
            }
        }
    }
}
项目:justenoughdimensions    文件:JEDEventHandler.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void onWorldCreateSpawn(WorldEvent.CreateSpawnPosition event)
{
    World world = event.getWorld();
    JustEnoughDimensions.logInfo("WorldEvent.CreateSpawnPosition - DIM: {}", world.provider.getDimension());

    overrideWorldInfoAndBiomeProvider(world);

    // Find a proper spawn point for the overworld that isn't inside ground...
    // For other dimensions than the regular overworld, this is done after
    // (and only if) setting up the custom WorldInfo override for a newly
    // created dimension, see overrideBiomeProviderAndFindSpawn().
    if (world.provider.getDimension() == 0)
    {
        WorldUtils.findAndSetWorldSpawn(world);

        if (event.getSettings().isBonusChestEnabled())
        {
            JustEnoughDimensions.logInfo("WorldEvent.CreateSpawnPosition - Generating a bonus chest");
            WorldUtils.createBonusChest(world);
        }

        event.setCanceled(true);
    }
}