net.minecraft.text.TranslatableText Java Examples

The following examples show how to use net.minecraft.text.TranslatableText. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MachineHandledScreen.java    From Galacticraft-Rewoven with MIT License 7 votes vote down vote up
@Override
public void render(MatrixStack stack, int mouseX, int mouseY, float delta) {
    if (this.handler.blockEntity != null) {
        ConfigurableElectricMachineBlockEntity.SecurityInfo security = this.handler.blockEntity.getSecurity();
        switch (security.getPublicity()) {
            case PRIVATE:
                if (!this.playerInventory.player.getUuid().equals(security.getOwner())) {
                    DrawableUtils.drawCenteredString(stack, this.client.textRenderer, "\u00A7l" + new TranslatableText("ui.galacticraft-rewoven.tabs.security_config.not_your_machine").asString(), (this.width / 2), this.y + 50, Formatting.DARK_RED.getColorValue());
                    return;
                }
            case SPACE_RACE:
                if (!this.playerInventory.player.getUuid().equals(security.getOwner())) {
                    DrawableUtils.drawCenteredString(stack, this.client.textRenderer, "\u00A7l" + new TranslatableText("Team stuff pending...").asString(), (this.width / 2), this.y + 50, Formatting.DARK_RED.getColorValue());
                    return;
                }
            default:
                break;
        }
    }

    this.drawConfigTabs(stack);
    super.render(stack, mouseX, mouseY, delta);
}
 
Example #2
Source File: HallowCharmItem.java    From the-hallow with MIT License 7 votes vote down vote up
@Override
public ActionResult useOnBlock(ItemUsageContext context) {
	PlayerEntity player = context.getPlayer();
	if (context.getWorld().isClient) return ActionResult.PASS;
	BlockState state = context.getWorld().getBlockState(context.getBlockPos());
	if(state.getBlock() == HallowedBlocks.HALLOWED_GATE) {
		if (context.getWorld().getDimension().getType() == DimensionType.OVERWORLD) {
			if (HallowedGateBlock.isValid(context.getWorld(), context.getBlockPos(), state)) {
				BlockPos pos = player.getBlockPos();
				CompoundTag tag = new CompoundTag();
				tag.putInt("x", pos.getX());
				tag.putInt("y", pos.getY());
				tag.putInt("z", pos.getZ());
				context.getStack().putSubTag("PortalLoc", tag);
				FabricDimensions.teleport(player, HallowedDimensions.THE_HALLOW);
				return ActionResult.SUCCESS;
			} else {
				player.addChatMessage(new TranslatableText("text.thehallow.gate_incomplete"), true);
			}
		} else {
			player.addChatMessage(new TranslatableText("text.thehallow.gate_in_wrong_dimension"), true);
		}
	}
	return ActionResult.PASS;
}
 
Example #3
Source File: GalacticraftCommands.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
private static int teleportMultiple(CommandContext<ServerCommandSource> context) {
    try {
        ServerWorld serverWorld = DimensionArgumentType.getDimensionArgument(context, "dimension");
        if (serverWorld == null) {
            context.getSource().sendError(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.failure.dimension").setStyle(Style.EMPTY.withColor(Formatting.RED)));
            return -1;
        }

        Collection<? extends Entity> entities = EntityArgumentType.getEntities(context, "entities");
        entities.forEach((Consumer<Entity>) entity -> {
            entity.changeDimension(serverWorld);
            context.getSource().sendFeedback(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.success.multiple", entities.size(), serverWorld.getRegistryKey().getValue()), true);
        });
    } catch (CommandSyntaxException ignore) {
        context.getSource().sendError(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.failure.entity").setStyle(Style.EMPTY.withColor(Formatting.RED)));
        return -1;
    }
    return -1;
}
 
Example #4
Source File: MixinPlayerChat_SayCommand.java    From Galaxy with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("UnresolvedMixinReference")
@Inject(
    method = "method_13563",
    at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/PlayerManager;broadcastChatMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/MessageType;Ljava/util/UUID;)V",
        ordinal = 0
    ),
    locals = LocalCapture.CAPTURE_FAILSOFT
)
private static void onCommand(CommandContext<ServerCommandSource> context, CallbackInfoReturnable<Integer> cir, Text text, TranslatableText translatableText, Entity entity) {
    if (!(entity instanceof ServerPlayerEntity)) return;

    Main main = Main.Companion.getMain();
    ServerPlayerEntity player = (ServerPlayerEntity) entity;

    if (main == null || !main.getEventManager().emit(new PlayerChatEvent(player, translatableText)).getCancel()) {
        player.server.getPlayerManager().broadcastChatMessage(translatableText, MessageType.CHAT, entity.getUuid());
    } else {
        cir.setReturnValue(0);
        cir.cancel();
        player.server.sendSystemMessage(translatableText.append(" (Canceled)"), entity.getUuid());
    }
}
 
Example #5
Source File: OxygenCollectorScreen.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void render(MatrixStack stack, int mouseX, int mouseY, float v) {
    super.render(stack, mouseX, mouseY, v);
    DrawableUtils.drawCenteredString(stack, this.client.textRenderer, new TranslatableText("block.galacticraft-rewoven.oxygen_collector").getString(), (this.width / 2), this.y + 5, Formatting.DARK_GRAY.getColorValue());
    String statusText = new TranslatableText("ui.galacticraft-rewoven.machine.status").getString();


    int statusX = this.x + 38;
    int statusY = this.y + 64;

    this.client.textRenderer.draw(stack, statusText, statusX, statusY, Formatting.DARK_GRAY.getColorValue());

    this.client.textRenderer.draw(stack, OxygenCollectorBlockEntity.OxygenCollectorStatus.get(handler.status.get()).getText(), statusX + this.client.textRenderer.getWidth(statusText), statusY, OxygenCollectorBlockEntity.OxygenCollectorStatus.get(handler.status.get()).getText().getStyle().getColor().getRgb());

    DrawableUtils.drawCenteredString(stack, this.client.textRenderer, new TranslatableText("ui.galacticraft-rewoven.machine.collecting", this.handler.lastCollectAmount.get()).getString(), (this.width / 2) + 10, statusY + 12, Formatting.DARK_GRAY.getColorValue());
    this.drawMouseoverTooltip(stack, mouseX, mouseY);
}
 
Example #6
Source File: GalacticraftCommands.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
private static int teleport(CommandContext<ServerCommandSource> context) {
    try {
        ServerWorld serverWorld = DimensionArgumentType.getDimensionArgument(context, "dimension");
        if (serverWorld == null) {
            context.getSource().sendError(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.failure.dimension").setStyle(Style.EMPTY.withColor(Formatting.RED)));
            return -1;
        }

        context.getSource().getPlayer().changeDimension(serverWorld);
        context.getSource().sendFeedback(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.success.single", serverWorld.getRegistryKey().getValue()), true);

    } catch (CommandSyntaxException ignore) {
        context.getSource().sendError(new TranslatableText("commands.galacticraft-rewoven.dimensiontp.failure.entity").setStyle(Style.EMPTY.withColor(Formatting.RED)));
        return -1;
    }
    return -1;
}
 
Example #7
Source File: GalacticraftEnergyType.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public TranslatableText getDisplayAmount(int amount) {
    float fAmount = (float) amount;

    if (fAmount < 1000) { // x < 1K
        return new TranslatableText("tooltip.galacticraft-rewoven.energy", fAmount);
    } else if (fAmount < 1_000_000) { // 1K < x < 1M
        float tAmount = fAmount / 1000;
        return new TranslatableText("tooltip.galacticraft-rewoven.energy.k", tAmount);
    } else if (fAmount < 1_000_000_000) { // 1M < x < 1G
        float tAmount = fAmount / 1_000_1000;
        return new TranslatableText("tooltip.galacticraft-rewoven.energy.m", tAmount);
    } else { // 1G < x
        float tAmount = fAmount / 1_000_000_000;
        return new TranslatableText("tooltip.galacticraft-rewoven.energy.g", tAmount);
    }
}
 
Example #8
Source File: PaperBagItem.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
public void appendTooltip(ItemStack itemStack, World world, List<Text> list, TooltipContext tooltipContext) {
	String translatedTooltip = new TranslatableText("text.thehallow.paper_bag").asString();
	String[] translatedTooltipWords = translatedTooltip.split(" ");
	
	StringBuilder tooltipBuilder = new StringBuilder();
	for (int i = 1; i <= translatedTooltipWords.length; i++) {
		tooltipBuilder.append(translatedTooltipWords[i - 1]);
		
		if (i % 4 == 0) {
			list.add(new LiteralText(tooltipBuilder.toString()).formatted(Formatting.GRAY));
			tooltipBuilder = new StringBuilder();
		} else {
			tooltipBuilder.append(" ");
		}
	}
	
	super.appendTooltip(itemStack, world, list, tooltipContext);
}
 
Example #9
Source File: Contributors.java    From the-hallow with MIT License 6 votes vote down vote up
private static Text makeDesc(Person person, Formatting formatting) {
	ContactInformation contact = person.getContact();
	Text ret = new LiteralText(person.getName()).formatted(formatting);
	contact.get("github").ifPresent(gh ->
		ret.append(Texts.bracketed(new TranslatableText("social.thehallow.github")
			.styled(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, gh))))
			.formatted(Formatting.BLACK)
		)
	);
	
	contact.get("minecraft").ifPresent(mc ->
		ret.append(Texts.bracketed(new TranslatableText("social.thehallow.minecraft")
			.styled(style -> style.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://mcuuid.net/?q=" + mc))))
			.formatted(Formatting.GREEN)
		)
	);
	
	return ret;
}
 
Example #10
Source File: Achievements_1_11_2.java    From multiconnect with MIT License 6 votes vote down vote up
private static Advancement create(String name, int x, int y, ItemStack icon, Advancement parent, boolean special) {
    if (x < minX) {
        minX = x;
    }
    if (y < minY) {
        minY = y;
    }
    Identifier id = new Identifier(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name));
    AdvancementDisplay display = new AdvancementDisplay(
            icon,
            new TranslatableText("achievement." + name),
            new TranslatableText("achievement." + name + ".desc"),
            parent == null ? new Identifier("textures/gui/advancements/backgrounds/stone.png") : null,
            special ? AdvancementFrame.CHALLENGE : AdvancementFrame.TASK,
            true,
            true,
            false
    );
    display.setPosition(x, y);
    Map<String, AdvancementCriterion> criteria = ImmutableMap.of(AchievementManager.REQUIREMENT, new AdvancementCriterion(new ImpossibleCriterion.Conditions()));
    String[][] requirements = {{AchievementManager.REQUIREMENT}};
    Advancement advancement = new Advancement(id, parent, display, AdvancementRewards.NONE, criteria, requirements);
    ACHIEVEMENTS.put(name, advancement);
    return advancement;
}
 
Example #11
Source File: MixinDisconnectedScreen.java    From multiconnect with MIT License 6 votes vote down vote up
@Inject(method = "<init>", at = @At("RETURN"))
private void onInit(Screen parentScreen, String title, Text reason, CallbackInfo ci) {
    forceProtocolLabel = new TranslatableText("multiconnect.changeForcedProtocol").append(" ->");

    isProtocolReason = false;
    server = MinecraftClient.getInstance().getCurrentServerEntry();
    if (server != null) {
        String reasonText = reason.getString().toLowerCase();
        for (ConnectionMode protocol : ConnectionMode.values()) {
            if (protocol != ConnectionMode.AUTO && reasonText.contains(protocol.getName())) {
                isProtocolReason = true;
                break;
            }
        }
        for (String word : TRIGGER_WORDS) {
            if (reasonText.contains(word)) {
                isProtocolReason = true;
                break;
            }
        }
    }
}
 
Example #12
Source File: MixinKeyboard.java    From Sandbox with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Inject(method = "processF3", at = @At("HEAD"), cancellable = true)
public void processF3(int button, CallbackInfoReturnable<Boolean> b) {
    if (button == 81) {
        this.debugWarn("debug.help.message");
        ChatHud chat = this.client.inGameHud.getChatHud();
        chat.addMessage(new TranslatableText("debug.reload_chunks.help"));
        chat.addMessage(new TranslatableText("debug.show_hitboxes.help"));
        chat.addMessage(new TranslatableText("debug.copy_location.help"));
        chat.addMessage(new TranslatableText("debug.clear_chat.help"));
        chat.addMessage(new TranslatableText("debug.cycle_renderdistance.help"));
        chat.addMessage(new TranslatableText("debug.chunk_boundaries.help"));
        chat.addMessage(new TranslatableText("debug.advanced_tooltips.help"));
        chat.addMessage(new TranslatableText("debug.inspect.help"));
        chat.addMessage(new TranslatableText("debug.creative_spectator.help"));
        chat.addMessage(new TranslatableText("debug.pause_focus.help"));
        chat.addMessage(new TranslatableText("debug.help.help"));
        chat.addMessage(new TranslatableText("debug.reload_resourcepacks.help"));
        chat.addMessage(new TranslatableText("debug.pause.help"));
        chat.addMessage(new LiteralText("Test"));
        b.setReturnValue(true);
    }
}
 
Example #13
Source File: EntityPlayerMPFake.java    From fabric-carpet with MIT License 6 votes vote down vote up
public static EntityPlayerMPFake createShadow(MinecraftServer server, ServerPlayerEntity player)
{
    player.getServer().getPlayerManager().remove(player);
    player.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login"));
    ServerWorld worldIn = server.getWorld(player.dimension);
    ServerPlayerInteractionManager interactionManagerIn = new ServerPlayerInteractionManager(worldIn);
    GameProfile gameprofile = player.getGameProfile();
    EntityPlayerMPFake playerShadow = new EntityPlayerMPFake(server, worldIn, gameprofile, interactionManagerIn, true);
    server.getPlayerManager().onPlayerConnect(new NetworkManagerFake(NetworkSide.SERVERBOUND), playerShadow);

    playerShadow.setHealth(player.getHealth());
    playerShadow.networkHandler.requestTeleport(player.getX(), player.getY(), player.getZ(), player.yaw, player.pitch);
    interactionManagerIn.setGameMode(player.interactionManager.getGameMode());
    ((ServerPlayerEntityInterface) playerShadow).getActionPack().copyFrom(((ServerPlayerEntityInterface) player).getActionPack());
    playerShadow.stepHeight = 0.6F;
    playerShadow.dataTracker.set(PLAYER_MODEL_PARTS, player.getDataTracker().get(PLAYER_MODEL_PARTS));


    server.getPlayerManager().sendToDimension(new EntitySetHeadYawS2CPacket(playerShadow, (byte) (player.headYaw * 256 / 360)), playerShadow.dimension);
    server.getPlayerManager().sendToAll(new PlayerListS2CPacket(PlayerListS2CPacket.Action.ADD_PLAYER, playerShadow));
    player.getServerWorld().getChunkManager().updateCameraPosition(playerShadow);
    return playerShadow;
}
 
Example #14
Source File: MixinPlayerChat_MeCommand.java    From Galaxy with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("UnresolvedMixinReference")
@Inject(
    method = "method_13238",
    at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/PlayerManager;broadcastChatMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/MessageType;Ljava/util/UUID;)V",
        ordinal = 0
    ),
    locals = LocalCapture.CAPTURE_FAILSOFT
)
private static void onCommand(CommandContext<ServerCommandSource> context, CallbackInfoReturnable<Integer> cir, TranslatableText translatableText, Entity entity) {
    if (!(entity instanceof ServerPlayerEntity)) return;

    Main main = Main.Companion.getMain();
    ServerPlayerEntity player = (ServerPlayerEntity) entity;

    if (main == null || !main.getEventManager().emit(new PlayerChatEvent(player, translatableText)).getCancel()) {
        player.server.getPlayerManager().broadcastChatMessage(translatableText, MessageType.CHAT, entity.getUuid());
    } else {
        cir.setReturnValue(0);
        cir.cancel();
        player.server.sendSystemMessage(translatableText.append(" (Canceled)"), entity.getUuid());
    }
}
 
Example #15
Source File: CompressorScreen.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public void drawMouseoverTooltip(MatrixStack stack, int mouseX, int mouseY) {
    super.drawMouseoverTooltip(stack, mouseX, mouseY);
    if (mouseX >= this.x - 22 && mouseX <= this.x && mouseY >= this.y + 3 && mouseY <= this.y + (22 + 3)) {
        this.renderTooltip(stack, new TranslatableText("ui.galacticraft-rewoven.tabs.side_config").setStyle(Style.EMPTY.withColor(Formatting.GRAY)), mouseX, mouseY);
    }
}
 
Example #16
Source File: BasicSolarPanelScreen.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
@NotNull
protected Collection<? extends Text> getEnergyTooltipLines() {
    List<Text> lines = new ArrayList<>();
    if (this.handler.blockEntity.status != BasicSolarPanelBlockEntity.BasicSolarPanelStatus.FULL
            && this.handler.blockEntity.status != BasicSolarPanelBlockEntity.BasicSolarPanelStatus.BLOCKED) {
        long time = world.getTimeOfDay() % 24000;
        if (time > 6000) {
            lines.add(new TranslatableText("ui.galacticraft-rewoven.machine.gj_per_t", (int) (((6000D - (time - 6000D)) / 705.882353D) + 0.5D) * this.handler.blockEntity.multiplier).setStyle(Style.EMPTY.withColor(Formatting.LIGHT_PURPLE)));
        } else {
            lines.add(new TranslatableText("ui.galacticraft-rewoven.machine.gj_per_t", (int) ((time / 705.882353D) + 0.5D) * this.handler.blockEntity.multiplier).setStyle(Style.EMPTY.withColor(Formatting.LIGHT_PURPLE)));
        }
    }
    return lines;
}
 
Example #17
Source File: GlowstoneWallTorchBlock.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public void buildTooltip(ItemStack itemStack, BlockView blockView, List<Text> list, TooltipContext tooltipContext) {
    if (Screen.hasShiftDown()) {
        list.add(new TranslatableText("tooltip.galacticraft-rewoven.glowstone_torch").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    } else {
        list.add(new TranslatableText("tooltip.galacticraft-rewoven.press_shift").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    }
}
 
Example #18
Source File: GlowstoneTorchBlock.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public void buildTooltip(ItemStack itemStack, BlockView blockView, List<Text> list, TooltipContext tooltipContext) {
    if (Screen.hasShiftDown()) {
        list.add(new TranslatableText("tooltip.galacticraft-rewoven.glowstone_torch").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    } else {
        list.add(new TranslatableText("tooltip.galacticraft-rewoven.press_shift").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    }
}
 
Example #19
Source File: StandardWrenchItem.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public void appendTooltip(ItemStack itemStack_1, World world_1, List<Text> list_1, TooltipContext tooltipContext_1) {
    if (Screen.hasShiftDown()) {
        list_1.add(new TranslatableText("tooltip.galacticraft-rewoven.standard_wrench").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    } else {
        list_1.add(new TranslatableText("tooltip.galacticraft-rewoven.press_shift").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    }
}
 
Example #20
Source File: BatteryItem.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public void appendTooltip(ItemStack stack, World world, List<Text> lines, TooltipContext context) {
    int charge = stack.getOrCreateTag().getInt("Energy");
    if (stack.getMaxDamage() - stack.getDamage() < 3334) {
        lines.add(new TranslatableText("tooltip.galacticraft-rewoven.energy-remaining", charge).setStyle(Style.EMPTY.withColor(Formatting.DARK_RED)));
    } else if (stack.getMaxDamage() - stack.getDamage() < 6667) {
        lines.add(new TranslatableText("tooltip.galacticraft-rewoven.energy-remaining", charge).setStyle(Style.EMPTY.withColor(Formatting.GOLD)));
    } else {
        lines.add(new TranslatableText("tooltip.galacticraft-rewoven.energy-remaining", charge).setStyle(Style.EMPTY.withColor(Formatting.GREEN)));
    }
    super.appendTooltip(stack, world, lines, context);
}
 
Example #21
Source File: Contributors.java    From the-hallow with MIT License 5 votes vote down vote up
public static void sendContributorsMessage(ServerCommandSource source) {
	source.sendFeedback(Texts.bracketed(new TranslatableText("thehallow.contrib.title").formatted(Formatting.GOLD)), false);
	
	Text root = new LiteralText("");
	
	for (Text entry : USER_INFO) {
		root.append(new TranslatableText("thehallow.contrib.entry", entry.copy()));
	}
	
	source.sendFeedback(root, false);
}
 
Example #22
Source File: SpooktoberCommand.java    From the-hallow with MIT License 5 votes vote down vote up
public static int run(CommandContext<ServerCommandSource> ctx) {
	
	long daysLeft = TimeUtil.daysTillSpooktober();
	
	if (daysLeft != 0) {
		ctx.getSource().sendFeedback(new TranslatableText("thehallow.cmd.tillspooktober", daysLeft).formatted(Formatting.GRAY), false);
		return 0;
	}
	
	ctx.getSource().sendFeedback(new TranslatableText("thehallow.cmd.spooktober").formatted(Formatting.GOLD, Formatting.BOLD), false);
	return SINGLE_SUCCESS;
}
 
Example #23
Source File: HallowedCommand.java    From the-hallow with MIT License 5 votes vote down vote up
public static int run(CommandContext<ServerCommandSource> ctx) {
	ctx.getSource().sendFeedback(Texts.bracketed(new TranslatableText("thehallow.about.name").formatted(Formatting.GOLD)), false);
	ctx.getSource().sendFeedback(new TranslatableText("thehallow.about.description").formatted(Formatting.LIGHT_PURPLE), false);
	ctx.getSource().sendFeedback(new TranslatableText("thehallow.about.github").formatted(Formatting.YELLOW)
			.append(new TranslatableText("thehallow.github").formatted(Formatting.GREEN)
				.styled(style -> style.setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/fabric-community/the-hallow")))),
		false);
	return SINGLE_SUCCESS;
}
 
Example #24
Source File: MixinDirectConnectScreen.java    From multiconnect with MIT License 5 votes vote down vote up
@Inject(method = "init", at = @At("RETURN"))
private void createButtons(CallbackInfo ci) {
    forceProtocolLabel = new TranslatableText("multiconnect.changeForcedProtocol").append(" ->");
    protocolSelector = new DropDownWidget<>(width - 80, 5, 70, 20, ConnectionMode.AUTO, mode -> new LiteralText(mode.getName()));
    ConnectionMode.populateDropDownWidget(protocolSelector);
    children.add(0, protocolSelector);
}
 
Example #25
Source File: MixinAddServerScreen.java    From multiconnect with MIT License 5 votes vote down vote up
@Inject(method = "init", at = @At("RETURN"))
private void createButtons(CallbackInfo ci) {
    forceProtocolLabel = new TranslatableText("multiconnect.changeForcedProtocol").append(" ->");
    protocolSelector = new DropDownWidget<>(width - 80, 5, 70, 20, ConnectionMode.byValue(ServersExt.getInstance().getForcedProtocol(server.address)), mode -> new LiteralText(mode.getName()));
    ConnectionMode.populateDropDownWidget(protocolSelector);
    children.add(0, protocolSelector);
}
 
Example #26
Source File: ModMenuSupport.java    From LibGui with MIT License 5 votes vote down vote up
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
	return screen -> new CottonClientScreen(new TranslatableText("options.libgui.libgui_settings"), new ConfigGui(screen)) {
		public void onClose() {
			this.client.openScreen(screen);
		}
		
		protected void init() {
			super.init();
			this.description.getRootPanel().validate(null);
		};
	};
}
 
Example #27
Source File: SandboxTitleScreen.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
public SandboxTitleScreen(boolean boolean_1) {
    super(new TranslatableText("narrator.screen.title"));
    this.backgroundRenderer = new RotatingCubeMapRenderer(PANORAMA_CUBE_MAP);
    this.doBackgroundFade = boolean_1;
    this.field_17776 = (double) (new Random()).nextFloat() < 1.0E-4D;
    if (Sandbox.unsupportedModsLoaded) {
        this.warning = new Warning(
                new TranslatableText("warning.sandbox.unsupported_mods_1").formatted(Formatting.RED, Formatting.BOLD),
                new TranslatableText("warning.sandbox.unsupported_mods_2").formatted(Formatting.RED),
                "https://hrzn.atlassian.net/servicedesk/customer/portal/3"
        );
    }
}
 
Example #28
Source File: PlayerManager_fakePlayersMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "createPlayer", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
        target = "Ljava/util/Iterator;hasNext()Z"), locals = LocalCapture.CAPTURE_FAILHARD)
private void newWhileLoop(GameProfile gameProfile_1, CallbackInfoReturnable<ServerPlayerEntity> cir, UUID uUID_1,
                          List list_1, Iterator var5)
{
    while (var5.hasNext())
    {
        ServerPlayerEntity serverPlayerEntity_3 = (ServerPlayerEntity) var5.next();
        if(serverPlayerEntity_3 instanceof EntityPlayerMPFake)
        {
            serverPlayerEntity_3.kill();
            continue;
        }
        serverPlayerEntity_3.networkHandler.disconnect(new TranslatableText("multiplayer.disconnect.duplicate_login"));
    }
}
 
Example #29
Source File: MachineHandledScreen.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
protected void drawEnergyTooltip(MatrixStack stack, int mouseX, int mouseY, int energyX, int energyY) {
    if (check(mouseX, mouseY, energyX, energyY, Constants.TextureCoordinates.OVERLAY_WIDTH, Constants.TextureCoordinates.OVERLAY_HEIGHT)) {
        List<Text> lines = new ArrayList<>();
        if (handler.blockEntity.getStatusForTooltip() != null) {
            lines.add(new TranslatableText("ui.galacticraft-rewoven.machine.status").setStyle(Style.EMPTY.withColor(Formatting.GRAY)).append(this.handler.blockEntity.getStatusForTooltip().getText()));
        }

        lines.add(new TranslatableText("ui.galacticraft-rewoven.machine.current_energy").setStyle(Style.EMPTY.withColor(Formatting.GOLD)).append(GalacticraftEnergy.GALACTICRAFT_JOULES.getDisplayAmount(this.handler.energy.get()).setStyle(Style.EMPTY.withColor(Formatting.BLUE))));
        lines.add(new TranslatableText("ui.galacticraft-rewoven.machine.max_energy").setStyle(Style.EMPTY.withColor(Formatting.RED)).append(GalacticraftEnergy.GALACTICRAFT_JOULES.getDisplayAmount(this.handler.getMaxEnergy()).setStyle(Style.EMPTY.withColor(Formatting.BLUE))));
        lines.addAll(getEnergyTooltipLines());

        this.renderTooltip(stack, lines, mouseX, mouseY);
    }
}
 
Example #30
Source File: CompressorBlock.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public final void buildTooltip(ItemStack itemStack_1, BlockView blockView_1, List<Text> list_1, TooltipContext tooltipContext_1) {
    if (Screen.hasShiftDown()) {
        list_1.add(new TranslatableText("tooltip.galacticraft-rewoven.compressor").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    } else {
        list_1.add(new TranslatableText("tooltip.galacticraft-rewoven.press_shift").setStyle(Style.EMPTY.withColor(Formatting.GRAY)));
    }
}