More translations for TR & RC

This commit is contained in:
drcrazy 2020-10-30 00:41:14 +03:00
parent c41be06bf1
commit 81aa7e7ec2
4 changed files with 24 additions and 8 deletions

View file

@ -25,6 +25,7 @@
package techreborn.blockentity.storage.item; package techreborn.blockentity.storage.item;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -435,8 +436,12 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
.append( .append(
new LiteralText(String.valueOf(this.getMaxCapacity())) new LiteralText(String.valueOf(this.getMaxCapacity()))
.formatted(Formatting.GOLD) .formatted(Formatting.GOLD)
.append(" items (") .append(" ")
.append(I18n.translate("techreborn.tooltip.unit.items"))
.append(" (")
.append(String.valueOf(this.getMaxCapacity() / 64)) .append(String.valueOf(this.getMaxCapacity() / 64))
.append(" ")
.append(I18n.translate("techreborn.tooltip.unit.stacks"))
.append(")") .append(")")
) )
); );

View file

@ -133,14 +133,16 @@ public class StackToolTipHandler implements ItemTooltipCallback {
} }
} else { } else {
try { try {
if ((block instanceof BlockEntityProvider) && Registry.BLOCK.getId(block).getNamespace().contains("techreborn")) { if ((block instanceof BlockEntityProvider) && isTRBlock(block)) {
BlockEntity blockEntity = ((BlockEntityProvider) block).createBlockEntity(MinecraftClient.getInstance().world); BlockEntity blockEntity = ((BlockEntityProvider) block).createBlockEntity(MinecraftClient.getInstance().world);
boolean hasData = false; boolean hasData = false;
if (stack.hasTag() && stack.getTag().contains("blockEntity_data")) { if (stack.hasTag() && stack.getOrCreateTag().contains("blockEntity_data")) {
CompoundTag blockEntityData = stack.getTag().getCompound("blockEntity_data"); CompoundTag blockEntityData = stack.getOrCreateTag().getCompound("blockEntity_data");
blockEntity.fromTag(blockEntity.getCachedState(), blockEntityData); if (blockEntity != null) {
blockEntity.fromTag(block.getDefaultState(), blockEntityData);
hasData = true; hasData = true;
tooltipLines.add(new LiteralText("Block data contained").formatted(Formatting.DARK_GREEN)); tooltipLines.add(new LiteralText(I18n.translate("techreborn.tooltip.has_data")).formatted(Formatting.DARK_GREEN));
}
} }
if (blockEntity instanceof IListInfoProvider) { if (blockEntity instanceof IListInfoProvider) {
((IListInfoProvider) blockEntity).addInfo(tooltipLines, false, hasData); ((IListInfoProvider) blockEntity).addInfo(tooltipLines, false, hasData);
@ -156,6 +158,10 @@ public class StackToolTipHandler implements ItemTooltipCallback {
return Registry.ITEM.getId(item).getNamespace().equals("techreborn"); return Registry.ITEM.getId(item).getNamespace().equals("techreborn");
} }
private boolean isTRBlock(Block block){
return Registry.BLOCK.getId(block).getNamespace().contains("techreborn");
}
public int percentage(int MaxValue, int CurrentValue) { public int percentage(int MaxValue, int CurrentValue) {
if (CurrentValue == 0) if (CurrentValue == 0)
return 0; return 0;

View file

@ -30,6 +30,7 @@ import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags; import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.item.TooltipContext; import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -137,7 +138,7 @@ public class OmniToolItem extends PickaxeItem implements EnergyHolder, ItemDurab
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
@Override @Override
public void appendTooltip(ItemStack stack, @Nullable World worldIn, List<Text> tooltip, TooltipContext flagIn) { public void appendTooltip(ItemStack stack, @Nullable World worldIn, List<Text> tooltip, TooltipContext flagIn) {
tooltip.add(new LiteralText(Formatting.YELLOW + "Swiss Army Knife")); tooltip.add(new LiteralText(Formatting.YELLOW + I18n.translate("techreborn.tooltip.omnitool_motto")));
} }
// ItemDurabilityExtensions // ItemDurabilityExtensions

View file

@ -825,10 +825,14 @@
"techreborn.tooltip.unit.capacity": "Capacity: ", "techreborn.tooltip.unit.capacity": "Capacity: ",
"techreborn.tooltip.unit.empty": "Empty", "techreborn.tooltip.unit.empty": "Empty",
"techreborn.tooltip.unit.divider": " of ", "techreborn.tooltip.unit.divider": " of ",
"techreborn.tooltip.unit.items": "items",
"techreborn.tooltip.unit.stacks": "stacks",
"techreborn.tooltip.painting_tool.select": "Shift right click on block to set style", "techreborn.tooltip.painting_tool.select": "Shift right click on block to set style",
"techreborn.tooltip.painting_tool.apply": "Right click on covered cable to apply", "techreborn.tooltip.painting_tool.apply": "Right click on covered cable to apply",
"techreborn.tooltip.cable.can_cover": "Can be covered with wooden plates", "techreborn.tooltip.cable.can_cover": "Can be covered with wooden plates",
"techreborn.tooltip.more_info": "Hold Shift for more info", "techreborn.tooltip.more_info": "Hold Shift for more info",
"techreborn.tooltip.has_data": "Stored data",
"techreborn.tooltip.omnitool_motto" : "Swiss Army Knife",
"_comment23": "ManualUI", "_comment23": "ManualUI",
"techreborn.manual.wiki": "Online wiki", "techreborn.manual.wiki": "Online wiki",