Search in sources :

Example 41 with Pos

use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.

the class PacketSpawnParticleStream method handleClientSide.

@Override
public void handleClientSide(EntityPlayer player) {
    if (player.worldObj.provider.dimensionId == dim) {
        double distance = start.distance(end);
        Pos direction = start.sub(end).divide(distance);
        int particles = (int) (distance / 0.3);
        for (int l = 0; l < particles; ++l) {
            Pos next = start.sub(direction.multiply(l));
            player.worldObj.spawnParticle("portal", next.x(), next.y(), next.z(), 0, 0, 0);
        }
    }
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos)

Example 42 with Pos

use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.

the class PacketSpawnParticleStream method decodeInto.

@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
    dim = buffer.readInt();
    start = new Pos(buffer);
    end = new Pos(buffer);
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos)

Example 43 with Pos

use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.

the class RenderSelection method render.

public static void render(Cube selection, Color box_color) {
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    Tessellator tess = Tessellator.instance;
    Tessellator.renderingWorldRenderer = false;
    // GL11.glLineWidth(20f);
    boolean render1 = false;
    // render p1
    if (selection.pointOne() != null && selection.pointOne().y() >= 0) {
        IPos3D vec1 = selection.pointOne();
        GL11.glTranslated(vec1.x() - RenderManager.renderPosX, vec1.y() + 1 - RenderManager.renderPosY, vec1.z() - RenderManager.renderPosZ);
        GL11.glScalef(1.0F, -1.0F, -1.0F);
        GL11.glColor3f(255, 0, 0);
        renderBlockBox(tess);
        render1 = true;
    }
    // render p2
    if (selection.pointTwo() != null && selection.pointOne().y() >= 0) {
        IPos3D p1 = selection.pointOne();
        IPos3D p2 = selection.pointTwo();
        if (render1) {
            float x = (float) (p2.x() - p1.x());
            float y = (float) (p1.y() - p2.y()) + 1;
            float z = (float) (p1.z() - p2.z()) - 1;
            GL11.glTranslated(x, y, z);
        } else {
            GL11.glTranslated(p2.x() - RenderManager.renderPosX, p2.y() + 1 - RenderManager.renderPosY, p2.z() - RenderManager.renderPosZ);
        }
        GL11.glScalef(1.0F, -1.0F, -1.0F);
        GL11.glColor3f(0, 255, 0);
        renderBlockBox(tess);
    }
    if (selection.isValid()) {
        float x = (float) (selection.min().xf() - selection.pointTwo().x());
        float y = (float) (selection.min().yf() - selection.pointTwo().y());
        float z = (float) (selection.min().zf() - selection.pointTwo().z()) - 1;
        // translate to the low point..
        GL11.glTranslated(x, y, z);
        GL11.glScalef(1.0F, -1.0F, -1.0F);
        GL11.glColor3f(box_color.getRed(), box_color.getGreen(), box_color.getBlue());
        renderBlockBoxTo(tess, new Pos(selection.getSizeX(), -selection.getSizeY(), -selection.getSizeZ()));
    }
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    // tess.renderingWorldRenderer = true;
    GL11.glPopMatrix();
}
Also used : IPos3D(com.builtbroken.jlib.data.vector.IPos3D) Tessellator(net.minecraft.client.renderer.Tessellator) Pos(com.builtbroken.mc.lib.transform.vector.Pos)

Example 44 with Pos

use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.

the class BlockUtility method setBlockSneaky.

/**
 * Sets a block in a sneaky way to bypass some restraints.
 */
public static void setBlockSneaky(World world, Pos position, Block block, int metadata, TileEntity tileEntity) {
    if (block != null && world != null) {
        Chunk chunk = world.getChunkFromChunkCoords(position.xi() >> 4, position.zi() >> 4);
        Pos chunkPosition = new Pos(position.xi() & 0xF, position.yi() & 0xF, position.zi() & 0xF);
        int heightMapIndex = chunkPosition.zi() << 4 | chunkPosition.xi();
        if (position.yi() >= chunk.precipitationHeightMap[heightMapIndex] - 1) {
            chunk.precipitationHeightMap[heightMapIndex] = -999;
        }
        int heightMapValue = chunk.heightMap[heightMapIndex];
        world.removeTileEntity(position.xi(), position.yi(), position.zi());
        ExtendedBlockStorage extendedBlockStorage = chunk.getBlockStorageArray()[position.yi() >> 4];
        if (extendedBlockStorage == null) {
            extendedBlockStorage = new ExtendedBlockStorage((position.yi() >> 4) << 4, !world.provider.hasNoSky);
            chunk.getBlockStorageArray()[position.yi() >> 4] = extendedBlockStorage;
        }
        extendedBlockStorage.func_150818_a(chunkPosition.xi(), chunkPosition.yi(), chunkPosition.zi(), block);
        extendedBlockStorage.setExtBlockMetadata(chunkPosition.xi(), chunkPosition.yi(), chunkPosition.zi(), metadata);
        if (position.yi() >= heightMapValue) {
            chunk.generateSkylightMap();
        } else {
            // chunk.getBlockLightOpacity(chunkPosition.xi(), position.yi(), chunkPosition.zi())
            if (chunk.getBlockLightValue(chunkPosition.xi(), position.yi(), chunkPosition.zi(), 0) > 0) {
                if (position.yi() >= heightMapValue) {
                    relightBlock(chunk, chunkPosition.clone().add(new Pos(0, 1, 0)));
                }
            } else if (position.yi() == heightMapValue - 1) {
                relightBlock(chunk, chunkPosition);
            }
            propagateSkylightOcclusion(chunk, chunkPosition);
        }
        chunk.isModified = true;
        // updateAllLightTypes
        world.func_147451_t(position.xi(), position.yi(), position.zi());
        if (tileEntity != null) {
            world.setTileEntity(position.xi(), position.yi(), position.zi(), tileEntity);
        }
        world.markBlockForUpdate(position.xi(), position.yi(), position.zi());
    }
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos) Chunk(net.minecraft.world.chunk.Chunk) ExtendedBlockStorage(net.minecraft.world.chunk.storage.ExtendedBlockStorage)

Example 45 with Pos

use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.

the class PacketSpawnParticleCircle method handleClientSide.

@Override
public void handleClientSide(EntityPlayer player) {
    if (// TODO add error logging as neither condition should happen
    player.worldObj.provider.dimensionId == dim && name != null && !name.isEmpty()) {
        if (Engine.runningAsDev && distance <= 1) {
            Engine.logger().error("PacketSpawnParticleCircle: Size of " + distance + " is to small to render effectively. " + new Pos(x, y, z).toString());
            return;
        }
        double c = 2 * Math.PI * distance;
        int particles = (int) Math.ceil(c) / 2;
        if (particles % 2 == 1) {
            particles += 1;
        }
        particles *= 5;
        double angleSeg = 360.0 / (double) particles;
        for (int i = 0; i < particles; i++) {
            EulerAngle angle = new EulerAngle(angleSeg * i, 0);
            Pos pos = angle.toPos().multiply(distance).add(x, y, z);
            player.worldObj.spawnParticle(name, pos.x(), pos.y(), pos.z(), vx, vy, vz);
        }
    }
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos) EulerAngle(com.builtbroken.mc.lib.transform.rotation.EulerAngle)

Aggregations

Pos (com.builtbroken.mc.lib.transform.vector.Pos)68 Block (net.minecraft.block.Block)11 TileEntity (net.minecraft.tileentity.TileEntity)8 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)8 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)7 Cube (com.builtbroken.mc.lib.transform.region.Cube)6 Test (org.junit.Test)6 IPos3D (com.builtbroken.jlib.data.vector.IPos3D)5 BlockEdit (com.builtbroken.mc.lib.world.edit.BlockEdit)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Vector3DistanceComparator (com.builtbroken.mc.lib.transform.sorting.Vector3DistanceComparator)4 BlockTile (com.builtbroken.mc.prefab.tile.BlockTile)4 Tile (com.builtbroken.mc.prefab.tile.Tile)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 World (net.minecraft.world.World)4 Pair (com.builtbroken.jlib.type.Pair)3 PacketTile (com.builtbroken.mc.core.network.packet.PacketTile)3 Quaternion (com.builtbroken.mc.lib.transform.rotation.Quaternion)3 AbstractTest (com.builtbroken.mc.testing.junit.AbstractTest)3