Search in sources :

Example 51 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project tanuki by AntiCope.

the class AntiCrystalPhase method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    ClientPlayerEntity p = mc.player;
    double blocks = clipDistance.get();
    if (!p.isOnGround())
        return;
    if (mc.options.forwardKey.isPressed()) {
        Vec3d forward = Vec3d.fromPolar(0, p.getYaw());
        p.updatePosition(p.getX() + forward.x * blocks, p.getY(), p.getZ() + forward.z * blocks);
    }
    if (mc.options.backKey.isPressed()) {
        Vec3d forward = Vec3d.fromPolar(0, p.getYaw() - 180);
        p.updatePosition(p.getX() + forward.x * blocks, p.getY(), p.getZ() + forward.z * blocks);
    }
    if (mc.options.leftKey.isPressed()) {
        Vec3d forward = Vec3d.fromPolar(0, p.getYaw() - 90);
        p.updatePosition(p.getX() + forward.x * blocks, p.getY(), p.getZ() + forward.z * blocks);
    }
    if (mc.options.rightKey.isPressed()) {
        Vec3d forward = Vec3d.fromPolar(0, p.getYaw() - 270);
        p.updatePosition(p.getX() + forward.x * blocks, p.getY(), p.getZ() + forward.z * blocks);
    }
    if (mc.options.jumpKey.isPressed()) {
        p.updatePosition(p.getX(), p.getY() + 0.05, p.getZ());
    }
    if (mc.options.sneakKey.isPressed()) {
        p.updatePosition(p.getX(), p.getY() - 0.05, p.getZ());
    }
}
Also used : ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Vec3d(net.minecraft.util.math.Vec3d) EventHandler(meteordevelopment.orbit.EventHandler)

Example 52 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project EarthMCEssentials by EarthMC-Stats.

the class EarthMCAPI method getNearby.

public static CompletableFuture<JsonArray> getNearby(int xBlocks, int zBlocks) {
    return CompletableFuture.supplyAsync(() -> {
        try {
            MinecraftClient client = MinecraftClient.getInstance();
            ClientPlayerEntity player = client.player;
            if (player != null) {
                if (!player.getEntityWorld().getDimension().isBedWorking())
                    return new JsonArray();
                JsonArray array = (JsonArray) new JsonParser().parse(getURL(config.api.main.domain() + config.api.routes.nearby + (int) player.getX() + "/" + (int) player.getZ() + "/" + xBlocks + "/" + zBlocks));
                for (int i = 0; i < array.size(); i++) {
                    JsonObject currentObj = (JsonObject) array.get(i);
                    if (currentObj.get("name").getAsString().equals(client.player.getName().asString()))
                        array.remove(i);
                }
                return array;
            } else
                return EarthMCEssentials.instance().getNearbyPlayers();
        } catch (APIException e) {
            MsgUtils.sendDebugMessage(e.getMessage(), e);
            return EarthMCEssentials.instance().getNearbyPlayers();
        }
    });
}
Also used : APIException(net.emc.emce.object.exception.APIException) MinecraftClient(net.minecraft.client.MinecraftClient) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 53 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method renderGuiItemOverlay.

public static void renderGuiItemOverlay(TextRenderer renderer, ItemStack stack, float x, float y, float scale, @Nullable String countLabel) {
    if (!stack.isEmpty()) {
        MatrixStack matrixStack = new MatrixStack();
        if (stack.getCount() != 1 || countLabel != null) {
            String string = countLabel == null ? String.valueOf(stack.getCount()) : countLabel;
            matrixStack.translate(0.0D, 0.0D, (double) (mc.getItemRenderer().zOffset + 200.0F));
            VertexConsumerProvider.Immediate immediate = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer());
            renderer.draw(string, (float) (x + 19 - 2 - renderer.getWidth(string)), (float) (y + 6 + 3), 16777215, true, matrixStack.peek().getPositionMatrix(), immediate, false, 0, 15728880);
            immediate.draw();
        }
        if (stack.isItemBarVisible()) {
            RenderSystem.disableDepthTest();
            RenderSystem.disableTexture();
            RenderSystem.disableBlend();
            int i = stack.getItemBarStep();
            int j = stack.getItemBarColor();
            fill(matrixStack, x + 2, y + 13, x + 2 + 13, y + 13 + 2, 0xff000000);
            fill(matrixStack, x + 2, y + 13, x + 2 + i, y + 13 + 1, new Color(j >> 16 & 255, j >> 8 & 255, j & 255, 255).getRGB());
            RenderSystem.enableBlend();
            RenderSystem.enableTexture();
            RenderSystem.enableDepthTest();
        }
        ClientPlayerEntity clientPlayerEntity = mc.player;
        float f = clientPlayerEntity == null ? 0.0F : clientPlayerEntity.getItemCooldownManager().getCooldownProgress(stack.getItem(), MinecraftClient.getInstance().getTickDelta());
        if (f > 0.0F) {
            RenderSystem.disableDepthTest();
            RenderSystem.disableTexture();
            RenderSystem.enableBlend();
            RenderSystem.defaultBlendFunc();
            Tessellator tessellator2 = Tessellator.getInstance();
            BufferBuilder bufferBuilder2 = tessellator2.getBuffer();
            renderGuiQuad(bufferBuilder2, x, y + MathHelper.floor(16.0F * (1.0F - f)), 16, MathHelper.ceil(16.0F * f), 255, 255, 255, 127);
            RenderSystem.enableTexture();
            RenderSystem.enableDepthTest();
        }
    }
}
Also used : Tessellator(net.minecraft.client.render.Tessellator) MatrixStack(net.minecraft.client.util.math.MatrixStack) Color(java.awt.Color) BufferBuilder(net.minecraft.client.render.BufferBuilder) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 54 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method getCrosshairVector.

public static Vec3d getCrosshairVector() {
    ClientPlayerEntity player = mc.player;
    float f = 0.017453292F;
    float pi = (float) Math.PI;
    assert player != null;
    float f1 = MathHelper.cos(-player.getYaw() * f - pi);
    float f2 = MathHelper.sin(-player.getYaw() * f - pi);
    float f3 = -MathHelper.cos(-player.getPitch() * f);
    float f4 = MathHelper.sin(-player.getPitch() * f);
    return new Vec3d(f2 * f3, f4, f1 * f3).add(mc.player.getX(), mc.player.getY() + 1.5, mc.player.getZ());
}
Also used : ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Vec3d(net.minecraft.util.math.Vec3d)

Example 55 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project Hypnotic-Client by Hypnotic-Development.

the class PlayerUtils method getDistanceToGround.

public static float getDistanceToGround() {
    if (mc.player.verticalCollision && mc.player.isOnGround()) {
        return 0.0F;
    }
    ClientPlayerEntity e = mc.player;
    for (float a = (float) e.getY(); a > 0.0F; a -= 1.0F) {
        int[] stairs = { 53, 67, 108, 109, 114, 128, 134, 135, 136, 156, 163, 164, 180 };
        int[] exemptIds = { 6, 27, 28, 30, 31, 32, 37, 38, 39, 40, 50, 51, 55, 59, 63, 65, 66, 68, 69, 70, 72, 75, 76, 77, 83, 92, 93, 94, 104, 105, 106, 115, 119, 131, 132, 143, 147, 148, 149, 150, 157, 171, 175, 176, 177 };
        BlockState block = mc.world.getBlockState(new BlockPos(e.getX(), a - 1.0F, e.getZ()));
        if (!(block.getBlock() instanceof AirBlock)) {
            if ((Block.getRawIdFromState(block) == 44) || (Block.getRawIdFromState(block) == 126)) {
                return (float) (e.getY() - a - 0.5D) < 0.0F ? 0.0F : (float) (e.getY() - a - 0.5D);
            }
            int[] arrayOfInt1;
            int j = (arrayOfInt1 = stairs).length;
            for (int i = 0; i < j; i++) {
                int id = arrayOfInt1[i];
                if (Block.getRawIdFromState(block) == id) {
                    return (float) (e.getY() - a - 1.0D) < 0.0F ? 0.0F : (float) (e.getY() - a - 1.0D);
                }
            }
            j = (arrayOfInt1 = exemptIds).length;
            for (int i = 0; i < j; i++) {
                int id = arrayOfInt1[i];
                if (Block.getRawIdFromState(block) == id) {
                    return (float) (e.getY() - a) < 0.0F ? 0.0F : (float) (e.getY() - a);
                }
            }
            return (float) (e.getY() - a + block.getBlock().getMaxHorizontalModelOffset() - 1.0D);
        }
    }
    return 0.0F;
}
Also used : BlockState(net.minecraft.block.BlockState) AirBlock(net.minecraft.block.AirBlock) BlockPos(net.minecraft.util.math.BlockPos) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Aggregations

ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)58 Identifier (net.minecraft.util.Identifier)11 Inject (org.spongepowered.asm.mixin.injection.Inject)10 PlayerUtils (at.haha007.edenclient.utils.PlayerUtils)9 ConfigSubscriber (at.haha007.edenclient.utils.config.ConfigSubscriber)9 PerWorldConfig (at.haha007.edenclient.utils.config.PerWorldConfig)9 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)9 MinecraftClient (net.minecraft.client.MinecraftClient)9 ClientCommandSource (net.minecraft.client.network.ClientCommandSource)9 CommandManager (at.haha007.edenclient.command.CommandManager)8 Registry (net.minecraft.util.registry.Registry)8 ChatColor (at.haha007.edenclient.utils.ChatColor)7 PlayerUtils.sendModMessage (at.haha007.edenclient.utils.PlayerUtils.sendModMessage)7 List (java.util.List)7 ClientWorld (net.minecraft.client.world.ClientWorld)7 ItemStack (net.minecraft.item.ItemStack)7 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)6 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)5 CommandContext (com.mojang.brigadier.context.CommandContext)5 Comparator (java.util.Comparator)5