Java Code Examples for net.minecraftforge.fml.common.eventhandler.EventPriority#LOW

The following examples show how to use net.minecraftforge.fml.common.eventhandler.EventPriority#LOW . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogoutSpot.java    From ForgeHax with MIT License 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOW)
public void onRenderGameOverlayEvent(Render2DEvent event) {
  if (!render.get()) {
    return;
  }
  
  synchronized (spots) {
    spots.forEach(
        spot -> {
          Vec3d top = spot.getTopVec();
          Plane upper = VectorUtils.toScreen(top);
          if (upper.isVisible()) {
            double distance = getLocalPlayer().getPositionVector().distanceTo(top);
            String name = String.format("%s (%.1f)", spot.getName(), distance);
            SurfaceHelper.drawTextShadow(
                name,
                (int) upper.getX() - (SurfaceHelper.getTextWidth(name) / 2),
                (int) upper.getY() - (SurfaceHelper.getTextHeight() + 1),
                Colors.RED.toBuffer());
          }
        });
  }
}
 
Example 2
Source File: GuiEnderUtilities.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOW)
public static void onMouseInputEventPre(MouseInputEvent.Pre event)
{
    // Handle the mouse input inside all of the mod's GUIs via the event and then cancel the event,
    // so that some mods like Inventory Sorter don't try to sort the Ender Utilities inventories.
    // Using priority LOW should still allow even older versions of Item Scroller to work,
    // since it uses normal priority.
    if (event.getGui() instanceof GuiEnderUtilities)
    {
        try
        {
            event.getGui().handleMouseInput();
            event.setCanceled(true);
        }
        catch (IOException e)
        {
            EnderUtilities.logger.warn("Exception while executing handleMouseInput() on {}", event.getGui().getClass().getName());
        }
    }
}
 
Example 3
Source File: RenderEventService.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOW)
public void onRenderGameOverlayEvent(final RenderGameOverlayEvent.Text event) {
  if (event.getType().equals(RenderGameOverlayEvent.ElementType.TEXT)) {
    MinecraftForge.EVENT_BUS.post(new Render2DEvent(event.getPartialTicks()));
    GlStateManager.color(1.f, 1.f, 1.f, 1.f); // reset color
  }
}
 
Example 4
Source File: CommonProxy.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOW)
public static void runEarlyMaterialHandlers(RegistryEvent.Register<IRecipe> event) {
    GTLog.logger.info("Running early material handlers...");
    OrePrefix.runMaterialHandlers();
}
 
Example 5
Source File: ESP.java    From ForgeHax with MIT License 4 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOW)
public void onRender2D(final Render2DEvent event) {
  getWorld()
    .loadedEntityList
    .stream()
    .filter(EntityUtils::isLiving)
    .filter(
      entity ->
        !Objects.equals(getLocalPlayer(), entity) && !EntityUtils.isFakeLocalPlayer(entity))
    .filter(EntityUtils::isAlive)
    .filter(EntityUtils::isValidEntity)
    .map(entity -> (EntityLivingBase) entity)
    .forEach(
      living -> {
        final Setting<DrawOptions> setting;
        
        switch (EntityUtils.getRelationship(living)) {
          case PLAYER:
            setting = players;
            break;
          case HOSTILE:
            setting = mobs_hostile;
            break;
          case NEUTRAL:
          case FRIENDLY:
            setting = mobs_friendly;
            break;
          default:
            setting = null;
            break;
        }
        
        if (setting == null || DrawOptions.DISABLED.equals(setting.get())) {
          return;
        }
        
        Vec3d bottomPos = EntityUtils.getInterpolatedPos(living, event.getPartialTicks());
        Vec3d topPos =
          bottomPos.addVector(0.D, living.getRenderBoundingBox().maxY - living.posY, 0.D);
        
        Plane top = VectorUtils.toScreen(topPos);
        Plane bot = VectorUtils.toScreen(bottomPos);
        
        // stop here if neither are visible
        if (!top.isVisible() && !bot.isVisible()) {
          return;
        }
        
        double topX = top.getX();
        double topY = top.getY() + 1.D;
        double botX = bot.getX();
        double botY = bot.getY() + 1.D;
        double height = (bot.getY() - top.getY());
        double width = height;
        
        AtomicDouble offset = new AtomicDouble();
        TopComponents.REVERSE_VALUES
          .stream()
          .filter(comp -> comp.valid(setting))
          .forEach(
            comp -> {
              double os = offset.get();
              offset.set(
                os
                  + comp.draw(
                  event.getSurfaceBuilder(),
                  living,
                  topX,
                  topY - os,
                  botX,
                  botY,
                  width,
                  height));
            });
      });
}