Search in sources :

Example 11 with Quaternion

use of net.minecraft.util.math.Quaternion 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 Quaternion

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

the class ItemRendererMixin method preRenderItem.

@Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", at = @At("HEAD"), cancellable = true)
public void preRenderItem(ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) {
    EventRenderItem event = new EventRenderItem(matrices, stack, renderMode, EventRenderItem.RenderTime.PRE, leftHanded);
    event.call();
    if (ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled()) {
        if ((ModuleManager.INSTANCE.getModule(Killaura.class).autoBlockMode.is("Visual") && Killaura.target != null ? Killaura.target == null : !mc.player.isUsingItem()) || renderMode != ModelTransformation.Mode.FIRST_PERSON_RIGHT_HAND)
            return;
        MatrixStack matrixStack = event.getMatrixStack();
        boolean offHand = event.isLeftHanded() ? event.getType() == ModelTransformation.Mode.FIRST_PERSON_RIGHT_HAND : event.getType() == ModelTransformation.Mode.FIRST_PERSON_LEFT_HAND;
        if (!offHand) {
            if ((event.getItemStack().getItem() instanceof AxeItem || event.getItemStack().getItem() instanceof SwordItem) && event.getItemStack() == mc.player.getMainHandStack()) {
                matrixStack.multiply(new Quaternion(-270f, 0f, 270f, true));
                matrixStack.multiply(new Quaternion(-120f, 270f, -150f, true));
                matrixStack.multiply(new Quaternion(-70f, -108f, 90f, true));
                // Only plays with killaura
                if (Killaura.target != null && !Killaura.target.isDead()) {
                    switch(ModuleManager.INSTANCE.getModule(OldBlock.class).animation.getSelected()) {
                        case "1.7(ish)":
                            matrixStack.multiply(new Quaternion(-ModuleManager.INSTANCE.getModule(OldBlock.class).swingTicks, 0, 0, true));
                            break;
                        case "Slide":
                            matrixStack.multiply(new Quaternion(-ModuleManager.INSTANCE.getModule(OldBlock.class).swingTicks, ModuleManager.INSTANCE.getModule(OldBlock.class).swingTicks, ModuleManager.INSTANCE.getModule(OldBlock.class).swingTicks / 2, true));
                            break;
                        case "Sigma":
                            matrixStack.multiply(new Quaternion(-ModuleManager.INSTANCE.getModule(OldBlock.class).swingTicks * 0.15f, 0, 0, true));
                            matrixStack.multiply(new Quaternion(0, 0, ModuleManager.INSTANCE.getModule(OldBlock.class).swingTicks * 0.5f, true));
                            break;
                        case "Swing":
                            mc.player.swingHand(Hand.MAIN_HAND);
                            break;
                    }
                }
                ArmCustomize arm = ModuleManager.INSTANCE.getModule(ArmCustomize.class);
                if (arm.isEnabled())
                    matrixStack.translate(arm.mainX.getValue(), arm.mainY.getValue(), arm.mainZ.getValue());
            }
        }
    }
    if (event.isCancelled())
        ci.cancel();
}
Also used : OldBlock(dev.hypnotic.module.render.OldBlock) Quaternion(net.minecraft.util.math.Quaternion) MatrixStack(net.minecraft.client.util.math.MatrixStack) EventRenderItem(dev.hypnotic.event.events.EventRenderItem) SwordItem(net.minecraft.item.SwordItem) AxeItem(net.minecraft.item.AxeItem) ArmCustomize(dev.hypnotic.module.render.ArmCustomize) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 13 with Quaternion

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

the class Waypoints method render.

@EventTarget
public void render(EventRender3D event) {
    MatrixStack matrices = event.getMatrices();
    for (Waypoint waypoint : WaypointManager.INSTANCE.waypoints) {
        if (waypoint.isEnabled()) {
            Camera c = mc.gameRenderer.getCamera();
            Vec3d vv = new Vec3d(waypoint.getX() + .5, c.getPos().y, waypoint.getZ() + .5);
            double distance = vv.distanceTo(mc.player.getPos());
            int a = 255;
            float scale = 3f;
            scale /= 50f;
            scale *= 0.55f;
            if (distance < 100) {
                a = (int) ((distance / 100) * 255);
            } else
                scale *= distance / 100d;
            RenderUtils.drawBoxOutline(new Box(new BlockPos(waypoint.getX(), 0, waypoint.getZ())).stretch(0, 500, 0), QuadColor.single(ColorUtils.defaultClientColor), 1);
            RenderUtils.drawBoxFill(new Box(new BlockPos(waypoint.getX(), 0, waypoint.getZ())).stretch(0, 500, 0), QuadColor.single(new Color(ColorUtils.defaultClientColor().getRed(), ColorUtils.defaultClientColor().getGreen(), ColorUtils.defaultClientColor().getBlue(), a).getRGB()));
            Vec3d textPos = new Vec3d(waypoint.getX() + 0.5, c.getPos().y, waypoint.getZ() + 0.25);
            matrices.push();
            matrices.translate(textPos.x - c.getPos().x - 1, textPos.y - c.getPos().y + 2, textPos.z - c.getPos().z - 0.5);
            matrices.translate(0, scale * 6, 0);
            matrices.scale(-scale, -scale, scale);
            Quaternion qu = mc.getEntityRenderDispatcher().getRotation();
            qu = new Quaternion(-qu.getX(), -qu.getY(), qu.getZ(), qu.getW());
            matrices.multiply(qu);
            VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
            RenderSystem.disableDepthTest();
            RenderSystem.polygonOffset(1, -15000000);
            RenderSystem.enablePolygonOffset();
            FontManager.robotoBig.drawCenteredString(matrices, waypoint.getName() + " " + Math.round(PlayerUtils.distanceTo(new BlockPos(waypoint.getX(), mc.player.getY(), waypoint.getZ()))) + "m", 0, 0, -1, true);
            RenderSystem.polygonOffset(1, 15000000);
            RenderSystem.disablePolygonOffset();
            RenderSystem.enableDepthTest();
            immediate.draw();
            matrices.pop();
        }
    }
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) MatrixStack(net.minecraft.client.util.math.MatrixStack) Color(java.awt.Color) QuadColor(dev.hypnotic.utils.render.QuadColor) Box(net.minecraft.util.math.Box) Vec3d(net.minecraft.util.math.Vec3d) Waypoint(dev.hypnotic.waypoint.Waypoint) Waypoint(dev.hypnotic.waypoint.Waypoint) BlockPos(net.minecraft.util.math.BlockPos) Camera(net.minecraft.client.render.Camera) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider) EventTarget(dev.hypnotic.event.EventTarget)

Example 14 with Quaternion

use of net.minecraft.util.math.Quaternion 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 15 with Quaternion

use of net.minecraft.util.math.Quaternion in project MCDungeonsWeapons by chronosacaria.

the class ProjectileEffectHelper method fireChainReactionProjectileFromVictim.

private static void fireChainReactionProjectileFromVictim(World world, LivingEntity attacker, LivingEntity victim, ItemStack projectileStack, float v1, float v2, float centerOffset, PersistentProjectileEntity originalArrow) {
    if (!world.isClient) {
        PersistentProjectileEntity projectile;
        projectile = createChainReactionProjectile(world, attacker, projectileStack, originalArrow);
        projectile.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY;
        Vec3d upVector = victim.getOppositeRotationVector(1.0F);
        Quaternion quaternion = new Quaternion(new Vector3f(upVector), centerOffset, true);
        Vec3d lookVector = victim.getRotationVec(1.0F);
        Vector3f vector3f = new Vector3f(lookVector);
        vector3f.rotate(quaternion);
        projectile.setVelocity((double) vector3f.getX(), (double) vector3f.getY(), (double) vector3f.getZ(), v1, v2);
        world.spawnEntity(projectile);
    }
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Vector3f(net.minecraft.client.util.math.Vector3f) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

Quaternion (net.minecraft.util.math.Quaternion)23 Vec3f (net.minecraft.util.math.Vec3f)13 Vec3d (net.minecraft.util.math.Vec3d)11 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)5 EntityRenderDispatcher (net.minecraft.client.render.entity.EntityRenderDispatcher)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)4 Color (java.awt.Color)3 VertexConsumer (net.minecraft.client.render.VertexConsumer)3 Vector3f (net.minecraft.client.util.math.Vector3f)2 ItemEntity (net.minecraft.entity.ItemEntity)2 SquidEntity (net.minecraft.entity.passive.SquidEntity)2 Identifier (net.minecraft.util.Identifier)2 Box (net.minecraft.util.math.Box)2 Pair (com.mojang.datafixers.util.Pair)1 EventTarget (dev.hypnotic.event.EventTarget)1 EventRenderItem (dev.hypnotic.event.events.EventRenderItem)1 ArmCustomize (dev.hypnotic.module.render.ArmCustomize)1 CustomFont (dev.hypnotic.module.render.CustomFont)1 OldBlock (dev.hypnotic.module.render.OldBlock)1 QuadColor (dev.hypnotic.utils.render.QuadColor)1