Search in sources :

Example 1 with InventoryGridRenderer

use of io.xol.chunkstories.gui.InventoryGridRenderer in project chunkstories by Hugobros3.

the class Ingame method render.

@Override
public void render(RenderingInterface renderer) {
    // Update client entity
    if ((playerEntity == null || playerEntity != getPlayer().getControlledEntity()) && getPlayer().getControlledEntity() != null) {
        playerEntity = getPlayer().getControlledEntity();
        if (playerEntity instanceof EntityWithSelectedItem)
            inventoryBarDrawer = ((EntityWithSelectedItem) playerEntity).getInventory() == null ? null : new InventoryGridRenderer((EntityWithSelectedItem) playerEntity);
        else
            inventoryBarDrawer = null;
    }
    if (playerEntity != null && ((EntityLiving) playerEntity).isDead() && !(gameWindow.getLayer() instanceof DeathScreen))
        gameWindow.setLayer(new DeathScreen(gameWindow, this));
    // Update the player
    if (playerEntity instanceof EntityControllable)
        ((EntityControllable) playerEntity).onEachFrame(getPlayer());
    Location selectedBlock = null;
    if (playerEntity instanceof EntityControllable)
        selectedBlock = ((EntityControllable) playerEntity).getBlockLookingAt(true);
    world.getPluginManager().fireEvent(new CameraSetupEvent(renderer.getCamera()));
    // Main render call
    world.getWorldRenderer().renderWorld(renderer);
    // Debug draws
    if (client.getConfiguration().getBooleanOption("client.debug.physicsVisualization") && playerEntity != null) {
        wireframeDebugger.render(renderer);
    }
    if (!guiHidden && selectedBlock != null && playerEntity instanceof EntityCreative && ((EntityCreative) playerEntity).getCreativeModeComponent().get())
        selectionRenderer.drawSelectionBox(renderer, selectedBlock);
    // Fades in & out the overlay
    if (!isCovered()) {
        if (pauseOverlayFade > 0.0)
            pauseOverlayFade -= 0.1;
    } else {
        float maxFade = 1.0f;
        if (gameWindow.getLayer() instanceof ChatPanelOverlay)
            maxFade = 0.25f;
        if (pauseOverlayFade < maxFade)
            pauseOverlayFade += 0.1;
    }
    // Blit the final 3d image
    world.getWorldRenderer().blitFinalImage(renderer, guiHidden);
    // Draw the GUI
    if (!guiHidden) {
        chatManager.render(renderer);
        // Draw inventory
        if (playerEntity != null && inventoryBarDrawer != null)
            inventoryBarDrawer.drawPlayerInventorySummary(renderer, renderer.getWindow().getWidth() / 2 - 7, 64 + 64);
        // Draw debug info
        if (client.getConfiguration().getBooleanOption("client.debug.showDebugInfo"))
            debugInfoRenderer.drawF3debugMenu(renderer);
        renderer.getGuiRenderer().drawBoxWindowsSpaceWithSize(getGameWindow().getWidth() / 2 - 8, getGameWindow().getHeight() / 2 - 8, 16, 16, 0, 1, 1, 0, renderer.textures().getTexture("./textures/gui/cursor.png"), false, true, null);
    }
    // Lack of overlay should infer autofocus
    if (!isCovered())
        focus(true);
    // Check connection didn't died and change scene if it has
    if (world instanceof WorldClientRemote) {
        if (!((WorldClientRemote) world).getConnection().isOpen())
            gameWindow.getClient().exitToMainMenu("Connection terminated : " + "(TODO: not this way)");
    }
    // Auto-switch to pause if it detects the game isn't in focus anymore
    if (!gameWindow.hasFocus() && !isCovered()) {
        focus(false);
        gameWindow.setLayer(new PauseMenu(gameWindow, gameWindow.getLayer()));
    }
}
Also used : EntityLiving(io.xol.chunkstories.api.entity.EntityLiving) CameraSetupEvent(io.xol.chunkstories.api.events.rendering.CameraSetupEvent) InventoryGridRenderer(io.xol.chunkstories.gui.InventoryGridRenderer) WorldClientRemote(io.xol.chunkstories.world.WorldClientRemote) EntityWithSelectedItem(io.xol.chunkstories.api.entity.interfaces.EntityWithSelectedItem) EntityCreative(io.xol.chunkstories.api.entity.interfaces.EntityCreative) ChatPanelOverlay(io.xol.chunkstories.gui.layer.ingame.ChatManager.ChatPanelOverlay) EntityControllable(io.xol.chunkstories.api.entity.interfaces.EntityControllable) Location(io.xol.chunkstories.api.Location)

Aggregations

Location (io.xol.chunkstories.api.Location)1 EntityLiving (io.xol.chunkstories.api.entity.EntityLiving)1 EntityControllable (io.xol.chunkstories.api.entity.interfaces.EntityControllable)1 EntityCreative (io.xol.chunkstories.api.entity.interfaces.EntityCreative)1 EntityWithSelectedItem (io.xol.chunkstories.api.entity.interfaces.EntityWithSelectedItem)1 CameraSetupEvent (io.xol.chunkstories.api.events.rendering.CameraSetupEvent)1 InventoryGridRenderer (io.xol.chunkstories.gui.InventoryGridRenderer)1 ChatPanelOverlay (io.xol.chunkstories.gui.layer.ingame.ChatManager.ChatPanelOverlay)1 WorldClientRemote (io.xol.chunkstories.world.WorldClientRemote)1