类net.minecraft.util.Formatting源码实例Demo

下面列出了怎么用net.minecraft.util.Formatting的API类实例代码及写法,或者点击链接到github查看源代码。

@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);
}
 
@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);
}
 
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;
}
 
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;
}
 
源代码5 项目: the-hallow   文件: PaperBagItem.java
@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);
}
 
源代码6 项目: the-hallow   文件: Contributors.java
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;
}
 
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);
    }
}
 
@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)));
    }
}
 
@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)));
    }
}
 
源代码10 项目: Galacticraft-Rewoven   文件: CompressorBlock.java
@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)));
    }
}
 
源代码11 项目: Galacticraft-Rewoven   文件: CompressorScreen.java
@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);
    }
}
 
@Override
public void drawMouseoverTooltip(MatrixStack stack, int mouseX, int mouseY) {
    super.drawMouseoverTooltip(stack, mouseX, mouseY);
    this.drawEnergyTooltip(stack, mouseX, mouseY, this.x + 11, this.y + 18);
    if (mouseX >= oxygenDisplayX && mouseX <= oxygenDisplayX + OVERLAY_WIDTH && mouseY >= oxygenDisplayY && mouseY <= oxygenDisplayY + OVERLAY_HEIGHT) {
        List<Text> toolTipLines = new ArrayList<>();
        toolTipLines.add(new TranslatableText("ui.galacticraft-rewoven.machine.current_oxygen", GalacticraftEnergy.GALACTICRAFT_JOULES.getDisplayAmount(this.handler.energy.get()).setStyle(Style.EMPTY.withColor(Formatting.BLUE))).setStyle(Style.EMPTY.withColor(Formatting.GOLD)));
        toolTipLines.add(new TranslatableText("ui.galacticraft-rewoven.machine.max_oxygen", GalacticraftEnergy.GALACTICRAFT_JOULES.getDisplayAmount(this.handler.getMaxEnergy())).setStyle(Style.EMPTY.withColor(Formatting.RED)));
        this.renderTooltip(stack, toolTipLines, mouseX, mouseY);
    }
}
 
@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;
}
 
源代码14 项目: Galacticraft-Rewoven   文件: ItemStackMixin.java
@SuppressWarnings("RedundantSuppression")
@Inject(method = "getName", at = @At("RETURN"), cancellable = true)
private void getName(CallbackInfoReturnable<Text> returnable) {
    Identifier id = Registry.ITEM.getId(getItem());
    //noinspection ConstantConditions,PointlessBooleanExpression
    if (false && id.getNamespace().equals(Constants.MOD_ID)) {
        Text returnVal = returnable.getReturnValue();
        if (returnVal.getStyle().getColor() == null) {
            returnable.setReturnValue(returnVal.shallowCopy().setStyle(returnVal.getStyle().withColor(Formatting.BLUE)));
        }
    }
}
 
源代码15 项目: Galacticraft-Rewoven   文件: StandardWrenchItem.java
@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)));
    }
}
 
源代码16 项目: Galacticraft-Rewoven   文件: BatteryItem.java
@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);
}
 
源代码17 项目: the-hallow   文件: Contributors.java
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);
}
 
源代码18 项目: the-hallow   文件: SpooktoberCommand.java
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;
}
 
源代码19 项目: the-hallow   文件: HallowedCommand.java
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;
}
 
源代码20 项目: multiconnect   文件: ScoreboardCommand.java
private static String[] displaySlots() {
    List<String> slots = new ArrayList<>();
    slots.add("list");
    slots.add("sidebar");
    slots.add("belowName");
    for (Formatting formatting : Formatting.values()) {
        if (formatting.isColor()) {
            slots.add("sidebar.team." + formatting.getName().toLowerCase(Locale.ENGLISH));
        }
    }
    return slots.toArray(new String[0]);
}
 
源代码21 项目: OptiFabric   文件: OptifineZipResourcePack.java
@Override
public <T> T parseMetadata(ResourceMetadataReader<T> metaReader) throws IOException {
	JsonObject pack = new JsonObject();
	pack.addProperty("pack_format", 5);
	pack.addProperty("description", "Added by OptiFabric\n" + Formatting.RED.toString() + "Disable if you have issues.");
	pack.add("pack", new JsonObject());

	if (!pack.has(metaReader.getKey())) {
		return null;
	}

	return metaReader.fromJson(pack);
}
 
源代码22 项目: OptiFabric   文件: Optifabric.java
public static void checkForErrors() {
	if (OptifabricError.hasError()) {
		ConfirmScreen confirmScreen = new ConfirmScreen(t -> {
			if (t) {
				Util.getOperatingSystem().open(OptifabricError.getErrorURL());
			} else {
				MinecraftClient.getInstance().scheduleStop();
			}
		}, new LiteralText(Formatting.RED + "There was an error loading OptiFabric!"), new LiteralText(OptifabricError.getError()), Formatting.GREEN + OptifabricError.getHelpButtonText(), Formatting.RED + "Close Game");

		MinecraftClient.getInstance().openScreen(confirmScreen);
	}
}
 
源代码23 项目: Sandbox   文件: SandboxTitleScreen.java
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"
        );
    }
}
 
源代码24 项目: bleachhack-1.14   文件: ESP.java
@Subscribe
public void onTick(EventTick event) {
	for (Entity e: mc.world.getEntities()) {
		if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.RED, "players");
		}
		
		else if (e instanceof Monster && getSettings().get(1).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.DARK_BLUE, "mobs");
		}
		
		else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GREEN, "passive");
		}
		
		else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GOLD, "items");
		}
		
		else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.LIGHT_PURPLE, "crystals");
		}
		
		else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GRAY, "vehicles");
		}
		else {
		    e.setGlowing(false);
		}
	}
}
 
源代码25 项目: bleachhack-1.14   文件: EntityUtils.java
public static void setGlowing(Entity entity, Formatting color, String teamName) {
	Team team = mc.world.getScoreboard().getTeamNames().contains(teamName) ?
			mc.world.getScoreboard().getTeam(teamName) :
			mc.world.getScoreboard().addTeam(teamName);
       
	mc.world.getScoreboard().addPlayerToTeam(
			entity instanceof PlayerEntity ? entity.getEntityName() : entity.getUuidAsString(), team);
	mc.world.getScoreboard().getTeam(teamName).setColor(color);
	
	entity.setGlowing(true);
}
 
源代码26 项目: bleachhack-1.14   文件: ESP.java
@Subscribe
public void onTick(EventTick event) {
	for (Entity e: mc.world.getEntities()) {
		if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.RED, "players");
		}
		
		else if (e instanceof Monster && getSettings().get(1).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.DARK_BLUE, "mobs");
		}
		
		else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GREEN, "passive");
		}
		
		else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GOLD, "items");
		}
		
		else if (e instanceof EndCrystalEntity && getSettings().get(4).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.LIGHT_PURPLE, "crystals");
		}
		
		else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GRAY, "vehicles");
		}
		else {
		    e.setGlowing(false);
		}
	}
}
 
源代码27 项目: bleachhack-1.14   文件: EntityUtils.java
public static void setGlowing(Entity entity, Formatting color, String teamName) {
	Team team = mc.world.getScoreboard().getTeamNames().contains(teamName) ?
			mc.world.getScoreboard().getTeam(teamName) :
			mc.world.getScoreboard().addTeam(teamName);
       
	mc.world.getScoreboard().addPlayerToTeam(
			entity instanceof PlayerEntity ? entity.getEntityName() : entity.getUuidAsString(), team);
	mc.world.getScoreboard().getTeam(teamName).setColor(color);
	
	entity.setGlowing(true);
}
 
源代码28 项目: bleachhack-1.14   文件: ESP.java
@Subscribe
public void onTick(EventTick event) {
	for (Entity e: mc.world.getEntities()) {
		if (e instanceof PlayerEntity && e != mc.player && getSettings().get(0).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.RED, "players");
		}
		
		else if (e instanceof Monster && getSettings().get(1).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.DARK_BLUE, "mobs");
		}
		
		else if (EntityUtils.isAnimal(e) && getSettings().get(2).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GREEN, "passive");
		}
		
		else if (e instanceof ItemEntity && getSettings().get(3).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GOLD, "items");
		}
		
		else if (e instanceof EnderCrystalEntity && getSettings().get(4).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.LIGHT_PURPLE, "crystals");
		}
		
		else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSettings().get(5).toToggle().state) {
			EntityUtils.setGlowing(e, Formatting.GRAY, "vehicles");
		}
		else {
		    e.setGlowing(false);
		}
	}
}
 
源代码29 项目: bleachhack-1.14   文件: EntityUtils.java
public static void setGlowing(Entity entity, Formatting color, String teamName) {
	Team team = mc.world.getScoreboard().getTeamNames().contains(teamName) ?
			mc.world.getScoreboard().getTeam(teamName) :
			mc.world.getScoreboard().addTeam(teamName);
       
	mc.world.getScoreboard().addPlayerToTeam(
			entity instanceof PlayerEntity ? entity.getEntityName() : entity.getUuidAsString(), team);
	mc.world.getScoreboard().getTeam(teamName).setColor(color);
	
	entity.setGlowing(true);
}
 
源代码30 项目: fabric-carpet   文件: Messenger.java
public static Style parseStyle(String style)
{
    //could be rewritten to be more efficient
    Style styleInstance = new Style();
    styleInstance.setItalic(style.indexOf('i')>=0);
    styleInstance.setStrikethrough(style.indexOf('s')>=0);
    styleInstance.setUnderline(style.indexOf('u')>=0);
    styleInstance.setBold(style.indexOf('b')>=0);
    styleInstance.setObfuscated(style.indexOf('o')>=0);
    styleInstance.setColor(Formatting.WHITE);
    if (style.indexOf('w')>=0) styleInstance.setColor(Formatting.WHITE); // not needed
    if (style.indexOf('y')>=0) styleInstance.setColor(Formatting.YELLOW);
    if (style.indexOf('m')>=0) styleInstance.setColor(Formatting.LIGHT_PURPLE);
    if (style.indexOf('r')>=0) styleInstance.setColor(Formatting.RED);
    if (style.indexOf('c')>=0) styleInstance.setColor(Formatting.AQUA);
    if (style.indexOf('l')>=0) styleInstance.setColor(Formatting.GREEN);
    if (style.indexOf('t')>=0) styleInstance.setColor(Formatting.BLUE);
    if (style.indexOf('f')>=0) styleInstance.setColor(Formatting.DARK_GRAY);
    if (style.indexOf('g')>=0) styleInstance.setColor(Formatting.GRAY);
    if (style.indexOf('d')>=0) styleInstance.setColor(Formatting.GOLD);
    if (style.indexOf('p')>=0) styleInstance.setColor(Formatting.DARK_PURPLE);
    if (style.indexOf('n')>=0) styleInstance.setColor(Formatting.DARK_RED);
    if (style.indexOf('q')>=0) styleInstance.setColor(Formatting.DARK_AQUA);
    if (style.indexOf('e')>=0) styleInstance.setColor(Formatting.DARK_GREEN);
    if (style.indexOf('v')>=0) styleInstance.setColor(Formatting.DARK_BLUE);
    if (style.indexOf('k')>=0) styleInstance.setColor(Formatting.BLACK);
    return styleInstance;
}
 
 类所在包
 类方法
 同包方法