Search in sources :

Example 26 with Pos

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

the class FXElectricBolt2 method renderParticle.

@Override
public void renderParticle(Tessellator tessellator, float partialframe, float cosYaw, float cosPitch, float sinYaw, float sinSinPitch, float cosSinPitch) {
    EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    tessellator.draw();
    GL11.glPushMatrix();
    GL11.glDepthMask(false);
    GL11.glEnable(3042);
    glShadeModel(GL_SMOOTH);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
    /**
		 * Render the actual bolts.
		 */
    tessellator.startDrawingQuads();
    tessellator.setBrightness(15728880);
    Pos playerVector = new Pos(sinYaw * -cosPitch, -cosSinPitch / cosYaw, cosYaw * cosPitch);
    int renderlength = (int) ((this.particleAge + partialframe + (int) (this.boltLength * 3.0F)) / (int) (this.boltLength * 3.0F) * this.segmentCount);
    for (BoltSegment segment : this.segments) {
        if (segment != null && segment.id <= renderlength) {
            double renderWidth = this.boltWidth * ((new Pos(player).distance(segment.start) / 5f + 1f) * (1 + segment.alpha) * 0.5f);
            renderWidth = Math.min(this.boltWidth, Math.max(renderWidth, 0));
            if (segment.difference.magnitude() > 0 && segment.difference.magnitude() != Double.NaN && segment.difference.magnitude() != Double.POSITIVE_INFINITY && renderWidth > 0 && renderWidth != Double.NaN && renderWidth != Double.POSITIVE_INFINITY) {
                Pos diffPrev = playerVector.cross(segment.prevDiff).multiply(renderWidth / segment.sinPrev);
                Pos diffNext = playerVector.cross(segment.nextDiff).multiply(renderWidth / segment.sinNext);
                Pos startVec = segment.start;
                Pos endVec = segment.end;
                float rx1 = (float) (startVec.x() - interpPosX);
                float ry1 = (float) (startVec.y() - interpPosY);
                float rz1 = (float) (startVec.z() - interpPosZ);
                float rx2 = (float) (endVec.x() - interpPosX);
                float ry2 = (float) (endVec.y() - interpPosY);
                float rz2 = (float) (endVec.z() - interpPosZ);
                tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, (1.0F - (this.particleAge >= 0 ? ((float) this.particleAge / (float) this.particleMaxAge) : 0.0F) * 0.6f) * segment.alpha);
                tessellator.addVertexWithUV(rx2 - diffNext.x(), ry2 - diffNext.y(), rz2 - diffNext.z(), 0.5D, 0.0D);
                tessellator.addVertexWithUV(rx1 - diffPrev.x(), ry1 - diffPrev.y(), rz1 - diffPrev.z(), 0.5D, 0.0D);
                tessellator.addVertexWithUV(rx1 + diffPrev.x(), ry1 + diffPrev.y(), rz1 + diffPrev.z(), 0.5D, 1.0D);
                tessellator.addVertexWithUV(rx2 + diffNext.x(), ry2 + diffNext.y(), rz2 + diffNext.z(), 0.5D, 1.0D);
                if (segment.next == null) {
                    Pos roundEnd = segment.end.clone().add(segment.difference.clone().normalize().multiply(renderWidth));
                    float rx3 = (float) (roundEnd.x() - interpPosX);
                    float ry3 = (float) (roundEnd.y() - interpPosY);
                    float rz3 = (float) (roundEnd.z() - interpPosZ);
                    tessellator.addVertexWithUV(rx3 - diffNext.x(), ry3 - diffNext.y(), rz3 - diffNext.z(), 0.0D, 0.0D);
                    tessellator.addVertexWithUV(rx2 - diffNext.x(), ry2 - diffNext.y(), rz2 - diffNext.z(), 0.5D, 0.0D);
                    tessellator.addVertexWithUV(rx2 + diffNext.x(), ry2 + diffNext.y(), rz2 + diffNext.z(), 0.5D, 1.0D);
                    tessellator.addVertexWithUV(rx3 + diffNext.x(), ry3 + diffNext.y(), rz3 + diffNext.z(), 0.0D, 1.0D);
                }
                if (segment.prev == null) {
                    Pos roundEnd = segment.start.clone().subtract(segment.difference.clone().normalize().multiply(renderWidth));
                    float rx3 = (float) (roundEnd.x() - interpPosX);
                    float ry3 = (float) (roundEnd.y() - interpPosY);
                    float rz3 = (float) (roundEnd.z() - interpPosZ);
                    tessellator.addVertexWithUV(rx1 - diffPrev.x(), ry1 - diffPrev.y(), rz1 - diffPrev.z(), 0.5D, 0.0D);
                    tessellator.addVertexWithUV(rx3 - diffPrev.x(), ry3 - diffPrev.y(), rz3 - diffPrev.z(), 0.0D, 0.0D);
                    tessellator.addVertexWithUV(rx3 + diffPrev.x(), ry3 + diffPrev.y(), rz3 + diffPrev.z(), 0.0D, 1.0D);
                    tessellator.addVertexWithUV(rx1 + diffPrev.x(), ry1 + diffPrev.y(), rz1 + diffPrev.z(), 0.5D, 1.0D);
                }
            }
        }
    }
    tessellator.draw();
    GL11.glDisable(3042);
    GL11.glDepthMask(true);
    GL11.glPopMatrix();
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(PARTICLE_RESOURCE);
    tessellator.startDrawingQuads();
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 27 with Pos

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

the class TestBlockEdit method testEquals.

@Test
public void testEquals() {
    World world = FakeWorld.newWorld("BlockEditTest");
    World world2 = FakeWorld.newWorld("BlockEditTest2");
    BlockEdit location = new BlockEdit(world, 0, 0, 0);
    BlockEdit location2 = new BlockEdit(world, 0, 0, 0);
    //Test would equals
    Assert.assertEquals("BlockEdit one should equal itself", location, location);
    Assert.assertEquals("BlockEdit two should equal itself", location2, location2);
    Assert.assertEquals("BlockEdit one & two should equal each other", location, location2);
    location2 = new BlockEdit(world2, 0, 0, 0);
    //Test world not equal
    Assert.assertNotSame("BlockEdit one & two should not equal each other", location, location2);
    location = new BlockEdit(world, 0, 1, 0);
    //Test pos not equal
    Assert.assertNotSame("BlockEdit one & two should not equal each other", location, location2);
    //Test decimal point
    for (Pos pos : new Pos[] { new Pos(1, 2.0, 3.0f), new Pos(1, 2.2, 3.1f), new Pos(1.5125412, 2.2223, 3.0f), new Pos(1.231, 2.45454, 3.23213f) }) {
        location = new BlockEdit(world, pos.x(), pos.y(), pos.z());
        location2 = new BlockEdit(world, pos.x(), pos.y(), pos.z());
        //Test would equals
        Assert.assertEquals("BlockEdit one should equal itself", location, location);
        Assert.assertEquals("BlockEdit two should equal itself", location2, location2);
        Assert.assertEquals("BlockEdit one & two should equal each other", location, location2);
    }
    location = new BlockEdit(world, 1, 2, 3);
    location2 = new BlockEdit(world, 1.3, 2.2, 3.4);
    //Test would equals
    Assert.assertEquals("BlockEdit one should equal itself", location, location);
    Assert.assertEquals("BlockEdit two should equal itself", location2, location2);
    Assert.assertEquals("BlockEdit one & two should equal each other", location, location2);
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) World(net.minecraft.world.World) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) BlockEdit(com.builtbroken.mc.lib.world.edit.BlockEdit) AbstractTest(com.builtbroken.mc.testing.junit.AbstractTest) Test(org.junit.Test)

Example 28 with Pos

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

the class TestBlockEdit method testHashCode.

@Test
public void testHashCode() {
    World world = FakeWorld.newWorld("BlockEditTest");
    World world2 = FakeWorld.newWorld("BlockEditTest2");
    BlockEdit location = new BlockEdit(world, 0, 0, 0);
    BlockEdit location2 = new BlockEdit(world, 0, 0, 0);
    //Test would equals
    Assert.assertEquals("BlockEdit one should equal itself", location.hashCode(), location.hashCode());
    Assert.assertEquals("BlockEdit two should equal itself", location2.hashCode(), location2.hashCode());
    Assert.assertEquals("BlockEdit one & two should equal each other", location.hashCode(), location2.hashCode());
    location2 = new BlockEdit(world2, 0, 0, 0);
    //Test world not equal
    Assert.assertNotSame("BlockEdit one & two should not equal each other", location.hashCode(), location2.hashCode());
    location = new BlockEdit(world, 0, 1, 0);
    //Test pos not equal
    Assert.assertNotSame("BlockEdit one & two should not equal each other", location.hashCode(), location2.hashCode());
    //Test decimal point
    for (Pos pos : new Pos[] { new Pos(1, 2.0, 3.0f), new Pos(1, 2.2, 3.1f), new Pos(1.5125412, 2.2223, 3.0f), new Pos(1.231, 2.45454, 3.23213f) }) {
        location = new BlockEdit(world, pos.x(), pos.y(), pos.z());
        location2 = new BlockEdit(world, pos.x(), pos.y(), pos.z());
        //Test would equals
        Assert.assertEquals("BlockEdit one should equal itself", location.hashCode(), location.hashCode());
        Assert.assertEquals("BlockEdit two should equal itself", location2.hashCode(), location2.hashCode());
        Assert.assertEquals("BlockEdit one & two should equal each other", location.hashCode(), location2.hashCode());
    }
    location = new BlockEdit(world, 1, 2, 3);
    location2 = new BlockEdit(world, 1.3, 2.2, 3.4);
    //Test would equals
    Assert.assertEquals("BlockEdit one should equal itself", location.hashCode(), location.hashCode());
    Assert.assertEquals("BlockEdit two should equal itself", location2.hashCode(), location2.hashCode());
    Assert.assertEquals("BlockEdit one & two should equal each other", location.hashCode(), location2.hashCode());
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) World(net.minecraft.world.World) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) BlockEdit(com.builtbroken.mc.lib.world.edit.BlockEdit) AbstractTest(com.builtbroken.mc.testing.junit.AbstractTest) Test(org.junit.Test)

Example 29 with Pos

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

the class AbstractTileTest method testGetExplosionResistance.

@Test
public void testGetExplosionResistance() {
    FakeWorld world = FakeWorld.newWorld("TestGetExplosionResistance");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    tile.getExplosionResistance(player);
    world.setBlock(0, 0, 0, block);
    tile = ((Tile) world.getTileEntity(0, 0, 0));
    tile.getExplosionResistance(player, new Pos(2));
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) PacketTile(com.builtbroken.mc.core.network.packet.PacketTile) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile) Test(org.junit.Test)

Example 30 with Pos

use of com.builtbroken.mc.imp.transform.vector.Pos in project ICBM-Classic by BuiltBrokenModding.

the class GuiCruiseLauncher method keyTyped.

@Override
public void keyTyped(char par1, int par2) {
    super.keyTyped(par1, par2);
    this.textFieldX.textboxKeyTyped(par1, par2);
    this.textFieldZ.textboxKeyTyped(par1, par2);
    this.textFieldY.textboxKeyTyped(par1, par2);
    this.textFieldFreq.textboxKeyTyped(par1, par2);
    try {
        Pos newTarget = new Pos(parseInt(this.textFieldX.getText()), parseInt(this.textFieldY.getText()), parseInt(this.textFieldZ.getText()));
        this.tileEntity.setTarget(newTarget);
        Engine.instance.packetHandler.sendToServer(new PacketTile(tileEntity, 2, tileEntity.getTarget().xi(), this.tileEntity.getTarget().yi(), this.tileEntity.getTarget().zi()));
    } catch (NumberFormatException e) {
    }
    try {
        short newFrequency = (short) Math.max(Short.parseShort(this.textFieldFreq.getText()), 0);
        this.tileEntity.setFrequency(newFrequency);
        Engine.instance.packetHandler.sendToServer(new PacketTile(tileEntity, 1, tileEntity.getFrequency()));
    } catch (NumberFormatException e) {
    }
}
Also used : PacketTile(com.builtbroken.mc.core.network.packet.PacketTile) Pos(com.builtbroken.mc.imp.transform.vector.Pos)

Aggregations

Pos (com.builtbroken.mc.imp.transform.vector.Pos)105 Block (net.minecraft.block.Block)25 TileEntity (net.minecraft.tileentity.TileEntity)13 Location (com.builtbroken.mc.imp.transform.vector.Location)11 Entity (net.minecraft.entity.Entity)11 Cube (com.builtbroken.mc.imp.transform.region.Cube)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)7 Test (org.junit.Test)7 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)6 EntityMissile (icbm.classic.content.entity.EntityMissile)6 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)6 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)6 IPos3D (com.builtbroken.jlib.data.vector.IPos3D)5 PacketTile (com.builtbroken.mc.core.network.packet.PacketTile)5 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)5 ItemStack (net.minecraft.item.ItemStack)5 EulerAngle (com.builtbroken.mc.imp.transform.rotation.EulerAngle)4 BlockTile (com.builtbroken.mc.prefab.tile.BlockTile)4 Tile (com.builtbroken.mc.prefab.tile.Tile)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4