Search in sources :

Example 11 with Vec3f

use of net.minecraft.util.math.Vec3f in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method drawNametag.

public static void drawNametag(MatrixStack matrixstack, Entity entity, double x, double y, double z, Color color) {
    setup3DRender(true);
    matrixstack.translate(x, y, z);
    matrixstack.multiply(new Quaternion(new Vec3f(0, -1, 0), 0, true));
    matrixstack.translate(-x, -y, -z);
    DrawableHelper.fill(matrixstack, 10, 10, 100, 100, -1);
    RenderSystem.lineWidth(1.5f);
    end3DRender();
    matrixstack.translate(x, y, z);
    matrixstack.multiply(new Quaternion(new Vec3f(0, 1, 0), 0, true));
    matrixstack.translate(-x, -y, -z);
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) Vec3f(net.minecraft.util.math.Vec3f)

Example 12 with Vec3f

use of net.minecraft.util.math.Vec3f in project Hypnotic-Client by Hypnotic-Development.

the class Vertexer method vertexLine.

public static void vertexLine(MatrixStack matrices, VertexConsumer vertexConsumer, float x1, float y1, float z1, float x2, float y2, float z2, LineColor lineColor) {
    Matrix4f model = matrices.peek().getPositionMatrix();
    Matrix3f normal = matrices.peek().getNormalMatrix();
    Vec3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2);
    int[] color1 = lineColor.getColor(x1, y1, z1, 0);
    int[] color2 = lineColor.getColor(x2, y2, z2, 1);
    vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
    vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next();
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Matrix3f(net.minecraft.util.math.Matrix3f) Vec3f(net.minecraft.util.math.Vec3f)

Example 13 with Vec3f

use of net.minecraft.util.math.Vec3f in project Hypnotic-Client by Hypnotic-Development.

the class Radar method render.

@Override
public void render(MatrixStack matrices, int scaledWidth, int scaledHeight, float partialTicks) {
    this.setWidth((float) this.size.getValue());
    this.setHeight((float) this.size.getValue());
    MatrixStack matrixStack = matrices;
    if (mc.player == null)
        return;
    DrawableHelper.fill(matrixStack, index, index, index, keyCode, index);
    RenderUtils.drawBorderRect(matrices, this.getX() + 1, this.getY(), this.getX() + this.getWidth() - 1, this.getY() + this.getHeight(), color.getColor().getRGB(), 1);
    RenderUtils.fillAndBorder(matrixStack, this.getX(), this.getY(), this.getX() + this.getWidth(), this.getY() + this.getHeight(), color.getRGB(), new Color(50, 50, 50, 250).getRGB(), 1);
    float midPos = this.getWidth() / 2.0f - 1;
    RenderUtils.fill(matrixStack, this.getX() + midPos, this.getY() + 1, this.getX() + midPos + 1, this.getY() + this.getHeight() - 1, new Color(60, 60, 60, 250).getRGB());
    RenderUtils.fill(matrixStack, this.getX() + 1, this.getY() + midPos, this.getX() + this.getWidth() - 1, this.getY() + midPos + 1, new Color(60, 60, 60, 250).getRGB());
    if (mc.world != null)
        for (Entity entity : mc.world.getEntities()) {
            if (!shouldRenderEntity(entity))
                continue;
            float xPos = (float) (entity.getX() - mc.player.getX()) + midPos + this.getX();
            float yPos = (float) (entity.getZ() - mc.player.getZ()) + midPos + this.getY() + this.getHeight();
            if (xPos < this.getX() + this.getWidth() - 2 && yPos < this.getY() + this.getHeight() - 2 && yPos > this.getY() + 2 && xPos > this.getX() + 2) {
                RenderUtils.fill(matrixStack, xPos, yPos, xPos + 1, yPos + 1, getEntityColor(entity).getRGB());
            }
        }
    matrixStack.push();
    matrixStack.translate(this.getX() + midPos + 0.5, this.getY() + midPos + 0.5, 0);
    RenderUtils.fill(matrixStack, -0.5f, -0.5f, 0.5f, 0.5f, color.getRGB());
    matrixStack.multiply(new Quaternion(new Vec3f(0.0F, 0.0F, 1.0F), mc.player.getYaw() + 180, true));
    drawPointer(matrixStack);
    matrixStack.pop();
    if (ModuleManager.INSTANCE.getModule(CustomFont.class).isEnabled()) {
        font.drawCenteredString(matrixStack, "N", this.getX() + midPos + 1, this.getY() - 2, -1);
        font.drawCenteredString(matrixStack, "S", this.getX() + midPos + 1, this.getY() + this.getWidth() - 15, -1);
        font.drawWithShadow(matrixStack, "W", this.getX() + 3, this.getY() + (this.getWidth() / 2) - 9, -1);
        font.drawWithShadow(matrixStack, "E", this.getX() + this.getWidth() - 3 - font.getStringWidth("E"), this.getY() + (this.getWidth() / 2) - 9, -1);
    } else {
        mc.textRenderer.drawWithShadow(matrixStack, "N", this.getX() + midPos - 2, this.getY() + 4 - 2, -1);
        mc.textRenderer.drawWithShadow(matrixStack, "S", this.getX() + midPos - 2, this.getY() + 4 + this.getHeight() - 15, -1);
        mc.textRenderer.drawWithShadow(matrixStack, "W", this.getX() + 3, this.getY() + 4 + this.getHeight() / 2 - 9, -1);
        mc.textRenderer.drawWithShadow(matrixStack, "E", this.getX() + this.getWidth() - 3 - font.getStringWidth("E"), this.getY() + 4 + this.getHeight() / 2 - 9, -1);
    }
    super.render(matrices, scaledWidth, scaledHeight, partialTicks);
}
Also used : ItemEntity(net.minecraft.entity.ItemEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Entity(net.minecraft.entity.Entity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) CustomFont(dev.hypnotic.module.render.CustomFont) Quaternion(net.minecraft.util.math.Quaternion) MatrixStack(net.minecraft.client.util.math.MatrixStack) Color(java.awt.Color) Vec3f(net.minecraft.util.math.Vec3f)

Example 14 with Vec3f

use of net.minecraft.util.math.Vec3f in project HWG by cybercat-mods.

the class FlareGunItem method shoot.

private static void shoot(World world, LivingEntity shooter, Hand hand, ItemStack stack, ItemStack projectile, float soundPitch, boolean creative, float speed, float divergence, float simulated) {
    if (!world.isClient) {
        BaseFlareEntity flareEntity = new BaseFlareEntity(world, projectile, shooter, shooter.getX(), shooter.getEyeY() - 0.15000000596046448D, shooter.getZ(), true);
        boolean bl = projectile.getItem() == HWGItems.BLACK_FLARE;
        boolean b2 = projectile.getItem() == HWGItems.BLUE_FLARE;
        boolean b3 = projectile.getItem() == HWGItems.BROWN_FLARE;
        boolean b4 = projectile.getItem() == HWGItems.CYAN_FLARE;
        boolean b5 = projectile.getItem() == HWGItems.GRAY_FLARE;
        boolean b6 = projectile.getItem() == HWGItems.GREEN_FLARE;
        boolean b7 = projectile.getItem() == HWGItems.LIGHTBLUE_FLARE;
        boolean b8 = projectile.getItem() == HWGItems.LIGHTGRAY_FLARE;
        boolean b9 = projectile.getItem() == HWGItems.LIME_FLARE;
        boolean b10 = projectile.getItem() == HWGItems.MAGENTA_FLARE;
        boolean b11 = projectile.getItem() == HWGItems.ORANGE_FLARE;
        boolean b12 = projectile.getItem() == HWGItems.PINK_FLARE;
        boolean b13 = projectile.getItem() == HWGItems.PURPLE_FLARE;
        boolean b14 = projectile.getItem() == HWGItems.RED_FLARE;
        boolean b15 = projectile.getItem() == HWGItems.YELLOW_FLARE;
        if (bl) {
            flareEntity.setColor(1);
        } else if (b2) {
            flareEntity.setColor(2);
        } else if (b3) {
            flareEntity.setColor(3);
        } else if (b4) {
            flareEntity.setColor(4);
        } else if (b5) {
            flareEntity.setColor(5);
        } else if (b6) {
            flareEntity.setColor(6);
        } else if (b7) {
            flareEntity.setColor(7);
        } else if (b8) {
            flareEntity.setColor(8);
        } else if (b9) {
            flareEntity.setColor(9);
        } else if (b10) {
            flareEntity.setColor(10);
        } else if (b11) {
            flareEntity.setColor(11);
        } else if (b12) {
            flareEntity.setColor(12);
        } else if (b13) {
            flareEntity.setColor(13);
        } else if (b14) {
            flareEntity.setColor(14);
        } else if (b15) {
            flareEntity.setColor(15);
        } else {
            flareEntity.setColor(16);
        }
        Vec3d vec3d = shooter.getOppositeRotationVector(1.0F);
        Quaternion quaternion = new Quaternion(new Vec3f(vec3d), simulated, true);
        Vec3d vec3d2 = shooter.getRotationVec(1.0F);
        Vec3f vector3f = new Vec3f(vec3d2);
        vector3f.rotate(quaternion);
        ((ProjectileEntity) flareEntity).setVelocity((double) vector3f.getX(), (double) vector3f.getY(), (double) vector3f.getZ(), speed, divergence);
        ((PersistentProjectileEntity) flareEntity).setDamage(0.3D);
        ((PersistentProjectileEntity) flareEntity).pickupType = PersistentProjectileEntity.PickupPermission.DISALLOWED;
        stack.damage(1, shooter, p -> p.sendToolBreakStatus(shooter.getActiveHand()));
        world.spawnEntity((Entity) flareEntity);
    }
}
Also used : ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Quaternion(net.minecraft.util.math.Quaternion) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Vec3f(net.minecraft.util.math.Vec3f) BaseFlareEntity(mod.azure.hwg.entity.projectiles.BaseFlareEntity) Vec3d(net.minecraft.util.math.Vec3d)

Example 15 with Vec3f

use of net.minecraft.util.math.Vec3f in project HWG by cybercat-mods.

the class GrenadeLauncherItem method shoot.

private static void shoot(World world, LivingEntity shooter, Hand hand, ItemStack stack, ItemStack projectile, float soundPitch, boolean creative, float speed, float divergence, float simulated) {
    if (!world.isClient) {
        boolean bl = projectile.getItem() == HWGItems.G_EMP;
        boolean b2 = projectile.getItem() == HWGItems.G_FRAG;
        boolean b3 = projectile.getItem() == HWGItems.G_NAPALM;
        boolean b4 = projectile.getItem() == HWGItems.G_STUN;
        GrenadeEntity projectileEntity2 = new GrenadeEntity(world, projectile, shooter, shooter.getX(), shooter.getEyeY() - 0.15000000596046448D, shooter.getZ(), true);
        projectileEntity2.setState(0);
        if (bl) {
            projectileEntity2.setVariant(1);
        } else if (b2) {
            projectileEntity2.setVariant(2);
        } else if (b3) {
            projectileEntity2.setVariant(3);
        } else if (b4) {
            projectileEntity2.setVariant(5);
        } else {
            projectileEntity2.setVariant(4);
        }
        Vec3d vec3d = shooter.getOppositeRotationVector(1.0F);
        Quaternion quaternion = new Quaternion(new Vec3f(vec3d), simulated, true);
        Vec3d vec3d2 = shooter.getRotationVec(1.0F);
        Vec3f vector3f = new Vec3f(vec3d2);
        vector3f.rotate(quaternion);
        ((PersistentProjectileEntity) projectileEntity2).setVelocity((double) vector3f.getX(), (double) vector3f.getY(), (double) vector3f.getZ(), speed, divergence);
        stack.damage(1, shooter, p -> p.sendToolBreakStatus(shooter.getActiveHand()));
        world.spawnEntity((Entity) projectileEntity2);
        world.playSound((PlayerEntity) null, shooter.getX(), shooter.getY(), shooter.getZ(), HWGSounds.GLAUNCHERFIRE, SoundCategory.PLAYERS, 1.0F, 0.9F);
    }
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) GrenadeEntity(mod.azure.hwg.entity.projectiles.GrenadeEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Vec3f(net.minecraft.util.math.Vec3f) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

Vec3f (net.minecraft.util.math.Vec3f)28 Quaternion (net.minecraft.util.math.Quaternion)16 Vec3d (net.minecraft.util.math.Vec3d)10 Matrix4f (net.minecraft.util.math.Matrix4f)5 Matrix3f (net.minecraft.util.math.Matrix3f)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)3 Identifier (net.minecraft.util.Identifier)3 Color (java.awt.Color)2 Camera (net.minecraft.client.render.Camera)2 VertexConsumer (net.minecraft.client.render.VertexConsumer)2 ClientWorld (net.minecraft.client.world.ClientWorld)2 ItemEntity (net.minecraft.entity.ItemEntity)2 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Pair (com.mojang.datafixers.util.Pair)1 CustomFont (dev.hypnotic.module.render.CustomFont)1 MonoColorSkybox (io.github.amerebagatelle.fabricskyboxes.skyboxes.MonoColorSkybox)1 AnimatedSquareTexturedSkybox (io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.AnimatedSquareTexturedSkybox)1 SquareTexturedSkybox (io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.SquareTexturedSkybox)1