Search in sources :

Example 1 with CellData

use of io.xol.chunkstories.api.world.cell.CellData in project chunkstories-core by Hugobros3.

the class ItemMeleeWeapon method onControllerInput.

@Override
public boolean onControllerInput(Entity owner, ItemPile pile, Input input, Controller controller) {
    if (input.getName().startsWith("mouse.left")) {
        // Checks current swing is done
        if (System.currentTimeMillis() - currentSwingStart > swingDuration) {
            currentSwingStart = System.currentTimeMillis();
            hasHitYet = false;
        }
        return true;
    } else if (input.getName().equals("shootGun") && owner.getWorld() instanceof WorldMaster) {
        // Actually hits
        EntityLiving shooter = (EntityLiving) owner;
        Vector3dc direction = shooter.getDirectionLookingAt();
        Vector3d eyeLocation = new Vector3d(shooter.getLocation());
        if (shooter instanceof EntityPlayer)
            eyeLocation.add(new Vector3d(0.0, ((EntityPlayer) shooter).eyePosition, 0.0));
        // Find wall collision
        Location shotBlock = owner.getWorld().collisionsManager().raytraceSolid(eyeLocation, direction, range);
        Vector3d nearestLocation = new Vector3d();
        // Loops to try and break blocks
        while (owner.getWorld() instanceof WorldMaster && shotBlock != null) {
            EditableCell peek = owner.getWorld().peekSafely(shotBlock);
            if (!peek.getVoxel().isAir() && peek.getVoxel().getMaterial().resolveProperty("bulletBreakable") != null && peek.getVoxel().getMaterial().resolveProperty("bulletBreakable").equals("true")) {
                // TODO: Spawn an event to check if it's okay
                // Destroy it
                peek.setVoxel(getDefinition().store().parent().voxels().air());
                for (int i = 0; i < 25; i++) {
                    Vector3d smashedVoxelParticleDirection = new Vector3d(direction);
                    smashedVoxelParticleDirection.mul(2.0);
                    smashedVoxelParticleDirection.add(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
                    smashedVoxelParticleDirection.normalize();
                    owner.getWorld().getParticlesManager().spawnParticleAtPositionWithVelocity("voxel_frag", shotBlock, smashedVoxelParticleDirection);
                }
                owner.getWorld().getSoundManager().playSoundEffect("sounds/environment/glass.ogg", Mode.NORMAL, shotBlock, (float) Math.random() * 0.2f + 0.9f, 1.0f);
                // Re-raytrace the ray
                shotBlock = owner.getWorld().collisionsManager().raytraceSolid(eyeLocation, direction, range);
            } else
                break;
        }
        if (shotBlock != null) {
            Location shotBlockOuter = owner.getWorld().collisionsManager().raytraceSolidOuter(eyeLocation, direction, range);
            if (shotBlockOuter != null) {
                Vector3d normal = shotBlockOuter.sub(shotBlock);
                double NbyI2x = 2.0 * direction.dot(normal);
                Vector3d NxNbyI2x = new Vector3d(normal);
                NxNbyI2x.mul(NbyI2x);
                Vector3d reflected = new Vector3d(direction);
                reflected.sub(NxNbyI2x);
                CellData peek = owner.getWorld().peekSafely(shotBlock);
                // This seems fine
                for (CollisionBox box : peek.getTranslatedCollisionBoxes()) {
                    Vector3dc thisLocation = box.lineIntersection(eyeLocation, direction);
                    if (thisLocation != null) {
                        if (nearestLocation == null || nearestLocation.distance(eyeLocation) > thisLocation.distance(eyeLocation))
                            nearestLocation.set(thisLocation);
                    }
                }
                // Position adjustements so shot blocks always shoot proper particles
                if (shotBlock.x() - nearestLocation.x() <= -1.0)
                    nearestLocation.add(-0.01, 0.0, 0.0);
                if (shotBlock.y() - nearestLocation.y() <= -1.0)
                    nearestLocation.add(0.0, -0.01, 0.0);
                if (shotBlock.z() - nearestLocation.z() <= -1.0)
                    nearestLocation.add(0.0, 0.0, -0.01);
                for (int i = 0; i < 25; i++) {
                    Vector3d untouchedReflection = new Vector3d(reflected);
                    Vector3d random = new Vector3d(Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0);
                    random.mul(0.5);
                    untouchedReflection.add(random);
                    untouchedReflection.normalize();
                    untouchedReflection.mul(0.25);
                    Vector3d ppos = new Vector3d(nearestLocation);
                    owner.getWorld().getParticlesManager().spawnParticleAtPositionWithVelocity("voxel_frag", ppos, untouchedReflection);
                    owner.getWorld().getSoundManager().playSoundEffect(owner.getWorld().peekSafely(shotBlock).getVoxel().getMaterial().resolveProperty("landingSounds"), Mode.NORMAL, ppos, 1, 0.25f);
                }
                owner.getWorld().getDecalsManager().drawDecal(nearestLocation, normal.negate(), new Vector3d(0.5), "bullethole");
            }
        }
        // Hitreg takes place on server bois
        if (shooter.getWorld() instanceof WorldMaster) {
            // Iterate over each found entities
            Iterator<Entity> shotEntities = owner.getWorld().collisionsManager().rayTraceEntities(eyeLocation, direction, range);
            while (shotEntities.hasNext()) {
                Entity shotEntity = shotEntities.next();
                // Don't shoot itself & only living things get shot
                if (!shotEntity.equals(shooter) && shotEntity instanceof EntityLiving) {
                    // Get hit location
                    for (HitBox hitBox : ((EntityLiving) shotEntity).getHitBoxes()) {
                        Vector3dc hitPoint = hitBox.lineIntersection(eyeLocation, direction);
                        if (hitPoint == null)
                            continue;
                        // Deal damage
                        ((EntityLiving) shotEntity).damage(pileAsDamageCause(pile), hitBox, (float) damage);
                        // Spawn blood particles
                        Vector3d bloodDir = new Vector3d();
                        direction.normalize(bloodDir).mul(0.25);
                        for (int i = 0; i < 250; i++) {
                            Vector3d random = new Vector3d(Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0);
                            random.mul(0.25);
                            random.add(bloodDir);
                            shooter.getWorld().getParticlesManager().spawnParticleAtPositionWithVelocity("blood", hitPoint, random);
                        }
                        // Spawn blood on walls
                        if (nearestLocation != null)
                            shooter.getWorld().getDecalsManager().drawDecal(nearestLocation, bloodDir, new Vector3d(3.0), "blood");
                    }
                }
            }
        }
    }
    return false;
}
Also used : Vector3dc(org.joml.Vector3dc) Entity(io.xol.chunkstories.api.entity.Entity) HitBox(io.xol.chunkstories.api.entity.EntityLiving.HitBox) EntityLiving(io.xol.chunkstories.api.entity.EntityLiving) Vector3d(org.joml.Vector3d) Iterator(java.util.Iterator) EntityPlayer(io.xol.chunkstories.core.entity.EntityPlayer) CellData(io.xol.chunkstories.api.world.cell.CellData) WorldMaster(io.xol.chunkstories.api.world.WorldMaster) EditableCell(io.xol.chunkstories.api.world.cell.EditableCell) Location(io.xol.chunkstories.api.Location) CollisionBox(io.xol.chunkstories.api.physics.CollisionBox)

Example 2 with CellData

use of io.xol.chunkstories.api.world.cell.CellData in project chunkstories-core by Hugobros3.

the class NearbyVoxelsVolumeTexture method update.

public void update(RenderingInterface renderingContext) {
    if (test == null) {
        test = renderingContext.newTexture3D(TextureFormat.RGBA_8BPP, 32, 32, 32);
    }
    final int SIZE = size;
    final int mod = SIZE / 32;
    int offCenter = SIZE / 2;
    int chunkX = (int) ((renderingContext.getCamera().getCameraPosition().x() - offCenter) / 32);
    int chunkY = (int) ((renderingContext.getCamera().getCameraPosition().y() - offCenter) / 32);
    int chunkZ = (int) ((renderingContext.getCamera().getCameraPosition().z() - offCenter) / 32);
    offsetX = chunkX % mod;
    offsetY = chunkY % mod;
    offsetZ = chunkZ % mod;
    if (bx != chunkX || by != chunkY || bz != chunkZ) {
        bx = chunkX;
        by = chunkY;
        bz = chunkZ;
        ByteBuffer bb = ByteBuffer.allocateDirect(4 * SIZE * SIZE * SIZE);
        byte[] empty = { 0, 0, 0, 0 };
        Chunk zChunk = null;
        Vector4f col = new Vector4f();
        for (int a = 0; a * 32 < SIZE; a++) for (int b = 0; b * 32 < SIZE; b++) for (int c = 0; c * 32 < SIZE; c++) {
            zChunk = worldRenderer.getWorld().getChunk(chunkX + a, chunkY + b, chunkZ + c);
            if (zChunk != null) {
                for (int z = 0; z < 32; z++) for (int y = 0; y < 32; y++) {
                    int dx = (0 + a) % mod;
                    int dy = (0 + b) % mod;
                    int dz = (0 + c) % mod;
                    bb.position(4 * ((dz * 32 + z) * SIZE * SIZE + (dy * 32 + y) * SIZE + 0 + dx * 32));
                    for (int x = 0; x < 32; x++) {
                        CellData cell = zChunk.peek(x, y, z);
                        // zChunk.peekSimple(x, y, z);
                        Voxel voxel = cell.getVoxel();
                        if (voxel.isAir() || voxel.getName().startsWith("glass") || voxel instanceof VoxelPane || (!voxel.getDefinition().isSolid() && !voxel.getDefinition().isLiquid() && voxel.getDefinition().getEmittedLightLevel() == 0)) {
                            bb.put(empty);
                        } else {
                            col.set(voxel.getVoxelTexture(VoxelSide.TOP, cell).getColor());
                            if (col.w() < 1.0) {
                                col.mul(new Vector4f(0.1f, 0.5f, 0.1f, 1.0f));
                            }
                            if (voxel.getDefinition().getEmittedLightLevel() > 0) {
                                Vector4f emits = new Vector4f(1.0f, 1.0f, 1.0f, 1.0f);
                                float alpha = col.w;
                                // if(alpha <= 0.0f)
                                alpha = 1.0f;
                                if (voxel.getName().contains("torch"))
                                    alpha = 2f;
                                bb.put((byte) (int) Math.max(0.0, col.x() * 255.0 * alpha));
                                bb.put((byte) (int) Math.max(0.0, col.y() * 255.0 * alpha));
                                bb.put((byte) (int) Math.max(0.0, col.z() * 255.0 * alpha));
                                bb.put((byte) 20);
                            } else {
                                bb.put((byte) (int) (col.x() * 255));
                                bb.put((byte) (int) (col.y() * 255));
                                bb.put((byte) (int) (col.z() * 255));
                                bb.put((byte) 1);
                            }
                        }
                    }
                }
            }
        }
        bb.position(0);
        bb.limit(bb.capacity());
        test.uploadTextureData(SIZE, SIZE, SIZE, bb);
        test.setTextureWrapping(true);
        System.out.println("do an upload");
    // MemoryUtil.memFree(bb);
    }
}
Also used : VoxelPane(io.xol.chunkstories.core.voxel.VoxelPane) Vector4f(org.joml.Vector4f) Voxel(io.xol.chunkstories.api.voxel.Voxel) Chunk(io.xol.chunkstories.api.world.chunk.Chunk) ByteBuffer(java.nio.ByteBuffer) CellData(io.xol.chunkstories.api.world.cell.CellData)

Example 3 with CellData

use of io.xol.chunkstories.api.world.cell.CellData in project chunkstories-core by Hugobros3.

the class BigVoxel method onPlace.

@Override
public void onPlace(FutureCell context, WorldModificationCause cause) throws IllegalBlockModificationException {
    // Be cool with the system doing it's thing
    if (cause == null)
        return;
    int x = context.getX();
    int y = context.getY();
    int z = context.getZ();
    // Check if there is space for it ...
    for (int a = x; a < x + xWidth; a++) {
        for (int b = y; b < y + yWidth; b++) {
            for (int c = z; c < z + zWidth; c++) {
                Chunk chunk = context.getWorld().getChunkWorldCoordinates(a, b, c);
                if (chunk == null)
                    throw new IllegalBlockModificationException(context, "All chunks upon wich this block places itself must be fully loaded !");
                CellData stuff = context.getWorld().peekSafely(a, b, c);
                if (stuff.getVoxel() == null || stuff.getVoxel().isAir() || !stuff.getVoxel().getDefinition().isSolid()) {
                    // These blocks are replaceable
                    continue;
                } else
                    throw new IllegalBlockModificationException(context, "Can't overwrite block at " + a + ": " + b + ": " + c);
            }
        }
    }
    // Actually build the thing then
    for (int a = 0; a < 0 + xWidth; a++) {
        for (int b = 0; b < 0 + yWidth; b++) {
            for (int c = 0; c < 0 + zWidth; c++) {
                int metadata = (byte) (((a & xMask) << xShift) | ((b & yMask) << yShift) | ((c & zMask) << zShift));
                context.getWorld().pokeSimple(a + x, b + y, c + z, this, -1, -1, metadata);
            }
        }
    }
}
Also used : IllegalBlockModificationException(io.xol.chunkstories.api.exceptions.world.voxel.IllegalBlockModificationException) Chunk(io.xol.chunkstories.api.world.chunk.Chunk) CellData(io.xol.chunkstories.api.world.cell.CellData)

Example 4 with CellData

use of io.xol.chunkstories.api.world.cell.CellData in project chunkstories by Hugobros3.

the class DefaultWorldCollisionsManager method runEntityAgainstWorldVoxels.

/**
 * Does a complicated check to see how far the entity can go using the delta direction, from the 'start' position.
 * Does not actually move anything
 * Returns the remaining distance in each dimension if it got stuck ( with vec3(0.0, 0.0, 0.0) meaning it can safely move without colliding with anything )
 */
public Vector3d runEntityAgainstWorldVoxels(Entity entity, Vector3dc from, Vector3dc delta) {
    CellData cell;
    // Extract the current position
    Vector3d pos = new Vector3d(from);
    // Keep biggest distanceToTravel for each dimension collisionBox of our entity
    Vector3d maxDistanceToTravel = new Vector3d(0.0);
    Vector3d direction = new Vector3d(delta);
    direction.normalize();
    // Iterate over every box
    for (int r = 0; r < entity.getCollisionBoxes().length; r++) {
        // Make a normalized double vector and keep the original length
        Vector3d vec = new Vector3d(delta);
        Vector3d distanceToTravel = new Vector3d(delta);
        double len = vec.length();
        vec.normalize();
        vec.mul(0.25d);
        // Do it block per block, face per face
        double distanceTraveled = 0;
        CollisionBox checkerX = entity.getCollisionBoxes()[r].translate(pos.x(), pos.y(), pos.z());
        CollisionBox checkerY = entity.getCollisionBoxes()[r].translate(pos.x(), pos.y(), pos.z());
        CollisionBox checkerZ = entity.getCollisionBoxes()[r].translate(pos.x(), pos.y(), pos.z());
        double stepDistanceX, stepDistanceY, stepDistanceZ;
        while (distanceTraveled < len) {
            if (len - distanceTraveled > 0.25) {
                // DistanceTraveled is incremented no matter what, for momentum loss while sliding on walls
                distanceTraveled += 0.25;
            } else {
                vec = new Vector3d(delta);
                vec.normalize();
                vec.mul(len - distanceTraveled);
                distanceTraveled = len;
            }
            stepDistanceX = vec.x();
            stepDistanceY = vec.y();
            stepDistanceZ = vec.z();
            // Z part
            checkerZ = entity.getCollisionBoxes()[r].translate(pos.x(), pos.y(), pos.z() + stepDistanceZ);
            for (int i = (int) Math.floor(pos.x()) - 1; i < (int) Math.ceil(pos.x() + checkerX.xw); i++) for (int j = (int) Math.floor(pos.y()) - 1; j < (int) Math.ceil(pos.y() + checkerX.h); j++) for (int k = (int) Math.floor(pos.z()) - 1; k < (int) Math.ceil(pos.z() + checkerX.zw); k++) {
                cell = world.peekSafely(i, j, k);
                if (cell.getVoxel().getDefinition().isSolid()) {
                    CollisionBox[] boxes = cell.getTranslatedCollisionBoxes();
                    if (boxes != null)
                        for (CollisionBox box : boxes) {
                            if (delta.z() != 0.0) {
                                if (checkerZ.collidesWith(box)) {
                                    stepDistanceZ = 0;
                                    if (delta.z() < 0) {
                                        double south = Math.min((box.zpos + box.zw + checkerZ.zw) - (pos.z()), 0.0d);
                                        stepDistanceZ = south;
                                    } else {
                                        double north = Math.max((box.zpos) - (pos.z() + checkerZ.zw), 0.0d);
                                        stepDistanceZ = north;
                                    }
                                    vec.z = (0d);
                                    checkerZ = entity.getCollisionBoxes()[r].translate(pos.x(), pos.y(), pos.z() + stepDistanceZ);
                                }
                            }
                        }
                }
            }
            distanceToTravel.z = (distanceToTravel.z() - stepDistanceZ);
            pos.z = (pos.z() + stepDistanceZ);
            // X-part
            checkerX = entity.getCollisionBoxes()[r].translate(pos.x() + stepDistanceX, pos.y(), pos.z());
            for (int i = (int) Math.floor(pos.x()) - 1; i < (int) Math.ceil(pos.x() + checkerY.xw); i++) for (int j = (int) Math.floor(pos.y()) - 1; j < (int) Math.ceil(pos.y() + checkerY.h); j++) for (int k = (int) Math.floor(pos.z()) - 1; k < (int) Math.ceil(pos.z() + checkerY.zw); k++) {
                cell = world.peekSafely(i, j, k);
                if (cell.getVoxel().getDefinition().isSolid()) {
                    CollisionBox[] boxes = cell.getTranslatedCollisionBoxes();
                    if (boxes != null)
                        for (CollisionBox box : boxes) {
                            if (delta.x() != 0.0) {
                                if (checkerX.collidesWith(box)) {
                                    stepDistanceX = 0;
                                    if (delta.x() < 0) {
                                        double left = Math.min((box.xpos + box.xw + checkerX.xw) - (pos.x()), 0.0d);
                                        // System.out.println("left:"+left);
                                        stepDistanceX = left;
                                    } else {
                                        double right = Math.max((box.xpos) - (pos.x() + checkerX.xw), 0.0d);
                                        // System.out.println("right"+right);
                                        stepDistanceX = right;
                                    }
                                    vec.x = (0d);
                                    checkerX = entity.getCollisionBoxes()[r].translate(pos.x() + stepDistanceX, pos.y(), pos.z());
                                }
                            }
                        }
                }
            }
            pos.x = (pos.x() + stepDistanceX);
            distanceToTravel.x = (distanceToTravel.x() - stepDistanceX);
            // Y-part
            checkerY = entity.getCollisionBoxes()[r].translate(pos.x(), pos.y() + stepDistanceY, pos.z());
            for (int i = (int) Math.floor(pos.x()) - 1; i < (int) Math.ceil(pos.x() + checkerZ.xw); i++) for (int j = (int) Math.floor(pos.y()) - 1; j < (int) Math.ceil(pos.y() + checkerZ.h) + 1; j++) for (int k = (int) Math.floor(pos.z()) - 1; k < (int) Math.ceil(pos.z() + checkerZ.zw); k++) {
                cell = world.peekSafely(i, j, k);
                if (cell.getVoxel().getDefinition().isSolid()) {
                    CollisionBox[] boxes = cell.getTranslatedCollisionBoxes();
                    if (boxes != null)
                        for (CollisionBox box : boxes) {
                            if (delta.y() != 0.0) {
                                if (checkerY.collidesWith(box)) {
                                    stepDistanceY = 0;
                                    if (delta.y() < 0) {
                                        double top = Math.min((box.ypos + box.h) - pos.y(), 0.0d);
                                        // System.out.println(top);
                                        stepDistanceY = top;
                                    } else {
                                        double bot = Math.max((box.ypos) - (pos.y() + checkerY.h), 0.0d);
                                        // System.out.println(bot);
                                        stepDistanceY = bot;
                                    }
                                    vec.y = (0d);
                                    checkerY = entity.getCollisionBoxes()[r].translate(pos.x(), pos.y() + stepDistanceY, pos.z());
                                }
                            }
                        }
                }
            }
            pos.y = (pos.y() + stepDistanceY);
            distanceToTravel.y = (distanceToTravel.y() - stepDistanceY);
        }
        if (Math.abs(distanceToTravel.x()) > Math.abs(maxDistanceToTravel.x()))
            maxDistanceToTravel.x = (distanceToTravel.x());
        if (Math.abs(distanceToTravel.y()) > Math.abs(maxDistanceToTravel.y()))
            maxDistanceToTravel.y = (distanceToTravel.y());
        if (Math.abs(distanceToTravel.z()) > Math.abs(maxDistanceToTravel.z()))
            maxDistanceToTravel.z = (distanceToTravel.z());
    }
    return maxDistanceToTravel;
}
Also used : Vector3d(org.joml.Vector3d) CellData(io.xol.chunkstories.api.world.cell.CellData) CollisionBox(io.xol.chunkstories.api.physics.CollisionBox)

Example 5 with CellData

use of io.xol.chunkstories.api.world.cell.CellData 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

CellData (io.xol.chunkstories.api.world.cell.CellData)14 Location (io.xol.chunkstories.api.Location)5 CollisionBox (io.xol.chunkstories.api.physics.CollisionBox)5 Vector3d (org.joml.Vector3d)5 Vector4f (org.joml.Vector4f)5 Entity (io.xol.chunkstories.api.entity.Entity)4 Voxel (io.xol.chunkstories.api.voxel.Voxel)4 Vector3dc (org.joml.Vector3dc)4 EntityLiving (io.xol.chunkstories.api.entity.EntityLiving)3 ItemVoxel (io.xol.chunkstories.api.item.ItemVoxel)3 WorldMaster (io.xol.chunkstories.api.world.WorldMaster)3 Chunk (io.xol.chunkstories.api.world.chunk.Chunk)3 HitBox (io.xol.chunkstories.api.entity.EntityLiving.HitBox)2 EntityControllable (io.xol.chunkstories.api.entity.interfaces.EntityControllable)2 PlayerVoxelModificationEvent (io.xol.chunkstories.api.events.player.voxel.PlayerVoxelModificationEvent)2 WorldException (io.xol.chunkstories.api.exceptions.world.WorldException)2 Player (io.xol.chunkstories.api.player.Player)2 Shader (io.xol.chunkstories.api.rendering.shader.Shader)2 Texture2D (io.xol.chunkstories.api.rendering.textures.Texture2D)2 DummyCell (io.xol.chunkstories.api.world.cell.DummyCell)2