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);
}
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);
}
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);
}
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;
}
use of net.minecraft.client.MinecraftClient in project BlockMeter by ModProg.
the class BlockMeterClient method renderOverlay.
public void renderOverlay(float partialTicks, MatrixStack stack) {
final MinecraftClient client = MinecraftClient.getInstance();
final Camera camera = client.gameRenderer.getCamera();
final Identifier currentDimension = client.player.world.getRegistryKey().getValue();
final ModConfig cfg = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
// MEH! but this seems to be needed to get the first background
// rectangle
client.textRenderer.draw(stack, "XXX", -100, -100, 0);
if (this.active || cfg.showBoxesWhenDisabled)
if (cfg.showOtherUsersBoxes) {
if (otherUsersBoxes != null && otherUsersBoxes.size() > 0) {
this.otherUsersBoxes.forEach((playerText, boxList) -> {
boxList.forEach(box -> box.render(camera, stack, currentDimension, playerText));
});
this.boxes.forEach(box -> {
if (!box.isFinished())
box.render(camera, stack, currentDimension);
});
}
if (!cfg.sendBoxes)
this.boxes.forEach(box -> {
if (box.isFinished())
box.render(camera, stack, currentDimension, client.player.getDisplayName());
else
box.render(camera, stack, currentDimension);
});
} else
this.boxes.forEach(box -> box.render(camera, stack, currentDimension));
}
Aggregations