Search in sources :

Example 56 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project BedrockIfy by juancarloscp52.

the class HeldItemTooltips method renderBackground.

private void renderBackground(MatrixStack matrices, float y, int screenBorder, int tooltipOffset, int maxLength) {
    MinecraftClient client = MinecraftClient.getInstance();
    int background = MathHelper.ceil((255.0D * MinecraftClient.getInstance().options.textBackgroundOpacity)) << 24;
    DrawableHelper.fill(matrices, MathHelper.ceil((client.getWindow().getScaledWidth() - maxLength) / 2f - 3), MathHelper.ceil(y - tooltipOffset - 5 - screenBorder), MathHelper.ceil((client.getWindow().getScaledWidth() + maxLength) / 2f + 1), MathHelper.ceil(y - tooltipOffset - 4 - screenBorder), background);
    DrawableHelper.fill(matrices, MathHelper.ceil((client.getWindow().getScaledWidth() - maxLength) / 2f - 3), MathHelper.ceil(y + 12 - screenBorder), MathHelper.ceil((client.getWindow().getScaledWidth() + maxLength) / 2f + 1), MathHelper.ceil(y + 13 - screenBorder), background);
    DrawableHelper.fill(matrices, MathHelper.ceil((client.getWindow().getScaledWidth() - maxLength) / 2f - 4), MathHelper.ceil(y - tooltipOffset - 4 - screenBorder), MathHelper.ceil((client.getWindow().getScaledWidth() + maxLength) / 2f + 2), MathHelper.ceil(y + 12 - screenBorder), background);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient)

Example 57 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project SeedcrackerX by 19MisterX98.

the class Database method joinFakeServerForAuth.

public static Text joinFakeServerForAuth() {
    try {
        MinecraftClient client = MinecraftClient.getInstance();
        client.getSessionService().joinServer(client.getSession().getProfile(), client.getSession().getAccessToken(), "seedcrackerx");
    } catch (AuthenticationUnavailableException authenticationUnavailableException) {
        return new TranslatableText("disconnect.loginFailedInfo", new TranslatableText("disconnect.loginFailedInfo.serversUnavailable"));
    } catch (InvalidCredentialsException authenticationUnavailableException) {
        return new TranslatableText("disconnect.loginFailedInfo", new TranslatableText("disconnect.loginFailedInfo.invalidSession"));
    } catch (InsufficientPrivilegesException authenticationUnavailableException) {
        return new TranslatableText("disconnect.loginFailedInfo", new TranslatableText("disconnect.loginFailedInfo.insufficientPrivileges"));
    } catch (AuthenticationException authenticationUnavailableException) {
        return new TranslatableText("disconnect.loginFailedInfo", authenticationUnavailableException.getMessage());
    }
    return null;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) AuthenticationUnavailableException(com.mojang.authlib.exceptions.AuthenticationUnavailableException) InsufficientPrivilegesException(com.mojang.authlib.exceptions.InsufficientPrivilegesException) InvalidCredentialsException(com.mojang.authlib.exceptions.InvalidCredentialsException) AuthenticationException(com.mojang.authlib.exceptions.AuthenticationException) MinecraftClient(net.minecraft.client.MinecraftClient)

Example 58 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project SeedcrackerX by 19MisterX98.

the class Database method handleDatabaseCall.

public static void handleDatabaseCall(Long seed) {
    HttpClient httpClient = HttpClient.newBuilder().version(HttpClient.Version.HTTP_2).build();
    MinecraftClient client = MinecraftClient.getInstance();
    Map<String, Object> data = new HashMap<>();
    data.put("serverIp", client.getNetworkHandler().getConnection().getAddress().toString());
    data.put("dimension", client.world.getDimension().getEffects().getPath());
    // javascript backend likes floating point. so we need to convert it to a string
    data.put("seed", seed + "L");
    data.put("version", Config.get().getVersion().name);
    data.put("username", client.player.getName().getString());
    data.put("hash", Config.get().anonymusSubmits ? 1 : 0);
    HttpRequest request = HttpRequest.newBuilder().POST(HttpRequest.BodyPublishers.ofString(HttpAuthenticationService.buildQuery(data))).uri(URI.create("https://script.google.com/macros/s/AKfycbzU-o8IUaKMQ-MOJEqD8hFGTAC7E15l4uiVqkQsOWxGXgh_HVny6x_TSDVKR8V2wmm9Aw/exec")).setHeader("User-Agent", "SeedcrackerX mod").header("Content-Type", "application/x-www-form-urlencoded").build();
    try {
        HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
        if (response.statusCode() == 302) {
            // the page says "document moved" but the post gets processed
            Log.warn("database.success");
        } else {
            Log.warn("database.fail");
        }
    } catch (IOException | InterruptedException e) {
        Log.warn("database.fail");
    }
}
Also used : HttpRequest(java.net.http.HttpRequest) HashMap(java.util.HashMap) HttpClient(java.net.http.HttpClient) MinecraftClient(net.minecraft.client.MinecraftClient) IOException(java.io.IOException)

Example 59 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project tweakermore by Fallen-Breath.

the class InventoryRefresher method refresh.

/**
 * Inspired by viaversion 1.14 -> 1.13 villager selection inventory forced resync
 * https://github.com/ViaVersion/ViaVersion/blob/4074352a531cfb0de6fa81e043ee761737748a7a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/packets/InventoryPackets.java#L238
 */
public static boolean refresh(KeyAction keyAction, IKeybind iKeybind) {
    MinecraftClient mc = MinecraftClient.getInstance();
    ClientPlayNetworkHandler networkHandler = mc.getNetworkHandler();
    if (networkHandler != null && mc.player != null) {
        ItemStack uniqueItem = new ItemStack(Items.STONE);
        // Tags with NaN are not equal
        uniqueItem.getOrCreateTag().putDouble("force_resync", Double.NaN);
        networkHandler.sendPacket(new ClickWindowC2SPacket(mc.player.container.syncId, -999, 2, SlotActionType.QUICK_CRAFT, uniqueItem, mc.player.container.getNextActionId(mc.player.inventory)));
    }
    return true;
}
Also used : ClickWindowC2SPacket(net.minecraft.network.packet.c2s.play.ClickWindowC2SPacket) MinecraftClient(net.minecraft.client.MinecraftClient) ItemStack(net.minecraft.item.ItemStack) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler)

Example 60 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project KiwiClient by TangyKiwi.

the class InGameHudMixin method render.

@Inject(method = "render", at = @At(value = "TAIL"), cancellable = true)
private void render(CallbackInfo info) {
    if (!MinecraftClient.getInstance().options.debugEnabled) {
        MinecraftClient client = MinecraftClient.getInstance();
        TextRenderer textRenderer = client.textRenderer;
        TextureManager textureManager = client.getTextureManager();
        MatrixStack matrixStack = new MatrixStack();
        RenderSystem.setShaderTexture(0, KiwiClient.DUCK);
        client.inGameHud.drawTexture(matrixStack, 0, 0, 0, 0, 130, 130);
    }
    DrawOverlayEvent event = new DrawOverlayEvent(new MatrixStack());
    KiwiClient.eventBus.post(event);
    if (event.isCancelled())
        info.cancel();
}
Also used : DrawOverlayEvent(com.tangykiwi.kiwiclient.event.DrawOverlayEvent) TextureManager(net.minecraft.client.texture.TextureManager) MatrixStack(net.minecraft.client.util.math.MatrixStack) MinecraftClient(net.minecraft.client.MinecraftClient) TextRenderer(net.minecraft.client.font.TextRenderer)

Aggregations

MinecraftClient (net.minecraft.client.MinecraftClient)84 ItemStack (net.minecraft.item.ItemStack)12 Text (net.minecraft.text.Text)7 Identifier (net.minecraft.util.Identifier)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 BlockPos (net.minecraft.util.math.BlockPos)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 TextRenderer (net.minecraft.client.font.TextRenderer)5 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)5 BlockHitResult (net.minecraft.util.hit.BlockHitResult)5 List (java.util.List)4 BlockState (net.minecraft.block.BlockState)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)4 Entity (net.minecraft.entity.Entity)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 NbtCompound (net.minecraft.nbt.NbtCompound)4 AreaIsometricRenderScreen (com.glisco.isometricrenders.client.gui.AreaIsometricRenderScreen)3 IsometricRenderScreen (com.glisco.isometricrenders.client.gui.IsometricRenderScreen)3 GameRenderer (net.minecraft.client.render.GameRenderer)3 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)3