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));
}
use of net.minecraft.client.MinecraftClient in project bewitchment by MoriyaShiine.
the class SyncContractsPacket method handle.
public static void handle(MinecraftClient client, ClientPlayNetworkHandler network, PacketByteBuf buf, PacketSender sender) {
NbtCompound contractsCompound = buf.readNbt();
client.execute(new Runnable() {
@Override
public void run() {
if (client.player != null) {
BWComponents.CONTRACTS_COMPONENT.maybeGet(client.player).ifPresent(contractsComponent -> {
contractsComponent.getContracts().clear();
NbtList contractsList = contractsCompound.getList("Contracts", NbtType.COMPOUND);
for (int i = 0; i < contractsList.size(); i++) {
NbtCompound contractCompound = contractsList.getCompound(i);
contractsComponent.addContract(new Contract.Instance(BWRegistries.CONTRACTS.get(new Identifier(contractCompound.getString("Contract"))), contractCompound.getInt("Duration"), contractCompound.getInt("Cost")));
}
});
}
}
});
}
use of net.minecraft.client.MinecraftClient in project reeses-sodium-options by FlashyReese.
the class SodiumVideoOptionsScreen method applyChanges.
private void applyChanges() {
final HashSet<OptionStorage<?>> dirtyStorages = new HashSet<>();
final EnumSet<OptionFlag> flags = EnumSet.noneOf(OptionFlag.class);
this.getAllOptions().forEach((option -> {
if (!option.hasChanged()) {
return;
}
option.applyChanges();
flags.addAll(option.getFlags());
dirtyStorages.add(option.getStorage());
}));
MinecraftClient client = MinecraftClient.getInstance();
if (flags.contains(OptionFlag.REQUIRES_RENDERER_RELOAD)) {
client.worldRenderer.reload();
}
if (flags.contains(OptionFlag.REQUIRES_ASSET_RELOAD)) {
client.setMipmapLevels(client.options.mipmapLevels);
client.reloadResourcesConcurrently();
}
for (OptionStorage<?> storage : dirtyStorages) {
storage.save();
}
}
Aggregations