Search in sources :

Example 96 with Vec3

use of net.minecraft.world.phys.Vec3 in project CyclopsCore by CyclopsMC.

the class DynamicBaseModel method addBakedQuadRotated.

/**
 * Add a given rotated quad to a list of quads.
 * @param quads The quads to append to.
 * @param x1 Start X
 * @param x2 End X
 * @param z1 Start Z
 * @param z2 End Z
 * @param y Y
 * @param texture The base texture
 * @param side The side to add render quad at.
 * @param rotation The rotation index to rotate by.
 * @param isColored When set to true a colored baked quad will be made, otherwise a regular baked quad is used.
 * @param shadeColor The shade color
 * @param uvs A double array of 4 uv pairs
 */
protected static void addBakedQuadRotated(List<BakedQuad> quads, float x1, float x2, float z1, float z2, float y, TextureAtlasSprite texture, Direction side, int rotation, boolean isColored, int shadeColor, float[][] uvs) {
    Vec3 v1 = rotate(new Vec3(x1 - .5, y - .5, z1 - .5), side).add(.5, .5, .5);
    Vec3 v2 = rotate(new Vec3(x1 - .5, y - .5, z2 - .5), side).add(.5, .5, .5);
    Vec3 v3 = rotate(new Vec3(x2 - .5, y - .5, z2 - .5), side).add(.5, .5, .5);
    Vec3 v4 = rotate(new Vec3(x2 - .5, y - .5, z1 - .5), side).add(.5, .5, .5);
    int[] data = Ints.concat(vertexToInts((float) v1.x, (float) v1.y, (float) v1.z, shadeColor, texture, uvs[(0 + rotation) % 4][0] * 16, uvs[(0 + rotation) % 4][1] * 16), vertexToInts((float) v2.x, (float) v2.y, (float) v2.z, shadeColor, texture, uvs[(1 + rotation) % 4][0] * 16, uvs[(1 + rotation) % 4][1] * 16), vertexToInts((float) v3.x, (float) v3.y, (float) v3.z, shadeColor, texture, uvs[(2 + rotation) % 4][0] * 16, uvs[(2 + rotation) % 4][1] * 16), vertexToInts((float) v4.x, (float) v4.y, (float) v4.z, shadeColor, texture, uvs[(3 + rotation) % 4][0] * 16, uvs[(3 + rotation) % 4][1] * 16));
    // This fixes lighting issues when item is rendered in hand/inventory
    ForgeHooksClient.fillNormal(data, side);
    quads.add(new BakedQuad(data, -1, side, texture, false));
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Vec3(net.minecraft.world.phys.Vec3)

Example 97 with Vec3

use of net.minecraft.world.phys.Vec3 in project SolarCraftRepository by FINDERFEED.

the class RadiantSmallTreeFoliagePlacer method isValidPos.

private boolean isValidPos(BlockPos mainpos, BlockPos posToCheck) {
    Vec3 mainposvec = Helpers.getBlockCenter(mainpos);
    Vec3 posToCheckVec = Helpers.getBlockCenter(posToCheck);
    Vec3 horizontalVector = new Vec3(posToCheckVec.x - mainposvec.x, 0, posToCheckVec.z - mainposvec.z);
    float x;
    if (posToCheckVec.y < mainposvec.y) {
        double razn = mainposvec.y - posToCheckVec.y;
        x = (5 - (float) (razn));
        if (Math.round(razn) != 1) {
            x /= 1.5f;
        }
    } else {
        x = 5 - (float) (posToCheckVec.y - mainposvec.y);
    }
    if (horizontalVector.length() <= Math.sqrt(2.3 * x)) {
        return true;
    }
    return false;
}
Also used : Vec3(net.minecraft.world.phys.Vec3)

Example 98 with Vec3

use of net.minecraft.world.phys.Vec3 in project SolarCraftRepository by FINDERFEED.

the class CeilingDripstoneLikeCrystals method isValidPlace.

private boolean isValidPlace(WorldGenLevel world, BlockPos origin, BlockPos posToCheck, int maxheight, int maxRad) {
    if (world.getBlockState(posToCheck).isAir()) {
        Vec3 horizontal = new Vec3(posToCheck.getX() - origin.getX(), 0, posToCheck.getZ() - origin.getZ());
        double height = Math.abs(posToCheck.getY() - origin.getY());
        double logPos = maxheight - height + 1;
        double radius = Math.log(logPos);
        return horizontal.length() <= radius;
    } else {
        return false;
    }
}
Also used : Vec3(net.minecraft.world.phys.Vec3)

Example 99 with Vec3

use of net.minecraft.world.phys.Vec3 in project SolarCraftRepository by FINDERFEED.

the class KeyDefenderTile method triggerTrap.

public void triggerTrap() {
    if (!this.level.isClientSide && !activated) {
        this.activated = true;
        for (int i = 0; i < 20; i++) {
            Zombie entity = new Zombie(EntityType.ZOMBIE, this.level);
            Vec3 pos;
            pos = new Vec3(this.worldPosition.getX() + level.random.nextFloat() * 8 - 4, this.worldPosition.getY() + 1, this.worldPosition.getZ() + level.random.nextFloat() * 8 - 4);
            entity.setPos(pos.x, pos.y, pos.z);
            this.level.addFreshEntity(entity);
        }
    }
}
Also used : Zombie(net.minecraft.world.entity.monster.Zombie) Vec3(net.minecraft.world.phys.Vec3)

Example 100 with Vec3

use of net.minecraft.world.phys.Vec3 in project HexMod by gamma-delta.

the class BlockEntityConjured method landParticle.

public void landParticle(Entity entity, int number) {
    if (getBlockState().getBlock() instanceof BlockConjured) {
        for (int i = 0; i < number * 2; i++) {
            int color = this.colorizer.getColor(entity.tickCount, entity.position().add(new Vec3(RANDOM.nextFloat(), RANDOM.nextFloat(), RANDOM.nextFloat()).scale(RANDOM.nextFloat() * 3)));
            assert level != null;
            level.addParticle(new ConjureParticleOptions(color, false), entity.getX() + (RANDOM.nextFloat() * 0.8D) - 0.2D, getBlockPos().getY() + (RANDOM.nextFloat() * 0.05D) + 0.95D, entity.getZ() + (RANDOM.nextFloat() * 0.8D) - 0.2D, 0.0, 0.0, 0.0);
        }
    }
}
Also used : Vec3(net.minecraft.world.phys.Vec3) ConjureParticleOptions(at.petrak.hexcasting.common.particles.ConjureParticleOptions)

Aggregations

Vec3 (net.minecraft.world.phys.Vec3)1131 BlockPos (net.minecraft.core.BlockPos)341 ItemStack (net.minecraft.world.item.ItemStack)189 Entity (net.minecraft.world.entity.Entity)133 Direction (net.minecraft.core.Direction)127 AABB (net.minecraft.world.phys.AABB)125 LivingEntity (net.minecraft.world.entity.LivingEntity)124 BlockState (net.minecraft.world.level.block.state.BlockState)111 Player (net.minecraft.world.entity.player.Player)91 BlockHitResult (net.minecraft.world.phys.BlockHitResult)85 Level (net.minecraft.world.level.Level)81 ServerLevel (net.minecraft.server.level.ServerLevel)74 ItemEntity (net.minecraft.world.entity.item.ItemEntity)74 InputWindowElement (com.simibubi.create.foundation.ponder.element.InputWindowElement)61 Selection (com.simibubi.create.foundation.ponder.Selection)53 ClipContext (net.minecraft.world.level.ClipContext)53 ServerPlayer (net.minecraft.server.level.ServerPlayer)51 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)43 HitResult (net.minecraft.world.phys.HitResult)43 WorldSectionElement (com.simibubi.create.foundation.ponder.element.WorldSectionElement)40