Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
The great translation update
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed Apr 7, 2024
1 parent 92f3dc9 commit b6f0df1
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 199 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package dev.compactmods.machines.api;

import net.minecraft.resources.ResourceLocation;

public interface Constants {
String MOD_ID = "compactmachines";

static ResourceLocation modRL(String path) {
return new ResourceLocation(MOD_ID, path);
}
}
42 changes: 0 additions & 42 deletions core-api/src/main/java/dev/compactmods/machines/api/Messages.java

This file was deleted.

31 changes: 0 additions & 31 deletions core-api/src/main/java/dev/compactmods/machines/api/Tooltips.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dev.compactmods.machines.api;

import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.AABB;

import java.util.function.Function;
import java.util.function.Supplier;

import static dev.compactmods.machines.api.Constants.MOD_ID;

public interface Translations {

Supplier<Component> HINT_HOLD_SHIFT = () -> Component.translatableWithFallback(IDs.HINT_HOLD_SHIFT, "Hold shift for details.")
.withStyle(ChatFormatting.DARK_GRAY)
.withStyle(ChatFormatting.ITALIC);

Supplier<Component> UNBREAKABLE_BLOCK = () -> Component.translatableWithFallback(IDs.UNBREAKABLE_BLOCK, "Warning! Unbreakable for non-creative players!")
.withStyle(ChatFormatting.DARK_RED);

Supplier<Component> TELEPORT_OUT_OF_BOUNDS = () -> Component
.translatableWithFallback(IDs.TELEPORT_OUT_OF_BOUNDS, "An otherworldly force prevents your teleportation.")
.withStyle(ChatFormatting.DARK_RED)
.withStyle(ChatFormatting.ITALIC);

interface IDs {
String TELEPORT_OUT_OF_BOUNDS = Util.makeDescriptionId("messages", Constants.modRL("teleport_oob"));
String HOW_DID_YOU_GET_HERE = Util.makeDescriptionId("messages", Constants.modRL("how_did_you_get_here"));
String HINT_HOLD_SHIFT = Util.makeDescriptionId("messages", Constants.modRL("hint.hold_shift"));
String UNBREAKABLE_BLOCK = Util.makeDescriptionId("messages", Constants.modRL("solid_wall"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package dev.compactmods.machines.api.command;

import dev.compactmods.machines.api.Constants;
import net.minecraft.Util;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;

import java.util.function.Function;
import java.util.function.Supplier;

import static dev.compactmods.machines.api.Constants.MOD_ID;

public interface CommandTranslations {

Supplier<Component> CANNOT_GIVE_MACHINE = () -> Component.translatableWithFallback(IDs.CANNOT_GIVE_MACHINE, "Cannot give machine.");

Function<Player, Component> MACHINE_GIVEN = (player) -> Component
.translatableWithFallback(IDs.MACHINE_GIVEN, "Created a new machine item and gave it to %s.", player.getDisplayName());

interface IDs {
String CANNOT_GIVE_MACHINE = Util.makeDescriptionId("commands.machines", Constants.modRL("cannot_give_machine_item"));

String MACHINE_GIVEN = Util.makeDescriptionId("commands.machines", Constants.modRL("machine_given_successfully"));

/**
* Used for displaying the number of registered rooms via summary commands.
*/
String ROOM_COUNT = Util.makeDescriptionId("commands.rooms", new ResourceLocation(MOD_ID, "room_reg_count"));

String SPAWN_CHANGED_SUCCESSFULLY = Util.makeDescriptionId("commands.rooms", new ResourceLocation(MOD_ID, "spawn_changed_successfully"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.compactmods.machines.api.machine;

import dev.compactmods.machines.api.Constants;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.BlockParticleOption;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import org.apache.commons.lang3.function.TriFunction;

import java.util.function.Function;
import java.util.function.Supplier;

public interface MachineTranslations {

Function<BlockPos, Component> NOT_A_MACHINE_BLOCK = (pos) -> Component.empty();

interface IDs {
String OWNER = Util.makeDescriptionId("machine", Constants.modRL("machine.owner"));
String SIZE = Util.makeDescriptionId("machine", Constants.modRL("machine.size"));
String BOUND_TO = Util.makeDescriptionId("machine", Constants.modRL("machine.bound_to"));
String NEW_MACHINE = Util.makeDescriptionId("machine", Constants.modRL("new_machine"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ public void setPlayerSpawn(UUID player, Vec3 location, Vec2 rotation) {
if(!roomBounds.contains(location))
return;

if (playerSpawns.containsKey(player))
playerSpawns.replace(player, new RoomSpawn(location, rotation));
else
playerSpawns.put(player, new RoomSpawn(location, rotation));

playerSpawns.put(player, new RoomSpawn(location, rotation));
this.setDirty();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package dev.compactmods.machines.wall;

import dev.compactmods.machines.api.Tooltips;
import dev.compactmods.machines.api.Translations;
import dev.compactmods.machines.api.WallConstants;
import dev.compactmods.machines.i18n.TranslationUtil;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
Expand All @@ -27,18 +26,8 @@ public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Compo
super.appendHoverText(stack, worldIn, tooltip, flagIn);

if (stack.is(WallConstants.TAG_SOLID_WALL_ITEMS)) {
MutableComponent text;
if (Screen.hasShiftDown()) {
text = TranslationUtil.tooltip(Tooltips.Details.SOLID_WALL)
.withStyle(ChatFormatting.DARK_RED);
} else {
text = TranslationUtil.tooltip(Tooltips.HINT_HOLD_SHIFT)
.withStyle(ChatFormatting.DARK_GRAY)
.withStyle(ChatFormatting.ITALIC);
}

tooltip.add(text);
tooltip.add(Screen.hasShiftDown() ?
Translations.UNBREAKABLE_BLOCK.get() : Translations.HINT_HOLD_SHIFT.get());
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package dev.compactmods.machines.api.room;

import com.mojang.authlib.GameProfile;
import dev.compactmods.machines.api.Constants;
import dev.compactmods.machines.api.room.function.PlayerAndRoomCodeFunction;
import dev.compactmods.machines.api.util.AABBHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.entity.player.Player;

import java.util.function.BiFunction;
import java.util.function.Function;

public interface RoomTranslations {

/**
* Used to show information about a player inside a Compact room.
*/
PlayerAndRoomCodeFunction<Component> PLAYER_ROOM_INFO = (player, roomCode) ->
Component.translatableWithFallback(IDs.PLAYER_ROOM_INFO, "%1$s is inside room '%2$s'.",
player.getDisplayName(), roomCode);

Function<Player, Component> PLAYER_NOT_IN_COMPACT_DIM = (player) -> Component.translatableWithFallback(IDs.Errors.PLAYER_NOT_IN_COMPACT_DIM, "", player.getDisplayName());

Function<Player, Component> UNKNOWN_ROOM_BY_PLAYER_CHUNK = (player) -> Component.translatableWithFallback(IDs.Errors.UNKNOWN_ROOM_BY_PLAYER_CHUNK, "Room not found at chunk: %s", player.chunkPosition())
.withStyle(ChatFormatting.DARK_RED);

Function<String, Component> UNKNOWN_ROOM_BY_CODE = (roomCode) -> Component.translatableWithFallback(IDs.Errors.UNKNOWN_ROOM_BY_CODE, "Room not found: %s", roomCode);

BiFunction<BlockPos, RoomInstance, Component> MACHINE_ROOM_INFO = (machinePos, info) -> Component.translatableWithFallback(IDs.MACHINE_ROOM_INFO,
"Machine at %1$s is bound to a %2$s size room at %3$s",
machinePos.toShortString(), AABBHelper.toString(info.boundaries().innerBounds()), info.boundaries().innerBounds().getCenter());

Function<GameProfile, Component> CANNOT_RENAME_NOT_OWNER = (owner) -> Component
.translatableWithFallback(IDs.Errors.CANNOT_RENAME_NOT_OWNER, "You are not the room owner; only %s may make changes.", owner.getName());

PlayerAndRoomCodeFunction<Component> ROOM_SPAWNPOINT_SET = (player, roomCode) -> Component
.translatableWithFallback(IDs.ROOM_SPAWNPOINT_SET, "Room spawn for %s updated.", player.getDisplayName())
.withStyle(ChatFormatting.GREEN);

interface IDs {
String ROOM_SPAWNPOINT_SET = Util.makeDescriptionId("rooms", Constants.modRL("spawnpoint_set"));

String PLAYER_ROOM_INFO = Util.makeDescriptionId("rooms", Constants.modRL("player_room_info"));

String MACHINE_ROOM_INFO = Util.makeDescriptionId("machine", Constants.modRL("machine_room_info"));

interface Errors {
String UNKNOWN_ROOM_BY_CODE = Util.makeDescriptionId("rooms.errors", Constants.modRL("room_not_found"));

String CANNOT_ENTER_ROOM = Util.makeDescriptionId("rooms.errors", Constants.modRL("cannot_enter"));

String UNKNOWN_ROOM_BY_PLAYER_CHUNK = Util.makeDescriptionId("rooms.errors", Constants.modRL("unknown_room_chunk"));

String PLAYER_NOT_IN_COMPACT_DIM = Util.makeDescriptionId("rooms.errors", Constants.modRL("player_not_in_compact_dimension"));
}
}
}
Loading

0 comments on commit b6f0df1

Please sign in to comment.