Search in sources :

Example 11 with Vec3i

use of net.minecraft.util.math.Vec3i in project Overloaded by CJ-MC-Mods.

the class ModelUtils method renderQuads.

public static void renderQuads(List<BakedQuad> listQuads) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    int i = 0;
    vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
    for (int j = listQuads.size(); i < j; ++i) {
        BakedQuad bakedquad = listQuads.get(i);
        vertexbuffer.addVertexData(bakedquad.getVertexData());
        vertexbuffer.putColorRGB_F4(1, 1, 1);
        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        vertexbuffer.putNormal((float) vec3i.getX(), (float) vec3i.getY(), (float) vec3i.getZ());
    }
    tessellator.draw();
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Vec3i(net.minecraft.util.math.Vec3i) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 12 with Vec3i

use of net.minecraft.util.math.Vec3i in project RecurrentComplex by Ivorforce.

the class CommandNaturalSpace method placeNaturalAir.

public static void placeNaturalAir(MockWorld world, BlockArea area, int floorDistance, int maxClosedSides) {
    BlockGenericSpace spaceBlock = RCBlocks.genericSpace;
    BlockPos lowerPoint = area.getLowerCorner();
    BlockPos higherPoint = area.getHigherCorner();
    Set<BlockPos> set = new HashSet<>();
    for (BlockSurfacePos surfaceCoord : BlockSurfaceArea.from(area)) {
        int safePoint = lowerPoint.getY();
        for (int y = higherPoint.getY(); y >= lowerPoint.getY(); y--) {
            IBlockState blockState = world.getBlockState(surfaceCoord.blockPos(y));
            if ((blockState.getMaterial() != Material.AIR && blockState.getBlock() != spaceBlock) || sidesClosed(world, surfaceCoord.blockPos(y), area) >= maxClosedSides) {
                boolean isFloor = blockState == RCBlocks.genericSolid.getDefaultState();
                safePoint = y + (isFloor ? 1 : floorDistance);
                break;
            }
        }
        for (int y = safePoint; y <= higherPoint.getY(); y++) set.add(surfaceCoord.blockPos(y));
        if (safePoint > lowerPoint.getY()) {
            for (int y = lowerPoint.getY(); y <= higherPoint.getY(); y++) {
                IBlockState blockState = world.getBlockState(surfaceCoord.blockPos(y));
                if ((blockState.getMaterial() != Material.AIR && blockState.getBlock() != spaceBlock) || sidesClosed(world, surfaceCoord.blockPos(y), area) >= maxClosedSides) {
                    safePoint = y - 1;
                    break;
                }
            }
        }
        for (int y = lowerPoint.getY(); y <= safePoint; y++) set.add(surfaceCoord.blockPos(y));
    }
    set.forEach(pos -> {
        BlockPos down = pos.down();
        BlockPos down2 = pos.down(2);
        world.setBlockState(pos, pos.getY() > lowerPoint.getY() && !set.contains(down) && world.getBlockState(down).getBlock().isReplaceable(world, down) && world.getBlockState(down2).getBlock().isReplaceable(world, down2) && new BlockArea(pos.subtract(new Vec3i(2, 0, 2)), pos.add(new Vec3i(2, 0, 2))).stream().allMatch(set::contains) ? spaceBlock.getDefaultState().withProperty(BlockGenericSpace.TYPE, 1) : spaceBlock.getDefaultState());
    });
}
Also used : BlockArea(ivorius.ivtoolkit.blocks.BlockArea) Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) BlockGenericSpace(ivorius.reccomplex.block.BlockGenericSpace) BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) BlockPos(net.minecraft.util.math.BlockPos) HashSet(java.util.HashSet)

Example 13 with Vec3i

use of net.minecraft.util.math.Vec3i in project Gaspunk by Ladysnake.

the class EntityGrenade method onImpact.

@Override
protected void onImpact(@Nonnull RayTraceResult result) {
    if (result.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(result.getBlockPos()).isFullBlock() && this.ignoreTime-- <= 0) {
        Vec3i hitVector = result.sideHit.getDirectionVec();
        motionX *= hitVector.getX() * -0.4 + 0.2;
        if (Math.abs(motionX) < 0.2)
            motionX = 0;
        motionY *= hitVector.getY() * -0.4 + 0.2;
        if (Math.abs(motionY) < 0.3)
            motionY = 0;
        motionZ *= hitVector.getZ() * -0.4 + 0.2;
        if (Math.abs(motionZ) < 0.2)
            motionZ = 0;
        this.ignoreTime = 2;
        isAirBorne = true;
    } else if (result.typeOfHit == RayTraceResult.Type.ENTITY) {
        this.motionX *= -0.05;
        this.motionY *= -0.05;
        this.motionZ *= -0.05;
        this.rotationYaw += 180.0F;
        this.prevRotationYaw += 180.0F;
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i)

Aggregations

Vec3i (net.minecraft.util.math.Vec3i)13 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)5 IBlockState (net.minecraft.block.state.IBlockState)4 Tessellator (net.minecraft.client.renderer.Tessellator)4 BlockPos (net.minecraft.util.math.BlockPos)4 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)2 IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)2 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)2 HashSet (java.util.HashSet)2 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)2 WorldServer (net.minecraft.world.WorldServer)2 Connection (blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection)1 com.google.gson (com.google.gson)1 BuildBattleDecorator (com.microsoft.Malmo.Schemas.BuildBattleDecorator)1 DrawBlockBasedObjectType (com.microsoft.Malmo.Schemas.DrawBlockBasedObjectType)1 XMLBlockState (com.microsoft.Malmo.Utils.BlockDrawingHelper.XMLBlockState)1 BlockAreas (ivorius.ivtoolkit.blocks.BlockAreas)1 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)1 IvMutableBlockPos (ivorius.ivtoolkit.blocks.IvMutableBlockPos)1 MCRegistry (ivorius.ivtoolkit.tools.MCRegistry)1