Language barrier

- Added LangBuilder to streamline things that make use of chat components
- Started migrating a bunch of text to use lang builders
- Glowing display board text now has a higher alpha
This commit is contained in:
simibubi 2022-07-05 16:49:55 +02:00
parent 4e9fc7dba7
commit 7443c95553
167 changed files with 1049 additions and 813 deletions

View file

@ -136,7 +136,7 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
AllGuiTextures heatBar = noHeat ? AllGuiTextures.JEI_NO_HEAT_BAR : AllGuiTextures.JEI_HEAT_BAR;
heatBar.render(matrixStack, 4, 80);
Minecraft.getInstance().font.draw(matrixStack, Lang.translate(requiredHeat.getTranslationKey()), 9,
Minecraft.getInstance().font.draw(matrixStack, Lang.translateDirect(requiredHeat.getTranslationKey()), 9,
86, requiredHeat.getColor());
}

View file

@ -77,7 +77,7 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
@Override
public Component getTitle() {
return Lang.translate("recipe." + name);
return Lang.translateDirect("recipe." + name);
}
@Override
@ -125,7 +125,7 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
return (view, tooltip) -> {
float chance = output.getChance();
if (chance != 1)
tooltip.add(1, Lang.translate("recipe.processing.chance", chance < 0.01 ? "<1" : (int) (chance * 100))
tooltip.add(1, Lang.translateDirect("recipe.processing.chance", chance < 0.01 ? "<1" : (int) (chance * 100))
.withStyle(ChatFormatting.GOLD));
};
}
@ -168,7 +168,7 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
}
int amount = mbAmount == -1 ? fluidStack.getAmount() : mbAmount;
Component text = new TextComponent(String.valueOf(amount)).append(Lang.translate("generic.unit.millibuckets")).withStyle(ChatFormatting.GOLD);
Component text = new TextComponent(String.valueOf(amount)).append(Lang.translateDirect("generic.unit.millibuckets")).withStyle(ChatFormatting.GOLD);
if (tooltip.isEmpty())
tooltip.add(0, text);
else {

View file

@ -47,7 +47,7 @@ public class DeployingCategory extends CreateRecipeCategory<DeployerApplicationR
.addTooltipCallback(addStochasticTooltip(recipe.getRollableResults().get(0)));
if (recipe.shouldKeepHeldItem()) {
handItemSlot.addTooltipCallback((recipeSlotView, tooltip) -> tooltip.add(1, Lang.translate("recipe.deploying.not_consumed").withStyle(ChatFormatting.GOLD)));
handItemSlot.addTooltipCallback((recipeSlotView, tooltip) -> tooltip.add(1, Lang.translateDirect("recipe.deploying.not_consumed").withStyle(ChatFormatting.GOLD)));
}
}

View file

@ -47,7 +47,7 @@ public class ItemApplicationCategory extends CreateRecipeCategory<ItemApplicatio
.addIngredients(recipe.getRequiredHeldItem())
.addTooltipCallback(
recipe.shouldKeepHeldItem()
? (view, tooltip) -> tooltip.add(1, Lang.translate("recipe.deploying.not_consumed")
? (view, tooltip) -> tooltip.add(1, Lang.translateDirect("recipe.deploying.not_consumed")
.withStyle(ChatFormatting.GOLD))
: (view, tooltip) -> {}
);

View file

@ -38,7 +38,7 @@ public abstract class ProcessingViaFanCategory<T extends Recipe<?>> extends Crea
public static Supplier<ItemStack> getFan(String name) {
return () -> AllBlocks.ENCASED_FAN.asStack()
.setHoverName(Lang.translate("recipe." + name + ".fan").withStyle(style -> style.withItalic(false)));
.setHoverName(Lang.translateDirect("recipe." + name + ".fan").withStyle(style -> style.withItalic(false)));
}
@Override

View file

@ -63,7 +63,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
return;
float chance = recipe.getOutputChance();
tooltip.add(1, Lang.translate("recipe.processing.chance", chance < 0.01 ? "<1" : (int) (chance * 100))
tooltip.add(1, Lang.translateDirect("recipe.processing.chance", chance < 0.01 ? "<1" : (int) (chance * 100))
.withStyle(ChatFormatting.GOLD));
});
@ -151,7 +151,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
public List<Component> getTooltipStrings(SequencedAssemblyRecipe recipe, IRecipeSlotsView iRecipeSlotsView, double mouseX, double mouseY) {
List<Component> tooltip = new ArrayList<>();
TranslatableComponent junk = Lang.translate("recipe.assembly.junk");
TranslatableComponent junk = Lang.translateDirect("recipe.assembly.junk");
boolean singleOutput = recipe.getOutputChance() == 1;
boolean willRepeat = recipe.getLoops() > 1;
@ -164,7 +164,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
if (!singleOutput && mouseX >= minX && mouseX < maxX && mouseY >= minY && mouseY < maxY) {
float chance = recipe.getOutputChance();
tooltip.add(junk);
tooltip.add(Lang.translate("recipe.processing.chance", chance < 0.01 ? "<1" : 100 - (int) (chance * 100))
tooltip.add(Lang.translateDirect("recipe.processing.chance", chance < 0.01 ? "<1" : 100 - (int) (chance * 100))
.withStyle(ChatFormatting.GOLD));
return tooltip;
}
@ -174,7 +174,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
minY = 92;
maxY = minY + 24;
if (willRepeat && mouseX >= minX && mouseX < maxX && mouseY >= minY && mouseY < maxY) {
tooltip.add(Lang.translate("recipe.assembly.repeat", recipe.getLoops()));
tooltip.add(Lang.translateDirect("recipe.assembly.repeat", recipe.getLoops()));
return tooltip;
}
@ -192,7 +192,7 @@ public class SequencedAssemblyCategory extends CreateRecipeCategory<SequencedAss
SequencedRecipe<?> sequencedRecipe = sequence.get(i);
SequencedAssemblySubCategory subCategory = getSubCategory(sequencedRecipe);
if (relativeX >= 0 && relativeX < subCategory.getWidth()) {
tooltip.add(Lang.translate("recipe.assembly.step", i + 1));
tooltip.add(Lang.translateDirect("recipe.assembly.step", i + 1));
tooltip.add(sequencedRecipe.getAsAssemblyRecipe()
.getDescriptionForAssembly()
.plainCopy()

View file

@ -111,7 +111,7 @@ public abstract class SequencedAssemblySubCategory {
if (recipe.getAsAssemblyRecipe() instanceof DeployerApplicationRecipe deployerRecipe && deployerRecipe.shouldKeepHeldItem()) {
slot.addTooltipCallback(
(recipeSlotView, tooltip) -> tooltip.add(1, Lang.translate("recipe.deploying.not_consumed").withStyle(ChatFormatting.GOLD))
(recipeSlotView, tooltip) -> tooltip.add(1, Lang.translateDirect("recipe.deploying.not_consumed").withStyle(ChatFormatting.GOLD))
);
}
}

View file

@ -4,13 +4,13 @@ import java.util.List;
import com.simibubi.create.content.contraptions.KineticNetwork;
import com.simibubi.create.content.contraptions.base.IRotate.SpeedLevel;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.contraptions.base.IRotate.StressImpact;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
@ -57,31 +57,35 @@ public abstract class GeneratingKineticTileEntity extends KineticTileEntity {
@Override
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
boolean added = super.addToGoggleTooltip(tooltip, isPlayerSneaking);
if (!StressImpact.isEnabled())
return added;
float stressBase = calculateAddedStressCapacity();
if (stressBase != 0 && IRotate.StressImpact.isEnabled()) {
tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.goggles.generator_stats")));
tooltip.add(componentSpacing.plainCopy().append(Lang.translate("tooltip.capacityProvided").withStyle(ChatFormatting.GRAY)));
if (Mth.equal(stressBase, 0))
return added;
Lang.translate("gui.goggles.generator_stats")
.forGoggles(tooltip);
Lang.translate("tooltip.capacityProvided")
.style(ChatFormatting.GRAY)
.forGoggles(tooltip);
float speed = getTheoreticalSpeed();
if (speed != getGeneratedSpeed() && speed != 0)
stressBase *= getGeneratedSpeed() / speed;
speed = Math.abs(speed);
float stressTotal = stressBase * speed;
tooltip.add(
componentSpacing.plainCopy()
.append(new TextComponent(" " + IHaveGoggleInformation.format(stressTotal))
.append(Lang.translate("generic.unit.stress"))
.withStyle(ChatFormatting.AQUA))
.append(" ")
.append(Lang.translate("gui.goggles.at_current_speed").withStyle(ChatFormatting.DARK_GRAY)));
Lang.number(stressTotal)
.translate("generic.unit.stress")
.style(ChatFormatting.AQUA)
.space()
.add(Lang.translate("gui.goggles.at_current_speed")
.style(ChatFormatting.DARK_GRAY))
.forGoggles(tooltip, 1);
added = true;
}
return added;
return true;
}
public void updateGeneratedRotation() {

View file

@ -1,18 +1,15 @@
package com.simibubi.create.content.contraptions.base;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.item.ItemDescription;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.LangBuilder;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.state.BlockState;
@ -49,9 +46,11 @@ public interface IRotate extends IWrenchable {
public float getSpeedValue() {
switch (this) {
case FAST:
return AllConfigs.SERVER.kinetics.fastSpeed.get().floatValue();
return AllConfigs.SERVER.kinetics.fastSpeed.get()
.floatValue();
case MEDIUM:
return AllConfigs.SERVER.kinetics.mediumSpeed.get().floatValue();
return AllConfigs.SERVER.kinetics.mediumSpeed.get()
.floatValue();
case SLOW:
return 1;
case NONE:
@ -72,19 +71,26 @@ public interface IRotate extends IWrenchable {
return NONE;
}
public static Component getFormattedSpeedText(float speed, boolean overstressed) {
public static LangBuilder getFormattedSpeedText(float speed, boolean overstressed) {
SpeedLevel speedLevel = of(speed);
LangBuilder builder = Lang.text(ItemDescription.makeProgressBar(3, speedLevel.ordinal()));
MutableComponent level = new TextComponent(ItemDescription.makeProgressBar(3, speedLevel.ordinal()));
level.append(Lang.translate("tooltip.speedRequirement." + Lang.asId(speedLevel.name())));
level.append(" (" + IHaveGoggleInformation.format(Math.abs(speed))).append(Lang.translate("generic.unit.rpm")).append(") ");
builder.translate("tooltip.speedRequirement." + Lang.asId(speedLevel.name()))
.space()
.text("(")
.add(Lang.number(Math.abs(speed)))
.space()
.translate("generic.unit.rpm")
.text(")")
.space();
if (overstressed)
level.withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.STRIKETHROUGH);
builder.style(ChatFormatting.DARK_GRAY)
.style(ChatFormatting.STRIKETHROUGH);
else
level.withStyle(speedLevel.getTextColor());
builder.style(speedLevel.getTextColor());
return level;
return builder;
}
}
@ -125,14 +131,12 @@ public interface IRotate extends IWrenchable {
return !AllConfigs.SERVER.kinetics.disableStress.get();
}
public static Component getFormattedStressText(double stressPercent) {
public static LangBuilder getFormattedStressText(double stressPercent) {
StressImpact stressLevel = of(stressPercent);
MutableComponent level = new TextComponent(ItemDescription.makeProgressBar(3, Math.min(stressLevel.ordinal() + 1, 3)));
level.append(Lang.translate("tooltip.stressImpact." + Lang.asId(stressLevel.name())));
level.append(String.format(" (%s%%) ", (int) (stressPercent * 100)));
return level.withStyle(stressLevel.getRelativeColor());
return Lang.text(ItemDescription.makeProgressBar(3, Math.min(stressLevel.ordinal() + 1, 3)))
.translate("tooltip.stressImpact." + Lang.asId(stressLevel.name()))
.text(String.format(" (%s%%) ", (int) (stressPercent * 100)))
.style(stressLevel.getRelativeColor());
}
}

View file

@ -35,7 +35,6 @@ import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
@ -46,8 +45,7 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor;
public class KineticTileEntity extends SmartTileEntity
implements IHaveGoggleInformation, IHaveHoveringInformation {
public class KineticTileEntity extends SmartTileEntity implements IHaveGoggleInformation, IHaveHoveringInformation {
public @Nullable Long network;
public @Nullable BlockPos source;
@ -399,9 +397,9 @@ public class KineticTileEntity extends SmartTileEntity
if (overStressed && AllConfigs.CLIENT.enableOverstressedTooltip.get()) {
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.stressometer.overstressed")
.append(Lang.translateDirect("gui.stressometer.overstressed")
.withStyle(GOLD)));
Component hint = Lang.translate("gui.contraptions.network_overstressed");
Component hint = Lang.translateDirect("gui.contraptions.network_overstressed");
List<Component> cutString = TooltipHelper.cutTextComponent(hint, GRAY, ChatFormatting.WHITE);
for (int i = 0; i < cutString.size(); i++)
tooltip.add(componentSpacing.plainCopy()
@ -411,9 +409,10 @@ public class KineticTileEntity extends SmartTileEntity
if (notFastEnough) {
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.speedRequirement")
.append(Lang.translateDirect("tooltip.speedRequirement")
.withStyle(GOLD)));
Component hint = Lang.translate("gui.contraptions.not_fast_enough", I18n.get(getBlockState().getBlock()
Component hint =
Lang.translateDirect("gui.contraptions.not_fast_enough", I18n.get(getBlockState().getBlock()
.getDescriptionId()));
List<Component> cutString = TooltipHelper.cutTextComponent(hint, GRAY, ChatFormatting.WHITE);
for (int i = 0; i < cutString.size(); i++)
@ -428,29 +427,30 @@ public class KineticTileEntity extends SmartTileEntity
@Override
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
boolean added = false;
float stressAtBase = calculateStressApplied();
if (calculateStressApplied() != 0 && StressImpact.isEnabled()) {
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.goggles.kinetic_stats")));
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.stressImpact")
.withStyle(ChatFormatting.GRAY)));
if (!StressImpact.isEnabled())
return added;
float stressAtBase = calculateStressApplied();
if (Mth.equal(stressAtBase, 0))
return added;
Lang.translate("gui.goggles.kinetic_stats")
.forGoggles(tooltip);
Lang.translate("tooltip.stressImpact")
.style(GRAY)
.forGoggles(tooltip);
float stressTotal = stressAtBase * Math.abs(getTheoreticalSpeed());
tooltip.add(componentSpacing.plainCopy()
.append(new TextComponent(" " + IHaveGoggleInformation.format(stressTotal))
.append(Lang.translate("generic.unit.stress"))
.append(" ")
.withStyle(ChatFormatting.AQUA))
.append(Lang.translate("gui.goggles.at_current_speed")
.withStyle(ChatFormatting.DARK_GRAY)));
Lang.number(stressTotal)
.translate("generic.unit.stress")
.style(ChatFormatting.AQUA)
.space()
.add(Lang.translate("gui.goggles.at_current_speed")
.style(ChatFormatting.DARK_GRAY))
.forGoggles(tooltip, 1);
added = true;
}
return added;
return true;
}

View file

@ -60,7 +60,7 @@ public class DeployerApplicationRecipe extends ItemApplicationRecipe implements
.getItems();
if (matchingStacks.length == 0)
return new TextComponent("Invalid");
return Lang.translate("recipe.assembly.deploying_item",
return Lang.translateDirect("recipe.assembly.deploying_item",
new TranslatableComponent(matchingStacks[0].getDescriptionId()).getString());
}

View file

@ -64,7 +64,7 @@ public class DeployerFakePlayer extends FakePlayer {
@Override
public Component getDisplayName() {
return Lang.translate("block.deployer.damage_source_name");
return Lang.translateDirect("block.deployer.damage_source_name");
}
@Override

View file

@ -32,11 +32,11 @@ public class CreativeMotorTileEntity extends GeneratingKineticTileEntity {
CenteredSideValueBoxTransform slot = new CenteredSideValueBoxTransform(
(motor, side) -> motor.getValue(CreativeMotorBlock.FACING) == side.getOpposite());
generatedSpeed = new ScrollValueBehaviour(Lang.translate("generic.speed"), this, slot);
generatedSpeed = new ScrollValueBehaviour(Lang.translateDirect("generic.speed"), this, slot);
generatedSpeed.between(-max, max);
generatedSpeed.value = DEFAULT_SPEED;
generatedSpeed.scrollableValue = DEFAULT_SPEED;
generatedSpeed.withUnit(i -> Lang.translate("generic.unit.rpm"));
generatedSpeed.withUnit(i -> Lang.translateDirect("generic.unit.rpm"));
generatedSpeed.withCallback(i -> this.updateGeneratedRotation());
generatedSpeed.withStepFunction(CreativeMotorTileEntity::step);
behaviours.add(generatedSpeed);

View file

@ -53,7 +53,7 @@ public class PressingRecipe extends ProcessingRecipe<RecipeWrapper> implements I
@Override
@OnlyIn(Dist.CLIENT)
public Component getDescriptionForAssembly() {
return Lang.translate("recipe.assembly.pressing");
return Lang.translateDirect("recipe.assembly.pressing");
}
@Override

View file

@ -53,7 +53,7 @@ public class CuttingRecipe extends ProcessingRecipe<RecipeWrapper> implements IA
@Override
@OnlyIn(Dist.CLIENT)
public Component getDescriptionForAssembly() {
return Lang.translate("recipe.assembly.cutting");
return Lang.translateDirect("recipe.assembly.cutting");
}
@Override

View file

@ -54,7 +54,7 @@ public class SteamEngineTileEntity extends SmartTileEntity implements IHaveGoggl
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
movementDirection = new ScrollOptionBehaviour<>(RotationDirection.class,
Lang.translate("contraptions.windmill.rotation_direction"), this, new SteamEngineValueBox());
Lang.translateDirect("contraptions.windmill.rotation_direction"), this, new SteamEngineValueBox());
movementDirection.requiresWrench();
movementDirection.onlyActiveWhen(() -> {
PoweredShaftTileEntity shaft = getShaft();

View file

@ -107,11 +107,11 @@ public class WhistleTileEntity extends SmartTileEntity implements IHaveGoggleInf
@Override
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
String[] pitches = Lang.translate("generic.notes")
String[] pitches = Lang.translateDirect("generic.notes")
.getString()
.split(";");
TextComponent textComponent = new TextComponent(spacing);
tooltip.add(textComponent.append(Lang.translate("generic.pitch", pitches[pitch % pitches.length])));
tooltip.add(textComponent.append(Lang.translateDirect("generic.pitch", pitches[pitch % pitches.length])));
return true;
}

View file

@ -22,7 +22,7 @@ public interface IDisplayAssemblyExceptions {
tooltip.add(TextComponent.EMPTY);
tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy()
.append(Lang.translate("gui.assembly.exception")
.append(Lang.translateDirect("gui.assembly.exception")
.withStyle(ChatFormatting.GOLD)));
String text = e.component.getString();

View file

@ -54,7 +54,7 @@ public class ClockworkBearingTileEntity extends KineticTileEntity
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
super.addBehaviours(behaviours);
operationMode = new ScrollOptionBehaviour<>(ClockHands.class,
Lang.translate("contraptions.clockwork.clock_hands"), this, getMovementModeSlot());
Lang.translateDirect("contraptions.clockwork.clock_hands"), this, getMovementModeSlot());
operationMode.requiresWrench();
behaviours.add(operationMode);
registerAwardables(behaviours, AllAdvancements.CLOCKWORK_BEARING);

View file

@ -51,7 +51,7 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
super.addBehaviours(behaviours);
movementMode = new ScrollOptionBehaviour<>(RotationMode.class, Lang.translate("contraptions.movement_mode"),
movementMode = new ScrollOptionBehaviour<>(RotationMode.class, Lang.translateDirect("contraptions.movement_mode"),
this, getMovementModeSlot());
movementMode.requiresWrench();
behaviours.add(movementMode);

View file

@ -101,7 +101,7 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity {
super.addBehaviours(behaviours);
behaviours.remove(movementMode);
movementDirection = new ScrollOptionBehaviour<>(RotationDirection.class,
Lang.translate("contraptions.windmill.rotation_direction"), this, getMovementModeSlot());
Lang.translateDirect("contraptions.windmill.rotation_direction"), this, getMovementModeSlot());
movementDirection.requiresWrench();
movementDirection.withCallback($ -> onDirectionChanged());
behaviours.add(movementDirection);

View file

@ -41,7 +41,7 @@ public class ChassisTileEntity extends SmartTileEntity {
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
int max = AllConfigs.SERVER.kinetics.maxChassisRange.get();
range = new BulkScrollValueBehaviour(Lang.translate("generic.range"), this, new CenteredSideValueBoxTransform(),
range = new BulkScrollValueBehaviour(Lang.translateDirect("generic.range"), this, new CenteredSideValueBoxTransform(),
te -> ((ChassisTileEntity) te).collectChassisGroup());
range.requiresWrench();
range.between(1, max);
@ -56,7 +56,7 @@ public class ChassisTileEntity extends SmartTileEntity {
public void initialize() {
super.initialize();
if (getBlockState().getBlock() instanceof RadialChassisBlock)
range.setLabel(Lang.translate("generic.radius"));
range.setLabel(Lang.translateDirect("generic.radius"));
}
public int getRange() {

View file

@ -40,7 +40,7 @@ public class ControlsHandler {
controlsPos = controllerLocalPos;
Minecraft.getInstance().player.displayClientMessage(
Lang.translate("contraption.controls.start_controlling", entity.getContraptionName()), true);
Lang.translateDirect("contraption.controls.start_controlling", entity.getContraptionName()), true);
}
public static void stopControlling() {
@ -57,7 +57,7 @@ public class ControlsHandler {
controlsPos = null;
currentlyPressed.clear();
Minecraft.getInstance().player.displayClientMessage(Lang.translate("contraption.controls.stop_controlling"),
Minecraft.getInstance().player.displayClientMessage(Lang.translateDirect("contraption.controls.stop_controlling"),
true);
}

View file

@ -234,7 +234,7 @@ public class CartAssemblerTileEntity extends SmartTileEntity implements IDisplay
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
movementMode = new ScrollOptionBehaviour<>(CartMovementMode.class,
Lang.translate("contraptions.cart_movement_mode"), this, getMovementModeSlot());
Lang.translateDirect("contraptions.cart_movement_mode"), this, getMovementModeSlot());
movementMode.requiresWrench();
behaviours.add(movementMode);
registerAwardables(behaviours, AllAdvancements.CONTRAPTION_ACTORS);

View file

@ -218,7 +218,7 @@ public class MinecartContraptionItem extends Item {
OrientedContraptionEntity contraption = (OrientedContraptionEntity) passengers.get(0);
if(ContraptionMovementSetting.isNoPickup(contraption.getContraption().getBlocks().values())) {
player.displayClientMessage(Lang.translate("contraption.minecart_contraption_illegal_pickup")
player.displayClientMessage(Lang.translateDirect("contraption.minecart_contraption_illegal_pickup")
.withStyle(ChatFormatting.RED), true);
return;
}
@ -236,7 +236,7 @@ public class MinecartContraptionItem extends Item {
NbtIo.write(generatedStack.serializeNBT(), dataOutput);
int estimatedPacketSize = dataOutput.toByteArray().length;
if (estimatedPacketSize > 2_000_000) {
player.displayClientMessage(Lang.translate("contraption.minecart_contraption_too_big")
player.displayClientMessage(Lang.translateDirect("contraption.minecart_contraption_too_big")
.withStyle(ChatFormatting.RED), true);
return;
}

View file

@ -49,7 +49,7 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
super.addBehaviours(behaviours);
movementMode = new ScrollOptionBehaviour<>(MovementMode.class, Lang.translate("contraptions.movement_mode"),
movementMode = new ScrollOptionBehaviour<>(MovementMode.class, Lang.translateDirect("contraptions.movement_mode"),
this, getMovementModeSlot());
movementMode.requiresWrench();
movementMode.withCallback(t -> waitingForSpeedChange = false);

View file

@ -177,7 +177,7 @@ public class CouplingHandler {
public static void status(Player player, String key) {
if (player == null)
return;
player.displayClientMessage(Lang.translate("minecart_coupling." + key), true);
player.displayClientMessage(Lang.translateDirect("minecart_coupling." + key), true);
}
}

View file

@ -72,7 +72,7 @@ public class FillingRecipe extends ProcessingRecipe<RecipeWrapper> implements IA
.getMatchingFluidStacks();
if (matchingFluidStacks.size() == 0)
return new TextComponent("Invalid");
return Lang.translate("recipe.assembly.spout_filling_fluid",
return Lang.translateDirect("recipe.assembly.spout_filling_fluid",
new TranslatableComponent(matchingFluidStacks.get(0)
.getTranslationKey()).getString());
}

View file

@ -150,7 +150,8 @@ public class BoilerData {
calcMinMaxForSize(boilerSize);
tooltip.add(indent.plainCopy()
.append(Lang.translate("boiler.status", getHeatLevelTextComponent().withStyle(ChatFormatting.GREEN))));
.append(
Lang.translateDirect("boiler.status", getHeatLevelTextComponent().withStyle(ChatFormatting.GREEN))));
tooltip.add(indent2.plainCopy()
.append(getSizeComponent(true, false)));
tooltip.add(indent2.plainCopy()
@ -162,22 +163,22 @@ public class BoilerData {
return true;
int boilerLevel = Math.min(activeHeat, Math.min(maxHeatForWater, maxHeatForSize));
double totalSU = getEngineEfficiency(boilerSize) * 16 * Math.max(boilerLevel, attachedEngines)
* BlockStressValues.getCapacity(AllBlocks.STEAM_ENGINE.get());
Component capacity =
new TextComponent(IHaveGoggleInformation.format(totalSU)).append(Lang.translate("generic.unit.stress"))
.withStyle(ChatFormatting.AQUA);
Component engines = (attachedEngines == 1 ? Lang.translate("boiler.via_one_engine")
: Lang.translate("boiler.via_engines", attachedEngines)).withStyle(ChatFormatting.DARK_GRAY);
tooltip.add(indent);
tooltip.add(indent.plainCopy()
.append(Lang.translate("tooltip.capacityProvided")
.withStyle(ChatFormatting.GRAY)));
tooltip.add(indent2.plainCopy()
.append(capacity)
.append(engines));
tooltip.add(Lang.empty());
Lang.translate("tooltip.capacityProvided")
.style(ChatFormatting.GRAY)
.forGoggles(tooltip);
Lang.number(totalSU)
.translate("generic.unit.stress")
.style(ChatFormatting.AQUA)
.space()
.add((attachedEngines == 1 ? Lang.translate("boiler.via_one_engine")
: Lang.translate("boiler.via_engines", attachedEngines)).style(ChatFormatting.DARK_GRAY))
.forGoggles(tooltip, 1);
return true;
}
@ -194,10 +195,10 @@ public class BoilerData {
public MutableComponent getHeatLevelTextComponent() {
int boilerLevel = Math.min(activeHeat, Math.min(maxHeatForWater, maxHeatForSize));
return isPassive() ? Lang.translate("boiler.passive")
: (boilerLevel == 0 ? Lang.translate("boiler.idle")
: boilerLevel == 18 ? Lang.translate("boiler.max_lvl")
: Lang.translate("boiler.lvl", IHaveGoggleInformation.format(boilerLevel)));
return isPassive() ? Lang.translateDirect("boiler.passive")
: (boilerLevel == 0 ? Lang.translateDirect("boiler.idle")
: boilerLevel == 18 ? Lang.translateDirect("boiler.max_lvl")
: Lang.translateDirect("boiler.lvl", String.valueOf(boilerLevel)));
}
public MutableComponent getSizeComponent(boolean forGoggles, boolean useBlocksAsBars, ChatFormatting... styles) {
@ -222,9 +223,9 @@ public class BoilerData {
ChatFormatting style1 = styles.length >= 1 ? styles[0] : ChatFormatting.GRAY;
ChatFormatting style2 = styles.length >= 2 ? styles[1] : ChatFormatting.DARK_GRAY;
return Lang.translate("boiler." + label)
return Lang.translateDirect("boiler." + label)
.withStyle(style1)
.append(Lang.translate("boiler." + label + "_dots")
.append(Lang.translateDirect("boiler." + label + "_dots")
.withStyle(style2))
.append(base);
}
@ -306,7 +307,7 @@ public class BoilerData {
if (AllBlocks.STEAM_WHISTLE.has(attachedState)
&& WhistleBlock.getAttachedDirection(attachedState)
.getOpposite() == d) {
if (level.getBlockEntity(attachedPos) instanceof WhistleTileEntity wte)
if (level.getBlockEntity(attachedPos)instanceof WhistleTileEntity wte)
whistlePitches.add(wte.getPitchId());
}
}

View file

@ -27,27 +27,27 @@ public class GoggleConfigScreen extends AbstractSimiScreen {
Component componentSpacing = new TextComponent(" ");
tooltip = new ArrayList<>();
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.config.overlay1")));
.append(Lang.translateDirect("gui.config.overlay1")));
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.config.overlay2")
.append(Lang.translateDirect("gui.config.overlay2")
.withStyle(ChatFormatting.GRAY)));
tooltip.add(TextComponent.EMPTY);
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.config.overlay3")));
.append(Lang.translateDirect("gui.config.overlay3")));
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.config.overlay4")));
.append(Lang.translateDirect("gui.config.overlay4")));
tooltip.add(TextComponent.EMPTY);
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.config.overlay5")
.append(Lang.translateDirect("gui.config.overlay5")
.withStyle(ChatFormatting.GRAY)));
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.config.overlay6")
.append(Lang.translateDirect("gui.config.overlay6")
.withStyle(ChatFormatting.GRAY)));
tooltip.add(TextComponent.EMPTY);
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.config.overlay7")));
.append(Lang.translateDirect("gui.config.overlay7")));
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.config.overlay8")));
.append(Lang.translateDirect("gui.config.overlay8")));
}
@Override

View file

@ -143,7 +143,7 @@ public class GoggleOverlayRenderer {
tooltip.add(TextComponent.EMPTY);
tooltip.add(IHaveGoggleInformation.componentSpacing.plainCopy()
.append(Lang.translate("gui.goggles.pole_length"))
.append(Lang.translateDirect("gui.goggles.pole_length"))
.append(new TextComponent(" " + poles)));
}

View file

@ -1,17 +1,14 @@
package com.simibubi.create.content.contraptions.goggles;
import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.LangBuilder;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
@ -21,29 +18,30 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
* */
public interface IHaveGoggleInformation {
Format numberFormat = new Format();
/**
* Use Lang.[...].forGoggles(list)
*/
String spacing = " ";
/**
* Use Lang.[...].forGoggles(list)
*/
@Deprecated
Component componentSpacing = new TextComponent(spacing);
/**
* this method will be called when looking at a TileEntity that implemented this
* interface
*
* @return {@code true} if the tooltip creation was successful and should be displayed,
* or {@code false} if the overlay should not be displayed
* */
default boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking){
* @return {@code true} if the tooltip creation was successful and should be
* displayed, or {@code false} if the overlay should not be displayed
*/
default boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
return false;
}
static String format(double d) {
return numberFormat.get()
.format(d).replace("\u00A0", " ");
}
default boolean containedFluidTooltip(List<Component> tooltip, boolean isPlayerSneaking, LazyOptional<IFluidHandler> handler) {
tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.goggles.fluid_container")));
TranslatableComponent mb = Lang.translate("generic.unit.millibuckets");
default boolean containedFluidTooltip(List<Component> tooltip, boolean isPlayerSneaking,
LazyOptional<IFluidHandler> handler) {
Optional<IFluidHandler> resolve = handler.resolve();
if (!resolve.isPresent())
return false;
@ -52,7 +50,9 @@ public interface IHaveGoggleInformation {
if (tank.getTanks() == 0)
return false;
Component indent = new TextComponent(spacing + " ");
LangBuilder mb = Lang.translate("generic.unit.millibuckets");
Lang.translate("gui.goggles.fluid_container")
.forGoggles(tooltip);
boolean isEmpty = true;
for (int i = 0; i < tank.getTanks(); i++) {
@ -60,17 +60,19 @@ public interface IHaveGoggleInformation {
if (fluidStack.isEmpty())
continue;
Component fluidName = new TranslatableComponent(fluidStack.getTranslationKey()).withStyle(ChatFormatting.GRAY);
Component contained = new TextComponent(format(fluidStack.getAmount())).append(mb).withStyle(ChatFormatting.GOLD);
Component slash = new TextComponent(" / ").withStyle(ChatFormatting.GRAY);
Component capacity = new TextComponent(format(tank.getTankCapacity(i))).append(mb).withStyle(ChatFormatting.DARK_GRAY);
Lang.fluidName(fluidStack)
.style(ChatFormatting.GRAY)
.forGoggles(tooltip, 1);
tooltip.add(indent.plainCopy()
.append(fluidName));
tooltip.add(indent.plainCopy()
.append(contained)
.append(slash)
.append(capacity));
Lang.builder()
.add(Lang.number(fluidStack.getAmount())
.add(mb)
.style(ChatFormatting.GOLD))
.text(ChatFormatting.GRAY, " / ")
.add(Lang.number(tank.getTankCapacity(i))
.add(mb)
.style(ChatFormatting.DARK_GRAY))
.forGoggles(tooltip, 1);
isEmpty = false;
}
@ -84,35 +86,14 @@ public interface IHaveGoggleInformation {
if (!isEmpty)
return true;
Component capacity = Lang.translate("gui.goggles.fluid_container.capacity").withStyle(ChatFormatting.GRAY);
Component amount = new TextComponent(format(tank.getTankCapacity(0))).append(mb).withStyle(ChatFormatting.GOLD);
Lang.translate("gui.goggles.fluid_container.capacity")
.add(Lang.number(tank.getTankCapacity(0))
.add(mb)
.style(ChatFormatting.GOLD))
.style(ChatFormatting.GRAY)
.forGoggles(tooltip, 1);
tooltip.add(indent.plainCopy()
.append(capacity)
.append(amount));
return true;
}
class Format {
private NumberFormat format = NumberFormat.getNumberInstance(Locale.ROOT);
private Format() {}
public NumberFormat get() {
return format;
}
public void update() {
format = NumberFormat.getInstance(Minecraft.getInstance()
.getLanguageManager()
.getSelected()
.getJavaLocale());
format.setMaximumFractionDigits(2);
format.setMinimumFractionDigits(0);
format.setGroupingUsed(true);
}
}
}

View file

@ -240,9 +240,9 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
int step = sequencedAssemblyRecipe.getStep(stack);
int total = length * sequencedAssemblyRecipe.loops;
toolTip.add(new TextComponent(""));
toolTip.add(Lang.translate("recipe.sequenced_assembly")
toolTip.add(Lang.translateDirect("recipe.sequenced_assembly")
.withStyle(ChatFormatting.GRAY));
toolTip.add(Lang.translate("recipe.assembly.progress", step, total)
toolTip.add(Lang.translateDirect("recipe.assembly.progress", step, total)
.withStyle(ChatFormatting.DARK_GRAY));
int remaining = total - step;
@ -253,7 +253,7 @@ public class SequencedAssemblyRecipe implements Recipe<RecipeWrapper> {
Component textComponent = sequencedRecipe.getAsAssemblyRecipe()
.getDescriptionForAssembly();
if (i == 0)
toolTip.add(Lang.translate("recipe.assembly.next", textComponent)
toolTip.add(Lang.translateDirect("recipe.assembly.next", textComponent)
.withStyle(ChatFormatting.AQUA));
else
toolTip.add(new TextComponent("-> ").append(textComponent)

View file

@ -59,18 +59,18 @@ public class BlazeBurnerInteractionBehaviour extends MovingInteractionBehaviour
if (train.runtime.paused && !train.runtime.completed) {
train.runtime.paused = false;
AllSoundEvents.CONFIRM.playOnServer(player.level, player.blockPosition(), 1, 1);
player.displayClientMessage(Lang.translate("schedule.continued"), true);
player.displayClientMessage(Lang.translateDirect("schedule.continued"), true);
return true;
}
if (!itemInHand.isEmpty()) {
AllSoundEvents.DENY.playOnServer(player.level, player.blockPosition(), 1, 1);
player.displayClientMessage(Lang.translate("schedule.remove_with_empty_hand"), true);
player.displayClientMessage(Lang.translateDirect("schedule.remove_with_empty_hand"), true);
return true;
}
AllSoundEvents.playItemPickup(player);
player.displayClientMessage(Lang.translate(
player.displayClientMessage(Lang.translateDirect(
train.runtime.isAutoSchedule ? "schedule.auto_removed_from_train" : "schedule.removed_from_train"),
true);
player.setItemInHand(activeHand, train.runtime.returnSchedule());
@ -86,21 +86,21 @@ public class BlazeBurnerInteractionBehaviour extends MovingInteractionBehaviour
if (schedule.entries.isEmpty()) {
AllSoundEvents.DENY.playOnServer(player.level, player.blockPosition(), 1, 1);
player.displayClientMessage(Lang.translate("schedule.no_stops"), true);
player.displayClientMessage(Lang.translateDirect("schedule.no_stops"), true);
return true;
}
train.runtime.setSchedule(schedule, false);
AllAdvancements.CONDUCTOR.awardTo(player);
AllSoundEvents.CONFIRM.playOnServer(player.level, player.blockPosition(), 1, 1);
player.displayClientMessage(Lang.translate("schedule.applied_to_train")
player.displayClientMessage(Lang.translateDirect("schedule.applied_to_train")
.withStyle(ChatFormatting.GREEN), true);
itemInHand.shrink(1);
player.setItemInHand(activeHand, itemInHand.isEmpty() ? ItemStack.EMPTY : itemInHand);
return true;
}
player.displayClientMessage(Lang.translate("schedule.non_controlling_seat"), true);
player.displayClientMessage(Lang.translateDirect("schedule.non_controlling_seat"), true);
AllSoundEvents.DENY.playOnServer(player.level, player.blockPosition(), 1, 1);
return true;
}

View file

@ -45,11 +45,11 @@ public class SpeedControllerTileEntity extends KineticTileEntity {
Integer max = AllConfigs.SERVER.kinetics.maxRotationSpeed.get();
targetSpeed =
new ScrollValueBehaviour(Lang.translate("generic.speed"), this, new ControllerValueBoxTransform());
new ScrollValueBehaviour(Lang.translateDirect("generic.speed"), this, new ControllerValueBoxTransform());
targetSpeed.between(-max, max);
targetSpeed.value = DEFAULT_SPEED;
targetSpeed.moveText(new Vec3(9, 0, 10));
targetSpeed.withUnit(i -> Lang.translate("generic.unit.rpm"));
targetSpeed.withUnit(i -> Lang.translateDirect("generic.unit.rpm"));
targetSpeed.withCallback(i -> this.updateTargetRotation());
targetSpeed.withStepFunction(CreativeMotorTileEntity::step);
behaviours.add(targetSpeed);

View file

@ -32,7 +32,7 @@ public enum InstructionSpeedModifiers {
static List<Component> getOptions() {
List<Component> options = new ArrayList<>();
for (InstructionSpeedModifiers entry : values())
options.add(Lang.translate(entry.translationKey));
options.add(Lang.translateDirect(entry.translationKey));
return options;
}

View file

@ -33,7 +33,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
private Vector<Vector<ScrollInput>> inputs;
public SequencedGearshiftScreen(SequencedGearshiftTileEntity te) {
super(Lang.translate("gui.sequenced_gearshift.title"));
super(Lang.translateDirect("gui.sequenced_gearshift.title"));
this.instructions = te.instructions;
this.pos = te.getBlockPos();
compareTag = Instruction.serializeAll(instructions);
@ -78,13 +78,13 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
new SelectionScrollInput(x, y + rowHeight * row, 50, 18).forOptions(SequencerInstructions.getOptions())
.calling(state -> instructionUpdated(index, state))
.setState(instruction.instruction.ordinal())
.titled(Lang.translate("gui.sequenced_gearshift.instruction"));
.titled(Lang.translateDirect("gui.sequenced_gearshift.instruction"));
ScrollInput value =
new ScrollInput(x + 58, y + rowHeight * row, 28, 18).calling(state -> instruction.value = state);
ScrollInput direction = new SelectionScrollInput(x + 88, y + rowHeight * row, 28, 18)
.forOptions(InstructionSpeedModifiers.getOptions())
.calling(state -> instruction.speedModifier = InstructionSpeedModifiers.values()[state])
.titled(Lang.translate("gui.sequenced_gearshift.speed"));
.titled(Lang.translateDirect("gui.sequenced_gearshift.speed"));
rowInputs.add(type);
rowInputs.add(value);
@ -105,7 +105,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
value.active = value.visible = hasValue;
if (hasValue)
value.withRange(1, def.maxValue + 1)
.titled(Lang.translate(def.parameterKey))
.titled(Lang.translateDirect(def.parameterKey))
.withShiftStep(def.shiftStep)
.setState(instruction.value)
.onChanged();
@ -146,7 +146,7 @@ public class SequencedGearshiftScreen extends AbstractSimiScreen {
SequencerInstructions def = instruction.instruction;
def.background.render(ms, x, y + 14 + yOffset, this);
label(ms, 36, yOffset - 3, Lang.translate(def.translationKey));
label(ms, 36, yOffset - 3, Lang.translateDirect(def.translationKey));
if (def.hasValueParameter) {
String text = def.formatValue(instruction.value);
int stringWidth = font.width(text);

View file

@ -48,13 +48,13 @@ public enum SequencerInstructions {
static List<Component> getOptions() {
List<Component> options = new ArrayList<>();
for (SequencerInstructions entry : values())
options.add(Lang.translate(entry.descriptiveTranslationKey));
options.add(Lang.translateDirect(entry.descriptiveTranslationKey));
return options;
}
String formatValue(int value) {
if (this == TURN_ANGLE)
return value + Lang.translate("generic.unit.degrees").getString();
return value + Lang.translateDirect("generic.unit.degrees").getString();
if (this == TURN_DISTANCE)
return value + "m";
if (this == DELAY) {

View file

@ -470,7 +470,7 @@ public class BeltSlicer {
return;
if (feedback.langKey != null)
mc.player.displayClientMessage(Lang.translate(feedback.langKey)
mc.player.displayClientMessage(Lang.translateDirect(feedback.langKey)
.withStyle(feedback.formatting), true);
else
mc.player.displayClientMessage(new TextComponent(""), true);

View file

@ -48,7 +48,7 @@ public class GaugeTileEntity extends KineticTileEntity implements IHaveGoggleInf
@Override
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.gauge.info_header")));
tooltip.add(componentSpacing.plainCopy().append(Lang.translateDirect("gui.gauge.info_header")));
return true;
}

View file

@ -55,10 +55,11 @@ public class SpeedGaugeTileEntity extends GaugeTileEntity {
@Override
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
super.addToGoggleTooltip(tooltip, isPlayerSneaking);
tooltip.add(componentSpacing.plainCopy().append(Lang.translate("gui.speedometer.title").withStyle(ChatFormatting.GRAY)));
tooltip.add(componentSpacing.plainCopy().append(SpeedLevel.getFormattedSpeedText(speed, isOverStressed())));
Lang.translate("gui.speedometer.title")
.style(ChatFormatting.GRAY)
.forGoggles(tooltip);
SpeedLevel.getFormattedSpeedText(speed, isOverStressed())
.forGoggles(tooltip);
return true;
}
}

View file

@ -3,20 +3,18 @@ package com.simibubi.create.content.contraptions.relays.gauge;
import java.util.List;
import com.simibubi.create.content.contraptions.base.IRotate.StressImpact;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.item.ItemDescription;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Color;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.LangBuilder;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
@ -83,35 +81,37 @@ public class StressGaugeTileEntity extends GaugeTileEntity {
double capacity = getNetworkCapacity();
double stressFraction = getNetworkStress() / (capacity == 0 ? 1 : capacity);
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.stressometer.title")
.withStyle(ChatFormatting.GRAY)));
Lang.translate("gui.stressometer.title")
.style(ChatFormatting.GRAY)
.forGoggles(tooltip);
if (getTheoreticalSpeed() == 0)
tooltip.add(new TextComponent(spacing + ItemDescription.makeProgressBar(3, 0))
.append(Lang.translate("gui.stressometer.no_rotation"))
.withStyle(ChatFormatting.DARK_GRAY));
Lang.text(ItemDescription.makeProgressBar(3, 0))
.translate("gui.stressometer.no_rotation")
.style(ChatFormatting.DARK_GRAY)
.forGoggles(tooltip);
else {
tooltip.add(componentSpacing.plainCopy()
.append(StressImpact.getFormattedStressText(stressFraction)));
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("gui.stressometer.capacity")
.withStyle(ChatFormatting.GRAY)));
StressImpact.getFormattedStressText(stressFraction)
.forGoggles(tooltip);
Lang.translate("gui.stressometer.capacity")
.style(ChatFormatting.GRAY)
.forGoggles(tooltip);
double remainingCapacity = capacity - getNetworkStress();
Component su = Lang.translate("generic.unit.stress");
MutableComponent stressTooltip = componentSpacing.plainCopy()
.append(new TextComponent(" " + IHaveGoggleInformation.format(remainingCapacity)).append(su.plainCopy())
.withStyle(StressImpact.of(stressFraction)
.getRelativeColor()));
if (remainingCapacity != capacity) {
stressTooltip.append(new TextComponent(" / ").withStyle(ChatFormatting.GRAY))
.append(new TextComponent(IHaveGoggleInformation.format(capacity)).append(su.plainCopy())
.withStyle(ChatFormatting.DARK_GRAY));
}
tooltip.add(stressTooltip);
LangBuilder su = Lang.translate("generic.unit.stress");
LangBuilder stressTip = Lang.number(remainingCapacity)
.add(su)
.style(StressImpact.of(stressFraction)
.getRelativeColor());
if (remainingCapacity != capacity)
stressTip.text(ChatFormatting.GRAY, " / ")
.add(Lang.number(capacity)
.add(su)
.style(ChatFormatting.DARK_GRAY));
stressTip.forGoggles(tooltip, 1);
}
if (!worldPosition.equals(lastSent))

View file

@ -63,7 +63,7 @@ public class BackTankUtil {
return;
boolean depleted = threshold == 1;
MutableComponent component = Lang.translate(depleted ? "backtank.depleted" : "backtank.low");
MutableComponent component = Lang.translateDirect(depleted ? "backtank.depleted" : "backtank.low");
AllSoundEvents.DENY.play(player.level, null, player.blockPosition(), 1, 1.25f);
AllSoundEvents.STEAM.play(player.level, null, player.blockPosition(), .5f, .5f);

View file

@ -34,8 +34,8 @@ public class SymmetryWandScreen extends AbstractSimiScreen {
private Label labelAlign;
private IconButton confirmButton;
private final Component mirrorType = Lang.translate("gui.symmetryWand.mirrorType");
private final Component orientation = Lang.translate("gui.symmetryWand.orientation");
private final Component mirrorType = Lang.translateDirect("gui.symmetryWand.mirrorType");
private final Component orientation = Lang.translateDirect("gui.symmetryWand.orientation");
private SymmetryMirror currentElement;
private ItemStack wand;

View file

@ -105,7 +105,7 @@ public class CrossPlaneMirror extends SymmetryMirror {
@Override
public List<Component> getAlignToolTips() {
return ImmutableList.of(Lang.translate("orientation.orthogonal"), Lang.translate("orientation.diagonal"));
return ImmutableList.of(Lang.translateDirect("orientation.orthogonal"), Lang.translateDirect("orientation.diagonal"));
}
}

View file

@ -101,7 +101,7 @@ public class PlaneMirror extends SymmetryMirror {
@Override
public List<Component> getAlignToolTips() {
return ImmutableList.of(Lang.translate("orientation.alongZ"), Lang.translate("orientation.alongX"));
return ImmutableList.of(Lang.translateDirect("orientation.alongZ"), Lang.translateDirect("orientation.alongX"));
}
}

View file

@ -45,8 +45,8 @@ public abstract class SymmetryMirror {
}
public static List<Component> getMirrors() {
return ImmutableList.of(Lang.translate("symmetry.mirror.plane"), Lang.translate("symmetry.mirror.doublePlane"),
Lang.translate("symmetry.mirror.triplePlane"));
return ImmutableList.of(Lang.translateDirect("symmetry.mirror.plane"), Lang.translateDirect("symmetry.mirror.doublePlane"),
Lang.translateDirect("symmetry.mirror.triplePlane"));
}
public StringRepresentable getOrientation() {

View file

@ -66,7 +66,7 @@ public class TriplePlaneMirror extends SymmetryMirror {
@Override
public List<Component> getAlignToolTips() {
return ImmutableList.of(Lang.translate("orientation.horizontal"));
return ImmutableList.of(Lang.translateDirect("orientation.horizontal"));
}
}

View file

@ -81,7 +81,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen {
if (state == State.DETACH) {
tip = Lang.translate("toolbox.outOfRange");
tip = Lang.translateDirect("toolbox.outOfRange");
if (hoveredX > -20 && hoveredX < 20 && hoveredY > -80 && hoveredY < -20)
hoveredSlot = UNEQUIP;
@ -99,7 +99,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen {
ms.translate(0.5, -0.5, 0);
if (!scrollMode && hoveredSlot == UNEQUIP) {
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.render(ms, -13, -13, this);
tip = Lang.translate("toolbox.detach")
tip = Lang.translateDirect("toolbox.detach")
.withStyle(ChatFormatting.GOLD);
}
ms.popPose();
@ -117,7 +117,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen {
ms.translate(0.5, -0.5, 0);
if (!scrollMode && hoveredSlot == DEPOSIT) {
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.render(ms, -13, -13, this);
tip = Lang.translate(state == State.SELECT_BOX ? "toolbox.depositAll" : "toolbox.depositBox")
tip = Lang.translateDirect(state == State.SELECT_BOX ? "toolbox.depositAll" : "toolbox.depositBox")
.withStyle(ChatFormatting.GOLD);
}
ms.popPose();
@ -179,7 +179,7 @@ public class RadialToolboxMenu extends AbstractSimiScreen {
(scrollMode ? AllIcons.I_REFRESH : AllIcons.I_FLIP).render(ms, -9, -9, this);
if (!scrollMode && UNEQUIP == hoveredSlot) {
AllGuiTextures.TOOLBELT_SLOT_HIGHLIGHT.render(ms, -13, -13, this);
tip = Lang.translate("toolbox.unequip", minecraft.player.getMainHandItem()
tip = Lang.translateDirect("toolbox.unequip", minecraft.player.getMainHandItem()
.getHoverName())
.withStyle(ChatFormatting.GOLD);
}

View file

@ -60,7 +60,7 @@ public class ToolboxScreen extends AbstractSimiContainerScreen<ToolboxContainer>
disposeButton.withCallback(() -> {
AllPackets.channel.sendToServer(new ToolboxDisposeAllPacket(menu.contentHolder.getBlockPos()));
});
disposeButton.setToolTip(Lang.translate("toolbox.depositBox"));
disposeButton.setToolTip(Lang.translateDirect("toolbox.depositBox"));
addRenderableWidget(disposeButton);
extraAreas = ImmutableList.of(

View file

@ -61,9 +61,7 @@ public class BlueprintScreen extends AbstractSimiContainerScreen<BlueprintContai
addRenderableWidget(resetButton);
addRenderableWidget(confirmButton);
extraAreas = ImmutableList.of(
new Rect2i(x + background.width, y + background.height - 36, 56, 44)
);
extraAreas = ImmutableList.of(new Rect2i(x + background.width, y + background.height - 36, 56, 44));
}
@Override
@ -78,8 +76,8 @@ public class BlueprintScreen extends AbstractSimiContainerScreen<BlueprintContai
background.render(ms, x, y, this);
font.draw(ms, title, x + 15, y + 4, 0xFFFFFF);
GuiGameElement.of(AllBlockPartials.CRAFTING_BLUEPRINT_1x1)
.<GuiGameElement.GuiRenderBuilder>at(x + background.width + 20, y + background.height - 32, 0)
GuiGameElement.of(AllBlockPartials.CRAFTING_BLUEPRINT_1x1).<GuiGameElement
.GuiRenderBuilder>at(x + background.width + 20, y + background.height - 32, 0)
.rotate(45, -45, 22.5f)
.scale(40)
.render(ms);
@ -93,8 +91,7 @@ public class BlueprintScreen extends AbstractSimiContainerScreen<BlueprintContai
super.renderTooltip(ms, x, y);
return;
}
renderComponentTooltip(ms, addToTooltip(new LinkedList<>(), hoveredSlot.getSlotIndex(), true), x, y,
font);
renderComponentTooltip(ms, addToTooltip(new LinkedList<>(), hoveredSlot.getSlotIndex(), true), x, y, font);
}
@Override
@ -110,26 +107,26 @@ public class BlueprintScreen extends AbstractSimiContainerScreen<BlueprintContai
return list;
if (slot < 9) {
list.add(Lang.createTranslationTextComponent("crafting_blueprint.crafting_slot")
list.add(Lang.translateDirect("crafting_blueprint.crafting_slot")
.withStyle(ChatFormatting.GOLD));
if (isEmptySlot)
list.add(Lang.createTranslationTextComponent("crafting_blueprint.filter_items_viable")
list.add(Lang.translateDirect("crafting_blueprint.filter_items_viable")
.withStyle(ChatFormatting.GRAY));
} else if (slot == 9) {
list.add(Lang.createTranslationTextComponent("crafting_blueprint.display_slot")
list.add(Lang.translateDirect("crafting_blueprint.display_slot")
.withStyle(ChatFormatting.GOLD));
if (!isEmptySlot)
list.add(Lang
.createTranslationTextComponent("crafting_blueprint."
+ (menu.contentHolder.inferredIcon ? "inferred" : "manually_assigned"))
.translateDirect(
"crafting_blueprint." + (menu.contentHolder.inferredIcon ? "inferred" : "manually_assigned"))
.withStyle(ChatFormatting.GRAY));
} else if (slot == 10) {
list.add(Lang.createTranslationTextComponent("crafting_blueprint.secondary_display_slot")
list.add(Lang.translateDirect("crafting_blueprint.secondary_display_slot")
.withStyle(ChatFormatting.GOLD));
if (isEmptySlot)
list.add(Lang.createTranslationTextComponent("crafting_blueprint.optional")
list.add(Lang.translateDirect("crafting_blueprint.optional")
.withStyle(ChatFormatting.GRAY));
}

View file

@ -242,13 +242,13 @@ public class PotatoCannonItem extends ProjectileWeaponItem {
reloadTicks = reloadTicks.withStyle(darkGreen);
tooltip.add(spacing.plainCopy()
.append(Lang.translate(_attack, damage)
.append(Lang.translateDirect(_attack, damage)
.withStyle(darkGreen)));
tooltip.add(spacing.plainCopy()
.append(Lang.translate(_reload, reloadTicks)
.append(Lang.translateDirect(_reload, reloadTicks)
.withStyle(darkGreen)));
tooltip.add(spacing.plainCopy()
.append(Lang.translate(_knockback, knockback)
.append(Lang.translateDirect(_knockback, knockback)
.withStyle(darkGreen)));
});
super.appendHoverText(stack, world, tooltip, flag);

View file

@ -59,7 +59,7 @@ public abstract class ZapperItem extends Item {
.getBlock()
.getDescriptionId();
ItemDescription.add(tooltip,
Lang.translate("terrainzapper.usingBlock",
Lang.translateDirect("terrainzapper.usingBlock",
new TranslatableComponent(usedblock).withStyle(ChatFormatting.GRAY))
.withStyle(ChatFormatting.DARK_GRAY));
}
@ -147,8 +147,8 @@ public abstract class ZapperItem extends Item {
.add(0, player.getEyeHeight(), 0);
Vec3 range = player.getLookAngle()
.scale(getZappingRange(item));
BlockHitResult raytrace = world
.clip(new ClipContext(start, start.add(range), Block.OUTLINE, Fluid.NONE, player));
BlockHitResult raytrace =
world.clip(new ClipContext(start, start.add(range), Block.OUTLINE, Fluid.NONE, player));
BlockPos pos = raytrace.getBlockPos();
BlockState stateReplaced = world.getBlockState(pos);
@ -180,7 +180,7 @@ public abstract class ZapperItem extends Item {
public Component validateUsage(ItemStack item) {
CompoundTag tag = item.getOrCreateTag();
if (!canActivateWithoutSelectedBlock(item) && !tag.contains("BlockUsed"))
return Lang.createTranslationTextComponent("terrainzapper.leftClickToSet");
return Lang.translateDirect("terrainzapper.leftClickToSet");
return null;
}

View file

@ -24,7 +24,7 @@ import net.minecraft.world.level.block.state.BlockState;
public abstract class ZapperScreen extends AbstractSimiScreen {
protected final Component patternSection = Lang.translate("gui.terrainzapper.patternSection");
protected final Component patternSection = Lang.translateDirect("gui.terrainzapper.patternSection");
protected AllGuiTextures background;
protected ItemStack zapper;
@ -81,7 +81,7 @@ public abstract class ZapperScreen extends AbstractSimiScreen {
patternButton.active = false;
currentPattern = pattern;
});
patternButton.setToolTip(Lang.translate("gui.terrainzapper.pattern." + pattern.translationKey));
patternButton.setToolTip(Lang.translateDirect("gui.terrainzapper.pattern." + pattern.translationKey));
patternButtons.add(patternButton);
}
}

View file

@ -53,7 +53,7 @@ public abstract class Brush {
Component getParamLabel(int paramIndex) {
return Lang
.translate(paramIndex == 0 ? "generic.width" : paramIndex == 1 ? "generic.height" : "generic.length");
.translateDirect(paramIndex == 0 ? "generic.width" : paramIndex == 1 ? "generic.height" : "generic.length");
}
public int get(int paramIndex) {

View file

@ -74,7 +74,7 @@ public class CylinderBrush extends ShapedBrush {
@Override
Component getParamLabel(int paramIndex) {
return paramIndex == 0 ? Lang.translate("generic.radius") : super.getParamLabel(paramIndex);
return paramIndex == 0 ? Lang.translateDirect("generic.radius") : super.getParamLabel(paramIndex);
}
@Override

View file

@ -27,7 +27,7 @@ public class DynamicBrush extends Brush {
}
Component getParamLabel(int paramIndex) {
return Lang.translate("generic.range");
return Lang.translateDirect("generic.range");
}
@Override

View file

@ -51,7 +51,7 @@ public class SphereBrush extends ShapedBrush {
@Override
Component getParamLabel(int paramIndex) {
return Lang.translate("generic.radius");
return Lang.translateDirect("generic.radius");
}
@Override

View file

@ -51,7 +51,7 @@ public class WorldshaperItem extends ZapperItem {
public Component validateUsage(ItemStack item) {
if (!item.getOrCreateTag()
.contains("BrushParams"))
return Lang.createTranslationTextComponent("terrainzapper.shiftRightClickToSet");
return Lang.translateDirect("terrainzapper.shiftRightClickToSet");
return super.validateUsage(item);
}
@ -86,7 +86,8 @@ public class WorldshaperItem extends ZapperItem {
return true;
}
public static void configureSettings(ItemStack stack, PlacementPatterns pattern, TerrainBrushes brush, int brushParamX, int brushParamY, int brushParamZ, TerrainTools tool, PlacementOptions placement) {
public static void configureSettings(ItemStack stack, PlacementPatterns pattern, TerrainBrushes brush,
int brushParamX, int brushParamY, int brushParamZ, TerrainTools tool, PlacementOptions placement) {
ZapperItem.configureSettings(stack, pattern);
CompoundTag nbt = stack.getOrCreateTag();
NBTHelper.writeEnum(nbt, "Brush", brush);

View file

@ -28,8 +28,8 @@ import net.minecraft.world.item.ItemStack;
public class WorldshaperScreen extends ZapperScreen {
protected final Component placementSection = Lang.translate("gui.terrainzapper.placement");
protected final Component toolSection = Lang.translate("gui.terrainzapper.tool");
protected final Component placementSection = Lang.translateDirect("gui.terrainzapper.placement");
protected final Component toolSection = Lang.translateDirect("gui.terrainzapper.tool");
protected final List<Component> brushOptions =
Lang.translatedOptions("gui.terrainzapper.brush", "cuboid", "sphere", "cylinder", "surface", "cluster");
@ -84,7 +84,7 @@ public class WorldshaperScreen extends ZapperScreen {
brushLabel = new Label(x + 61, y + 25, TextComponent.EMPTY).withShadow();
brushInput = new SelectionScrollInput(x + 56, y + 20, 77, 18).forOptions(brushOptions)
.titled(Lang.translate("gui.terrainzapper.brush"))
.titled(Lang.translateDirect("gui.terrainzapper.brush"))
.writingTo(brushLabel)
.calling(brushIndex -> {
currentBrush = TerrainBrushes.values()[brushIndex];
@ -165,12 +165,12 @@ public class WorldshaperScreen extends ZapperScreen {
followDiagonalsIndicator.state = followDiagonalsIndicator.state == State.OFF ? State.ON : State.OFF;
currentFollowDiagonals = !currentFollowDiagonals;
});
followDiagonals.setToolTip(Lang.translate("gui.terrainzapper.searchDiagonal"));
followDiagonals.setToolTip(Lang.translateDirect("gui.terrainzapper.searchDiagonal"));
acrossMaterials.withCallback(() -> {
acrossMaterialsIndicator.state = acrossMaterialsIndicator.state == State.OFF ? State.ON : State.OFF;
currentAcrossMaterials = !currentAcrossMaterials;
});
acrossMaterials.setToolTip(Lang.translate("gui.terrainzapper.searchFuzzy"));
acrossMaterials.setToolTip(Lang.translateDirect("gui.terrainzapper.searchFuzzy"));
addRenderableWidget(followDiagonals);
addRenderableWidget(followDiagonalsIndicator);
addRenderableWidget(acrossMaterials);
@ -196,7 +196,7 @@ public class WorldshaperScreen extends ZapperScreen {
toolButton.active = false;
currentTool = tool;
});
toolButton.setToolTip(Lang.translate("gui.terrainzapper.tool." + tool.translationKey));
toolButton.setToolTip(Lang.translateDirect("gui.terrainzapper.tool." + tool.translationKey));
toolButtons.add(toolButton);
}
@ -228,7 +228,7 @@ public class WorldshaperScreen extends ZapperScreen {
placementButton.active = false;
currentPlacement = option;
});
placementButton.setToolTip(Lang.translate("gui.terrainzapper.placement." + option.translationKey));
placementButton.setToolTip(Lang.translateDirect("gui.terrainzapper.placement." + option.translationKey));
placementButtons.add(placementButton);
}

View file

@ -91,7 +91,7 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
super.addBehaviours(behaviours);
behaviours.add(selectionMode = new ScrollOptionBehaviour<>(SelectionMode.class,
Lang.translate("logistics.when_multiple_outputs_available"), this,
Lang.translateDirect("logistics.when_multiple_outputs_available"), this,
new CenteredSideValueBoxTransform((state, d) -> d == Direction.UP)));
selectionMode.requiresWrench();
@ -748,16 +748,16 @@ public class BrassTunnelTileEntity extends BeltTunnelTileEntity implements IHave
return false;
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.brass_tunnel.contains"))
.append(Lang.translateDirect("tooltip.brass_tunnel.contains"))
.withStyle(ChatFormatting.WHITE));
for (ItemStack item : allStacks) {
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.brass_tunnel.contains_entry", new TranslatableComponent(item.getItem()
.append(Lang.translateDirect("tooltip.brass_tunnel.contains_entry", new TranslatableComponent(item.getItem()
.getDescriptionId(item)).getString(), item.getCount()))
.withStyle(ChatFormatting.GRAY));
}
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.brass_tunnel.retrieve"))
.append(Lang.translateDirect("tooltip.brass_tunnel.retrieve"))
.withStyle(ChatFormatting.DARK_GRAY));
return true;

View file

@ -700,26 +700,26 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
boolean downward = getItemMotion() < 0;
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.chute.header")));
.append(Lang.translateDirect("tooltip.chute.header")));
if (pull == 0 && push == 0)
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.chute.no_fans_attached"))
.append(Lang.translateDirect("tooltip.chute.no_fans_attached"))
.withStyle(ChatFormatting.GRAY));
if (pull != 0)
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.chute.fans_" + (pull > 0 ? "pull_up" : "push_down"))
.append(Lang.translateDirect("tooltip.chute.fans_" + (pull > 0 ? "pull_up" : "push_down"))
.withStyle(ChatFormatting.GRAY)));
if (push != 0)
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.chute.fans_" + (push > 0 ? "push_up" : "pull_down"))
.append(Lang.translateDirect("tooltip.chute.fans_" + (push > 0 ? "push_up" : "pull_down"))
.withStyle(ChatFormatting.GRAY)));
tooltip.add(componentSpacing.plainCopy()
.append("-> ")
.append(Lang.translate("tooltip.chute.items_move_" + (downward ? "down" : "up"))
.append(Lang.translateDirect("tooltip.chute.items_move_" + (downward ? "down" : "up"))
.withStyle(ChatFormatting.YELLOW)));
if (!item.isEmpty()) {
tooltip.add(componentSpacing.plainCopy()
.append(Lang.translate("tooltip.chute.contains", new TranslatableComponent(item.getItem()
.append(Lang.translateDirect("tooltip.chute.contains", new TranslatableComponent(item.getItem()
.getDescriptionId(item)).getString(), item.getCount()))
.withStyle(ChatFormatting.GREEN));
}

View file

@ -59,7 +59,7 @@ public class EjectorTargetHandler {
String key = "weighted_ejector.target_set";
ChatFormatting colour = ChatFormatting.GOLD;
player.displayClientMessage(Lang.translate(key)
player.displayClientMessage(Lang.translateDirect(key)
.withStyle(colour), true);
currentSelection = pos;
launcher = null;
@ -101,7 +101,7 @@ public class EjectorTargetHandler {
Direction validTargetDirection = getValidTargetDirection(pos);
if (validTargetDirection == null) {
player.displayClientMessage(Lang.translate(key)
player.displayClientMessage(Lang.translateDirect(key)
.withStyle(colour), true);
currentItem = null;
currentSelection = null;
@ -112,7 +112,7 @@ public class EjectorTargetHandler {
colour = ChatFormatting.GREEN;
player.displayClientMessage(
Lang.translate(key, currentSelection.getX(), currentSelection.getY(), currentSelection.getZ())
Lang.translateDirect(key, currentSelection.getX(), currentSelection.getY(), currentSelection.getZ())
.withStyle(colour),
true);

View file

@ -102,7 +102,7 @@ public class EjectorTileEntity extends KineticTileEntity {
super.addBehaviours(behaviours);
behaviours.add(depotBehaviour = new DepotBehaviour(this));
maxStackSize = new ScrollValueBehaviour(Lang.translate("weighted_ejector.stack_size"), this, new EjectorSlot())
maxStackSize = new ScrollValueBehaviour(Lang.translateDirect("weighted_ejector.stack_size"), this, new EjectorSlot())
.between(0, 64)
.withFormatter(i -> i == 0 ? "*" : String.valueOf(i))
.onlyActiveWhen(() -> state == State.CHARGED)

View file

@ -29,7 +29,7 @@ public abstract class BrassDiodeTileEntity extends SmartTileEntity {
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
maxState = new ScrollValueBehaviour(Lang.translate("generic.delay"), this, new BrassDiodeScrollSlot())
maxState = new ScrollValueBehaviour(Lang.translateDirect("generic.delay"), this, new BrassDiodeScrollSlot())
.between(2, 60 * 20 * 30);
maxState.withStepFunction(this::step);
maxState.withFormatter(this::format);
@ -98,10 +98,10 @@ public abstract class BrassDiodeTileEntity extends SmartTileEntity {
private Component getUnit(int value) {
if (value < 20)
return Lang.translate("generic.unit.ticks");
return Lang.translateDirect("generic.unit.ticks");
if (value < 20 * 60)
return Lang.translate("generic.unit.seconds");
return Lang.translate("generic.unit.minutes");
return Lang.translateDirect("generic.unit.seconds");
return Lang.translateDirect("generic.unit.minutes");
}
}

View file

@ -151,7 +151,7 @@ public class DisplayLinkBlock extends WrenchableDirectionalBlock implements ITE<
if (!(player instanceof LocalPlayer))
return;
if (te.targetOffset.equals(BlockPos.ZERO)) {
player.displayClientMessage(Lang.translate("display_link.invalid"), true);
player.displayClientMessage(Lang.translateDirect("display_link.invalid"), true);
return;
}
ScreenOpener.open(new DisplayLinkScreen(te));

View file

@ -60,7 +60,7 @@ public class DisplayLinkBlockItem extends BlockItem {
if (player.isSteppingCarefully() && stack.hasTag()) {
if (level.isClientSide)
return InteractionResult.SUCCESS;
player.displayClientMessage(Lang.translate("display_link.clear"), true);
player.displayClientMessage(Lang.translateDirect("display_link.clear"), true);
stack.setTag(null);
return InteractionResult.SUCCESS;
}
@ -70,7 +70,7 @@ public class DisplayLinkBlockItem extends BlockItem {
return InteractionResult.SUCCESS;
CompoundTag stackTag = stack.getOrCreateTag();
stackTag.put("SelectedPos", NbtUtils.writeBlockPos(pos));
player.displayClientMessage(Lang.translate("display_link.set"), true);
player.displayClientMessage(Lang.translateDirect("display_link.set"), true);
stack.setTag(stackTag);
return InteractionResult.SUCCESS;
}
@ -83,7 +83,7 @@ public class DisplayLinkBlockItem extends BlockItem {
.isReplaceable() ? 0 : 1);
if (!selectedPos.closerThan(placedPos, AllConfigs.SERVER.logistics.displayLinkRange.get())) {
player.displayClientMessage(Lang.translate("display_link.too_far")
player.displayClientMessage(Lang.translateDirect("display_link.too_far")
.withStyle(ChatFormatting.RED), true);
return InteractionResult.FAIL;
}
@ -98,7 +98,7 @@ public class DisplayLinkBlockItem extends BlockItem {
ItemStack itemInHand = player.getItemInHand(pContext.getHand());
if (!itemInHand.isEmpty())
itemInHand.setTag(null);
player.displayClientMessage(Lang.translate("display_link.success")
player.displayClientMessage(Lang.translateDirect("display_link.success")
.withStyle(ChatFormatting.GREEN), true);
return useOn;
}

View file

@ -140,7 +140,7 @@ public class DisplayLinkScreen extends AbstractSimiScreen {
if (rows > 1) {
targetLineSelector = new ScrollInput(x + 61, y + 105, 135, 16).withRange(0, rows)
.titled(Lang.translate("display_link.display_on"))
.titled(Lang.translateDirect("display_link.display_on"))
.inverted()
.calling(i -> targetLineLabel.text = target.getLineOptionText(i))
.setState(startIndex);
@ -157,11 +157,11 @@ public class DisplayLinkScreen extends AbstractSimiScreen {
});
sourceWidget.getToolTip().addAll(List.of(
Lang.translate("display_link.reading_from"),
Lang.translateDirect("display_link.reading_from"),
sourceState.getBlock().getName()
.withStyle(s -> s.withColor(sources.isEmpty() ? 0xF68989 : 0xF2C16D)),
Lang.translate("display_link.attached_side"),
Lang.translate("display_link.view_compatible")
Lang.translateDirect("display_link.attached_side"),
Lang.translateDirect("display_link.view_compatible")
.withStyle(ChatFormatting.GRAY)
));
@ -174,11 +174,11 @@ public class DisplayLinkScreen extends AbstractSimiScreen {
});
targetWidget.getToolTip().addAll(List.of(
Lang.translate("display_link.writing_to"),
Lang.translateDirect("display_link.writing_to"),
targetState.getBlock().getName()
.withStyle(s -> s.withColor(target == null ? 0xF68989 : 0xF2C16D)),
Lang.translate("display_link.targeted_location"),
Lang.translate("display_link.view_compatible")
Lang.translateDirect("display_link.targeted_location"),
Lang.translateDirect("display_link.view_compatible")
.withStyle(ChatFormatting.GRAY)
));
@ -197,7 +197,7 @@ public class DisplayLinkScreen extends AbstractSimiScreen {
.toList();
sourceTypeSelector = new SelectionScrollInput(x + 61, y + 26, 135, 16).forOptions(options)
.writingTo(sourceTypeLabel)
.titled(Lang.translate("display_link.information_type"))
.titled(Lang.translateDirect("display_link.information_type"))
.calling(this::initGathererSourceSubOptions)
.setState(startIndex);
sourceTypeSelector.onChanged();
@ -216,8 +216,8 @@ public class DisplayLinkScreen extends AbstractSimiScreen {
if (targetLineSelector != null)
targetLineSelector
.titled(source instanceof SingleLineDisplaySource ? Lang.translate("display_link.display_on")
: Lang.translate("display_link.display_on_multiline"));
.titled(source instanceof SingleLineDisplaySource ? Lang.translateDirect("display_link.display_on")
: Lang.translateDirect("display_link.display_on_multiline"));
configWidgets.forEach(s -> {
s.forEach(this::removeWidget);
@ -252,13 +252,13 @@ public class DisplayLinkScreen extends AbstractSimiScreen {
int y = guiTop;
background.render(ms, x, y, this);
MutableComponent header = Lang.translate("display_link.title");
MutableComponent header = Lang.translateDirect("display_link.title");
font.draw(ms, header, x + background.width / 2 - font.width(header) / 2, y + 4, 0x442000);
if (sources.isEmpty())
font.drawShadow(ms, Lang.translate("display_link.no_source"), x + 65, y + 30, 0xD3D3D3);
font.drawShadow(ms, Lang.translateDirect("display_link.no_source"), x + 65, y + 30, 0xD3D3D3);
if (target == null)
font.drawShadow(ms, Lang.translate("display_link.no_target"), x + 65, y + 109, 0xD3D3D3);
font.drawShadow(ms, Lang.translateDirect("display_link.no_target"), x + 65, y + 109, 0xD3D3D3);
ms.pushPose();
ms.translate(0, guiTop + 46, 0);

View file

@ -23,16 +23,16 @@ import net.minecraft.world.level.block.entity.LecternBlockEntity;
public class BoilerDisplaySource extends DisplaySource {
public static final List<MutableComponent> notEnoughSpaceSingle =
List.of(Lang.translate("display_source.boiler.not_enough_space")
.append(Lang.translate("display_source.boiler.for_boiler_status")));
List.of(Lang.translateDirect("display_source.boiler.not_enough_space")
.append(Lang.translateDirect("display_source.boiler.for_boiler_status")));
public static final List<MutableComponent> notEnoughSpaceDouble =
List.of(Lang.translate("display_source.boiler.not_enough_space"),
Lang.translate("display_source.boiler.for_boiler_status"));
List.of(Lang.translateDirect("display_source.boiler.not_enough_space"),
Lang.translateDirect("display_source.boiler.for_boiler_status"));
public static final List<List<MutableComponent>> notEnoughSpaceFlap =
List.of(List.of(Lang.translate("display_source.boiler.not_enough_space")),
List.of(Lang.translate("display_source.boiler.for_boiler_status")));
List.of(List.of(Lang.translateDirect("display_source.boiler.not_enough_space")),
List.of(Lang.translateDirect("display_source.boiler.for_boiler_status")));
@Override
public List<MutableComponent> provideText(DisplayLinkContext context, DisplayTargetStats stats) {
@ -133,7 +133,7 @@ public class BoilerDisplaySource extends DisplaySource {
heat = new TextComponent(Strings.repeat(' ', lw - labelWidthOf("heat"))).append(heat);
}
return Stream.of(List.of(Lang.translate(label, boiler.getHeatLevelTextComponent())),
return Stream.of(List.of(Lang.translateDirect(label, boiler.getHeatLevelTextComponent())),
List.of(size, boiler.getSizeComponent(!forFlapDisplay, forFlapDisplay, ChatFormatting.BLACK)),
List.of(water, boiler.getWaterComponent(!forFlapDisplay, forFlapDisplay, ChatFormatting.BLACK)),
List.of(heat, boiler.getHeatComponent(!forFlapDisplay, forFlapDisplay, ChatFormatting.BLACK)));
@ -151,7 +151,7 @@ public class BoilerDisplaySource extends DisplaySource {
private MutableComponent labelOf(String label) {
if (label.isBlank())
return TextComponent.EMPTY.copy();
return Lang.translate("boiler." + label);
return Lang.translateDirect("boiler." + label);
}
@Override

View file

@ -26,7 +26,7 @@ public class DeathCounterDisplaySource extends StatTrackingDisplaySource {
@Override
protected Component getObjectiveDisplayName() {
return Lang.translate("display_source.scoreboard.objective.deaths");
return Lang.translateDirect("display_source.scoreboard.objective.deaths");
}
}

View file

@ -38,7 +38,7 @@ public class FillLevelDisplaySource extends PercentOrProgressBarDisplaySource {
return;
builder.addSelectionScrollInput(0, 120,
(si, l) -> si.forOptions(Lang.translatedOptions("display_source.fill_level", "percent", "progress_bar"))
.titled(Lang.translate("display_source.fill_level.display")),
.titled(Lang.translateDirect("display_source.fill_level.display")),
"Mode");
}

View file

@ -1,6 +1,5 @@
package com.simibubi.create.content.logistics.block.display.source;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.logistics.block.display.DisplayLinkBlock;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.block.display.DisplayLinkTileEntity;
@ -45,7 +44,8 @@ public class ItemThoughputDisplaySource extends AccumulatedItemCountDisplaySourc
}
}
return new TextComponent(IHaveGoggleInformation.format(rate));
return Lang.number(rate)
.component();
}
public void itemReceived(DisplayLinkTileEntity te, int amount) {
@ -101,14 +101,15 @@ public class ItemThoughputDisplaySource extends AccumulatedItemCountDisplaySourc
@Override
@OnlyIn(Dist.CLIENT)
public void initConfigurationWidgets(DisplayLinkContext context, ModularGuiLineBuilder builder, boolean isFirstLine) {
public void initConfigurationWidgets(DisplayLinkContext context, ModularGuiLineBuilder builder,
boolean isFirstLine) {
super.initConfigurationWidgets(context, builder, isFirstLine);
if (isFirstLine)
return;
builder.addSelectionScrollInput(0, 80, (si, l) -> {
si.forOptions(Lang.translatedOptions("display_source.item_throughput.interval", "second", "minute", "hour"))
.titled(Lang.translate("display_source.item_throughput.interval"));
.titled(Lang.translateDirect("display_source.item_throughput.interval"));
}, "Interval");
}

View file

@ -1,6 +1,5 @@
package com.simibubi.create.content.logistics.block.display.source;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.contraptions.relays.gauge.SpeedGaugeTileEntity;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.block.display.target.DisplayTargetStats;
@ -8,7 +7,6 @@ import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -16,13 +14,16 @@ public class KineticSpeedDisplaySource extends NumericSingleLineDisplaySource {
@Override
protected MutableComponent provideLine(DisplayLinkContext context, DisplayTargetStats stats) {
if (!(context.getSourceTE() instanceof SpeedGaugeTileEntity gaugeTile))
if (!(context.getSourceTE()instanceof SpeedGaugeTileEntity gaugeTile))
return ZERO;
boolean absoluteValue = context.sourceConfig().getInt("Directional") == 0;
boolean absoluteValue = context.sourceConfig()
.getInt("Directional") == 0;
float speed = absoluteValue ? Math.abs(gaugeTile.getSpeed()) : gaugeTile.getSpeed();
return new TextComponent(IHaveGoggleInformation.format(speed));
return Lang.number(speed)
.space()
.translate("generic.unit.rpm")
.component();
}
@Override
@ -32,13 +33,15 @@ public class KineticSpeedDisplaySource extends NumericSingleLineDisplaySource {
@Override
@OnlyIn(Dist.CLIENT)
public void initConfigurationWidgets(DisplayLinkContext context, ModularGuiLineBuilder builder, boolean isFirstLine) {
public void initConfigurationWidgets(DisplayLinkContext context, ModularGuiLineBuilder builder,
boolean isFirstLine) {
super.initConfigurationWidgets(context, builder, isFirstLine);
if (isFirstLine)
return;
builder.addSelectionScrollInput(0, 95, (selectionScrollInput, label) -> {
selectionScrollInput.forOptions(Lang.translatedOptions("display_source.kinetic_speed", "absolute", "directional"));
selectionScrollInput
.forOptions(Lang.translatedOptions("display_source.kinetic_speed", "absolute", "directional"));
}, "Directional");
}

View file

@ -1,14 +1,13 @@
package com.simibubi.create.content.logistics.block.display.source;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.contraptions.relays.gauge.StressGaugeTileEntity;
import com.simibubi.create.content.logistics.block.display.DisplayLinkContext;
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayTileEntity;
import com.simibubi.create.foundation.gui.ModularGuiLineBuilder;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.LangBuilder;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -19,10 +18,11 @@ public class KineticStressDisplaySource extends PercentOrProgressBarDisplaySourc
int mode = getMode(context);
if (mode == 1)
return super.formatNumeric(context, currentLevel);
TextComponent textComponent = new TextComponent(IHaveGoggleInformation.format(currentLevel));
LangBuilder builder = Lang.number(currentLevel);
if (context.getTargetTE() instanceof FlapDisplayTileEntity)
textComponent.append(" ");
return textComponent.append(Lang.translate("generic.unit.stress"));
builder.space();
return builder.translate("generic.unit.stress")
.component();
}
private int getMode(DisplayLinkContext context) {
@ -32,7 +32,7 @@ public class KineticStressDisplaySource extends PercentOrProgressBarDisplaySourc
@Override
protected Float getProgress(DisplayLinkContext context) {
if (!(context.getSourceTE() instanceof StressGaugeTileEntity gaugeTile))
if (!(context.getSourceTE()instanceof StressGaugeTileEntity gaugeTile))
return null;
float capacity = gaugeTile.getNetworkCapacity();
@ -71,7 +71,7 @@ public class KineticStressDisplaySource extends PercentOrProgressBarDisplaySourc
(si, l) -> si
.forOptions(Lang.translatedOptions("display_source.kinetic_stress", "progress_bar", "percent",
"current", "max", "remaining"))
.titled(Lang.translate("display_source.kinetic_stress.display")),
.titled(Lang.translateDirect("display_source.kinetic_stress.display")),
"Mode");
}

View file

@ -53,7 +53,7 @@ public class RedstonePowerDisplaySource extends PercentOrProgressBarDisplaySourc
return;
builder.addSelectionScrollInput(0, 120,
(si, l) -> si.forOptions(Lang.translatedOptions("display_source.redstone_power", "number", "progress_bar"))
.titled(Lang.translate("display_source.redstone_power.display")),
.titled(Lang.translateDirect("display_source.redstone_power.display")),
"Mode");
}

View file

@ -47,7 +47,7 @@ public class ScoreboardDisplaySource extends ValueListDisplaySource {
private ImmutableList<IntAttached<MutableComponent>> notFound(String objective) {
return ImmutableList
.of(IntAttached.with(404, Lang.translate("display_source.scoreboard.objective_not_found", objective)));
.of(IntAttached.with(404, Lang.translateDirect("display_source.scoreboard.objective_not_found", objective)));
}
@Override
@ -60,9 +60,9 @@ public class ScoreboardDisplaySource extends ValueListDisplaySource {
if (isFirstLine)
builder.addTextInput(0, 137, (e, t) -> {
e.setValue("");
t.withTooltip(ImmutableList.of(Lang.translate("display_source.scoreboard.objective")
t.withTooltip(ImmutableList.of(Lang.translateDirect("display_source.scoreboard.objective")
.withStyle(s -> s.withColor(0x5391E1)),
Lang.translate("gui.schedule.lmb_edit")
Lang.translateDirect("gui.schedule.lmb_edit")
.withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.ITALIC)));
}, "Objective");
else

View file

@ -34,9 +34,9 @@ public abstract class SingleLineDisplaySource extends DisplaySource {
protected void addLabelingTextBox(ModularGuiLineBuilder builder) {
builder.addTextInput(0, 137, (e, t) -> {
e.setValue("");
t.withTooltip(ImmutableList.of(Lang.translate("display_source.label")
t.withTooltip(ImmutableList.of(Lang.translateDirect("display_source.label")
.withStyle(s -> s.withColor(0x5391E1)),
Lang.translate("gui.schedule.lmb_edit")
Lang.translateDirect("gui.schedule.lmb_edit")
.withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.ITALIC)));
}, "Label");
}

View file

@ -57,7 +57,7 @@ public class StationSummaryDisplaySource extends DisplaySource {
} else if (prediction.ticks < 200) {
lines.add(WHITESPACE);
lines.add(Lang.translate("display_source.station_summary.now"));
lines.add(Lang.translateDirect("display_source.station_summary.now"));
} else {
int min = prediction.ticks / 1200;
@ -68,8 +68,8 @@ public class StationSummaryDisplaySource extends DisplaySource {
sec = 0;
}
lines.add(min > 0 ? new TextComponent(String.valueOf(min)) : WHITESPACE);
lines.add(min > 0 ? Lang.translate("display_source.station_summary.minutes")
: Lang.translate("display_source.station_summary.seconds", sec));
lines.add(min > 0 ? Lang.translateDirect("display_source.station_summary.minutes")
: Lang.translateDirect("display_source.station_summary.seconds", sec));
}
lines.add(prediction.train.name.copy());
@ -187,16 +187,16 @@ public class StationSummaryDisplaySource extends DisplaySource {
if (isFirstLine) {
builder.addTextInput(0, 137, (e, t) -> {
e.setValue("");
t.withTooltip(ImmutableList.of(Lang.translate("display_source.station_summary.filter")
t.withTooltip(ImmutableList.of(Lang.translateDirect("display_source.station_summary.filter")
.withStyle(s -> s.withColor(0x5391E1)),
Lang.translate("gui.schedule.lmb_edit")
Lang.translateDirect("gui.schedule.lmb_edit")
.withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.ITALIC)));
}, "Filter");
return;
}
builder.addScrollInput(0, 32, (si, l) -> {
si.titled(Lang.translate("display_source.station_summary.train_name_column"))
si.titled(Lang.translateDirect("display_source.station_summary.train_name_column"))
.withRange(0, 73)
.withShiftStep(12);
si.setState(50);
@ -204,7 +204,7 @@ public class StationSummaryDisplaySource extends DisplaySource {
}, "NameColumn");
builder.addScrollInput(36, 22, (si, l) -> {
si.titled(Lang.translate("display_source.station_summary.platform_column"))
si.titled(Lang.translateDirect("display_source.station_summary.platform_column"))
.withRange(0, 16)
.withShiftStep(4);
si.setState(3);

View file

@ -35,7 +35,7 @@ public class TimeOfDayDisplaySource extends SingleLineDisplaySource {
int dayTime = (int) (sLevel.getDayTime() % 24000);
int hours = (dayTime / 1000 + 6) % 24;
int minutes = (dayTime % 1000) * 60 / 1000;
MutableComponent suffix = Lang.translate("generic.daytime." + (hours > 11 ? "pm" : "am"));
MutableComponent suffix = Lang.translateDirect("generic.daytime." + (hours > 11 ? "pm" : "am"));
minutes = minutes / 5 * 5;
if (c12) {
@ -79,7 +79,7 @@ public class TimeOfDayDisplaySource extends SingleLineDisplaySource {
builder.addSelectionScrollInput(0, 60, (si, l) -> {
si.forOptions(Lang.translatedOptions("display_source.time", "12_hour", "24_hour"))
.titled(Lang.translate("display_source.time.format"));
.titled(Lang.translateDirect("display_source.time.format"));
}, "Cycle");
}

View file

@ -138,11 +138,11 @@ public abstract class ValueListDisplaySource extends DisplaySource {
private Couple<MutableComponent> shorten(int number) {
if (number >= 1000000)
return Couple.create(new TextComponent(String.valueOf(number / 1000000)),
Lang.translate("display_source.value_list.million")
Lang.translateDirect("display_source.value_list.million")
.append(WHITESPACE));
if (number >= 1000)
return Couple.create(new TextComponent(String.valueOf(number / 1000)),
Lang.translate("display_source.value_list.thousand")
Lang.translateDirect("display_source.value_list.thousand")
.append(WHITESPACE));
return Couple.create(new TextComponent(String.valueOf(number)), WHITESPACE);
}
@ -163,7 +163,7 @@ public abstract class ValueListDisplaySource extends DisplaySource {
protected void addFullNumberConfig(ModularGuiLineBuilder builder) {
builder.addSelectionScrollInput(0, 75,
(si, l) -> si.forOptions(Lang.translatedOptions("display_source.value_list", "shortened", "full_number"))
.titled(Lang.translate("display_source.value_list.display")),
.titled(Lang.translateDirect("display_source.value_list.display")),
"Format");
}

View file

@ -32,7 +32,7 @@ public abstract class DisplayTarget extends DisplayBehaviour {
}
public Component getLineOptionText(int line) {
return Lang.translate("display_target.line", line + 1);
return Lang.translateDirect("display_target.line", line + 1);
}
public static void reserve(int line, BlockEntity target, DisplayLinkContext context) {

View file

@ -65,7 +65,7 @@ public class LecternDisplayTarget extends DisplayTarget {
}
public Component getLineOptionText(int line) {
return Lang.translate("display_target.page", line + 1);
return Lang.translateDirect("display_target.page", line + 1);
}
private ItemStack signBook(ItemStack book) {

View file

@ -24,7 +24,7 @@ public abstract class SingleLineDisplayTarget extends DisplayTarget {
@Override
public Component getLineOptionText(int line) {
return Lang.translate("display_target.single_line");
return Lang.translateDirect("display_target.single_line");
}
protected abstract int getWidth(DisplayLinkContext context);

View file

@ -6,7 +6,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Str
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
@ -178,16 +177,14 @@ public class ArmInteractionPoint {
}
public enum Mode {
DEPOSIT("mechanical_arm.deposit_to", ChatFormatting.GOLD, 0xFFCB74),
TAKE("mechanical_arm.extract_from", ChatFormatting.AQUA, 0x4F8A8B);
DEPOSIT("mechanical_arm.deposit_to", 0xDDC166),
TAKE("mechanical_arm.extract_from", 0x7FCDE0);
private final String translationKey;
private final ChatFormatting chatColor;
private final int color;
Mode(String translationKey, ChatFormatting chatColor, int color) {
Mode(String translationKey, int color) {
this.translationKey = translationKey;
this.chatColor = chatColor;
this.color = color;
}
@ -195,10 +192,6 @@ public class ArmInteractionPoint {
return translationKey;
}
public ChatFormatting getChatColor() {
return chatColor;
}
public int getColor() {
return color;
}

View file

@ -16,7 +16,6 @@ import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
@ -64,11 +63,12 @@ public class ArmInteractionPointHandler {
selected.cycleMode();
if (player != null) {
String key = selected.getMode().getTranslationKey();
ChatFormatting colour = selected.getMode().getChatColor();
MutableComponent translatedBlock = state.getBlock().getName();
player.displayClientMessage((Lang.translate(key, translatedBlock.withStyle(ChatFormatting.WHITE, colour)).withStyle(colour)),
true);
Mode mode = selected.getMode();
Lang.builder()
.translate(mode.getTranslationKey(), Lang.blockName(state)
.style(ChatFormatting.WHITE))
.color(mode.getColor())
.sendStatus(player);
}
event.setCanceled(true);
@ -95,7 +95,8 @@ public class ArmInteractionPointHandler {
int removed = 0;
for (Iterator<ArmInteractionPoint> iterator = currentSelection.iterator(); iterator.hasNext();) {
ArmInteractionPoint point = iterator.next();
if (point.getPos().closerThan(pos, ArmTileEntity.getRange()))
if (point.getPos()
.closerThan(pos, ArmTileEntity.getRange()))
continue;
iterator.remove();
removed++;
@ -103,8 +104,10 @@ public class ArmInteractionPointHandler {
LocalPlayer player = Minecraft.getInstance().player;
if (removed > 0) {
player.displayClientMessage(Lang.createTranslationTextComponent("mechanical_arm.points_outside_range", removed)
.withStyle(ChatFormatting.RED), true);
Lang.builder()
.translate("mechanical_arm.points_outside_range", removed)
.style(ChatFormatting.RED)
.sendStatus(player);
} else {
int inputs = 0;
int outputs = 0;
@ -115,8 +118,10 @@ public class ArmInteractionPointHandler {
inputs++;
}
if (inputs + outputs > 0)
player.displayClientMessage(Lang.createTranslationTextComponent("mechanical_arm.summary", inputs, outputs)
.withStyle(ChatFormatting.WHITE), true);
Lang.builder()
.translate("mechanical_arm.summary", inputs, outputs)
.style(ChatFormatting.WHITE)
.sendStatus(player);
}
AllPackets.channel.sendToServer(new ArmPlacementPacket(currentSelection, pos));
@ -194,7 +199,8 @@ public class ArmInteractionPointHandler {
if (shape.isEmpty())
continue;
int color = point.getMode().getColor();
int color = point.getMode()
.getColor();
CreateClient.OUTLINER.showAABB(point, shape.bounds()
.move(pos))
.colored(color)
@ -215,7 +221,8 @@ public class ArmInteractionPointHandler {
private static ArmInteractionPoint getSelected(BlockPos pos) {
for (ArmInteractionPoint point : currentSelection)
if (point.getPos().equals(pos))
if (point.getPos()
.equals(pos))
return point;
return null;
}

View file

@ -102,7 +102,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE
super.addBehaviours(behaviours);
selectionMode = new ScrollOptionBehaviour<SelectionMode>(SelectionMode.class,
Lang.translate("logistics.when_multiple_outputs_available"), this, new SelectionModeValueBox());
Lang.translateDirect("logistics.when_multiple_outputs_available"), this, new SelectionModeValueBox());
selectionMode.requiresWrench();
behaviours.add(selectionMode);

View file

@ -79,7 +79,7 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
@Override
public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
tooltip.add(componentSpacing.plainCopy().append(Lang.translate("tooltip.analogStrength", this.state)));
tooltip.add(componentSpacing.plainCopy().append(Lang.translateDirect("tooltip.analogStrength", this.state)));
return true;
}

View file

@ -25,7 +25,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
private IconButton confirmButton;
private IconButton flipSignals;
private final Component invertSignal = Lang.translate("gui.stockpile_switch.invert_signal");
private final Component invertSignal = Lang.translateDirect("gui.stockpile_switch.invert_signal");
private final ItemStack renderedItem = new ItemStack(AllBlocks.STOCKPILE_SWITCH.get());
private AllGuiTextures background;
@ -36,7 +36,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
private LerpedFloat cursorLane;
public StockpileSwitchScreen(StockpileSwitchTileEntity te) {
super(Lang.translate("gui.stockpile_switch.title"));
super(Lang.translateDirect("gui.stockpile_switch.title"));
background = AllGuiTextures.STOCKSWITCH;
this.te = te;
lastModification = -1;
@ -60,7 +60,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
.titled(TextComponent.EMPTY.plainCopy())
.calling(state -> {
lastModification = 0;
offBelow.titled(Lang.translate("gui.stockpile_switch.move_to_upper_at", state));
offBelow.titled(Lang.translateDirect("gui.stockpile_switch.move_to_upper_at", state));
if (onAbove.getState() <= state) {
onAbove.setState(state + 1);
onAbove.onChanged();
@ -72,7 +72,7 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
.titled(TextComponent.EMPTY.plainCopy())
.calling(state -> {
lastModification = 0;
onAbove.titled(Lang.translate("gui.stockpile_switch.move_to_lower_at", state));
onAbove.titled(Lang.translateDirect("gui.stockpile_switch.move_to_lower_at", state));
if (offBelow.getState() >= state) {
offBelow.setState(state - 1);
offBelow.onChanged();

View file

@ -84,7 +84,8 @@ public class LinkedControllerClientHandler {
}
protected static void onReset() {
ControlsUtil.getControls().forEach(kb -> kb.setDown(ControlsUtil.isActuallyPressed(kb)));
ControlsUtil.getControls()
.forEach(kb -> kb.setDown(ControlsUtil.isActuallyPressed(kb)));
packetCooldown = 0;
selectedLocation = BlockPos.ZERO;
@ -126,7 +127,8 @@ public class LinkedControllerClientHandler {
}
}
if (inLectern() && AllBlocks.LECTERN_CONTROLLER.get().getTileEntityOptional(mc.level, lecternPos)
if (inLectern() && AllBlocks.LECTERN_CONTROLLER.get()
.getTileEntityOptional(mc.level, lecternPos)
.map(te -> !te.isUsedBy(mc.player))
.orElse(true)) {
deactivateInLectern();
@ -139,7 +141,8 @@ public class LinkedControllerClientHandler {
return;
}
if (InputConstants.isKeyDown(mc.getWindow().getWindow(), GLFW.GLFW_KEY_ESCAPE)) {
if (InputConstants.isKeyDown(mc.getWindow()
.getWindow(), GLFW.GLFW_KEY_ESCAPE)) {
MODE = Mode.IDLE;
onReset();
return;
@ -206,13 +209,15 @@ public class LinkedControllerClientHandler {
controls.forEach(kb -> kb.setDown(false));
}
public static void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width1, int height1) {
public static void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width1,
int height1) {
if (MODE != Mode.BIND)
return;
Minecraft mc = Minecraft.getInstance();
poseStack.pushPose();
Screen tooltipScreen = new Screen(TextComponent.EMPTY) {};
Screen tooltipScreen = new Screen(TextComponent.EMPTY) {
};
tooltipScreen.init(mc, width1, height1);
Object[] keys = new Object[6];
@ -224,10 +229,9 @@ public class LinkedControllerClientHandler {
}
List<Component> list = new ArrayList<>();
list.add(Lang.createTranslationTextComponent("linked_controller.bind_mode")
list.add(Lang.translateDirect("linked_controller.bind_mode")
.withStyle(ChatFormatting.GOLD));
list.addAll(
TooltipHelper.cutTextComponent(Lang.createTranslationTextComponent("linked_controller.press_keybind", keys),
list.addAll(TooltipHelper.cutTextComponent(Lang.translateDirect("linked_controller.press_keybind", keys),
ChatFormatting.GRAY, ChatFormatting.GRAY));
int width = 0;

View file

@ -57,9 +57,7 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen<LinkedCo
addRenderableWidget(resetButton);
addRenderableWidget(confirmButton);
extraAreas = ImmutableList.of(
new Rect2i(x + background.width + 4, y + background.height - 44, 64, 56)
);
extraAreas = ImmutableList.of(new Rect2i(x + background.width + 4, y + background.height - 44, 64, 56));
}
@Override
@ -74,8 +72,8 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen<LinkedCo
background.render(ms, x, y, this);
font.draw(ms, title, x + 15, y + 4, 0x442000);
GuiGameElement.of(menu.contentHolder)
.<GuiGameElement.GuiRenderBuilder>at(x + background.width - 4, y + background.height - 56, -200)
GuiGameElement.of(menu.contentHolder).<GuiGameElement
.GuiRenderBuilder>at(x + background.width - 4, y + background.height - 56, -200)
.scale(5)
.render(ms);
}
@ -111,9 +109,7 @@ public class LinkedControllerScreen extends AbstractSimiContainerScreen<LinkedCo
private List<Component> addToTooltip(List<Component> list, int slot) {
if (slot < 0 || slot >= 12)
return list;
list.add(Lang
.createTranslationTextComponent("linked_controller.frequency_slot_" + ((slot % 2) + 1),
ControlsUtil.getControls()
list.add(Lang.translateDirect("linked_controller.frequency_slot_" + ((slot % 2) + 1), ControlsUtil.getControls()
.get(slot / 2)
.getTranslatedKeyMessage()
.getString())

View file

@ -30,19 +30,19 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
private static final String PREFIX = "gui.attribute_filter.";
private Component addDESC = Lang.translate(PREFIX + "add_attribute");
private Component addInvertedDESC = Lang.translate(PREFIX + "add_inverted_attribute");
private Component addDESC = Lang.translateDirect(PREFIX + "add_attribute");
private Component addInvertedDESC = Lang.translateDirect(PREFIX + "add_inverted_attribute");
private Component allowDisN = Lang.translate(PREFIX + "allow_list_disjunctive");
private Component allowDisDESC = Lang.translate(PREFIX + "allow_list_disjunctive.description");
private Component allowConN = Lang.translate(PREFIX + "allow_list_conjunctive");
private Component allowConDESC = Lang.translate(PREFIX + "allow_list_conjunctive.description");
private Component denyN = Lang.translate(PREFIX + "deny_list");
private Component denyDESC = Lang.translate(PREFIX + "deny_list.description");
private Component allowDisN = Lang.translateDirect(PREFIX + "allow_list_disjunctive");
private Component allowDisDESC = Lang.translateDirect(PREFIX + "allow_list_disjunctive.description");
private Component allowConN = Lang.translateDirect(PREFIX + "allow_list_conjunctive");
private Component allowConDESC = Lang.translateDirect(PREFIX + "allow_list_conjunctive.description");
private Component denyN = Lang.translateDirect(PREFIX + "deny_list");
private Component denyDESC = Lang.translateDirect(PREFIX + "deny_list.description");
private Component referenceH = Lang.translate(PREFIX + "add_reference_item");
private Component noSelectedT = Lang.translate(PREFIX + "no_selected_attributes");
private Component selectedT = Lang.translate(PREFIX + "selected_attributes");
private Component referenceH = Lang.translateDirect(PREFIX + "add_reference_item");
private Component noSelectedT = Lang.translateDirect(PREFIX + "no_selected_attributes");
private Component selectedT = Lang.translateDirect(PREFIX + "selected_attributes");
private IconButton whitelistDis, whitelistCon, blacklist;
private Indicator whitelistDisIndicator, whitelistConIndicator, blacklistIndicator;

View file

@ -89,7 +89,7 @@ public class FilterItem extends Item implements MenuProvider {
boolean blacklist = filter.getOrCreateTag()
.getBoolean("Blacklist");
list.add((blacklist ? Lang.translate("gui.filter.deny_list") : Lang.translate("gui.filter.allow_list")).withStyle(ChatFormatting.GOLD));
list.add((blacklist ? Lang.translateDirect("gui.filter.deny_list") : Lang.translateDirect("gui.filter.allow_list")).withStyle(ChatFormatting.GOLD));
int count = 0;
for (int i = 0; i < filterItems.getSlots(); i++) {
if (count > 3) {
@ -112,10 +112,10 @@ public class FilterItem extends Item implements MenuProvider {
WhitelistMode whitelistMode = WhitelistMode.values()[filter.getOrCreateTag()
.getInt("WhitelistMode")];
list.add((whitelistMode == WhitelistMode.WHITELIST_CONJ
? Lang.translate("gui.attribute_filter.allow_list_conjunctive")
? Lang.translateDirect("gui.attribute_filter.allow_list_conjunctive")
: whitelistMode == WhitelistMode.WHITELIST_DISJ
? Lang.translate("gui.attribute_filter.allow_list_disjunctive")
: Lang.translate("gui.attribute_filter.deny_list")).withStyle(ChatFormatting.GOLD));
? Lang.translateDirect("gui.attribute_filter.allow_list_disjunctive")
: Lang.translateDirect("gui.attribute_filter.deny_list")).withStyle(ChatFormatting.GOLD));
int count = 0;
ListTag attributes = filter.getOrCreateTag()

View file

@ -19,15 +19,15 @@ public class FilterScreen extends AbstractFilterScreen<FilterContainer> {
private static final String PREFIX = "gui.filter.";
private Component allowN = Lang.translate(PREFIX + "allow_list");
private Component allowDESC = Lang.translate(PREFIX + "allow_list.description");
private Component denyN = Lang.translate(PREFIX + "deny_list");
private Component denyDESC = Lang.translate(PREFIX + "deny_list.description");
private Component allowN = Lang.translateDirect(PREFIX + "allow_list");
private Component allowDESC = Lang.translateDirect(PREFIX + "allow_list.description");
private Component denyN = Lang.translateDirect(PREFIX + "deny_list");
private Component denyDESC = Lang.translateDirect(PREFIX + "deny_list.description");
private Component respectDataN = Lang.translate(PREFIX + "respect_data");
private Component respectDataDESC = Lang.translate(PREFIX + "respect_data.description");
private Component ignoreDataN = Lang.translate(PREFIX + "ignore_data");
private Component ignoreDataDESC = Lang.translate(PREFIX + "ignore_data.description");
private Component respectDataN = Lang.translateDirect(PREFIX + "respect_data");
private Component respectDataDESC = Lang.translateDirect(PREFIX + "respect_data.description");
private Component ignoreDataN = Lang.translateDirect(PREFIX + "ignore_data");
private Component ignoreDataDESC = Lang.translateDirect(PREFIX + "ignore_data.description");
private IconButton whitelist, blacklist;
private IconButton respectNBT, ignoreNBT;

View file

@ -122,7 +122,7 @@ public interface ItemAttribute {
@OnlyIn(value = Dist.CLIENT)
default TranslatableComponent format(boolean inverted) {
return Lang.translate("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""),
return Lang.translateDirect("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""),
getTranslationParameters());
}
@ -300,7 +300,7 @@ public interface ItemAttribute {
@Override
@OnlyIn(value = Dist.CLIENT)
public TranslatableComponent format(boolean inverted) {
return Lang.translate("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""),
return Lang.translateDirect("item_attributes." + getTranslationKey() + (inverted ? ".inverted" : ""),
group.getDisplayName());
}

View file

@ -48,7 +48,7 @@ public class ShulkerFillLevelAttribute implements ItemAttribute {
public Object[] getTranslationParameters() {
String parameter = "";
if (levels != null)
parameter = Lang.translate("item_attributes." + getTranslationKey() + "." + levels.key).getString();
parameter = Lang.translateDirect("item_attributes." + getTranslationKey() + "." + levels.key).getString();
return new Object[]{parameter};
}

View file

@ -99,9 +99,9 @@ public class CarriageContraption extends Contraption {
if (bogeys == 0)
return false;
if (bogeys > 2)
throw new AssemblyException(Lang.translate("train_assembly.too_many_bogeys", bogeys));
throw new AssemblyException(Lang.translateDirect("train_assembly.too_many_bogeys", bogeys));
if (sidewaysControls)
throw new AssemblyException(Lang.translate("train_assembly.sideways_controls"));
throw new AssemblyException(Lang.translateDirect("train_assembly.sideways_controls"));
for (BlockPos blazePos : assembledBlazeBurners)
for (Direction direction : Iterate.directionsInAxis(assemblyDirection.getAxis()))

View file

@ -528,7 +528,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
@Override
public Component getDisplayName() {
if (carriage == null)
return Lang.translate("train");
return Lang.translateDirect("train");
return carriage.train.name;
}
@ -587,7 +587,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
boolean spaceDown = heldControls.contains(4);
GlobalStation currentStation = carriage.train.getCurrentStation();
if (currentStation != null && spaceDown) {
sendPrompt(player, Lang.translate("train.arrived_at",
sendPrompt(player, Lang.translateDirect("train.arrived_at",
new TextComponent(currentStation.name).withStyle(s -> s.withColor(0x704630))), false);
return true;
}
@ -599,7 +599,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
if (currentStation != null && targetSpeed != 0) {
stationMessage = false;
sendPrompt(player, Lang.translate("train.departing_from",
sendPrompt(player, Lang.translateDirect("train.departing_from",
new TextComponent(currentStation.name).withStyle(s -> s.withColor(0x704630))), false);
}
@ -680,7 +680,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
private void displayApproachStationMessage(Player player, GlobalStation station) {
sendPrompt(player,
Lang.translate("contraption.controls.approach_station", new KeybindComponent("key.jump"), station.name),
Lang.translateDirect("contraption.controls.approach_station", new KeybindComponent("key.jump"), station.name),
false);
stationMessage = true;
}

View file

@ -140,7 +140,7 @@ public class Train {
this.carriageSpacing = carriageSpacing;
this.icon = TrainIconType.getDefault();
this.stress = new double[carriageSpacing.size()];
this.name = Lang.translate("train.unnamed");
this.name = Lang.translateDirect("train.unnamed");
this.status = new TrainStatus(this);
this.doubleEnded = doubleEnded;

View file

@ -96,7 +96,7 @@ public class TrainRelocationPacket extends SimplePacketBase {
}
if (TrainRelocator.relocate(train, sender.level, pos, hoveredBezier, direction, lookAngle, false)) {
sender.displayClientMessage(Lang.translate("train.relocate.success")
sender.displayClientMessage(Lang.translateDirect("train.relocate.success")
.withStyle(ChatFormatting.GREEN), true);
train.carriages.forEach(c -> c.forEachPresentEntity(e -> {
e.nonDamageTicks = 10;

View file

@ -83,7 +83,7 @@ public class TrainRelocator {
if (!player.position()
.closerThan(relocatingOrigin, 24) || player.isSteppingCarefully()) {
relocatingTrain = null;
player.displayClientMessage(Lang.translate("train.relocate.abort")
player.displayClientMessage(Lang.translateDirect("train.relocate.abort")
.withStyle(ChatFormatting.RED), true);
return;
}
@ -294,14 +294,14 @@ public class TrainRelocator {
if (entity instanceof AbstractContraptionEntity ce && Math.abs(ce.getPosition(0)
.subtract(ce.getPosition(1))
.lengthSqr()) > 1 / 1024d) {
player.displayClientMessage(Lang.translate("train.cannot_relocate_moving")
player.displayClientMessage(Lang.translateDirect("train.cannot_relocate_moving")
.withStyle(ChatFormatting.RED), true);
relocatingTrain = null;
return;
}
if (!AllItems.WRENCH.isIn(player.getMainHandItem())) {
player.displayClientMessage(Lang.translate("train.relocate.abort")
player.displayClientMessage(Lang.translateDirect("train.relocate.abort")
.withStyle(ChatFormatting.RED), true);
relocatingTrain = null;
return;
@ -309,19 +309,19 @@ public class TrainRelocator {
if (!player.position()
.closerThan(relocatingOrigin, 24)) {
player.displayClientMessage(Lang.translate("train.relocate.too_far")
player.displayClientMessage(Lang.translateDirect("train.relocate.too_far")
.withStyle(ChatFormatting.RED), true);
return;
}
Boolean success = relocateClient(relocating, true);
if (success == null)
player.displayClientMessage(Lang.translate("train.relocate", relocating.name), true);
player.displayClientMessage(Lang.translateDirect("train.relocate", relocating.name), true);
else if (success.booleanValue())
player.displayClientMessage(Lang.translate("train.relocate.valid")
player.displayClientMessage(Lang.translateDirect("train.relocate.valid")
.withStyle(ChatFormatting.GREEN), true);
else
player.displayClientMessage(Lang.translate("train.relocate.invalid")
player.displayClientMessage(Lang.translateDirect("train.relocate.invalid")
.withStyle(ChatFormatting.RED), true);
return;
}

Some files were not shown because too many files have changed in this diff Show more