Package org.terasology.math

Examples of org.terasology.math.Vector3i


            }
        }
    }

    public Vector3i getPosition() {
        return new Vector3i(pos);
    }
View Full Code Here


    private void processBiomeChanges(NetData.NetMessage message) {
        for (NetData.BiomeChangeMessage biomeChange : message.getBiomeChangeList()) {
            logger.debug("Received block change to {}", blockManager.getBlock((short) biomeChange.getNewBiome()));
            // TODO: Store changes to blocks that aren't ready to be modified (the surrounding chunks aren't available)
            WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
            Vector3i pos = NetMessageUtil.convert(biomeChange.getPos());
            if (worldProvider.isBlockRelevant(pos)) {
                Biome newBiome = biomeManager.getBiomeByShortId((short) biomeChange.getNewBiome());
                worldProvider.setBiome(pos, newBiome);
            } else {
                awaitingChunkReadyBiomeUpdates.put(TeraMath.calcChunkPos(pos), biomeChange);
View Full Code Here

        }
    }

    private void processInvalidatedChunks(NetData.NetMessage message) {
        for (NetData.InvalidateChunkMessage chunk : message.getInvalidateChunkList()) {
            Vector3i chunkPos = NetMessageUtil.convert(chunk.getPos());
            remoteWorldProvider.invalidateChunks(chunkPos);
            awaitingChunkReadyBlockUpdates.removeAll(chunkPos);
            awaitingChunkReadyBiomeUpdates.removeAll(chunkPos);
        }
    }
View Full Code Here

    public void onChunkReady(Vector3i chunkPos) {
        WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);

        List<NetData.BlockChangeMessage> updateBlockMessages = awaitingChunkReadyBlockUpdates.removeAll(chunkPos);
        for (NetData.BlockChangeMessage message : updateBlockMessages) {
            Vector3i pos = NetMessageUtil.convert(message.getPos());
            Block newBlock = blockManager.getBlock((short) message.getNewBlock());
            worldProvider.setBlock(pos, newBlock);
        }

        List<NetData.BiomeChangeMessage> updateBiomeMessages = awaitingChunkReadyBiomeUpdates.removeAll(chunkPos);
        for (NetData.BiomeChangeMessage message : updateBiomeMessages) {
            Vector3i pos = NetMessageUtil.convert(message.getPos());
            Biome newBiome = biomeManager.getBiomeByShortId((short) message.getNewBiome());
            worldProvider.setBiome(pos, newBiome);
        }
    }
View Full Code Here

        result.setSequenceNumber(input.getSequenceNumber());
        if (worldProvider.isBlockRelevant(initial.getPosition())) {
            updatePosition(characterMovementComponent, result, input, entity);

            if (input.isFirstRun()) {
                checkBlockEntry(entity, new Vector3i(initial.getPosition(), 0.5f), new Vector3i(result.getPosition(), 0.5f), characterMovementComponent.height);
            }

            if (result.getMode() != MovementMode.GHOSTING && result.getMode() != MovementMode.NONE) {
                checkMode(characterMovementComponent, result, initial, entity, input.isFirstRun());
            }
View Full Code Here

        // TODO: This will only work for tall mobs/players and single block mobs
        // is this a different position than previously
        if (!oldPosition.equals(newPosition)) {
            // get the old position's blocks
            Block[] oldBlocks = new Block[(int) Math.ceil(characterHeight)];
            Vector3i currentPosition = oldPosition.clone();
            for (int currentHeight = 0; currentHeight < oldBlocks.length; currentHeight++) {
                oldBlocks[currentHeight] = worldProvider.getBlock(currentPosition);
                currentPosition.add(0, 1, 0);
            }

            // get the new position's blocks
            Block[] newBlocks = new Block[(int) Math.ceil(characterHeight)];
            currentPosition = newPosition.clone();
            for (int currentHeight = 0; currentHeight < characterHeight; currentHeight++) {
                newBlocks[currentHeight] = worldProvider.getBlock(currentPosition);
                currentPosition.add(0, 1, 0);
            }

            for (int i = 0; i < characterHeight; i++) {
                // send a block enter/leave event for this character
                entity.send(new OnEnterBlockEvent(oldBlocks[i], newBlocks[i], new Vector3i(0, i, 0)));
            }
        }
    }
View Full Code Here

            for (Vector3f side : sides) {
                Block block = worldProvider.getBlock(side);
                if (block.isClimbable()) {
                    //If any of our sides are near a climbable block, check if we are near to the side
                    Vector3i myPos = new Vector3i(worldPos, 0.5f);
                    Vector3i climbBlockPos = new Vector3i(side, 0.5f);
                    Vector3i dir = block.getDirection().getVector3i().clone();
                    float currentDistance = 10f;

                    if (dir.x != 0 && Math.abs(worldPos.x - (float) climbBlockPos.x + (float) dir.x * .5f) < movementComp.radius + 0.1f) {
                        newClimbing = true;
                        if (myPos.x < climbBlockPos.x) {
View Full Code Here

            return;
        }
        Quat4f rotation = new Quat4f();
        Vector3f tmp;

        Vector3i climbDir3i = state.getClimbDirection();
        Vector3f climbDir3f = climbDir3i.toVector3f();

        QuaternionUtil.setEuler(rotation, TeraMath.DEG_TO_RAD * state.getYaw(), 0, 0);
        tmp = new Vector3f(0.0f, 0.0f, -1.0f);
        QuaternionUtil.quatRotate(rotation, tmp, tmp);
        float angleToClimbDirection = tmp.angle(climbDir3f);
View Full Code Here

*/
public class ChunkStoreId implements StoreId {
    private Vector3i pos;

    public ChunkStoreId(Vector3i pos) {
        this.pos = new Vector3i(pos);
    }
View Full Code Here

        glEnable(GL11.GL_CULL_FACE);
    }

    private void renderBlockParticles(Vector3f worldPos, Vector3f cameraPosition, BlockParticleEffectComponent particleEffect) {

        Vector3i worldPos3i = new Vector3i(worldPos, 0.5f);
        Biome biome = worldProvider.getBiome(worldPos3i);

        glPushMatrix();
        glTranslated(worldPos.x - cameraPosition.x, worldPos.y - cameraPosition.y, worldPos.z - cameraPosition.z);
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.