use of net.minecraft.text.TranslatableText in project BlockMeter by ModProg.
the class BlockMeterClient method onInitializeClient.
@Override
public void onInitializeClient() {
final KeyBinding keyBinding = new KeyBinding("key.blockmeter.assign", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_M, "category.blockmeter.key");
final KeyBinding keyBindingMenu = new KeyBinding("key.blockmeter.menu", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_LEFT_ALT, "category.blockmeter.key");
KeyBindingHelper.registerKeyBinding(keyBinding);
KeyBindingHelper.registerKeyBinding(keyBindingMenu);
// This is ugly I know, but I did not find something better
// (Issue in AutoConfig https://github.com/shedaniel/AutoConfig/issues/13)
confMgr = (ConfigManager<ModConfig>) AutoConfig.register(ModConfig.class, Toml4jConfigSerializer::new);
ClientTickEvents.START_CLIENT_TICK.register(e -> {
if (keyBinding.wasPressed()) {
if (Screen.hasShiftDown()) {
if (undo())
e.player.sendMessage(new TranslatableText("blockmeter.clearLast"), true);
} else if (Screen.hasControlDown()) {
if (clear())
e.player.sendMessage(new TranslatableText("blockmeter.clearAll"), true);
} else if (this.active) {
disable();
e.player.sendMessage(new TranslatableText("blockmeter.toggle.off", new Object[0]), true);
} else {
active = true;
ItemStack itemStack = e.player.getMainHandStack();
currentItem = itemStack.getItem();
e.player.sendMessage(new TranslatableText("blockmeter.toggle.on", new Object[] { new TranslatableText(itemStack.getTranslationKey(), new Object[0]) }), true);
}
}
if (keyBindingMenu.wasPressed() && active && MinecraftClient.getInstance().player.getMainHandStack().getItem() == this.currentItem) {
MinecraftClient.getInstance().setScreen((Screen) this.quickMenu);
}
// Updates Selection preview
if (this.active && this.boxes.size() > 0) {
final ClientMeasureBox currentBox = getCurrentBox();
if (currentBox != null) {
final HitResult rayHit = e.player.raycast((double) e.interactionManager.getReachDistance(), 1.0f, false);
if (rayHit.getType() == HitResult.Type.BLOCK) {
final BlockHitResult blockHitResult = (BlockHitResult) rayHit;
currentBox.setBlockEnd(new BlockPos(blockHitResult.getBlockPos()));
}
}
}
});
UseBlockCallback.EVENT.register((playerEntity, world, hand, hitResult) -> this.onBlockMeterClick(playerEntity, hitResult));
}
use of net.minecraft.text.TranslatableText in project FabricWaystones by LordDeatHunter.
the class WaystoneBlockScreen method drawBackground.
@Override
protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) {
if (page == Page.WAYSTONES) {
super.drawBackground(matrices, delta, mouseX, mouseY);
} else {
this.renderBackground(matrices);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, CONFIG_TEXTURE);
this.drawTexture(matrices, x, y, 0, 0, this.backgroundWidth, this.backgroundHeight);
if (canEdit()) {
this.drawTexture(matrices, x + 23, y + 103, 0, 125, 103, 13);
}
renderButtons(matrices, mouseX, mouseY);
renderButtonText(matrices);
String owner = ((WaystoneBlockScreenHandler) handler).getOwnerName();
if (owner == null || "".equals(owner)) {
owner = new TranslatableText("waystones.config.no_owner").getString();
}
this.textRenderer.draw(matrices, new TranslatableText("waystones.config.owner", owner), this.x + 10, this.y + 75, 0x161616);
if (this.nameField.isVisible()) {
this.nameField.render(matrices, mouseX, mouseY, delta);
}
renderButtonTooltips(matrices, mouseX, mouseY);
}
}
use of net.minecraft.text.TranslatableText in project FabricWaystones by LordDeatHunter.
the class LocalVoidItem method appendTooltip.
@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
super.appendTooltip(stack, world, tooltip, context);
String name = null;
NbtCompound tag = stack.getNbt();
boolean invalid = false;
if (tag == null || !tag.contains("waystone")) {
invalid = true;
} else {
name = Waystones.WAYSTONE_STORAGE.getName(tag.getString("waystone"));
if (name == null) {
invalid = true;
}
}
if (invalid) {
tooltip.add(new TranslatableText("waystones.local_void.empty_tooltip"));
return;
}
tooltip.add(new TranslatableText("waystones.local_void.tooltip", new LiteralText(name).styled(style -> style.withColor(TextColor.parse(new TranslatableText("waystones.local_void.tooltip.arg_color").getString())))));
}
use of net.minecraft.text.TranslatableText in project FabricWaystones by LordDeatHunter.
the class ScrollOfInfiniteKnowledgeItem method appendTooltip.
@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
super.appendTooltip(stack, world, tooltip, context);
tooltip.add(new TranslatableText("waystones.scroll.infinite"));
int count = -1;
if (Waystones.WAYSTONE_STORAGE != null) {
count = Waystones.WAYSTONE_STORAGE.getCount();
} else if (world != null && world.isClient) {
count = ClientStuff.getWaystoneCount();
}
if (count != -1) {
tooltip.add(new TranslatableText("waystones.scroll.infinite_tooltip", new LiteralText(String.valueOf(count)).styled(style -> style.withColor(TextColor.parse(new TranslatableText("waystones.scroll.infinite_tooltip.arg_color").getString())))));
}
}
use of net.minecraft.text.TranslatableText in project FabricWaystones by LordDeatHunter.
the class WaystoneScrollItem method appendTooltip.
@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
super.appendTooltip(stack, world, tooltip, context);
NbtCompound tag = stack.getNbt();
if (tag == null || !tag.contains("waystones")) {
return;
}
int size = tag.getList("waystones", 8).size();
HashSet<String> waystones = null;
if (Waystones.WAYSTONE_STORAGE != null) {
waystones = Waystones.WAYSTONE_STORAGE.getAllHashes();
} else if (world != null && world.isClient) {
waystones = ClientStuff.getWaystoneHashes();
}
if (waystones != null) {
tooltip.add(new TranslatableText("waystones.scroll.tooltip", new LiteralText(String.valueOf(size)).styled(style -> style.withColor(TextColor.parse(new TranslatableText("waystones.scroll.tooltip.arg_color").getString())))));
}
}
Aggregations