Java 类net.minecraftforge.client.event.RenderTooltipEvent 实例源码

项目: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);
    }
}
项目:Industrial-Foregoing    文件:MobRenderInPrisonHandler.java   
@SubscribeEvent
public void onTooltip(RenderTooltipEvent.PostText event) {
    if (event.getStack() == null || event.getStack().isEmpty()) return;
    if (event.getStack().getItem() instanceof MobImprisonmentToolItem && ((MobImprisonmentToolItem) event.getStack().getItem()).containsEntity(event.getStack())) {
        try {
            Entity entity = EntityList.createEntityByID(event.getStack().getTagCompound().getInteger("id"), Minecraft.getMinecraft().world);
            entity.readFromNBT(event.getStack().getTagCompound());
            ItemStackUtils.renderEntity((int) (event.getX() + 15 + entity.width), (int) (event.getY() + 58 + entity.height), 15, 0, 0, (EntityLivingBase) entity);
        } catch (NullPointerException e) {
            e.printStackTrace();
        }
    }

}
项目:NotEnoughItems    文件:NEIClientEventHandler.java   
@SubscribeEvent
public void tooltipPreEvent(RenderTooltipEvent.Pre event) {
    //for (IContainerObjectHandler handler : objectHandlers) {
    //    if (!handler.shouldShowTooltip(Minecraft.getMinecraft().currentScreen)) {
    //        event.setCanceled(true);
    //        return;
    //    }
    //}
    event.setY(MathHelper.clip(event.getY(), 8, event.getScreenHeight() - 8));
}