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);
}
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;
}
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");
}
}
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;
}
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();
}
Aggregations