Compare commits

..
Author SHA1 Message Date
Martin Robertz 21a1ae6fd9 update 2025-01-25 19:57:31 +01:00
slprime 04f2f5af2c Change Permutation Filter 2025-01-25 19:06:33 +02:00
27 changed files with 142 additions and 430 deletions

No files matched your search

+1 -3
View File
@@ -2,9 +2,7 @@
dependencies {
api('com.github.GTNewHorizons:CodeChickenCore:1.4.1:dev')
implementation('com.github.GTNewHorizons:GTNHLib:0.6.16:dev')
implementation('com.github.GTNewHorizons:GTNHLib:0.6.5:dev')
shadowImplementation('org.apache.commons:commons-csv:1.10.0')
compileOnly 'maven.modrinth:forge-essentials:7.5.1'
}
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+3 -2
View File
@@ -86,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -205,7 +206,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
-4
View File
@@ -1,8 +1,4 @@
// Add any additional repositiroes for your dependencies here
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.37'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.31'
}
@@ -46,9 +46,6 @@ import codechicken.nei.recipe.GuiRecipeTab;
import codechicken.nei.recipe.StackInfo;
import cpw.mods.fml.client.CustomModLoadingErrorDisplayException;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModClassLoader;
import cpw.mods.fml.common.discovery.ASMDataTable;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
@@ -257,29 +254,11 @@ public class ClientHandler {
}
public static void loadPluginsList() {
if (!Loader.isModLoaded("jarjar")) {
// Do the old style class discovery
final ClassDiscoverer classDiscoverer = new ClassDiscoverer(
test -> test.startsWith("NEI") && test.endsWith("Config.class"),
IConfigureNEI.class);
final ClassDiscoverer classDiscoverer = new ClassDiscoverer(
test -> test.startsWith("NEI") && test.endsWith("Config.class"),
IConfigureNEI.class);
NEIClientConfig.pluginsList.addAll(classDiscoverer.findClasses());
} else {
// If JarJar's loaded, the ASMDataTable now includes interfaces in addition to Annotations, so use that
// instead Includes a small change in behavior of no longer requiring the class to start with NEI and end
// with Config; This could easily be changed if desired, but the previous behavior was likely to speed
// things up by limiting the scope when looking at all of the jars and classes in the classpath.
final ASMDataTable dataTable = NEIModContainer.getAsmDataTable();
final ModClassLoader modClassLoader = (ModClassLoader) Loader.instance().getModClassLoader();
for (ASMDataTable.ASMData asmData : dataTable.getAll(IConfigureNEI.class.getName().replace('.', '/'))) {
final String className = asmData.getClassName().replace('/', '.');
try {
NEIClientConfig.pluginsList.add(Class.forName(className, true, modClassLoader));
} catch (ClassNotFoundException e) {
NEIClientConfig.logger.error("Failed to load plugin class {}", className, e);
}
}
}
NEIClientConfig.pluginsList.addAll(classDiscoverer.findClasses());
}
@SubscribeEvent
@@ -338,9 +317,8 @@ public class ClientHandler {
public void loadWorld(World world, boolean fromServer) {
if (world != lastworld) {
SMPmagneticItems.clear();
if (!NEIClientConfig.getBooleanSetting("world.overlays.lock")) {
WorldOverlayRenderer.reset();
}
WorldOverlayRenderer.reset();
if (!fromServer) {
NEIClientConfig.setHasSMPCounterPart(false);
NEIClientConfig.setInternalEnabled(false);
@@ -4,7 +4,6 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
@@ -103,39 +102,6 @@ public class FormattedTextField extends GuiTextField {
this.editable = p_146184_1_;
}
@Override
public void writeText(String p_146191_1_) {
String newText = "";
String substr = ChatAllowedCharacters.filerAllowedCharacters(p_146191_1_);
int cursorPosition = getCursorPosition();
int maxStringLength = getMaxStringLength();
String text = getText();
if (text.isEmpty()) {
newText = substr.substring(0, Math.min(maxStringLength, substr.length()));
cursorPosition = newText.length();
} else {
int selectionEnd = getSelectionEnd();
String textStart = text.substring(0, Math.min(cursorPosition, selectionEnd));
String textEnd = text.substring(Math.max(cursorPosition, selectionEnd));
newText = textStart + substr + textEnd;
if (newText.length() > maxStringLength) {
newText = newText.substring(0, maxStringLength);
}
cursorPosition = Math.min(textStart.length() + substr.length(), newText.length());
}
setText(newText);
setCursorPosition(cursorPosition);
}
@Override
public int getNthWordFromPos(int p_146183_1_, int p_146183_2_) {
return this.func_146197_a(p_146183_1_, p_146183_2_, true);
}
@Override
public void drawTextBox() {
if (this.getVisible()) {
@@ -234,7 +234,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
return true;
}
if (NEIClientConfig.isKeyHashDown("gui.next_tooltip") && GuiContainerManager.incrementTooltipPage()) {
if (NEIClientConfig.isKeyHashDown("gui.next_tooltip")) {
GuiContainerManager.incrementTooltipPage();
return true;
}
@@ -184,7 +184,7 @@ public class LayoutStyleMinecraft extends LayoutStyle {
final Rectangle4i area = new Rectangle4i(0, 0, 0, BUTTON_SIZE);
if (NEIClientConfig.isSearchWidgetCentered()) {
area.w = Math.min(gui.xSize, 176) - MARGIN * 2;
area.w = gui.xSize - MARGIN * 2;
area.x = (gui.width - area.w) / 2;
area.y = gui.height - BUTTON_SIZE - MARGIN;
} else if (NEIClientConfig.showItemQuantityWidget()) {
@@ -9,7 +9,6 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
@@ -46,6 +45,7 @@ import codechicken.nei.config.GuiHighlightTips;
import codechicken.nei.config.GuiNEIOptionList;
import codechicken.nei.config.GuiOptionList;
import codechicken.nei.config.GuiPanelSettings;
import codechicken.nei.config.OptionButton;
import codechicken.nei.config.OptionCycled;
import codechicken.nei.config.OptionGamemodes;
import codechicken.nei.config.OptionIntegerField;
@@ -61,7 +61,6 @@ import codechicken.nei.recipe.GuiRecipeTab;
import codechicken.nei.recipe.IRecipeHandler;
import codechicken.nei.recipe.RecipeCatalysts;
import codechicken.nei.recipe.RecipeInfo;
import codechicken.nei.util.NEIKeyboardUtils;
import codechicken.obfuscator.ObfuscationRun;
public class NEIClientConfig {
@@ -288,6 +287,19 @@ public class NEIClientConfig {
0,
OptionIntegerField.UNSIGNED_INT_MAX));
API.addOption(
new OptionButton(
"inventory.collapsibleItems.reloadLabel",
"inventory.collapsibleItems.reloadButton",
"inventory.collapsibleItems.reloadTip") {
@Override
public boolean onClick(int button) {
LayoutManager.markItemsDirty();
return super.onClick(button);
}
});
tag.getTag("inventory.itemzoom.enabled").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.itemzoom.enabled", true));
@@ -335,9 +347,6 @@ public class NEIClientConfig {
API.addOption(new OptionOpenGui("world.presets", GuiPresetList.class));
tag.getTag("world.overlays.lock").getBooleanValue(true);
API.addOption(new OptionToggleButton("world.overlays.lock", true));
tag.getTag("inventory.disableMouseScrollTransfer").getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.disableMouseScrollTransfer", true));
@@ -355,19 +364,6 @@ public class NEIClientConfig {
tag.getTag("inventory.gridRenderingCacheMode").getIntValue(0);
API.addOption(new OptionCycled("inventory.gridRenderingCacheMode", 3, true));
tag.getTag("inventory.gridRenderingCacheFPS").getIntValue(8);
API.addOption(new OptionIntegerField("inventory.gridRenderingCacheFPS", 1, 144) {
@Override
public boolean isEnabled() {
return OpenGlHelper.framebufferSupported && getIntSetting("inventory.gridRenderingCacheMode") == 1;
}
});
tag.getTag("inventory.hotkeysHelpText").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.hotkeysHelpText", true));
tag.getTag("loadPluginsInParallel").getBooleanValue(true);
tag.getTag("itemLoadingTimeout").getIntValue(500);
tag.getTag("command.creative").setDefaultValue("/gamemode {0} {1}");
@@ -793,7 +789,7 @@ public class NEIClientConfig {
private static final Map<String, String> keySettings = new HashMap<>();
public static int getKeyBinding(String string) {
final String key = keySettings.computeIfAbsent(string, s -> "keys." + s);
final String key = keySettings.computeIfAbsent(string, (s) -> "keys." + s);
return getSetting(key).getIntValue(Keyboard.KEY_NONE);
}
@@ -803,37 +799,17 @@ public class NEIClientConfig {
public static boolean isKeyHashDown(String string) {
final int hash = getKeyBinding(string);
if (hash != Keyboard.CHAR_NONE && Keyboard.getEventKeyState()) {
return KeyManager.keyStates.containsKey(string) ? hash == Keyboard.getEventKey()
: hash == NEIClientUtils.getKeyHash();
}
return false;
return hash != Keyboard.CHAR_NONE && hash == NEIClientUtils.getKeyHash();
}
public static String getKeyName(String keyBind) {
return getKeyName(keyBind, 0);
}
public static String getKeyName(String keyBind, int meta, int mouseBind) {
final int hash = getKeyBinding(keyBind);
if (hash == Keyboard.CHAR_NONE) {
return null;
}
return NEIClientUtils.getKeyName(hash + meta, mouseBind);
}
public static String getKeyName(String keyBind, int meta) {
final int hash = getKeyBinding(keyBind);
if (hash == Keyboard.CHAR_NONE) {
return null;
}
return NEIKeyboardUtils.getKeyName(hash + meta);
return NEIClientUtils.getKeyName(hash);
}
public static void bootNEI(World world) {
@@ -852,11 +828,8 @@ public class NEIClientConfig {
@Override
public void run() {
final Stream<Class<?>> stream = NEIClientConfig.getBooleanSetting("loadPluginsInParallel")
? NEIClientConfig.pluginsList.parallelStream()
: NEIClientConfig.pluginsList.stream();
stream.forEach(clazz -> {
NEIClientConfig.pluginsList.parallelStream().forEach(clazz -> {
try {
IConfigureNEI config = (IConfigureNEI) clazz.getConstructor().newInstance();
config.loadConfig();
@@ -50,8 +50,6 @@ import codechicken.lib.util.LangProxy;
import codechicken.nei.api.GuiInfo;
import codechicken.nei.api.IInfiniteItemHandler;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.util.NEIKeyboardUtils;
import codechicken.nei.util.NEIMouseUtils;
public class NEIClientUtils extends NEIServerUtils {
@@ -59,10 +57,25 @@ public class NEIClientUtils extends NEIServerUtils {
/** Formats a number with group separator and at most 2 fraction digits. */
private static final Map<Locale, DecimalFormat> decimalFormatters = new HashMap<>();
private static final Map<Integer, Integer> keyHashMap = new HashMap<>();
public static final int ALT_HASH = NEIKeyboardUtils.ALT_HASH;
public static final int SHIFT_HASH = NEIKeyboardUtils.SHIFT_HASH;
public static final int CTRL_HASH = NEIKeyboardUtils.CTRL_HASH;
public static final int ALT_HASH = 1 << 27;
public static final int SHIFT_HASH = 1 << 26;
public static final int CTRL_HASH = 1 << 25;
static {
keyHashMap.put(Keyboard.KEY_LSHIFT, SHIFT_HASH);
keyHashMap.put(Keyboard.KEY_RSHIFT, SHIFT_HASH);
keyHashMap.put(Keyboard.KEY_LCONTROL, CTRL_HASH);
keyHashMap.put(Keyboard.KEY_LCONTROL, CTRL_HASH);
keyHashMap.put(Keyboard.KEY_LMETA, CTRL_HASH);
keyHashMap.put(Keyboard.KEY_RMETA, CTRL_HASH);
keyHashMap.put(Keyboard.KEY_LMENU, ALT_HASH);
keyHashMap.put(Keyboard.KEY_LMENU, ALT_HASH);
}
public static Minecraft mc() {
return Minecraft.getMinecraft();
@@ -439,7 +452,7 @@ public class NEIClientUtils extends NEIServerUtils {
if (Keyboard.getEventKeyState()) {
final int keycode = Keyboard.getEventKey();
if (!NEIKeyboardUtils.isHashKey(keycode)) {
if (!keyHashMap.containsKey(keycode)) {
return getMetaHash() + keycode;
}
}
@@ -447,22 +460,45 @@ public class NEIClientUtils extends NEIServerUtils {
return Keyboard.CHAR_NONE;
}
public static String getKeyName(int keyBind, int mouseBind) {
public static String getKeyHashName(int keyBind) {
StringJoiner keyText = new StringJoiner(" + ");
String keyHash = keyBind == Keyboard.KEY_NONE ? "" : NEIKeyboardUtils.getKeyName(keyBind);
String mouseHash = mouseBind == NEIMouseUtils.MOUSE_BTN_NONE ? "" : NEIMouseUtils.getKeyName(mouseBind);
if (!keyHash.isEmpty()) {
keyText.add(keyHash);
if ((keyBind & CTRL_HASH) != 0) {
keyText.add(translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl"));
}
if (!mouseHash.isEmpty()) {
keyText.add(mouseHash);
if ((keyBind & SHIFT_HASH) != 0) {
keyText.add(translate("key.shift"));
}
if ((keyBind & ALT_HASH) != 0) {
keyText.add(translate("key.alt"));
}
return keyText.toString();
}
public static String getKeyName(int keyBind) {
keyBind = keyHashMap.getOrDefault(keyBind, keyBind);
StringJoiner keyText = new StringJoiner(" + ");
String hashText = getKeyHashName(keyBind);
int keyID = unHashKey(keyBind);
if (!hashText.isEmpty()) {
keyText.add(hashText);
}
if (keyID != Keyboard.CHAR_NONE || hashText.isEmpty()) {
keyText.add(Keyboard.getKeyName(keyID));
}
return keyText.toString();
}
public static int unHashKey(int keyBind) {
return keyBind & ~(CTRL_HASH | SHIFT_HASH | ALT_HASH);
}
public static void playClickSound() {
mc().getSoundHandler()
.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
@@ -25,7 +25,6 @@ import cpw.mods.fml.common.DummyModContainer;
import cpw.mods.fml.common.LoadController;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.discovery.ASMDataTable;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
@@ -42,8 +41,6 @@ public class NEIModContainer extends DummyModContainer {
private static boolean gregTech5Loaded;
private static boolean gtnhLibLoaded;
private static ASMDataTable asmDataTable;
public NEIModContainer() {
super(getModMetadata());
loadMetadata();
@@ -120,7 +117,6 @@ public class NEIModContainer extends DummyModContainer {
gregTech5Loaded = Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi_post");
gtnhLibLoaded = Loader.isModLoaded("gtnhlib");
if (CommonUtils.isClient()) ClientHandler.preInit();
asmDataTable = event.getAsmData();
}
@Subscribe
@@ -143,7 +139,6 @@ public class NEIModContainer extends DummyModContainer {
GuiRecipeTab.loadHandlerInfo();
ClientHandler.loadPluginsList();
ClientHandler.loadHandlerOrdering();
asmDataTable = null;
}
}
@@ -166,8 +161,4 @@ public class NEIModContainer extends DummyModContainer {
public Class<?> getCustomResourcePackClass() {
return getSource().isDirectory() ? FMLFolderResourcePack.class : FMLFileResourcePack.class;
}
public static ASMDataTable getAsmDataTable() {
return asmDataTable;
}
}
@@ -21,8 +21,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.permission.PermissionLevel;
import net.minecraftforge.permission.PermissionManager;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
@@ -46,8 +44,6 @@ public class NEIServerConfig {
public static HashMap<String, PlayerSave> playerSaves = new HashMap<>();
public static ItemStackMap<Set<String>> bannedItems = new ItemStackMap<>();
private static boolean doesPermAPIExist = false;
public static void load(World world) {
if (MinecraftServer.getServer() != server) {
logger.debug("Loading NEI Server");
@@ -57,16 +53,6 @@ public class NEIServerConfig {
dimTags.clear();
loadConfig();
loadBannedItems();
try {
Class.forName("net.minecraftforge.permission.PermissionManager");
doesPermAPIExist = true;
NEIActions.baseActions().forEach(
action -> {
PermissionManager.registerPermission("nei.permissions." + action, PermissionLevel.OP);
});
} catch (ClassNotFoundException ignored) {}
}
loadWorld(world);
}
@@ -135,12 +121,7 @@ public class NEIServerConfig {
}
public static boolean canPlayerPerformAction(String playername, String name) {
String node = "permissions." + NEIActions.base(name);
boolean hasPerm = doesPermAPIExist
? PermissionManager.checkPermission(ServerUtils.getPlayer(playername), "nei." + node)
: false;
return hasPerm || isPlayerInList(playername, getPlayerList(node), true);
return isPlayerInList(playername, getPlayerList("permissions." + NEIActions.base(name)), true);
}
public static boolean isPlayerInList(String playername, Set<String> list, boolean allowCards) {
@@ -82,11 +82,7 @@ public class PositionedStack {
}
public PositionedStack copy() {
PositionedStack pStack = new PositionedStack(
Arrays.stream(this.items).map(ItemStack::copy).toArray(ItemStack[]::new),
relx,
rely,
false);
PositionedStack pStack = new PositionedStack(Arrays.asList(items), relx, rely, false);
pStack.permutated = this.permutated;
return pStack;
}
@@ -33,7 +33,6 @@ import codechicken.nei.api.ItemFilter;
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerTooltipHandler;
import codechicken.nei.util.NEIMouseUtils;
public class SubsetWidget extends Button implements ItemFilterProvider, IContainerTooltipHandler {
@@ -842,21 +841,21 @@ public class SubsetWidget extends Button implements ItemFilterProvider, IContain
if (NEIClientConfig.canCheatItem(SubsetWidget.hoverStack)) {
hotkeys.put(
NEIClientUtils.getKeyName(NEIClientUtils.CTRL_HASH, NEIMouseUtils.MOUSE_BTN_LMB),
NEIClientUtils.translate("subsets.item.cheat.key"),
NEIClientUtils.translate("subsets.item.cheat"));
}
if (SubsetWidget.enableSearchBySubsets) {
hotkeys.put(
NEIClientUtils.getKeyName(NEIClientUtils.SHIFT_HASH, NEIMouseUtils.MOUSE_BTN_LMB),
NEIClientUtils.translate("subsets.item.search.key"),
NEIClientUtils.translate("subsets.item.search"));
}
hotkeys.put(
NEIMouseUtils.getKeyName(NEIMouseUtils.MOUSE_BTN_LMB),
NEIClientUtils.translate("subsets.item.show.key"),
NEIClientUtils.translate("subsets.item.show"));
hotkeys.put(
NEIMouseUtils.getKeyName(NEIMouseUtils.MOUSE_BTN_RMB),
NEIClientUtils.translate("subsets.item.hide.key"),
NEIClientUtils.translate("subsets.item.hide"));
} else if (SubsetWidget.hoverTag != null) {
hotkeys.put(
@@ -865,16 +864,12 @@ public class SubsetWidget extends Button implements ItemFilterProvider, IContain
if (SubsetWidget.enableSearchBySubsets) {
hotkeys.put(
NEIClientUtils.getKeyName(NEIClientUtils.SHIFT_HASH, NEIMouseUtils.MOUSE_BTN_LMB),
NEIClientUtils.translate("subsets.tag.search.key"),
NEIClientUtils.translate("subsets.tag.search"));
}
hotkeys.put(
NEIMouseUtils.getKeyName(NEIMouseUtils.MOUSE_BTN_LMB),
NEIClientUtils.translate("subsets.tag.show"));
hotkeys.put(
NEIMouseUtils.getKeyName(NEIMouseUtils.MOUSE_BTN_RMB),
NEIClientUtils.translate("subsets.tag.hide"));
hotkeys.put(NEIClientUtils.translate("subsets.tag.show.key"), NEIClientUtils.translate("subsets.tag.show"));
hotkeys.put(NEIClientUtils.translate("subsets.tag.hide.key"), NEIClientUtils.translate("subsets.tag.hide"));
}
return hotkeys;
@@ -8,7 +8,6 @@ import java.awt.Rectangle;
import org.lwjgl.input.Keyboard;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.util.NEIKeyboardUtils;
public class OptionKeyBind extends OptionButton {
@@ -124,10 +123,10 @@ public class OptionKeyBind extends OptionButton {
public String getButtonText() {
if (editing) {
return NEIKeyboardUtils.getHashName(NEIClientUtils.getMetaHash());
return NEIClientUtils.getKeyHashName(NEIClientUtils.getMetaHash());
}
return NEIKeyboardUtils.getKeyName(Math.max(getValue(), 0));
return NEIClientUtils.getKeyName(Math.max(getValue(), 0));
}
@Override
@@ -8,7 +8,7 @@ import codechicken.nei.TextField;
public class OptionTextField extends Option {
protected final TextField textField = new TextField("option-text-field") {
protected final TextField textField = new TextField("test") {
{
this.h = 20;
@@ -19,7 +19,6 @@ public class OptionTextField extends Option {
// don't override global if text hasn't changed
if (focused() && isValidValue(text()) && (!defaulting() || !text().equals(getTag().getValue()))) {
getTag().setValue(text());
OptionTextField.this.onTextChange(text());
}
}
@@ -28,20 +27,12 @@ public class OptionTextField extends Option {
if (!focus && !isValidValue(text())) setText(renderTag().getValue());
super.setFocus(focus);
}
@Override
public void draw(int mousex, int mousey) {
this.field.setEnabled(isEnabled());
super.draw(mousex, mousey);
}
};
public OptionTextField(String name) {
super(name);
}
public void onTextChange(String text) {}
@Override
public void update() {
textField.update();
@@ -56,10 +47,6 @@ public class OptionTextField extends Option {
return slot.slotWidth();
}
public boolean isEnabled() {
return true;
}
@Override
public void draw(int mousex, int mousey, float frame) {
GuiDraw.drawString(getPrefix(), 10, 6, -1);
@@ -72,14 +59,12 @@ public class OptionTextField extends Option {
@Override
public void keyTyped(char c, int keycode) {
if (isEnabled()) {
textField.handleKeyPress(keycode, c);
}
textField.handleKeyPress(keycode, c);
}
@Override
public void mouseClicked(int mousex, int mousey, int button) {
if (isEnabled() && textField.contains(mousex, mousey)) textField.handleClick(mousex, mousey, button);
if (textField.contains(mousex, mousey)) textField.handleClick(mousex, mousey, button);
}
@Override
@@ -89,7 +74,7 @@ public class OptionTextField extends Option {
@Override
public List<String> handleTooltip(int mousex, int mousey, List<String> currenttip) {
if (isEnabled() && new Rectangle4i(10, 0, textField.x - 10, 20).contains(mousex, mousey)) {
if (new Rectangle4i(10, 0, textField.x - 10, 20).contains(mousex, mousey)) {
String tip = translateN(name + ".tip");
if (!tip.equals(namespaced(name + ".tip"))) currenttip.add(tip);
}
@@ -554,8 +554,7 @@ public class GuiContainerManager {
}
ItemStack stack = getStackMouseOver(window);
boolean showTooltip = shouldShowTooltip(window);
if (tooltip.isEmpty() && showTooltip) { // mouseover tip, not holding an item
if (tooltip.isEmpty() && shouldShowTooltip(window)) { // mouseover tip, not holding an item
font = getFontRenderer(stack);
if (stack != null) {
tooltip = itemDisplayNameMultiline(stack, window, true);
@@ -570,7 +569,7 @@ public class GuiContainerManager {
if (!tooltip.isEmpty()) tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
if (showTooltip) {
if (shouldShowTooltip(window)) {
List<String> hotkeystips = collectHotkeyTips(mousex, mousey);
if (!hotkeystips.isEmpty()) {
@@ -616,19 +615,23 @@ public class GuiContainerManager {
}
private List<String> collectHotkeyTips(int mousex, int mousey) {
Map<String, String> hotkeys = new HashMap<>();
if (NEIClientUtils.altKey()) {
Map<String, String> hotkeys = new HashMap<>();
synchronized (instanceTooltipHandlers) {
for (IContainerTooltipHandler handler : instanceTooltipHandlers) {
hotkeys = handler.handleHotkeys(window, mousex, mousey, hotkeys);
}
synchronized (instanceTooltipHandlers) {
for (IContainerTooltipHandler handler : instanceTooltipHandlers) {
hotkeys = handler.handleHotkeys(window, mousex, mousey, hotkeys);
}
}
if (!hotkeys.isEmpty()) {
List<String> hotkeystips = new ArrayList<>();
if (!hotkeys.isEmpty()) {
List<String> hotkeystips = new ArrayList<>();
if (!NEIClientUtils.altKey()) {
hotkeystips.add(
EnumChatFormatting.GRAY + translate(
"showHotkeys",
EnumChatFormatting.GOLD + translate("key.alt") + EnumChatFormatting.GRAY));
} else {
Map<String, List<String>> messages = new HashMap<>();
hotkeys.remove(null);
hotkeys.remove("");
@@ -661,28 +664,9 @@ public class GuiContainerManager {
hotkeystips.set(
hotkeystips.size() - 1,
hotkeystips.get(hotkeystips.size() - 1) + GuiDraw.TOOLTIP_LINESPACE);
return hotkeystips;
}
} else if (NEIClientConfig.getBooleanSetting("inventory.hotkeysHelpText")) {
boolean existsHotkeys = false;
synchronized (instanceTooltipHandlers) {
for (IContainerTooltipHandler handler : instanceTooltipHandlers) {
if (!handler.handleHotkeys(window, mousex, mousey, new HashMap<>()).isEmpty()) {
existsHotkeys = true;
break;
}
}
}
if (existsHotkeys) {
return Collections.singletonList(
EnumChatFormatting.GRAY + translate(
"showHotkeys",
EnumChatFormatting.GOLD + translate("key.alt") + EnumChatFormatting.GRAY));
}
return hotkeystips;
}
return Collections.emptyList();
@@ -691,50 +675,39 @@ public class GuiContainerManager {
private String getHotkeyTip(List<String> keys, String message) {
return EnumChatFormatting.GOLD
+ String.join(EnumChatFormatting.DARK_GRAY + " / " + EnumChatFormatting.GOLD, keys)
+ EnumChatFormatting.DARK_GRAY
+ " - "
+ EnumChatFormatting.GRAY
+ " - "
+ message
+ EnumChatFormatting.RESET;
}
private static int tooltipPage;
private static int maxTooltipPage;
public static void drawPagedTooltip(FontRenderer font, int x, int y, List<String> list) {
if (list.isEmpty()) return;
List<List<String>> tooltips = splitTooltipByPage(list);
maxTooltipPage = tooltips.size();
tooltipPage = tooltipPage < maxTooltipPage ? tooltipPage : 0;
final List<String> currentTooltip = tooltips.get(tooltipPage);
if (maxTooltipPage > 1) {
final String pageTooltip = EnumChatFormatting.ITALIC + NEIClientUtils.translate(
"inventory.tooltip.page",
tooltipPage + 1,
maxTooltipPage,
NEIClientConfig.getKeyName("gui.next_tooltip"));
currentTooltip.set(
currentTooltip.size() - 1,
currentTooltip.get(currentTooltip.size() - 1) + GuiDraw.TOOLTIP_LINESPACE);
currentTooltip.add(pageTooltip);
tooltipPage = tooltipPage < tooltips.size() ? tooltipPage : 0;
if (tooltips.size() > 1) {
tooltips.get(tooltipPage).add(
EnumChatFormatting.ITALIC + NEIClientUtils.translate(
"inventory.tooltip.page",
tooltipPage + 1,
tooltips.size(),
NEIClientConfig.getKeyName("gui.next_tooltip")));
}
if (NEIModContainer.isGTNHLibLoaded()) {
drawMultilineTip(
font,
x,
y,
currentTooltip,
tooltips.get(tooltipPage),
RenderTooltipEventHelper.getBackgroundStart(),
RenderTooltipEventHelper.getBackgroundEnd(),
RenderTooltipEventHelper.getBorderStart(),
RenderTooltipEventHelper.getBorderEnd());
} else {
drawMultilineTip(font, x, y, currentTooltip);
return;
}
drawMultilineTip(font, x, y, tooltips.get(tooltipPage));
}
public static List<List<String>> splitTooltipByPage(List<String> list) {
@@ -746,9 +719,8 @@ public class GuiContainerManager {
GuiDraw.ITooltipLineHandler line = GuiDraw.getTipLine(text);
int lineHeight = line != null ? line.getSize().height
: text.endsWith(GuiDraw.TOOLTIP_LINESPACE) && i + 1 < list.size() ? 12 : 10;
if (height + lineHeight <= GuiDraw.displaySize().height - 8 * 2 - 10 || tmp.isEmpty()) {
if (height + lineHeight <= GuiDraw.displaySize().height - 8 * 2 - 10) {
// top & bottom 8px + last line for showing page
// and at least include one line per page
height += lineHeight;
} else {
ret.add(new ArrayList<>(tmp));
@@ -780,8 +752,8 @@ public class GuiContainerManager {
}
}
public static boolean incrementTooltipPage() {
return tooltipPage != Math.min(tooltipPage++, maxTooltipPage);
public static void incrementTooltipPage() {
tooltipPage++;
}
public void renderSlotUnderlay(Slot slot) {
@@ -86,7 +86,7 @@ public class StackInfo {
}
public static boolean equalItemAndNBT(ItemStack stackA, ItemStack stackB, boolean useNBT) {
if (stackA == null || stackB == null || stackA.getItem() != stackB.getItem()) {
if (stackA == null || stackB == null || !stackA.isItemEqual(stackB)) {
return false;
}
@@ -24,7 +24,7 @@ public class DefaultStackStringifyHandler implements IStackStringifyHandler {
nbTag.setInteger("Count", saveStackSize ? stack.stackSize : 1);
nbTag.setShort("Damage", (short) stack.getItemDamage());
if (stack.hasTagCompound() && !stack.getTagCompound().hasNoTags()) {
if (stack.hasTagCompound()) {
nbTag.setTag("tag", stack.getTagCompound());
}
@@ -1,80 +0,0 @@
package codechicken.nei.util;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
import codechicken.nei.NEIClientUtils;
public class NEIKeyboardUtils {
public static final int ALT_HASH = 1 << 27;
public static final int SHIFT_HASH = 1 << 26;
public static final int CTRL_HASH = 1 << 25;
private static final Map<Integer, Integer> keyHashMap = new HashMap<>();
static {
keyHashMap.put(Keyboard.KEY_LSHIFT, SHIFT_HASH);
keyHashMap.put(Keyboard.KEY_RSHIFT, SHIFT_HASH);
keyHashMap.put(Keyboard.KEY_LCONTROL, CTRL_HASH);
keyHashMap.put(Keyboard.KEY_LCONTROL, CTRL_HASH);
keyHashMap.put(Keyboard.KEY_LMETA, CTRL_HASH);
keyHashMap.put(Keyboard.KEY_RMETA, CTRL_HASH);
keyHashMap.put(Keyboard.KEY_LMENU, ALT_HASH);
keyHashMap.put(Keyboard.KEY_LMENU, ALT_HASH);
}
private NEIKeyboardUtils() {}
public static boolean isHashKey(int keycode) {
return keyHashMap.containsKey(keycode);
}
public static String getHashName(int keyBind) {
StringJoiner keyText = new StringJoiner(" + ");
if ((keyBind & CTRL_HASH) != 0) {
keyText.add(NEIClientUtils.translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl"));
}
if ((keyBind & SHIFT_HASH) != 0) {
keyText.add(NEIClientUtils.translate("key.shift"));
}
if ((keyBind & ALT_HASH) != 0) {
keyText.add(NEIClientUtils.translate("key.alt"));
}
return keyText.toString();
}
public static String getKeyName(int keyBind) {
keyBind = keyHashMap.getOrDefault(keyBind, keyBind);
StringJoiner keyText = new StringJoiner(" + ");
String hashText = getHashName(keyBind);
int keyID = unhash(keyBind);
if (!hashText.isEmpty()) {
keyText.add(hashText);
}
if (keyID != Keyboard.CHAR_NONE || hashText.isEmpty()) {
keyText.add(Keyboard.getKeyName(keyID));
}
return keyText.toString();
}
public static int unhash(int keyBind) {
return keyBind & ~(CTRL_HASH | SHIFT_HASH | ALT_HASH);
}
}
@@ -1,67 +0,0 @@
package codechicken.nei.util;
import java.util.StringJoiner;
import codechicken.nei.NEIClientUtils;
public class NEIMouseUtils {
public static final int MOUSE_BTN_NONE = Integer.MIN_VALUE;
public static final int MOUSE_BTN_LMB = 0;
public static final int MOUSE_BTN_RMB = 1;
public static final int MOUSE_BTN_MMB = 2;
public static final int MOUSE_SCROLL = 1 << 27;
public static final int MOUSE_DRAG = 1 << 26;
private NEIMouseUtils() {}
public static String getHashName(int mouseBind) {
StringJoiner mouseText = new StringJoiner(" + ");
if ((mouseBind & MOUSE_SCROLL) != 0) {
mouseText.add(NEIClientUtils.translate("mouse.scroll"));
}
if ((mouseBind & MOUSE_DRAG) != 0) {
mouseText.add(NEIClientUtils.translate("mouse.drag"));
}
return mouseText.toString();
}
public static String getKeyName(int mouseBind) {
StringJoiner mouseText = new StringJoiner(" + ");
String hashText = getHashName(mouseBind < 0 ? mouseBind - MOUSE_BTN_NONE : mouseBind);
if (mouseBind >= 0) {
int button = unhash(mouseBind);
switch (button) {
case MOUSE_BTN_LMB:
mouseText.add(NEIClientUtils.translate("mouse.left"));
break;
case MOUSE_BTN_RMB:
mouseText.add(NEIClientUtils.translate("mouse.right"));
break;
case MOUSE_BTN_MMB:
mouseText.add(NEIClientUtils.translate("mouse.middle"));
break;
default:
mouseText.add(NEIClientUtils.translate("mouse.other", button));
break;
}
}
if (!hashText.isEmpty()) {
mouseText.add(hashText);
}
return mouseText.toString();
}
public static int unhash(int mouseBind) {
return mouseBind & ~(MOUSE_SCROLL | MOUSE_DRAG);
}
}
@@ -24,7 +24,7 @@ public enum ReadableNumberConverter {
/**
* String representation of the sorted postfixes
*/
private static final char[] ENCODED_POSTFIXES = "kMGTPE".toCharArray();
private static final char[] ENCODED_POSTFIXES = "KMGTPE".toCharArray();
private final Format format;
+9 -15
View File
@@ -5,12 +5,6 @@ nei.save=Save
nei.key.ctrl=CTRL
nei.key.shift=SHIFT
nei.key.alt=ALT
nei.mouse.left=LMB
nei.mouse.right=RMB
nei.mouse.middle=MMB
nei.mouse.other=Button %d
nei.mouse.scroll=Scroll
nei.mouse.drag=Drag
# Mac Command Key
nei.key.ctrl.mac=CMD
nei.showHotkeys=Hold %s for hotkeys
@@ -198,9 +192,6 @@ nei.options.inventory.bookmarks.ignorePotionOverlap.false=No
nei.options.inventory.bookmarks.worldSpecific=World Specific Bookmarks
nei.options.inventory.bookmarks.worldSpecific.true=Yes
nei.options.inventory.bookmarks.worldSpecific.false=No
nei.options.inventory.hotkeysHelpText=Show Hotkeys Help Text
nei.options.inventory.hotkeysHelpText.true=Yes
nei.options.inventory.hotkeysHelpText.false=No
nei.options.inventory.guirecipe=Recipes GUI
nei.options.inventory.guirecipe.jeiStyleTabs=JEI Style Tabs
nei.options.inventory.guirecipe.jeiStyleTabs.true=Yes
@@ -320,7 +311,6 @@ nei.options.inventory.gridRenderingCacheMode=Grid Rendering Cache Mode
nei.options.inventory.gridRenderingCacheMode.0=Off
nei.options.inventory.gridRenderingCacheMode.1=Low FPS
nei.options.inventory.gridRenderingCacheMode.2=Freeze
nei.options.inventory.gridRenderingCacheFPS=Grid Rendering Cache FPS
nei.options.inventory.collapsibleItems=Collapsible Items
nei.options.inventory.collapsibleItems.enabled=Collapsible Items
nei.options.inventory.collapsibleItems.enabled.true=Enabled
@@ -330,6 +320,8 @@ nei.options.inventory.collapsibleItems.customName.true=Yes
nei.options.inventory.collapsibleItems.customName.false=No
nei.options.inventory.collapsibleItems.expandedColor=Expanded Color
nei.options.inventory.collapsibleItems.collapsedColor=Collapsed Color
nei.options.inventory.collapsibleItems.reloadLabel=Reload
nei.options.inventory.collapsibleItems.reloadButton=Run
nei.options.inventory.history=History Panel
nei.options.inventory.history.enabled=History Panel Visibility
nei.options.inventory.history.enabled.true=Enabled
@@ -388,11 +380,6 @@ nei.options.world.highlight_tips.sample=Sample
nei.options.world.panels=Panels Settings
nei.options.world.presets=Presets List
nei.options.world.overlays=Overlays Settings
nei.options.world.overlays.lock=Lock overlays between dimensions
nei.options.world.overlays.lock.true=Enabled
nei.options.world.overlays.lock.false=Disabled
nei.options.tools=Tools
nei.options.tools.handler_load_from_config=Load handlers from Config
nei.options.tools.handler_load_from_config.true=Config
@@ -474,14 +461,21 @@ nei.itemsort.damage=Item Damage
nei.itemsort.name=Display Name
nei.subsets.item.cheat=Give out an Item
nei.subsets.item.cheat.key=Ctrl + LMB
nei.subsets.item.search=Search by Item
nei.subsets.item.search.key=Shift + LMB
nei.subsets.item.show=Show Item
nei.subsets.item.show.key=LMB
nei.subsets.item.hide=Hide Item
nei.subsets.item.hide.key=RMB
nei.subsets.tag.search=Search by Subset
nei.subsets.tag.search.key=Shift + LMB
nei.subsets.tag.onlythis=Show only this Subset
nei.subsets.tag.onlythis.key=Double LMB
nei.subsets.tag.show=Show Subset
nei.subsets.tag.show.key=LMB
nei.subsets.tag.hide=Hide Subset
nei.subsets.tag.hide.key=RMB
nei.subsets.Blocks=Blocks
nei.subsets.Blocks.MobSpawners=Mob Spawners
@@ -134,11 +134,6 @@ nei.options.world.highlight_tips=Mettez en surbrillance les info-bulles
nei.options.world.highlight_tips.hide=Caché
nei.options.world.highlight_tips.show=Montré
nei.options.world.overlays=Paramètres des overlays
nei.options.world.overlays.lock.true=Activé
nei.options.world.overlays.lock.false=Désactivé
nei.options.world.overlays.lock=Conserver les overlays entre les dimensions
nei.options.tools=Outils
nei.options.tools.dump=Data Dumps
nei.options.tools.dump.dump=Jeter
@@ -301,6 +301,8 @@ nei.options.inventory.collapsibleItems.customName.true=Да
nei.options.inventory.collapsibleItems.customName.false=Нет
nei.options.inventory.collapsibleItems.expandedColor=Цвет развернутого
nei.options.inventory.collapsibleItems.collapsedColor=Цвет свернутого
nei.options.inventory.collapsibleItems.reloadLabel=Перезагрузить
nei.options.inventory.collapsibleItems.reloadButton=Запустить
nei.options.inventory.history=Панель истории
nei.options.inventory.history.enabled=Видимость панели истории
nei.options.inventory.history.enabled.true=Включено