use of net.minecraft.text.LiteralText in project KiwiClient by TangyKiwi.
the class BetterChat method onMessageRecieve.
@Subscribe
@AllowConcurrentEvents
public void onMessageRecieve(AddMessageEvent event) {
((ChatHudAccessor) mc.inGameHud.getChatHud()).getVisibleMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
((ChatHudAccessor) mc.inGameHud.getChatHud()).getMessages().removeIf((message) -> message.getId() == event.id && event.id != 0);
Text message = event.message;
// Timestamps
if (getSetting(2).asToggle().state) {
Matcher matcher = Pattern.compile("^(<[0-9]{2}:[0-9]{2}:[0-9]{2}>\\s)").matcher(message.getString());
if (matcher.matches())
message.getSiblings().subList(0, 8).clear();
Text timestamp = new LiteralText("[" + dateFormat.format(new Date()) + "] ").formatted(Formatting.GRAY);
message = new LiteralText("").append(timestamp).append(message);
}
// Player Heads
if (getSetting(3).asToggle().state) {
message = new LiteralText(" ").append(message);
}
event.setCancelled(true);
((IChatHUD) mc.inGameHud.getChatHud()).add(message, event.id, mc.inGameHud.getTicks(), false);
}
use of net.minecraft.text.LiteralText in project KiwiClient by TangyKiwi.
the class BetterTab method getPlayerName.
public Text getPlayerName(PlayerListEntry playerListEntry) {
Text name;
Color color = null;
name = playerListEntry.getDisplayName();
if (name == null)
name = new LiteralText(playerListEntry.getProfile().getName());
if (color != null) {
String nameString = name.getString();
for (Formatting format : Formatting.values()) {
if (format.isColor())
nameString = nameString.replace(format.toString(), "");
}
name = new LiteralText(nameString).setStyle(name.getStyle().withColor(TextColor.fromRgb(color.getRGB())));
}
return name;
}
use of net.minecraft.text.LiteralText in project KiwiClient by TangyKiwi.
the class Tooltips method appendTooltip.
@Subscribe
@AllowConcurrentEvents
public void appendTooltip(ItemStackTooltipEvent event) {
// Stew
if (getSetting(0).asToggle().state) {
if (event.itemStack.getItem() == Items.SUSPICIOUS_STEW) {
NbtCompound tag = event.itemStack.getNbt();
if (tag != null) {
NbtList effects = tag.getList("Effects", 10);
if (effects != null) {
for (int i = 0; i < effects.size(); i++) {
NbtCompound effectTag = effects.getCompound(i);
byte effectId = effectTag.getByte("EffectId");
int effectDuration = effectTag.contains("EffectDuration") ? effectTag.getInt("EffectDuration") : 160;
StatusEffectInstance effect = new StatusEffectInstance(StatusEffect.byRawId(effectId), effectDuration, 0);
event.list.add(1, getStatusText(effect));
}
}
}
} else if (event.itemStack.getItem().isFood()) {
FoodComponent food = event.itemStack.getItem().getFoodComponent();
if (food != null) {
food.getStatusEffects().forEach((e) -> {
StatusEffectInstance effect = e.getFirst();
event.list.add(1, getStatusText(effect));
});
}
}
}
// Bees
if (getSetting(1).asToggle().state) {
if (event.itemStack.getItem() == Items.BEEHIVE || event.itemStack.getItem() == Items.BEE_NEST) {
NbtCompound tag = event.itemStack.getNbt();
if (tag != null) {
NbtCompound blockStateTag = tag.getCompound("BlockStateTag");
if (blockStateTag != null) {
int level = blockStateTag.getInt("honey_level");
event.list.add(1, new LiteralText(String.format("%sHoney Level: %s%d%s", Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY)));
}
NbtCompound blockEntityTag = tag.getCompound("BlockEntityTag");
if (blockEntityTag != null) {
NbtList beesTag = blockEntityTag.getList("Bees", 10);
event.list.add(1, new LiteralText(String.format("%sBees: %s%d%s", Formatting.GRAY, Formatting.YELLOW, beesTag.size(), Formatting.GRAY)));
}
}
}
}
// Fish handled in EntityBucketItemMixin
}
use of net.minecraft.text.LiteralText in project KiwiClient by TangyKiwi.
the class Dupe method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
HitResult hr = MinecraftClient.getInstance().crosshairTarget;
if (hr instanceof BlockHitResult) {
BlockHitResult bhr = (BlockHitResult) hr;
BlockState bs = MinecraftClient.getInstance().world.getBlockState(bhr.getBlockPos());
if (bs.getBlock() instanceof ShulkerBoxBlock) {
MinecraftClient.getInstance().interactionManager.interactBlock(MinecraftClient.getInstance().player, MinecraftClient.getInstance().world, Hand.MAIN_HAND, bhr);
preDoDupe = true;
}
} else {
Utils.mc.inGameHud.getChatHud().addMessage(new LiteralText("Please look at a shulker box"));
}
return SINGLE_SUCCESS;
});
}
use of net.minecraft.text.LiteralText in project KiwiClient by TangyKiwi.
the class Server method build.
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {
boolean sp = Utils.mc.isIntegratedServerRunning();
if (!sp && Utils.mc.getCurrentServerEntry() == null) {
Utils.mc.inGameHud.getChatHud().addMessage(new LiteralText("Error getting server info."));
return SINGLE_SUCCESS;
}
Utils.mc.inGameHud.getChatHud().addMessage(new LiteralText("\u00a77" + "------ Server Info ------"));
Utils.mc.inGameHud.getChatHud().addMessage(createText("Address", getAddress(sp)));
Utils.mc.inGameHud.getChatHud().addMessage(createText("Brand", getBrand(sp)));
Utils.mc.inGameHud.getChatHud().addMessage(createText("Day", getDay()));
Utils.mc.inGameHud.getChatHud().addMessage(createText("Difficulty", getDifficulty()));
Utils.mc.inGameHud.getChatHud().addMessage(createText("IP", getIP(sp)));
Utils.mc.inGameHud.getChatHud().addMessage(createText("MOTD", getMotd(sp)));
Utils.mc.inGameHud.getChatHud().addMessage(createText("Ping", getPing()));
Utils.mc.inGameHud.getChatHud().addMessage(createText("Permission Level", getPerms()));
Utils.mc.inGameHud.getChatHud().addMessage(createText("Protocol", getProtocol(sp)));
Utils.mc.inGameHud.getChatHud().addMessage(createText("Version", getVersion(sp)));
return SINGLE_SUCCESS;
});
}
Aggregations