Search in sources :

Example 66 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)

Example 67 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project meteor-client by MeteorDevelopment.

the class ContainerButtonWidget method renderButton.

@Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
    MinecraftClient minecraftClient = MinecraftClient.getInstance();
    TextRenderer textRenderer = minecraftClient.textRenderer;
    RenderSystem.setShader(GameRenderer::getPositionTexShader);
    RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
    RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha);
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.enableDepthTest();
    int halfWidth = width / 2;
    int halfHeight = height / 2;
    int texY = getYImage(isHovered()) * 20;
    drawTexture(matrices, x, y, 0, 46 + texY, halfWidth, halfHeight);
    drawTexture(matrices, x, y + halfHeight, 0, 46 + texY + 14, halfWidth, halfHeight);
    drawTexture(matrices, x + halfWidth, y, 200 - halfWidth, 46 + texY, halfWidth, halfHeight);
    drawTexture(matrices, x + halfWidth, y + halfHeight, 200 - halfWidth, 46 + texY + 14, halfWidth, halfHeight);
    drawCenteredText(matrices, textRenderer, getMessage(), x + width / 2, (y + height / 2) - 4, active ? 16777215 : 10526880 | MathHelper.ceil(alpha * 255.0F) << 24);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) GameRenderer(net.minecraft.client.render.GameRenderer) TextRenderer(net.minecraft.client.font.TextRenderer)

Example 68 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project FZMM-Mod by Zailer43.

the class EncodebookLogic method EncodeBook.

public static void EncodeBook(final int SEED, String message, final String AUTHOR, final String PADDING_CHARS, final int MAX_MESSAGE_LENGTH, String bookTitle) {
    /*
		{
			title:"&3Encode book (secret_mc_1)",
			author:"Zailer43",
			pages:[
				'{
					"translate":"secret_mc_1",
					"with":[
						"y","F","r","d","6","5","8","y","s","A",...,"e","s"
					]
				}',
				'{
					"hoverEvent":{
						"action":"show_text",
						"contents":{
							"text":"yFrd658ysA...es"
						}
					},
					"text":"&9Idea by: &0turkeybot69\\n
					&9Encode key: &0secret_mc_1\\n
					&9End-to-end encode: &0true\\n
					&9Encode message: &0Hover over here"
				}'
			]
		}

		 */
    MinecraftClient mc = MinecraftClient.getInstance();
    Character[] encodeMessage = new Character[MAX_MESSAGE_LENGTH];
    short[] encodedKey;
    Random random = new Random(new Date().getTime());
    StringBuilder messageBuilder, encodeMessageString = new StringBuilder();
    String[] paddingCharacters = PADDING_CHARS.split("");
    ItemStack book = Items.WRITTEN_BOOK.getDefaultStack();
    NbtCompound tag = new NbtCompound();
    NbtList pages = new NbtList();
    MutableText page1, page2;
    String translationKeyPrefix = Configs.Encodebook.TRANSLATION_KEY_PREFIX.getStringValue();
    assert mc.player != null;
    message += Configs.Encodebook.SEPARATOR_MESSAGE.getStringValue();
    message = message.replaceAll(" ", "_");
    messageBuilder = new StringBuilder(message);
    int messageLength = message.length();
    encodedKey = encodeKey(getKey(SEED), MAX_MESSAGE_LENGTH);
    if (bookTitle.contains("%s")) {
        bookTitle = String.format(bookTitle, translationKeyPrefix + SEED);
    }
    while (messageLength < MAX_MESSAGE_LENGTH) {
        messageBuilder.append(paddingCharacters[random.nextInt(paddingCharacters.length)]);
        messageLength++;
    }
    message = messageBuilder.toString();
    for (int i = 0; i < MAX_MESSAGE_LENGTH; i++) encodeMessage[encodedKey[i]] = message.charAt(i);
    for (int i = 0; i < MAX_MESSAGE_LENGTH; i++) {
        encodeMessageString.append(encodeMessage[i]);
    }
    tag.putString(WrittenBookItem.TITLE_KEY, bookTitle);
    tag.putString(WrittenBookItem.AUTHOR_KEY, AUTHOR);
    page1 = new TranslatableText(translationKeyPrefix + SEED, (Object[]) encodeMessage).setStyle(Style.EMPTY.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("You probably need the decoder to see this message"))));
    page2 = new LiteralText(Formatting.BLUE + "Idea by: " + Formatting.BLACK + "turkeybot69\n" + Formatting.BLUE + "Encode key: " + Formatting.BLACK + translationKeyPrefix + SEED + "\n" + Formatting.BLUE + "Asymmetric encode: " + Formatting.BLACK + (Configs.Encodebook.ASYMMETRIC_ENCODE_KEY.getIntegerValue() != 0) + "\n" + Formatting.BLUE + "Encode message: " + Formatting.BLACK + "Hover over here").setStyle(Style.EMPTY.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(encodeMessageString.toString()))));
    pages.add(FzmmUtils.textToNbtString(page1, false));
    pages.add(FzmmUtils.textToNbtString(page2, false));
    tag.put(WrittenBookItem.PAGES_KEY, pages);
    book.setNbt(tag);
    FzmmUtils.giveItem(book);
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) Date(java.util.Date) Random(java.util.Random) MinecraftClient(net.minecraft.client.MinecraftClient) NbtList(net.minecraft.nbt.NbtList) ItemStack(net.minecraft.item.ItemStack)

Example 69 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project FZMM-Mod by Zailer43.

the class GradientLogic method getGradient.

public static MutableText getGradient(String message, Color4f initialColor4f, Color4f finalColor4f, boolean obfuscated, boolean bold, boolean strikethrough, boolean underline, boolean italic) {
    MinecraftClient mc = MinecraftClient.getInstance();
    assert mc.player != null;
    Color initialColor = new Color(initialColor4f.intValue);
    Color finalColor = new Color(finalColor4f.intValue);
    byte red = (byte) (initialColor.getRed() + Byte.MIN_VALUE);
    byte green = (byte) (initialColor.getGreen() + Byte.MIN_VALUE);
    byte blue = (byte) (initialColor.getBlue() + Byte.MIN_VALUE);
    byte red2 = (byte) (finalColor.getRed() + Byte.MIN_VALUE);
    byte green2 = (byte) (finalColor.getGreen() + Byte.MIN_VALUE);
    byte blue2 = (byte) (finalColor.getBlue() + Byte.MIN_VALUE);
    Style style = Style.EMPTY;
    if (obfuscated)
        style = style.withObfuscated(true);
    if (bold)
        style = style.withBold(true);
    if (strikethrough)
        style = style.withStrikethrough(true);
    if (underline)
        style = style.withUnderline(true);
    if (italic)
        style = style.withItalic(true);
    else
        style = style.withItalic(false);
    return getGradient(message, red, green, blue, red2, green2, blue2, style);
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient) TextColor(net.minecraft.text.TextColor) Style(net.minecraft.text.Style)

Example 70 with MinecraftClient

use of net.minecraft.client.MinecraftClient in project FZMM-Mod by Zailer43.

the class GenericCallback method changeGuiScale.

private boolean changeGuiScale(boolean increment) {
    MinecraftClient mc = MinecraftClient.getInstance();
    int guiScale = mc.options.guiScale;
    if (increment)
        guiScale++;
    else
        guiScale--;
    guiScale = MathHelper.clamp(guiScale, 1, 4);
    mc.options.guiScale = guiScale;
    mc.onResolutionChanged();
    return true;
}
Also used : MinecraftClient(net.minecraft.client.MinecraftClient)

Aggregations

MinecraftClient (net.minecraft.client.MinecraftClient)101 ItemStack (net.minecraft.item.ItemStack)14 Text (net.minecraft.text.Text)13 PlayerEntity (net.minecraft.entity.player.PlayerEntity)10 TranslatableText (net.minecraft.text.TranslatableText)8 Identifier (net.minecraft.util.Identifier)8 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)7 BlockHitResult (net.minecraft.util.hit.BlockHitResult)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 TextRenderer (net.minecraft.client.font.TextRenderer)6 GameRenderer (net.minecraft.client.render.GameRenderer)6 BlockPos (net.minecraft.util.math.BlockPos)6 BlockEntity (net.minecraft.block.entity.BlockEntity)5 Screen (net.minecraft.client.gui.screen.Screen)5 MatrixStack (net.minecraft.client.util.math.MatrixStack)5 PlayerInventory (net.minecraft.entity.player.PlayerInventory)5 List (java.util.List)4 BlockState (net.minecraft.block.BlockState)4 Entity (net.minecraft.entity.Entity)4 NbtCompound (net.minecraft.nbt.NbtCompound)4