Java Code Examples for net.minecraftforge.fml.common.gameevent.TickEvent#RenderTickEvent

The following examples show how to use net.minecraftforge.fml.common.gameevent.TickEvent#RenderTickEvent . 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: NeedsMoreJpeg.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onRenderTick(TickEvent.RenderTickEvent event) {
    if (event.phase == TickEvent.Phase.START) {
        Minecraft client = Minecraft.getMinecraft();

        boolean hasGoggles = hasGoggles(client);
        if (hasGoggles != hadGoggles) {
            client.entityRenderer.loadEntityShader(null);
        }

        if (hasGoggles && shouldChangeShader(client)) {
            ShaderGroup activeGroup = client.entityRenderer.getShaderGroup();
            if (activeGroup != null) {
                activeGroup.deleteShaderGroup();
            }
            client.entityRenderer.loadShader(SHADER_LOCATION);
        }

        hadGoggles = hasGoggles;
    }
}
 
Example 2
Source File: RenderListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
@SubscribeEvent()
public void onRender(TickEvent.RenderTickEvent e) {
    if (guiToOpen == EnumUtils.GUIType.MAIN) {
        Minecraft.getMinecraft().displayGuiScreen(new SkyblockAddonsGui(guiPageToOpen, guiTabToOpen));
    } else if (guiToOpen == EnumUtils.GUIType.EDIT_LOCATIONS) {
        Minecraft.getMinecraft().displayGuiScreen(new LocationEditGui(main, guiPageToOpen, guiTabToOpen));
    } else if (guiToOpen == EnumUtils.GUIType.SETTINGS) {
        Minecraft.getMinecraft().displayGuiScreen(new SettingsGui(guiFeatureToOpen, 1, guiPageToOpen, guiTabToOpen, guiFeatureToOpen.getSettings()));
    } else if (guiToOpen == EnumUtils.GUIType.WARP) {
        Minecraft.getMinecraft().displayGuiScreen(new IslandWarpGui());
    }
    guiToOpen = null;
}
 
Example 3
Source File: SexyFont.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void frame(TickEvent.RenderTickEvent e) {
	if(e.phase == TickEvent.Phase.START) {
		Minecraft mc = Minecraft.getMinecraft();
		if(mc.player == null) {
			SexyFont.sexyTime = false;
		} else {
			Item head = mc.player.inventory.armorItemInSlot(EntityEquipmentSlot.HEAD.getIndex()).getItem();
			SexyFont.sexyTime = head == SexyFont.Items.SEXY_GLASSES;
		}
	}
}
 
Example 4
Source File: NemezEventHandler.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public static void renderTick(TickEvent.RenderTickEvent event) {
	World world = Minecraft.getMinecraft().world;
	if (event.phase == TickEvent.Phase.START) {
		for (Reversal reversal : reversals) {
			if (reversal.world.get() != world) continue;

			if (reversal.nemez.hasNext())
				reversal.nemez.applySnapshot(world, event.renderTickTime);
		}
	}
}
 
Example 5
Source File: EpisodeEventWrapper.java    From malmo with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
    // Pass the event on to the active episode, if there is one:
    this.stateEpisodeLock.readLock().lock();
    if (this.stateEpisode != null && this.stateEpisode.isLive())
    {
        this.stateEpisode.onRenderTick(ev);
    }
    this.stateEpisodeLock.readLock().unlock();
}
 
Example 6
Source File: CommandForWheeledRobotNavigationImplementation.java    From malmo with MIT License 5 votes vote down vote up
/** Called for each screen redraw - approximately three times as often as the other tick events, 
 * under normal conditions.<br>
 * This is where we want to update our yaw/pitch, in order to get smooth panning etc
 * (which is how Minecraft itself does it).
 * The speed of the render ticks is not guaranteed, and can vary from machine to machine, so
 * we try to account for this in the calculations.
 * @param ev the RenderTickEvent object for this tick
 */
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
    if (ev.phase == Phase.START)
    {
        if (this.isOverriding())
        {
            updateYawAndPitch();
        }
    }
}
 
Example 7
Source File: HumanLevelCommandsImplementation.java    From malmo with MIT License 5 votes vote down vote up
/** Called for each screen redraw - approximately three times as often as the other tick events,
 * under normal conditions.<br>
 * This is where we want to update our yaw/pitch, in order to get smooth panning etc
 * (which is how Minecraft itself does it).
 * The speed of the render ticks is not guaranteed, and can vary from machine to machine, so
 * we try to account for this in the calculations.
 * @param ev the RenderTickEvent object for this tick
 */
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
    if (ev.phase == Phase.START && this.isOverriding())
    {
        // Track average fps:
        this.renderTickMonitor.beat();
        if (this.isOverriding())
        {
            EntityPlayerSP player = Minecraft.getMinecraft().player;
            if (player != null)
            {
                if (this.targetPitchDelta != 0 || this.targetYawDelta != 0)
                {
                    player.turn(this.targetYawDeltaDelta, this.targetPitchDeltaDelta);
                    this.targetYawDelta -= this.targetYawDeltaDelta;
                    this.targetPitchDelta -= this.targetPitchDeltaDelta;
                    if (this.targetYawDelta / this.targetYawDeltaDelta < 1.0)
                        this.targetYawDeltaDelta = this.targetYawDelta;
                    if (this.targetPitchDelta / this.targetPitchDeltaDelta < 1.0)
                        this.targetPitchDeltaDelta = this.targetPitchDelta;
                }
            }
        }
    }
}
 
Example 8
Source File: GlassesHUD.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public void renderTick(TickEvent.RenderTickEvent event){
    if(event.phase == TickEvent.Phase.END) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        if(mc != null && mc.player != null) {
            render2D();
        }
    }
}
 
Example 9
Source File: ClientRenderHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent event)
{

	if(event.phase == Phase.START)
	{
		if(ClientRenderHandler.IsGeneratingFirstIsland)
		{
			Minecraft.getMinecraft().skipRenderWorld = true;
			skipRender = true;
		}
		else
		{
			skipRender = false;
		}
	}
	if(event.phase == Phase.END)
	{
		if(skipRender && ClientRenderHandler.IsGeneratingFirstIsland)
		{
			String gen = Core.translate("gui.generatingmapmessage");
			FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
			ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
			int sizeX = Minecraft.getMinecraft().displayWidth/2;
			int sizeY = Minecraft.getMinecraft().displayHeight/2;

			renderer.drawString(gen, sizeX/2 - (renderer.getStringWidth(gen) / 2)+1, sizeY/2+1, Color.black.getRGB());
			renderer.drawString(gen, sizeX/2 - (renderer.getStringWidth(gen) / 2), sizeY/2, Color.white.getRGB());
			Minecraft.getMinecraft().skipRenderWorld = false;
			skipRender = false;
		}
	}
}
 
Example 10
Source File: TooltipOverlayHandler.java    From IGW-mod with GNU General Public License v2.0 5 votes vote down vote up
@SubscribeEvent
public void tickEnd(TickEvent.RenderTickEvent event){
    if(event.phase == TickEvent.Phase.END && TickHandler.showTooltip() && ConfigHandler.shouldShowTooltip && FMLClientHandler.instance().getClient().inGameHasFocus && IGWMod.proxy.getPlayer().world != null) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        ScaledResolution sr = new ScaledResolution(mc);
        FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer;
        String objectName = TickHandler.getCurrentObjectName();
        String moreInfo = "'" + Keyboard.getKeyName(ClientProxy.openInterfaceKey.getKeyCode()) + "' for more info";
        fontRenderer.drawString(objectName, sr.getScaledWidth() / 2 - fontRenderer.getStringWidth(objectName) / 2, sr.getScaledHeight() / 2 - 20, 0xFFFFFFFF);
        fontRenderer.drawString(moreInfo, sr.getScaledWidth() / 2 - fontRenderer.getStringWidth(moreInfo) / 2, sr.getScaledHeight() / 2 - 10, 0xFFFFFFFF);
    }
}
 
Example 11
Source File: ClientStateMachine.java    From malmo with MIT License 4 votes vote down vote up
@Override
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
    // We wait until we start to get render ticks, at which point we assume Minecraft has finished starting up.
    episodeHasCompleted(ClientState.DORMANT);
}
 
Example 12
Source File: ScreenHelper.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
    purgeExpiredFragments(null);
    if (Minecraft.getMinecraft().currentScreen != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu))
        return;
    if (Minecraft.getMinecraft().gameSettings.showDebugInfo)    // Don't obscure MC debug info with our debug info
        return;

    ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft());
    int width = res.getScaledWidth();
    int height = res.getScaledHeight();
    float rx = (float) width / 1000f;
    float ry = (float) height / 1000f;

    synchronized(this.fragments)
    {
        for (TextCategory cat : TextCategory.values())
        {
            TextCategoryAttributes atts = this.attributes.get(cat);
            if (atts != null && (!atts.flashing || ((System.currentTimeMillis() / 500) % 3 != 0)) && shouldDisplay(atts.displayLevel))
            {
                int x = Math.round(rx * (float) atts.xOrg);
                int y = Math.round(ry * (float) atts.yOrg);
                ArrayList<TextFragment> frags = this.fragments.get(cat);
                if (frags != null && !frags.isEmpty())
                {
                    for (TextFragment frag : frags)
                    {
                        drawText(frag.text, x, y, atts.colour);
                        y += 10;
                    }
                }
            }
        }
    }
}
 
Example 13
Source File: ObservationFromSystemImplementation.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
    if (ev.side == Side.CLIENT && ev.phase == Phase.START)
        this.renderTickMonitor.beat();
}
 
Example 14
Source File: ClientHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@SubscribeEvent
public void tickEvent(TickEvent.RenderTickEvent event) {
    if(event.phase == Phase.END && NEIClientConfig.isEnabled())
        HUDRenderer.renderOverlay();
}
 
Example 15
Source File: CCCEventHandler.java    From CodeChickenCore with MIT License 4 votes vote down vote up
@SubscribeEvent
public void renderTick(TickEvent.RenderTickEvent event) {
    if(event.phase == Phase.START)
        renderFrame = event.renderTickTime;
}