Package org.terasology.math

Examples of org.terasology.math.Vector3i


    public Vector3i getSelectedChunk() {
        if (selectedChunk == null) {
            return null;
        }
        return new Vector3i(selectedChunk);
    }
View Full Code Here


                chunks.clear();
                map.clear();
                recomputeRenderY();
            } else if (event instanceof ChunkMonitorEvent.BasicChunkEvent) {
                final ChunkMonitorEvent.BasicChunkEvent bEvent = (ChunkMonitorEvent.BasicChunkEvent) event;
                final Vector3i pos = bEvent.getPosition();
                final ChunkMonitorEntry entry;
                if (event instanceof ChunkMonitorEvent.Created) {
                    final ChunkMonitorEvent.Created cEvent = (ChunkMonitorEvent.Created) event;
                    entry = cEvent.getEntry();
                    if (pos.y < minRenderY) {
View Full Code Here

    private void sendNewChunks(NetData.NetMessage.Builder message) {
        if (!readyChunks.isEmpty()) {
            chunkSendCounter += chunkSendRate * NET_TICK_RATE * networkSystem.getBandwidthPerClient();
            if (chunkSendCounter > 1.0f) {
                chunkSendCounter -= 1.0f;
                Vector3i center = new Vector3i();
                LocationComponent loc = getEntity().getComponent(ClientComponent.class).character.getComponent(LocationComponent.class);
                if (loc != null) {
                    center.set(TeraMath.calcChunkPos(new Vector3i(loc.getWorldPosition(), 0.5f)));
                }
                Vector3i pos = null;
                int distance = Integer.MAX_VALUE;
                for (Vector3i chunkPos : readyChunks.keySet()) {
                    int chunkDistance = chunkPos.distanceSquared(center);
                    if (pos == null || chunkDistance < distance) {
                        pos = chunkPos;
View Full Code Here

    }

    private void sendChunkInvalidations(NetData.NetMessage.Builder message) {
        Iterator<Vector3i> i = invalidatedChunks.iterator();
        while (i.hasNext()) {
            Vector3i pos = i.next();
            i.remove();
            relevantChunks.remove(pos);
            message.addInvalidateChunk(NetData.InvalidateChunkMessage.newBuilder().setPos(NetMessageUtil.convert(pos)));
        }
        invalidatedChunks.clear();
View Full Code Here

        invalidatedChunks.add(pos);
    }

    @Override
    public void onBlockChanged(Vector3i pos, Block newBlock, Block originalBlock) {
        Vector3i chunkPos = TeraMath.calcChunkPos(pos);
        if (relevantChunks.contains(chunkPos)) {
            queuedOutgoingBlockChanges.add(NetData.BlockChangeMessage.newBuilder()
                    .setPos(NetMessageUtil.convert(pos))
                    .setNewBlock(newBlock.getId())
                    .build());
View Full Code Here

        }
    }

    @Override
    public void onBiomeChanged(Vector3i pos, Biome newBiome, Biome originalBiome) {
        Vector3i chunkPos = TeraMath.calcChunkPos(pos);
        if (relevantChunks.contains(chunkPos)) {
            queuedOutgoingBiomeChanges.add(NetData.BiomeChangeMessage.newBuilder()
                .setPos(NetMessageUtil.convert(pos))
                .setNewBiome(biomeManager.getBiomeShortId(newBiome))
                .build());
View Full Code Here

        }

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == 2) {
                final Vector3i pos = calcPlayerChunkPos();
                if (pos != null) {
                    setRenderY(pos.y);
                }
            }
        }
View Full Code Here

            int xmin = Integer.MAX_VALUE;
            int xmax = Integer.MIN_VALUE;
            int ymin = Integer.MAX_VALUE;
            int ymax = Integer.MIN_VALUE;
            for (ChunkMonitorEntry entry : chunkEntries) {
                final Vector3i pos = entry.getPosition();
                if (pos.y != renderY) {
                    continue;
                }
                if (pos.x < xmin) {
                    xmin = pos.x;
View Full Code Here

            }
            return (System.currentTimeMillis() - time);
        }

        private void doFollowPlayer() {
            final Vector3i pos = calcPlayerChunkPos();
            if (pos != null) {
                setRenderY(pos.y);
            }
        }
View Full Code Here

        }
    }

    private void spawnPlayer(EntityRef clientEntity, Vector3i initialSpawnPosition) {

        Vector3i spawnPos = getSafeSpawnPosition(initialSpawnPosition);

        ClientComponent client = clientEntity.getComponent(ClientComponent.class);
        if (client != null) {
            PlayerFactory playerFactory = new PlayerFactory(entityManager);
            EntityRef playerCharacter = playerFactory.newInstance(new Vector3f(spawnPos.x, spawnPos.y + 1.5f, spawnPos.z), clientEntity);
            Location.attachChild(playerCharacter, clientEntity, new Vector3f(), new Quat4f(0, 0, 0, 1));

            Client clientListener = networkSystem.getOwner(clientEntity);
            Vector3i distance = clientListener.getViewDistance().getChunkDistance();
            updateRelevanceEntity(clientEntity, distance);
            client.character = playerCharacter;
            clientEntity.saveComponent(client);
            playerCharacter.send(new OnPlayerSpawnedEvent());
        }
View Full Code Here

TOP

Related Classes of org.terasology.math.Vector3i

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.