diff --git a/.gitignore b/.gitignore index 967255e4..8e24443d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,19 +1,44 @@ +# Filter Minecraft sources +/src/minecraft/* +!/src/minecraft/invtweaks +!/src/minecraft/net +/src/minecraft/net/minecraft/client +/src/minecraft/net/minecraft/server +/src/minecraft/net/minecraft/src/* +!/src/minecraft/net/minecraft/src/InvTweaks* + +# Builds & binaries bin/ target/ lib/ -client/ -isom/ -InvTweaks-*/ -files/ +invtweaks_docs/_build launcher/ -docs/_build *.zip *.jar -minecraft/net/minecraft/src/*.java -*# + +# Tmp files *~ -*.rej +*# + +# IDEs .classpath .project .settings .pydevproject + +# MCP Files +docs/ +conf/ +eclipse/ +jars/ +logs/ +runtime/ +temp/ +reobf/ +CHANGELOG +LICENSE.txt +*.bat +*.sh + +# Misc +*.rej diff --git a/LICENSE.md b/LICENSE.md old mode 100755 new mode 100644 index 8abeba79..fe92f288 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ ## Inventory Tweaks Mod license (MIT) -Copyright (c) 2011-2012 Marwane Kalam-Alami +Copyright (c) 2011-2013 Marwane Kalam-Alami Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 6ed75606..f6e969ef 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ - +## This repository is not maintained anymore. -* Matching Minecraft version: **1.4.4** +**Kobata has a well maintained fork with multiple bugfixes and additions. Since March 2013, he is the new official maintainer for InvTweaks.** -## What's this project about +* **Please go to [his fork of this repository](https://github.com/Kobata/inventory-tweaks) for further updates** +* **See also the new [InvTweaks thread](http://www.minecraftforum.net/topic/1720872-inventory-tweaks-151-mar-9/) on the Minecraft forums** -This Open Source project (see [License](https://github.com/mkalam-alami/inventory-tweaks/blob/master/src/doc/license.txt)) is a client mod for [Minecraft](http://www.minecraft.net/), a game by [Mojang AB](http://mojang.com/). It implements various features to help players with the management of inventories and chests. A lot of effort has been put to make it as customizable as possible, without being annoying to set up. +## What is Inventory Tweaks? -## Get started +This Open Source project (see [License](https://github.com/mkalam-alami/inventory-tweaks/blob/master/src/doc/license.txt)) is a client mod for [Minecraft](http://www.minecraft.net/), a game by [Mojang AB](http://mojang.com/). It implements various features to help players with the management of inventories and chests. A lot of effort has been put to make it as customizable as possible, without being annoying to set up. -* For documentation about how to use or install the mod, see the [main page of Inventory Tweaks](http://wan.ka.free.fr/?invtweaks). This place is for developers! -* To start coding, all is explained on the [project's wiki](https://github.com/mkalam-alami/inventory-tweaks/wiki). + diff --git a/build.xml b/build.xml index de852232..054c6944 100755 --- a/build.xml +++ b/build.xml @@ -25,7 +25,7 @@ - Copying zip to mods folder - + - Done! diff --git a/conf/mcp.cfg b/conf/mcp.cfg new file mode 100644 index 00000000..b4d6940c --- /dev/null +++ b/conf/mcp.cfg @@ -0,0 +1,155 @@ +[DEFAULT] +DirTemp = temp +DirSrc = src +DirLogs = logs +DirBin = bin +DirJars = jars +DirReobf = reobf +DirConf = conf +DirRuntime = runtime +DirLib = lib +DirTempSrc = temp/src +DirTempCls = temp/cls +DirTempBin = temp/bin +DirModSrc = modsrc +DirEclipse = eclipse + +[CSV] +Classes = %(DirConf)s/classes.csv +Methods = %(DirConf)s/methods.csv +Fields = %(DirConf)s/fields.csv +Params = %(DirConf)s/params.csv +NewIds = %(DirConf)s/newids.csv + +[SRGS] +ConfClient = %(DirConf)s/client.srg +ConfServer = %(DirConf)s/server.srg +Client = %(DirTemp)s/client_rg.srg +Server = %(DirTemp)s/server_rg.srg +DeobfClient = %(DirTemp)s/client_deobf.srg +DeobfServer = %(DirTemp)s/server_deobf.srg +ReobfClient = %(DirTemp)s/client_ro.srg +ReobfServer = %(DirTemp)s/server_ro.srg + +[JAR] +DirNatives = %(DirJars)s/bin/natives +Client = %(DirJars)s/bin/minecraft.jar +Server = %(DirJars)s/minecraft_server.jar +LWJGL = %(DirJars)s/bin/jinput.jar,%(DirJars)s/bin/lwjgl.jar,%(DirJars)s/bin/lwjgl_util.jar +MD5Client = 48677dc4c2b98c29918722b5ab27b4fd +MD5Server = b0700fa969dbf0ff085082cde87384d2 + +[RETROGUARD] +Location = %(DirRuntime)s/bin/retroguard.jar +RetroConf = %(DirTemp)s/retroguard.cfg +RetroReobConf = %(DirTemp)s/retroguard_ro.cfg +ClientConf = %(DirTemp)s/client_rg.cfg +ServerConf = %(DirTemp)s/server_rg.cfg +ClientReobConf = %(DirTemp)s/client_ro.cfg +ServerReobConf = %(DirTemp)s/server_ro.cfg +ClientOut = %(DirTemp)s/minecraft_rg.jar +ServerOut = %(DirTemp)s/minecraft_server_rg.jar +ClientLog = %(DirLogs)s/client_rg.log +ServerLog = %(DirLogs)s/server_rg.log +ClientDeobLog = %(DirLogs)s/client_deob.log +ServerDeobLog = %(DirLogs)s/server_deob.log +NullPkg = net/minecraft/src + +[EXCEPTOR] +XClientCfg = %(DirConf)s/joined.exc +XServerCfg = %(DirConf)s/joined.exc +XClientOut = %(DirTemp)s/minecraft_exc.jar +XServerOut = %(DirTemp)s/minecraft_server_exc.jar +XClientLog = %(DirLogs)s/client_exc.log +XServerLog = %(DirLogs)s/server_exc.log + +[DECOMPILE] +ClsClientTemp = %(DirTempCls)s/minecraft +ClsServerTemp = %(DirTempCls)s/minecraft_server +SrcClientTemp = %(DirTempSrc)s/minecraft +SrcServerTemp = %(DirTempSrc)s/minecraft_server +FFSource = net + +[OUTPUT] +BinClientTemp = %(DirTempBin)s/minecraft +BinServerTemp = %(DirTempBin)s/minecraft_server +SrcClient = %(DirSrc)s/minecraft +SrcServer = %(DirSrc)s/minecraft_server +TestClient = net/minecraft/client/Minecraft +TestServer = net/minecraft/server/MinecraftServer + +[PATCHES] +PatchClient = %(DirConf)s/patches/minecraft.patch +PatchServer = %(DirConf)s/patches/minecraft_server.patch +PatchTemp = %(DirTemp)s/temp.patch +FFPatchClient = %(DirConf)s/patches/minecraft_ff.patch +FFPatchServer = %(DirConf)s/patches/minecraft_server_ff.patch +PatchClient_osx = %(DirConf)s/patches/minecraft_osx.patch +PatchServer_osx = %(DirConf)s/patches/minecraft_server_osx.patch + +[RECOMPILE] +BinClient = %(DirBin)s/minecraft +BinServer = %(DirBin)s/minecraft_server +LogClient = %(DirLogs)s/client_compile.log +LogServer = %(DirLogs)s/server_compile.log +ClassPathClient = %(DirLib)s/,%(DirLib)s/*,%(DirJars)s/bin/minecraft.jar,%(DirJars)s/bin/jinput.jar,%(DirJars)s/bin/lwjgl.jar,%(DirJars)s/bin/lwjgl_util.jar +ClassPathServer = %(DirLib)s/,%(DirLib)s/*,%(DirJars)s/minecraft_server.jar +ClientFixes = %(DirConf)s/patches +FixStart = Start +IgnorePkg = paulscode,com/jcraft,isom,ibxm,de/matthiasmann/twl,org/xmlpull,javax/xml + +[REOBF] +MD5Client = %(DirTemp)s/client.md5 +MD5Server = %(DirTemp)s/server.md5 +MD5PreReobfClient = %(DirTemp)s/client_reobf.md5 +MD5PreReobfServer = %(DirTemp)s/server_reobf.md5 +RecompJarClient = %(DirTemp)s/client_recomp.jar +RecompJarServer = %(DirTemp)s/server_recomp.jar +ObfJarClient = %(DirTemp)s/client_reobf.jar +ObfJarServer = %(DirTemp)s/server_reobf.jar +ReobfDirClient = %(DirReobf)s/minecraft +ReobfDirServer = %(DirReobf)s/minecraft_server +ClientRoLog = %(DirLogs)s/client_ro.log +ServerRoLog = %(DirLogs)s/server_ro.log +ReobfClientLog = %(DirLogs)s/client_reob.log +ReobfServerLog = %(DirLogs)s/server_reob.log + +[GETMODSOURCE] +OutSRCClient = %(DirModSrc)s/minecraft +OutSRCServer = %(DirModSrc)s/minecraft_server + +[MCP] +LogFile = %(DirLogs)s/mcp.log +LogFileErr = %(DirLogs)s/mcperr.log +UpdateUrl = http://mcp.ocean-labs.de/files/mcprolling_{version}/ +IgnoreUpdate = %(DirBin)s,%(DirLib)s,%(DirLogs)s,%(DirModSrc)s,%(DirReobf)s,%(DirSrc)s,%(DirTemp)s,%(DirEclipse)s/Client/bin,%(DirEclipse)s/Server/bin,%(DirJars)s/world,%(DirJars)s/saves,%(DirJars)s/resources +RGIndex = 92000 +ParamIndex = 8000 + +[ASTYLE] +AstyleConfig = %(DirConf)s/astyle.cfg + +[COMMANDS] +Wine = wine +Patcher_win = %(DirRuntime)s/bin/applydiff.exe +Patcher_linux = patch +Patcher_osx = patch +Jad_win = %(DirRuntime)s/bin/jad.exe +Jad_osx = %(DirRuntime)s/bin/jad-osx +AStyle_win = %(DirRuntime)s/bin/astyle.exe +AStyle_linux = astyle +AStyle_osx = %(DirRuntime)s/bin/astyle-osx +JadRetro = %(DirRuntime)s/bin/jadretro.jar +Fernflower = %(DirRuntime)s/bin/fernflower.jar +Exceptor = %(DirRuntime)s/bin/mcinjector.jar +CmdPatch = %s -p1 -u -i {patchfile} -d {srcdir} +CmdJad = %s -b -d {outdir} -dead -o -r -s .java -stat -ff {classes} +CmdAStyle = %s --suffix=none --quiet --options={conffile} {classes} +CmdRG = %s -cp "{classpath}" RetroGuard -searge {conffile} +CmdRGReobf = %s -cp "{classpath}" RetroGuard -notch {conffile} +CmdJadretro = %s -jar %s {targetdir} +CmdFernflower = %s -jar %s -din=0 -rbr=0 -dgs=1 -asc=1 -log=WARN {indir} {outdir} +CmdExceptor = %s -jar %s {input} {output} {conf} {log} +CmdRecomp = %s -Xlint:-options -deprecation -g -source 1.6 -target 1.6 -classpath "{classpath}" -sourcepath {sourcepath} -d {outpath} {pkgs} +CmdStartSrv = %s -Xincgc -Xms1024M -Xmx1024M -cp "{classpath}" net.minecraft.server.MinecraftServer +CmdStartClt = %s -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 -Xincgc -Xms1024M -Xmx1024M -cp "{classpath}" -Djava.library.path={natives} Start diff --git a/docs/download.txt b/docs/download.txt deleted file mode 100644 index 44b90e24..00000000 --- a/docs/download.txt +++ /dev/null @@ -1,14 +0,0 @@ -.. image:: _static/img/dl.png - :align: left - -`Inventory Tweaks 1.45 `_ for **Minecraft 1.4.4** (requires `Forge `_ or `ModLoader `_) | `Mirror `_ - -.. image:: _static/img/dl.png - :align: left - -`Inventory Tweaks 1.44 `_ for **Minecraft 1.4.2** (requires `Forge `_ or `ModLoader `_) | `Mirror `_ - -.. image:: _static/img/dl.png - :align: left - -`Inventory Tweaks 1.43b `_ for **Minecraft 1.3.2** (requires `Forge `_ or `ModLoader `_) | `Mirror `_ \ No newline at end of file diff --git a/docs/make.bat b/docs/make.bat deleted file mode 100755 index 61f12477..00000000 --- a/docs/make.bat +++ /dev/null @@ -1,190 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set BUILDDIR=_build -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . -set I18NSPHINXOPTS=%SPHINXOPTS% . -if NOT "%PAPER%" == "" ( - set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% - set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% -) - -if "%1" == "" goto help - -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. html to make standalone HTML files - echo. dirhtml to make HTML files named index.html in directories - echo. singlehtml to make a single large HTML file - echo. pickle to make pickle files - echo. json to make JSON files - echo. htmlhelp to make HTML files and a HTML help project - echo. qthelp to make HTML files and a qthelp project - echo. devhelp to make HTML files and a Devhelp project - echo. epub to make an epub - echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter - echo. text to make text files - echo. man to make manual pages - echo. texinfo to make Texinfo files - echo. gettext to make PO message catalogs - echo. changes to make an overview over all changed/added/deprecated items - echo. linkcheck to check all external links for integrity - echo. doctest to run all doctests embedded in the documentation if enabled - goto end -) - -if "%1" == "clean" ( - for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i - del /q /s %BUILDDIR%\* - goto end -) - -if "%1" == "html" ( - %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/html. - goto end -) - -if "%1" == "dirhtml" ( - %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. - goto end -) - -if "%1" == "singlehtml" ( - %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. - goto end -) - -if "%1" == "pickle" ( - %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the pickle files. - goto end -) - -if "%1" == "json" ( - %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the JSON files. - goto end -) - -if "%1" == "htmlhelp" ( - %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run HTML Help Workshop with the ^ -.hhp project file in %BUILDDIR%/htmlhelp. - goto end -) - -if "%1" == "qthelp" ( - %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run "qcollectiongenerator" with the ^ -.qhcp project file in %BUILDDIR%/qthelp, like this: - echo.^> qcollectiongenerator %BUILDDIR%\qthelp\InventoryTweaks.qhcp - echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\InventoryTweaks.ghc - goto end -) - -if "%1" == "devhelp" ( - %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. - goto end -) - -if "%1" == "epub" ( - %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The epub file is in %BUILDDIR%/epub. - goto end -) - -if "%1" == "latex" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "text" ( - %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The text files are in %BUILDDIR%/text. - goto end -) - -if "%1" == "man" ( - %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The manual pages are in %BUILDDIR%/man. - goto end -) - -if "%1" == "texinfo" ( - %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. - goto end -) - -if "%1" == "gettext" ( - %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The message catalogs are in %BUILDDIR%/locale. - goto end -) - -if "%1" == "changes" ( - %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes - if errorlevel 1 exit /b 1 - echo. - echo.The overview file is in %BUILDDIR%/changes. - goto end -) - -if "%1" == "linkcheck" ( - %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck - if errorlevel 1 exit /b 1 - echo. - echo.Link check complete; look for any errors in the above output ^ -or in %BUILDDIR%/linkcheck/output.txt. - goto end -) - -if "%1" == "doctest" ( - %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest - if errorlevel 1 exit /b 1 - echo. - echo.Testing of doctests in the sources finished, look at the ^ -results in %BUILDDIR%/doctest/output.txt. - goto end -) - -:end diff --git a/docs/Makefile b/invtweaks_docs/Makefile old mode 100755 new mode 100644 similarity index 100% rename from docs/Makefile rename to invtweaks_docs/Makefile diff --git a/docs/README.md b/invtweaks_docs/README.md similarity index 100% rename from docs/README.md rename to invtweaks_docs/README.md diff --git a/docs/_static/img/button10px.png b/invtweaks_docs/_static/img/button10px.png similarity index 100% rename from docs/_static/img/button10px.png rename to invtweaks_docs/_static/img/button10px.png diff --git a/docs/_static/img/demo.jpg b/invtweaks_docs/_static/img/demo.jpg old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/demo.jpg rename to invtweaks_docs/_static/img/demo.jpg diff --git a/docs/_static/img/dl.png b/invtweaks_docs/_static/img/dl.png similarity index 100% rename from docs/_static/img/dl.png rename to invtweaks_docs/_static/img/dl.png diff --git a/docs/_static/img/flag/cn.png b/invtweaks_docs/_static/img/flag/cn.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/cn.png rename to invtweaks_docs/_static/img/flag/cn.png diff --git a/docs/_static/img/flag/dk.png b/invtweaks_docs/_static/img/flag/dk.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/dk.png rename to invtweaks_docs/_static/img/flag/dk.png diff --git a/docs/_static/img/flag/es.png b/invtweaks_docs/_static/img/flag/es.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/es.png rename to invtweaks_docs/_static/img/flag/es.png diff --git a/docs/_static/img/flag/fr.png b/invtweaks_docs/_static/img/flag/fr.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/fr.png rename to invtweaks_docs/_static/img/flag/fr.png diff --git a/docs/_static/img/flag/it.png b/invtweaks_docs/_static/img/flag/it.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/it.png rename to invtweaks_docs/_static/img/flag/it.png diff --git a/docs/_static/img/flag/jp.png b/invtweaks_docs/_static/img/flag/jp.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/jp.png rename to invtweaks_docs/_static/img/flag/jp.png diff --git a/docs/_static/img/flag/kr.png b/invtweaks_docs/_static/img/flag/kr.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/kr.png rename to invtweaks_docs/_static/img/flag/kr.png diff --git a/docs/_static/img/flag/nl.png b/invtweaks_docs/_static/img/flag/nl.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/nl.png rename to invtweaks_docs/_static/img/flag/nl.png diff --git a/docs/_static/img/flag/pl.png b/invtweaks_docs/_static/img/flag/pl.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/pl.png rename to invtweaks_docs/_static/img/flag/pl.png diff --git a/docs/_static/img/flag/pt.png b/invtweaks_docs/_static/img/flag/pt.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/pt.png rename to invtweaks_docs/_static/img/flag/pt.png diff --git a/docs/_static/img/flag/ru.png b/invtweaks_docs/_static/img/flag/ru.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/ru.png rename to invtweaks_docs/_static/img/flag/ru.png diff --git a/docs/_static/img/flag/tw.png b/invtweaks_docs/_static/img/flag/tw.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/tw.png rename to invtweaks_docs/_static/img/flag/tw.png diff --git a/docs/_static/img/flag/us.png b/invtweaks_docs/_static/img/flag/us.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/flag/us.png rename to invtweaks_docs/_static/img/flag/us.png diff --git a/docs/_static/img/invtweaks.png b/invtweaks_docs/_static/img/invtweaks.png old mode 100755 new mode 100644 similarity index 100% rename from docs/_static/img/invtweaks.png rename to invtweaks_docs/_static/img/invtweaks.png diff --git a/docs/_themes/nature-custom/static/nature.css_t b/invtweaks_docs/_themes/nature-custom/static/nature.css_t similarity index 100% rename from docs/_themes/nature-custom/static/nature.css_t rename to invtweaks_docs/_themes/nature-custom/static/nature.css_t diff --git a/docs/_themes/nature-custom/static/pygments.css b/invtweaks_docs/_themes/nature-custom/static/pygments.css similarity index 100% rename from docs/_themes/nature-custom/static/pygments.css rename to invtweaks_docs/_themes/nature-custom/static/pygments.css diff --git a/docs/_themes/nature-custom/theme.conf b/invtweaks_docs/_themes/nature-custom/theme.conf similarity index 100% rename from docs/_themes/nature-custom/theme.conf rename to invtweaks_docs/_themes/nature-custom/theme.conf diff --git a/docs/changelog.txt b/invtweaks_docs/changelog.txt old mode 100755 new mode 100644 similarity index 96% rename from docs/changelog.txt rename to invtweaks_docs/changelog.txt index d346cbcf..42d4ae3b --- a/docs/changelog.txt +++ b/invtweaks_docs/changelog.txt @@ -3,7 +3,13 @@ Latest changes ============== -`[11.15.2012] 1.45 (1.4.4) `_ +`[01.17.2013] 1.50 (1.4.7) `_ + * Switched sources to MCP (= faster to update, easier to contribute) + * Middle click evens the stacks on crafting tables (thanks to InvTweaks-1.50-1.4.7.zip) + * Removed uneffective NoCheatPlus hack, put a help screen instead + * Fix chests being sometimes left open forever + +`[11.15.2012] 1.45 (1.4.4) `_ * Added Beta option to make the mod work on anti-cheat servers * Fixed the potato IDs in the item tree (delete config/InvTweaksTree.txt to refresh it) * Added Norwegian translation (thanks to mymusicmanager) diff --git a/docs/conf.py b/invtweaks_docs/conf.py old mode 100755 new mode 100644 similarity index 98% rename from docs/conf.py rename to invtweaks_docs/conf.py index 6da5f333..96d9556e --- a/docs/conf.py +++ b/invtweaks_docs/conf.py @@ -20,6 +20,12 @@ # -- General configuration ----------------------------------------------------- +# INVENTORY TWEAKS VERSION +invtweaks_version = '1.50' + + + + # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' @@ -48,9 +54,9 @@ # built documents. # # The short X.Y version. -version = '1.45' +version = invtweaks_version # The full version, including alpha/beta/rc tags. -release = '1.45' +release = invtweaks_version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/invtweaks_docs/download.txt b/invtweaks_docs/download.txt new file mode 100644 index 00000000..4ed931c3 --- /dev/null +++ b/invtweaks_docs/download.txt @@ -0,0 +1,14 @@ +.. image:: _static/img/dl.png + :align: left + +`Inventory Tweaks 1.50 `_ for **Minecraft 1.4.6/1.4.7** (requires `Forge `_ or `ModLoader `_) | `Mirror `_ + +.. image:: _static/img/dl.png + :align: left + +`Inventory Tweaks 1.45 `_ for **Minecraft 1.4.4/1.4.5** (requires `Forge `_ or `ModLoader `_) | `Mirror `_ + +.. image:: _static/img/dl.png + :align: left + +`Inventory Tweaks 1.43b `_ for **Minecraft 1.3.2** (requires `Forge `_ or `ModLoader `_) | `Mirror `_ \ No newline at end of file diff --git a/docs/index.txt b/invtweaks_docs/index.txt old mode 100755 new mode 100644 similarity index 96% rename from docs/index.txt rename to invtweaks_docs/index.txt index 14cb3314..d26920d5 --- a/docs/index.txt +++ b/invtweaks_docs/index.txt @@ -52,7 +52,9 @@ Just start playing Minecraft, you can already use most features of the mod. Noti Inventory sorting ~~~~~~~~~~~~~~~~~ -Trigger the sorting in your inventory by using the **middle click**, or by pressing **R** (by default), at any time. If you want to change the shortcut, you can do that from the "..." menu in your inventory. +Trigger the sorting in your inventory by using the **middle click**, or by pressing **R** (by default), at any time. If you want to change the shortcut, you can do that from the "..." menu in your inventory. + +Tip: The middle click shortcut behaves differently if you target the **crafting input**: in that case, it will adjust the item amounts to balance them, helping optimize your recipe input. For example, if you want to make sticks, it will make sure your wood will be split equally between the top and the bottom stack. Chests sorting ~~~~~~~~~~~~~~ diff --git a/docs/index_cn.txt b/invtweaks_docs/index_cn.txt similarity index 100% rename from docs/index_cn.txt rename to invtweaks_docs/index_cn.txt diff --git a/docs/index_de.txt b/invtweaks_docs/index_de.txt similarity index 100% rename from docs/index_de.txt rename to invtweaks_docs/index_de.txt diff --git a/docs/index_dk.txt b/invtweaks_docs/index_dk.txt similarity index 100% rename from docs/index_dk.txt rename to invtweaks_docs/index_dk.txt diff --git a/docs/index_es.txt b/invtweaks_docs/index_es.txt similarity index 100% rename from docs/index_es.txt rename to invtweaks_docs/index_es.txt diff --git a/docs/index_fr.txt b/invtweaks_docs/index_fr.txt similarity index 100% rename from docs/index_fr.txt rename to invtweaks_docs/index_fr.txt diff --git a/docs/index_it.txt b/invtweaks_docs/index_it.txt similarity index 100% rename from docs/index_it.txt rename to invtweaks_docs/index_it.txt diff --git a/docs/index_jp.txt b/invtweaks_docs/index_jp.txt similarity index 100% rename from docs/index_jp.txt rename to invtweaks_docs/index_jp.txt diff --git a/docs/index_kr.txt b/invtweaks_docs/index_kr.txt similarity index 100% rename from docs/index_kr.txt rename to invtweaks_docs/index_kr.txt diff --git a/docs/index_nl.txt b/invtweaks_docs/index_nl.txt similarity index 100% rename from docs/index_nl.txt rename to invtweaks_docs/index_nl.txt diff --git a/docs/index_pl.txt b/invtweaks_docs/index_pl.txt similarity index 100% rename from docs/index_pl.txt rename to invtweaks_docs/index_pl.txt diff --git a/docs/index_pt.txt b/invtweaks_docs/index_pt.txt similarity index 100% rename from docs/index_pt.txt rename to invtweaks_docs/index_pt.txt diff --git a/docs/index_ru.txt b/invtweaks_docs/index_ru.txt similarity index 100% rename from docs/index_ru.txt rename to invtweaks_docs/index_ru.txt diff --git a/docs/index_tw.txt b/invtweaks_docs/index_tw.txt similarity index 100% rename from docs/index_tw.txt rename to invtweaks_docs/index_tw.txt diff --git a/docs/langs.txt b/invtweaks_docs/langs.txt similarity index 100% rename from docs/langs.txt rename to invtweaks_docs/langs.txt diff --git a/invtweaks_scripts/copy_resources.py b/invtweaks_scripts/copy_resources.py new file mode 100644 index 00000000..3c3ca061 --- /dev/null +++ b/invtweaks_scripts/copy_resources.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +import shutil +import sys +import os + +# Functions + +INVTWEAKS_SRC = 'src/minecraft/invtweaks/' +INVTWEAKS_BIN = 'bin/minecraft/invtweaks/' + +def copy_resource_tree(resource): + shutil.rmtree(INVTWEAKS_BIN + resource, True) + shutil.copytree(INVTWEAKS_SRC + resource, INVTWEAKS_BIN + resource) + +def copy_resource(resource): + try: + os.remove(INVTWEAKS_BIN + resource) + except OSError: + pass + shutil.copy(INVTWEAKS_SRC + resource, INVTWEAKS_BIN + resource) + +# Resources copy + +print 'Copying InvTweaks resources...' + +copy_resource_tree('lang/') +copy_resource('DefaultConfig.dat') +copy_resource('DefaultTree.dat') + +print 'OK!' \ No newline at end of file diff --git a/invtweaks_scripts/package_mod.py b/invtweaks_scripts/package_mod.py new file mode 100644 index 00000000..9d3a9328 --- /dev/null +++ b/invtweaks_scripts/package_mod.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +import shutil +import sys +import os +import zipfile + +# Constants + +INVTWEAKS_SRC = 'src/minecraft/invtweaks' +INVTWEAKS_CLASS = 'reobf/minecraft' +INVTWEAKS_TMP = 'temp/invtweaks' + +# Remove tmp dir + +shutil.rmtree(INVTWEAKS_TMP, True) + +# Gather files + +print 'Packaging InvTweaks...' + +shutil.copytree(INVTWEAKS_CLASS, INVTWEAKS_TMP) +shutil.copy(INVTWEAKS_SRC + '/DefaultConfig.dat', INVTWEAKS_TMP + '/invtweaks/DefaultConfig.dat') +shutil.copy(INVTWEAKS_SRC + '/DefaultTree.dat', INVTWEAKS_TMP + '/invtweaks/DefaultTree.dat') +shutil.copytree(INVTWEAKS_SRC + '/lang', INVTWEAKS_TMP + '/invtweaks/lang') +shutil.copy('LICENSE.md', INVTWEAKS_TMP + '/LICENSE.txt') + +# Zip + +def get_compression_mode(): + try: + import zlib + return zipfile.ZIP_DEFLATED + except: + print '(...but without compressing)' + return zipfile.ZIP_STORED + +def write_to_zip(zip, compression, path): + archive_path = path.replace(INVTWEAKS_TMP, '') + zip.write(path, arcname=archive_path, compress_type=compression) + +def list_files_recursive(folder): + contents = [] + for folder_element in os.listdir(folder): + sys.stdout.write(folder_element + '\n') + if os.path.isfile(folder_element): + contents.append(folder_element) + else: + contents.extend(list_files_recursive(folder_element)) + return contents + +print 'Zipping InvTweaks...' + +compression_mode = get_compression_mode() +invtweaks_zip = zipfile.ZipFile('InvTweaks-DEV.zip', mode='w') +for root, dirs, files in os.walk(INVTWEAKS_TMP): + for file in files: + write_to_zip(invtweaks_zip, compression_mode, root + '/' + file) + +print 'OK!' \ No newline at end of file diff --git a/obfutils.sh b/obfutils.sh deleted file mode 100755 index 356a6ef1..00000000 --- a/obfutils.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Replacement utils, helpful when updating the mod. -# @author Jimeo Wan -# License: MIT - -# Replace class names -if [[ ($1 == "-class") && $2 && $3 ]] -then - sed -i "s/\([(< ]\)$2\([)> ]\)/\1$3\2/" src/*.java - -else - HELP=1 -fi - -# Help -if [ $help ] -then - echo 'Usage:' - echo 'obfutils.sh -class FROMCLASS TOCLASS' -fi - diff --git a/pom.xml b/pom.xml deleted file mode 100755 index de1dfc8a..00000000 --- a/pom.xml +++ /dev/null @@ -1,155 +0,0 @@ - - 4.0.0 - - net.jimeowan - inventory-tweaks - 1.45-1.4.4 - jar - Inventory Tweaks - - - UTF-8 - InvTweaks-${project.version} - - - - ${archive.name} - - - src - - - . - false - src - - doc/* - invtweaks/lang/* - *.dat - - - *.java - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.6 - - - - move - - run - - package - - - - - - - - - deploy - - run - - install - - - - - - - - - - - - - - - - - - - minecraft-path-windows - - - windows - - - - ${user.home}/AppData/Roaming/.minecraft/ - ${minecraft.path}bin/ - - - - minecraft-path-linux - - - unix - - - - ${user.home}/.minecraft/ - ${minecraft.path}bin/ - - - - minecraft-path-mac - - - unix - mac os x - - - - ${user.home}/Library/Application Support/minecraft/ - ${minecraft.path}bin/ - - - - - - - - net.minecraft - minecraft - any - system - ${minecraft.bin.path}minecraft.jar - - - net.minecraft - lwjgl - 1.8 - system - ${minecraft.bin.path}lwjgl.jar - - - net.minecraft - lwjgl_util - 1.8 - system - ${minecraft.bin.path}lwjgl_util.jar - - - - diff --git a/recompile.bat b/recompile.bat new file mode 100644 index 00000000..c97cdbb5 --- /dev/null +++ b/recompile.bat @@ -0,0 +1,4 @@ +@echo off +runtime\bin\python\python_mcp runtime\recompile.py %* +runtime\bin\python\python_mcp invtweaks_scripts\copy_resources.py +pause diff --git a/recompile.sh b/recompile.sh new file mode 100644 index 00000000..abdb34b3 --- /dev/null +++ b/recompile.sh @@ -0,0 +1,3 @@ +#!/bin/bash +python runtime/recompile.py "$@" +python invtweaks_scripts/copy_resources.py \ No newline at end of file diff --git a/reobfuscate.bat b/reobfuscate.bat new file mode 100755 index 00000000..493583f0 --- /dev/null +++ b/reobfuscate.bat @@ -0,0 +1,4 @@ +@echo off +runtime\bin\python\python_mcp runtime\reobfuscate.py %* +runtime\bin\python\python_mcp invtweaks_scripts\package_mod.py +pause diff --git a/reobfuscate.sh b/reobfuscate.sh new file mode 100755 index 00000000..6ee02adb --- /dev/null +++ b/reobfuscate.sh @@ -0,0 +1,3 @@ +#!/bin/bash +python runtime/reobfuscate.py "$@" +python invtweaks_scripts/package_mod.py diff --git a/src/InvTweaksObfuscation.java b/src/InvTweaksObfuscation.java deleted file mode 100755 index 5df19d1f..00000000 --- a/src/InvTweaksObfuscation.java +++ /dev/null @@ -1,492 +0,0 @@ -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import net.minecraft.client.Minecraft; - -/** - * Minecraft 1.3 Obfuscation layer - * - * @author Jimeo Wan - * - */ -public class InvTweaksObfuscation { - - private static final Logger log = Logger.getLogger("InvTweaks"); - - protected Minecraft mc; - - protected InvTweaksModCompatibility mods; - - private static Map fieldsMap = new HashMap(); - - static { - // CreativeSlot.underlyingSlot - makeFieldPublic(avn.class, "b"); - // RenderEngine.texturePack - makeFieldPublic(bap.class, "k"); - } - - public InvTweaksObfuscation(Minecraft mc) { - this.mc = mc; - this.mods = new InvTweaksModCompatibility(this); - } - - // Minecraft members - - protected void addChatMessage(String message) { - if (mc.v != null) { - mc.v.b().a(message); - } - } - protected ayk getThePlayer() { // EntityPlayer - return mc.g; - } - protected ayh getTheWorld() { // World - return mc.e; - } - protected ayg getPlayerController() { // PlayerController - return mc.b; - } - protected aue getCurrentScreen() { // GuiScreen - return mc.r; - } - protected atj getFontRenderer() { // FontRenderer - return mc.p; - } - protected void displayGuiScreen(aue parentScreen) { - mc.a(parentScreen); - } - protected int getDisplayWidth() { - return mc.c; - } - protected int getDisplayHeight() { - return mc.d; - } - protected asl getGameSettings() { - return mc.y; - } - public arn[] getRegisteredBindings() { - return getGameSettings().P; - } - public void setRegisteredBindings(arn[] bindings) { - getGameSettings().P = bindings; - } - protected int getKeyBindingForwardKeyCode() { - return getKeyCode(getGameSettings().B); - } - protected int getKeyBindingBackKeyCode() { - return getKeyCode(getGameSettings().D); - } - - // EntityPlayer members - - protected qw getInventoryPlayer() { // InventoryPlayer - return getThePlayer().bI; - } - protected um getCurrentEquippedItem() { // ItemStack - return getThePlayer().bT(); - } - protected rp getCraftingInventory() { // Container - return getThePlayer().bJ; - } - protected rp getPlayerContainer() { // ContainerPlayer - return (rp) getThePlayer().bJ; // MCP name: inventorySlots // XXX Why the same as craftying inventory? - } - - // InventoryPlayer members - - protected um[] getMainInventory() { - return getInventoryPlayer().a; - } - protected void setMainInventory(um[] value) { - getInventoryPlayer().a = value; - } - protected void setHasInventoryChanged(boolean value) { - getInventoryPlayer().e = value; - } - protected void setHeldStack(um stack) { - getInventoryPlayer().b(stack); // setItemStack - } - protected boolean hasInventoryChanged() { - return getInventoryPlayer().e; - } - protected um getHeldStack() { - return getInventoryPlayer().n(); // getItemStack - } - protected um getFocusedStack() { - return getInventoryPlayer().g(); // getCurrentItem - } - protected int getFocusedSlot() { - return getInventoryPlayer().c; // currentItem - } - - // GuiScreen members - - protected int getWindowWidth(aue guiScreen) { - return guiScreen.g; - } - protected int getWindowHeight(aue guiScreen) { - return guiScreen.h; - } - protected int getGuiX(auy guiContainer) { // GuiContainer - return guiContainer.n; - } - protected int getGuiY(auy guiContainer) { - return guiContainer.o; - } - protected int getGuiWidth(auy guiContainer) { // GuiContainer - return guiContainer.b; - } - protected int getGuiHeight(auy guiContainer) { - return guiContainer.c; - } - @SuppressWarnings("unchecked") - protected List getControlList(aue guiScreen) { - return guiScreen.i; - } - protected void setControlList(aue guiScreen, List controlList) { - guiScreen.i = controlList; - } - protected auy asGuiContainer(aue guiScreen) { - return (auy) guiScreen; - } - - // FontRenderer members - - protected int getStringWidth(atj fontRenderer, String line) { - return fontRenderer.a(line); - } - protected void drawStringWithShadow(atj fontRenderer, - String s, int i, int j, int k) { - fontRenderer.a(s, i, j, k); - } - - // ItemStack members - - protected um createItemStack(int id, int size, int damage) { - return new um(id, size, damage); - } - protected um copy(um itemStack) { - return itemStack.l(); - } - protected int getItemDamage(um itemStack) { - return itemStack.j(); - } - protected int getMaxStackSize(um itemStack) { - return itemStack.d(); - } - protected boolean hasDataTags(um itemStack) { - return itemStack.o(); - } - protected int getStackSize(um itemStack) { - return itemStack.a; - } - protected int getItemID(um itemStack) { - return itemStack.c; - } - protected boolean areItemStacksEqual(um itemStack1, um itemStack2) { - return itemStack1.a(itemStack2) && getStackSize(itemStack1) == getStackSize(itemStack2); - } - protected boolean isItemStackDamageable(um itemStack) { - return itemStack.f(); - } - protected boolean areSameItemType(um itemStack1, um itemStack2) { - return areItemsEqual(itemStack1, itemStack2) || - (isItemStackDamageable(itemStack1) - && getItemID(itemStack1) == getItemID(itemStack2)); - } - protected boolean areItemsEqual(um itemStack1, um itemStack2) { - return itemStack1.a(itemStack2); // isItemEqual - } - protected int getAnimationsToGo(um itemStack) { - return itemStack.b; - } - protected uk getItem(um itemStack) { // Item - return itemStack.b(); - } - - // Item & ItemArmor - - protected boolean isDamageable(uk item) { - return item.n(); - } - protected int getMaxDamage(uk item) { - return item.m(); - } - protected int getArmorLevel(st itemArmor) { // ItemArmor - return itemArmor.b; - } - protected st asItemArmor(uk item) { // ItemArmor - return (st) item; - } - - // PlayerController members - - protected um clickInventory(ayg playerController, - int windowId, int slot, int clickButton, - boolean shiftHold, ayk entityPlayer) { - return playerController.a(windowId, slot, clickButton, - (shiftHold) ? 1 : 0 /* XXX Placeholder */, entityPlayer); - } - - // Container members - - protected int getWindowId(rp container) { - return container.d; - } - protected List getSlots(rp container) { - return container.c; - } - protected sq getSlot(rp container, int i) { // Slot - return (sq) (getSlots(container).get(i)); - } - - protected um getSlotStack(rp container, int i) { - sq slot = getSlot(container, i); - return (slot == null) ? null : getStack(slot); // getStack - } - - protected void setSlotStack(rp container, int i, um stack) { - container.a(i, stack); // putStackInSlot - } - - // Slot members - - protected boolean hasStack(sq slot) { - return slot.d(); - } - protected int getSlotNumber(sq slot) { - try { - // Creative slots don't set the "g" property, serve as a proxy for true slots - if (slot instanceof avn) { - sq underlyingSlot = (sq) getThroughReflection(avn.class, "b", slot); - if (underlyingSlot != null) { - return underlyingSlot.g; - } - } - } catch (Exception e) { - log.warning("Failed to access creative slot number"); - } - return slot.g; - } - protected um getStack(sq slot) { - return slot.c(); - } - protected int getXDisplayPosition(sq slot) { - return slot.h; - } - protected int getYDisplayPosition(sq slot) { - return slot.i; - } - protected boolean areSlotAndStackCompatible(sq slot, um itemStack) { - return slot.a(itemStack); // isItemValid - } - - // GuiContainer members - - protected rp getContainer(auy guiContainer) { - return guiContainer.d; /* inventorySlots */ - } - - // GuiButton - - protected ast asGuiButton(Object o) { - return (ast) o; - } - protected void setEnabled(ast guiButton, boolean enabled) { // GuiButton - guiButton.g = enabled; - } - protected int getId(ast guiButton) { // GuiButton - return guiButton.f; - } - protected void setDisplayString(ast guiButton, String string) { - guiButton.e = string; - } - protected String getDisplayString(ast guiButton) { - return guiButton.e; - } - - // Other - - protected void playSound(String string, float f, float g) { - mc.A.a(string, f, g); - } - protected long getCurrentTime() { - return getTheWorld().E(); - } - protected int getKeyCode(arn b) { // KeyBinding - return b.d; - } - protected int getSpecialChestRowSize(auy guiContainer, int defaultValue) { - return mods.getSpecialChestRowSize(guiContainer, defaultValue); - } - protected boolean hasTexture(String texture) { - bec texturePacksManager = (bec) getThroughReflection(bap.class, "k", mc.o); - return texturePacksManager != null && texturePacksManager.e().a(texture) != null; - } - - // Static access - - public static bn getLocalizationService() { // StringTranslate - return bn.a(); // StringTranslate.getInstance() - } - public static String getCurrentLanguage() { - return getLocalizationService().c(); - } - public static String getLocalizedString(String key) { - return getLocalizationService().b(key); - } - public static um getHoldStackStatic(Minecraft mc) { - return new InvTweaksObfuscation(mc).getHeldStack(); - } - public static aue getCurrentScreenStatic(Minecraft mc) { - return new InvTweaksObfuscation(mc).getCurrentScreen(); - } - - // Classes - - protected boolean isValidChest(aue guiScreen) { - return guiScreen != null && (isGuiChest(guiScreen) - || isGuiDispenser(guiScreen) - || mods.isSpecialChest(guiScreen)); - } - protected boolean isValidInventory(aue guiScreen) { - return isStandardInventory(guiScreen) - || mods.isSpecialInventory(guiScreen); - } - protected boolean isStandardInventory(aue guiScreen) { - return isGuiInventory(guiScreen) - || isGuiWorkbench(guiScreen) - || isGuiFurnace(guiScreen) - || isGuiBrewingStand(guiScreen) - || isGuiEnchantmentTable(guiScreen) - || isGuiTrading(guiScreen) - || isGuiAnvil(guiScreen) - || isGuiBeacon(guiScreen) - || (isGuiInventoryCreative(guiScreen) - && getSlots(getContainer(asGuiContainer(guiScreen))).size() == 46); - } - - protected boolean isGuiContainer(Object o) { // GuiContainer (abstract class) - return o != null && o instanceof auy; - } - - protected boolean isGuiBeacon(Object o) { // GuiBeacon - return o != null && o.getClass().equals(auz.class); - } - protected boolean isGuiBrewingStand(Object o) { // GuiBrewingStand - return o != null && o.getClass().equals(avg.class); - } - protected boolean isGuiChest(Object o) { // GuiChest - return o != null && o.getClass().equals(avi.class); - } - protected boolean isGuiWorkbench(Object o) { // GuiWorkbench - return o != null && o.getClass().equals(avj.class); - } - protected boolean isGuiInventoryCreative(Object o) { // GuiInventoryCreative - return o != null && o.getClass().equals(avl.class); - } - protected boolean isGuiEnchantmentTable(Object o) { // GuiEnchantmentTable - return o != null && o.getClass().equals(avq.class); - } - protected boolean isGuiFurnace(Object o) { // GuiFurnace - return o != null && o.getClass().equals(avr.class); - } - protected boolean isGuiInventory(Object o) { // GuiInventory - return o != null && o.getClass().equals(avs.class); - } - protected boolean isGuiTrading(Object o) { // GuiTrading - return o != null && o.getClass().equals(avt.class); - } - protected boolean isGuiAnvil(Object o) { // GuiAnvil - return o != null && o.getClass().equals(avv.class); - } - protected boolean isGuiDispenser(Object o) { // GuiDispenser - return o != null && o.getClass().equals(avx.class); - } - - protected boolean isGuiButton(Object o) { // GuiButton - return o != null && o instanceof ast; - } - - protected boolean isGuiEditSign(Object o) { // GuiEditSign - return o != null && o.getClass().equals(avw.class); - } - // ================ TODO ================ - - protected boolean isContainerBeacon(Object o) { // ContainerBeacon - return o != null && o.getClass().equals(rq.class); - } - protected boolean isContainerBrewingStand(Object o) { // ContainerBrewingStand - return o != null && o.getClass().equals(rs.class); - } - protected boolean isContainerChest(Object o) { // ContainerChest - return o != null && o.getClass().equals(rw.class); - } - protected boolean isContainerWorkbench(Object o) { // ContainerWorkbench - return o != null && o.getClass().equals(ry.class); - } - protected boolean isContainerEnchantmentTable(Object o) { // ContainerEnchantmentTable - return o != null && o.getClass().equals(rz.class); - } - protected boolean isContainerFurnace(Object o) { // ContainerFurnace - return o != null && o.getClass().equals(sc.class); - } - protected boolean isContainerPlayer(Object o) { // ContainerPlayer - return o != null && o.getClass().equals(se.class); - } - protected boolean isContainerTrading(Object o) { // ContainerTrading - return o != null && o.getClass().equals(si.class); - } - protected boolean isContainerAnvil(Object o) { // ContainerAnvil - return o != null && o.getClass().equals(sl.class); - } - protected boolean isContainerDispenser(Object o) { // ContainerDispenser - return o != null && o.getClass().equals(sr.class); - } - protected boolean isContainerCreative(Object o) { // ContainerCreative - return o != null && o.getClass().equals(avm.class); - } - - protected boolean isItemArmor(Object o) { // ItemArmor - return o != null && o instanceof st; - } - - protected boolean isBasicSlot(Object o) { // Slot - return o != null && o.getClass().equals(sq.class); - } - - // Reflection utils - - protected static void makeFieldPublic(Class c, String field) { - try { - Field f = c.getDeclaredField(field); - f.setAccessible(true); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(f, Modifier.PUBLIC); - fieldsMap.put(c.getName() + field, f); - } - catch (Exception e) { - log.severe("Failed to make " + c.getName() + "." + field + " accessible: " + e.getMessage()); - } - } - - /** - * Access value from any field, even private. - * Field must be made public through the makeFieldPublic() function first. - * @return - */ - protected static Object getThroughReflection(Class c, String field, Object instance) { - try { - return fieldsMap.get(c.getName() + field).get(instance); - } catch (Exception e) { - return null; - } - } - -} \ No newline at end of file diff --git a/src/InvTweaksObfuscationGuiButton.java b/src/InvTweaksObfuscationGuiButton.java deleted file mode 100755 index 00b0cc4c..00000000 --- a/src/InvTweaksObfuscationGuiButton.java +++ /dev/null @@ -1,55 +0,0 @@ -import net.minecraft.client.Minecraft; - -/** - * Obfuscation layer for gui buttons. - * @author Jimeo Wan - * - */ -public class InvTweaksObfuscationGuiButton extends ast /* GuiButton */ { - - public InvTweaksObfuscationGuiButton(int arg0, int arg1, int arg2, int arg3, int arg4, String arg5) { - super(arg0, arg1, arg2, arg3, arg4, arg5); - } - - protected void drawGradientRect( - int i, int j, int k, int l, int m, int n) { - a(i, j, k, l, m, n); - } - protected void drawTexturedModalRect( - int xPosition, int i, int j, int k, int l, int m) { - b(xPosition, i, j, k, l, m); - } - protected void drawRect(int i, int j, int k, int l, int textColor) { - a(i, j, k, l, textColor); - } - - protected String getDisplayString() { - return e; - } - protected int getTexture(Minecraft mc, String texture) { - return mc.o.b(texture); // renderengine.getTexture - } - protected int getHoverState(boolean mouseOverButton) { - return this.a(mouseOverButton); - } - - protected boolean isEnabled2() { - return this.h; - } - protected boolean isEnabled() { - return this.g; - } - - protected int getXPosition() { - return c; - } - protected int getYPosition() { - return d; - } - protected int getWidth() { - return a; - } - protected int getHeight() { - return b; - } -} \ No newline at end of file diff --git a/src/doc/README.txt b/src/doc/README.txt deleted file mode 100644 index f62a244e..00000000 --- a/src/doc/README.txt +++ /dev/null @@ -1,9 +0,0 @@ -|==============================================================| -| INVENTORY TWEAKS Mod - By Jimeo Wan (jimeo.wan at gmail.com) | -| Readme | -|==============================================================| - -Need help? - -* Official website: http://modding.kalam-alami.net/invtweaks -* Minecraft Forum thread: http://www.minecraftforum.net/topic/323444-inventory-tweaks diff --git a/src/doc/license.txt b/src/doc/license.txt deleted file mode 100644 index a8e93832..00000000 --- a/src/doc/license.txt +++ /dev/null @@ -1,24 +0,0 @@ -|==============================================================| -| INVENTORY TWEAKS Mod - By Jimeo Wan (jimeo.wan at gmail.com) | -| License (MIT) | -|==============================================================| - -Copyright (c) 2011-2012 Marwane Kalam-Alami - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/src/DefaultConfig.dat b/src/minecraft/invtweaks/DefaultConfig.dat similarity index 100% rename from src/DefaultConfig.dat rename to src/minecraft/invtweaks/DefaultConfig.dat diff --git a/src/DefaultTree.dat b/src/minecraft/invtweaks/DefaultTree.dat similarity index 100% rename from src/DefaultTree.dat rename to src/minecraft/invtweaks/DefaultTree.dat diff --git a/src/InvTweaks.java b/src/minecraft/invtweaks/InvTweaks.java similarity index 87% rename from src/InvTweaks.java rename to src/minecraft/invtweaks/InvTweaks.java index e0c5f2d6..2484dadb 100644 --- a/src/InvTweaks.java +++ b/src/minecraft/invtweaks/InvTweaks.java @@ -1,3 +1,5 @@ +package invtweaks; + import invtweaks.InvTweaksConst; import invtweaks.InvTweaksItemTree; import invtweaks.InvTweaksItemTreeItem; @@ -13,6 +15,12 @@ import java.util.logging.Logger; import net.minecraft.client.Minecraft; +import net.minecraft.src.GuiButton; +import net.minecraft.src.GuiContainer; +import net.minecraft.src.GuiScreen; +import net.minecraft.src.InvTweaksObfuscation; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Slot; import org.lwjgl.LWJGLException; import org.lwjgl.input.Keyboard; @@ -23,14 +31,14 @@ /** * Main class for Inventory Tweaks, which maintains various hooks * and dispatches the events to the correct handlers. - * + * * @author Jimeo Wan * * Contact: jimeo.wan (at) gmail (dot) com * Website: {@link http://wan.ka.free.fr/?invtweaks} * Source code: {@link https://github.com/jimeowan/inventory-tweaks} * License: MIT - * + * */ public class InvTweaks extends InvTweaksObfuscation { @@ -42,7 +50,7 @@ public class InvTweaks extends InvTweaksObfuscation { * The configuration loader. */ private InvTweaksConfigManager cfgManager = null; - + /** * Attributes to remember the status of chest sorting * while using middle clicks. @@ -50,21 +58,22 @@ public class InvTweaks extends InvTweaksObfuscation { private int chestAlgorithm = InvTweaksHandlerSorting.ALGORITHM_DEFAULT; private long chestAlgorithmClickTimestamp = 0; private boolean chestAlgorithmButtonDown = false; - + /** * Various information concerning the context, stored on * each tick to allow for certain features (auto-refill, * sorting on pick up...) */ private int storedStackId = 0, storedStackDamage = -1, storedFocusedSlot = -1; - private um[] hotbarClone = new um[InvTweaksConst.INVENTORY_HOTBAR_SIZE]; + private ItemStack[] hotbarClone = new ItemStack[InvTweaksConst.INVENTORY_HOTBAR_SIZE]; private boolean hadFocus = true, mouseWasDown = false;; - + + private boolean wasInGUI = false; /** * Allows to trigger some logic only every Const.POLLING_DELAY. */ private int tickNumber = 0, lastPollingTickNumber = -InvTweaksConst.POLLING_DELAY; - + /** * Stores when the sorting key was last pressed (allows to detect long key holding) */ @@ -73,7 +82,7 @@ public class InvTweaks extends InvTweaksObfuscation { private boolean itemPickupPending = false; - + /** * Creates an instance of the mod, and loads the configuration * from the files, creating them if necessary. @@ -94,7 +103,7 @@ public InvTweaks(Minecraft mc) { } else { log.severe("Mod failed to initialize!"); } - + } @@ -108,17 +117,20 @@ public void onTickInGame() { return; } handleAutoRefill(); + if(wasInGUI) { + wasInGUI = false; + } } } - + /** * To be called on each tick when a menu is open. * Handles the GUI additions and the middle clicking. - * @param aue + * @param GuiScreen */ - public void onTickInGUI(aue guiScreen) { + public void onTickInGUI(GuiScreen guiScreen) { synchronized (this) { - handleMiddleClick(guiScreen); // Called before the rest to be able to trigger config reload + handleMiddleClick(guiScreen); // Called before the rest to be able to trigger config reload if (!onTick()) { return; } @@ -126,12 +138,20 @@ public void onTickInGUI(aue guiScreen) { unlockKeysIfNecessary(); } handleGUILayout(guiScreen); + if(!wasInGUI) { + // Right-click is always true on initial open of GUI. + // Ignore it to prevent erroneous trigger of shortcuts. + mouseWasDown = true; + } handleShortcuts(guiScreen); - - // Copy some info about current selected stack for auto-refill - um currentStack = getFocusedStack(); + + // Copy some info about current selected stack for auto-refill + ItemStack currentStack = getFocusedStack(); storedStackId = (currentStack == null) ? 0 : getItemID(currentStack); storedStackDamage = (currentStack == null) ? 0 : getItemDamage(currentStack); + if(!wasInGUI) { + wasInGUI = true; + } } } @@ -141,14 +161,14 @@ public void onTickInGUI(aue guiScreen) { */ public final void onSortingKeyPressed() { synchronized (this) { - + // Check config loading success if (!cfgManager.makeSureConfigurationIsLoaded()) { return; } - + // Check current GUI - aue guiScreen = getCurrentScreen(); + GuiScreen guiScreen = getCurrentScreen(); if (guiScreen == null || (isValidChest(guiScreen) || isValidInventory(guiScreen))) { // Sorting! handleSorting(guiScreen); @@ -161,7 +181,7 @@ public final void onSortingKeyPressed() { * Moves the picked up item in another slot that matches best the current configuration. */ public void onItemPickup() { - + if (!cfgManager.makeSureConfigurationIsLoaded()) { return; } @@ -170,30 +190,29 @@ public void onItemPickup() { if (cfgManager.getConfig().getProperty(InvTweaksConfig.PROP_ENABLE_SORTING_ON_PICKUP).equals("false")) { return; } - + try { InvTweaksContainerSectionManager containerMgr = new InvTweaksContainerSectionManager(mc, InvTweaksContainerSection.INVENTORY); - containerMgr.setClickDelay(config.getClickDelay()); // Find stack slot (look in hotbar only). // We're looking for a brand new stack in the hotbar // (not an existing stack whose amount has been increased) int currentSlot = -1; for (int i = 0; i < InvTweaksConst.INVENTORY_HOTBAR_SIZE; i++) { - um currentHotbarStack = containerMgr.getItemStack(i + 27); + ItemStack currentHotbarStack = containerMgr.getItemStack(i + 27); // Don't move already started stacks if (currentHotbarStack != null && getAnimationsToGo(currentHotbarStack) == 5 && hotbarClone[i] == null) { currentSlot = i + 27; } } - + if (currentSlot != -1) { itemPickupPending = false; - + // Find preffered slots List prefferedPositions = new LinkedList(); InvTweaksItemTree tree = config.getTree(); - um stack = containerMgr.getItemStack(currentSlot); + ItemStack stack = containerMgr.getItemStack(currentSlot); List items = tree.getItems(getItemID(stack), getItemDamage(stack)); for (InvTweaksConfigSortingRule rule : config.getRules()) { @@ -203,7 +222,7 @@ public void onItemPickup() { } } } - + // Find best slot for stack boolean hasToBeMoved = true; if (prefferedPositions != null) { @@ -226,7 +245,7 @@ else if (containerMgr.getItemStack(newSlot) == null) { } } } - + // Else, put the slot anywhere if (hasToBeMoved) { for (int i = 0; i < containerMgr.getSize(); i++) { @@ -237,9 +256,9 @@ else if (containerMgr.getItemStack(newSlot) == null) { } } } - + } - + } catch (Exception e) { logInGameError("Failed to move picked up stack", e); } @@ -258,7 +277,7 @@ public void logInGame(String message, boolean alreadyTranslated) { addChatMessage(formattedMsg); log.info(formattedMsg); } - + public void logInGameError(String message, Exception e) { String formattedMsg = buildlogString(Level.SEVERE, InvTweaksLocalization.get(message), e); addChatMessage(formattedMsg); @@ -288,7 +307,7 @@ public static Minecraft getMinecraftInstance() { public static InvTweaksConfigManager getConfigManager() { return instance.cfgManager; } - + public static boolean classExists(String className) { try { return Class.forName(className) != null; @@ -300,22 +319,22 @@ public static boolean classExists(String className) { private boolean onTick() { tickNumber++; - + // Not calling "cfgManager.makeSureConfigurationIsLoaded()" for performance reasons InvTweaksConfig config = cfgManager.getConfig(); - if (config == null) { + if (config == null) { return false; } - + // Clone the hotbar to be able to monitor changes on it if (itemPickupPending) { onItemPickup(); } - aue currentScreen = getCurrentScreen(); + GuiScreen currentScreen = getCurrentScreen(); if (currentScreen == null || isGuiInventory(currentScreen)) { cloneHotbar(); } - + // Handle sort key if (Keyboard.isKeyDown(config.getSortKeyCode())) { if (!sortKeyDown) { @@ -326,18 +345,18 @@ private boolean onTick() { else { sortKeyDown = false; } - + // Handle config switch handleConfigSwitch(); - + return true; - + } - + private void handleConfigSwitch() { - + InvTweaksConfig config = cfgManager.getConfig(); - aue currentScreen = getCurrentScreen(); + GuiScreen currentScreen = getCurrentScreen(); // Switch between configurations (shortcut) cfgManager.getShortcutsHandler().updatePressedKeys(); @@ -362,11 +381,11 @@ private void handleConfigSwitch() { case Keyboard.KEY_NUMPAD9: newRuleset = config.switchConfig(8); break; } } - + if (newRuleset != null) { logInGame(String.format(InvTweaksLocalization.get("invtweaks.loadconfig.enabled"), newRuleset), true); // Hack to prevent 2nd way to switch configs from being enabled - sortingKeyPressedDate = Integer.MAX_VALUE; + sortingKeyPressedDate = Integer.MAX_VALUE; } } @@ -392,11 +411,11 @@ private void handleConfigSwitch() { } - private void handleSorting(aue guiScreen) { - - um selectedItem = null; + private void handleSorting(GuiScreen guiScreen) { + + ItemStack selectedItem = null; int focusedSlot = getFocusedSlot(); - um[] mainInventory = getMainInventory(); + ItemStack[] mainInventory = getMainInventory(); if (focusedSlot < mainInventory.length && focusedSlot >= 0) { selectedItem = mainInventory[focusedSlot]; } @@ -423,22 +442,22 @@ private void handleSorting(aue guiScreen) { } private void handleAutoRefill() { - - um currentStack = getFocusedStack(); + + ItemStack currentStack = getFocusedStack(); int currentStackId = (currentStack == null) ? 0 : getItemID(currentStack); int currentStackDamage = (currentStack == null) ? 0 : getItemDamage(currentStack); int focusedSlot = getFocusedSlot() + 27; // Convert to container slots index InvTweaksConfig config = cfgManager.getConfig(); - + if (currentStackId != storedStackId || currentStackDamage != storedStackDamage) { - + if (storedFocusedSlot != focusedSlot) { // Filter selection change storedFocusedSlot = focusedSlot; } else if ((currentStack == null || getItemID(currentStack) == 281 && storedStackId == 282) // Handle eaten mushroom soup && (getCurrentScreen() == null || // Filter open inventory or other window isGuiEditSign(getCurrentScreen()))) { - + if (config.isAutoRefillEnabled(storedStackId, storedStackId)) { try { cfgManager.getAutoRefillHandler().autoRefillSlot(focusedSlot, storedStackId, storedStackDamage); @@ -463,50 +482,49 @@ else if ((currentStack == null || getItemID(currentStack) == 281 && storedStackI } } } - - // Copy some info about current selected stack for auto-refill + + // Copy some info about current selected stack for auto-refill storedStackId = currentStackId; storedStackDamage = currentStackDamage; - + } - private void handleMiddleClick(aue guiScreen) { - + private void handleMiddleClick(GuiScreen guiScreen) { + if (Mouse.isButtonDown(2)) { - + if (!cfgManager.makeSureConfigurationIsLoaded()) { return; } InvTweaksConfig config = cfgManager.getConfig(); - + // Check that middle click sorting is allowed if (config.getProperty(InvTweaksConfig.PROP_ENABLE_MIDDLE_CLICK) .equals(InvTweaksConfig.VALUE_TRUE)) { - + if (!chestAlgorithmButtonDown) { chestAlgorithmButtonDown = true; InvTweaksContainerManager containerMgr = new InvTweaksContainerManager(mc); - containerMgr.setClickDelay(config.getClickDelay()); - sq slotAtMousePosition = containerMgr.getSlotAtMousePosition(); + Slot slotAtMousePosition = containerMgr.getSlotAtMousePosition(); InvTweaksContainerSection target = null; if (slotAtMousePosition != null) { target = containerMgr.getSlotSection(getSlotNumber(slotAtMousePosition)); } - + if (isValidChest(guiScreen)) { - + // Check if the middle click target the chest or the inventory // (copied GuiContainer.getSlotAtPosition algorithm) - auy guiContainer = asGuiContainer(guiScreen); - + GuiContainer guiContainer = asGuiContainer(guiScreen); + if (InvTweaksContainerSection.CHEST.equals(target)) { - + // Play click playClick(); - + long timestamp = System.currentTimeMillis(); - if (timestamp - chestAlgorithmClickTimestamp > + if (timestamp - chestAlgorithmClickTimestamp > InvTweaksConst.CHEST_ALGORITHM_SWAP_MAX_INTERVAL) { chestAlgorithm = InvTweaksHandlerSorting.ALGORITHM_DEFAULT; } @@ -522,29 +540,40 @@ private void handleMiddleClick(aue guiScreen) { chestAlgorithm = (chestAlgorithm + 1) % 3; chestAlgorithmClickTimestamp = timestamp; + } else if(InvTweaksContainerSection.CRAFTING_IN.equals(target)) { + try { + new InvTweaksHandlerSorting(mc, cfgManager.getConfig(), + InvTweaksContainerSection.CRAFTING_IN, + InvTweaksHandlerSorting.ALGORITHM_EVEN_STACKS, + (containerMgr.getSize(target) == 9) ? 3 : 2).sort(); + } catch(Exception e) { + logInGameError("invtweaks.sort.crafting.error", e); + e.printStackTrace(); + } + } else if (InvTweaksContainerSection.INVENTORY_HOTBAR.equals(target) || (InvTweaksContainerSection.INVENTORY_NOT_HOTBAR.equals(target))) { handleSorting(guiScreen); } - - } else if (isValidInventory(guiScreen)) { - - /* - // Crafting stacks evening (hook ready, TODO implement algorithm) - if (InvTweaksContainerSection.CRAFTING_IN.equals(target)) { + + } + + else if (isValidInventory(guiScreen)) { + if (InvTweaksContainerSection.CRAFTING_IN.equals(target)) { + // Crafting stacks evening try { - new InvTweaksHandlerSorting(mc, cfgManager.getConfig(), - InvTweaksContainerSection.CRAFTING_IN, - InvTweaksHandlerSorting.ALGORITHM_EVEN_STACKS, - (containerMgr.getSize(target) == 9) ? 3 : 2).sort(); - } catch (Exception e) { + new InvTweaksHandlerSorting(mc, cfgManager.getConfig(), + InvTweaksContainerSection.CRAFTING_IN, + InvTweaksHandlerSorting.ALGORITHM_EVEN_STACKS, + (containerMgr.getSize(target) == 9) ? 3 : 2).sort(); + } catch (Exception e) { logInGameError("invtweaks.sort.crafting.error", e); e.printStackTrace(); - } - }*/ - - handleSorting(guiScreen); - + } + } else { + // Sorting + handleSorting(guiScreen); + } } } } @@ -553,14 +582,14 @@ private void handleMiddleClick(aue guiScreen) { } } - private void handleGUILayout(aue guiScreen) { + private void handleGUILayout(GuiScreen guiScreen) { InvTweaksConfig config = cfgManager.getConfig(); boolean isValidChest = isValidChest(guiScreen); if (isValidChest || (isStandardInventory(guiScreen) && !isGuiEnchantmentTable(guiScreen))) { - auy guiContainer = asGuiContainer(guiScreen); + GuiContainer guiContainer = asGuiContainer(guiScreen); int w = 10, h = 10; // Look for the mods buttons @@ -568,7 +597,7 @@ private void handleGUILayout(aue guiScreen) { List controlList = getControlList(guiScreen); for (Object o : controlList) { if (isGuiButton(o)) { - ast button = asGuiButton(o); + GuiButton button = asGuiButton(o); if (getId(button) == InvTweaksConst.JIMEOWAN_ID) { customButtonsAdded = true; break; @@ -577,10 +606,12 @@ private void handleGUILayout(aue guiScreen) { } if (!customButtonsAdded) { - + // Check for custom button texture - boolean customTextureAvailable = hasTexture("/gui/button10px.png"); - + // Disabled because the current implementation requires reflection, which is difficult to manage + // in a MCP environment - TODO find a workaround to access the texture packs data + boolean customTextureAvailable = false;//hasTexture("/gui/button10px.png"); + // Inventory button if (!isValidChest) { controlList.add(new InvTweaksGuiSettingsButton( @@ -609,13 +640,13 @@ private void handleGUILayout(aue guiScreen) { y += 50; } } - + // Settings button controlList.add(new InvTweaksGuiSettingsButton( - cfgManager, id++, + cfgManager, id++, (isChestWayTooBig) ? x + 22 : x - 1, (isChestWayTooBig) ? y - 3 : y, - w, h, "...", + w, h, "...", InvTweaksLocalization.get("invtweaks.button.settings.tooltip"), customTextureAvailable)); @@ -623,7 +654,7 @@ private void handleGUILayout(aue guiScreen) { if (!config.getProperty(InvTweaksConfig.PROP_SHOW_CHEST_BUTTONS).equals("false")) { int rowSize = getContainerRowSize(guiContainer); - + InvTweaksObfuscationGuiButton button = new InvTweaksGuiSortingButton( cfgManager, id++, (isChestWayTooBig) ? x + 22 : x - 13, @@ -658,12 +689,12 @@ private void handleGUILayout(aue guiScreen) { } } } - + else { // Remove "..." button from non-survival tabs of the creative screen if (isGuiInventoryCreative(guiScreen)) { List controlList = getControlList(guiScreen); - ast buttonToRemove = null; + GuiButton buttonToRemove = null; for (Object o : controlList) { if (isGuiButton(o)) { if (getId(asGuiButton(o)) == InvTweaksConst.JIMEOWAN_ID) { @@ -675,12 +706,12 @@ private void handleGUILayout(aue guiScreen) { if (buttonToRemove != null) { controlList.remove(buttonToRemove); } - + } } } - + /** * Hacky parsing of the NEI configuration file to see if the mod is enabled or not. */ @@ -709,23 +740,23 @@ private boolean isNotEnoughItemsEnabled() { } } - private void handleShortcuts(aue guiScreen) { - + private void handleShortcuts(GuiScreen guiScreen) { + // Check open GUI if (!(isValidChest(guiScreen) || isStandardInventory(guiScreen))) { return; } - + // FIXME Shortcuts are currently buggy within creative inventory if (isGuiInventoryCreative(guiScreen)) { return; } - + // Configurable shortcuts if (Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) { if (!mouseWasDown) { mouseWasDown = true; - + // The mouse has just been clicked, // trigger a shortcut according to the pressed keys. if (cfgManager.getConfig().getProperty( @@ -737,10 +768,10 @@ private void handleShortcuts(aue guiScreen) { else { mouseWasDown = false; } - + } - private int getContainerRowSize(auy guiContainer) { + private int getContainerRowSize(GuiContainer guiContainer) { if (isGuiChest(guiContainer)) { return InvTweaksConst.CHEST_ROW_SIZE; } @@ -799,7 +830,7 @@ private void unlockKeysIfNecessary() { * (especially needed by the "on pickup" features). */ private void cloneHotbar() { - um[] mainInventory = getMainInventory(); + ItemStack[] mainInventory = getMainInventory(); for (int i = 0; i < 9; i++) { if (mainInventory[i] != null) { hotbarClone[i] = copy(mainInventory[i]); @@ -827,5 +858,5 @@ private String buildlogString(Level level, String message, Exception e) { private String buildlogString(Level level, String message) { return InvTweaksConst.INGAME_LOG_PREFIX + ((level.equals(Level.SEVERE)) ? "[ERROR] " : "") + message; } - + } diff --git a/src/InvTweaksConfig.java b/src/minecraft/invtweaks/InvTweaksConfig.java similarity index 97% rename from src/InvTweaksConfig.java rename to src/minecraft/invtweaks/InvTweaksConfig.java index 2cb9e5f1..117c58c2 100644 --- a/src/InvTweaksConfig.java +++ b/src/minecraft/invtweaks/InvTweaksConfig.java @@ -1,3 +1,5 @@ +package invtweaks; + import invtweaks.InvTweaksConst; import invtweaks.InvTweaksItemTree; import invtweaks.InvTweaksItemTreeItem; @@ -30,7 +32,6 @@ */ public class InvTweaksConfig { - @SuppressWarnings("unused") private static final Logger log = Logger.getLogger("InvTweaks"); public static final String PROP_VERSION = "version"; @@ -54,7 +55,6 @@ public class InvTweaksConfig { public static final String PROP_SHORTCUT_DROP = "shortcutKeyDrop"; public static final String PROP_SHORTCUT_UP = "shortcutKeyToUpperSection"; public static final String PROP_SHORTCUT_DOWN = "shortcutKeyToLowerSection"; - public static final String PROP_SLOW_SORTING = "slowSorting"; // Other public static final String PROP_ENABLE_SOUNDS = "enableSounds"; @@ -360,16 +360,6 @@ public boolean isAutoRefillEnabled(int itemID, int itemDamage) { } } - public int getClickDelay() { - String slowSortingValue = getProperty(PROP_SLOW_SORTING); - if (VALUE_FALSE.equals(slowSortingValue)) { - return 0; - } - else { - return InvTweaksConst.SLOW_SORTING_DELAY; - } - } - /** * Check potential conflicts with Convenient Inventory (regarding the middle * click shortcut), and solve them according to the CI version. @@ -486,7 +476,6 @@ private void reset() { properties.put(PROP_ENABLE_SHORTCUTS, VALUE_TRUE); properties.put(PROP_ENABLE_AUTO_EQUIP_ARMOR, VALUE_FALSE); properties.put(PROP_KEY_SORT_INVENTORY, "R"); - properties.put(PROP_SLOW_SORTING, VALUE_FALSE); properties.put(PROP_SHORTCUT_ALL_ITEMS, "LCONTROL+LSHIFT, RCONTROL+RSHIFT"); properties.put(PROP_SHORTCUT_EVERYTHING, "SPACE"); diff --git a/src/InvTweaksConfigInventoryRuleset.java b/src/minecraft/invtweaks/InvTweaksConfigInventoryRuleset.java similarity index 99% rename from src/InvTweaksConfigInventoryRuleset.java rename to src/minecraft/invtweaks/InvTweaksConfigInventoryRuleset.java index ba31f005..cba85782 100644 --- a/src/InvTweaksConfigInventoryRuleset.java +++ b/src/minecraft/invtweaks/InvTweaksConfigInventoryRuleset.java @@ -1,5 +1,4 @@ - - +package invtweaks; import invtweaks.InvTweaksConst; import invtweaks.InvTweaksItemTree; @@ -21,7 +20,6 @@ */ public class InvTweaksConfigInventoryRuleset { - @SuppressWarnings("unused") private static final Logger log = Logger.getLogger("InvTweaks"); private String name; diff --git a/src/InvTweaksConfigManager.java b/src/minecraft/invtweaks/InvTweaksConfigManager.java similarity index 99% rename from src/InvTweaksConfigManager.java rename to src/minecraft/invtweaks/InvTweaksConfigManager.java index b69718ba..dec48e6d 100644 --- a/src/InvTweaksConfigManager.java +++ b/src/minecraft/invtweaks/InvTweaksConfigManager.java @@ -1,5 +1,4 @@ - - +package invtweaks; import invtweaks.InvTweaksConst; import invtweaks.InvTweaksItemTreeLoader; diff --git a/src/InvTweaksConfigProperties.java b/src/minecraft/invtweaks/InvTweaksConfigProperties.java old mode 100755 new mode 100644 similarity index 97% rename from src/InvTweaksConfigProperties.java rename to src/minecraft/invtweaks/InvTweaksConfigProperties.java index f69fc19f..b446e252 --- a/src/InvTweaksConfigProperties.java +++ b/src/minecraft/invtweaks/InvTweaksConfigProperties.java @@ -1,4 +1,4 @@ - +package invtweaks; import java.util.Collections; import java.util.Enumeration; diff --git a/src/InvTweaksConfigSortingRule.java b/src/minecraft/invtweaks/InvTweaksConfigSortingRule.java similarity index 99% rename from src/InvTweaksConfigSortingRule.java rename to src/minecraft/invtweaks/InvTweaksConfigSortingRule.java index 1b696754..d21b6283 100644 --- a/src/InvTweaksConfigSortingRule.java +++ b/src/minecraft/invtweaks/InvTweaksConfigSortingRule.java @@ -1,7 +1,4 @@ - - - -import invtweaks.InvTweaksItemTree; +package invtweaks; import java.awt.Point; import java.util.logging.Logger; @@ -17,7 +14,6 @@ */ public class InvTweaksConfigSortingRule implements Comparable { - @SuppressWarnings("unused") private static final Logger log = Logger.getLogger("InvTweaks"); private String constraint; diff --git a/src/InvTweaksConfigSortingRuleType.java b/src/minecraft/invtweaks/InvTweaksConfigSortingRuleType.java old mode 100755 new mode 100644 similarity index 96% rename from src/InvTweaksConfigSortingRuleType.java rename to src/minecraft/invtweaks/InvTweaksConfigSortingRuleType.java index be30a50a..05dd2cee --- a/src/InvTweaksConfigSortingRuleType.java +++ b/src/minecraft/invtweaks/InvTweaksConfigSortingRuleType.java @@ -1,3 +1,5 @@ +package invtweaks; + public enum InvTweaksConfigSortingRuleType { RECTANGLE(1), ROW(2), COLUMN(3), SLOT(4); diff --git a/src/invtweaks/InvTweaksConst.java b/src/minecraft/invtweaks/InvTweaksConst.java similarity index 91% rename from src/invtweaks/InvTweaksConst.java rename to src/minecraft/invtweaks/InvTweaksConst.java index 017b4ae3..2bec261a 100644 --- a/src/invtweaks/InvTweaksConst.java +++ b/src/minecraft/invtweaks/InvTweaksConst.java @@ -8,12 +8,11 @@ public class InvTweaksConst { // Mod version - public static final String MOD_VERSION = "1.45 (1.4.4)"; + public static final String MOD_VERSION = "1.50 (1.4.7)"; // Mod tree version // Change only when the tree evolves significantly enough to need to override all configs public static final String TREE_VERSION = "1.4.0"; - // Timing constants public static final int RULESET_SWAP_DELAY = 1000; @@ -54,11 +53,12 @@ public class InvTweaksConst { public static final int SLOW_SORTING_DELAY = 30; /** - * Returns the Minecraft folder ensuring: - It is an absolute path - It ends - * with a folder separator + * Returns the Minecraft folder ensuring: + * - It is an absolute path + * - It ends with a folder separator */ public static String getMinecraftDir() { - String absolutePath = Minecraft.b().getAbsolutePath(); + String absolutePath = Minecraft.getMinecraftDir().getAbsolutePath(); if (absolutePath.endsWith(".")) { return absolutePath.substring(0, absolutePath.length() - 1); } diff --git a/src/InvTweaksContainerManager.java b/src/minecraft/invtweaks/InvTweaksContainerManager.java old mode 100755 new mode 100644 similarity index 90% rename from src/InvTweaksContainerManager.java rename to src/minecraft/invtweaks/InvTweaksContainerManager.java index ee0a3477..60ab2fa1 --- a/src/InvTweaksContainerManager.java +++ b/src/minecraft/invtweaks/InvTweaksContainerManager.java @@ -1,3 +1,4 @@ +package invtweaks; import java.util.HashMap; import java.util.List; @@ -7,6 +8,12 @@ import org.lwjgl.input.Mouse; import net.minecraft.client.Minecraft; +import net.minecraft.src.Container; +import net.minecraft.src.GuiContainer; +import net.minecraft.src.GuiScreen; +import net.minecraft.src.InvTweaksObfuscation; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Slot; /** * Allows to perform various operations on the inventory @@ -25,10 +32,10 @@ public class InvTweaksContainerManager extends InvTweaksObfuscation { public static final int ACTION_TIMEOUT = 500; public static final int POLLING_DELAY = 3; - private auy guiContainer; - private rp container; - private Map> slotRefs - = new HashMap>(); + private GuiContainer guiContainer; + private Container container; + private Map> slotRefs + = new HashMap>(); private int clickDelay = 0; @@ -42,7 +49,7 @@ public class InvTweaksContainerManager extends InvTweaksObfuscation { public InvTweaksContainerManager(Minecraft mc) { super(mc); - aue currentScreen = getCurrentScreen(); + GuiScreen currentScreen = getCurrentScreen(); if (isGuiContainer(currentScreen)) { this.guiContainer = asGuiContainer(currentScreen); this.container = getContainer(this.guiContainer); @@ -51,7 +58,7 @@ public InvTweaksContainerManager(Minecraft mc) { this.container = getPlayerContainer(); } - List slots = (List) getSlots(container); + List slots = (List) getSlots(container); int size = slots.size(); boolean guiWithInventory = true; @@ -143,8 +150,8 @@ else if (isContainerBrewingStand(container)) { public boolean move(InvTweaksContainerSection srcSection, int srcIndex, InvTweaksContainerSection destSection, int destIndex) { //System.out.println(srcSection + ":" + srcIndex + " to " + destSection + ":" + destIndex); - um srcStack = getItemStack(srcSection, srcIndex); - um destStack = getItemStack(destSection, destIndex); + ItemStack srcStack = getItemStack(srcSection, srcIndex); + ItemStack destStack = getItemStack(destSection, destIndex); if (srcStack == null && destIndex != DROP_SLOT) { return false; @@ -219,12 +226,12 @@ public boolean moveSome(InvTweaksContainerSection srcSection, int srcIndex, InvTweaksContainerSection destSection, int destIndex, int amount) { - um source = getItemStack(srcSection, srcIndex); + ItemStack source = getItemStack(srcSection, srcIndex); if (source == null || srcSection == destSection && srcIndex == destIndex) { return true; } - um destination = getItemStack(srcSection, srcIndex); + ItemStack destination = getItemStack(srcSection, srcIndex); int sourceSize = getStackSize(source); int movedAmount = Math.min(amount, sourceSize); @@ -261,7 +268,7 @@ public boolean dropSome(InvTweaksContainerSection srcSection, int srcIndex, int * @throws Exception */ public boolean putHoldItemDown(InvTweaksContainerSection destSection, int destIndex) { - um heldStack = getHeldStack(); + ItemStack heldStack = getHeldStack(); if (heldStack != null) { if (getItemStack(destSection, destIndex) == null) { click(destSection, destIndex, false); @@ -304,13 +311,13 @@ public void click(InvTweaksContainerSection section, int index, boolean rightCli } } - public sq getSlotAtMousePosition() { + public Slot getSlotAtMousePosition() { // Copied from GuiContainer if (guiContainer != null) { int x = getMouseX(); int y = getMouseY(); for (int k = 0; k < getSlots(getContainer(guiContainer)).size(); k++) { - sq slot = (sq) getSlots(getContainer(guiContainer)).get(k); + Slot slot = (Slot) getSlots(getContainer(guiContainer)).get(k); if (getIsMouseOverSlot(slot, x, y)) { return slot; } @@ -322,15 +329,15 @@ public sq getSlotAtMousePosition() { } } - public boolean getIsMouseOverSlot(sq slot) { + public boolean getIsMouseOverSlot(Slot slot) { return getIsMouseOverSlot(slot, getMouseX(), getMouseY()); } - private boolean getIsMouseOverSlot(sq slot, int x, int y) { + private boolean getIsMouseOverSlot(Slot slot, int x, int y) { // Copied from GuiContainer if (guiContainer != null) { - int i = guiContainer.n; // TODO Deobfuscate - int j = guiContainer.o; + int i = (guiContainer.width - getGuiWidth(guiContainer)) / 2; + int j = (guiContainer.height - getGuiHeight(guiContainer)) / 2; x -= i; y -= j; return x >= getXDisplayPosition(slot) - 1 @@ -356,7 +363,7 @@ public boolean hasSection(InvTweaksContainerSection section) { return slotRefs.containsKey(section); } - public List getSlots(InvTweaksContainerSection section) { + public List getSlots(InvTweaksContainerSection section) { return slotRefs.get(section); } @@ -365,7 +372,7 @@ public List getSlots(InvTweaksContainerSection section) { */ public int getSize() { int result = 0; - for (List slots : slotRefs.values()) { + for (List slots : slotRefs.values()) { result += slots.size(); } return result; @@ -392,7 +399,7 @@ public int getSize(InvTweaksContainerSection section) { */ public int getFirstEmptyIndex(InvTweaksContainerSection section) { int i = 0; - for (sq slot : slotRefs.get(section)) { + for (Slot slot : slotRefs.get(section)) { if (!hasStack(slot)) { return i; } @@ -414,8 +421,8 @@ public boolean isSlotEmpty(InvTweaksContainerSection section, int slot) { } } - public sq getSlot(InvTweaksContainerSection section, int index) { - List slots = slotRefs.get(section); + public Slot getSlot(InvTweaksContainerSection section, int index) { + List slots = slotRefs.get(section); if (slots != null) { return slots.get(index); } else { @@ -446,7 +453,7 @@ public int getSlotIndex(int slotNumber, boolean preferInventory) { || (preferInventory && section != InvTweaksContainerSection.INVENTORY_NOT_HOTBAR && section != InvTweaksContainerSection.INVENTORY_HOTBAR)) { int i = 0; - for (sq slot : slotRefs.get(section)) { + for (Slot slot : slotRefs.get(section)) { if (getSlotNumber(slot) == slotNumber) { return i; } @@ -466,7 +473,7 @@ public InvTweaksContainerSection getSlotSection(int slotNumber) { // TODO Caching with getSlotIndex for (InvTweaksContainerSection section : slotRefs.keySet()) { if (section != InvTweaksContainerSection.INVENTORY) { - for (sq slot : slotRefs.get(section)) { + for (Slot slot : slotRefs.get(section)) { if (getSlotNumber(slot) == slotNumber) { return section; } @@ -482,7 +489,7 @@ public InvTweaksContainerSection getSlotSection(int slotNumber) { * @param slot * @return An ItemStack or null. */ - public um getItemStack(InvTweaksContainerSection section, int index) + public ItemStack getItemStack(InvTweaksContainerSection section, int index) throws NullPointerException, IndexOutOfBoundsException { int slot = indexToSlot(section, index); if (slot >= 0 && slot < getSlots(container).size()) { @@ -492,13 +499,13 @@ public um getItemStack(InvTweaksContainerSection section, int index) } } - public rp getContainer() { + public Container getContainer() { return container; } private int getFirstEmptyUsableSlotNumber() { for (InvTweaksContainerSection section : slotRefs.keySet()) { - for (sq slot : slotRefs.get(section)) { + for (Slot slot : slotRefs.get(section)) { // Use only standard slot (to make sure // we can freely put and remove items there) if (isBasicSlot(slot) && !hasStack(slot)) { @@ -520,7 +527,7 @@ private int indexToSlot(InvTweaksContainerSection section, int index) { return DROP_SLOT; } if (hasSection(section)) { - sq slot = slotRefs.get(section).get(index); + Slot slot = slotRefs.get(section).get(index); if (slot != null) { return getSlotNumber(slot); } diff --git a/src/InvTweaksContainerSection.java b/src/minecraft/invtweaks/InvTweaksContainerSection.java old mode 100755 new mode 100644 similarity index 97% rename from src/InvTweaksContainerSection.java rename to src/minecraft/invtweaks/InvTweaksContainerSection.java index ada0ec0b..3a3f37d2 --- a/src/InvTweaksContainerSection.java +++ b/src/minecraft/invtweaks/InvTweaksContainerSection.java @@ -1,3 +1,5 @@ +package invtweaks; + /** * Names for specific parts of containers. * For unknown container types (such as mod containers), diff --git a/src/InvTweaksContainerSectionManager.java b/src/minecraft/invtweaks/InvTweaksContainerSectionManager.java old mode 100755 new mode 100644 similarity index 90% rename from src/InvTweaksContainerSectionManager.java rename to src/minecraft/invtweaks/InvTweaksContainerSectionManager.java index c0bdf19e..331568bc --- a/src/InvTweaksContainerSectionManager.java +++ b/src/minecraft/invtweaks/InvTweaksContainerSectionManager.java @@ -1,7 +1,12 @@ +package invtweaks; + import java.util.List; import java.util.concurrent.TimeoutException; import net.minecraft.client.Minecraft; +import net.minecraft.src.Container; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Slot; /** * Allows to perform various operations on a single section of @@ -63,7 +68,7 @@ public void click(int index, boolean rightClick) throws TimeoutException { containerMgr.click(section, index, rightClick); } - public List getSlots() { + public List getSlots() { return containerMgr.getSlots(section); } @@ -79,7 +84,7 @@ public boolean isSlotEmpty(int slot) { return containerMgr.isSlotEmpty(section, slot); } - public sq getSlot(int index) { + public Slot getSlot(int index) { return containerMgr.getSlot(section, index); } @@ -96,11 +101,11 @@ public boolean isSlotInSection(int slotNumber) { return containerMgr.getSlotSection(slotNumber) == section; } - public um getItemStack(int index) throws NullPointerException, IndexOutOfBoundsException { + public ItemStack getItemStack(int index) throws NullPointerException, IndexOutOfBoundsException { return containerMgr.getItemStack(section, index); } - public rp getContainer() { + public Container getContainer() { return containerMgr.getContainer(); } diff --git a/src/InvTweaksGuiIconButton.java b/src/minecraft/invtweaks/InvTweaksGuiIconButton.java old mode 100755 new mode 100644 similarity index 91% rename from src/InvTweaksGuiIconButton.java rename to src/minecraft/invtweaks/InvTweaksGuiIconButton.java index 40582e52..536e4f53 --- a/src/InvTweaksGuiIconButton.java +++ b/src/minecraft/invtweaks/InvTweaksGuiIconButton.java @@ -1,4 +1,4 @@ - +package invtweaks; import net.minecraft.client.Minecraft; @@ -23,13 +23,9 @@ public InvTweaksGuiIconButton(InvTweaksConfigManager cfgManager, this.useCustomTexture = useCustomTexture; } - public void a(Minecraft minecraft, int i, int j) { /* drawButton */ - super.a(minecraft, i, j); + public void drawButton(Minecraft minecraft, int i, int j) { + super.drawButton(minecraft, i, j); - if (!isEnabled2()) { - return; - } - // Draw background (use the 4 corners of the texture to fit best its small size) int k = getHoverState(isMouseOverButton(i, j)); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/minecraft/invtweaks/InvTweaksGuiModNotWorking.java b/src/minecraft/invtweaks/InvTweaksGuiModNotWorking.java new file mode 100644 index 00000000..cdf16719 --- /dev/null +++ b/src/minecraft/invtweaks/InvTweaksGuiModNotWorking.java @@ -0,0 +1,42 @@ +package invtweaks; + +import java.util.logging.Logger; + +import net.minecraft.client.Minecraft; +import net.minecraft.src.GuiButton; +import net.minecraft.src.GuiScreen; + + +/** + * A help menu for the NoCheatPlus conflict. + * + * @author Jimeo Wan + * + */ +public class InvTweaksGuiModNotWorking extends InvTweaksGuiSettingsAbstract { + + private static final Logger log = Logger.getLogger("InvTweaks"); + + public InvTweaksGuiModNotWorking(Minecraft mc, GuiScreen parentScreen, InvTweaksConfig config) { + super(mc, parentScreen, config); + } + + public void drawScreen(int i, int j, float f) { + super.drawScreen(i, j, f); + + int x = obf.getWindowWidth(this) / 2; + drawCenteredString(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.help.bugsorting.pt1"), x, 80, 0xBBBBBB); + drawCenteredString(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.help.bugsorting.pt2"), x, 95, 0xBBBBBB); + drawCenteredString(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.help.bugsorting.pt3"), x, 110, 0xBBBBBB); + drawCenteredString(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.help.bugsorting.pt4"), x, 150, 0xFFFF99); + } + + protected void actionPerformed(GuiButton guibutton) { + switch (obf.getId(guibutton)) { + // Back to main settings screen + case ID_DONE: + obf.displayGuiScreen(new InvTweaksGuiSettings(mc, parentScreen, config)); + } + } + +} diff --git a/src/InvTweaksGuiSettings.java b/src/minecraft/invtweaks/InvTweaksGuiSettings.java similarity index 82% rename from src/InvTweaksGuiSettings.java rename to src/minecraft/invtweaks/InvTweaksGuiSettings.java index ebbf5ab1..eee4b893 100644 --- a/src/InvTweaksGuiSettings.java +++ b/src/minecraft/invtweaks/InvTweaksGuiSettings.java @@ -1,3 +1,5 @@ +package invtweaks; + import invtweaks.InvTweaksConst; import java.awt.Desktop; @@ -7,6 +9,8 @@ import java.util.logging.Logger; import net.minecraft.client.Minecraft; +import net.minecraft.src.GuiButton; +import net.minecraft.src.GuiScreen; import org.lwjgl.input.Keyboard; import org.lwjgl.util.Point; @@ -20,7 +24,6 @@ */ public class InvTweaksGuiSettings extends InvTweaksGuiSettingsAbstract { - @SuppressWarnings("unused") private static final Logger log = Logger.getLogger("InvTweaks"); private final static int ID_MIDDLE_CLICK = 1; @@ -30,6 +33,7 @@ public class InvTweaksGuiSettings extends InvTweaksGuiSettingsAbstract { private final static int ID_AUTO_REFILL = 5; private final static int ID_MORE_OPTIONS = 6; private final static int ID_SORTING_KEY = 7; + private final static int ID_BUG_SORTING = 8; private final static int ID_EDITRULES = 100; private final static int ID_EDITTREE = 101; private final static int ID_HELP = 102; @@ -39,11 +43,13 @@ public class InvTweaksGuiSettings extends InvTweaksGuiSettingsAbstract { private static String labelAutoRefill; private static String labelAutoRefillBeforeBreak; private static String labelMoreOptions; + private static String labelBugSorting; private InvTweaksGuiTooltipButton sortMappingButton; private boolean sortMappingEdition = false; + - public InvTweaksGuiSettings(Minecraft mc, aue parentScreen, InvTweaksConfig config) { + public InvTweaksGuiSettings(Minecraft mc, GuiScreen parentScreen, InvTweaksConfig config) { super(mc, parentScreen, config); labelMiddleClick = InvTweaksLocalization.get("invtweaks.settings.middleclick"); @@ -51,11 +57,11 @@ public InvTweaksGuiSettings(Minecraft mc, aue parentScreen, InvTweaksConfig conf labelAutoRefill = InvTweaksLocalization.get("invtweaks.settings.autorefill"); labelAutoRefillBeforeBreak = InvTweaksLocalization.get("invtweaks.settings.beforebreak"); labelMoreOptions = InvTweaksLocalization.get("invtweaks.settings.moreoptions"); - + labelBugSorting = InvTweaksLocalization.get("invtweaks.help.bugsorting"); } - public void A_() { /* initGui */ - super.A_(); + public void initGui() { + super.initGui(); List controlList = obf.getControlList(this); Point p = new Point(); @@ -64,9 +70,9 @@ public void A_() { /* initGui */ // Create large buttons moveToButtonCoords(1, p); - controlList.add(new ast(ID_EDITRULES, p.getX() + 55, obf.getWindowHeight(this) / 6 + 96, InvTweaksLocalization.get("invtweaks.settings.rulesfile"))); - controlList.add(new ast(ID_EDITTREE, p.getX() + 55, obf.getWindowHeight(this) / 6 + 120, InvTweaksLocalization.get("invtweaks.settings.treefile"))); - controlList.add(new ast(ID_HELP, p.getX() + 55, obf.getWindowHeight(this) / 6 + 144, InvTweaksLocalization.get("invtweaks.settings.onlinehelp"))); + controlList.add(new GuiButton(ID_EDITRULES, p.getX() + 55, obf.getWindowHeight(this) / 6 + 96, InvTweaksLocalization.get("invtweaks.settings.rulesfile"))); + controlList.add(new GuiButton(ID_EDITTREE, p.getX() + 55, obf.getWindowHeight(this) / 6 + 120, InvTweaksLocalization.get("invtweaks.settings.treefile"))); + controlList.add(new GuiButton(ID_HELP, p.getX() + 55, obf.getWindowHeight(this) / 6 + 144, InvTweaksLocalization.get("invtweaks.settings.onlinehelp"))); // Create settings buttons @@ -101,6 +107,8 @@ public void A_() { /* initGui */ moveToButtonCoords(i++, p); controlList.add(new InvTweaksGuiTooltipButton(ID_MORE_OPTIONS, p.getX(), p.getY(), labelMoreOptions, InvTweaksLocalization.get("invtweaks.settings.moreoptions.tooltip"))); + controlList.add(new InvTweaksGuiTooltipButton(ID_BUG_SORTING, 5, this.height - 20, 100, 20, labelBugSorting, null, false)); + String middleClick = config.getProperty(InvTweaksConfig.PROP_ENABLE_MIDDLE_CLICK); moveToButtonCoords(i++, p); InvTweaksGuiTooltipButton middleClickBtn = new InvTweaksGuiTooltipButton(ID_MIDDLE_CLICK, p.getX(), p.getY(), computeBooleanButtonLabel( @@ -111,12 +119,12 @@ public void A_() { /* initGui */ obf.setEnabled(middleClickBtn, false); middleClickBtn.setTooltip(middleClickBtn.getTooltip() + "\n(" + InvTweaksLocalization.get("invtweaks.settings.disableci.tooltip")); } - + // Check if links to files are supported, if not disable the buttons if (!Desktop.isDesktopSupported()) { for (Object o : controlList) { if (obf.isGuiButton(o)) { - ast guiButton = obf.asGuiButton(o); + GuiButton guiButton = obf.asGuiButton(o); if (obf.getId(guiButton) >= ID_EDITRULES && obf.getId(guiButton) <= ID_HELP) { obf.setEnabled(guiButton, false); } @@ -129,14 +137,14 @@ public void A_() { /* initGui */ } - protected void a(ast guibutton) { /* actionPerformed */ - super.a(guibutton); + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); switch (obf.getId(guibutton)) { // Switch sorting key case ID_SORTING_KEY: - sortMappingButton.e = InvTweaksLocalization.get("invtweaks.settings.key") + " > ??? <"; + sortMappingButton.displayString = InvTweaksLocalization.get("invtweaks.settings.key") + " > ??? <"; sortMappingEdition = true; break; @@ -170,6 +178,11 @@ protected void a(ast guibutton) { /* actionPerformed */ obf.displayGuiScreen(new InvTweaksGuiSettingsAdvanced(mc, parentScreen, config)); break; + // Sorting bug help screen + case ID_BUG_SORTING: + obf.displayGuiScreen(new InvTweaksGuiModNotWorking(mc, parentScreen, config)); + break; + // Open rules configuration in external editor case ID_EDITRULES: try { @@ -200,14 +213,14 @@ protected void a(ast guibutton) { /* actionPerformed */ } } - - protected void a(char c, int keyCode) { /* keyPressed */ + + protected void keyTyped(char c, int keyCode) { if (sortMappingEdition) { String keyName = Keyboard.getKeyName(keyCode); config.setProperty(InvTweaksConfig.PROP_KEY_SORT_INVENTORY, keyName); - sortMappingButton.e = InvTweaksLocalization.get("invtweaks.settings.key") + " " + keyName; + sortMappingButton.displayString = InvTweaksLocalization.get("invtweaks.settings.key") + " " + keyName; } - + super.keyTyped(c, keyCode); } } diff --git a/src/InvTweaksGuiSettingsAbstract.java b/src/minecraft/invtweaks/InvTweaksGuiSettingsAbstract.java old mode 100755 new mode 100644 similarity index 67% rename from src/InvTweaksGuiSettingsAbstract.java rename to src/minecraft/invtweaks/InvTweaksGuiSettingsAbstract.java index 84de57e9..5841757a --- a/src/InvTweaksGuiSettingsAbstract.java +++ b/src/minecraft/invtweaks/InvTweaksGuiSettingsAbstract.java @@ -1,8 +1,14 @@ +package invtweaks; + import java.util.List; import java.util.logging.Logger; import net.minecraft.client.Minecraft; +import net.minecraft.src.GuiButton; +import net.minecraft.src.GuiScreen; +import net.minecraft.src.InvTweaksObfuscation; +import org.lwjgl.input.Keyboard; import org.lwjgl.util.Point; @@ -12,7 +18,7 @@ * @author Jimeo Wan * */ -public abstract class InvTweaksGuiSettingsAbstract extends aue /* GuiScreen */ { +public abstract class InvTweaksGuiSettingsAbstract extends GuiScreen { protected static final Logger log = Logger.getLogger("InvTweaks"); @@ -23,12 +29,12 @@ public abstract class InvTweaksGuiSettingsAbstract extends aue /* GuiScreen */ { protected Minecraft mc; protected InvTweaksObfuscation obf; protected InvTweaksConfig config; - protected aue parentScreen; + protected GuiScreen parentScreen; protected static String LABEL_DONE; protected final static int ID_DONE = 200; - public InvTweaksGuiSettingsAbstract(Minecraft mc, aue parentScreen, + public InvTweaksGuiSettingsAbstract(Minecraft mc, GuiScreen parentScreen, InvTweaksConfig config) { LABEL_DONE = InvTweaksLocalization.get("invtweaks.settings.exit"); @@ -42,36 +48,42 @@ public InvTweaksGuiSettingsAbstract(Minecraft mc, aue parentScreen, this.config = config; } - public void A_() { /* initGui */ + public void initGui() { List controlList = obf.getControlList(this); Point p = new Point(); moveToButtonCoords(1, p); - controlList.add(new ast(ID_DONE, p.getX() + 55, obf.getWindowHeight(this) / 6 + 168, LABEL_DONE)); // GuiButton + controlList.add(new GuiButton(ID_DONE, p.getX() + 55, obf.getWindowHeight(this) / 6 + 168, LABEL_DONE)); // GuiButton // Save control list obf.setControlList(this, controlList); } - public void a(int i, int j, float f) { /* drawScreen */ - z_(); // Gui.drawDefaultBackground - a(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.settings.title"), obf.getWindowWidth(this) / 2, 20, 0xffffff); // Gui.drawCenteredString - super.a(i, j, f); // drawScreen + public void drawScreen(int i, int j, float f) { + drawDefaultBackground(); + drawCenteredString(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.settings.title"), obf.getWindowWidth(this) / 2, 20, 0xffffff); + super.drawScreen(i, j, f); } - protected void a(ast guibutton) { /* actionPerformed */ + protected void actionPerformed(GuiButton guibutton) { if (obf.getId(guibutton) == ID_DONE) { obf.displayGuiScreen(parentScreen); } } + + protected void keyTyped(char c, int keyCode) { + if (keyCode == Keyboard.KEY_ESCAPE) { + obf.displayGuiScreen(parentScreen); + } + } protected void moveToButtonCoords(int buttonOrder, Point p) { p.setX(obf.getWindowWidth(this) / 2 - 155 + ((buttonOrder+1) % 2) * 160); p.setY(obf.getWindowHeight(this) / 6 + (buttonOrder / 2) * 24); } - protected void toggleBooleanButton(ast guibutton, String property, String label) { + protected void toggleBooleanButton(GuiButton guibutton, String property, String label) { Boolean enabled = !new Boolean(config.getProperty(property)); config.setProperty(property, enabled.toString()); obf.setDisplayString(guibutton, computeBooleanButtonLabel(property, label)); diff --git a/src/InvTweaksGuiSettingsAdvanced.java b/src/minecraft/invtweaks/InvTweaksGuiSettingsAdvanced.java old mode 100755 new mode 100644 similarity index 70% rename from src/InvTweaksGuiSettingsAdvanced.java rename to src/minecraft/invtweaks/InvTweaksGuiSettingsAdvanced.java index bd16e7c6..453f7c5a --- a/src/InvTweaksGuiSettingsAdvanced.java +++ b/src/minecraft/invtweaks/InvTweaksGuiSettingsAdvanced.java @@ -1,4 +1,4 @@ -import invtweaks.InvTweaksConst; +package invtweaks; import java.awt.Desktop; import java.io.File; @@ -6,6 +6,8 @@ import java.util.logging.Logger; import net.minecraft.client.Minecraft; +import net.minecraft.src.GuiButton; +import net.minecraft.src.GuiScreen; import org.lwjgl.util.Point; @@ -18,34 +20,30 @@ */ public class InvTweaksGuiSettingsAdvanced extends InvTweaksGuiSettingsAbstract { - @SuppressWarnings("unused") private static final Logger log = Logger.getLogger("InvTweaks"); private final static int ID_SORT_ON_PICKUP = 1; private final static int ID_AUTO_EQUIP_ARMOR = 2; private final static int ID_ENABLE_SOUNDS = 3; private final static int ID_CHESTS_BUTTONS = 4; - private final static int ID_SLOW_SORTING = 5; private final static int ID_EDITSHORTCUTS = 100; private static String labelChestButtons; private static String labelSortOnPickup; private static String labelEquipArmor; private static String labelEnableSounds; - private static String labelSlowSorting; - public InvTweaksGuiSettingsAdvanced(Minecraft mc, aue parentScreen, InvTweaksConfig config) { + public InvTweaksGuiSettingsAdvanced(Minecraft mc, GuiScreen parentScreen, InvTweaksConfig config) { super(mc, parentScreen, config); labelSortOnPickup = InvTweaksLocalization.get("invtweaks.settings.advanced.sortonpickup"); labelEquipArmor = InvTweaksLocalization.get("invtweaks.settings.advanced.autoequip"); labelEnableSounds = InvTweaksLocalization.get("invtweaks.settings.advanced.sounds"); labelChestButtons = InvTweaksLocalization.get("invtweaks.settings.chestbuttons"); - labelSlowSorting = InvTweaksLocalization.get("invtweaks.settings.slowsorting"); } - public void A_() { /* initGui */ - super.A_(); + public void initGui() { + super.initGui(); List controlList = obf.getControlList(this); Point p = new Point(); @@ -54,7 +52,7 @@ public void A_() { /* initGui */ // Create large buttons moveToButtonCoords(1, p); - controlList.add(new ast(ID_EDITSHORTCUTS, p.getX() + 55, obf.getWindowHeight(this) / 6 + 144, InvTweaksLocalization.get("invtweaks.settings.advanced.mappingsfile"))); + controlList.add(new GuiButton(ID_EDITSHORTCUTS, p.getX() + 55, obf.getWindowHeight(this) / 6 + 144, InvTweaksLocalization.get("invtweaks.settings.advanced.mappingsfile"))); // Create settings buttons @@ -79,17 +77,11 @@ public void A_() { /* initGui */ InvTweaksConfig.PROP_ENABLE_AUTO_EQUIP_ARMOR, labelEquipArmor), InvTweaksLocalization.get("invtweaks.settings.advanced.autoequip.tooltip")); controlList.add(autoEquipArmorBtn); - i += 3; - moveToButtonCoords(i++, p); - InvTweaksGuiTooltipButton slowSortingBtn = new InvTweaksGuiTooltipButton(ID_SLOW_SORTING, p.getX(), p.getY() + 10, - computeBooleanButtonLabel(InvTweaksConfig.PROP_SLOW_SORTING, labelSlowSorting), null); - controlList.add(slowSortingBtn); - // Check if links to files are supported, if not disable the buttons if (!Desktop.isDesktopSupported()) { for (Object o : controlList) { if (obf.isGuiButton(o)) { - ast button = obf.asGuiButton(o); + GuiButton button = obf.asGuiButton(o); if (obf.getId(button) == ID_EDITSHORTCUTS) { obf.setEnabled(button, false); } @@ -102,20 +94,15 @@ public void A_() { /* initGui */ } - public void a(int i, int j, float f) { /* drawScreen */ - super.a(i, j, f); - - Point p = new Point(); - moveToButtonCoords(1, p); - b(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.settings.pvpwarning.pt1"), p.getX(), 40, 0x999999); // Gui.drawCenteredString - b(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.settings.pvpwarning.pt2"), p.getX(), 50, 0x999999); + public void drawScreen(int i, int j, float f) { + super.drawScreen(i, j, f); - b(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.settings.slowsorting.pt1"), p.getX(), 115, 0x999999); - b(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.settings.slowsorting.pt2"), p.getX(), 125, 0x999999); - b(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.settings.slowsorting.pt3"), p.getX(), 135, 0x999999); + int x = obf.getWindowWidth(this) / 2; + drawCenteredString(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.settings.pvpwarning.pt1"), x, 40, 0x999999); + drawCenteredString(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.settings.pvpwarning.pt2"), x, 50, 0x999999); } - protected void a(ast guibutton) { /* actionPerformed */ + protected void actionPerformed(GuiButton guibutton) { switch (obf.getId(guibutton)) { @@ -138,11 +125,6 @@ protected void a(ast guibutton) { /* actionPerformed */ case ID_CHESTS_BUTTONS: toggleBooleanButton(guibutton, InvTweaksConfig.PROP_SHOW_CHEST_BUTTONS, labelChestButtons); break; - - // Toggle sounds - case ID_SLOW_SORTING: - toggleBooleanButton(guibutton, InvTweaksConfig.PROP_SLOW_SORTING, labelSlowSorting); - break; // Open shortcuts mappings in external editor case ID_EDITSHORTCUTS: diff --git a/src/InvTweaksGuiSettingsButton.java b/src/minecraft/invtweaks/InvTweaksGuiSettingsButton.java old mode 100755 new mode 100644 similarity index 79% rename from src/InvTweaksGuiSettingsButton.java rename to src/minecraft/invtweaks/InvTweaksGuiSettingsButton.java index 49a27bf0..310da4a8 --- a/src/InvTweaksGuiSettingsButton.java +++ b/src/minecraft/invtweaks/InvTweaksGuiSettingsButton.java @@ -1,8 +1,11 @@ +package invtweaks; + import java.util.concurrent.TimeoutException; import java.util.logging.Logger; import net.minecraft.client.Minecraft; +import net.minecraft.src.InvTweaksObfuscation; /** * Button that opens the inventory & chest settings screen. @@ -19,38 +22,33 @@ public InvTweaksGuiSettingsButton(InvTweaksConfigManager cfgManager, super(cfgManager, id, x, y, w, h, displayString, tooltip, useCustomTexture); } - public void a(Minecraft minecraft, int i, int j) { - super.a(minecraft, i, j); - - if (!isEnabled2()) { - return; - } + public void drawButton(Minecraft minecraft, int i, int j) { + super.drawButton(minecraft, i, j); // Display string InvTweaksObfuscation obf = new InvTweaksObfuscation(minecraft); - a(obf.getFontRenderer(), + drawCenteredString(obf.getFontRenderer(), getDisplayString(), getXPosition() + 5, getYPosition() - 1, - getTextColor(i, j)); // Gui.drawCenteredString + getTextColor(i, j)); } /** * Displays inventory settings GUI */ - public boolean c(Minecraft minecraft, int i, int j) { /* mousePressed */ + public boolean mousePressed(Minecraft minecraft, int i, int j) { InvTweaksObfuscation obf = new InvTweaksObfuscation(minecraft); InvTweaksConfig config = cfgManager.getConfig(); - if (super.c(minecraft, i, j)) { // mousePressed + if (super.mousePressed(minecraft, i, j)) { // Put hold item down if necessary InvTweaksContainerSectionManager containerMgr; try { containerMgr = new InvTweaksContainerSectionManager( minecraft, InvTweaksContainerSection.INVENTORY); - containerMgr.setClickDelay(config.getClickDelay()); if (obf.getHeldStack() != null) { try { // Put hold item down @@ -72,8 +70,7 @@ public boolean c(Minecraft minecraft, int i, int j) { /* mousePressed */ cfgManager.makeSureConfigurationIsLoaded(); // Display menu - obf.displayGuiScreen( - new InvTweaksGuiSettings(minecraft, obf.getCurrentScreen(), config)); + obf.displayGuiScreen(new InvTweaksGuiSettings(minecraft, obf.getCurrentScreen(), config)); return true; } else { return false; diff --git a/src/InvTweaksGuiShortcutsHelp.java b/src/minecraft/invtweaks/InvTweaksGuiShortcutsHelp.java old mode 100755 new mode 100644 similarity index 76% rename from src/InvTweaksGuiShortcutsHelp.java rename to src/minecraft/invtweaks/InvTweaksGuiShortcutsHelp.java index b3458360..ba2cc228 --- a/src/InvTweaksGuiShortcutsHelp.java +++ b/src/minecraft/invtweaks/InvTweaksGuiShortcutsHelp.java @@ -1,42 +1,47 @@ +package invtweaks; + import java.util.LinkedList; import java.util.List; import net.minecraft.client.Minecraft; +import net.minecraft.src.GuiButton; +import net.minecraft.src.GuiScreen; +import net.minecraft.src.InvTweaksObfuscation; import org.lwjgl.input.Keyboard; -public class InvTweaksGuiShortcutsHelp extends aue /* GuiScreen */ { +public class InvTweaksGuiShortcutsHelp extends GuiScreen { private final static int ID_DONE = 0; private InvTweaksObfuscation obf; - private aue parentScreen; + private GuiScreen parentScreen; private InvTweaksConfig config; public InvTweaksGuiShortcutsHelp(Minecraft mc, - aue parentScreen, InvTweaksConfig config) { + GuiScreen parentScreen, InvTweaksConfig config) { this.obf = new InvTweaksObfuscation(mc); this.parentScreen = parentScreen; this.config = config; } - public void A_() { /* initGui */ + public void initGui() { // Create Done button - List controlList = new LinkedList(); /* GuiButton */ - controlList.add(new ast(ID_DONE, + List controlList = new LinkedList(); + controlList.add(new GuiButton(ID_DONE, obf.getWindowWidth(this) / 2 - 100, obf.getWindowHeight(this) / 6 + 168, "Done")); obf.setControlList(this, controlList); } - public void a(int i, int j, float f) { /* drawScreen */ + public void drawScreen(int i, int j, float f) { // Note: 0x0000EEFF = blue color (currently unused) - z_(); // Gui.drawDefaultBackground - a(obf.getFontRenderer(), "WARNING: Since 1.3.1, shortcuts won't work as expected. Looking for a workaround...", obf.getWindowWidth(this) / 2, 5, 0xff0000); - a(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.help.shortcuts.title"), obf.getWindowWidth(this) / 2, 20, 0xffffff); // Gui.drawCenteredString + drawDefaultBackground(); + drawCenteredString(obf.getFontRenderer(), "WARNING: Since 1.3.1, shortcuts won't work as expected. Looking for a workaround...", obf.getWindowWidth(this) / 2, 5, 0xff0000); + drawCenteredString(obf.getFontRenderer(), InvTweaksLocalization.get("invtweaks.help.shortcuts.title"), obf.getWindowWidth(this) / 2, 20, 0xffffff); // Gui.drawCenteredString String clickLabel = InvTweaksLocalization.get("invtweaks.help.shortcuts.click"); int y = obf.getWindowHeight(this) / 6 - 2; @@ -79,20 +84,23 @@ public void a(int i, int j, float f) { /* drawScreen */ String sortKeyName = getKeyName(config.getSortKeyCode(), "(Sort Key)"); drawShortcutLine(InvTweaksLocalization.get("invtweaks.help.shortcuts.selectconfig"), "0-9 + " +sortKeyName, 0x0088FFFF, y); - super.a(i, j, f); // drawScreen + super.drawScreen(i, j, f); } - protected void a(ast guibutton) { /* actionPerformed */ - + protected void actionPerformed(GuiButton guibutton) { switch (obf.getId(guibutton)) { - case ID_DONE: obf.displayGuiScreen(parentScreen); break; - } } + protected void keyTyped(char c, int keyCode) { + if (keyCode == Keyboard.KEY_ESCAPE) { + obf.displayGuiScreen(parentScreen); + } + } + private String buildUpOrDownLabel(String shortcutProp, int keyCode, String defaultKeyName) { String shortcutLabel = config.getProperty(shortcutProp); String keyLabel = getKeyName(keyCode, defaultKeyName); @@ -114,9 +122,9 @@ protected String getKeyName(int keyCode, String defaultValue) { } private void drawShortcutLine(String label, String value, int color, int y) { - b(obf.getFontRenderer(), label, 30, y, -1); // drawString + drawString(obf.getFontRenderer(), label, 30, y, -1); // drawString if (value != null) { - b(obf.getFontRenderer(), value.contains("DEFAULT") ? "-" : value.replaceAll(", ", " " + InvTweaksLocalization.get("invtweaks.help.shortcuts.or") + " "), + drawString(obf.getFontRenderer(), value.contains("DEFAULT") ? "-" : value.replaceAll(", ", " " + InvTweaksLocalization.get("invtweaks.help.shortcuts.or") + " "), obf.getWindowWidth(this) / 2 - 30, y, color); // drawString } } diff --git a/src/InvTweaksGuiSortingButton.java b/src/minecraft/invtweaks/InvTweaksGuiSortingButton.java old mode 100755 new mode 100644 similarity index 89% rename from src/InvTweaksGuiSortingButton.java rename to src/minecraft/invtweaks/InvTweaksGuiSortingButton.java index 48dfba8b..a0435ba0 --- a/src/InvTweaksGuiSortingButton.java +++ b/src/minecraft/invtweaks/InvTweaksGuiSortingButton.java @@ -1,3 +1,5 @@ +package invtweaks; + import net.minecraft.client.Minecraft; /** @@ -21,12 +23,8 @@ public InvTweaksGuiSortingButton(InvTweaksConfigManager cfgManager, this.rowSize = rowSize; } - public void a(Minecraft minecraft, int i, int j) { /* drawButton */ - super.a(minecraft, i, j); - - if (!isEnabled2()) { - return; - } + public void drawButton(Minecraft minecraft, int i, int j) { + super.drawButton(minecraft, i, j); // Display symbol int textColor = getTextColor(i, j); @@ -47,8 +45,8 @@ public void a(Minecraft minecraft, int i, int j) { /* drawButton */ /** * Sort container */ - public boolean c(Minecraft minecraft, int i, int j) { - if (super.c(minecraft, i, j)) { // mousePressed + public boolean mousePressed(Minecraft minecraft, int i, int j) { + if (super.mousePressed(minecraft, i, j)) { try { new InvTweaksHandlerSorting( minecraft, cfgManager.getConfig(), diff --git a/src/InvTweaksGuiTooltipButton.java b/src/minecraft/invtweaks/InvTweaksGuiTooltipButton.java old mode 100755 new mode 100644 similarity index 82% rename from src/InvTweaksGuiTooltipButton.java rename to src/minecraft/invtweaks/InvTweaksGuiTooltipButton.java index 02fe76f0..d58693d8 --- a/src/InvTweaksGuiTooltipButton.java +++ b/src/minecraft/invtweaks/InvTweaksGuiTooltipButton.java @@ -1,5 +1,9 @@ +package invtweaks; + import invtweaks.InvTweaksConst; import net.minecraft.client.Minecraft; +import net.minecraft.src.FontRenderer; +import net.minecraft.src.InvTweaksObfuscation; /** * Icon-size button, which get drawns in a specific way to fit its small size. @@ -17,12 +21,13 @@ public class InvTweaksGuiTooltipButton extends InvTweaksObfuscationGuiButton { private String tooltip = null; private String[] tooltipLines = null; private int tooltipWidth = -1; - + private boolean drawBackground = true; + public InvTweaksGuiTooltipButton(int id, int x, int y, String displayString) { this(id, x, y, 150, 20, displayString, null); } - + /** * Default size is 150, the common "GuiSmallButton" button size. */ @@ -44,15 +49,25 @@ public InvTweaksGuiTooltipButton(int id, int x, int y, int w, int h, } } - public void a(Minecraft minecraft, int i, int j) { /* drawButton */ - super.a(minecraft, i, j); + public InvTweaksGuiTooltipButton(int id, int x, int y, int w, int h, + String displayString, String tooltip, boolean drawBackground) { + super(id, x, y, w, h, displayString); + if (tooltip != null) { + setTooltip(tooltip); + } + this.drawBackground = drawBackground; + } + + public void drawButton(Minecraft minecraft, int i, int j) { + if (this.drawBackground) { + super.drawButton(minecraft, i, j); + } + else { + this.drawString(minecraft.fontRenderer, this.displayString, this.xPosition, this.yPosition + (this.height - 8) / 2, 0x999999); + } InvTweaksObfuscation obf = new InvTweaksObfuscation(minecraft); - if (!isEnabled2()) { - return; - } - if (tooltipLines != null) { // Compute hover time if (isMouseOverButton(i, j)) { @@ -70,7 +85,7 @@ public void a(Minecraft minecraft, int i, int j) { /* drawButton */ // Draw tooltip if hover time is long enough if (hoverTime > InvTweaksConst.TOOLTIP_DELAY && tooltipLines != null) { - atj fontRenderer = obf.getFontRenderer(); + FontRenderer fontRenderer = obf.getFontRenderer(); // Compute tooltip params int x = i + 12, y = j - LINE_HEIGHT*tooltipLines.length; diff --git a/src/InvTweaksHandlerAutoRefill.java b/src/minecraft/invtweaks/InvTweaksHandlerAutoRefill.java similarity index 97% rename from src/InvTweaksHandlerAutoRefill.java rename to src/minecraft/invtweaks/InvTweaksHandlerAutoRefill.java index 4d671110..478694d9 100644 --- a/src/InvTweaksHandlerAutoRefill.java +++ b/src/minecraft/invtweaks/InvTweaksHandlerAutoRefill.java @@ -1,3 +1,5 @@ +package invtweaks; + import invtweaks.InvTweaksConst; import invtweaks.InvTweaksItemTree; import invtweaks.InvTweaksItemTreeItem; @@ -9,6 +11,8 @@ import net.minecraft.client.Minecraft; +import net.minecraft.src.InvTweaksObfuscation; +import net.minecraft.src.ItemStack; /** * Handles the auto-refilling of the hotbar. @@ -39,8 +43,7 @@ public void autoRefillSlot(int slot, int wantedId, int wantedDamage) throws Exce InvTweaksContainerSectionManager container = new InvTweaksContainerSectionManager( mc, InvTweaksContainerSection.INVENTORY); - container.setClickDelay(config.getClickDelay()); - um candidateStack, replacementStack = null; + ItemStack candidateStack, replacementStack = null; int replacementStackSlot = -1; boolean refillBeforeBreak = config.getProperty(InvTweaksConfig.PROP_AUTO_REFILL_BEFORE_BREAK) .equals(InvTweaksConfig.VALUE_TRUE); @@ -175,7 +178,7 @@ public void run() { // In POLLING_DELAY ms, things might have changed try { - um stack = containerMgr.getItemStack(i); + ItemStack stack = containerMgr.getItemStack(i); if (stack != null && getItemID(stack) == expectedItemId || this.refillBeforeBreak) { if (containerMgr.move(targetedSlot, i) || containerMgr.move(i, targetedSlot)) { if (!config.getProperty(InvTweaksConfig.PROP_ENABLE_SOUNDS).equals(InvTweaksConfig.VALUE_FALSE)) { diff --git a/src/InvTweaksHandlerShortcuts.java b/src/minecraft/invtweaks/InvTweaksHandlerShortcuts.java old mode 100755 new mode 100644 similarity index 96% rename from src/InvTweaksHandlerShortcuts.java rename to src/minecraft/invtweaks/InvTweaksHandlerShortcuts.java index a6feda4a..5bf9e802 --- a/src/InvTweaksHandlerShortcuts.java +++ b/src/minecraft/invtweaks/InvTweaksHandlerShortcuts.java @@ -1,3 +1,5 @@ +package invtweaks; + import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -7,6 +9,9 @@ import java.util.logging.Logger; import net.minecraft.client.Minecraft; +import net.minecraft.src.InvTweaksObfuscation; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Slot; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; @@ -19,7 +24,6 @@ */ public class InvTweaksHandlerShortcuts extends InvTweaksObfuscation { - @SuppressWarnings("unused") private static final Logger log = Logger.getLogger("InvTweaks"); private static final int DROP_SLOT = -999; @@ -28,7 +32,7 @@ private class ShortcutConfig { public InvTweaksShortcutType type = null; public InvTweaksContainerSection fromSection = null; public int fromIndex = -1; - public um fromStack = null; + public ItemStack fromStack = null; public InvTweaksContainerSection toSection = null; public int toIndex = -1; public boolean drop = false; @@ -144,8 +148,7 @@ public ShortcutConfig computeShortcutToTrigger() { // Init container = new InvTweaksContainerManager(mc); - container.setClickDelay(config.getClickDelay()); - sq slot = container.getSlotAtMousePosition(); + Slot slot = container.getSlotAtMousePosition(); ShortcutConfig shortcutConfig = new ShortcutConfig(); // If a valid and not empty slot is clicked @@ -206,7 +209,7 @@ else if (container.hasSection(InvTweaksContainerSection.FURNACE_IN)) { orderedSections.add(InvTweaksContainerSection.FURNACE_IN); } else if (container.hasSection(InvTweaksContainerSection.BREWING_INGREDIENT)) { - um stack = container.getStack(slot); + ItemStack stack = container.getStack(slot); if (stack != null) { if (getItemID(stack) == 373 /* Water Bottle/Potions */) { orderedSections.add(InvTweaksContainerSection.BREWING_BOTTLES); @@ -309,7 +312,7 @@ private boolean haveControlsChanged() { private void runShortcut(ShortcutConfig shortcut) throws TimeoutException { // Try to put held item down if (getHeldStack() != null) { - sq slot = container.getSlotAtMousePosition(); + Slot slot = container.getSlotAtMousePosition(); if (slot != null) { int slotNumber = getSlotNumber(slot); container.putHoldItemDown(container.getSlotSection(slotNumber), container.getSlotIndex(slotNumber)); @@ -337,7 +340,7 @@ private void runShortcut(ShortcutConfig shortcut) throws TimeoutException { case MOVE_ONE_STACK: { - sq slot = container.getSlot(shortcut.fromSection, shortcut.fromIndex); + Slot slot = container.getSlot(shortcut.fromSection, shortcut.fromIndex); if (shortcut.fromSection != InvTweaksContainerSection.CRAFTING_OUT && shortcut.toSection != InvTweaksContainerSection.ENCHANTMENT) { while (hasStack(slot) && toIndex != -1) { @@ -392,10 +395,10 @@ private void runShortcut(ShortcutConfig shortcut) throws TimeoutException { } } - private void moveAll(ShortcutConfig shortcut, um stackToMatch) throws TimeoutException { + private void moveAll(ShortcutConfig shortcut, ItemStack stackToMatch) throws TimeoutException { int toIndex = getNextTargetIndex(shortcut), newIndex; boolean success; - for (sq slot : container.getSlots(shortcut.fromSection)) { + for (Slot slot : container.getSlots(shortcut.fromSection)) { if (hasStack(slot) && (stackToMatch == null || areSameItemType(stackToMatch, getStack(slot)))) { int fromIndex = container.getSlotIndex(getSlotNumber(slot)); while (hasStack(slot) && toIndex != -1 && !(shortcut.fromSection == shortcut.toSection && fromIndex == toIndex)) { @@ -420,9 +423,9 @@ private int getNextTargetIndex(ShortcutConfig shortcut) { // Try to merge with existing slot if (!shortcut.forceEmptySlot) { int i = 0; - for (sq slot : container.getSlots(shortcut.toSection)) { + for (Slot slot : container.getSlots(shortcut.toSection)) { if (hasStack(slot)) { - um stack = getStack(slot); + ItemStack stack = getStack(slot); if (!hasDataTags(stack) && areItemsEqual(stack, shortcut.fromStack) && getStackSize(stack) < getMaxStackSize(stack)) { result = i; diff --git a/src/InvTweaksHandlerSorting.java b/src/minecraft/invtweaks/InvTweaksHandlerSorting.java similarity index 77% rename from src/InvTweaksHandlerSorting.java rename to src/minecraft/invtweaks/InvTweaksHandlerSorting.java index bc2d7e59..bcd9e869 100644 --- a/src/InvTweaksHandlerSorting.java +++ b/src/minecraft/invtweaks/InvTweaksHandlerSorting.java @@ -1,24 +1,34 @@ +package invtweaks; + import invtweaks.InvTweaksConst; import invtweaks.InvTweaksItemTree; import invtweaks.InvTweaksItemTreeItem; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Vector; import java.util.concurrent.TimeoutException; import java.util.logging.Logger; import net.minecraft.client.Minecraft; +import net.minecraft.src.InvTweaksObfuscation; +import net.minecraft.src.Item; +import net.minecraft.src.ItemArmor; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Slot; /** * Core of the sorting behaviour. Allows to move items in a container * (inventory or chest) with respect to the mod's configuration. - * + * * @author Jimeo Wan * */ @@ -32,7 +42,7 @@ public class InvTweaksHandlerSorting extends InvTweaksObfuscation { private static int[] DEFAULT_LOCK_PRIORITIES = null; private static boolean[] DEFAULT_FROZEN_SLOTS = null; private static final int MAX_CONTAINER_SIZE = 999; - + public static final int ALGORITHM_DEFAULT = 0; public static final int ALGORITHM_VERTICAL = 1; public static final int ALGORITHM_HORIZONTAL = 2; @@ -43,8 +53,7 @@ public class InvTweaksHandlerSorting extends InvTweaksObfuscation { private int algorithm; private int size; private boolean sortArmorParts; - private int clickDelay; - + private InvTweaksItemTree tree; private Vector rules; private int[] rulePriority; @@ -55,7 +64,7 @@ public class InvTweaksHandlerSorting extends InvTweaksObfuscation { public InvTweaksHandlerSorting(Minecraft mc, InvTweaksConfig config, InvTweaksContainerSection section, int algorithm, int rowSize) throws Exception { super(mc); - + // Init constants if (DEFAULT_LOCK_PRIORITIES == null) { @@ -73,13 +82,11 @@ public InvTweaksHandlerSorting(Minecraft mc, InvTweaksConfig config, // Init attributes - this.clickDelay = config.getClickDelay(); this.containerMgr = new InvTweaksContainerSectionManager(mc, section); - this.containerMgr.setClickDelay(this.clickDelay); this.size = containerMgr.getSize(); this.sortArmorParts = config.getProperty(InvTweaksConfig.PROP_ENABLE_AUTO_EQUIP_ARMOR).equals(InvTweaksConfig.VALUE_TRUE) && !isGuiInventoryCreative(getCurrentScreen()); // FIXME Armor parts disappear when sorting in creative mode while holding an item - + this.rules = config.getRules(); this.tree = config.getTree(); if (section == InvTweaksContainerSection.INVENTORY) { @@ -100,7 +107,7 @@ public InvTweaksHandlerSorting(Minecraft mc, InvTweaksConfig config, this.keywordOrder = new int[size]; for (int i = 0; i < size; i++) { this.rulePriority[i] = -1; - um stack = containerMgr.getItemStack(i); + ItemStack stack = containerMgr.getItemStack(i); if (stack != null) { this.keywordOrder[i] = getItemOrder(stack); } else { @@ -108,16 +115,15 @@ public InvTweaksHandlerSorting(Minecraft mc, InvTweaksConfig config, } } } - + public void sort() throws TimeoutException { - + // Do nothing if the inventory is closed // if (!mc.hrrentScreen instanceof GuiContainer) // return; - + long timer = System.nanoTime(); InvTweaksContainerManager globalContainer = new InvTweaksContainerManager(mc); - globalContainer.setClickDelay(this.clickDelay); // Put hold item down if (getHeldStack() != null) { @@ -129,23 +135,96 @@ public void sort() throws TimeoutException { return; // Not enough room to work, abort } } - + if (algorithm != ALGORITHM_DEFAULT) { - - if (algorithm == ALGORITHM_INVENTORY) { - + + if (algorithm == ALGORITHM_EVEN_STACKS) { + log.info("Distributing items."); + + //item and slot counts for each unique item + HashMap, int[]> itemCounts = new HashMap, int[]>(); + for(int i = 0; i < size; i++) { + ItemStack stack = containerMgr.getItemStack(i); + if(stack != null) { + List item = Arrays.asList(getItemID(stack), getItemDamage(stack)); + int[] count = itemCounts.get(item); + if(count == null) { + int[] newCount = {getStackSize(stack), 1}; + itemCounts.put(item,newCount); + } else { + count[0] += getStackSize(stack); //amount of item + count[1]++; //slots with item + } + } + } + + //handle each unique item separately + for(Entry, int[]> entry : itemCounts.entrySet()) { + List item = entry.getKey(); + int[] count = entry.getValue(); + int numPerSlot = count[0]/count[1]; //totalNumber/numberOfSlots + + //skip hacked itemstacks that are larger than their max size + //no idea why they would be here, but may as well account for them anyway + if(numPerSlot <= getMaxStackSize(new ItemStack(item.get(0),1,0))) { + + //linkedlists to store which stacks have too many/few items + LinkedList smallStacks = new LinkedList(); + LinkedList largeStacks = new LinkedList(); + for(int i = 0; i < size; i++) { + ItemStack stack = containerMgr.getItemStack(i); + if(stack != null && Arrays.asList(getItemID(stack),getItemDamage(stack)).equals(item)) { + int stackSize = getStackSize(stack); + if(stackSize > numPerSlot) + largeStacks.offer(i); + else if(stackSize < numPerSlot) + smallStacks.offer(i); + } + } + + //move items from stacks with too many to those with too little + while((!smallStacks.isEmpty())) { + int largeIndex = (Integer)largeStacks.peek(); + int largeSize = getStackSize(containerMgr.getItemStack(largeIndex)); + int smallIndex = (Integer)smallStacks.peek(); + int smallSize = getStackSize(containerMgr.getItemStack(smallIndex)); + containerMgr.moveSome(largeIndex, smallIndex, Math.min(numPerSlot-smallSize,largeSize-numPerSlot)); + + //update stack lists + largeSize = getStackSize(containerMgr.getItemStack(largeIndex)); + smallSize = getStackSize(containerMgr.getItemStack(smallIndex)); + if(largeSize == numPerSlot) + largeStacks.remove(); + if(smallSize == numPerSlot) + smallStacks.remove(); + } + + //put all leftover into one stack for easy removal + while(largeStacks.size() > 1) { + int largeIndex = (Integer)largeStacks.poll(); + int largeSize = getStackSize(containerMgr.getItemStack(largeIndex)); + containerMgr.moveSome(largeIndex,(Integer)largeStacks.peek(),largeSize-numPerSlot); + } + } + } + + //mark all items as moved. (is there a better way?) + for(int i=0;i craftingSlots = globalContainer.getSlots(InvTweaksContainerSection.CRAFTING_IN); + List craftingSlots = globalContainer.getSlots(InvTweaksContainerSection.CRAFTING_IN); int emptyIndex = globalContainer.getFirstEmptyIndex(InvTweaksContainerSection.INVENTORY); if (emptyIndex != -1) { - for (sq craftingSlot : craftingSlots) { + for (Slot craftingSlot : craftingSlots) { if (hasStack(craftingSlot)) { globalContainer.move( InvTweaksContainerSection.CRAFTING_IN, globalContainer.getSlotIndex(getSlotNumber(craftingSlot)), - InvTweaksContainerSection.INVENTORY, + InvTweaksContainerSection.INVENTORY, emptyIndex); emptyIndex = globalContainer.getFirstEmptyIndex(InvTweaksContainerSection.INVENTORY); if(emptyIndex == -1) { @@ -155,36 +234,41 @@ public void sort() throws TimeoutException { } } } - - + + //// Merge stacks to fill the ones in locked slots //// + Move armor parts to the armor slots - + log.info("Merging stacks."); for (int i = size - 1; i >= 0; i--) { - um from = containerMgr.getItemStack(i); + ItemStack from = containerMgr.getItemStack(i); if (from != null) { // Move armor parts - uk fromItem = getItem(from); + Item fromItem = getItem(from); if (isDamageable(fromItem)) { if (sortArmorParts) { if (isItemArmor(fromItem)) { - st fromItemArmor = asItemArmor(fromItem); + ItemArmor fromItemArmor = asItemArmor(fromItem); if (globalContainer.hasSection(InvTweaksContainerSection.ARMOR)) { - List armorSlots = globalContainer.getSlots(InvTweaksContainerSection.ARMOR); - for (sq slot : armorSlots) { + List armorSlots = globalContainer.getSlots(InvTweaksContainerSection.ARMOR); + for (Slot slot : armorSlots) { boolean move = false; if (!hasStack(slot)) { move = true; } else { - int armorLevel = getArmorLevel(asItemArmor(getItem(getStack(slot)))); - if (armorLevel < getArmorLevel(fromItemArmor) - || (armorLevel == getArmorLevel(fromItemArmor) - && getItemDamage(getStack(slot)) < getItemDamage(from))) { - move = true; - } + Item currentArmor = getItem(getStack(slot)); + if(isItemArmor(currentArmor)) { + int armorLevel = getArmorLevel(asItemArmor(currentArmor)); + if (armorLevel < getArmorLevel(fromItemArmor) + || (armorLevel == getArmorLevel(fromItemArmor) + && getItemDamage(getStack(slot)) < getItemDamage(from))) { + move = true; + } + } else { + move = true; + } } if (areSlotAndStackCompatible(slot, from) && move) { globalContainer.move(InvTweaksContainerSection.INVENTORY, i, InvTweaksContainerSection.ARMOR, @@ -195,13 +279,13 @@ && getItemDamage(getStack(slot)) < getItemDamage(from))) { } } } - + // Stackable objects are never damageable else { int j = 0; for (Integer lockPriority : lockPriorities) { if (lockPriority > 0) { - um to = containerMgr.getItemStack(j); + ItemStack to = containerMgr.getItemStack(j); if (to != null && areItemsEqual(from, to)) { move(i, j, Integer.MAX_VALUE); markAsNotMoved(j); @@ -215,38 +299,38 @@ && getItemDamage(getStack(slot)) < getItemDamage(from))) { } } } - + } - + //// Apply rules log.info("Applying rules."); - + // Sorts rule by rule, themselves being already sorted by decreasing priority Iterator rulesIt = rules.iterator(); while (rulesIt.hasNext()) { - + InvTweaksConfigSortingRule rule = rulesIt.next(); int rulePriority = rule.getPriority(); - + if (log.getLevel() == InvTweaksConst.DEBUG) log.info("Rule : "+rule.getKeyword()+"("+rulePriority+")"); - + // For every item in the inventory for (int i = 0; i < size; i++) { - um from = containerMgr.getItemStack(i); + ItemStack from = containerMgr.getItemStack(i); // If the rule is strong enough to move the item and it matches the item, move it if (hasToBeMoved(i) && lockPriorities[i] < rulePriority) { List fromItems = tree.getItems( getItemID(from), getItemDamage(from)); if (tree.matches(fromItems, rule.getKeyword())) { - + // Test preffered slots int[] preferredSlots = rule.getPreferredSlots(); int stackToMove = i; for (int j = 0; j < preferredSlots.length; j++) { int k = preferredSlots[j]; - + // Move the stack! int moveResult = move(stackToMove, k, rulePriority); if (moveResult != -1) { @@ -270,10 +354,10 @@ && getItemDamage(getStack(slot)) < getItemDamage(from))) { } } } - + //// Don't move locked stacks log.info("Locking stacks."); - + for (int i = 0; i < size; i++) { if (hasToBeMoved(i) && lockPriorities[i] > 0) { markAsMoved(i, 1); @@ -281,7 +365,7 @@ && getItemDamage(getStack(slot)) < getItemDamage(from))) { } } - + //// Sort remaining defaultSorting(); @@ -300,9 +384,9 @@ && getItemDamage(getStack(slot)) < getItemDamage(from))) { } private void defaultSorting() throws TimeoutException { - + log.info("Default sorting."); - + Vector remaining = new Vector(), nextRemaining = new Vector(); for (int i = 0; i < size; i++) { if (hasToBeMoved(i)) { @@ -310,7 +394,7 @@ private void defaultSorting() throws TimeoutException { nextRemaining.add(i); } } - + int iterations = 0; while (remaining.size() > 0 && iterations++ < 50) { for (int i : remaining) { @@ -332,13 +416,13 @@ private void defaultSorting() throws TimeoutException { if (iterations == 100) { log.warning("Sorting takes too long, aborting."); } - + } /** * Tries to move a stack from i to j, and swaps them if j is already * occupied but i is of greater priority (even if they are of same ID). - * + * * @param i from slot * @param j to slot * @param priority The rule priority. Use 1 if the stack was not moved using a rule. @@ -349,8 +433,8 @@ private void defaultSorting() throws TimeoutException { */ private int move(int i, int j, int priority) throws TimeoutException { - um from = containerMgr.getItemStack(i), to = containerMgr.getItemStack(j); - + ItemStack from = containerMgr.getItemStack(i), to = containerMgr.getItemStack(j); + if (from == null || frozenSlots[j] || frozenSlots[i]) { return -1; } @@ -363,20 +447,20 @@ private int move(int i, int j, int priority) throws TimeoutException { markAsMoved(i, priority); return j; } - + // Move to empty slot if (to == null && lockPriorities[j] <= priority && !frozenSlots[j]) { rulePriority[i] = -1; keywordOrder[i] = -1; rulePriority[j] = priority; keywordOrder[j] = getItemOrder(from); - containerMgr.move(i, j); + containerMgr.move(i, j); return j; } // Try to swap/merge else if (to != null) { - + boolean canBeSwappedOrMerged = false; // Can be swapped? @@ -400,15 +484,15 @@ else if (getStackSize(from) > getMaxStackSize(from)) { canBeSwappedOrMerged = false; } } - + if (canBeSwappedOrMerged) { - + keywordOrder[j] = keywordOrder[i]; rulePriority[j] = priority; rulePriority[i] = -1; containerMgr.move(i, j); - um remains = containerMgr.getItemStack(i); + ItemStack remains = containerMgr.getItemStack(i); if (remains != null) { int dropSlot = i; @@ -454,8 +538,8 @@ private boolean hasToBeMoved(int slot) { private boolean isOrderedBefore(int i, int j) { - um iStack = containerMgr.getItemStack(i), jStack = containerMgr.getItemStack(j); - + ItemStack iStack = containerMgr.getItemStack(i), jStack = containerMgr.getItemStack(j); + if (jStack == null) { return true; } else if (iStack == null || keywordOrder[i] == -1) { @@ -485,19 +569,19 @@ private boolean isOrderedBefore(int i, int j) { } } - private int getItemOrder(um itemStack) { + private int getItemOrder(ItemStack itemStack) { List items = tree.getItems( getItemID(itemStack), getItemDamage(itemStack)); return (items != null && items.size() > 0) ? items.get(0).getOrder() : Integer.MAX_VALUE; } - + private void computeLineSortingRules(int rowSize, boolean horizontal) { - + rules = new Vector(); - - + + Map stats = computeContainerStats(); List itemOrder = new ArrayList(); @@ -508,13 +592,13 @@ private void computeLineSortingRules(int rowSize, boolean horizontal) { int availableSlots = size; int remainingStacks = 0; for (Integer stacks : stats.values()) { - remainingStacks += stacks; + remainingStacks += stacks; } - + // No need to compute rules for an empty chest if (distinctItems == 0) return; - + // (Partially) sort stats by decreasing item stack count List unorderedItems = new ArrayList(stats.keySet()); boolean hasStacksToOrderFirst = true; @@ -533,7 +617,7 @@ private void computeLineSortingRules(int rowSize, boolean horizontal) { } Collections.sort(unorderedItems, Collections.reverseOrder()); itemOrder.addAll(unorderedItems); - + // Define space size used for each item type. if (horizontal) { spaceHeight = 1; @@ -543,16 +627,16 @@ private void computeLineSortingRules(int rowSize, boolean horizontal) { spaceWidth = 1; spaceHeight = columnSize/((distinctItems+rowSize-1)/rowSize); } - + char row = 'a', maxRow = (char) (row - 1 + columnSize); char column = '1', maxColumn = (char) (column - 1 + rowSize); - + // Create rules Iterator it = itemOrder.iterator(); while (it.hasNext()) { - + InvTweaksItemTreeItem item = it.next(); - + // Adapt rule dimensions to fit the amount int thisSpaceWidth = spaceWidth, thisSpaceHeight = spaceHeight; @@ -580,7 +664,7 @@ else if (column + thisSpaceWidth < maxColumn) { } } } - + // Adjust line/column ends to fill empty space if (horizontal && (column + thisSpaceWidth == maxColumn)) { thisSpaceWidth++; @@ -588,7 +672,7 @@ else if (column + thisSpaceWidth < maxColumn) { else if (!horizontal && row + thisSpaceHeight == maxRow) { thisSpaceHeight++; } - + // Create rule String constraint = row + "" + column + "-" + (char)(row - 1 + thisSpaceHeight) @@ -597,7 +681,7 @@ else if (!horizontal && row + thisSpaceHeight == maxRow) { constraint += 'v'; } rules.add(new InvTweaksConfigSortingRule(tree, constraint, item.getName(), size, rowSize)); - + // Check if ther's still room for more rules availableSlots -= thisSpaceHeight*thisSpaceWidth; remainingStacks -= stats.get(item); @@ -628,7 +712,7 @@ else if (!horizontal && row + thisSpaceHeight == maxRow) { break; } } - + String defaultRule; if (horizontal) { defaultRule = maxRow + "1-a" + maxColumn; @@ -636,25 +720,25 @@ else if (!horizontal && row + thisSpaceHeight == maxRow) { else { defaultRule = "a" + maxColumn + "-" + maxRow + "1v"; } - rules.add(new InvTweaksConfigSortingRule(tree, defaultRule, + rules.add(new InvTweaksConfigSortingRule(tree, defaultRule, tree.getRootCategory().getName(), size, rowSize)); - + } - + private Map computeContainerStats() { Map stats = new HashMap(); Map itemSearch = new HashMap(); - + for (int i = 0; i < size; i++) { - um stack = containerMgr.getItemStack(i); + ItemStack stack = containerMgr.getItemStack(i); if (stack != null) { - int itemSearchKey = getItemID(stack)*100000 + + int itemSearchKey = getItemID(stack)*100000 + ((getMaxStackSize(stack) != 1) ? getItemDamage(stack) : 0); InvTweaksItemTreeItem item = itemSearch.get(itemSearchKey); if (item == null) { item = tree.getItems(getItemID(stack), getItemDamage(stack)).get(0); - itemSearch.put(itemSearchKey, item); + itemSearch.put(itemSearchKey, item); stats.put(item, 1); } else { @@ -662,11 +746,12 @@ private Map computeContainerStats() { } } } - + return stats; } - + private int getContainerColumnSize(int rowSize) { return size / rowSize; } + } diff --git a/src/invtweaks/InvTweaksItemTree.java b/src/minecraft/invtweaks/InvTweaksItemTree.java similarity index 99% rename from src/invtweaks/InvTweaksItemTree.java rename to src/minecraft/invtweaks/InvTweaksItemTree.java index 12b2cd39..e82cf92d 100644 --- a/src/invtweaks/InvTweaksItemTree.java +++ b/src/minecraft/invtweaks/InvTweaksItemTree.java @@ -247,7 +247,6 @@ public void addItem(String parentCategory, /** * For debug purposes. Call log(getRootCategory(), 0) to log the whole tree. */ - @SuppressWarnings("unused") private void log(InvTweaksItemTreeCategory category, int indentLevel) { String logIdent = ""; diff --git a/src/invtweaks/InvTweaksItemTreeCategory.java b/src/minecraft/invtweaks/InvTweaksItemTreeCategory.java similarity index 99% rename from src/invtweaks/InvTweaksItemTreeCategory.java rename to src/minecraft/invtweaks/InvTweaksItemTreeCategory.java index 7d7e1408..5a691b53 100644 --- a/src/invtweaks/InvTweaksItemTreeCategory.java +++ b/src/minecraft/invtweaks/InvTweaksItemTreeCategory.java @@ -18,7 +18,6 @@ */ public class InvTweaksItemTreeCategory { - @SuppressWarnings("unused") private static final Logger log = Logger.getLogger("InvTweaks"); private final Map> items = diff --git a/src/invtweaks/InvTweaksItemTreeItem.java b/src/minecraft/invtweaks/InvTweaksItemTreeItem.java similarity index 100% rename from src/invtweaks/InvTweaksItemTreeItem.java rename to src/minecraft/invtweaks/InvTweaksItemTreeItem.java diff --git a/src/invtweaks/InvTweaksItemTreeListener.java b/src/minecraft/invtweaks/InvTweaksItemTreeListener.java old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/InvTweaksItemTreeListener.java rename to src/minecraft/invtweaks/InvTweaksItemTreeListener.java diff --git a/src/invtweaks/InvTweaksItemTreeLoader.java b/src/minecraft/invtweaks/InvTweaksItemTreeLoader.java similarity index 100% rename from src/invtweaks/InvTweaksItemTreeLoader.java rename to src/minecraft/invtweaks/InvTweaksItemTreeLoader.java diff --git a/src/InvTweaksLocalization.java b/src/minecraft/invtweaks/InvTweaksLocalization.java similarity index 92% rename from src/InvTweaksLocalization.java rename to src/minecraft/invtweaks/InvTweaksLocalization.java index 20489583..16fe0a83 100644 --- a/src/InvTweaksLocalization.java +++ b/src/minecraft/invtweaks/InvTweaksLocalization.java @@ -1,7 +1,11 @@ +package invtweaks; + import java.io.InputStream; import java.util.Properties; import java.util.logging.Logger; +import net.minecraft.src.InvTweaksObfuscation; + /** * The global mod's configuration. @@ -11,9 +15,8 @@ */ public class InvTweaksLocalization { - @SuppressWarnings("unused") private static final Logger log = Logger.getLogger("InvTweaks"); - private static final String LANG_RESOURCES_LOCATION = "invtweaks/lang/"; + private static final String LANG_RESOURCES_LOCATION = "/invtweaks/lang/"; private static final String DEFAULT_LANGUAGE = "en_US"; private static Properties defaultMappings = new Properties(); private static Properties mappings = new Properties(); diff --git a/src/InvTweaksModCompatibility.java b/src/minecraft/invtweaks/InvTweaksModCompatibility.java old mode 100755 new mode 100644 similarity index 72% rename from src/InvTweaksModCompatibility.java rename to src/minecraft/invtweaks/InvTweaksModCompatibility.java index 750782c7..ac1ef6fd --- a/src/InvTweaksModCompatibility.java +++ b/src/minecraft/invtweaks/InvTweaksModCompatibility.java @@ -1,15 +1,23 @@ +package invtweaks; + import invtweaks.InvTweaksConst; import java.util.HashMap; import java.util.List; import java.util.Map; +import net.minecraft.src.Container; +import net.minecraft.src.GuiContainer; +import net.minecraft.src.GuiScreen; +import net.minecraft.src.InvTweaksObfuscation; +import net.minecraft.src.Slot; + public class InvTweaksModCompatibility { private InvTweaksObfuscation obf; - InvTweaksModCompatibility(InvTweaksObfuscation obf) { + public InvTweaksModCompatibility(InvTweaksObfuscation obf) { this.obf = obf; } @@ -19,7 +27,7 @@ public class InvTweaksModCompatibility { * @param guiContainer * @return */ - public boolean isSpecialChest(aue guiScreen) { + public boolean isSpecialChest(GuiScreen guiScreen) { return is(guiScreen, "GuiAlchChest") // Equivalent Exchange || is(guiScreen, "GuiCondenser") // Equivalent Exchange || is(guiScreen, "GUIChest") // Iron chests (formerly IC2) @@ -39,6 +47,7 @@ public boolean isSpecialChest(aue guiScreen) { || is(guiScreen, "GuiFilter") // Red Power 2 || is(guiScreen, "GuiAdvBench") // Red Power 2 || is(guiScreen, "GuiEject") // Red Power 2 + || is(guiScreen, "GuiBag") // Red Power 2 || is(guiScreen, "GuiPersonalChest") || is(guiScreen, "GuiNuclearReactor") // IC2 || is(guiScreen, "GuiEnderChest") // EnderChest @@ -47,6 +56,7 @@ public boolean isSpecialChest(aue guiScreen) { || is(guiScreen, "FC_GuiChest") // Metallurgy || is(guiScreen, "FM_GuiMintStorage") // Metallurgy || is(guiScreen, "GuiChestTFC") // TerraFirmaCraft + || is(guiScreen, "GuiBackpack") // Backpacks ; } @@ -57,7 +67,7 @@ public boolean isSpecialChest(aue guiScreen) { * @param defaultValue * @return */ - public int getSpecialChestRowSize(auy guiContainer, int defaultValue) { + public int getSpecialChestRowSize(GuiContainer guiContainer, int defaultValue) { if (is(guiContainer, "GuiAlchChest") || is(guiContainer, "GuiCondenser")) { // Equivalent Exchange return 13; @@ -90,7 +100,7 @@ public int getSpecialChestRowSize(auy guiContainer, int defaultValue) { return defaultValue; } - public boolean isChestWayTooBig(aue guiScreen) { + public boolean isChestWayTooBig(GuiScreen guiScreen) { return is(guiScreen, "GuiAlchChest") // Equivalent Exchange || is(guiScreen, "GuiMultiPageChest") // MultiPage Chest || is(guiScreen, "GUIChest") // IronChests @@ -103,7 +113,7 @@ public boolean isChestWayTooBig(aue guiScreen) { * @param guiScreen * @return */ - public boolean isSpecialInventory(aue guiScreen) { + public boolean isSpecialInventory(GuiScreen guiScreen) { try { return obf.getSlots(obf.getContainer(obf.asGuiContainer(guiScreen))).size() > InvTweaksConst.INVENTORY_SIZE && !obf.isGuiInventoryCreative(guiScreen); @@ -113,25 +123,28 @@ public boolean isSpecialInventory(aue guiScreen) { } @SuppressWarnings("unchecked") - public Map> getSpecialContainerSlots(aue guiScreen, rp container) { + public Map> getSpecialContainerSlots(GuiScreen guiScreen, Container container) { - Map> result = new HashMap>(); - List slots = (List) obf.getSlots(container); + Map> result = new HashMap>(); + List slots = (List) obf.getSlots(container); if (is(guiScreen, "GuiCondenser")) { // EE result.put(InvTweaksContainerSection.CHEST, slots.subList(1, slots.size() - 36)); } else if (is(guiScreen, "GuiAdvBench")) { // RedPower 2 - result.put(InvTweaksContainerSection.CRAFTING_IN, slots.subList(0, 9)); - result.put(InvTweaksContainerSection.CRAFTING_OUT, slots.subList(9, 10)); - result.put(InvTweaksContainerSection.CHEST, slots.subList(10, 28)); + result.put(InvTweaksContainerSection.CRAFTING_IN, slots.subList(0, 9)); + result.put(InvTweaksContainerSection.CRAFTING_OUT, slots.subList(10, 11)); + result.put(InvTweaksContainerSection.CHEST, slots.subList(11, 29)); + } else if(is(guiScreen, "GuiArcaneWorkbench") || is(guiScreen, "GuiInfusionWorkbench")) { // Thaumcraft 3 + result.put(InvTweaksContainerSection.CRAFTING_OUT, slots.subList(0, 1)); + result.put(InvTweaksContainerSection.CRAFTING_IN, slots.subList(2, 11)); } return result; } - private static final boolean is(aue guiScreen, String className) { + private static final boolean is(GuiScreen guiScreen, String className) { try { return guiScreen.getClass().getSimpleName().contains(className); } diff --git a/src/minecraft/invtweaks/InvTweaksObfuscationGuiButton.java b/src/minecraft/invtweaks/InvTweaksObfuscationGuiButton.java new file mode 100644 index 00000000..8a20a38e --- /dev/null +++ b/src/minecraft/invtweaks/InvTweaksObfuscationGuiButton.java @@ -0,0 +1,44 @@ +package invtweaks; + +import net.minecraft.client.Minecraft; +import net.minecraft.src.GuiButton; + +/** + * Obfuscation layer for gui buttons. + * @author Jimeo Wan + * + */ +public class InvTweaksObfuscationGuiButton extends GuiButton { + + public InvTweaksObfuscationGuiButton(int id, int x, int y, int w, int h, String string) { + super(id, x, y, w, h, string); + } + + protected String getDisplayString() { + return displayString; + } + + protected int getTexture(Minecraft mc, String texture) { + return mc.renderEngine.getTexture(texture); + } + + protected boolean isEnabled() { + return enabled; + } + + protected int getXPosition() { + return xPosition; + } + + protected int getYPosition() { + return yPosition; + } + + protected int getWidth() { + return width; + } + + protected int getHeight() { + return height; + } +} \ No newline at end of file diff --git a/src/InvTweaksShortcutMapping.java b/src/minecraft/invtweaks/InvTweaksShortcutMapping.java old mode 100755 new mode 100644 similarity index 98% rename from src/InvTweaksShortcutMapping.java rename to src/minecraft/invtweaks/InvTweaksShortcutMapping.java index 6fc4896f..bfafab88 --- a/src/InvTweaksShortcutMapping.java +++ b/src/minecraft/invtweaks/InvTweaksShortcutMapping.java @@ -1,3 +1,5 @@ +package invtweaks; + import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -13,7 +15,6 @@ */ public class InvTweaksShortcutMapping { - @SuppressWarnings("unused") private static final Logger log = Logger.getLogger("InvTweaks"); private List keysToHold = new LinkedList(); diff --git a/src/InvTweaksShortcutType.java b/src/minecraft/invtweaks/InvTweaksShortcutType.java old mode 100755 new mode 100644 similarity index 94% rename from src/InvTweaksShortcutType.java rename to src/minecraft/invtweaks/InvTweaksShortcutType.java index 75adbe80..e1ec6f07 --- a/src/InvTweaksShortcutType.java +++ b/src/minecraft/invtweaks/InvTweaksShortcutType.java @@ -1,3 +1,5 @@ +package invtweaks; + /** * * @author Jimeo Wan diff --git a/src/invtweaks/lang/_README.txt b/src/minecraft/invtweaks/lang/_README.txt old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/_README.txt rename to src/minecraft/invtweaks/lang/_README.txt diff --git a/src/invtweaks/lang/da_DK.properties b/src/minecraft/invtweaks/lang/da_DK.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/da_DK.properties rename to src/minecraft/invtweaks/lang/da_DK.properties diff --git a/src/invtweaks/lang/de_DE.properties b/src/minecraft/invtweaks/lang/de_DE.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/de_DE.properties rename to src/minecraft/invtweaks/lang/de_DE.properties diff --git a/src/invtweaks/lang/en_US.properties b/src/minecraft/invtweaks/lang/en_US.properties old mode 100755 new mode 100644 similarity index 90% rename from src/invtweaks/lang/en_US.properties rename to src/minecraft/invtweaks/lang/en_US.properties index fd8a34c0..b91e2bbe --- a/src/invtweaks/lang/en_US.properties +++ b/src/minecraft/invtweaks/lang/en_US.properties @@ -41,11 +41,11 @@ invtweaks.settings.treefile=Open the item tree file... invtweaks.settings.treefile.error=[9] Failed to open tree file invtweaks.settings.onlinehelp=Open help in browser... invtweaks.settings.onlinehelp.error=[10] Failed to open help -invtweaks.settings.slowsorting=Server hack mode -invtweaks.settings.slowsorting.pt1=If your server seems to 'cancel' what this mod does, -invtweaks.settings.slowsorting.pt2=ask your admin to disable the "inventory.fastclick" and -invtweaks.settings.slowsorting.pt3="combined.improbable" NoCheatPlus options. Otherwise, try this: -invtweaks.settings.slowsorting.tooltip=Sorts items slowly to cheat the no-cheat plugins +invtweaks.help.bugsorting=Not working? +invtweaks.help.bugsorting.pt1=If your server seems to 'cancel' what this mod does, +invtweaks.help.bugsorting.pt2=it's probably caused by it using the NoCheatPlus plugin. +invtweaks.help.bugsorting.pt3=Ask your admin to disable the following options: +invtweaks.help.bugsorting.pt4="inventory.fastclick" and "combined.improbable" invtweaks.settings.pvpwarning.pt1=Note: On PvP servers, the auto-refill & auto-equip armor invtweaks.settings.pvpwarning.pt2=options are often considered cheating! invtweaks.settings.exit=Done diff --git a/src/invtweaks/lang/es_ES.properties b/src/minecraft/invtweaks/lang/es_ES.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/es_ES.properties rename to src/minecraft/invtweaks/lang/es_ES.properties diff --git a/src/invtweaks/lang/fr_FR.properties b/src/minecraft/invtweaks/lang/fr_FR.properties old mode 100755 new mode 100644 similarity index 91% rename from src/invtweaks/lang/fr_FR.properties rename to src/minecraft/invtweaks/lang/fr_FR.properties index 8657b055..1e9a2a5d --- a/src/invtweaks/lang/fr_FR.properties +++ b/src/minecraft/invtweaks/lang/fr_FR.properties @@ -41,11 +41,11 @@ invtweaks.settings.treefile=Ouvrir le fichier d'arborescence des objets... invtweaks.settings.treefile.error=[9] Impossible d'ouvrir l'arborescence des objets invtweaks.settings.onlinehelp=Ouvrir l'aide en ligne... invtweaks.settings.onlinehelp.error=[10] Impossible d'ouvrir l'aide en ligne -invtweaks.settings.slowsorting=Mode anti-protection serveur -invtweaks.settings.slowsorting.pt1=Si votre serveur semble annuler les actions du mod, -invtweaks.settings.slowsorting.pt2=demandez à votre admin de désactiver "inventory.fastclick" et -invtweaks.settings.slowsorting.pt3="combined.improbable" (des options NoCheatPlus). Sinon, essayez : -invtweaks.settings.slowsorting.tooltip=Trie en cliquant lentement pour contourner l'anti-triche +invtweaks.help.bugsorting=Bugué ? +invtweaks.help.bugsorting.pt1=Si votre serveur semble annuler les actions du mod, +invtweaks.help.bugsorting.pt2=c'est sûrement dû au plugin anti-triche NoCheatPlus. +invtweaks.help.bugsorting.pt3=Demandez à votre admin de désactiver les options : +invtweaks.help.bugsorting.pt4="inventory.fastclick" et "combined.improbable" invtweaks.settings.pvpwarning.pt1=Note\: Sur les serveurs PvP, le remplacement et l'\u00e9quipement invtweaks.settings.pvpwarning.pt2=d'armure automatiques sont souvent vus comme de la triche \! invtweaks.settings.exit=Fermer diff --git a/src/invtweaks/lang/ja_JP.properties b/src/minecraft/invtweaks/lang/ja_JP.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/ja_JP.properties rename to src/minecraft/invtweaks/lang/ja_JP.properties diff --git a/src/invtweaks/lang/ko_KR.properties b/src/minecraft/invtweaks/lang/ko_KR.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/ko_KR.properties rename to src/minecraft/invtweaks/lang/ko_KR.properties diff --git a/src/invtweaks/lang/nb_NO.properties b/src/minecraft/invtweaks/lang/nb_NO.properties similarity index 100% rename from src/invtweaks/lang/nb_NO.properties rename to src/minecraft/invtweaks/lang/nb_NO.properties diff --git a/src/invtweaks/lang/nl_NL.properties b/src/minecraft/invtweaks/lang/nl_NL.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/nl_NL.properties rename to src/minecraft/invtweaks/lang/nl_NL.properties diff --git a/src/invtweaks/lang/pl_PL.properties b/src/minecraft/invtweaks/lang/pl_PL.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/pl_PL.properties rename to src/minecraft/invtweaks/lang/pl_PL.properties diff --git a/src/invtweaks/lang/pt_BR.properties b/src/minecraft/invtweaks/lang/pt_BR.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/pt_BR.properties rename to src/minecraft/invtweaks/lang/pt_BR.properties diff --git a/src/invtweaks/lang/pt_PT.properties b/src/minecraft/invtweaks/lang/pt_PT.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/pt_PT.properties rename to src/minecraft/invtweaks/lang/pt_PT.properties diff --git a/src/invtweaks/lang/ru_RU.properties b/src/minecraft/invtweaks/lang/ru_RU.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/ru_RU.properties rename to src/minecraft/invtweaks/lang/ru_RU.properties diff --git a/src/invtweaks/lang/sv_SE.properties b/src/minecraft/invtweaks/lang/sv_SE.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/sv_SE.properties rename to src/minecraft/invtweaks/lang/sv_SE.properties diff --git a/src/invtweaks/lang/tr_TR.properties b/src/minecraft/invtweaks/lang/tr_TR.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/tr_TR.properties rename to src/minecraft/invtweaks/lang/tr_TR.properties diff --git a/src/invtweaks/lang/uk_UA.properties b/src/minecraft/invtweaks/lang/uk_UA.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/uk_UA.properties rename to src/minecraft/invtweaks/lang/uk_UA.properties diff --git a/src/invtweaks/lang/zh_CN.properties b/src/minecraft/invtweaks/lang/zh_CN.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/zh_CN.properties rename to src/minecraft/invtweaks/lang/zh_CN.properties diff --git a/src/invtweaks/lang/zh_TW.properties b/src/minecraft/invtweaks/lang/zh_TW.properties old mode 100755 new mode 100644 similarity index 100% rename from src/invtweaks/lang/zh_TW.properties rename to src/minecraft/invtweaks/lang/zh_TW.properties diff --git a/src/minecraft/net/minecraft/src/InvTweaksObfuscation.java b/src/minecraft/net/minecraft/src/InvTweaksObfuscation.java new file mode 100644 index 00000000..43c8e827 --- /dev/null +++ b/src/minecraft/net/minecraft/src/InvTweaksObfuscation.java @@ -0,0 +1,471 @@ +package net.minecraft.src; + +import invtweaks.InvTweaksModCompatibility; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +import net.minecraft.client.Minecraft; + +/** + * Minecraft 1.3 Obfuscation layer + * + * @author Jimeo Wan + * + */ +public class InvTweaksObfuscation { + + private static final Logger log = Logger.getLogger("InvTweaks"); + + public Minecraft mc; + + public InvTweaksModCompatibility mods; + + private static Map fieldsMap = new HashMap(); + + public InvTweaksObfuscation(Minecraft mc) { + this.mc = mc; + this.mods = new InvTweaksModCompatibility(this); + } + + // Minecraft members + + public void addChatMessage(String message) { + if (mc.ingameGUI != null) { + mc.ingameGUI.getChatGUI().printChatMessage(message); + } + } + public EntityPlayer getThePlayer() { + return mc.thePlayer; + } + public World getTheWorld() { + return mc.theWorld; + } + public PlayerControllerMP getPlayerController() { + return mc.playerController; + } + public GuiScreen getCurrentScreen() { + return mc.currentScreen; + } + public FontRenderer getFontRenderer() { + return mc.fontRenderer; + } + public void displayGuiScreen(GuiScreen parentScreen) { + mc.displayGuiScreen(parentScreen); + } + public int getDisplayWidth() { + return mc.displayWidth; + } + public int getDisplayHeight() { + return mc.displayHeight; + } + public GameSettings getGameSettings() { + return mc.gameSettings; + } + public KeyBinding[] getRegisteredBindings() { + return getGameSettings().keyBindings; + } + public void setRegisteredBindings(KeyBinding[] bindings) { + getGameSettings().keyBindings = bindings; + } + public int getKeyBindingForwardKeyCode() { + return getKeyCode(getGameSettings().keyBindForward); + } + public int getKeyBindingBackKeyCode() { + return getKeyCode(getGameSettings().keyBindBack); + } + + // EntityPlayer members + + public InventoryPlayer getInventoryPlayer() { // InventoryPlayer + return getThePlayer().inventory; + } + public ItemStack getCurrentEquippedItem() { // ItemStack + return getThePlayer().getCurrentEquippedItem(); + } + public ContainerPlayer getPlayerContainer() { + return (ContainerPlayer) getThePlayer().inventoryContainer; + } + + // InventoryPlayer members + + public ItemStack[] getMainInventory() { + return getInventoryPlayer().mainInventory; + } + public void setMainInventory(ItemStack[] value) { + getInventoryPlayer().mainInventory = value; + } + public void setHasInventoryChanged(boolean value) { + getInventoryPlayer().inventoryChanged = value; + } + public void setHeldStack(ItemStack stack) { + getInventoryPlayer().setItemStack(stack); // setItemStack + } + public boolean hasInventoryChanged() { + return getInventoryPlayer().inventoryChanged; + } + public ItemStack getHeldStack() { + return getInventoryPlayer().getItemStack(); // getItemStack + } + public ItemStack getFocusedStack() { + return getInventoryPlayer().getCurrentItem(); // getCurrentItem + } + public int getFocusedSlot() { + return getInventoryPlayer().currentItem; // currentItem + } + + // GuiScreen members + + public int getWindowWidth(GuiScreen guiScreen) { + return guiScreen.width; + } + public int getWindowHeight(GuiScreen guiScreen) { + return guiScreen.height; + } + public int getGuiX(GuiContainer guiContainer) { + return guiContainer.guiLeft; + } + public int getGuiY(GuiContainer guiContainer) { + return guiContainer.guiTop; + } + public int getGuiWidth(GuiContainer guiContainer) { + return guiContainer.xSize; + } + public int getGuiHeight(GuiContainer guiContainer) { + return guiContainer.ySize; + } + @SuppressWarnings("unchecked") + public List getControlList(GuiScreen guiScreen) { + return guiScreen.controlList; + } + public void setControlList(GuiScreen guiScreen, List controlList) { + guiScreen.controlList = controlList; + } + public GuiContainer asGuiContainer(GuiScreen guiScreen) { + return (GuiContainer) guiScreen; + } + + // FontRenderer members + + public int getStringWidth(FontRenderer fontRenderer, String line) { + return fontRenderer.getStringWidth(line); + } + public void drawStringWithShadow(FontRenderer fontRenderer, + String s, int i, int j, int k) { + fontRenderer.drawStringWithShadow(s, i, j, k); + } + + // ItemStack members + + public ItemStack createItemStack(int id, int size, int damage) { + return new ItemStack(id, size, damage); + } + public ItemStack copy(ItemStack itemStack) { + return itemStack.copy(); + } + public int getItemDamage(ItemStack itemStack) { + return itemStack.getItemDamage(); + } + public int getMaxStackSize(ItemStack itemStack) { + return itemStack.getMaxStackSize(); + } + public boolean hasDataTags(ItemStack itemStack) { + return itemStack.hasTagCompound(); + } + public int getStackSize(ItemStack itemStack) { + return itemStack.stackSize; + } + public int getItemID(ItemStack itemStack) { + return itemStack.itemID; + } + public boolean areItemStacksEqual(ItemStack itemStack1, ItemStack itemStack2) { + return itemStack1.isItemEqual(itemStack2) && getStackSize(itemStack1) == getStackSize(itemStack2); + } + public boolean isItemStackDamageable(ItemStack itemStack) { + return itemStack.isItemStackDamageable(); + } + public boolean areSameItemType(ItemStack itemStack1, ItemStack itemStack2) { + return areItemsEqual(itemStack1, itemStack2) || + (isItemStackDamageable(itemStack1) + && getItemID(itemStack1) == getItemID(itemStack2)); + } + public boolean areItemsEqual(ItemStack itemStack1, ItemStack itemStack2) { + return itemStack1.isItemEqual(itemStack2); + } + public int getAnimationsToGo(ItemStack itemStack) { + return itemStack.animationsToGo; + } + public Item getItem(ItemStack itemStack) { // Item + return itemStack.getItem(); + } + + // Item & ItemArmor + + public boolean isDamageable(Item item) { + return item.isDamageable(); + } + public int getMaxDamage(Item item) { + return item.getMaxDamage(); + } + public int getArmorLevel(ItemArmor itemArmor) { // ItemArmor + return itemArmor.damageReduceAmount; + } + public ItemArmor asItemArmor(Item item) { // ItemArmor + return (ItemArmor) item; + } + + // PlayerController members + + public ItemStack clickInventory(PlayerControllerMP playerController, + int windowId, int slot, int clickButton, + boolean shiftHold, EntityPlayer entityPlayer) { + return playerController.windowClick(windowId, slot, clickButton, + (shiftHold) ? 1 : 0 /* XXX Placeholder */, entityPlayer); + } + + // Container members + + public int getWindowId(Container container) { + return container.windowId; + } + public List getSlots(Container container) { + return container.inventorySlots; + } + public Slot getSlot(Container container, int i) { // Slot + return (Slot) (getSlots(container).get(i)); + } + + public ItemStack getSlotStack(Container container, int i) { + Slot slot = getSlot(container, i); + return (slot == null) ? null : getStack(slot); // getStack + } + + public void setSlotStack(Container container, int i, ItemStack stack) { + container.putStackInSlot(i, stack); // putStackInSlot + } + + // Slot members + + public boolean hasStack(Slot slot) { + return slot.getHasStack(); + } + public int getSlotNumber(Slot slot) { + try { + // Creative slots don't set the "slotNumber" property, serve as a proxy for true slots + if (slot instanceof SlotCreativeInventory) { + Slot underlyingSlot = SlotCreativeInventory.func_75240_a((SlotCreativeInventory) slot); + if (underlyingSlot != null) { + return underlyingSlot.slotNumber; + } + } + } catch (Exception e) { + log.warning("Failed to access creative slot nItemStackber"); + } + return slot.slotNumber; + } + public ItemStack getStack(Slot slot) { + return slot.getStack(); + } + public int getXDisplayPosition(Slot slot) { + return slot.xDisplayPosition; + } + public int getYDisplayPosition(Slot slot) { + return slot.yDisplayPosition; + } + public boolean areSlotAndStackCompatible(Slot slot, ItemStack itemStack) { + return slot.isItemValid(itemStack); // isItemValid + } + + // GuiContainer members + + public Container getContainer(GuiContainer guiContainer) { + return guiContainer.inventorySlots; + } + + // GuiButton + + public GuiButton asGuiButton(Object o) { + return (GuiButton) o; + } + public void setEnabled(GuiButton guiButton, boolean enabled) { // GuiButton + guiButton.enabled = enabled; + } + public int getId(GuiButton guiButton) { // GuiButton + return guiButton.id; + } + public void setDisplayString(GuiButton guiButton, String string) { + guiButton.displayString = string; + } + public String getDisplayString(GuiButton guiButton) { + return guiButton.displayString; + } + + // Other + + public void playSound(String string, float f, float g) { + mc.sndManager.playSoundFX(string, f, g); + } + public long getCurrentTime() { + return getTheWorld().getTotalWorldTime(); + } + public int getKeyCode(KeyBinding b) { + return b.keyCode; + } + public int getSpecialChestRowSize(GuiContainer guiContainer, int defaultValue) { + return mods.getSpecialChestRowSize(guiContainer, defaultValue); + } + /*public boolean hasTexture(String texture) { + TexturePackList texturePacksManager = (TexturePackList) getThroughReflection(RenderEngine.class, "texturePack", mc.renderEngine); + InputStream resourceAsStream = null; + try { + resourceAsStream = texturePacksManager.getSelectedTexturePack().getResourceAsStream(texture); + return texturePacksManager != null && resourceAsStream != null; + } + finally { + if (resourceAsStream != null) { + try { + resourceAsStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + }*/ + + // Static access + + public static StringTranslate getLocalizationService() { // StringTranslate + return StringTranslate.getInstance(); // StringTranslate.getInstance() + } + public static String getCurrentLanguage() { + return getLocalizationService().getCurrentLanguage(); + } + public static String getLocalizedString(String key) { + return getLocalizationService().translateKey(key); + } + public static ItemStack getHoldStackStatic(Minecraft mc) { + return new InvTweaksObfuscation(mc).getHeldStack(); + } + public static GuiScreen getCurrentScreenStatic(Minecraft mc) { + return new InvTweaksObfuscation(mc).getCurrentScreen(); + } + + // Classes + + public boolean isValidChest(GuiScreen guiScreen) { + return guiScreen != null && (isGuiChest(guiScreen) + || isGuiDispenser(guiScreen) + || mods.isSpecialChest(guiScreen)) + && (guiScreen instanceof GuiContainer); + } + public boolean isValidInventory(GuiScreen guiScreen) { + return isStandardInventory(guiScreen) + || mods.isSpecialInventory(guiScreen); + } + public boolean isStandardInventory(GuiScreen guiScreen) { + return isGuiInventory(guiScreen) + || isGuiWorkbench(guiScreen) + || isGuiFurnace(guiScreen) + || isGuiBrewingStand(guiScreen) + || isGuiEnchantmentTable(guiScreen) + || isGuiTrading(guiScreen) + || isGuiAnvil(guiScreen) + || isGuiBeacon(guiScreen) + || (isGuiInventoryCreative(guiScreen) + && getSlots(getContainer(asGuiContainer(guiScreen))).size() == 46); + } + + public boolean isGuiContainer(Object o) { // GuiContainer (abstract class) + return o != null && o instanceof GuiContainer; + } + + public boolean isGuiBeacon(Object o) { // GuiBeacon + return o != null && o.getClass().equals(GuiBeacon.class); + } + public boolean isGuiBrewingStand(Object o) { // GuiBrewingStand + return o != null && o.getClass().equals(GuiBrewingStand.class); + } + public boolean isGuiChest(Object o) { // GuiChest + return o != null && o.getClass().equals(GuiChest.class); + } + public boolean isGuiWorkbench(Object o) { // GuiWorkbench + return o != null && o.getClass().equals(GuiCrafting.class); + } + public boolean isGuiInventoryCreative(Object o) { // GuiInventoryCreative + return o != null && o.getClass().equals(GuiContainerCreative.class); + } + public boolean isGuiEnchantmentTable(Object o) { // GuiEnchantmentTable + return o != null && o.getClass().equals(GuiEnchantment.class); + } + public boolean isGuiFurnace(Object o) { // GuiFurnace + return o != null && o.getClass().equals(GuiFurnace.class); + } + public boolean isGuiInventory(Object o) { // GuiInventory + return o != null && o.getClass().equals(GuiInventory.class); + } + public boolean isGuiTrading(Object o) { // GuiTrading + return o != null && o.getClass().equals(GuiMerchant.class); + } + public boolean isGuiAnvil(Object o) { // GuiAnvil + return o != null && o.getClass().equals(GuiRepair.class); + } + public boolean isGuiDispenser(Object o) { // GuiDispenser + return o != null && o.getClass().equals(GuiDispenser.class); + } + + public boolean isGuiButton(Object o) { // GuiButton + return o != null && o instanceof GuiButton; + } + + public boolean isGuiEditSign(Object o) { + return o != null && o.getClass().equals(GuiEditSign.class); + } + public boolean isContainerBeacon(Object o) { + return o != null && o.getClass().equals(ContainerBeacon.class); + } + public boolean isContainerBrewingStand(Object o) { + return o != null && o.getClass().equals(ContainerBrewingStand.class); + } + public boolean isContainerChest(Object o) { + return o != null && o.getClass().equals(ContainerChest.class); + } + public boolean isContainerWorkbench(Object o) { + return o != null && o.getClass().equals(ContainerWorkbench.class); + } + public boolean isContainerEnchantmentTable(Object o) { + return o != null && o.getClass().equals(ContainerEnchantment.class); + } + public boolean isContainerFurnace(Object o) { + return o != null && o.getClass().equals(ContainerFurnace.class); + } + public boolean isContainerPlayer(Object o) { + return o != null && o.getClass().equals(ContainerPlayer.class); + } + public boolean isContainerTrading(Object o) { + return o != null && o.getClass().equals(ContainerMerchant.class); + } + public boolean isContainerAnvil(Object o) { + return o != null && o.getClass().equals(ContainerRepair.class); + } + public boolean isContainerDispenser(Object o) { + return o != null && o.getClass().equals(ContainerDispenser.class); + } + public boolean isContainerCreative(Object o) { // ContainerCreative + return o != null && o.getClass().equals(ContainerCreative.class); + } + + public boolean isItemArmor(Object o) { // ItemArmor + return o != null && o instanceof ItemArmor; + } + + public boolean isBasicSlot(Object o) { // Slot + return o != null && o.getClass().equals(Slot.class); + } + +} \ No newline at end of file diff --git a/src/mod_InvTweaks.java b/src/minecraft/net/minecraft/src/mod_InvTweaks.java similarity index 91% rename from src/mod_InvTweaks.java rename to src/minecraft/net/minecraft/src/mod_InvTweaks.java index ae4ad325..7d8d0c10 100644 --- a/src/mod_InvTweaks.java +++ b/src/minecraft/net/minecraft/src/mod_InvTweaks.java @@ -1,3 +1,5 @@ +package net.minecraft.src; +import invtweaks.InvTweaks; import invtweaks.InvTweaksConst; import java.util.logging.Logger; @@ -17,7 +19,6 @@ */ public class mod_InvTweaks extends BaseMod { - @SuppressWarnings("unused") private static final Logger log = Logger.getLogger("InvTweaks"); private InvTweaks instance; @@ -62,9 +63,10 @@ public boolean onTickInGame(float clock, Minecraft minecraft) { /** * Called by ModLoader when an item has been picked up. */ + @Override - public void onItemPickup(qx entityplayer, um itemstack) { + public void onItemPickup(EntityPlayer entityplayer, ItemStack itemstack) { instance.setItemPickupPending(true); } - + }