diff --git a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java index be1159fb..12f484da 100644 --- a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java +++ b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java @@ -144,15 +144,15 @@ public class WarpDriveConfig { public static boolean RECIPES_ENABLE_VANILLA = false; // Client - public static float CLIENT_LOCATION_SCALE = 0.5F; - public static String CLIENT_LOCATION_FORMAT = "§l"; + public static float CLIENT_LOCATION_SCALE = 1.0F; + public static String CLIENT_LOCATION_FORMAT_TITLE = "§l%1$s"; public static int CLIENT_LOCATION_BACKGROUND_COLOR = Commons.colorARGBtoInt(64, 48, 48, 48); public static int CLIENT_LOCATION_TEXT_COLOR = Commons.colorARGBtoInt(230, 180, 180, 240); public static boolean CLIENT_LOCATION_HAS_SHADOW = true; public static EnumDisplayAlignment CLIENT_LOCATION_SCREEN_ALIGNMENT = EnumDisplayAlignment.MIDDLE_RIGHT; - public static int CLIENT_LOCATION_SCREEN_OFFSET_X = -50; - public static int CLIENT_LOCATION_SCREEN_OFFSET_Y = 0; - public static EnumDisplayAlignment CLIENT_LOCATION_TEXT_ALIGNMENT = EnumDisplayAlignment.TOP_CENTER; + public static int CLIENT_LOCATION_SCREEN_OFFSET_X = 0; + public static int CLIENT_LOCATION_SCREEN_OFFSET_Y = -20; + public static EnumDisplayAlignment CLIENT_LOCATION_TEXT_ALIGNMENT = EnumDisplayAlignment.TOP_RIGHT; public static float CLIENT_LOCATION_WIDTH_RATIO = 0.0F; public static int CLIENT_LOCATION_WIDTH_MIN = 90; @@ -492,8 +492,8 @@ public class WarpDriveConfig { CLIENT_LOCATION_SCALE = Commons.clamp(0.25F, 4.0F, (float) config.get("client", "location_scale", CLIENT_LOCATION_SCALE, "Scale for location text font").getDouble() ); - CLIENT_LOCATION_FORMAT = config.get("client", "location_format", CLIENT_LOCATION_FORMAT, - "Format prefix for location title").getString(); + CLIENT_LOCATION_FORMAT_TITLE = config.get("client", "location_prefix", CLIENT_LOCATION_FORMAT_TITLE, + "Format for location title").getString(); { String stringValue = config.get("client", "location_background_color", String.format("0x%6X", CLIENT_LOCATION_BACKGROUND_COLOR), "Hexadecimal color code for location tile and description background (0xAARRGGBB where AA is alpha, RR is Red, GG is Green and BB is Blue component)").getString(); @@ -901,6 +901,8 @@ public class WarpDriveConfig { config.get("lift", "entity_cooldown_ticks", LIFT_ENTITY_COOLDOWN_TICKS, "Cooldown after moving an entity").getInt()); // Particles accelerator + ACCELERATOR_ENABLE = config.get("accelerator", "enable", ACCELERATOR_ENABLE, "Enable accelerator blocks. Requires a compatible server, as it won't work in single player").getBoolean(false); + ACCELERATOR_MAX_PARTICLE_BUNCHES = Commons.clamp(2, 100, config.get("accelerator", "max_particle_bunches", ACCELERATOR_MAX_PARTICLE_BUNCHES, "Maximum number of particle bunches per accelerator controller").getInt()); diff --git a/src/main/java/cr0s/warpdrive/render/RenderCommons.java b/src/main/java/cr0s/warpdrive/render/RenderCommons.java index ca6ef8de..9fb0b665 100644 --- a/src/main/java/cr0s/warpdrive/render/RenderCommons.java +++ b/src/main/java/cr0s/warpdrive/render/RenderCommons.java @@ -5,6 +5,7 @@ import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.config.Dictionary; import cr0s.warpdrive.data.EnumDisplayAlignment; +import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; @@ -152,19 +153,25 @@ public class RenderCommons { } public static void drawText(final int screen_width, final int screen_height, final String textHeader, final String textContent, - final float scale, final String formatHeaderPrefix, final int colorBackground, final int colorText, final boolean hasHeaderShadow, + final float scale, final String formatHeader, final int colorBackground, final int colorText, final boolean hasHeaderShadow, final EnumDisplayAlignment enumScreenAnchor, final int xOffset, final int yOffset, final EnumDisplayAlignment enumTextAlignment, final float widthTextRatio, final int widthTextMin) { // prepare the string box content and dimensions - final String header_formatted = Commons.updateEscapeCodes(formatHeaderPrefix + StatCollector.translateToLocal(textHeader)); + final String header_formatted = Commons.updateEscapeCodes(String.format(StatCollector.translateToLocal(textHeader), formatHeader)); final String content_formatted = Commons.updateEscapeCodes(StatCollector.translateToLocal(textContent)); final int scaled_box_width = Math.max(widthTextMin, Math.round(widthTextRatio * screen_width)) + 2 * TEXT_BORDER; @SuppressWarnings("unchecked") - final List listHeaderLines = minecraft.fontRenderer.listFormattedStringToWidth(header_formatted, scaled_box_width - 2 * TEXT_BORDER); + final List listHeaderLines = + header_formatted.isEmpty() ? new ArrayList<>(0) + : minecraft.fontRenderer.listFormattedStringToWidth(header_formatted, scaled_box_width - 2 * TEXT_BORDER); @SuppressWarnings("unchecked") - final List listContentLines = minecraft.fontRenderer.listFormattedStringToWidth(content_formatted, scaled_box_width - 2 * TEXT_BORDER); - final int scaled_box_height = (listHeaderLines.size() + listContentLines.size()) * minecraft.fontRenderer.FONT_HEIGHT + 3 * TEXT_BORDER; + final List listContentLines = + content_formatted.isEmpty() ? new ArrayList<>(0) + : minecraft.fontRenderer.listFormattedStringToWidth(content_formatted, scaled_box_width - 2 * TEXT_BORDER); + final boolean hasTileAndContent = listHeaderLines.size() > 0 && listContentLines.size() > 0; + final int scaled_box_height = (listHeaderLines.size() + listContentLines.size()) * minecraft.fontRenderer.FONT_HEIGHT + + (hasTileAndContent ? 3 : 1) * TEXT_BORDER; // compute the position final int screen_text_x = Math.round(screen_width * enumScreenAnchor.xRatio + xOffset - enumTextAlignment.xRatio * scaled_box_width * scale); @@ -203,7 +210,9 @@ public class RenderCommons { minecraft.fontRenderer.drawString(textLine, scaled_text_x, scaled_text_y, colorText, hasHeaderShadow); scaled_text_y += minecraft.fontRenderer.FONT_HEIGHT; } - scaled_text_y += TEXT_BORDER; + if (hasTileAndContent) { + scaled_text_y += TEXT_BORDER; + } for (final String textLine : listContentLines) { minecraft.fontRenderer.drawString(textLine, scaled_text_x, scaled_text_y, colorText, false); scaled_text_y += minecraft.fontRenderer.FONT_HEIGHT; diff --git a/src/main/java/cr0s/warpdrive/render/RenderOverlayLocation.java b/src/main/java/cr0s/warpdrive/render/RenderOverlayLocation.java index 8ab47791..2d1babcf 100644 --- a/src/main/java/cr0s/warpdrive/render/RenderOverlayLocation.java +++ b/src/main/java/cr0s/warpdrive/render/RenderOverlayLocation.java @@ -48,7 +48,7 @@ public class RenderOverlayLocation { // show current location name & description RenderCommons.drawText(widthScreen, heightScreen, name, description, WarpDriveConfig.CLIENT_LOCATION_SCALE, - WarpDriveConfig.CLIENT_LOCATION_FORMAT, + WarpDriveConfig.CLIENT_LOCATION_FORMAT_TITLE, WarpDriveConfig.CLIENT_LOCATION_BACKGROUND_COLOR, WarpDriveConfig.CLIENT_LOCATION_TEXT_COLOR, WarpDriveConfig.CLIENT_LOCATION_HAS_SHADOW, diff --git a/src/main/resources/config/celestialObjects-default.xml b/src/main/resources/config/celestialObjects-default.xml index 3e3358fb..68af268c 100644 --- a/src/main/resources/config/celestialObjects-default.xml +++ b/src/main/resources/config/celestialObjects-default.xml @@ -27,7 +27,7 @@ nbt defines a JSON string for custom tags. It's used by WarpDrive extensions. --> - §lHyperspace + Hyperspace Your ship warp bubble is your\nonly protection. - - - + + + @@ -140,10 +142,10 @@
- - - - + + + +