Search in sources :

Example 1 with ClientParticlesRenderer

use of io.xol.chunkstories.renderer.particles.ClientParticlesRenderer in project chunkstories by Hugobros3.

the class Ingame method handleInput.

@Override
public boolean handleInput(Input input) {
    // Block inputs if chatting
    if (input.equals("chat")) {
        gameWindow.setLayer(chatManager.new ChatPanelOverlay(gameWindow, this));
        focus(false);
        guiHidden = false;
        return true;
    } else if (input.equals("hideGui")) {
        guiHidden = !guiHidden;
        return true;
    } else if (input.equals("screenshot")) {
        chatManager.insert(world.getWorldRenderer().screenShot());
    } else if (input.equals("toggleDebugInfo")) {
        OptionBoolean debugInfo = (OptionBoolean) client.getConfiguration().getOption("client.debug.showDebugInfo");
        debugInfo.toggle();
        guiHidden = false;
        return true;
    } else if (input.equals("takeCubemap")) {
        // shouldTakeACubemap = true;
        return true;
    // CTRL-F12 reloads
    } else if (input.equals("reloadContent")) {
        // Rebuild the mod FS
        gameWindow.getClient().reloadAssets();
        // Reload plugins
        world.getPluginManager().reloadPlugins();
        // Mark some caches dirty
        world.getWorldRenderer().reloadContentSpecificStuff();
        return true;
    // CTRL-R redraws chunks
    } else if (input.equals("redrawChunks")) {
        ((ClientParticlesRenderer) world.getParticlesManager()).cleanAllParticles();
        world.redrawEverything();
        world.getWorldRenderer().flagChunksModified();
        return true;
    // Item slots selection
    } else if (input.getName().startsWith("inventorySlot")) {
        int requestedInventorySlot = Integer.parseInt(input.getName().replace("inventorySlot", ""));
        // Match zero onto last slot
        if (requestedInventorySlot == 0)
            requestedInventorySlot = 10;
        // Map to zero-indexed inventory
        requestedInventorySlot--;
        if (playerEntity != null && playerEntity instanceof EntityWithSelectedItem) {
            // Do not accept request to select non-existent inventories slots
            if (requestedInventorySlot > ((EntityWithInventory) playerEntity).getInventory().getWidth())
                return false;
            ItemPile p = ((EntityWithInventory) playerEntity).getInventory().getItemPileAt(requestedInventorySlot, 0);
            if (p != null)
                requestedInventorySlot = p.getX();
            ((EntityWithSelectedItem) playerEntity).setSelectedItemIndex(requestedInventorySlot);
        }
        return true;
    } else if (input.equals("exit")) /* Exit brings up the pause menu */
    {
        focus(false);
        guiHidden = false;
        gameWindow.setLayer(new PauseMenu(gameWindow, this));
        return true;
    } else if (input instanceof MouseScroll) {
        MouseScroll ms = (MouseScroll) input;
        if (playerEntity != null && playerEntity instanceof EntityWithSelectedItem) {
            ItemPile selected = null;
            int selectedInventorySlot = ((EntityWithSelectedItem) playerEntity).getSelectedItemIndex();
            int originalSlot = selectedInventorySlot;
            if (ms.amount() < 0) {
                selectedInventorySlot %= ((EntityWithInventory) playerEntity).getInventory().getWidth();
                selected = ((EntityWithInventory) playerEntity).getInventory().getItemPileAt(selectedInventorySlot, 0);
                if (selected != null)
                    selectedInventorySlot += selected.getItem().getDefinition().getSlotsWidth();
                else
                    selectedInventorySlot++;
            } else {
                selectedInventorySlot--;
                if (selectedInventorySlot < 0)
                    selectedInventorySlot += ((EntityWithInventory) playerEntity).getInventory().getWidth();
                selected = ((EntityWithInventory) playerEntity).getInventory().getItemPileAt(selectedInventorySlot, 0);
                if (selected != null)
                    selectedInventorySlot = selected.getX();
            }
            // Switch slot
            if (originalSlot != selectedInventorySlot)
                ((EntityWithSelectedItem) playerEntity).setSelectedItemIndex(selectedInventorySlot);
            return true;
        }
    }
    return false;
}
Also used : EntityWithInventory(io.xol.chunkstories.api.entity.interfaces.EntityWithInventory) EntityWithSelectedItem(io.xol.chunkstories.api.entity.interfaces.EntityWithSelectedItem) ChatPanelOverlay(io.xol.chunkstories.gui.layer.ingame.ChatManager.ChatPanelOverlay) OptionBoolean(io.xol.chunkstories.api.util.Configuration.OptionBoolean) ItemPile(io.xol.chunkstories.api.item.inventory.ItemPile) MouseScroll(io.xol.chunkstories.api.input.Mouse.MouseScroll) ClientParticlesRenderer(io.xol.chunkstories.renderer.particles.ClientParticlesRenderer)

Example 2 with ClientParticlesRenderer

use of io.xol.chunkstories.renderer.particles.ClientParticlesRenderer in project chunkstories by Hugobros3.

the class DebugInfoRenderer method drawF3debugMenu.

public void drawF3debugMenu(RenderingInterface renderingInterface) {
    CameraInterface camera = renderingInterface.getCamera();
    Entity playerEntity = client.getPlayer().getControlledEntity();
    /*int timeTook = Client.profiler.timeTook();
		String debugInfo = Client.profiler.reset("gui").toString();
		if (timeTook > 400)
			System.out.println("Lengty frame, printing debug information : \n" + debugInfo);*/
    // Memory usage
    long total = Runtime.getRuntime().totalMemory();
    long used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
    // By default use the camera position
    int bx = ((int) camera.getCameraPosition().x());
    int by = ((int) camera.getCameraPosition().y());
    int bz = ((int) camera.getCameraPosition().z());
    int lx = bx, ly = by, lz = bz;
    // If the player can look use that
    if (playerEntity != null && playerEntity instanceof EntityControllable) {
        Location loc = ((EntityControllable) playerEntity).getBlockLookingAt(true);
        if (loc != null) {
            lx = (int) loc.x();
            ly = (int) loc.y();
            lz = (int) loc.z();
        }
    }
    int raw_data = world.peekRaw(lx, ly, lz);
    CellData cell = world.peekSafely(lx, ly, lz);
    // System.out.println(VoxelFormat.id(raw_data));
    int cx = bx / 32;
    int cy = by / 32;
    int cz = bz / 32;
    int csh = world.getRegionsSummariesHolder().getHeightAtWorldCoordinates(bx, bz);
    // Obtain the angle the player is facing
    VoxelSide side = VoxelSide.TOP;
    float angleX = -1;
    if (playerEntity != null && playerEntity instanceof EntityLiving)
        angleX = Math.round(((EntityLiving) playerEntity).getEntityRotationComponent().getHorizontalRotation());
    double dx = Math.sin(angleX / 360 * 2.0 * Math.PI);
    double dz = Math.cos(angleX / 360 * 2.0 * Math.PI);
    if (Math.abs(dx) > Math.abs(dz)) {
        if (dx > 0)
            side = VoxelSide.RIGHT;
        else
            side = VoxelSide.LEFT;
    } else {
        if (dz > 0)
            side = VoxelSide.FRONT;
        else
            side = VoxelSide.BACK;
    }
    // Count all the entities
    int ec = 0;
    IterableIterator<Entity> i = world.getAllLoadedEntities();
    while (i.hasNext()) {
        i.next();
        ec++;
    }
    Chunk current = world.getChunk(cx, cy, cz);
    int x_top = renderingInterface.getWindow().getHeight() - 16;
    Font font = null;
    font = renderingInterface.getFontRenderer().getFont("LiberationSans-Regular", 12);
    if (font == null)
        font = renderingInterface.getFontRenderer().getFont("LiberationSans-Regular", 12);
    int lineHeight = font.getLineHeight();
    int posx, posy;
    String text;
    posx = 8;
    posy = x_top - posx;
    text = GLCalls.getStatistics() + " Chunks in view : " + world.getWorldRenderer().getChunksRenderer().getChunksVisible() + " Entities " + ec + " Particles :" + ((ClientParticlesRenderer) world.getParticlesManager()).count() + " #FF0000Render FPS: " + Client.getInstance().getGameWindow().getFPS() + " avg: " + Math.floor(10000.0 / Client.getInstance().getGameWindow().getFPS()) / 10.0 + " #00FFFFSimulation FPS: " + world.getWorldRenderer().getWorld().getGameLogic().getSimulationFps();
    renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
    posy -= lineHeight;
    text = "RAM usage : " + used / 1024 / 1024 + " / " + total / 1024 / 1024 + " MB used, chunks loaded in ram: " + world.getRegionsHolder().countChunksWithData() + "/" + world.getRegionsHolder().countChunks() + " " + Math.floor(world.getRegionsHolder().countChunksWithData() * 4 * 32 * 32 * 32 / (1024L * 1024 / 100f)) / 100f + "MB used by chunks";
    renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
    long totalVram = (renderingInterface.getTotalVramUsage()) / 1024 / 1024;
    posy -= lineHeight;
    text = "VRAM usage : " + totalVram + "MB as " + Texture2DGL.getTotalNumberOfTextureObjects() + " textures using " + Texture2DGL.getTotalVramUsage() / 1024 / 1024 + "MB + " + VertexBufferGL.getTotalNumberOfVerticesObjects() + " vbos using " + renderingInterface.getVertexDataVramUsage() / 1024 / 1024 + " MB";
    renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
    posy -= lineHeight;
    text = "Worker threads: " + world.getGameContext().tasks() + " - " + world.ioHandler.toString();
    renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
    posy -= lineHeight;
    text = "Position : x:" + bx + " y:" + by + " z:" + bz + " dir: " + angleX + " side: " + side + " #FF0000Block looking at#FFFFFF : pos: " + lx + ": " + ly + ": " + lz + " data: " + raw_data + " voxel_type: " + cell.getVoxel().getName() + " sl:" + cell.getSunlight() + " bl: " + cell.getBlocklight() + " meta:" + cell.getMetaData() + " csh:" + csh;
    renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
    posy -= lineHeight;
    text = "Current Summary : " + world.getRegionsSummariesHolder().getHeightmapChunkCoordinates(cx, cz);
    renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
    posy -= lineHeight;
    text = "Current Region : " + world.getRegionChunkCoordinates(cx, cy, cz);
    renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
    if (current == null) {
        posy -= lineHeight;
        text = "Current chunk null";
        renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
    } else if (current instanceof ChunkRenderable) {
        ChunkRenderDataHolder chunkRenderData = ((ClientChunk) current).getChunkRenderData();
        if (chunkRenderData != null) {
            posy -= lineHeight;
            text = "Current Chunk : " + current + " - " + chunkRenderData.toString();
            renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
        } else {
            posy -= lineHeight;
            text = "Current Chunk : " + current + " - No rendering data";
            renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
        }
    }
    if (playerEntity != null && playerEntity instanceof Entity) {
        posy -= lineHeight;
        text = "Controlled Entity : " + playerEntity;
        renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
    }
}
Also used : Entity(io.xol.chunkstories.api.entity.Entity) VoxelSide(io.xol.chunkstories.api.voxel.VoxelSide) EntityLiving(io.xol.chunkstories.api.entity.EntityLiving) ChunkRenderable(io.xol.chunkstories.api.rendering.world.chunk.ChunkRenderable) Chunk(io.xol.chunkstories.api.world.chunk.Chunk) ClientChunk(io.xol.chunkstories.world.chunk.ClientChunk) CellData(io.xol.chunkstories.api.world.cell.CellData) Font(io.xol.chunkstories.api.rendering.text.FontRenderer.Font) ChunkRenderDataHolder(io.xol.chunkstories.renderer.chunks.ChunkRenderDataHolder) Vector4f(org.joml.Vector4f) CameraInterface(io.xol.chunkstories.api.rendering.CameraInterface) EntityControllable(io.xol.chunkstories.api.entity.interfaces.EntityControllable) Location(io.xol.chunkstories.api.Location) ClientParticlesRenderer(io.xol.chunkstories.renderer.particles.ClientParticlesRenderer)

Aggregations

ClientParticlesRenderer (io.xol.chunkstories.renderer.particles.ClientParticlesRenderer)2 Location (io.xol.chunkstories.api.Location)1 Entity (io.xol.chunkstories.api.entity.Entity)1 EntityLiving (io.xol.chunkstories.api.entity.EntityLiving)1 EntityControllable (io.xol.chunkstories.api.entity.interfaces.EntityControllable)1 EntityWithInventory (io.xol.chunkstories.api.entity.interfaces.EntityWithInventory)1 EntityWithSelectedItem (io.xol.chunkstories.api.entity.interfaces.EntityWithSelectedItem)1 MouseScroll (io.xol.chunkstories.api.input.Mouse.MouseScroll)1 ItemPile (io.xol.chunkstories.api.item.inventory.ItemPile)1 CameraInterface (io.xol.chunkstories.api.rendering.CameraInterface)1 Font (io.xol.chunkstories.api.rendering.text.FontRenderer.Font)1 ChunkRenderable (io.xol.chunkstories.api.rendering.world.chunk.ChunkRenderable)1 OptionBoolean (io.xol.chunkstories.api.util.Configuration.OptionBoolean)1 VoxelSide (io.xol.chunkstories.api.voxel.VoxelSide)1 CellData (io.xol.chunkstories.api.world.cell.CellData)1 Chunk (io.xol.chunkstories.api.world.chunk.Chunk)1 ChatPanelOverlay (io.xol.chunkstories.gui.layer.ingame.ChatManager.ChatPanelOverlay)1 ChunkRenderDataHolder (io.xol.chunkstories.renderer.chunks.ChunkRenderDataHolder)1 ClientChunk (io.xol.chunkstories.world.chunk.ClientChunk)1 Vector4f (org.joml.Vector4f)1