mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Replace more calls to I18n with Component.translatable
Fix up the Relay item Whitelist GUI
This commit is contained in:
parent
d1ceffcac9
commit
3a767e1894
10 changed files with 69 additions and 50 deletions
|
@ -19,7 +19,6 @@ import net.minecraft.ChatFormatting;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -154,7 +153,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay {
|
|||
BlockEntity tile = minecraft.level.getBlockEntity(pos);
|
||||
if (tile != null) {
|
||||
if (tile instanceof IPhantomTile phantom) {
|
||||
guiGraphics.drawString(minecraft.font, ChatFormatting.GOLD + I18n.get("tooltip." + ActuallyAdditions.MODID + ".blockPhantomRange.desc") + ": " + phantom.getRange(), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 - 40, ChatFormatting.WHITE.getColor());
|
||||
guiGraphics.drawString(minecraft.font, Component.translatable("tooltip." + ActuallyAdditions.MODID + ".blockPhantomRange.desc").append(": " + phantom.getRange()).withStyle(ChatFormatting.GOLD), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 - 40, ChatFormatting.WHITE.getColor());
|
||||
if (phantom.hasBoundPosition()) {
|
||||
int distance = Mth.ceil(new Vec3(pos.getX(), pos.getY(), pos.getZ()).distanceTo(new Vec3(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ())));
|
||||
BlockState state = minecraft.level.getBlockState(phantom.getBoundPosition());
|
||||
|
@ -171,7 +170,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay {
|
|||
drawWordWrap(guiGraphics, minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.connectedNoRange.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, 200, 0xFFFFFF, true);
|
||||
}
|
||||
} else {
|
||||
guiGraphics.drawString(minecraft.font, ChatFormatting.RED + I18n.get("tooltip.actuallyadditions.phantom.notConnected.desc"), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, ChatFormatting.WHITE.getColor());
|
||||
guiGraphics.drawString(minecraft.font, Component.translatable("tooltip.actuallyadditions.phantom.notConnected.desc").withStyle(ChatFormatting.RED), resolution.getGuiScaledWidth() / 2 + 5, resolution.getGuiScaledHeight() / 2 + 25, ChatFormatting.WHITE.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ import net.minecraft.client.gui.Font;
|
|||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
|
@ -58,7 +58,7 @@ public class RenderBatteryBox implements BlockEntityRenderer<TileEntityBatteryBo
|
|||
Font font = Minecraft.getInstance().font;
|
||||
|
||||
String energyTotal = Lang.cleanEnergyValues(cap, false);
|
||||
String energyName = I18n.get("misc.actuallyadditions.power_name_long");
|
||||
Component energyName = Component.translatable("misc.actuallyadditions.power_name_long");
|
||||
float backgroundOpacity = Minecraft.getInstance().options.getBackgroundOpacity(0.25F);
|
||||
int j = (int) (backgroundOpacity * 255.0F) << 24;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import net.minecraft.ChatFormatting;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -193,16 +192,17 @@ public class ClientEvents {
|
|||
|
||||
if (tileHit instanceof TileEntityBase base) {
|
||||
if (base.isRedstoneToggle()) {
|
||||
String strg = String.format("%s: %s", I18n.get("info." + ActuallyAdditions.MODID + ".redstoneMode"), ChatFormatting.DARK_RED + I18n.get("info." + ActuallyAdditions.MODID + ".redstoneMode." + (base.isPulseMode
|
||||
Component component = Component.translatable("info." + ActuallyAdditions.MODID + ".redstoneMode").append(": ")
|
||||
.append(Component.translatable("info." + ActuallyAdditions.MODID + ".redstoneMode." + (base.isPulseMode
|
||||
? "pulse"
|
||||
: "deactivation")) + ChatFormatting.RESET);
|
||||
guiGraphics.drawString(font, strg, (int) (event.getWindow().getGuiScaledWidth() / 2f + 5), (int) (event.getWindow().getGuiScaledHeight() / 2f + 5), 0xFFFFFF);
|
||||
: "deactivation")).withStyle(ChatFormatting.DARK_RED));
|
||||
guiGraphics.drawString(font, component, (int) (event.getWindow().getGuiScaledWidth() / 2f + 5), (int) (event.getWindow().getGuiScaledHeight() / 2f + 5), 0xFFFFFF);
|
||||
|
||||
String expl;
|
||||
Component expl;
|
||||
if (!stack.isEmpty() && stack.getItem() == CommonConfig.Other.redstoneConfigureItem) {
|
||||
expl = ChatFormatting.GREEN + I18n.get("info." + ActuallyAdditions.MODID + ".redstoneMode.validItem");
|
||||
expl = Component.translatable("info." + ActuallyAdditions.MODID + ".redstoneMode.validItem").withStyle(ChatFormatting.GREEN);
|
||||
} else {
|
||||
expl = ChatFormatting.GRAY.toString() + ChatFormatting.ITALIC + I18n.get("info." + ActuallyAdditions.MODID + ".redstoneMode.invalidItem", I18n.get(CommonConfig.Other.redstoneConfigureItem.asItem().getDescriptionId()));
|
||||
expl = Component.translatable("info." + ActuallyAdditions.MODID + ".redstoneMode.invalidItem", Component.translatable(CommonConfig.Other.redstoneConfigureItem.asItem().getDescriptionId()).getString()).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC);
|
||||
}
|
||||
guiGraphics.drawString(font, expl, (int) (event.getWindow().getGuiScaledWidth() / 2f + 5), (int) (event.getWindow().getGuiScaledHeight() / 2f + 15), 0xFFFFFF);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class GuiFilter extends AAScreen<ContainerFilter> {
|
|||
|
||||
@Override
|
||||
public void renderLabels(@Nonnull GuiGraphics guiGraphics, int x, int y) {
|
||||
AssetUtil.displayNameString(guiGraphics, this.font, this.imageWidth, -10, I18n.get("container." + ActuallyAdditions.MODID + ".filter"));
|
||||
AssetUtil.displayNameString(guiGraphics, this.font, this.imageWidth, -10, this.title.getString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,23 +13,36 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
|
|||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerLaserRelayItemWhitelist;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemAdvanced;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class GuiLaserRelayItemWhitelist extends AAScreen<ContainerLaserRelayItemWhitelist> {
|
||||
|
||||
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_laser_relay_item_whitelist");
|
||||
private final Component inboundText = Component.translatable("info." + ActuallyAdditions.MODID + ".gui.inbound");
|
||||
private final Component outboundText = Component.translatable("info." + ActuallyAdditions.MODID + ".gui.outbound");
|
||||
private final TileEntityLaserRelayItemAdvanced tile;
|
||||
|
||||
private FilterSettingsGui leftFilter;
|
||||
|
@ -57,43 +70,53 @@ public class GuiLaserRelayItemWhitelist extends AAScreen<ContainerLaserRelayItem
|
|||
public void init() {
|
||||
super.init();
|
||||
|
||||
// this.leftFilter = new FilterSettingsGui(this.tile.leftFilter, this.leftPos + 3, this.topPos + 6, this.buttonList);
|
||||
// this.rightFilter = new FilterSettingsGui(this.tile.rightFilter, this.leftPos + 157, this.topPos + 6, this.buttonList);
|
||||
//
|
||||
// this.buttonSmartWhitelistLeft = new Buttons.SmallerButton(2, this.leftPos + 3, this.topPos + 79, "S");
|
||||
// this.buttonSmartWhitelistRight = new Buttons.SmallerButton(3, this.leftPos + 157, this.topPos + 79, "S");
|
||||
// this.addButton(this.buttonSmartWhitelistLeft);
|
||||
// this.addButton(this.buttonSmartWhitelistRight);
|
||||
this.leftFilter = new FilterSettingsGui(this.tile.leftFilter, this.leftPos + 3, this.topPos + 6, this::addRenderableWidget, this::buttonClicked, 0);
|
||||
this.rightFilter = new FilterSettingsGui(this.tile.rightFilter, this.leftPos + 157, this.topPos + 6, this::addRenderableWidget, this::buttonClicked, 4);
|
||||
|
||||
this.buttonSmartWhitelistLeft = this.addRenderableWidget(Button.builder(
|
||||
Component.literal("S"),
|
||||
(button) -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.tile, 2);
|
||||
}).bounds(this.leftPos + 3, this.topPos + 79, 16, 16)
|
||||
.build());
|
||||
|
||||
this.buttonSmartWhitelistRight = this.addRenderableWidget(Button.builder(
|
||||
Component.literal("S"),
|
||||
(button) -> {
|
||||
PacketHandlerHelper.sendButtonPacket(this.tile, 3);
|
||||
}).bounds(this.leftPos + 157, this.topPos + 79, 16, 16)
|
||||
.build());
|
||||
}
|
||||
|
||||
public void buttonClicked(int id) {
|
||||
CompoundTag data = new CompoundTag();
|
||||
data.putInt("ButtonID", id);
|
||||
data.putInt("PlayerID", Minecraft.getInstance().player.getId());
|
||||
data.putString("WorldID", Minecraft.getInstance().level.dimension().location().toString());
|
||||
PacketDistributor.SERVER.noArg().send(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER));
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public void actionPerformed(Button button) {
|
||||
// PacketHandlerHelper.sendButtonPacket(this.tile, button.id);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void render(@Nonnull GuiGraphics guiGraphics, int x, int y, float f) {
|
||||
super.render(guiGraphics, x, y, f);
|
||||
//
|
||||
// if (this.buttonSmartWhitelistLeft.isMouseOver() || this.buttonSmartWhitelistRight.isMouseOver()) {
|
||||
// List<String> list = new ArrayList<>();
|
||||
// list.add(TextFormatting.BOLD + StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.smart"));
|
||||
// list.addAll(this.font.listFormattedStringToWidth(StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.smartInfo"), 200));
|
||||
// this.drawHoveringText(list, x, y); //renderComponentTooltip
|
||||
// }
|
||||
public void render(@Nonnull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
|
||||
this.leftFilter.drawHover(guiGraphics, x, y);
|
||||
this.rightFilter.drawHover(guiGraphics, x, y);
|
||||
if (this.buttonSmartWhitelistLeft.isMouseOver(mouseX, mouseY) || this.buttonSmartWhitelistRight.isMouseOver(mouseX, mouseY)) {
|
||||
List<FormattedCharSequence> list = new ArrayList<>();
|
||||
list.add(Component.translatable("info." + ActuallyAdditions.MODID + ".gui.smart").withStyle(ChatFormatting.BOLD).getVisualOrderText());
|
||||
list.addAll(this.font.split(Component.translatable("info." + ActuallyAdditions.MODID + ".gui.smartInfo"), 200));
|
||||
guiGraphics.renderTooltip(this.font, list, mouseX, mouseY); //renderTooltip
|
||||
}
|
||||
|
||||
this.leftFilter.drawHover(guiGraphics, mouseX, mouseY);
|
||||
this.rightFilter.drawHover(guiGraphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderLabels(@Nonnull GuiGraphics guiGraphics, int x, int y) {
|
||||
AssetUtil.displayNameString(guiGraphics, this.font, this.imageWidth, -10, this.tile);
|
||||
AssetUtil.displayNameString(guiGraphics, this.font, this.imageWidth, -10, this.title.getString());
|
||||
|
||||
String s1 = I18n.get("info." + ActuallyAdditions.MODID + ".gui.inbound");
|
||||
String s2 = I18n.get("info." + ActuallyAdditions.MODID + ".gui.outbound");
|
||||
guiGraphics.drawString(font, s1, 46 - this.font.width(s1) / 2, 80, 0x404040, false);
|
||||
guiGraphics.drawString(font, s2, 131 - this.font.width(s2) / 2, 80, 0x404040, false);
|
||||
guiGraphics.drawString(font, inboundText, 46 - this.font.width(inboundText) / 2, 80, 0x404040, false);
|
||||
guiGraphics.drawString(font, outboundText, 131 - this.font.width(outboundText) / 2, 80, 0x404040, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,6 +126,5 @@ public class GuiLaserRelayItemWhitelist extends AAScreen<ContainerLaserRelayItem
|
|||
guiGraphics.blit(AssetUtil.GUI_INVENTORY_LOCATION, this.leftPos, this.topPos + 93, 0, 0, 176, 86);
|
||||
|
||||
guiGraphics.blit(RES_LOC, this.leftPos, this.topPos, 0, 0, 176, 93);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.ContainerOilGenerator;
|
|||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
|
@ -70,7 +69,7 @@ public class GuiOilGenerator extends AAScreen<ContainerOilGenerator> {
|
|||
}
|
||||
|
||||
if (this.generator.maxBurnTime > 0 && this.generator.currentEnergyProduce > 0) {
|
||||
guiGraphics.drawCenteredString(this.font, this.generator.currentEnergyProduce + " " + I18n.get("misc.actuallyadditions.energy_tick"), this.leftPos + 87, this.topPos + 65, 0xFFFFFF);
|
||||
guiGraphics.drawCenteredString(this.font, Component.literal(this.generator.currentEnergyProduce + " ").append(Component.translatable("misc.actuallyadditions.energy_tick")), this.leftPos + 87, this.topPos + 65, 0xFFFFFF);
|
||||
guiGraphics.drawCenteredString(this.font, "for " + this.generator.maxBurnTime + " t", this.leftPos + 87, this.topPos + 75, 0xFFFFFF);
|
||||
PoseStack poseStack = guiGraphics.pose();
|
||||
poseStack.pushPose();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||
|
@ -37,7 +38,7 @@ public class ItemFilter extends ItemBase {
|
|||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
||||
if (!world.isClientSide && hand == InteractionHand.MAIN_HAND) {
|
||||
player.openMenu(new SimpleMenuProvider((windowId, inv, playerEnt) -> new ContainerFilter(windowId, inv), Component.empty()));
|
||||
player.openMenu(new SimpleMenuProvider((windowId, inv, playerEnt) -> new ContainerFilter(windowId, inv), Component.translatable("container." + ActuallyAdditions.MODID + ".filter")));
|
||||
// player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FILTER.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
}
|
||||
return InteractionResultHolder.pass(player.getItemInHand(hand));
|
||||
|
|
|
@ -19,7 +19,6 @@ import mezz.jei.api.recipe.RecipeType;
|
|||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
|
@ -69,7 +68,7 @@ public class CoffeeMachineCategory implements IRecipeCategory<CoffeeIngredientRe
|
|||
Minecraft mc = Minecraft.getInstance();
|
||||
if (!Strings.isNullOrEmpty(recipe.getExtraText())) {
|
||||
guiGraphics.drawString(mc.font, Component.translatable("jei." + ActuallyAdditions.MODID + ".coffee.special").append( ":"), 2, 4, 4210752, false);
|
||||
guiGraphics.drawString(mc.font, I18n.get(recipe.getExtraText()), 2, 16, 4210752, false);
|
||||
guiGraphics.drawString(mc.font, Component.literal(recipe.getExtraText()), 2, 16, 4210752, false);
|
||||
}
|
||||
|
||||
if (recipe.getMaxAmplifier() > 0) {
|
||||
|
|
|
@ -262,7 +262,6 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay {
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public Component getExtraDisplayString() {
|
||||
return Component.translatable("info." + ActuallyAdditions.MODID + ".laserRelay.energy.extra").append(": ").append(Component.translatable(this.mode.name).withStyle(ChatFormatting.DARK_RED));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -150,7 +150,7 @@ public class TileEntityLaserRelayItemAdvanced extends TileEntityLaserRelayItem i
|
|||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.empty();
|
||||
return Component.translatable("container.actuallyadditions.laserRelayAdvanced");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
Loading…
Reference in a new issue