mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-23 21:50:02 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
477b955247 | ||
|
|
ce2610923c | ||
|
|
e069188aab | ||
|
|
308febfed0 | ||
|
|
9f4968524a | ||
|
|
177b37f63d | ||
|
|
8e5f3c49b1 | ||
|
|
ef310b30ce |
No files matched your search
@@ -21,8 +21,6 @@ import codechicken.lib.vec.Rectangle4i;
|
||||
import codechicken.nei.api.GuiInfo;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.item.ItemNameOverlayMode;
|
||||
import codechicken.nei.item.ItemNameOverlayRenderer;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
@@ -31,8 +29,6 @@ public abstract class ItemsGrid<T extends ItemsGrid.ItemsGridSlot, M extends Ite
|
||||
protected static class ScreenCapture {
|
||||
|
||||
private long nextCacheRefresh = 0;
|
||||
private ItemNameOverlayMode itemNameOverlayMode;
|
||||
private long itemNameOverlayRevision;
|
||||
private final Framebuffer framebuffer;
|
||||
|
||||
public ScreenCapture() {
|
||||
@@ -49,8 +45,6 @@ public abstract class ItemsGrid<T extends ItemsGrid.ItemsGridSlot, M extends Ite
|
||||
final Minecraft minecraft = Minecraft.getMinecraft();
|
||||
return this.nextCacheRefresh == 0 || this.framebuffer.framebufferWidth != minecraft.displayWidth
|
||||
|| framebuffer.framebufferHeight != minecraft.displayHeight
|
||||
|| this.itemNameOverlayMode != NEIClientConfig.getItemNameOverlayMode()
|
||||
|| this.itemNameOverlayRevision != ItemNameOverlayRenderer.INSTANCE.getCacheRevision()
|
||||
|| getGridRenderingCacheFPS(mode) > 0 && this.nextCacheRefresh < System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@@ -76,9 +70,6 @@ public abstract class ItemsGrid<T extends ItemsGrid.ItemsGridSlot, M extends Ite
|
||||
|
||||
callback.run();
|
||||
|
||||
this.itemNameOverlayMode = NEIClientConfig.getItemNameOverlayMode();
|
||||
this.itemNameOverlayRevision = ItemNameOverlayRenderer.INSTANCE.getCacheRevision();
|
||||
|
||||
GL11.glPopAttrib();
|
||||
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
|
||||
@@ -47,7 +47,6 @@ import codechicken.nei.config.GuiPanelSettings;
|
||||
import codechicken.nei.config.OptionButton;
|
||||
import codechicken.nei.config.OptionCycled;
|
||||
import codechicken.nei.config.OptionExportConfig;
|
||||
import codechicken.nei.config.OptionFloatField;
|
||||
import codechicken.nei.config.OptionGamemodes;
|
||||
import codechicken.nei.config.OptionIntegerField;
|
||||
import codechicken.nei.config.OptionList;
|
||||
@@ -58,9 +57,6 @@ import codechicken.nei.config.OptionToggleButtonBoubs;
|
||||
import codechicken.nei.config.OptionUtilities;
|
||||
import codechicken.nei.config.preset.GuiPresetList;
|
||||
import codechicken.nei.event.NEIConfigsLoadedEvent;
|
||||
import codechicken.nei.item.ItemNameOverlayMode;
|
||||
import codechicken.nei.item.ItemNameOverlayRenderer;
|
||||
import codechicken.nei.item.ItemNameOverlaySettings;
|
||||
import codechicken.nei.moboverlay.MobOverlayScan;
|
||||
import codechicken.nei.moboverlay.MobOverlayStyle;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
@@ -76,7 +72,6 @@ public class NEIClientConfig {
|
||||
private static boolean enabledOverride;
|
||||
private static String worldPath;
|
||||
private static final String CHEAT_MODE_KEY = "cheatmode";
|
||||
private static ItemNameOverlaySettings itemNameOverlaySettings = ItemNameOverlaySettings.defaults();
|
||||
|
||||
public static Logger logger = LogManager.getLogger("NotEnoughItems");
|
||||
public static File configDir = new File(CommonUtils.getMinecraftDir(), "config/NEI/");
|
||||
@@ -415,8 +410,6 @@ public class NEIClientConfig {
|
||||
tag.getTag("inventory.itemzoom.nameColor").getHexValue(0xFFFFFFFF);
|
||||
API.addOption(new OptionIntegerField("inventory.itemzoom.nameColor", 0, OptionIntegerField.UNSIGNED_INT_MAX));
|
||||
|
||||
setItemNameOverlayDefaults(tag);
|
||||
|
||||
setFavoriteDefaults(tag);
|
||||
|
||||
tag.getTag("inventory.tooltip.showFluidTemperature").setComment("Enabled show Fluid Temperature")
|
||||
@@ -598,99 +591,6 @@ public class NEIClientConfig {
|
||||
setDefaultKeyBindings();
|
||||
}
|
||||
|
||||
private static void setItemNameOverlayDefaults(ConfigTagParent tag) {
|
||||
final ConfigTag overlay = tag.getTag("inventory.itemNameOverlay");
|
||||
final int previousMode = overlay.getValue() != null ? overlay.getIntValue(3) : 3;
|
||||
tag.getTag("inventory.itemNameOverlay.mode")
|
||||
.setComment("Icon name labels: 0 = items, 1 = fluids, 2 = all, 3 = off").getIntValue(previousMode);
|
||||
// Move the old scalar value into the new settings page without losing the selection.
|
||||
if (overlay.getValue() != null) {
|
||||
overlay.setValue(null);
|
||||
}
|
||||
API.addOption(new OptionCycled("inventory.itemNameOverlay.mode", 4, true) {
|
||||
|
||||
@Override
|
||||
public void setValue(int value) {
|
||||
super.setValue(value);
|
||||
reloadItemNameOverlaySettings();
|
||||
}
|
||||
});
|
||||
|
||||
addItemNameScaleOption(tag, "fontScale", "Preferred scale for ordinary fonts", 0.5f);
|
||||
addItemNameScaleOption(tag, "unicodeFontScale", "Preferred scale for Unicode text and fonts", 0.5625f);
|
||||
addItemNameScaleOption(tag, "minimumScale", "Minimum scale for fitting a name into its label", 0.3f);
|
||||
addItemNameIntegerOption(tag, "width", "Total label width in icon coordinates", 18, 4, 32);
|
||||
addItemNameIntegerOption(tag, "maxCharacters", "Maximum characters per line; 0 means automatic", 0, 0, 256);
|
||||
addItemNameIntegerOption(tag, "maxLines", "Maximum number of name lines", 2, 1, 4);
|
||||
|
||||
tag.getTag("inventory.itemNameOverlay.outline").setComment("Draw a one-screen-pixel outline around names")
|
||||
.getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.itemNameOverlay.outline", true) {
|
||||
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
final boolean changed = super.onClick(button);
|
||||
reloadItemNameOverlaySettings();
|
||||
return changed;
|
||||
}
|
||||
});
|
||||
reloadItemNameOverlaySettings();
|
||||
}
|
||||
|
||||
private static void addItemNameScaleOption(ConfigTagParent tag, String name, String comment, float defaultValue) {
|
||||
final String path = "inventory.itemNameOverlay." + name;
|
||||
tag.getTag(path).setComment(comment).setDefaultValue(Float.toString(defaultValue));
|
||||
API.addOption(new OptionFloatField(path, 0.1f, 2f) {
|
||||
|
||||
@Override
|
||||
public void onTextChange(String text) {
|
||||
reloadItemNameOverlaySettings();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void addItemNameIntegerOption(ConfigTagParent tag, String name, String comment, int defaultValue,
|
||||
int min, int max) {
|
||||
final String path = "inventory.itemNameOverlay." + name;
|
||||
tag.getTag(path).setComment(comment).getIntValue(defaultValue);
|
||||
API.addOption(new OptionIntegerField(path, min, max) {
|
||||
|
||||
@Override
|
||||
public void onTextChange(String text) {
|
||||
reloadItemNameOverlaySettings();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static float readItemNameScale(String name, float fallback) {
|
||||
try {
|
||||
final float value = Float
|
||||
.parseFloat(getSetting("inventory.itemNameOverlay." + name).getValue(Float.toString(fallback)));
|
||||
return Float.isFinite(value) ? value : fallback;
|
||||
} catch (NumberFormatException ignored) {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
public static void reloadItemNameOverlaySettings() {
|
||||
itemNameOverlaySettings = new ItemNameOverlaySettings(
|
||||
ItemNameOverlayMode.fromConfigValue(getIntSetting("inventory.itemNameOverlay.mode")),
|
||||
readItemNameScale("fontScale", 0.5f),
|
||||
readItemNameScale("unicodeFontScale", 0.5625f),
|
||||
readItemNameScale("minimumScale", 0.3f),
|
||||
getIntSetting("inventory.itemNameOverlay.width"),
|
||||
getIntSetting("inventory.itemNameOverlay.maxCharacters"),
|
||||
getIntSetting("inventory.itemNameOverlay.maxLines"),
|
||||
getBooleanSetting("inventory.itemNameOverlay.outline"));
|
||||
ItemNameOverlayRenderer.INSTANCE.setSettings(itemNameOverlaySettings);
|
||||
}
|
||||
|
||||
private static void refreshItemNameOverlaySetting(String setting) {
|
||||
if (setting.startsWith("inventory.itemNameOverlay.")) {
|
||||
reloadItemNameOverlaySettings();
|
||||
}
|
||||
}
|
||||
|
||||
private static void linkOptionList() {
|
||||
OptionList.setOptionList(new OptionList("nei.options") {
|
||||
|
||||
@@ -1373,13 +1273,11 @@ public class NEIClientConfig {
|
||||
public static void toggleBooleanSetting(String setting) {
|
||||
ConfigTag tag = getSetting(setting);
|
||||
tag.setBooleanValue(!tag.getBooleanValue());
|
||||
refreshItemNameOverlaySetting(setting);
|
||||
}
|
||||
|
||||
public static void cycleSetting(String setting, int max) {
|
||||
ConfigTag tag = getSetting(setting);
|
||||
tag.setIntValue((tag.getIntValue() + 1) % max);
|
||||
refreshItemNameOverlaySetting(setting);
|
||||
}
|
||||
|
||||
public static int getIntSetting(String setting) {
|
||||
@@ -1388,7 +1286,6 @@ public class NEIClientConfig {
|
||||
|
||||
public static void setIntSetting(String setting, int val) {
|
||||
getSetting(setting).setIntValue(val);
|
||||
refreshItemNameOverlaySetting(setting);
|
||||
}
|
||||
|
||||
public static String getSearchExpression() {
|
||||
@@ -1419,14 +1316,6 @@ public class NEIClientConfig {
|
||||
return OpenGlHelper.framebufferSupported ? getIntSetting("inventory.gridRenderingCacheMode") : 0;
|
||||
}
|
||||
|
||||
public static ItemNameOverlayMode getItemNameOverlayMode() {
|
||||
return itemNameOverlaySettings.mode;
|
||||
}
|
||||
|
||||
public static ItemNameOverlaySettings getItemNameOverlaySettings() {
|
||||
return itemNameOverlaySettings;
|
||||
}
|
||||
|
||||
public static boolean enableCollapsibleItems() {
|
||||
return getBooleanSetting("inventory.collapsibleItems.enabled");
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
private static final MobOverlayScan MOB_OVERLAY_SCAN = new MobOverlayScan();
|
||||
private static final MobOverlayFace MARKED_FACE = new MobOverlayFace();
|
||||
private static final MobOverlayDisplayList MOB_OVERLAY_LIST = new MobOverlayDisplayList();
|
||||
private static final byte[] COLUMN_CELLS = new byte[2 * MobOverlayScan.MAX_VERTICAL_RADIUS + 1];
|
||||
|
||||
public static void reset() {
|
||||
mobOverlay = 0;
|
||||
@@ -83,10 +84,6 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
/**
|
||||
* The model view matrix is relative to ({@code intOffsetX}, {@code intOffsetY}, {@code intOffsetZ}), the camera
|
||||
* position cast to {@code int}.
|
||||
*/
|
||||
private static void renderMobSpawnOverlay(Entity entity, int intOffsetX, int intOffsetY, int intOffsetZ) {
|
||||
if (mobOverlay == 0) {
|
||||
MOB_OVERLAY_SCAN.clear();
|
||||
@@ -110,29 +107,49 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
endMobOverlayDraw();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a marked face to {@link #MOB_OVERLAY_LIST} for each block of {@link #MOB_OVERLAY_SCAN} where mobs can spawn.
|
||||
*/
|
||||
private static void compileMobOverlayList(MobOverlayStyle style, long worldTicks) {
|
||||
MOB_OVERLAY_LIST.beginCompile(MOB_OVERLAY_SCAN, style, worldTicks);
|
||||
for (int chunkX = MOB_OVERLAY_SCAN.getMinChunkX(); chunkX <= MOB_OVERLAY_SCAN.getMaxChunkX(); chunkX++) {
|
||||
for (int chunkZ = MOB_OVERLAY_SCAN.getMinChunkZ(); chunkZ <= MOB_OVERLAY_SCAN.getMaxChunkZ(); chunkZ++) {
|
||||
if (!MOB_OVERLAY_LIST.beginChunk(MOB_OVERLAY_SCAN, chunkX, chunkZ)) continue;
|
||||
|
||||
MOB_OVERLAY_LIST.endChunk(compileChunkFaces(style, chunkX, chunkZ));
|
||||
}
|
||||
}
|
||||
MOB_OVERLAY_LIST.endCompile(MOB_OVERLAY_SCAN);
|
||||
}
|
||||
|
||||
private static boolean compileChunkFaces(MobOverlayStyle style, int chunkX, int chunkZ) {
|
||||
final int CHUNK_WIDTH = 1 << MobOverlayScan.CHUNK_SHIFT;
|
||||
final float alpha = style.computeAlpha();
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawing(style.glMode);
|
||||
final int cornerX = chunkX << MobOverlayScan.CHUNK_SHIFT;
|
||||
final int cornerZ = chunkZ << MobOverlayScan.CHUNK_SHIFT;
|
||||
final int minX = MOB_OVERLAY_SCAN.getMinX();
|
||||
final int minZ = MOB_OVERLAY_SCAN.getMinZ();
|
||||
final int span = MOB_OVERLAY_SCAN.getSpan();
|
||||
for (int i = 0; i < span; i++) {
|
||||
for (int j = 0; j < span; j++) {
|
||||
for (int k = 0; k < MOB_OVERLAY_SCAN.getHeight(); k++) {
|
||||
if (MOB_OVERLAY_SCAN.readSpawnMode(i, k, j) == 0) continue;
|
||||
final int height = MOB_OVERLAY_SCAN.getHeight();
|
||||
boolean hasFaces = false;
|
||||
tess.startDrawing(style.glMode);
|
||||
for (int i = Math.max(cornerX - minX, 0); i < Math.min(cornerX + CHUNK_WIDTH - minX, span); i++) {
|
||||
for (int j = Math.max(cornerZ - minZ, 0); j < Math.min(cornerZ + CHUNK_WIDTH - minZ, span); j++) {
|
||||
MOB_OVERLAY_SCAN.readColumn(i, j, COLUMN_CELLS);
|
||||
for (int k = 0; k < height; k++) {
|
||||
if (MobOverlayScan.extractSpawnMode(COLUMN_CELLS[k]) == 0) continue;
|
||||
|
||||
MARKED_FACE.moveTo(i, k + MOB_OVERLAY_SCAN.readOverlayYOffset(i, k, j), j);
|
||||
MARKED_FACE.moveTo(
|
||||
minX + i - cornerX,
|
||||
k + MobOverlayScan.computeOverlayYOffset(COLUMN_CELLS[k]),
|
||||
minZ + j - cornerZ);
|
||||
loadNeighbourModes(i, k, j);
|
||||
MARKED_FACE.applyColor(style.colouring, alpha);
|
||||
style.addVertices(MARKED_FACE);
|
||||
hasFaces = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
tess.draw();
|
||||
MOB_OVERLAY_LIST.endCompile();
|
||||
return hasFaces;
|
||||
}
|
||||
|
||||
private static void beginMobOverlayDraw(MobOverlayStyle style) {
|
||||
@@ -147,7 +164,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glLineWidth(1.5F);
|
||||
// the outline of `MobOverlayStyle.CONNECTED` lies in the plane of the tint. With depth writes on, the depth
|
||||
// the outline of `MobOverlayStyle.CONNECTED` lies in the plane of the tint. When depth writes are on, the depth
|
||||
// test discards most of the outline
|
||||
GL11.glDepthMask(false);
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package codechicken.nei.config;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
|
||||
public class OptionFloatField extends OptionTextField {
|
||||
|
||||
public final float min;
|
||||
public final float max;
|
||||
|
||||
public OptionFloatField(String name, float min, float max) {
|
||||
super(name);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxInputWidth() {
|
||||
return GuiDraw.getStringWidth(Float.toString(max)) + 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInput(String text) {
|
||||
if (text.isEmpty() || text.equals(".")) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
return Float.isFinite(Float.parseFloat(text));
|
||||
} catch (NumberFormatException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidValue(String text) {
|
||||
try {
|
||||
final float value = Float.parseFloat(text);
|
||||
return Float.isFinite(value) && value >= min && value <= max;
|
||||
} catch (NumberFormatException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,8 +50,6 @@ import codechicken.nei.KeyManager;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIModContainer;
|
||||
import codechicken.nei.item.ItemNameOverlayMode;
|
||||
import codechicken.nei.item.ItemNameOverlayRenderer;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.ItemUntranslator;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
@@ -64,7 +62,6 @@ public class GuiContainerManager {
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager p_110549_1_) {
|
||||
renderingErrorItems.clear();
|
||||
ItemNameOverlayRenderer.INSTANCE.clearCache();
|
||||
ItemList.loadItems.restart();
|
||||
|
||||
if (NEIClientConfig.enableItemUntranslator()) {
|
||||
@@ -351,28 +348,12 @@ public class GuiContainerManager {
|
||||
|
||||
drawItems.renderItemAndEffectIntoGUI(fontRenderer, renderEngine, itemstack, offsetX, offsetY);
|
||||
|
||||
final ItemNameOverlayMode nameMode = NEIClientConfig.getItemNameOverlayMode();
|
||||
int nameHeight = 0;
|
||||
if (nameMode != ItemNameOverlayMode.OFF) {
|
||||
nameHeight = stackSize.isEmpty() ? 11
|
||||
: Math.max(
|
||||
0,
|
||||
(int) (16
|
||||
- (Math.max(fontRenderer.FONT_HEIGHT, GuiDraw.fontRenderer.FONT_HEIGHT) - 1)
|
||||
* scale
|
||||
- 1));
|
||||
}
|
||||
|
||||
if (scale != 1f && !stackSize.isEmpty()) {
|
||||
drawBigStackSize(offsetX, offsetY, stackSize, scale);
|
||||
stackSize = "";
|
||||
}
|
||||
|
||||
drawItems.renderItemOverlayIntoGUI(fontRenderer, renderEngine, itemstack, offsetX, offsetY, stackSize);
|
||||
if (nameMode != ItemNameOverlayMode.OFF) {
|
||||
ItemNameOverlayRenderer.INSTANCE
|
||||
.render(nameMode, itemstack, fontRenderer, offsetX, offsetY, nameHeight);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -639,9 +620,6 @@ public class GuiContainerManager {
|
||||
* Called at the start of drawScreen
|
||||
*/
|
||||
public void preDraw() {
|
||||
if (NEIClientConfig.getItemNameOverlayMode() != ItemNameOverlayMode.OFF) {
|
||||
ItemNameOverlayRenderer.INSTANCE.refreshFontState();
|
||||
}
|
||||
for (IContainerDrawHandler drawHandler : drawHandlers) drawHandler.onPreDraw(window);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package codechicken.nei.item;
|
||||
|
||||
public enum ItemNameOverlayMode {
|
||||
|
||||
ITEMS(true, false),
|
||||
FLUIDS(false, true),
|
||||
ALL(true, true),
|
||||
OFF(false, false);
|
||||
|
||||
private final boolean items;
|
||||
private final boolean fluids;
|
||||
|
||||
private ItemNameOverlayMode(boolean items, boolean fluids) {
|
||||
this.items = items;
|
||||
this.fluids = fluids;
|
||||
}
|
||||
|
||||
public boolean includes(boolean fluidDisplay) {
|
||||
return fluidDisplay ? fluids : items;
|
||||
}
|
||||
|
||||
public static ItemNameOverlayMode fromConfigValue(int value) {
|
||||
return switch (value) {
|
||||
case 0 -> ITEMS;
|
||||
case 1 -> FLUIDS;
|
||||
case 2 -> ALL;
|
||||
default -> OFF;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,679 +0,0 @@
|
||||
package codechicken.nei.item;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.text.BreakIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.resources.Language;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.util.font.FontRendering;
|
||||
import com.gtnewhorizon.gtnhlib.util.font.IFontParameters;
|
||||
|
||||
import codechicken.nei.LRUCache;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class ItemNameOverlayRenderer {
|
||||
|
||||
public static final ItemNameOverlayRenderer INSTANCE = new ItemNameOverlayRenderer();
|
||||
|
||||
public static final int[] OUTLINE_STEPS = { -1, -1, 1, 0, 1, 0, 0, 1, 0, 1, -1, 0, -1, 0, 0, -1 };
|
||||
|
||||
public final FloatBuffer matrixBuffer = BufferUtils.createFloatBuffer(16);
|
||||
public final LRUCache<LayoutKey, LabelLayout> layouts = new LRUCache<>(2048);
|
||||
public final LayoutKey lookupKey = new LayoutKey(null, "", 0, 0, false);
|
||||
public final GuiScaleCache guiScaleCache = new GuiScaleCache();
|
||||
public ItemNameOverlaySettings settings = ItemNameOverlaySettings.defaults();
|
||||
public Object fontState;
|
||||
public String languageCode;
|
||||
public BreakIterator lineBreaker;
|
||||
public long cacheRevision;
|
||||
|
||||
public void render(ItemNameOverlayMode mode, ItemStack stack, FontRenderer font, int x, int y,
|
||||
int availableHeight) {
|
||||
if (mode == ItemNameOverlayMode.OFF || stack == null || stack.getItem() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean fluidDisplay = StackInfo.isFluidDisplayItem(stack);
|
||||
if (!mode.includes(fluidDisplay)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String name;
|
||||
if (fluidDisplay) {
|
||||
final FluidStack fluid = StackInfo.getFluid(stack);
|
||||
name = fluid != null ? fluid.getLocalizedName() : stack.getDisplayName();
|
||||
// Fluid renderers own their amount overlay, so reserve its bottom row.
|
||||
availableHeight = Math.min(availableHeight, font.getUnicodeFlag() ? 8 : 11);
|
||||
} else {
|
||||
name = stack.getDisplayName();
|
||||
}
|
||||
|
||||
final ItemNameOverlaySettings currentSettings = settings;
|
||||
drawLabel(
|
||||
font,
|
||||
name,
|
||||
x + (16 - currentSettings.width) / 2f,
|
||||
(float) y,
|
||||
currentSettings.width,
|
||||
availableHeight,
|
||||
currentSettings);
|
||||
}
|
||||
|
||||
public void drawLabel(FontRenderer font, String text, float x, float y, int width, int height,
|
||||
ItemNameOverlaySettings currentSettings) {
|
||||
if (text == null || text.isEmpty() || width <= 0 || height <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
refreshLineBreaker();
|
||||
lookupKey.set(font, text, width, height, font.getUnicodeFlag());
|
||||
LabelLayout layout = layouts.get(lookupKey);
|
||||
if (layout == null) {
|
||||
// Stored keys are copies; the reusable lookup key never enters the cache.
|
||||
final LayoutKey key = new LayoutKey(lookupKey);
|
||||
layout = createLayout(key, currentSettings);
|
||||
layouts.put(key, layout);
|
||||
}
|
||||
if (layout.lines.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int guiScale = readRenderTransform();
|
||||
final float scaleX = matrixBuffer.get(0);
|
||||
final float scaleY = matrixBuffer.get(5);
|
||||
final float translateX = matrixBuffer.get(12);
|
||||
final float translateY = matrixBuffer.get(13);
|
||||
final float pixelScaleX = Math.abs(scaleX) * guiScale;
|
||||
final float pixelScaleY = Math.abs(scaleY) * guiScale;
|
||||
if (pixelScaleX <= 0 || pixelScaleY <= 0) {
|
||||
return;
|
||||
}
|
||||
final float inverseScale = 1f / layout.scale;
|
||||
final float pixelWidth = inverseScale / pixelScaleX;
|
||||
final float pixelHeight = inverseScale / pixelScaleY;
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_CURRENT_BIT | GL11.GL_COLOR_BUFFER_BIT);
|
||||
GL11.glPushMatrix();
|
||||
try {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glTranslatef(x, y, 0);
|
||||
GL11.glScalef(layout.scale, layout.scale, 1);
|
||||
|
||||
for (LabelLine line : layout.lines) {
|
||||
final float alignedX = (alignToPixel(x + line.x, translateX, scaleX, guiScale) - x) * inverseScale;
|
||||
final float alignedY = (alignToPixel(y + line.y, translateY, scaleY, guiScale) - y) * inverseScale;
|
||||
GL11.glTranslatef(alignedX, alignedY, 0);
|
||||
if (currentSettings.outline) {
|
||||
drawOutlinedLine(font, line.text, pixelWidth, pixelHeight);
|
||||
} else {
|
||||
font.drawString(line.text, 0, 0, 0xFFFFFFFF);
|
||||
}
|
||||
GL11.glTranslatef(-alignedX, -alignedY, 0);
|
||||
}
|
||||
} finally {
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSettings(ItemNameOverlaySettings settings) {
|
||||
Objects.requireNonNull(settings);
|
||||
if (!this.settings.equals(settings)) {
|
||||
this.settings = settings;
|
||||
clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshFontState() {
|
||||
refreshLineBreaker();
|
||||
final Object currentState = FontAccess.currentState();
|
||||
if (!Objects.equals(fontState, currentState)) {
|
||||
fontState = currentState;
|
||||
clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
layouts.clear();
|
||||
lookupKey.set(null, "", 0, 0, false);
|
||||
if (lineBreaker != null) {
|
||||
lineBreaker.setText("");
|
||||
}
|
||||
cacheRevision++;
|
||||
}
|
||||
|
||||
public void refreshLineBreaker() {
|
||||
final Language language = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage();
|
||||
String currentCode = language != null ? language.getLanguageCode() : "en_US";
|
||||
if (currentCode == null || currentCode.isEmpty()) {
|
||||
currentCode = "en_US";
|
||||
}
|
||||
if (lineBreaker == null || !currentCode.equals(languageCode)) {
|
||||
Locale locale = Locale.forLanguageTag(currentCode.replace('_', '-'));
|
||||
if (locale.getLanguage().isEmpty()) {
|
||||
locale = Locale.ENGLISH;
|
||||
}
|
||||
languageCode = currentCode;
|
||||
lineBreaker = BreakIterator.getLineInstance(locale);
|
||||
clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
public long getCacheRevision() {
|
||||
return cacheRevision;
|
||||
}
|
||||
|
||||
public int readRenderTransform() {
|
||||
final Minecraft minecraft = Minecraft.getMinecraft();
|
||||
final int guiScale = guiScaleCache.getScaleFactor(minecraft);
|
||||
matrixBuffer.clear();
|
||||
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, matrixBuffer);
|
||||
return guiScale;
|
||||
}
|
||||
|
||||
public float alignToPixel(float coordinate, float translation, float scale, int guiScale) {
|
||||
final float screenPosition = (translation + coordinate * scale) * guiScale;
|
||||
return (Math.round(screenPosition) / (float) guiScale - translation) / scale;
|
||||
}
|
||||
|
||||
public LabelLayout createLayout(LayoutKey key, ItemNameOverlaySettings settings) {
|
||||
final FontRenderer font = key.font;
|
||||
final String text = sanitizeText(key.text);
|
||||
final float minimumScale = settings.minimumScale;
|
||||
if (text.isEmpty()) {
|
||||
return new LabelLayout(font, key.width, Collections.emptyList(), minimumScale);
|
||||
}
|
||||
|
||||
final boolean unicode = key.unicode || hasUnicodeCharacters(text);
|
||||
final float preferredScale = Math.max(minimumScale, unicode ? settings.unicodeFontScale : settings.fontScale);
|
||||
final float lineHeight = FontAccess.lineHeight(font);
|
||||
final float singleLineScale = Math.min(
|
||||
preferredScale,
|
||||
Math.min(key.width / (float) Math.max(1, getTextWidth(font, text)), key.height / (lineHeight + 1)));
|
||||
if (singleLineScale >= minimumScale && fitsCharacterLimit(text, settings.maxCharacters)) {
|
||||
return new LabelLayout(font, key.width, Collections.singletonList(text), singleLineScale);
|
||||
}
|
||||
|
||||
final int maximumWidth = (int) Math.nextUp(key.width / minimumScale);
|
||||
final LineBreaks breaks = createLineBreaks(font, text, maximumWidth, settings.maxCharacters);
|
||||
int availableLines = 1;
|
||||
for (int lineCount = 2; lineCount <= settings.maxLines; lineCount++) {
|
||||
final float wrappedScale = Math.min(preferredScale, key.height / (lineHeight * lineCount + 1));
|
||||
if (wrappedScale < minimumScale) {
|
||||
break;
|
||||
}
|
||||
availableLines = lineCount;
|
||||
List<String> completeLines = wrapText(
|
||||
font,
|
||||
text,
|
||||
maximumWidth,
|
||||
lineCount,
|
||||
settings.maxCharacters,
|
||||
breaks,
|
||||
false);
|
||||
if (fitsWidth(font, completeLines, maximumWidth, settings.maxCharacters)) {
|
||||
// Find the narrowest complete split before reducing the configured multi-line scale.
|
||||
int lowerWidth = 1;
|
||||
int upperWidth = maximumWidth;
|
||||
while (lowerWidth < upperWidth) {
|
||||
final int candidateWidth = lowerWidth + (upperWidth - lowerWidth) / 2;
|
||||
final List<String> candidateLines = wrapText(
|
||||
font,
|
||||
text,
|
||||
candidateWidth,
|
||||
lineCount,
|
||||
settings.maxCharacters,
|
||||
breaks,
|
||||
false);
|
||||
if (fitsWidth(font, candidateLines, candidateWidth, settings.maxCharacters)) {
|
||||
upperWidth = candidateWidth;
|
||||
completeLines = candidateLines;
|
||||
} else {
|
||||
lowerWidth = candidateWidth + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int widestLine = 1;
|
||||
for (String line : completeLines) {
|
||||
widestLine = Math.max(widestLine, getTextWidth(font, line));
|
||||
}
|
||||
final float completeScale = Math.min(wrappedScale, key.width / (float) widestLine);
|
||||
return new LabelLayout(font, key.width, completeLines, completeScale);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final float croppedScale = Math.min(preferredScale, key.height / (lineHeight * availableLines + 1));
|
||||
if (croppedScale < minimumScale) {
|
||||
return new LabelLayout(font, key.width, Collections.emptyList(), croppedScale);
|
||||
}
|
||||
|
||||
final int textWidth = (int) (key.width / croppedScale);
|
||||
final List<String> shortenedLines = new ArrayList<>(
|
||||
wrapText(font, text, textWidth, availableLines, settings.maxCharacters, breaks, true));
|
||||
if (shortenedLines.isEmpty()) {
|
||||
final String line = ellipsize(font, text, textWidth, settings.maxCharacters);
|
||||
if (!line.isEmpty()) {
|
||||
shortenedLines.add(line);
|
||||
}
|
||||
} else {
|
||||
final int lastLine = shortenedLines.size() - 1;
|
||||
shortenedLines
|
||||
.set(lastLine, ellipsize(font, shortenedLines.get(lastLine), textWidth, settings.maxCharacters));
|
||||
}
|
||||
return new LabelLayout(font, key.width, shortenedLines, croppedScale);
|
||||
}
|
||||
|
||||
public LineBreaks createLineBreaks(FontRenderer font, String text, int maximumWidth, int maxCharacters) {
|
||||
lineBreaker.setText(text);
|
||||
final int[] boundaries = new int[text.length() + 1];
|
||||
int count = 0;
|
||||
for (int boundary = lineBreaker.first(); boundary != BreakIterator.DONE; boundary = lineBreaker.next()) {
|
||||
boundaries[count++] = boundary;
|
||||
}
|
||||
final boolean[] splittable = new boolean[count - 1];
|
||||
for (int index = 0; index < splittable.length; index++) {
|
||||
final String token = text.substring(boundaries[index], boundaries[index + 1]).trim();
|
||||
splittable[index] = getTextWidth(font, token) > maximumWidth || !fitsCharacterLimit(token, maxCharacters);
|
||||
}
|
||||
return new LineBreaks(boundaries, count, splittable);
|
||||
}
|
||||
|
||||
public List<String> wrapText(FontRenderer font, String text, int width, int maxLines, int maxCharacters,
|
||||
LineBreaks breaks, boolean forceFit) {
|
||||
final List<String> lines = new ArrayList<>(maxLines);
|
||||
int start = 0;
|
||||
while (start < text.length()) {
|
||||
final String remainder = text.substring(start);
|
||||
if (lines.size() == maxLines - 1) {
|
||||
lines.add(remainder);
|
||||
break;
|
||||
}
|
||||
String prefix = trimToWidth(font, remainder, width);
|
||||
if (maxCharacters > 0) {
|
||||
prefix = trimCharacters(prefix, maxCharacters);
|
||||
}
|
||||
if (prefix.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
int fittedEnd = start + prefix.length();
|
||||
// Trailing spaces do not consume visible line width or the character limit.
|
||||
while (fittedEnd < text.length() && text.charAt(fittedEnd) <= ' ') {
|
||||
fittedEnd++;
|
||||
}
|
||||
final int split = breaks.select(start, fittedEnd, forceFit);
|
||||
lines.add(text.substring(start, split).trim());
|
||||
start = split;
|
||||
while (start < text.length() && text.charAt(start) <= ' ') {
|
||||
start++;
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
public boolean fitsWidth(FontRenderer font, List<String> lines, int width, int maxCharacters) {
|
||||
if (lines.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (String line : lines) {
|
||||
if (getTextWidth(font, line) > width || !fitsCharacterLimit(line, maxCharacters)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String sanitizeText(String text) {
|
||||
text = FontAccess.preprocess(text);
|
||||
if (text.indexOf('\u00a7') >= 0) {
|
||||
final StringBuilder plain = new StringBuilder(text.length());
|
||||
for (int index = 0; index < text.length(); index++) {
|
||||
if (text.charAt(index) == '\u00a7' && index + 1 < text.length()) {
|
||||
index++;
|
||||
} else {
|
||||
plain.append(text.charAt(index));
|
||||
}
|
||||
}
|
||||
text = plain.toString();
|
||||
}
|
||||
return text.replace('\n', ' ').replace('\r', ' ').replace('\t', ' ').trim();
|
||||
}
|
||||
|
||||
public String ellipsize(FontRenderer font, String text, int width, int maxCharacters) {
|
||||
if (getTextWidth(font, text) <= width && fitsCharacterLimit(text, maxCharacters)) {
|
||||
return text;
|
||||
}
|
||||
|
||||
String suffix = trimToWidth(font, "...", width);
|
||||
if (maxCharacters > 0) {
|
||||
suffix = trimCharacters(suffix, maxCharacters);
|
||||
}
|
||||
String prefix = trimToWidth(font, text, width - getTextWidth(font, suffix)).trim();
|
||||
if (maxCharacters > 0) {
|
||||
prefix = trimCharacters(prefix, maxCharacters - suffix.codePointCount(0, suffix.length()));
|
||||
}
|
||||
String shortened = prefix + suffix;
|
||||
// Custom glyph spacing at the join must be measured as part of the complete string.
|
||||
while (!prefix.isEmpty() && getTextWidth(font, shortened) > width) {
|
||||
prefix = prefix.substring(0, prefix.offsetByCodePoints(prefix.length(), -1)).trim();
|
||||
shortened = prefix + suffix;
|
||||
}
|
||||
return shortened;
|
||||
}
|
||||
|
||||
public String trimToWidth(FontRenderer font, String text, int width) {
|
||||
if (width <= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
final String trimmed = FontAccess.trimToWidth(font, text, width);
|
||||
final int length = trimmed.length();
|
||||
return length > 0 && Character.isHighSurrogate(trimmed.charAt(length - 1)) ? trimmed.substring(0, length - 1)
|
||||
: trimmed;
|
||||
}
|
||||
|
||||
public static int getTextWidth(FontRenderer font, String text) {
|
||||
return FontAccess.width(font, text);
|
||||
}
|
||||
|
||||
public static boolean fitsCharacterLimit(String text, int limit) {
|
||||
return limit == 0 || text.codePointCount(0, text.length()) <= limit;
|
||||
}
|
||||
|
||||
public static String trimCharacters(String text, int limit) {
|
||||
final int count = Math.min(limit, text.codePointCount(0, text.length()));
|
||||
return text.substring(0, text.offsetByCodePoints(0, count));
|
||||
}
|
||||
|
||||
public boolean hasUnicodeCharacters(String text) {
|
||||
for (int index = 0; index < text.length(); index++) {
|
||||
if (text.charAt(index) > 255) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void drawOutlinedLine(FontRenderer font, String text, float pixelWidth, float pixelHeight) {
|
||||
// Visit each neighboring screen pixel once, then return to the center.
|
||||
for (int index = 0; index < OUTLINE_STEPS.length; index += 2) {
|
||||
GL11.glTranslatef(OUTLINE_STEPS[index] * pixelWidth, OUTLINE_STEPS[index + 1] * pixelHeight, 0);
|
||||
font.drawString(text, 0, 0, 0xFF000000);
|
||||
}
|
||||
GL11.glTranslatef(pixelWidth, 0, 0);
|
||||
font.drawString(text, 0, 0, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
public static class LineBreaks {
|
||||
|
||||
public final int[] boundaries;
|
||||
public final int count;
|
||||
public final boolean[] splittable;
|
||||
|
||||
public LineBreaks(int[] boundaries, int count, boolean[] splittable) {
|
||||
this.boundaries = boundaries;
|
||||
this.count = count;
|
||||
this.splittable = splittable;
|
||||
}
|
||||
|
||||
public int select(int start, int fittedEnd, boolean forceFit) {
|
||||
final int boundary = boundaries[atOrBefore(fittedEnd)];
|
||||
if (boundary > start) {
|
||||
return boundary;
|
||||
}
|
||||
final int token = atOrBefore(start);
|
||||
// Keep normal tokens whole during scale selection; split only when constraints require it.
|
||||
return forceFit || splittable[token] ? fittedEnd : boundaries[token + 1];
|
||||
}
|
||||
|
||||
public int atOrBefore(int offset) {
|
||||
final int index = Arrays.binarySearch(boundaries, 0, count, offset);
|
||||
return index >= 0 ? index : -index - 2;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LabelLayout {
|
||||
|
||||
public final LabelLine[] lines;
|
||||
public final float scale;
|
||||
|
||||
public LabelLayout(FontRenderer font, int width, List<String> texts, float scale) {
|
||||
this.lines = new LabelLine[texts.size()];
|
||||
this.scale = scale;
|
||||
final float lineHeight = FontAccess.lineHeight(font);
|
||||
final float anchorOffset = (lineHeight - font.FONT_HEIGHT) / 2f;
|
||||
for (int index = 0; index < texts.size(); index++) {
|
||||
final String text = texts.get(index);
|
||||
this.lines[index] = new LabelLine(
|
||||
text,
|
||||
(width - getTextWidth(font, text) * scale) / 2f,
|
||||
(1 + anchorOffset + index * lineHeight) * scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LabelLine {
|
||||
|
||||
public final String text;
|
||||
public final float x;
|
||||
public final float y;
|
||||
|
||||
public LabelLine(String text, float x, float y) {
|
||||
this.text = text;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FontAccess {
|
||||
|
||||
public static final boolean GTNH_FONTS = hasFontAPI();
|
||||
public static Method settingsMethod = findSettingsMethod();
|
||||
|
||||
public static boolean hasFontAPI() {
|
||||
if (!Loader.isModLoaded("gtnhlib")) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
FontRendering.class.getMethod("preprocessText", String.class);
|
||||
IFontParameters.class.getMethod("getCharWidthFine", char.class);
|
||||
IFontParameters.class.getMethod("getGlyphScaleX");
|
||||
IFontParameters.class.getMethod("getGlyphScaleY");
|
||||
IFontParameters.class.getMethod("getGlyphSpacing");
|
||||
IFontParameters.class.getMethod("getWhitespaceScale");
|
||||
return true;
|
||||
} catch (ReflectiveOperationException | LinkageError ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Method findSettingsMethod() {
|
||||
if (!Loader.isModLoaded("angelica")) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Class.forName(
|
||||
"com.gtnewhorizons.angelica.client.font.GlyphSettings",
|
||||
false,
|
||||
ItemNameOverlayRenderer.class.getClassLoader()).getMethod("current");
|
||||
} catch (ReflectiveOperationException | LinkageError ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object currentState() {
|
||||
if (settingsMethod != null) {
|
||||
try {
|
||||
return settingsMethod.invoke(null, (Object[]) null);
|
||||
} catch (ReflectiveOperationException | LinkageError ignored) {
|
||||
settingsMethod = null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String preprocess(String text) {
|
||||
return GTNH_FONTS ? FontRendering.preprocessText(text) : text;
|
||||
}
|
||||
|
||||
public static int width(FontRenderer font, String text) {
|
||||
// Preserve custom FontRenderer subclasses' own measurement overrides.
|
||||
return GTNH_FONTS && font.getClass() == FontRenderer.class && font instanceof IFontParameters
|
||||
? FontRendering.getStringWidth(text, font)
|
||||
: font.getStringWidth(text);
|
||||
}
|
||||
|
||||
public static String trimToWidth(FontRenderer font, String text, int width) {
|
||||
return GTNH_FONTS && font.getClass() == FontRenderer.class && font instanceof IFontParameters
|
||||
? FontRendering.trimStringToWidth(text, width, false, font)
|
||||
: font.trimStringToWidth(text, width);
|
||||
}
|
||||
|
||||
public static float lineHeight(FontRenderer font) {
|
||||
if (GTNH_FONTS && font instanceof IFontParameters parameters) {
|
||||
final float scale = parameters.getGlyphScaleY();
|
||||
if (Float.isFinite(scale) && scale > 0) {
|
||||
return font.FONT_HEIGHT * scale;
|
||||
}
|
||||
}
|
||||
return font.FONT_HEIGHT;
|
||||
}
|
||||
|
||||
public static void applyMetrics(LayoutKey key, FontRenderer font) {
|
||||
if (GTNH_FONTS && font instanceof IFontParameters parameters) {
|
||||
key.glyphScaleX = parameters.getGlyphScaleX();
|
||||
key.glyphScaleY = parameters.getGlyphScaleY();
|
||||
key.glyphSpacing = parameters.getGlyphSpacing();
|
||||
key.whitespaceScale = parameters.getWhitespaceScale();
|
||||
} else {
|
||||
key.glyphScaleX = 1;
|
||||
key.glyphScaleY = 1;
|
||||
key.glyphSpacing = 0;
|
||||
key.whitespaceScale = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class GuiScaleCache {
|
||||
|
||||
public int displayWidth = -1;
|
||||
public int displayHeight = -1;
|
||||
public int setting;
|
||||
public boolean unicode;
|
||||
public int scaleFactor;
|
||||
|
||||
public int getScaleFactor(Minecraft minecraft) {
|
||||
final boolean currentUnicode = minecraft.func_152349_b();
|
||||
if (displayWidth != minecraft.displayWidth || displayHeight != minecraft.displayHeight
|
||||
|| setting != minecraft.gameSettings.guiScale
|
||||
|| unicode != currentUnicode) {
|
||||
displayWidth = minecraft.displayWidth;
|
||||
displayHeight = minecraft.displayHeight;
|
||||
setting = minecraft.gameSettings.guiScale;
|
||||
unicode = currentUnicode;
|
||||
scaleFactor = new ScaledResolution(minecraft, displayWidth, displayHeight).getScaleFactor();
|
||||
}
|
||||
return scaleFactor;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LayoutKey {
|
||||
|
||||
public FontRenderer font;
|
||||
public String text;
|
||||
public int width;
|
||||
public int height;
|
||||
public int fontHeight;
|
||||
public float glyphScaleX;
|
||||
public float glyphScaleY;
|
||||
public float glyphSpacing;
|
||||
public float whitespaceScale;
|
||||
public boolean unicode;
|
||||
public int hash;
|
||||
|
||||
public LayoutKey(FontRenderer font, String text, int width, int height, boolean unicode) {
|
||||
set(font, text, width, height, unicode);
|
||||
}
|
||||
|
||||
public LayoutKey(LayoutKey key) {
|
||||
this.font = key.font;
|
||||
this.text = key.text;
|
||||
this.width = key.width;
|
||||
this.height = key.height;
|
||||
this.fontHeight = key.fontHeight;
|
||||
this.glyphScaleX = key.glyphScaleX;
|
||||
this.glyphScaleY = key.glyphScaleY;
|
||||
this.glyphSpacing = key.glyphSpacing;
|
||||
this.whitespaceScale = key.whitespaceScale;
|
||||
this.unicode = key.unicode;
|
||||
this.hash = key.hash;
|
||||
}
|
||||
|
||||
public void set(FontRenderer font, String text, int width, int height, boolean unicode) {
|
||||
this.font = font;
|
||||
this.text = text;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.fontHeight = font != null ? font.FONT_HEIGHT : 0;
|
||||
if (font != null) {
|
||||
FontAccess.applyMetrics(this, font);
|
||||
} else {
|
||||
this.glyphScaleX = 1;
|
||||
this.glyphScaleY = 1;
|
||||
this.glyphSpacing = 0;
|
||||
this.whitespaceScale = 1;
|
||||
}
|
||||
this.unicode = unicode;
|
||||
int hash = System.identityHashCode(font);
|
||||
hash = 31 * hash + text.hashCode();
|
||||
hash = 31 * hash + width;
|
||||
hash = 31 * hash + height;
|
||||
hash = 31 * hash + fontHeight;
|
||||
hash = 31 * hash + Float.floatToIntBits(glyphScaleX);
|
||||
hash = 31 * hash + Float.floatToIntBits(glyphScaleY);
|
||||
hash = 31 * hash + Float.floatToIntBits(glyphSpacing);
|
||||
hash = 31 * hash + Float.floatToIntBits(whitespaceScale);
|
||||
this.hash = 31 * hash + Boolean.hashCode(unicode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof LayoutKey key && font == key.font
|
||||
&& text.equals(key.text)
|
||||
&& width == key.width
|
||||
&& height == key.height
|
||||
&& fontHeight == key.fontHeight
|
||||
&& Float.compare(glyphScaleX, key.glyphScaleX) == 0
|
||||
&& Float.compare(glyphScaleY, key.glyphScaleY) == 0
|
||||
&& Float.compare(glyphSpacing, key.glyphSpacing) == 0
|
||||
&& Float.compare(whitespaceScale, key.whitespaceScale) == 0
|
||||
&& unicode == key.unicode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package codechicken.nei.item;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ItemNameOverlaySettings {
|
||||
|
||||
private static final ItemNameOverlaySettings DEFAULT = new ItemNameOverlaySettings(
|
||||
ItemNameOverlayMode.OFF,
|
||||
0.5f,
|
||||
0.5625f,
|
||||
0.3f,
|
||||
18,
|
||||
0,
|
||||
2,
|
||||
true);
|
||||
|
||||
public final ItemNameOverlayMode mode;
|
||||
public final float fontScale;
|
||||
public final float unicodeFontScale;
|
||||
public final float minimumScale;
|
||||
public final int width;
|
||||
public final int maxCharacters;
|
||||
public final int maxLines;
|
||||
public final boolean outline;
|
||||
|
||||
public ItemNameOverlaySettings(ItemNameOverlayMode mode, float fontScale, float unicodeFontScale,
|
||||
float minimumScale, int width, int maxCharacters, int maxLines, boolean outline) {
|
||||
this.mode = Objects.requireNonNull(mode);
|
||||
this.fontScale = normalizeScale(fontScale, 0.5f);
|
||||
this.unicodeFontScale = normalizeScale(unicodeFontScale, 0.5625f);
|
||||
this.minimumScale = normalizeScale(minimumScale, 0.3f);
|
||||
this.width = Math.max(4, Math.min(32, width));
|
||||
this.maxCharacters = Math.max(0, Math.min(256, maxCharacters));
|
||||
this.maxLines = Math.max(1, Math.min(4, maxLines));
|
||||
this.outline = outline;
|
||||
}
|
||||
|
||||
public static ItemNameOverlaySettings defaults() {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
private static float normalizeScale(float value, float fallback) {
|
||||
return Float.isFinite(value) ? Math.max(0.1f, Math.min(2f, value)) : fallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof ItemNameOverlaySettings settings && getClass() == other.getClass()
|
||||
&& mode == settings.mode
|
||||
&& fontScale == settings.fontScale
|
||||
&& unicodeFontScale == settings.unicodeFontScale
|
||||
&& minimumScale == settings.minimumScale
|
||||
&& width == settings.width
|
||||
&& maxCharacters == settings.maxCharacters
|
||||
&& maxLines == settings.maxLines
|
||||
&& outline == settings.outline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = mode.hashCode();
|
||||
hash = 31 * hash + Float.floatToIntBits(fontScale);
|
||||
hash = 31 * hash + Float.floatToIntBits(unicodeFontScale);
|
||||
hash = 31 * hash + Float.floatToIntBits(minimumScale);
|
||||
hash = 31 * hash + width;
|
||||
hash = 31 * hash + maxCharacters;
|
||||
hash = 31 * hash + maxLines;
|
||||
return 31 * hash + Boolean.hashCode(outline);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +1,117 @@
|
||||
package codechicken.nei.moboverlay;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/** The mob spawn overlay quads, compiled into a GL display list. */
|
||||
/**
|
||||
* {@code MobOverlayDisplayList} compiles the overlay quads of each chunk column of a {@link MobOverlayScan} box into
|
||||
* one GL display list. A compile rebuilds only the lists whose {@link MobOverlayScan#readChunkVersion} changed.
|
||||
*/
|
||||
public final class MobOverlayDisplayList {
|
||||
|
||||
private int listId = -1;
|
||||
private static final int NO_LIST = -1;
|
||||
|
||||
private int firstListId = NO_LIST;
|
||||
private int parentListId = NO_LIST;
|
||||
private int anchorX;
|
||||
private int anchorY;
|
||||
private int anchorZ;
|
||||
private int chunkSpan;
|
||||
private boolean[] isCompiled = new boolean[0];
|
||||
private boolean[] hasFaces = new boolean[0];
|
||||
private int[] compiledChunkVersion = new int[0];
|
||||
private int modesVersion;
|
||||
private MobOverlayStyle style;
|
||||
private int minX;
|
||||
private int minY;
|
||||
private int minZ;
|
||||
private long compiledTicks;
|
||||
private int compilingChunk;
|
||||
|
||||
/**
|
||||
* Compiles after a {@link MobOverlayScan#getModesVersion} change are debounced to one per {@code MIN_COMPILE_TICKS}
|
||||
* ticks, because the version changes several times per second while the player moves fast, and a compile runs for a
|
||||
* millisecond or more.
|
||||
*/
|
||||
public boolean isCompileDue(int currentModesVersion, MobOverlayStyle currentStyle, long worldTicks) {
|
||||
final int MIN_COMPILE_TICKS = 5;
|
||||
if (listId < 0 || style != currentStyle) return true;
|
||||
if (firstListId == NO_LIST || style != currentStyle) return true;
|
||||
|
||||
// after a dimension change or a server switch, `worldTicks` can be lower than `compiledTicks`
|
||||
final boolean isWaitOver = worldTicks - compiledTicks >= MIN_COMPILE_TICKS || worldTicks < compiledTicks;
|
||||
return modesVersion != currentModesVersion && isWaitOver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quad positions are relative to block ({@link MobOverlayScan#getMinX}, {@link MobOverlayScan#getMinY},
|
||||
* {@link MobOverlayScan#getMinZ}) of {@code scan}.
|
||||
*/
|
||||
public void beginCompile(MobOverlayScan scan, MobOverlayStyle newStyle, long worldTicks) {
|
||||
if (listId < 0) listId = GLAllocation.generateDisplayLists(1);
|
||||
if (chunkSpan != scan.getChunkSpan()) resize(scan.getChunkSpan());
|
||||
if (style != newStyle) Arrays.fill(isCompiled, false);
|
||||
modesVersion = scan.getModesVersion();
|
||||
style = newStyle;
|
||||
minX = scan.getMinX();
|
||||
minY = scan.getMinY();
|
||||
minZ = scan.getMinZ();
|
||||
compiledTicks = worldTicks;
|
||||
GL11.glNewList(listId, GL11.GL_COMPILE);
|
||||
anchorX = scan.getMinX();
|
||||
anchorY = scan.getMinY();
|
||||
anchorZ = scan.getMinZ();
|
||||
}
|
||||
|
||||
public void endCompile() {
|
||||
public boolean beginChunk(MobOverlayScan scan, int chunkX, int chunkZ) {
|
||||
final int chunk = scan.findChunk(chunkX, chunkZ);
|
||||
final int chunkVersion = scan.readChunkVersion(chunkX, chunkZ);
|
||||
if (isCompiled[chunk] && compiledChunkVersion[chunk] == chunkVersion) return false;
|
||||
|
||||
isCompiled[chunk] = true;
|
||||
compiledChunkVersion[chunk] = chunkVersion;
|
||||
compilingChunk = chunk;
|
||||
GL11.glNewList(firstListId + chunk, GL11.GL_COMPILE);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void endChunk(boolean hasChunkFaces) {
|
||||
GL11.glEndList();
|
||||
hasFaces[compilingChunk] = hasChunkFaces;
|
||||
}
|
||||
|
||||
public void endCompile(MobOverlayScan scan) {
|
||||
GL11.glNewList(parentListId, GL11.GL_COMPILE);
|
||||
for (int chunkX = scan.getMinChunkX(); chunkX <= scan.getMaxChunkX(); chunkX++) {
|
||||
for (int chunkZ = scan.getMinChunkZ(); chunkZ <= scan.getMaxChunkZ(); chunkZ++) {
|
||||
final int chunk = scan.findChunk(chunkX, chunkZ);
|
||||
if (!hasFaces[chunk]) continue;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(
|
||||
(chunkX << MobOverlayScan.CHUNK_SHIFT) - anchorX,
|
||||
0,
|
||||
(chunkZ << MobOverlayScan.CHUNK_SHIFT) - anchorZ);
|
||||
GL11.glCallList(firstListId + chunk);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
/** The model view matrix is relative to block ({@code cameraX}, {@code cameraY}, {@code cameraZ}). */
|
||||
public void draw(int cameraX, int cameraY, int cameraZ) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(minX - cameraX, minY - cameraY, minZ - cameraZ);
|
||||
GL11.glCallList(listId);
|
||||
GL11.glTranslated(anchorX - cameraX, anchorY - cameraY, anchorZ - cameraZ);
|
||||
GL11.glCallList(parentListId);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
if (listId < 0) return;
|
||||
private void resize(int newChunkSpan) {
|
||||
final int chunkCount = newChunkSpan * newChunkSpan;
|
||||
delete();
|
||||
|
||||
GLAllocation.deleteDisplayLists(listId);
|
||||
listId = -1;
|
||||
chunkSpan = newChunkSpan;
|
||||
firstListId = GLAllocation.generateDisplayLists(chunkCount + 1);
|
||||
parentListId = firstListId + chunkCount;
|
||||
|
||||
isCompiled = new boolean[chunkCount];
|
||||
hasFaces = new boolean[chunkCount];
|
||||
compiledChunkVersion = new int[chunkCount];
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
if (firstListId == NO_LIST) return;
|
||||
|
||||
GLAllocation.deleteDisplayLists(firstListId);
|
||||
firstListId = NO_LIST;
|
||||
parentListId = NO_LIST;
|
||||
chunkSpan = 0;
|
||||
Arrays.fill(isCompiled, false);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package codechicken.nei.moboverlay;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
/** Vertex builder for one block's top face in the mob spawn overlay. */
|
||||
/** {@code MobOverlayFace} adds the vertices of the mark on one block's top face to {@link Tessellator#instance}. */
|
||||
public final class MobOverlayFace {
|
||||
|
||||
public static final byte OUTSIDE_SCAN = -2;
|
||||
@@ -36,7 +36,7 @@ public final class MobOverlayFace {
|
||||
|
||||
public boolean isJoined(int offsetX, int offsetZ) {
|
||||
final byte neighbourMode = neighbourModes[indexNeighbour(offsetX, offsetZ)];
|
||||
// no outline along the edge of the scan
|
||||
// `MobOverlayStyle.CONNECTED` doesn't outline the edge of the scan
|
||||
return neighbourMode == neighbourModes[indexNeighbour(0, 0)] || neighbourMode == OUTSIDE_SCAN;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ public final class MobOverlayFace {
|
||||
addTexturedVertex(1, 0);
|
||||
}
|
||||
|
||||
/** @param offsetX 0 at the west edge, 1 at the east edge */
|
||||
public void addVertex(double offsetX, double offsetZ) {
|
||||
Tessellator.instance.addVertex(x + offsetX, y, z + offsetZ);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package codechicken.nei.moboverlay;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
@@ -16,11 +18,8 @@ import net.minecraft.world.chunk.Chunk;
|
||||
import codechicken.lib.math.MathHelper;
|
||||
|
||||
/**
|
||||
* Spawn modes, and the tops of flat blocks such as carpets, in a box around the player. The spawn modes are from
|
||||
* {@link Column#getSpawnMode}: 0 for no spawns, 1 for night only and 2 for any time. The box moves with the player once
|
||||
* the player is a few blocks from the box's centre, and {@link #update} scans only the blocks that enter the box.
|
||||
* {@link #update} rescans the column of a block or light change on the next tick. On each tick, {@link #update} also
|
||||
* rescans a slice of the columns, for changes with no block update, such as a boat that moves into the box.
|
||||
* Spawn modes of the blocks in a box around the player. {@link #update} scans the blocks that enter the box, the
|
||||
* columns of block and light changes, and a slice of the box on each tick.
|
||||
*/
|
||||
public final class MobOverlayScan {
|
||||
|
||||
@@ -31,6 +30,7 @@ public final class MobOverlayScan {
|
||||
public static final int MIN_VERTICAL_RADIUS = 4;
|
||||
public static final int MAX_VERTICAL_RADIUS = 64;
|
||||
public static final int DEFAULT_VERTICAL_RADIUS = 16;
|
||||
public static final int CHUNK_SHIFT = 4;
|
||||
private static final int RECENTRE_DISTANCE = 4;
|
||||
private static final int VERTICAL_RECENTRE_DISTANCE = 2;
|
||||
private static final int RESCAN_TICKS = 40;
|
||||
@@ -47,18 +47,21 @@ public final class MobOverlayScan {
|
||||
// a ring buffer over the box, indexed by `findCell()`. A cell has the spawn mode in the bits of `SPAWN_MODE_MASK`,
|
||||
// and `Column.readCoverTop()` shifted left by `COVER_TOP_SHIFT`
|
||||
private byte[] modes = new byte[0];
|
||||
// indexed by `findColumn(x, z)`
|
||||
private boolean[] dirty = new boolean[0];
|
||||
private boolean hasDirtyColumns;
|
||||
private int minX;
|
||||
private int minY;
|
||||
private int minZ;
|
||||
// the slice rescan of `update()` continues from this column, numbered `(x - minX) * span + (z - minZ)`
|
||||
private int nextRescanColumn;
|
||||
private int modesVersion;
|
||||
private int chunkSpan;
|
||||
// The version of a chunk column changes when a cell in or beside the chunk column changes, and when an edge of the
|
||||
// box moves into, out of, within or across the chunk column. A full scan and a vertical move change the version of
|
||||
// every chunk column
|
||||
private int[] chunkVersions = new int[0];
|
||||
private int chunkVersionCount;
|
||||
private boolean hasModes;
|
||||
private long scannedTick;
|
||||
// world of `modes`, with `changeListener` added
|
||||
private World scannedWorld;
|
||||
|
||||
public void clear() {
|
||||
@@ -71,17 +74,17 @@ public final class MobOverlayScan {
|
||||
height = 0;
|
||||
modes = new byte[0];
|
||||
dirty = new boolean[0];
|
||||
chunkSpan = 0;
|
||||
chunkVersions = new int[0];
|
||||
hasModes = false;
|
||||
scannedWorld = null;
|
||||
// `Chunk.worldObj` references the world
|
||||
// a world isn't garbage-collected while `column.chunk` references a chunk of the world
|
||||
column.chunk = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan every column in this call after {@link #clear}, a change of either radius, a world change, or a move of
|
||||
* {@link #getSpan} blocks or more across or {@link #getHeight} blocks or more up or down. {@code newRadius} is
|
||||
* clamped between {@link #MIN_RADIUS} and {@link #MAX_RADIUS}, and {@code newVerticalRadius} between
|
||||
* {@link #MIN_VERTICAL_RADIUS} and {@link #MAX_VERTICAL_RADIUS}.
|
||||
* {@link #getSpan} blocks or more across or {@link #getHeight} blocks or more up or down.
|
||||
*/
|
||||
public void update(Entity entity, int newRadius, int newVerticalRadius) {
|
||||
final World world = entity.worldObj;
|
||||
@@ -112,11 +115,14 @@ public final class MobOverlayScan {
|
||||
if (isChanged) modesVersion++;
|
||||
}
|
||||
|
||||
/** The version changes when a spawn mode or the top of a flat block changes, or the box moves. */
|
||||
public int getModesVersion() {
|
||||
return modesVersion;
|
||||
}
|
||||
|
||||
public int getChunkSpan() {
|
||||
return chunkSpan;
|
||||
}
|
||||
|
||||
public int getSpan() {
|
||||
return span;
|
||||
}
|
||||
@@ -137,19 +143,44 @@ public final class MobOverlayScan {
|
||||
return minZ;
|
||||
}
|
||||
|
||||
/** {@code i} and {@code j} are from 0 to {@link #getSpan}, and {@code k} is from 0 to {@link #getHeight}. */
|
||||
public byte readSpawnMode(int i, int k, int j) {
|
||||
return (byte) (modes[findCell(minX + i, minY + k, minZ + j)] & SPAWN_MODE_MASK);
|
||||
public int getMinChunkX() {
|
||||
return minX >> CHUNK_SHIFT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Height of the overlay above the bottom of the block, so that a flat block such as a carpet does not cover the
|
||||
* overlay. The indices are those of {@link #readSpawnMode}.
|
||||
*/
|
||||
public double readOverlayYOffset(int i, int k, int j) {
|
||||
public int getMaxChunkX() {
|
||||
return (minX + span - 1) >> CHUNK_SHIFT;
|
||||
}
|
||||
|
||||
public int getMinChunkZ() {
|
||||
return minZ >> CHUNK_SHIFT;
|
||||
}
|
||||
|
||||
public int getMaxChunkZ() {
|
||||
return (minZ + span - 1) >> CHUNK_SHIFT;
|
||||
}
|
||||
|
||||
public int readChunkVersion(int chunkX, int chunkZ) {
|
||||
return chunkVersions[findChunk(chunkX, chunkZ)];
|
||||
}
|
||||
|
||||
public byte readSpawnMode(int i, int k, int j) {
|
||||
return extractSpawnMode(modes[findCell(minX + i, minY + k, minZ + j)]);
|
||||
}
|
||||
|
||||
public void readColumn(int i, int j, byte[] columnCells) {
|
||||
final int columnStart = findColumn(minX + i, minZ + j) * height;
|
||||
final int bottomCell = Math.floorMod(minY, height);
|
||||
System.arraycopy(modes, columnStart + bottomCell, columnCells, 0, height - bottomCell);
|
||||
System.arraycopy(modes, columnStart, columnCells, height - bottomCell, bottomCell);
|
||||
}
|
||||
|
||||
public static byte extractSpawnMode(byte cell) {
|
||||
return (byte) (cell & SPAWN_MODE_MASK);
|
||||
}
|
||||
|
||||
public static double computeOverlayYOffset(byte cell) {
|
||||
final double OVERLAY_GAP = 0.02;
|
||||
final int coverTopSteps = modes[findCell(minX + i, minY + k, minZ + j)] >> COVER_TOP_SHIFT;
|
||||
return (double) coverTopSteps / COVER_TOP_STEPS + OVERLAY_GAP;
|
||||
return (double) (cell >> COVER_TOP_SHIFT) / COVER_TOP_STEPS + OVERLAY_GAP;
|
||||
}
|
||||
|
||||
private void resize(int newRadius, int newVerticalRadius) {
|
||||
@@ -159,6 +190,8 @@ public final class MobOverlayScan {
|
||||
height = 2 * newVerticalRadius + 1;
|
||||
modes = new byte[span * span * height];
|
||||
dirty = new boolean[span * span];
|
||||
chunkSpan = ((span - 1) >> CHUNK_SHIFT) + 2;
|
||||
chunkVersions = new int[chunkSpan * chunkSpan];
|
||||
hasModes = false;
|
||||
nextRescanColumn = 0;
|
||||
}
|
||||
@@ -172,6 +205,7 @@ public final class MobOverlayScan {
|
||||
scanColumn(x, z);
|
||||
}
|
||||
}
|
||||
markAllChunks();
|
||||
hasModes = true;
|
||||
modesVersion++;
|
||||
scannedTick = scannedWorld.getTotalWorldTime();
|
||||
@@ -189,6 +223,7 @@ public final class MobOverlayScan {
|
||||
final int offsetX = centreX - radius - minX;
|
||||
if (Math.abs(offsetX) > RECENTRE_DISTANCE) {
|
||||
final int enteringX = offsetX > 0 ? minX + span : minX + offsetX;
|
||||
markMovedEdgeChunks(minX, offsetX, Axis.X);
|
||||
minX += offsetX;
|
||||
for (int x = enteringX; x < enteringX + Math.abs(offsetX); x++) {
|
||||
for (int z = minZ; z < minZ + span; z++) {
|
||||
@@ -201,6 +236,7 @@ public final class MobOverlayScan {
|
||||
final int offsetZ = centreZ - radius - minZ;
|
||||
if (Math.abs(offsetZ) > RECENTRE_DISTANCE) {
|
||||
final int enteringZ = offsetZ > 0 ? minZ + span : minZ + offsetZ;
|
||||
markMovedEdgeChunks(minZ, offsetZ, Axis.Z);
|
||||
minZ += offsetZ;
|
||||
for (int x = minX; x < minX + span; x++) {
|
||||
for (int z = enteringZ; z < enteringZ + Math.abs(offsetZ); z++) {
|
||||
@@ -220,6 +256,7 @@ public final class MobOverlayScan {
|
||||
column.scan(enteringY, enteringY + Math.abs(offsetY));
|
||||
}
|
||||
}
|
||||
markAllChunks();
|
||||
isMoved = true;
|
||||
}
|
||||
return isMoved;
|
||||
@@ -230,7 +267,7 @@ public final class MobOverlayScan {
|
||||
boolean isChanged = false;
|
||||
for (int x = minX; x < minX + span; x++) {
|
||||
for (int z = minZ; z < minZ + span; z++) {
|
||||
if (dirty[findColumn(x, z)]) isChanged |= scanColumn(x, z);
|
||||
if (dirty[findColumn(x, z)]) isChanged |= rescanColumn(x, z);
|
||||
}
|
||||
}
|
||||
return isChanged;
|
||||
@@ -243,7 +280,7 @@ public final class MobOverlayScan {
|
||||
for (; nextRescanColumn < sliceEnd; nextRescanColumn++) {
|
||||
final int x = minX + nextRescanColumn / span;
|
||||
final int z = minZ + nextRescanColumn % span;
|
||||
isChanged |= scanColumn(x, z);
|
||||
isChanged |= rescanColumn(x, z);
|
||||
}
|
||||
if (nextRescanColumn >= columnCount) nextRescanColumn = 0;
|
||||
return isChanged;
|
||||
@@ -256,6 +293,60 @@ public final class MobOverlayScan {
|
||||
return column.scan(minY, minY + height);
|
||||
}
|
||||
|
||||
private boolean rescanColumn(int x, int z) {
|
||||
final boolean isChanged = scanColumn(x, z);
|
||||
// the connected outline of a cell depends on the spawn modes of the cells beside the cell
|
||||
if (isChanged) {
|
||||
for (int offsetX = -1; offsetX <= 1; offsetX++) {
|
||||
for (int offsetZ = -1; offsetZ <= 1; offsetZ++) {
|
||||
markChunk((x + offsetX) >> CHUNK_SHIFT, (z + offsetZ) >> CHUNK_SHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
private void markMovedEdgeChunks(int oldMin, int offset, Axis moveAxis) {
|
||||
final int lowFrom = Math.min(oldMin, oldMin + offset);
|
||||
final int lowTo = Math.max(oldMin, oldMin + offset);
|
||||
markStripChunks(lowFrom, lowTo, moveAxis);
|
||||
markStripChunks(lowFrom + span - 1, lowTo + span - 1, moveAxis);
|
||||
}
|
||||
|
||||
private void markStripChunks(int from, int to, Axis moveAxis) {
|
||||
final int acrossMin = switch (moveAxis) {
|
||||
case X -> minZ;
|
||||
case Z -> minX;
|
||||
};
|
||||
final int minAcrossChunk = acrossMin >> CHUNK_SHIFT;
|
||||
final int maxAcrossChunk = (acrossMin + span - 1) >> CHUNK_SHIFT;
|
||||
for (int alongChunk = from >> CHUNK_SHIFT; alongChunk <= to >> CHUNK_SHIFT; alongChunk++) {
|
||||
for (int acrossChunk = minAcrossChunk; acrossChunk <= maxAcrossChunk; acrossChunk++) {
|
||||
final int chunkX = switch (moveAxis) {
|
||||
case X -> alongChunk;
|
||||
case Z -> acrossChunk;
|
||||
};
|
||||
final int chunkZ = switch (moveAxis) {
|
||||
case X -> acrossChunk;
|
||||
case Z -> alongChunk;
|
||||
};
|
||||
markChunk(chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void markAllChunks() {
|
||||
Arrays.fill(chunkVersions, ++chunkVersionCount);
|
||||
}
|
||||
|
||||
private void markChunk(int chunkX, int chunkZ) {
|
||||
chunkVersions[findChunk(chunkX, chunkZ)] = ++chunkVersionCount;
|
||||
}
|
||||
|
||||
public int findChunk(int chunkX, int chunkZ) {
|
||||
return Math.floorMod(chunkX, chunkSpan) * chunkSpan + Math.floorMod(chunkZ, chunkSpan);
|
||||
}
|
||||
|
||||
private int findColumn(int x, int z) {
|
||||
return Math.floorMod(x, span) * span + Math.floorMod(z, span);
|
||||
}
|
||||
@@ -264,10 +355,6 @@ public final class MobOverlayScan {
|
||||
return findColumn(x, z) * height + Math.floorMod(y, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link #moveTo} reads a column's chunk, biome and highest non-air block in the box, and {@link #scan} reads the
|
||||
* column's blocks.
|
||||
*/
|
||||
private final class Column {
|
||||
|
||||
private final Entity dummyEntity = new EntityPig(null);
|
||||
@@ -285,10 +372,8 @@ public final class MobOverlayScan {
|
||||
canBiomeSpawn = !biome.getSpawnableList(EnumCreatureType.monster).isEmpty()
|
||||
&& biome.getSpawningChance() > 0;
|
||||
chunk = scannedWorld.getChunkFromBlockCoords(x, z);
|
||||
// `getHeightValue()` is the height above the highest block with a light opacity above 0. A block with a
|
||||
// light opacity of 0 can be higher: Tinkers' Construct slime grass, a hopper or a snow layer. A mob can
|
||||
// spawn on top of slime grass, a hopper or a full snow block. Search the blocks for the highest non-air
|
||||
// block
|
||||
// `getHeightValue()` skips blocks with a light opacity of 0. A mob can spawn on some of these blocks, such
|
||||
// as Tinkers' Construct slime grass, a hopper or a full snow block. Search for the highest non-air block
|
||||
final int SECTION_HEIGHT = 16;
|
||||
int y = Math.min(minY + height - 1, chunk.getTopFilledSegment() + SECTION_HEIGHT - 1);
|
||||
while (y >= minY && chunk.getBlock(x & 15, y, z & 15).isAir(chunk.worldObj, x, y, z)) y--;
|
||||
@@ -308,12 +393,15 @@ public final class MobOverlayScan {
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
/** The spawn mode of the block at height {@code y} in this column. */
|
||||
private byte getSpawnMode(int y) {
|
||||
if (y >= chunk.worldObj.getHeight()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// vanilla `SpawnerAnimals.canCreatureTypeSpawnAtLocation()` rejects a normal cube in the cell (such as the
|
||||
// inside of a stone block). Test the block before the light read
|
||||
if (chunk.getBlock(x & 15, y, z & 15).isNormalCube()) return 0;
|
||||
|
||||
if (chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15) >= 8 || !SpawnerAnimals
|
||||
.canCreatureTypeSpawnAtLocation(EnumCreatureType.monster, chunk.worldObj, x, y, z)) {
|
||||
return 0;
|
||||
@@ -337,10 +425,6 @@ public final class MobOverlayScan {
|
||||
return (byte) (chunk.getSavedLightValue(EnumSkyBlock.Sky, x & 15, y, z & 15) >= 8 ? 1 : 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* The top of the block at height {@code y}, in fractions of a block with {@link MobOverlayScan#COVER_TOP_STEPS}
|
||||
* as the denominator, or 0 for a tall block.
|
||||
*/
|
||||
private int readCoverTop(int y) {
|
||||
final double MAX_COVER_TOP = 0.25;
|
||||
final Block block = chunk.getBlock(x & 15, y, z & 15);
|
||||
@@ -352,7 +436,6 @@ public final class MobOverlayScan {
|
||||
}
|
||||
}
|
||||
|
||||
/** Marks the columns of the block and light changes in {@link #scannedWorld}. */
|
||||
private final class ChangeListener implements IWorldAccess {
|
||||
|
||||
@Override
|
||||
@@ -417,4 +500,9 @@ public final class MobOverlayScan {
|
||||
hasDirtyColumns = true;
|
||||
}
|
||||
}
|
||||
|
||||
private enum Axis {
|
||||
X,
|
||||
Z
|
||||
}
|
||||
}
|
||||
@@ -27,9 +27,7 @@ public enum MobOverlayStyle {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* A light tint, with a stronger outline around each area of one spawn mode, like a connected texture.
|
||||
*/
|
||||
/** A light tint and a stronger connected-texture outline around each area of one spawn mode. */
|
||||
CONNECTED(GL11.GL_QUADS) {
|
||||
|
||||
@Override
|
||||
@@ -39,7 +37,8 @@ public enum MobOverlayStyle {
|
||||
face.applyColor(Colouring.OVERLAY, MARK_ALPHA);
|
||||
for (int offsetX = -1; offsetX <= 1; offsetX++) {
|
||||
for (int offsetZ = -1; offsetZ <= 1; offsetZ++) {
|
||||
// a corner cell is drawn when either edge next to the corner is outlined, and on an inside corner
|
||||
// a corner cell is drawn when either edge next to the corner is outlined or when the corner is an
|
||||
// inside corner
|
||||
final boolean isOutline = !(face.isJoined(offsetX, offsetZ) && face.isJoined(offsetX, 0)
|
||||
&& face.isJoined(0, offsetZ));
|
||||
if (isOutline) face.addCell(offsetX, offsetZ, OUTLINE_WIDTH);
|
||||
@@ -48,7 +47,7 @@ public enum MobOverlayStyle {
|
||||
}
|
||||
},
|
||||
|
||||
/** A small square in the middle of the block, with no tint. */
|
||||
/** A small square in the middle of an untinted block. */
|
||||
SQUARE(GL11.GL_QUADS) {
|
||||
|
||||
@Override
|
||||
@@ -62,7 +61,7 @@ public enum MobOverlayStyle {
|
||||
}
|
||||
},
|
||||
|
||||
/** The pufferfish sticker. */
|
||||
/** A pufferfish sticker on the block. */
|
||||
PUFFERFISH("pufferfish", Colouring.STICKER) {
|
||||
|
||||
@Override
|
||||
@@ -102,7 +101,6 @@ public enum MobOverlayStyle {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
/** @return the {@link #formatName} of every style, separated by commas */
|
||||
public static String formatAllNames() {
|
||||
final StringJoiner names = new StringJoiner(", ");
|
||||
for (MobOverlayStyle style : values()) {
|
||||
@@ -119,7 +117,7 @@ public enum MobOverlayStyle {
|
||||
return switch (this) {
|
||||
case CONNECTED -> TINT_ALPHA;
|
||||
case SQUARE -> MARK_ALPHA;
|
||||
// opaque lines for X, and the alpha of the PNG for PUFFERFISH
|
||||
// the lines of X are opaque, and the alpha of PUFFERFISH comes from the PNG
|
||||
case X, PUFFERFISH -> 1.0F;
|
||||
};
|
||||
}
|
||||
@@ -127,9 +125,9 @@ public enum MobOverlayStyle {
|
||||
public abstract void addVertices(MobOverlayFace face);
|
||||
|
||||
public enum Colouring {
|
||||
/** Yellow where mobs spawn only at night, red where mobs spawn at any time. */
|
||||
/** Yellow marks where mobs spawn only at night and red marks where mobs spawn at any time. */
|
||||
OVERLAY,
|
||||
/** The texture's colours, tinted red where mobs spawn at any time. */
|
||||
/** Texture colours with a red tint where mobs spawn at any time. */
|
||||
STICKER
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
# Mob overlay TODO: spawn rules from other mods
|
||||
|
||||
`MobOverlayScan` reads the block, the light and the biome of each cell. Some mods set the result of Forge's
|
||||
`LivingSpawnEvent.CheckSpawn` from the monster's position, and `MobOverlayScan` doesn't call these handlers.
|
||||
|
||||
A monster spawns when the result is `ALLOW`, or when the result is `DEFAULT` and `getCanSpawnHere()` returns
|
||||
true. So `ALLOW` skips the light test.
|
||||
|
||||
## DENY: marked cells where a monster can't spawn
|
||||
|
||||
GregTech and Extra Utilities measure a range from the centre of the block.
|
||||
|
||||
| mod in 2.9.0 | handler | range | on the client? |
|
||||
|---|---|---|---|
|
||||
| GregTech Monster Repellator | `GTSpawnEventHandler.denyMobSpawn()` | sphere. The radius is 4 + 12 × tier without power and 16 + 48 × tier with power | no. `MTEMonsterRepellent.onPostTick()` registers the range on the server only |
|
||||
| Extra Utilities magnum torch | `EventHandlerServer.magnumTorchDenySpawn()` | ellipsoid 128 blocks out and 32 blocks up and down | maybe. `TileEntityAntiMobTorch` adds itself to the static `magnumTorchRegistry` and doesn't check the side. The bytecode is the source of this row, and the row isn't tested in game |
|
||||
| Extra Utilities chandelier | the same handler | sphere, radius 16 | maybe. The chandelier's tile entity is a `TileEntityAntiMobTorch` too |
|
||||
| Gadomancy aura pylon with Lux | `EventHandlerEntityServer.on(CheckSpawn)` | sphere, radius `AuraEffects.LUX.getRange()` | not checked. `AuraEffects.LUX` adds the pylon to `registeredLuxPylons` when the pylon's effect runs on an entity |
|
||||
| Blood Magic Ward of Sacrosanctity (`AW028SpawnWard`) | `AlchemicalWizardryEventHooks.onLivingSpawnEvent()` | box from the ritual's horizontal and vertical radii | not checked. `RitualEffectSpawnWard` fills `respawnMap` |
|
||||
| Botania Emptiness potion | `PotionEmptiness.onSpawn()` | sphere around each player with the effect | the player's potion effects |
|
||||
| ServerUtilities | `ServerUtilitiesWorldEventHandler.onMobSpawned()` | chunks of the safe spawn area, and claimed chunks by the team's settings | no. The claims are server data |
|
||||
| Et Futurum Requiem | `ServerEventHandler.spawnEvent()` | in the Nether, a cell above `ModBlocks.NETHER_WART` at meta 0, for a mob that doesn't fly | yes. The block below is in the client world |
|
||||
|
||||
## ALLOW: monsters spawn in unmarked lit cells
|
||||
|
||||
| mod in 2.9.0 | handler | range |
|
||||
|---|---|---|
|
||||
| Blood Magic Veil of Evil (`AW029VeilOfEvil`) | `AlchemicalWizardryEventHooks.onLivingSpawnEvent()` | box from the ritual's radii. Creepers are excluded |
|
||||
| Botania Bloodthirst potion | `PotionBloodthirst.onSpawn()` | sphere around each player with the effect |
|
||||
|
||||
Thaumcraft 4.2.3.5 doesn't have a `CheckSpawn` handler. The list comes from a scan of the 2.9.0 pack's jars for
|
||||
`LivingSpawnEvent$CheckSpawn`. Handlers that test only the mob type, the dimension or the mob count are left out:
|
||||
AMDIForge, EnderZoo, Automagy, the Extra Utilities Underdark, and the slime handlers of Biomes O' Plenty and Botania.
|
||||
The Extra Utilities siege handler (`EventHandlerSiege.SiegeCheckSpawn()`) isn't checked.
|
||||
|
||||
## To do
|
||||
|
||||
- [ ] Add an NEI API: a mod registers a cell test that returns `DENY`, `ALLOW` or `DEFAULT`. `MobOverlayScan` calls
|
||||
each test for each cell in the box.
|
||||
- [ ] Add an API call to mark an area dirty. `MobOverlayScan` then rescans the area when a range is added or
|
||||
removed.
|
||||
- [ ] Ask GregTech, Gadomancy, Blood Magic and ServerUtilities to send their ranges to the client.
|
||||
- [ ] Test the Extra Utilities registry on a client with a dedicated server.
|
||||
- [ ] Find out how the handlers combine. `GTSpawnEventHandler` returns early on `DENY`, and Blood Magic's handler
|
||||
changes `ALLOW` to `DEFAULT`, so the result depends on the order of the handlers on the event bus.
|
||||
@@ -434,30 +434,6 @@ nei.options.inventory.itemIDs=Item IDs
|
||||
nei.options.inventory.itemIDs.0=Hidden
|
||||
nei.options.inventory.itemIDs.1=Auto
|
||||
nei.options.inventory.itemIDs.2=Shown
|
||||
nei.options.inventory.itemNameOverlay=Icon Name Overlay
|
||||
nei.options.inventory.itemNameOverlay.tip=Configure names displayed on item and fluid icons.
|
||||
nei.options.inventory.itemNameOverlay.mode=Display Name on Icons
|
||||
nei.options.inventory.itemNameOverlay.mode.0=Items Only
|
||||
nei.options.inventory.itemNameOverlay.mode.1=Fluids Only
|
||||
nei.options.inventory.itemNameOverlay.mode.2=Shown
|
||||
nei.options.inventory.itemNameOverlay.mode.3=Hidden
|
||||
nei.options.inventory.itemNameOverlay.mode.tip=Choose which icons display names. Hover over an icon to see its full name.
|
||||
nei.options.inventory.itemNameOverlay.fontScale=Font Scale
|
||||
nei.options.inventory.itemNameOverlay.fontScale.tip=Preferred size for ordinary fonts. 1.0 is normal size; names may shrink to fit.
|
||||
nei.options.inventory.itemNameOverlay.unicodeFontScale=Unicode Font Scale
|
||||
nei.options.inventory.itemNameOverlay.unicodeFontScale.tip=Preferred size for Unicode fonts and text, including Chinese characters. 1.0 is normal size.
|
||||
nei.options.inventory.itemNameOverlay.minimumScale=Minimum Font Scale
|
||||
nei.options.inventory.itemNameOverlay.minimumScale.tip=Lower bound when shrinking names. This takes priority if it exceeds a preferred font scale.
|
||||
nei.options.inventory.itemNameOverlay.width=Label Width
|
||||
nei.options.inventory.itemNameOverlay.width.tip=Total label width in pixels, centered on each icon. Larger values can overlap neighboring icons.
|
||||
nei.options.inventory.itemNameOverlay.maxCharacters=Maximum Characters per Line
|
||||
nei.options.inventory.itemNameOverlay.maxCharacters.tip=0 = automatic. Limits Unicode characters per line, including any ellipsis.
|
||||
nei.options.inventory.itemNameOverlay.maxLines=Maximum Lines
|
||||
nei.options.inventory.itemNameOverlay.maxLines.tip=1 disables wrapping. The available height and minimum scale can reduce the actual number of lines.
|
||||
nei.options.inventory.itemNameOverlay.outline=Text Outline
|
||||
nei.options.inventory.itemNameOverlay.outline.true=Shown
|
||||
nei.options.inventory.itemNameOverlay.outline.false=Hidden
|
||||
nei.options.inventory.itemNameOverlay.outline.tip=Draw a one-screen-pixel black outline to keep names readable against the icon.
|
||||
nei.options.inventory.utilities=Utilities
|
||||
nei.options.inventory.utilities.tip=Select features for utility mode
|
||||
nei.options.inventory.utilities.time=Time
|
||||
|
||||
@@ -153,30 +153,6 @@ nei.options.inventory.itemIDs=物品ID
|
||||
nei.options.inventory.itemIDs.0=隐藏
|
||||
nei.options.inventory.itemIDs.1=自动
|
||||
nei.options.inventory.itemIDs.2=显示
|
||||
nei.options.inventory.itemNameOverlay=图标名称显示
|
||||
nei.options.inventory.itemNameOverlay.tip=调整物品和流体图标上的名称显示。
|
||||
nei.options.inventory.itemNameOverlay.mode=显示名称
|
||||
nei.options.inventory.itemNameOverlay.mode.0=仅物品
|
||||
nei.options.inventory.itemNameOverlay.mode.1=仅流体
|
||||
nei.options.inventory.itemNameOverlay.mode.2=显示
|
||||
nei.options.inventory.itemNameOverlay.mode.3=隐藏
|
||||
nei.options.inventory.itemNameOverlay.mode.tip=选择哪些图标显示名称,悬停可查看完整名称。
|
||||
nei.options.inventory.itemNameOverlay.fontScale=普通字体缩放
|
||||
nei.options.inventory.itemNameOverlay.fontScale.tip=普通字体的首选大小,1.0 表示正常字号;名称放不下时可自动缩小。
|
||||
nei.options.inventory.itemNameOverlay.unicodeFontScale=Unicode 字体缩放
|
||||
nei.options.inventory.itemNameOverlay.unicodeFontScale.tip=汉字等字符和 Unicode 字体的首选大小,1.0 表示正常字号。
|
||||
nei.options.inventory.itemNameOverlay.minimumScale=最小字体缩放
|
||||
nei.options.inventory.itemNameOverlay.minimumScale.tip=自动缩小名称时的下限;若大于首选缩放,则优先采用此下限。
|
||||
nei.options.inventory.itemNameOverlay.width=标签宽度
|
||||
nei.options.inventory.itemNameOverlay.width.tip=标签的总宽度(像素),始终以图标居中;较大值可能覆盖相邻图标。
|
||||
nei.options.inventory.itemNameOverlay.maxCharacters=每行最多字符数
|
||||
nei.options.inventory.itemNameOverlay.maxCharacters.tip=0 表示自动;限制每行的 Unicode 字符数,包括省略号。
|
||||
nei.options.inventory.itemNameOverlay.maxLines=最多行数
|
||||
nei.options.inventory.itemNameOverlay.maxLines.tip=设为 1 可关闭换行;实际行数还取决于可用高度和最小缩放。
|
||||
nei.options.inventory.itemNameOverlay.outline=文字描边
|
||||
nei.options.inventory.itemNameOverlay.outline.true=显示
|
||||
nei.options.inventory.itemNameOverlay.outline.false=隐藏
|
||||
nei.options.inventory.itemNameOverlay.outline.tip=在文字外绘制 1 个屏幕像素的黑色描边,方便辨认名称。
|
||||
nei.options.inventory.search.patternMode=搜索模式
|
||||
nei.options.inventory.search.patternMode.0=简单
|
||||
nei.options.inventory.search.patternMode.1=扩展
|
||||
|
||||
@@ -91,30 +91,6 @@ nei.options.inventory.itemIDs=物品ID
|
||||
nei.options.inventory.itemIDs.0=隱藏
|
||||
nei.options.inventory.itemIDs.1=自動
|
||||
nei.options.inventory.itemIDs.2=顯示
|
||||
nei.options.inventory.itemNameOverlay=圖示名稱顯示
|
||||
nei.options.inventory.itemNameOverlay.tip=調整物品和流體圖示上的名稱顯示。
|
||||
nei.options.inventory.itemNameOverlay.mode=顯示名稱
|
||||
nei.options.inventory.itemNameOverlay.mode.0=僅物品
|
||||
nei.options.inventory.itemNameOverlay.mode.1=僅流體
|
||||
nei.options.inventory.itemNameOverlay.mode.2=顯示
|
||||
nei.options.inventory.itemNameOverlay.mode.3=隱藏
|
||||
nei.options.inventory.itemNameOverlay.mode.tip=選擇哪些圖示顯示名稱,懸停可查看完整名稱。
|
||||
nei.options.inventory.itemNameOverlay.fontScale=普通字型縮放
|
||||
nei.options.inventory.itemNameOverlay.fontScale.tip=普通字型的首選大小,1.0 表示正常字級;名稱放不下時可自動縮小。
|
||||
nei.options.inventory.itemNameOverlay.unicodeFontScale=Unicode 字型縮放
|
||||
nei.options.inventory.itemNameOverlay.unicodeFontScale.tip=漢字等字元和 Unicode 字型的首選大小,1.0 表示正常字級。
|
||||
nei.options.inventory.itemNameOverlay.minimumScale=最小字型縮放
|
||||
nei.options.inventory.itemNameOverlay.minimumScale.tip=自動縮小名稱時的下限;若大於首選縮放,則優先採用此下限。
|
||||
nei.options.inventory.itemNameOverlay.width=標籤寬度
|
||||
nei.options.inventory.itemNameOverlay.width.tip=標籤的總寬度(像素),始終以圖示置中;較大值可能覆蓋相鄰圖示。
|
||||
nei.options.inventory.itemNameOverlay.maxCharacters=每行最多字元數
|
||||
nei.options.inventory.itemNameOverlay.maxCharacters.tip=0 表示自動;限制每行的 Unicode 字元數,包括省略號。
|
||||
nei.options.inventory.itemNameOverlay.maxLines=最多行數
|
||||
nei.options.inventory.itemNameOverlay.maxLines.tip=設為 1 可關閉換行;實際行數還取決於可用高度和最小縮放。
|
||||
nei.options.inventory.itemNameOverlay.outline=文字描邊
|
||||
nei.options.inventory.itemNameOverlay.outline.true=顯示
|
||||
nei.options.inventory.itemNameOverlay.outline.false=隱藏
|
||||
nei.options.inventory.itemNameOverlay.outline.tip=在文字外繪製 1 個螢幕像素的黑色描邊,方便辨認名稱。
|
||||
nei.options.inventory.search.patternMode=搜索模式
|
||||
nei.options.inventory.search.patternMode.0=簡單
|
||||
nei.options.inventory.search.patternMode.1=擴展
|
||||
|
||||
Reference in new issue
Block a user