Compare commits

..
Author SHA1 Message Date
Wilhelm Schuster 166748c066 Make sure NEI plugins are loaded before processing keybindings (#375)
NEI plugins are initialized in a separate thread. If this takes too long,
the client tick handler might already be running checking the keybindings
in KeyManager while a plugin calls API.addKeyBind() which can lead to a
CME.

Reported in https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/13292
Thanks to @Denostrov for helping me track this down.
2023-05-07 16:39:08 +02:00
chill 28112a85e7 Readme: fix wording (#374) 2023-05-07 16:39:08 +02:00
miozune afba3f26f7 probably better way 2023-05-07 19:45:59 +09:00
miozune c47baaf019 updateBuildScript & spotlessApply 2023-05-07 19:27:12 +09:00
miozune 2207952e3b Separate logic to get detailed string of fluid amount 2023-05-07 19:26:10 +09:00
MalTeeez 962754ee10 Create handlers for Fusion Crafting (DE-), Techguns and some missing NC recipes (#372)
* Add Fusion Crafting catalyst.csv

* Add Fusion Crafter handler.csv

* Add Techguns handlers & some missing NuclearCraft handlers

* Add Techguns catalysts & some missing NuclearCraft catalysts

* Fix typo

* Add heights to handlers and fix typo

* Small height increase

* Group NC catalysts

* Group NC handlers
2023-04-28 08:24:58 +02:00
Jason Mitchell 0e34840c21 More robust IMC handling (#371)
* Complain if IMC adds a handler/catalyst for a handlerID that doesn't exist.

* Look at the right maps this time

* Don't show matches, only misses
2023-04-16 21:22:09 +02:00
CaedisandMartin Robertz a12fadb10d Add option to have the search widget under item panel (#364)
* Add option to have the search widget under item panel

* update bs+sa

* Make heights consistent

---------

Co-authored-by: Martin Robertz <[email protected]>
2023-04-01 23:16:18 +02:00
Raven Szewczyk 9218e233aa Ignore nonstackables in max overlaid recipe count calculation (#365)
* Update buildscript

* Ignore nonstackables in max overlaid recipe count calculation
2023-03-30 21:47:33 +02:00
theOnly1iKnow 23e16abae6 Add handlers of Reikas mods plus fixes (#362)
* Added Handlers for some of Reikas mods aswell as:
 - a fix for the Industrialcraft Fluid/Solid Canning Machine
 - Tiling for all MFR machines with multiple recipes 
 - Added Cyanite Reporcessor from Big Reactors

* Bring metalformer in line with other IC2 machines
2023-03-20 08:30:15 -07:00
theOnly1iKnow b3cb4db9ca Added handlers for Factorization plus a missing MFR handler (#359)
* Added Handlers for Factorization
as well as a missing MFR Handler

* Added three more MFR handlers
2023-03-06 13:10:28 +01:00
Raven Szewczyk 45fea43a4b Fix MissingFileException in <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/12791> (#360) 2023-03-05 14:11:45 +01:00
miozune 088d9c08a8 Prevent NPE with null value for keybind (#358) 2023-03-03 11:15:13 +01:00
miozune 98547c2bcf Prevent NPE with null overlayHandler (#357) 2023-03-03 11:14:56 +01:00
Raven Szewczyk 02fa633043 Fix mob spawn spots sometimes showing as gray (#355) 2023-03-01 13:39:08 +01:00
r1tsuu 9df6ab0232 MacOS Command key accessibility (#354)
* MacOS Command key accessibility

* MacOS Command key accessibility

* Fixed spotless violation build error

* Fixed RMENU key to RMETA as CTRL on MacOS
2023-02-28 15:53:59 +01:00
Raven Szewczyk 89cc203875 Light/chunk overlay fixes (#353)
* Update buildscript

* Fix mob/chunk overlay rendering at very far x/z coordinates

Closes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/12680>

* Use Tesselator for mob spawn overlay drawing for a minor performance boost

* Missed a couple of offsets in the other chunk overlay modes
2023-02-27 13:31:44 +01:00
asdflj 4b247d08a5 add more api (#352) 2023-02-15 11:55:16 +01:00
Midnight145 8ecc8f20d5 add legacy handlers for botania,neiplugins (#349)
* add missing handlers for Blightfall

* update gitignore

* remove trailing commas

* add fluid registry handler

* readd missing quotes
2023-02-13 16:41:32 +00:00
miozune 74b9f8339a Require shift by default for moving items with overlaying recipe (#351) 2023-02-13 07:26:28 +01:00
miozune e20756a196 Don't require holding shift to move items when overlaying recipe (#348)
* updateBuildScript

* Remove redundant public modifier

* Don't require holding shift to move items when overlaying recipe
2023-02-09 11:21:30 +01:00
miozune 6d0f83c499 Make recipe query load all the uncrashed handlers instead of all-or-nothing if one of the handlers crashed (#347)
* Make recipe query load all the uncrashed handlers instead of all-or-nothing if one of the handlers crashed

* better error handling
2023-02-08 08:54:43 +01:00
miozune 8e219c06be Add JEI styled cycle ingredients (#346) 2023-02-05 16:57:09 +01:00
miozune 3fc576b6fc Add more error message for crash with recipe lookup (#345) 2023-02-05 11:27:52 +01:00
miozune 249cb2b308 Allow using hash for tooltip pagination keybind (#344) 2023-02-04 10:35:36 +01:00
miozune e8d8c1994b Add tooltip pagination (#343) 2023-02-03 15:35:03 +01:00
Raven Szewczyk 195b47944f There is no more 1.7.10- in the gha urls (#342) 2023-01-31 19:21:17 +01:00
Raven Szewczyk 3224fdef7d [ci skip] upgraded build system 2023-01-31 09:54:53 +00:00
Raven Szewczyk 46a159d788 Update buildscript, dependencies and modid injection shenanigans 2023-01-30 11:53:56 +00:00
İlker ARICI bd20e00a6e Add Actually Additions Catalysts.csv (#340)
* Actually Additions Catalysts.csv

* Update catalysts.csv

* Update catalysts.csv
2023-01-29 15:56:08 +01:00
İlker ARICI bf06b09d5a Add Actually Additions handlers (#339)
* Update handlers.csv

I have no experience in coding and not sure if this works, but here is my try at adding Actually Additions handlers to NEI

* Update handlers.csv

* Update handlers.csv

* Update handlers.csv

* Update handlers.csv
2023-01-29 15:55:59 +01:00
Jason Mitchell 1b1dd3567a [ci skip] Add git-blame-ignore-revs for spotlessApply 2023-01-28 17:55:51 -08:00
Jason Mitchell f106b5e766 [ci skip] spotlessApply with the new settings 2023-01-28 17:55:51 -08:00
Jason Mitchell f1dea5460a [ci skip] Update buildscript to RetroFuturaGradle 2023-01-28 17:55:49 -08:00
miozune 9b73b94d16 Fix meta id for MAX Bio Lab (#338) 2023-01-28 17:24:57 +01:00
Raven Szewczyk e133afc774 Fix jar resource loading on newer Java versions (still works on 8) (#337) 2023-01-25 20:50:48 +01:00
asdflj 75ff631f16 bookmark item stack size readable conversion (#335) 2023-01-23 10:59:29 +01:00
Raven Szewczyk 6f5d45c4ea Update CodeChicken dependencies (#330) 2023-01-05 12:18:21 +00:00
miozune fb51475bb9 Fix stack size of permutations on PositionedStack (#327) 2022-12-26 19:14:45 +01:00
Jason Mitchell 99ec3a4204 Add cf & modrinth deps (#325)
* Add cf & modrinth deps

* rm jitpack

* Spotless, you are annoying sometimes
2022-12-22 20:58:39 +01:00
miozune 8c4d609e4c Expose some members in GuiContainerManager (#324) 2022-12-21 10:37:43 +01:00
miozune 336c7dc621 Fix inventory desync when closing GuiRecipe (#320) 2022-11-29 18:21:45 +01:00
Yang Xizhi 2130a47f6f fix overlap of ? button (#321) 2022-11-29 11:19:42 +01:00
miozune 73b492b0e3 Add Dangote Distillus to catalyst for distillery (#319) 2022-11-18 07:33:16 +01:00
miozune efa69f31b6 Fix incorrect RecipeCatalysts for naquadah generators (#318) 2022-11-08 07:38:28 +01:00
makamys 95b437e5c9 Only mark item list as dirty if it's actually modified (#316)
Fixes #315
2022-10-23 11:53:29 +02:00
miozune afe3c54c29 Add config to not optimize computation for GUI overlap (#314) 2022-10-17 20:59:14 +02:00
Jason MitchellandGitHub GTNH Actions 2cab09e91b Try/Catch AIOBE - maybe fixes #295 (#312)
* Try/Catch AIOBE - maybe fixes #295

* spotlessApply

Co-authored-by: GitHub GTNH Actions <unknown>
2022-10-17 11:34:06 +02:00
Jason Mitchell 4b4ab434c0 Update buildscript and add CF/Modrinth project IDs 2022-10-15 08:20:59 -07:00
Yang Xizhi 9d108b21f9 fix missing yShift (#309) 2022-10-15 15:40:52 +02:00
slprimeandslprime 2302dac5c0 Bookmarks: save result that has output bigger than 64 (#308)
Co-authored-by: slprime <[email protected]>
2022-10-13 20:49:43 +02:00
slprimeandslprime 7c2fb2df5f fix bookmarks (#307)
Co-authored-by: slprime <[email protected]>
2022-10-13 10:06:08 +02:00
miozune 14aa3728ca Add AE2 Stuff Inscriber to RecipeCatalyst (#306) 2022-10-13 08:50:04 +02:00
Kiwi 66fc2270dd Update zh_CN.lang (#301) 2022-09-24 12:25:39 +02:00
miozune 138d25dbfd Fix incorrect color applied to GuiRecipeCatalyst (#300) 2022-09-19 05:58:46 +02:00
Raven Szewczyk d9191750a7 Update CodeChickenLib (#299) 2022-09-18 23:15:42 +02:00
くぁーりぃ 6d9ec0c0da Backport some of REI bookmark features (#296)
* add placeholder bookmark drop

* add item panel to bookmark panel injection support

* fix outofboundsexception

* fix drag'n drop voids bookmark

* add itemstack moving animation

* implement pop animation

* fix crashes

* disable ItemPanel Animation

* disable pop animation on bookmark load

* spotlessapply

* disable move animation on gui scale

* add config option
2022-09-18 12:08:16 +02:00
くぁーりぃ 617ac0600d Add search history (#294)
* add search history

* spotlessApply

* linkedlist->arraylist
2022-09-10 18:35:48 +02:00
7d7e3b61a6 Fix other mods cannot mixin GuiContainer.java when NEI is loaded (#291)
Co-authored-by: くぁーりぃ <[email protected]>
Co-authored-by: GitHub GTNH Actions <>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-09-05 18:47:51 +08:00
miozune 748695158f Allow using handlerId for handler order (#290) 2022-09-03 10:25:40 +02:00
DrParadox7 a2c037e0c0 Update Handlers (#288)
Updated Handlers and Catalyst for the following:
-Minefactory Reloaded
-GregTech 4
-Nuclearcraft
2022-08-31 17:30:14 +02:00
miozune e93d23e444 Show message while loading itempanel (#286)
* Show message while loading itempanel

* Move to ItemsGrid

* Add bookmark message

* ItemList

* Revert "Add bookmark message"

This reverts commit 030b5ed1ef.

* Item List

* Use Label

* clean
2022-08-31 10:43:22 +02:00
miozune 748cfe3754 Fix crash when itempanel is not initialized yet (#285) 2022-08-28 14:23:11 +02:00
firenoo b64d104d7e README.md: Add some documentation for getting started on development (#283) 2022-08-27 17:19:09 +02:00
miozune 46d90b6923 Show handler order when hovering on tab and shift pressed (#281) 2022-08-26 22:14:08 +02:00
slprime e61120099a Fix DnD Real Item as Ghost (#279) 2022-08-23 21:15:37 +02:00
Yang Xizhi bcb6eb214f fix dead loop when click certain gui with real item (#278)
fix https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11067
2022-08-23 06:41:34 +01:00
slprimeandVladislav Laetansky 9221434b2e Create ShortcutInputHandler api class (#277)
* Add RecipeItemInputHandler#lastKeyTyped(ItemStack)

* move shortcut to api

* Update src/main/java/codechicken/nei/api/ShortcutInputHandler.java

Co-authored-by: Vladislav Laetansky <[email protected]>

Co-authored-by: Vladislav Laetansky <[email protected]>
2022-08-21 16:33:52 +02:00
slprime 02937061d4 Presets: Open List Fatal & Slot Overlay (#276)
* Presets: Open List Fatal

* fix slot overlay
2022-08-21 11:34:56 +02:00
miozuneGitHub GTNH Actionsgithub-actions[bot]
0e6425295b Catch exception on drawSlotItem (#273)
* Catch exception on drawSlotItem

* updateBuildScript

* updateBuildScript

* spotlessApply

* spotlessApply (#274)

Co-authored-by: miozune <[email protected]>
Co-authored-by: GitHub GTNH Actions <>

* spotlessApply (#275)

Co-authored-by: miozune <[email protected]>
Co-authored-by: GitHub GTNH Actions <>

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-08-20 11:41:22 +02:00
191 changed files with 5189 additions and 3063 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# Ignore spotlessApply reformat
f106b5e7665df6341ae8539f74dc391a7efc98b1
+44
View File
@@ -0,0 +1,44 @@
* text eol=lf
*.[jJ][aA][rR] binary
*.[pP][nN][gG] binary
*.[jJ][pP][gG] binary
*.[jJ][pP][eE][gG] binary
*.[gG][iI][fF] binary
*.[tT][iI][fF] binary
*.[tT][iI][fF][fF] binary
*.[iI][cC][oO] binary
*.[sS][vV][gG] text
*.[eE][pP][sS] binary
*.[xX][cC][fF] binary
*.[kK][aA][rR] binary
*.[mM]4[aA] binary
*.[mM][iI][dD] binary
*.[mM][iI][dD][iI] binary
*.[mM][pP]3 binary
*.[oO][gG][gG] binary
*.[rR][aA] binary
*.7[zZ] binary
*.[gG][zZ] binary
*.[tT][aA][rR] binary
*.[tT][gG][zZ] binary
*.[zZ][iI][pP] binary
*.[tT][cC][nN] binary
*.[sS][oO] binary
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary
*.[pP][aA][tT][cC][hH] -text
*.[bB][aA][tT] text eol=crlf
*.[cC][mM][dD] text eol=crlf
*.[pP][sS]1 text eol=crlf
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
+1
View File
@@ -27,3 +27,4 @@ whitelist.json
*.iws
src/main/resources/mixins.*.json
*.bat
.DS_Store
+8 -1
View File
@@ -12,7 +12,7 @@ If you have issues with NEI outside of the GTNH modpack you may report them in t
- Uses a parallel stream to search the item list over multiple cores, resulting in 2-6x faster searches on average
- Loads the recipe handlers in parallel
* A textbox for search with most of the features you'd expect - moving forward, backwards, selection, etc
* Bookmarks! What are you in the process of crafting? Bookmark it using either 'A' or configure your own key.
* Bookmarks! Are you in the process of crafting? Bookmark it using either 'A' or configure your own key.
* Toggle bookmark pane. Default shortcut key `B`. Item Subsets menu is only available if bookmarks are not visible.
* Utility/Cheat buttons line up and wrap based on GUI size
* ItemList is no longer regenerated from the ItemRegistry on every inventory load
@@ -27,6 +27,13 @@ If you have issues with NEI outside of the GTNH modpack you may report them in t
* Remove TMI style
* Removed inventory Load/Save state
## Development
Before launching, you need to add
```
-Dfml.coreMods.load=codechicken.nei.asm.NEICorePlugin
```
as a command line argument to the VM.
## License
GTNH Modifications Copyright (c) 2019-2022 mitchej123 and the GTNH Team
+1 -1
View File
@@ -1,3 +1,3 @@
compileJava {
options.encoding = "UTF-8"
options.encoding = "UTF-8"
}
+1079 -516
View File
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -1,7 +1,7 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev')
compile('com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev')
shadowImplementation('org.apache.commons:commons-csv:1.8')
api('com.github.GTNewHorizons:CodeChickenLib:1.1.6:dev')
api('com.github.GTNewHorizons:CodeChickenCore:1.1.10:dev')
shadowImplementation('org.apache.commons:commons-csv:1.9.0')
}
+43 -5
View File
@@ -26,11 +26,19 @@ developmentEnvironmentUserName = Developer
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = NEIModContainer.java
gradleTokenModId = GRADLETOKEN_MODID
gradleTokenModName = GRADLETOKEN_MODNAME
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName =
# Generate a class with String fields for the mod id, name, version and group name named with the fields below
generateGradleTokenClass = codechicken.nei.Tags
gradleTokenModId = MODID
gradleTokenModName = MODNAME
gradleTokenVersion = VERSION
gradleTokenGroupName = GROUPNAME
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
@@ -58,3 +66,33 @@ containsMixinsAndOrCoreModOnly = true
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = true
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId = 358228
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project id of the other mod.
curseForgeRelations = requiredDependency:codechickencore-unofficial;requiredDependency:codechickenlib-unofficial
# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token.
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish on Modrinth.
modrinthProjectId = notenoughitems-unofficial
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
modrinthRelations = required-project:codechickenlib-unofficial;required-project:codechickencore-unofficial
Binary file not shown.
+2 -1
View File
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+171 -115
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,78 +17,113 @@
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@@ -105,84 +140,105 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+15 -23
View File
@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,10 +25,14 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@@ -37,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -51,7 +55,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -61,38 +65,26 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
+11 -14
View File
@@ -1,18 +1,15 @@
// Add any additional repositiroes for your dependencies here
repositories {
mavenCentral()
maven {
name 'GTNH Maven'
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
}
maven {
url 'https://cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
maven {
url 'https://jitpack.io'
}
mavenCentral()
maven {
name 'GTNH Maven'
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
}
maven {
url 'https://cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
}
+28
View File
@@ -0,0 +1,28 @@
pluginManagement {
repositories {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
mavenContent {
includeGroup("com.gtnewhorizons.retrofuturagradle")
}
}
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
}
plugins {
id 'com.diffplug.blowdryerSetup' version '1.6.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
}
blowdryerSetup {
repoSubfolder 'gtnhShared'
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
//devLocal '.' // Use this when testing config updates locally
}
+135 -106
View File
@@ -4,17 +4,6 @@ import static codechicken.lib.gui.GuiDraw.drawRect;
import static codechicken.lib.gui.GuiDraw.getMousePosition;
import static codechicken.nei.NEIClientUtils.translate;
import codechicken.core.CommonUtils;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemPanel.ItemPanelSlot;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.BookmarkRecipeId;
import codechicken.nei.recipe.StackInfo;
import codechicken.nei.util.NBTJson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import java.awt.Point;
import java.io.File;
import java.io.FileInputStream;
@@ -23,18 +12,32 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import javax.annotation.Nullable;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import org.apache.commons.io.IOUtils;
import org.lwjgl.opengl.GL11;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import codechicken.core.CommonUtils;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemPanel.ItemPanelSlot;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.BookmarkRecipeId;
import codechicken.nei.recipe.StackInfo;
import codechicken.nei.util.NBTJson;
import codechicken.nei.util.ReadableNumberConverter;
public class BookmarkPanel extends PanelWidget {
protected File bookmarkFile;
@@ -50,6 +53,7 @@ public class BookmarkPanel extends PanelWidget {
protected int activeNamespaceIndex = 0;
protected static class BookmarkStackMeta {
public int factor;
public BookmarkRecipeId recipeId;
public boolean ingredient = false;
@@ -68,10 +72,13 @@ public class BookmarkPanel extends PanelWidget {
TODO_LIST
}
protected static class BookmarkGrid extends ItemsGrid {
public static class BookmarkGrid extends ItemsGrid {
protected static final float SCALE_SPEED = 0.1f;
protected List<List<Integer>> gridMask;
protected List<BookmarkStackMeta> metadata = new ArrayList<>();
protected WeakHashMap<ItemStack, Float> animation = new WeakHashMap<>();
protected BookmarkViewMode viewMode = BookmarkViewMode.DEFAULT;
protected boolean[] todoSpaces;
@@ -171,11 +178,8 @@ public class BookmarkPanel extends PanelWidget {
} else {
meta = getMetadata(idx);
if (idx > 0
&& ((i % columns) == 0)
== (meta.recipeId != null
&& meta.ingredient
&& meta.recipeId.equals(getRecipeId(idx - 1)))) {
if (idx > 0 && ((i % columns) == 0) == (meta.recipeId != null && meta.ingredient
&& meta.recipeId.equals(getRecipeId(idx - 1)))) {
pmask.add(null);
} else {
pmask.add(idx++);
@@ -206,8 +210,8 @@ public class BookmarkPanel extends PanelWidget {
for (int idx = 0; idx < realItems.size(); idx++) {
final BookmarkStackMeta meta = getMetadata(idx);
if ((recipeId == null && meta.recipeId == null
|| recipeId != null && meta.recipeId != null && recipeId.equals(meta.recipeId))
&& StackInfo.equalItemAndNBT(stackA, realItems.get(idx), useNBT)) {
|| recipeId != null && meta.recipeId != null && recipeId.equals(meta.recipeId))
&& StackInfo.equalItemAndNBT(stackA, getItem(idx), useNBT)) {
return idx;
}
}
@@ -220,8 +224,17 @@ public class BookmarkPanel extends PanelWidget {
}
public void addItem(ItemStack stackA, BookmarkStackMeta meta) {
addItem(stackA, meta, true);
}
public void addItem(ItemStack stackA, BookmarkStackMeta meta, boolean animate) {
realItems.add(stackA);
metadata.add(meta);
if (animate && !NEIClientConfig.shouldCacheItemRendering() && NEIClientConfig.areBookmarksAnimated()) {
animation.put(stackA, 0f);
}
onGridChanged();
}
@@ -253,6 +266,7 @@ public class BookmarkPanel extends PanelWidget {
}
protected boolean removeItem(int idx) {
animation.remove(getItem(idx));
realItems.remove(idx);
metadata.remove(idx);
onGridChanged();
@@ -282,8 +296,7 @@ public class BookmarkPanel extends PanelWidget {
}
private boolean isPartOfFocusedRecipe(ItemPanelSlot focused, int myIdx) {
return NEIClientUtils.shiftKey()
&& focused != null
return NEIClientUtils.shiftKey() && focused != null
&& LayoutManager.bookmarkPanel.sortedStackIndex == -1
&& getRecipeId(focused.slotIndex) != null
&& getRecipeId(myIdx) != null
@@ -299,12 +312,8 @@ public class BookmarkPanel extends PanelWidget {
} else if (focus != null) {
BookmarkStackMeta meta = getMetadata(idx);
if (isPartOfFocusedRecipe(focus, idx)) {
drawRect(
rect.x,
rect.y,
rect.w,
rect.h,
meta.ingredient ? 0x88b3b300 : 0x88009933); // highlight recipe
drawRect(rect.x, rect.y, rect.w, rect.h, meta.ingredient ? 0x88b3b300 : 0x88009933); // highlight
// recipe
} else if (focus.slotIndex == idx) {
drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555); // highlight
}
@@ -317,20 +326,34 @@ public class BookmarkPanel extends PanelWidget {
|| LayoutManager.bookmarkPanel.sortedStackIndex != idx) {
final ItemStack stack = getItem(idx);
final BookmarkStackMeta meta = getMetadata(idx);
GuiContainerManager.drawItem(
rect.x + 1,
rect.y + 1,
stack,
true,
meta.factor < 0 || meta.fluidDisplay ? "" : String.valueOf(stack.stackSize));
if (meta.recipeId != null && !meta.ingredient && NEIClientConfig.showRecipeMarker()) {
drawRecipeMarker(rect.x, rect.y, GuiContainerManager.getFontRenderer(stack));
final String stackSize = meta.factor < 0 || meta.fluidDisplay ? ""
: ReadableNumberConverter.INSTANCE.toWideReadableForm(stack.stackSize);
if (animation.containsKey(stack) && animation.get(stack) < 1) {
final float currentScale = animation.get(stack) + SCALE_SPEED;
animation.put(stack, currentScale);
drawPoppingItem(rect, stack, stackSize, currentScale);
} else {
GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, stack, true, stackSize);
if (meta.recipeId != null && !meta.ingredient && NEIClientConfig.showRecipeMarker()) {
drawRecipeMarker(rect.x, rect.y, GuiContainerManager.getFontRenderer(stack));
}
}
}
}
protected void drawPoppingItem(Rectangle4i rect, ItemStack stack, String stackSize, float currentScale) {
GL11.glScalef(currentScale, currentScale, currentScale); // push & pop matrix crashes the game
GuiContainerManager.drawItem(
Math.round((rect.x + 1 + (SLOT_SIZE / 2 - currentScale * SLOT_SIZE / 2)) / currentScale),
Math.round((rect.y + 1 + (SLOT_SIZE / 2 - currentScale * SLOT_SIZE / 2)) / currentScale),
stack,
true,
stackSize);
GL11.glScalef(1 / currentScale, 1 / currentScale, 1 / currentScale);
}
protected void drawRecipeMarker(int offsetX, int offsetY, FontRenderer fontRenderer) {
final float scaleFactor = fontRenderer.getUnicodeFlag() ? 0.85f : 0.5f;
final float inverseScaleFactor = 1.0f / scaleFactor;
@@ -358,6 +381,7 @@ public class BookmarkPanel extends PanelWidget {
namespaceLabel = new Label("1", true);
namespacePrev = new Button("Prev") {
public boolean onButtonPress(boolean rightclick) {
if (rightclick) {
@@ -374,6 +398,7 @@ public class BookmarkPanel extends PanelWidget {
};
namespaceNext = new Button("Next") {
public boolean onButtonPress(boolean rightclick) {
if (rightclick) {
return false;
@@ -403,16 +428,29 @@ public class BookmarkPanel extends PanelWidget {
return String.format("(%d/%d) [%d]", getPage(), Math.max(1, getNumPages()), size);
}
public void addItem(ItemStack itemStack) {
addItem(itemStack, true);
}
public void addItem(ItemStack itemStack, boolean saveStackSize) {
final BookmarkGrid BGrid = (BookmarkGrid) grid;
int idx = BGrid.indexOf(itemStack, true);
if (idx != -1) {
BGrid.removeItem(idx);
}
addOrRemoveItem(itemStack, null, null, false, saveStackSize);
}
public int getNameSpaceSize() {
return namespaces.size();
}
public void addOrRemoveItem(ItemStack stackA) {
addOrRemoveItem(stackA, null, null, false, false);
}
public void addOrRemoveItem(
ItemStack stackover,
final String handlerName,
final List<PositionedStack> ingredients,
boolean saveIngredients,
boolean saveStackSize) {
public void addOrRemoveItem(ItemStack stackover, final String handlerName, final List<PositionedStack> ingredients,
boolean saveIngredients, boolean saveStackSize) {
loadBookmarksIfNeeded();
final Point mousePos = getMousePosition();
@@ -488,7 +526,7 @@ public class BookmarkPanel extends PanelWidget {
BookmarkRecipeId recipeId = ((BookmarkGrid) grid).findRecipeId(stackA);
if (recipeId == null) {
for (int idx = 0; idx < namespaces.size() && recipeId == null; idx++) {
for (int idx = 0; idx < getNameSpaceSize() && recipeId == null; idx++) {
if (idx == activeNamespaceIndex) continue;
recipeId = namespaces.get(idx).findRecipeId(stackA);
}
@@ -505,18 +543,18 @@ public class BookmarkPanel extends PanelWidget {
protected int fixCountOfNamespaces() {
if (namespaces.get(namespaces.size() - 1).size() > 0) {
if (namespaces.get(getNameSpaceSize() - 1).size() > 0) {
namespaces.add(new BookmarkGrid());
} else if (activeNamespaceIndex == namespaces.size() - 2 && grid.size() == 0) {
namespaces.remove(namespaces.size() - 1);
} else if (activeNamespaceIndex == getNameSpaceSize() - 2 && grid.size() == 0) {
namespaces.remove(getNameSpaceSize() - 1);
}
return namespaces.size();
return getNameSpaceSize();
}
protected boolean removeEmptyNamespaces() {
if (activeNamespaceIndex != namespaces.size() - 1 && grid.size() == 0) {
if (activeNamespaceIndex != getNameSpaceSize() - 1 && grid.size() == 0) {
namespaces.remove(activeNamespaceIndex);
grid = namespaces.get(activeNamespaceIndex);
return true;
@@ -534,7 +572,7 @@ public class BookmarkPanel extends PanelWidget {
removeEmptyNamespaces();
if (activeNamespaceIndex == 0) {
activeNamespaceIndex = namespaces.size() - 1;
activeNamespaceIndex = getNameSpaceSize() - 1;
} else {
activeNamespaceIndex--;
}
@@ -592,8 +630,7 @@ public class BookmarkPanel extends PanelWidget {
src.close();
dst.close();
} catch (IOException e) {
}
} catch (IOException e) {}
}
}
@@ -608,7 +645,7 @@ public class BookmarkPanel extends PanelWidget {
ArrayList<String> strings = new ArrayList<>();
for (int grpIdx = 0; grpIdx < namespaces.size() - 1; grpIdx++) {
for (int grpIdx = 0; grpIdx < getNameSpaceSize() - 1; grpIdx++) {
final BookmarkGrid grid = namespaces.get(grpIdx);
JsonObject settings = new JsonObject();
@@ -695,10 +732,8 @@ public class BookmarkPanel extends PanelWidget {
}
if (settings.get("viewmode") != null) {
namespaces
.get(namespaceIndex)
.setViewMode(BookmarkViewMode.valueOf(
settings.get("viewmode").getAsString()));
namespaces.get(namespaceIndex)
.setViewMode(BookmarkViewMode.valueOf(settings.get("viewmode").getAsString()));
}
if (settings.get("active") != null && settings.get("active").getAsBoolean()) {
@@ -725,21 +760,14 @@ public class BookmarkPanel extends PanelWidget {
ItemStack itemStack = StackInfo.loadFromNBT(itemStackNBT);
if (itemStack != null) {
namespaces
.get(namespaceIndex)
.addItem(
itemStack,
new BookmarkStackMeta(
recipeId,
jsonObject.has("factor")
? jsonObject.get("factor").getAsInt()
: 0,
jsonObject.has("ingredient")
? jsonObject
.get("ingredient")
.getAsBoolean()
: false,
itemStackNBT.hasKey("gtFluidName")));
namespaces.get(namespaceIndex).addItem(
itemStack,
new BookmarkStackMeta(
recipeId,
jsonObject.has("factor") ? jsonObject.get("factor").getAsInt() : 0,
jsonObject.has("ingredient") ? jsonObject.get("ingredient").getAsBoolean() : false,
itemStackNBT.hasKey("gtFluidName")),
false);
} else {
NEIClientConfig.logger.warn(
"Failed to load bookmarked ItemStack from json string, the item no longer exists:\n{}",
@@ -883,17 +911,12 @@ public class BookmarkPanel extends PanelWidget {
final BookmarkGrid hoverGrid = namespaces.get(activeNamespaceIndex);
final BookmarkGrid sortedGrid = namespaces.get(sortedNamespaceIndex);
if (mouseOverSlot == null) {
mouseOverSlot =
getNextSlot(mousex, mousey, hoverGrid.getViewMode() == BookmarkViewMode.TODO_LIST);
}
if (mouseOverSlot != null) {
if (mouseOverSlot != null || getNextSlot(new Point(mousex, mousey)) >= 0) {
final ItemStack stack = sortedGrid.getItem(sortedStackIndex);
final BookmarkStackMeta meta = sortedGrid.getMetadata(sortedStackIndex);
sortedGrid.removeItem(sortedStackIndex);
hoverGrid.addItem(stack, meta);
hoverGrid.addItem(stack, meta, false);
sortedNamespaceIndex = activeNamespaceIndex;
sortedStackIndex = hoverGrid.indexOf(stack, meta.recipeId);
@@ -908,8 +931,7 @@ public class BookmarkPanel extends PanelWidget {
} else if (sortedGrid.getViewMode() == BookmarkViewMode.TODO_LIST) {
final ItemStack stack = sortedGrid.getItem(sortedStackIndex);
final BookmarkStackMeta meta = sortedGrid.getMetadata(sortedStackIndex);
final boolean isIngredient = sortedStackIndex > 0
&& meta.recipeId != null
final boolean isIngredient = sortedStackIndex > 0 && meta.recipeId != null
&& meta.ingredient
&& meta.recipeId.equals(sortedGrid.getRecipeId(sortedStackIndex - 1));
@@ -921,13 +943,12 @@ public class BookmarkPanel extends PanelWidget {
sortedStackIndex = sortedGrid.indexOf(stack, meta.recipeId);
}
} else if (mouseOverSlot != null
&& meta.recipeId != null
} else if (mouseOverSlot != null && meta.recipeId != null
&& sortedGrid.getMetadata(mouseOverSlot.slotIndex).ingredient
&& meta.recipeId.equals(sortedGrid.getRecipeId(mouseOverSlot.slotIndex))) {
sortedGrid.moveItem(sortedStackIndex, mouseOverSlot.slotIndex);
sortedStackIndex = sortedGrid.indexOf(stack, meta.recipeId);
}
sortedGrid.moveItem(sortedStackIndex, mouseOverSlot.slotIndex);
sortedStackIndex = sortedGrid.indexOf(stack, meta.recipeId);
}
}
}
}
@@ -938,23 +959,24 @@ public class BookmarkPanel extends PanelWidget {
super.mouseDragged(mousex, mousey, button, heldTime);
}
private ItemPanelSlot getNextSlot(int mousex, int mousey, boolean line) {
private int getNextSlot(final Point point) {
final List<Integer> mask = grid.getMask();
final int columns = grid.getColumns();
final int perPage = grid.getRows() * columns;
final boolean line = ((BookmarkGrid) grid).getViewMode() == BookmarkViewMode.TODO_LIST;
for (int i = mask.size(); i < perPage; i++) {
if (!grid.isInvalidSlot(i) && (!line || (i % columns) == 0)) {
if (grid.getSlotRect(i).contains(mousex, mousey)) {
return new ItemPanelSlot(grid.size() - 1, null);
if (point == null || grid.getSlotRect(i).contains(point.x, point.y)) {
return i;
}
return null;
return -1;
}
}
return null;
return -1;
}
@Override
@@ -965,14 +987,20 @@ public class BookmarkPanel extends PanelWidget {
GuiContainerManager.drawItem(
mousex - 8,
mousey - 8,
namespaces
.get(sortedNamespaceIndex)
.getItem(sortedStackIndex)
.copy(),
namespaces.get(sortedNamespaceIndex).getItem(sortedStackIndex).copy(),
true);
GuiContainerManager.drawItems.zLevel -= 100;
}
if (ItemPanels.itemPanel.draggedStack != null && this.contains(mousex, mousey)) {
final int idx = getNextSlot(null);
if (idx >= 0) {
Rectangle4i rect = grid.getSlotRect(idx);
drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555); // highlight
}
}
super.postDraw(mousex, mousey);
}
@@ -1025,11 +1053,10 @@ public class BookmarkPanel extends PanelWidget {
public boolean onMouseWheel(int shift, int mousex, int mousey) {
if (new Rectangle4i(
namespacePrev.x,
namespacePrev.y,
namespaceNext.x + namespaceNext.w - namespacePrev.x,
namespacePrev.h)
.contains(mousex, mousey)) {
namespacePrev.x,
namespacePrev.y,
namespaceNext.x + namespaceNext.w - namespacePrev.x,
namespacePrev.h).contains(mousex, mousey)) {
if (shift > 0) {
prevNamespace();
@@ -1085,8 +1112,10 @@ public class BookmarkPanel extends PanelWidget {
meta.factor = factor;
} else {
meta.factor = nbTag.getInteger("Count") == factor && shift < 0 ? -1 * factor : factor;
nbTag.setInteger("Count", Math.max(nbTag.getInteger("Count") + factor * shift, factor));
BGrid.replaceItem(slotIndex, StackInfo.loadFromNBT(nbTag));
if ((long) nbTag.getInteger("Count") + ((long) factor * shift) <= Integer.MAX_VALUE) {
nbTag.setInteger("Count", Math.max(nbTag.getInteger("Count") + factor * shift, factor));
BGrid.replaceItem(slotIndex, StackInfo.loadFromNBT(nbTag));
}
}
}
}
+2 -4
View File
@@ -5,6 +5,7 @@ import static codechicken.lib.gui.GuiDraw.getStringWidth;
import java.util.List;
public abstract class Button extends Widget {
public Button(String s) {
label = s;
}
@@ -60,10 +61,7 @@ public abstract class Button extends Widget {
public Image icon;
/**
* 0x4 = state flag, as opposed to 1 click
* 0 = normal
* 1 = on
* 2 = disabled
* 0x4 = state flag, as opposed to 1 click 0 = normal 1 = on 2 = disabled
*/
public int state;
}
@@ -1,6 +1,7 @@
package codechicken.nei;
public abstract class ButtonCycled extends Button {
public ButtonCycled() {}
public ButtonCycled(int num) {
@@ -1,19 +1,5 @@
package codechicken.nei;
import codechicken.core.ClientUtils;
import codechicken.core.GuiModListScroll;
import codechicken.lib.packet.PacketCustom;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.recipe.GuiRecipeTab;
import codechicken.nei.recipe.StackInfo;
import com.google.common.collect.Lists;
import cpw.mods.fml.client.CustomModLoadingErrorDisplayException;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -31,6 +17,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.FontRenderer;
@@ -44,32 +31,43 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord;
import org.apache.commons.io.IOUtils;
import com.google.common.collect.Lists;
import codechicken.core.ClientUtils;
import codechicken.core.GuiModListScroll;
import codechicken.lib.packet.PacketCustom;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.recipe.GuiRecipeTab;
import codechicken.nei.recipe.StackInfo;
import cpw.mods.fml.client.CustomModLoadingErrorDisplayException;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
public class ClientHandler {
private static String[] defaultSerialHandlers = {"WayofTime.alchemicalWizardry.client.nei.NEIAlchemyRecipeHandler"};
private static String[] defaultHeightHackHandlerRegex = {
"buildcraft.compat.nei.*",
"cofh.thermalexpansion.plugins.nei.handlers.*",
"crazypants.enderio.nei.*",
"forestry.factory.recipes.nei.*",
"ic2.neiIntegration.core.recipehandler.*",
"mariculture.plugins.nei.*",
"redgear.brewcraft.plugins.nei.*",
"tconstruct.plugins.nei.*",
"WayofTime.alchemicalWizardry.client.nei.*",
};
private static String[] defaultSerialHandlers = {
"WayofTime.alchemicalWizardry.client.nei.NEIAlchemyRecipeHandler" };
private static String[] defaultHeightHackHandlerRegex = { "buildcraft.compat.nei.*",
"cofh.thermalexpansion.plugins.nei.handlers.*", "crazypants.enderio.nei.*",
"forestry.factory.recipes.nei.*", "ic2.neiIntegration.core.recipehandler.*", "mariculture.plugins.nei.*",
"redgear.brewcraft.plugins.nei.*", "tconstruct.plugins.nei.*",
"WayofTime.alchemicalWizardry.client.nei.*", };
private static String[] defaultHandlerOrdering = {
"# Each line in this file should either be a comment (starts with '#') or an ordering.",
"# Ordering lines are <handler ID>,<ordering number>.",
"# Handlers will be sorted in order of number ascending, so smaller numbers first.",
"# Any handlers that are missing from this file will be assigned to 0.",
"# Negative numbers are fine.",
"# If you delete this file, it will be regenerated with all registered handler IDs.",
};
"# Each line in this file should either be a comment (starts with '#') or an ordering.",
"# Ordering lines are <handler ID>,<ordering number>.",
"# Handlers will be sorted in order of number ascending, so smaller numbers first.",
"# Any handlers that are missing from this file will be assigned to 0.", "# Negative numbers are fine.",
"# If you delete this file, it will be regenerated with all registered handler IDs.", };
private static ClientHandler instance;
private ArrayList<EntityItem> SMPmagneticItems = new ArrayList<>();
@@ -100,9 +98,10 @@ public class ClientHandler {
items = SMPmagneticItems;
} else {
items = world.getEntitiesWithinAABB(
EntityItem.class, player.boundingBox.expand(distancexz, distancey, distancexz));
EntityItem.class,
player.boundingBox.expand(distancexz, distancey, distancexz));
}
for (Iterator<EntityItem> iterator = items.iterator(); iterator.hasNext(); ) {
for (Iterator<EntityItem> iterator = items.iterator(); iterator.hasNext();) {
EntityItem item = iterator.next();
if (item.delayBeforeCanPickup > 0) continue;
@@ -166,8 +165,7 @@ public class ClientHandler {
if (!file.exists()) {
try (FileWriter writer = new FileWriter(file)) {
NEIClientConfig.logger.info("Creating default serial handlers list {}", file);
Collection<String> toSave = Loader.isModLoaded("dreamcraft")
? Collections.singletonList("")
Collection<String> toSave = Loader.isModLoaded("dreamcraft") ? Collections.singletonList("")
: Arrays.asList(defaultSerialHandlers);
IOUtils.writeLines(toSave, "\n", writer);
} catch (IOException e) {
@@ -196,8 +194,7 @@ public class ClientHandler {
try (FileReader reader = new FileReader(file)) {
NEIClientConfig.logger.info("Loading height hack handlers from file {}", file);
NEIClientConfig.heightHackHandlerRegex = IOUtils.readLines(reader).stream()
.map(Pattern::compile)
NEIClientConfig.heightHackHandlerRegex = IOUtils.readLines(reader).stream().map(Pattern::compile)
.collect(Collectors.toCollection(HashSet::new));
} catch (IOException e) {
NEIClientConfig.logger.error("Failed to load height hack handlers from file {}", file, e);
@@ -228,8 +225,7 @@ public class ClientHandler {
NEIClientConfig.logger.info("Creating default handler ordering CSV {}", file);
List<String> toWrite = Lists.newArrayList(defaultHandlerOrdering);
GuiRecipeTab.handlerMap.keySet().stream()
.sorted()
GuiRecipeTab.handlerMap.keySet().stream().sorted()
.forEach(handlerId -> toWrite.add(String.format("%s,0", handlerId)));
IOUtils.writeLines(toWrite, "\n", writer);
@@ -279,7 +275,11 @@ public class ClientHandler {
if (!NEIClientConfig.isEnabled()) return;
KeyManager.tickKeyStates();
/*
* NEI plugins are loaded in a separate thread. Make sure loading them has finished otherwise a CME might
* occur in KeyManager if a plugin calls API.addKeyBind() during initialization.
*/
if (NEIClientConfig.isLoaded()) KeyManager.tickKeyStates();
NEIController.updateUnlimitedItems(mc.thePlayer.inventory);
if (mc.currentScreen == null) NEIController.processCreativeCycling(mc.thePlayer.inventory);
@@ -319,7 +319,7 @@ public class ClientHandler {
NEIClientConfig.setInternalEnabled(false);
if (!Minecraft.getMinecraft().isSingleplayer()) // wait for server to initiate in singleplayer
NEIClientConfig.loadWorld("remote/" + ClientUtils.getServerIP().replace(':', '~'));
NEIClientConfig.loadWorld("remote/" + ClientUtils.getServerIP().replace(':', '~'));
ItemMobSpawner.clearEntityReferences(world);
}
@@ -334,6 +334,7 @@ public class ClientHandler {
public static RuntimeException throwCME(final String message) {
final GuiScreen errorGui = new GuiErrorScreen(null, null) {
@Override
public void handleMouseInput() {}
@@ -351,17 +352,14 @@ public class ClientHandler {
@SuppressWarnings("serial")
CustomModLoadingErrorDisplayException e = new CustomModLoadingErrorDisplayException() {
@Override
public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) {
Minecraft.getMinecraft().displayGuiScreen(errorGui);
}
@Override
public void drawScreen(
GuiErrorScreen errorScreen,
FontRenderer fontRenderer,
int mouseRelX,
int mouseRelY,
public void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY,
float tickTime) {}
};
throw e;
@@ -1,7 +1,5 @@
package codechicken.nei;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@@ -11,8 +9,13 @@ import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ContainerCreativeInv extends Container {
private class SlotArmor extends Slot {
final int armorType;
public SlotArmor(IInventory inv, int x, int y, int slot, int armor) {
@@ -38,14 +41,15 @@ public class ContainerCreativeInv extends Container {
}
private class SlotBlockArmor extends SlotArmor {
public SlotBlockArmor(IInventory inv, int x, int y, int slot, int armor) {
super(inv, x, y, slot, armor);
}
@Override
public boolean isItemValid(ItemStack stack) {
return super.isItemValid(stack)
|| stack != null; // && Block.getBlockFromItem(stack.getItem()) != Blocks.air;
return super.isItemValid(stack) || stack != null; // && Block.getBlockFromItem(stack.getItem()) !=
// Blocks.air;
}
}
@@ -54,20 +58,22 @@ public class ContainerCreativeInv extends Container {
public ContainerCreativeInv(EntityPlayer player, ExtendedCreativeInv extraInv) {
this.player = player;
InventoryPlayer invPlayer = player.inventory;
for (int row = 0; row < 6; row++)
for (int col = 0; col < 9; col++)
addSlotToContainer(new Slot(extraInv, col + row * 9, 8 + col * 18, 5 + row * 18));
for (int row = 0; row < 6; row++) for (int col = 0; col < 9; col++)
addSlotToContainer(new Slot(extraInv, col + row * 9, 8 + col * 18, 5 + row * 18));
for (int row = 0; row < 3; ++row)
for (int col = 0; col < 9; ++col)
addSlotToContainer(new Slot(invPlayer, col + row * 9 + 9, 8 + col * 18, 118 + row * 18));
for (int row = 0; row < 3; ++row) for (int col = 0; col < 9; ++col)
addSlotToContainer(new Slot(invPlayer, col + row * 9 + 9, 8 + col * 18, 118 + row * 18));
for (int col = 0; col < 9; ++col) addSlotToContainer(new Slot(invPlayer, col, 8 + col * 18, 176));
addSlotToContainer(new SlotBlockArmor(invPlayer, invPlayer.getSizeInventory() - 1, -15, 23, 0));
for (int armorType = 1; armorType < 4; armorType++)
addSlotToContainer(new SlotArmor(
invPlayer, invPlayer.getSizeInventory() - 1 - armorType, -15, 23 + armorType * 18, armorType));
for (int armorType = 1; armorType < 4; armorType++) addSlotToContainer(
new SlotArmor(
invPlayer,
invPlayer.getSizeInventory() - 1 - armorType,
-15,
23 + armorType * 18,
armorType));
}
@Override
@@ -1,7 +1,7 @@
package codechicken.nei;
import codechicken.lib.render.CCRenderState;
import java.util.ArrayList;
import net.minecraft.client.gui.Gui;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.player.EntityPlayer;
@@ -13,13 +13,18 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import codechicken.lib.render.CCRenderState;
/**
* This is crap code, don't ever do this.
*/
public class ContainerEnchantmentModifier extends ContainerEnchantment {
public static class EnchantmentHash {
public EnchantmentHash(Enchantment e, int i, int l) {
enchantment = e;
state = i;
@@ -101,9 +106,7 @@ public class ContainerEnchantmentModifier extends ContainerEnchantment {
int barempty = height - getScrollBarHeight();
int sbary = rely + (int) (barempty * percentscrolled + 0.5);
if (button == 0
&& getScrollBarHeight() < height
&& // the scroll bar can move (not full length)
if (button == 0 && getScrollBarHeight() < height && // the scroll bar can move (not full length)
mousex >= relx + cwidth
&& mousex < relx + cwidth + getScrollBarWidth()
&& mousey >= rely
@@ -217,10 +220,10 @@ public class ContainerEnchantmentModifier extends ContainerEnchantment {
if (NEIServerUtils.stackHasEnchantment(toolstack, e.effectId)) {
state = 2;
level = NEIServerUtils.getEnchantmentLevel(toolstack, e.effectId);
} else if (NEIServerUtils.doesEnchantmentConflict(NEIServerUtils.getEnchantments(toolstack), e)
&& validate) {
state = 1;
}
} else
if (NEIServerUtils.doesEnchantmentConflict(NEIServerUtils.getEnchantments(toolstack), e) && validate) {
state = 1;
}
slotEnchantment.add(new EnchantmentHash(e, state, level));
}
if (numoptions != slotEnchantment.size()) {
@@ -255,7 +258,12 @@ public class ContainerEnchantmentModifier extends ContainerEnchantment {
GL11.glColor3f(1, 1, 1);
if (hasScrollBar()) {
gui.drawTexturedModalRect(
relx, rely + slot * slotheight, 0, gui.ySize + slotheight * shade, cwidth - 30, slotheight);
relx,
rely + slot * slotheight,
0,
gui.ySize + slotheight * shade,
cwidth - 30,
slotheight);
gui.drawTexturedModalRect(
relx + cwidth - 30,
rely + slot * slotheight,
@@ -265,7 +273,12 @@ public class ContainerEnchantmentModifier extends ContainerEnchantment {
slotheight);
} else {
gui.drawTexturedModalRect(
relx, rely + slot * slotheight, 0, gui.ySize + slotheight * shade, cwidth + 7, slotheight);
relx,
rely + slot * slotheight,
0,
gui.ySize + slotheight * shade,
cwidth + 7,
slotheight);
}
gui.getFontRenderer().drawString(text, relx + 4, rely + slot * slotheight + 5, textColourFromState(shade));
@@ -284,12 +297,8 @@ public class ContainerEnchantmentModifier extends ContainerEnchantment {
Gui.drawRect(sbarx, rely, sbarx + getScrollBarWidth(), rely + height, 0xFF202020); // background
Gui.drawRect(sbarx, sbary, sbarx + getScrollBarWidth(), sbary + getScrollBarHeight(), 0xFF8B8B8B); // corners
Gui.drawRect(
sbarx,
sbary,
sbarx + getScrollBarWidth() - 1,
sbary + getScrollBarHeight() - 1,
0xFFF0F0F0); // topleft up
Gui.drawRect(sbarx, sbary, sbarx + getScrollBarWidth() - 1, sbary + getScrollBarHeight() - 1, 0xFFF0F0F0); // topleft
// up
Gui.drawRect(
sbarx + 1,
sbary + 1,
@@ -1,10 +1,5 @@
package codechicken.nei;
import codechicken.lib.inventory.ContainerExtended;
import codechicken.lib.inventory.InventoryNBT;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.lib.inventory.SlotHandleClicks;
import codechicken.lib.packet.PacketCustom;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
@@ -16,8 +11,16 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.PotionEffect;
import codechicken.lib.inventory.ContainerExtended;
import codechicken.lib.inventory.InventoryNBT;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.lib.inventory.SlotHandleClicks;
import codechicken.lib.packet.PacketCustom;
public class ContainerPotionCreator extends ContainerExtended {
public class SlotPotion extends Slot {
public SlotPotion(IInventory inv, int slotIndex, int x, int y) {
super(inv, slotIndex, x, y);
}
@@ -40,6 +43,7 @@ public class ContainerPotionCreator extends ContainerExtended {
}
public class SlotPotionStore extends SlotHandleClicks {
public SlotPotionStore(IInventory inv, int slotIndex, int x, int y) {
super(inv, slotIndex, x, y);
}
@@ -68,6 +72,7 @@ public class ContainerPotionCreator extends ContainerExtended {
}
public static class InventoryPotionStore extends InventoryNBT {
public InventoryPotionStore() {
super(9, NEIClientConfig.global.nbt.getCompoundTag("potionStore"));
}
@@ -128,9 +133,9 @@ public class ContainerPotionCreator extends ContainerExtended {
PotionEffect e = PotionEffect.readCustomPotionEffectFromNBT(tag);
if (e.getPotionID() != effectID) newEffects.appendTag(tag);
}
if (add)
newEffects.appendTag(new PotionEffect(effectID, packet.readInt(), packet.readUByte())
.writeCustomPotionEffectToNBT(new NBTTagCompound()));
if (add) newEffects.appendTag(
new PotionEffect(effectID, packet.readInt(), packet.readUByte())
.writeCustomPotionEffectToNBT(new NBTTagCompound()));
potion.getTagCompound().setTag("CustomPotionEffects", newEffects);
}
@@ -1,32 +1,29 @@
package codechicken.nei;
import codechicken.nei.api.IHighlightHandler;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.guihook.GuiContainerManager;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import codechicken.nei.api.IHighlightHandler;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.guihook.GuiContainerManager;
public class DefaultHighlightHandler implements IHighlightHandler {
@Override
public List<String> handleTextData(
ItemStack stack,
World world,
EntityPlayer player,
MovingObjectPosition mop,
List<String> currenttip,
ItemInfo.Layout layout) {
public List<String> handleTextData(ItemStack stack, World world, EntityPlayer player, MovingObjectPosition mop,
List<String> currenttip, ItemInfo.Layout layout) {
String name = null;
try {
String s = GuiContainerManager.itemDisplayNameShort(stack);
if (s != null && !s.endsWith("Unnamed")) name = s;
if (name != null) currenttip.add(name);
} catch (Exception ignored) {
}
} catch (Exception ignored) {}
if (name != null && stack.getItem() == Items.redstone) {
int md = world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ);
@@ -1,9 +1,11 @@
package codechicken.nei;
import codechicken.nei.api.ItemFilter;
import net.minecraft.item.ItemStack;
import codechicken.nei.api.ItemFilter;
public class DoubleFilteredFilter implements ItemFilter {
private ItemFilter filter;
private ItemList.PatternItemFilter patternFilter;
@@ -1,11 +1,13 @@
package codechicken.nei;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.relauncher.Side;
public class ExtendedCreativeInv implements IInventory {
final PlayerSave playerSave;
final Side side;
@@ -4,21 +4,25 @@ import static codechicken.nei.NEIServerUtils.areStacksIdentical;
import static codechicken.nei.NEIServerUtils.areStacksSameType;
import static codechicken.nei.NEIServerUtils.copyStack;
import codechicken.nei.guihook.GuiContainerManager;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import codechicken.nei.guihook.GuiContainerManager;
public class FastTransferManager {
/**
* Based on the general assumption that we want to fill top to bottom, left to right
*/
public static class SlotPositionComparator implements Comparator<Integer> {
final Container container;
public SlotPositionComparator(Container c) {
@@ -101,8 +105,7 @@ public class FastTransferManager {
if (!fillZoneWithHeldItem(window, toZone)) return;
for (int transferFrom : slotZones.get(fromZone)) {
ItemStack transferStack =
window.inventorySlots.getSlot(transferFrom).getStack();
ItemStack transferStack = window.inventorySlots.getSlot(transferFrom).getStack();
if (!areStacksSameType(heldStack, transferStack)) continue;
@@ -142,12 +145,10 @@ public class FastTransferManager {
ItemStack after = compareAfter.get(i);
if (!areStacksIdentical(before, after) && after != null)
if (before == null
? areStacksSameType(stack, after)
: // transfered into this empty slot
areStacksSameType(stack, after)
&& after.stackSize - before.stackSize > 0) // it added to this stack
return i;
if (before == null ? areStacksSameType(stack, after) : // transfered into this empty slot
areStacksSameType(stack, after) && after.stackSize - before.stackSize > 0) // it added to
// this stack
return i;
}
return -1;
@@ -180,16 +181,16 @@ public class FastTransferManager {
if (from.isItemValid(from.getStack())) moveOneItem(window, fromSlot, toSlot);
else // slots that you can't put stuff in
moveOutputSet(window, fromSlot, toSlot);
moveOutputSet(window, fromSlot, toSlot);
}
public void moveOutputSet(GuiContainer window, int fromSlot, int toSlot) {
if (NEIClientUtils.getHeldItem() != null) return;
clickSlot(window, fromSlot); // pickup fromSlot
if (NEIClientUtils.getHeldItem()
== null) // maybe this container does auto transfers. No need to pick up the final item
return;
if (NEIClientUtils.getHeldItem() == null) // maybe this container does auto transfers. No need to pick up the
// final item
return;
clickSlot(window, toSlot); // place one in toSlot
}
@@ -202,15 +203,15 @@ public class FastTransferManager {
public void retrieveItem(GuiContainer window, int toSlot) {
Slot slot = window.inventorySlots.getSlot(toSlot);
ItemStack slotStack = slot.getStack();
if (slotStack == null
|| slotStack.stackSize == slot.getSlotStackLimit()
|| slotStack.stackSize == slotStack.getMaxStackSize()) return;
if (slotStack == null || slotStack.stackSize == slot.getSlotStackLimit()
|| slotStack.stackSize == slotStack.getMaxStackSize())
return;
generateSlotMap(window.inventorySlots, slotStack);
Integer destZone = slotZoneMap.get(toSlot);
if (destZone == null) // slots that don't accept
return;
return;
int firstZoneSlot = findShiftClickDestinationSlot(window.inventorySlots, toSlot);
int firstZone = -1;
@@ -239,9 +240,9 @@ public class FastTransferManager {
Slot slot = window.inventorySlots.getSlot(i);
ItemStack stack1 = slot.getStack();
if (areStacksSameType(stack, stack1)
&& stack1.stackSize != slot.getSlotStackLimit()
&& // get from full stacks on second pass
if (areStacksSameType(stack, stack1) && stack1.stackSize != slot.getSlotStackLimit() && // get from full
// stacks on second
// pass
stack1.stackSize != stack1.getMaxStackSize()) {
moveOneItem(window, i, toSlot);
return true;
@@ -312,7 +313,7 @@ public class FastTransferManager {
generateSlotMap(window.inventorySlots, held);
Integer zone = slotZoneMap.get(pickedUpFromSlot);
if (zone == null) // something went wrong and we can't work out where the item was picked up from
return;
return;
for (int slotIndex : slotZones.get(zone)) {
Slot slot = window.inventorySlots.getSlot(slotIndex);
@@ -2,15 +2,18 @@ package codechicken.nei;
import static codechicken.nei.NEIClientUtils.translate;
import codechicken.lib.render.CCRenderState;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import codechicken.lib.render.CCRenderState;
public class GuiEnchantmentModifier extends GuiContainer {
final ContainerEnchantmentModifier container;
public GuiEnchantmentModifier(InventoryPlayer inventoryplayer, World world, int i, int j, int k) {
@@ -1,18 +1,22 @@
package codechicken.nei;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
public class GuiExtendedCreativeInv extends GuiContainer implements INEIGuiHandler {
public GuiExtendedCreativeInv(Container par1Container) {
super(par1Container);
ySize = 198;
+22 -11
View File
@@ -4,9 +4,11 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiNEIButton extends GuiButton {
protected static final ResourceLocation guiTex = new ResourceLocation("textures/gui/widgets.png");
public GuiNEIButton(int i, int j, int k, int l, int i1, String s) {
@@ -22,8 +24,8 @@ public class GuiNEIButton extends GuiButton {
boolean flag = i >= xPosition && j >= yPosition && i < xPosition + width && j < yPosition + height;
int k = getHoverState(flag);
drawTexturedModalRect(xPosition, yPosition, 0, 46 + k * 20, width / 2, height / 2); // top left
drawTexturedModalRect(
xPosition + width / 2, yPosition, 200 - width / 2, 46 + k * 20, width / 2, height / 2); // top right
drawTexturedModalRect(xPosition + width / 2, yPosition, 200 - width / 2, 46 + k * 20, width / 2, height / 2); // top
// right
drawTexturedModalRect(
xPosition,
yPosition + height / 2,
@@ -40,14 +42,23 @@ public class GuiNEIButton extends GuiButton {
height / 2); // bottom right
mouseDragged(minecraft, i, j);
if (!enabled)
drawCenteredString(
fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, 0xffa0a0a0);
else if (flag)
drawCenteredString(
fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, 0xffffa0);
else
drawCenteredString(
fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, 0xe0e0e0);
if (!enabled) drawCenteredString(
fontrenderer,
displayString,
xPosition + width / 2,
yPosition + (height - 8) / 2,
0xffa0a0a0);
else if (flag) drawCenteredString(
fontrenderer,
displayString,
xPosition + width / 2,
yPosition + (height - 8) / 2,
0xffffa0);
else drawCenteredString(
fontrenderer,
displayString,
xPosition + width / 2,
yPosition + (height - 8) / 2,
0xe0e0e0);
}
}
@@ -2,24 +2,29 @@ package codechicken.nei;
import static codechicken.nei.NEIClientUtils.translate;
import java.awt.Dimension;
import java.util.ArrayList;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import codechicken.core.gui.GuiCCButton;
import codechicken.core.gui.GuiCCTextField;
import codechicken.core.gui.GuiScrollSlot;
import codechicken.core.inventory.GuiContainerWidget;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.FontUtils;
import java.awt.Dimension;
import java.util.ArrayList;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
public class GuiPotionCreator extends GuiContainerWidget {
public class GuiSlotPotionEffects extends GuiScrollSlot {
public int selectedslot = -1;
public boolean enabled = true;
private final ArrayList<Potion> validPotions = new ArrayList<>();
@@ -69,7 +74,12 @@ public class GuiPotionCreator extends GuiContainerWidget {
CCRenderState.changeTexture("textures/gui/container/enchanting_table.png");
drawTexturedModalRect(x, y, 0, 166 + getSlotHeight(slot) * shade, width - 30, getSlotHeight(slot));
drawTexturedModalRect(
x + width - 30, y, width - 23, 166 + getSlotHeight(slot) * shade, 30, getSlotHeight(slot));
x + width - 30,
y,
width - 23,
166 + getSlotHeight(slot) * shade,
30,
getSlotHeight(slot));
if (potion.hasStatusIcon()) {
CCRenderState.changeTexture("textures/gui/container/inventory.png");
@@ -94,9 +104,7 @@ public class GuiPotionCreator extends GuiContainerWidget {
private PotionEffect getEffect(int id) {
ItemStack potion = container.potionInv.getStackInSlot(0);
if (potion != null
&& potion.hasTagCompound()
&& potion.getTagCompound().hasKey("CustomPotionEffects")) {
if (potion != null && potion.hasTagCompound() && potion.getTagCompound().hasKey("CustomPotionEffects")) {
NBTTagList potionTagList = potion.getTagCompound().getTagList("CustomPotionEffects", 10);
for (int i = 0; i < potionTagList.tagCount(); i++) {
PotionEffect effect = PotionEffect.readCustomPotionEffectFromNBT(potionTagList.getCompoundTagAt(i));
@@ -167,6 +175,7 @@ public class GuiPotionCreator extends GuiContainerWidget {
}
public class GuiDurationField extends GuiCCTextField {
private String baseValue;
public GuiDurationField(int x, int y, int width, int height) {
@@ -216,8 +225,8 @@ public class GuiPotionCreator extends GuiContainerWidget {
@Override
public void drawText() {
String s = getText();
String seconds =
s.substring(Math.max(0, s.length() - 2), Math.max(0, s.length() - 2) + Math.min(s.length(), 2));
String seconds = s
.substring(Math.max(0, s.length() - 2), Math.max(0, s.length() - 2) + Math.min(s.length(), 2));
String minutes = s.length() < 3 ? "" : s.substring(0, s.length() - 2);
int ty = y + height / 2 - 4;
int tcolour = getTextColour();
+10 -7
View File
@@ -5,23 +5,27 @@ import static codechicken.lib.gui.GuiDraw.drawString;
import static codechicken.lib.gui.GuiDraw.drawTooltipBox;
import static codechicken.lib.gui.GuiDraw.getStringWidth;
import codechicken.lib.config.ConfigTag;
import codechicken.nei.KeyManager.IKeyStateTracker;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.StackInfo;
import java.awt.Dimension;
import java.awt.Point;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import codechicken.lib.config.ConfigTag;
import codechicken.nei.KeyManager.IKeyStateTracker;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.StackInfo;
public class HUDRenderer implements IKeyStateTracker {
@Override
public void tickKeyStates() {
if (KeyManager.keyStates.get("world.highlight_tips").down) {
@@ -32,8 +36,7 @@ public class HUDRenderer implements IKeyStateTracker {
public static void renderOverlay() {
Minecraft mc = Minecraft.getMinecraft();
if (mc.currentScreen == null
&& mc.theWorld != null
if (mc.currentScreen == null && mc.theWorld != null
&& !mc.gameSettings.keyBindPlayerList.getIsKeyPressed()
&& NEIClientConfig.getBooleanSetting("world.highlight_tips")
&& mc.objectMouseOver != null
+1
View File
@@ -1,6 +1,7 @@
package codechicken.nei;
public class Image {
public int x;
public int y;
public int width;
@@ -1,11 +1,13 @@
package codechicken.nei;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.nei.api.IInfiniteItemHandler;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.nei.api.IInfiniteItemHandler;
public class InfiniteStackSizeHandler implements IInfiniteItemHandler {
@Override
public void onPickup(ItemStack heldItem) {
heldItem.stackSize = 1;
@@ -1,10 +1,12 @@
package codechicken.nei;
import codechicken.nei.api.IInfiniteItemHandler;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import codechicken.nei.api.IInfiniteItemHandler;
public class InfiniteToolHandler implements IInfiniteItemHandler {
@Override
public void onPickup(ItemStack heldItem) {
heldItem.setItemDamage(0);
@@ -5,15 +5,14 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
public class InventoryCraftingDummy extends InventoryCrafting {
public InventoryCraftingDummy() {
super(
new Container() {
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
}
},
3,
3);
super(new Container() {
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
}
}, 3, 3);
}
}
+56 -43
View File
@@ -1,12 +1,5 @@
package codechicken.nei;
import codechicken.nei.ThreadOperationTimer.TimeoutException;
import codechicken.nei.api.ItemFilter;
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.guihook.GuiContainerManager;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
@@ -15,11 +8,22 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import codechicken.nei.ThreadOperationTimer.TimeoutException;
import codechicken.nei.api.ItemFilter;
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.guihook.GuiContainerManager;
public class ItemList {
/**
* Fields are replaced atomically and contents never modified.
*/
@@ -37,8 +41,13 @@ public class ItemList {
private static final HashSet<Item> erroredItems = new HashSet<>();
private static final HashSet<String> stackTraces = new HashSet<>();
/**
* Unlike {@link LayoutManager#itemsLoaded}, this indicates whether item loading is actually finished or not.
*/
public static boolean loadFinished;
public static class EverythingItemFilter implements ItemFilter {
@Override
public boolean matches(ItemStack item) {
return true;
@@ -46,6 +55,7 @@ public class ItemList {
}
public static class NothingItemFilter implements ItemFilter {
@Override
public boolean matches(ItemStack item) {
return false;
@@ -53,6 +63,7 @@ public class ItemList {
}
public static class PatternItemFilter implements ItemFilter {
public Pattern pattern;
public PatternItemFilter(Pattern pattern) {
@@ -66,6 +77,7 @@ public class ItemList {
}
public static class AllMultiItemFilter implements ItemFilter {
public List<ItemFilter> filters;
public AllMultiItemFilter(List<ItemFilter> filters) {
@@ -78,18 +90,18 @@ public class ItemList {
@Override
public boolean matches(ItemStack item) {
for (ItemFilter filter : filters)
try {
if (!filter.matches(item)) return false;
} catch (Exception e) {
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
}
for (ItemFilter filter : filters) try {
if (!filter.matches(item)) return false;
} catch (Exception e) {
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
}
return true;
}
}
public static class AnyMultiItemFilter implements ItemFilter {
public List<ItemFilter> filters;
public AnyMultiItemFilter(List<ItemFilter> filters) {
@@ -102,18 +114,18 @@ public class ItemList {
@Override
public boolean matches(ItemStack item) {
for (ItemFilter filter : filters)
try {
if (filter.matches(item)) return true;
} catch (Exception e) {
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
}
for (ItemFilter filter : filters) try {
if (filter.matches(item)) return true;
} catch (Exception e) {
NEIClientConfig.logger.error("Exception filtering " + item + " with " + filter, e);
}
return false;
}
}
public static interface ItemsLoadedCallback {
public void itemsLoaded();
}
@@ -130,7 +142,7 @@ public class ItemList {
}
/**
* @deprecated use getItemListFilter().matches(item)
* @deprecated use getItemListFilter().matches(item)
*/
@Deprecated
public static boolean itemMatches(ItemStack item) {
@@ -150,28 +162,27 @@ public class ItemList {
}
public static final RestartableTask loadItems = new RestartableTask("NEI Item Loading") {
private void damageSearch(Item item, List<ItemStack> permutations) {
HashSet<String> damageIconSet = new HashSet<>();
for (int damage = 0; damage < 16; damage++)
try {
ItemStack itemstack = new ItemStack(item, 1, damage);
IIcon icon = item.getIconIndex(itemstack);
String name = GuiContainerManager.concatenatedDisplayName(itemstack, false);
String s = name + "@" + (icon == null ? 0 : icon.hashCode());
if (!damageIconSet.contains(s)) {
damageIconSet.add(s);
permutations.add(itemstack);
}
} catch (TimeoutException t) {
throw t;
} catch (Throwable t) {
NEIServerUtils.logOnce(
t,
stackTraces,
"Ommiting " + item + ":" + damage + " "
+ item.getClass().getSimpleName(),
item.toString());
for (int damage = 0; damage < 16; damage++) try {
ItemStack itemstack = new ItemStack(item, 1, damage);
IIcon icon = item.getIconIndex(itemstack);
String name = GuiContainerManager.concatenatedDisplayName(itemstack, false);
String s = name + "@" + (icon == null ? 0 : icon.hashCode());
if (!damageIconSet.contains(s)) {
damageIconSet.add(s);
permutations.add(itemstack);
}
} catch (TimeoutException t) {
throw t;
} catch (Throwable t) {
NEIServerUtils.logOnce(
t,
stackTraces,
"Ommiting " + item + ":" + damage + " " + item.getClass().getSimpleName(),
item.toString());
}
}
@Override
@@ -179,6 +190,7 @@ public class ItemList {
public void execute() {
// System.out.println("Executing NEI Item Loading");
ThreadOperationTimer timer = getTimer(NEIClientConfig.getItemLoadingTimeout());
loadFinished = false;
LinkedList<ItemStack> items = new LinkedList<>();
LinkedList<ItemStack> permutations = new LinkedList<>();
@@ -218,6 +230,8 @@ public class ItemList {
for (ItemsLoadedCallback callback : loadCallbacks) callback.itemsLoaded();
updateFilter.restart();
loadFinished = true;
}
};
@@ -231,6 +245,7 @@ public class ItemList {
public static ForkJoinPool forkJoinPool = getPool(numProcessors * 2 / 3);
public static final RestartableTask updateFilter = new RestartableTask("NEI Item Filtering") {
@Override
public void execute() {
// System.out.println("Executing NEI Item Filtering");
@@ -238,10 +253,8 @@ public class ItemList {
ItemFilter filter = getItemListFilter();
try {
filtered = ItemList.forkJoinPool
.submit(() -> items.parallelStream()
.filter(PresetsWidget::matches)
.filter(filter::matches)
filtered = ItemList.forkJoinPool.submit(
() -> items.parallelStream().filter(PresetsWidget::matches).filter(filter::matches)
.collect(Collectors.toCollection(ArrayList::new)))
.get();
} catch (InterruptedException | ExecutionException e) {
@@ -3,6 +3,7 @@ package codechicken.nei;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
@@ -20,6 +21,7 @@ import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
public class ItemMobSpawner extends ItemBlock {
private static Map<Integer, EntityLiving> entityHashMap;
private static Map<Integer, String> IDtoNameMap;
public static int idPig;
@@ -48,20 +50,11 @@ public class ItemMobSpawner extends ItemBlock {
return Blocks.mob_spawner.getBlockTextureFromSide(0);
}
public boolean onItemUse(
ItemStack itemstack,
EntityPlayer entityplayer,
World world,
int x,
int y,
int z,
int par7,
float par8,
float par9,
float par10) {
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int par7,
float par8, float par9, float par10) {
if (super.onItemUse(itemstack, entityplayer, world, x, y, z, par7, par8, par9, par10) && world.isRemote) {
TileEntityMobSpawner tileentitymobspawner =
(TileEntityMobSpawner) world.getTileEntity(placedX, placedY, placedZ);
TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner) world
.getTileEntity(placedX, placedY, placedZ);
if (tileentitymobspawner != null) {
setDefaultTag(itemstack);
String mobtype = IDtoNameMap.get(itemstack.getItemDamage());
@@ -93,8 +86,7 @@ public class ItemMobSpawner extends ItemBlock {
loadSpawners(world);
Class<?> clazz = (Class<?>) EntityList.IDtoClassMapping.get(ID);
try {
e = (EntityLiving)
clazz.getConstructor(new Class[] {World.class}).newInstance(world);
e = (EntityLiving) clazz.getConstructor(new Class[] { World.class }).newInstance(world);
} catch (Throwable t) {
if (clazz == null)
NEIClientConfig.logger.error("Null class for entity (" + ID + ", " + IDtoNameMap.get(ID));
@@ -117,15 +109,13 @@ public class ItemMobSpawner extends ItemBlock {
public static void loadSpawners(World world) {
if (loaded) return;
loaded = true;
HashMap<Class<Entity>, String> classToStringMapping =
(HashMap<Class<Entity>, String>) EntityList.classToStringMapping;
HashMap<Class<Entity>, Integer> classToIDMapping =
(HashMap<Class<Entity>, Integer>) EntityList.classToIDMapping;
HashMap<Class<Entity>, String> classToStringMapping = (HashMap<Class<Entity>, String>) EntityList.classToStringMapping;
HashMap<Class<Entity>, Integer> classToIDMapping = (HashMap<Class<Entity>, Integer>) EntityList.classToIDMapping;
for (Class<Entity> eclass : classToStringMapping.keySet()) {
if (!EntityLiving.class.isAssignableFrom(eclass)) continue;
try {
EntityLiving entityliving = (EntityLiving)
eclass.getConstructor(new Class[] {World.class}).newInstance(world);
EntityLiving entityliving = (EntityLiving) eclass.getConstructor(new Class[] { World.class })
.newInstance(world);
entityliving.isChild();
int id = classToIDMapping.get(eclass);
@@ -136,13 +126,11 @@ public class ItemMobSpawner extends ItemBlock {
IDtoNameMap.put(id, name);
if (name.equals("Pig")) idPig = id;
} catch (Throwable ignored) {
}
} catch (Throwable ignored) {}
}
IDtoNameMap.entrySet()
.removeIf(e -> getEntity(e.getKey()).getClass() == EntityPig.class
&& !e.getValue().equals("Pig"));
.removeIf(e -> getEntity(e.getKey()).getClass() == EntityPig.class && !e.getValue().equals("Pig"));
}
@Override
+34 -11
View File
@@ -2,16 +2,19 @@ package codechicken.nei;
import static codechicken.lib.gui.GuiDraw.drawRect;
import codechicken.lib.vec.Rectangle4i;
import java.util.ArrayList;
import javax.annotation.Nullable;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.lib.vec.Rectangle4i;
public class ItemPanel extends PanelWidget {
/**
* Backwards compat :-/
* Backwards compat :-/
*/
@SuppressWarnings("unused")
@Deprecated
@@ -33,6 +36,7 @@ public class ItemPanel extends PanelWidget {
public ItemQuantityField quantity;
public static class ItemPanelSlot {
public ItemStack item;
public int slotIndex;
@@ -48,6 +52,7 @@ public class ItemPanel extends PanelWidget {
}
protected static class ItemPanelGrid extends ItemsGrid {
public ArrayList<ItemStack> newItems;
public void setItems(ArrayList<ItemStack> items) {
@@ -73,6 +78,11 @@ public class ItemPanel extends PanelWidget {
super.drawSlotOutline(focused, slotIdx, rect);
}
}
@Override
public String getMessageOnEmpty() {
return ItemList.loadFinished ? null : NEIClientUtils.translate("itempanel.loading");
}
}
public ItemPanel() {
@@ -89,6 +99,7 @@ public class ItemPanel extends PanelWidget {
super.init();
more = new Button("+") {
@Override
public boolean onButtonPress(boolean rightclick) {
if (rightclick) return false;
@@ -105,6 +116,7 @@ public class ItemPanel extends PanelWidget {
}
};
less = new Button("-") {
@Override
public boolean onButtonPress(boolean rightclick) {
if (rightclick) return false;
@@ -154,19 +166,30 @@ public class ItemPanel extends PanelWidget {
}
protected int resizeFooter(GuiContainer gui) {
if (!NEIClientConfig.showItemQuantityWidget()) return 0;
final int BUTTON_SIZE = 16;
if (!NEIClientConfig.showItemQuantityWidget() && NEIClientConfig.isSearchWidgetCentered()) return 0;
final int BUTTON_SIZE = 20;
more.w = less.w = BUTTON_SIZE;
more.h = less.h = quantity.h = BUTTON_SIZE;
quantity.h = BUTTON_SIZE;
less.x = x;
more.x = x + w - BUTTON_SIZE;
more.y = less.y = quantity.y = y + h - BUTTON_SIZE;
if (NEIClientConfig.isSearchWidgetCentered()) {
more.h = less.h = BUTTON_SIZE;
more.x = x + w - BUTTON_SIZE;
more.y = less.y = quantity.y = y + h - BUTTON_SIZE;
less.x = x;
quantity.x = x + BUTTON_SIZE + 2;
quantity.w = more.x - quantity.x - 2;
} else {
quantity.x = (int) (x + (w * 0.7)) + 3;
quantity.y = y + h - BUTTON_SIZE;
quantity.w = (int) ((w * 0.3) - BUTTON_SIZE - 1);
quantity.x = x + BUTTON_SIZE + 2;
quantity.w = more.x - quantity.x - 2;
more.h = less.h = BUTTON_SIZE / 2;
more.y = y + h - (more.h * 2);
less.x = more.x = quantity.x + quantity.w;
less.y = more.y + more.h;
}
return BUTTON_SIZE + 2;
}
@@ -1,6 +1,7 @@
package codechicken.nei;
public class ItemPanels {
public static final ItemPanel itemPanel = new ItemPanel();
public static final BookmarkPanel bookmarkPanel = new BookmarkPanel();
}
@@ -3,6 +3,7 @@ package codechicken.nei;
import static codechicken.nei.NEIClientUtils.translate;
public class ItemQuantityField extends TextField {
public ItemQuantityField(String ident) {
super(ident);
centered = true;
+13 -8
View File
@@ -1,21 +1,25 @@
package codechicken.nei;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import codechicken.lib.config.ConfigTagParent;
import codechicken.nei.ItemList.ItemsLoadedCallback;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.config.GuiItemSorter;
import codechicken.nei.config.OptionOpenGui;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback {
public static class SortEntry {
public final String name;
public final Comparator<ItemStack> comparator;
@@ -44,7 +48,7 @@ public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback {
public static void sort(ArrayList<ItemStack> items) {
try {
// items = (ArrayList<ItemStack>)
// items = (ArrayList<ItemStack>)
// items.parallelStream().sorted(instance).collect(Collectors.toList());
items.sort(instance);
} catch (Exception e) {
@@ -125,6 +129,7 @@ public class ItemSorter implements Comparator<ItemStack>, ItemsLoadedCallback {
});
tag.getTag("inventory.itemsort").setDefaultValue(getSaveString(list));
API.addOption(new OptionOpenGui("inventory.itemsort", GuiItemSorter.class) {
@Override
public void useGlobals() {
super.useGlobals();
+16 -17
View File
@@ -4,20 +4,24 @@ import static codechicken.lib.inventory.InventoryUtils.actualDamage;
import static codechicken.lib.inventory.InventoryUtils.newItemStack;
import static net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE;
import com.google.common.base.Objects;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import com.google.common.base.Objects;
/**
* A maplike class for ItemStack keys with wildcard damage/NBT. Optimised for lookup
*/
public class ItemStackMap<T> {
public static class StackMetaKey {
public final int damage;
public final NBTTagCompound tag;
@@ -42,6 +46,7 @@ public class ItemStackMap<T> {
}
public static class Entry<T> {
public final ItemStack key;
public final T value;
@@ -52,6 +57,7 @@ public class ItemStackMap<T> {
}
public class DetailMap {
private boolean hasWildcard;
private T wildcard;
private HashMap<Integer, T> damageMap;
@@ -121,8 +127,7 @@ public class ItemStackMap<T> {
}
private void updateSize() {
int newSize = (hasWildcard ? 1 : 0)
+ (metaMap != null ? metaMap.size() : 0)
int newSize = (hasWildcard ? 1 : 0) + (metaMap != null ? metaMap.size() : 0)
+ (tagMap != null ? tagMap.size() : 0)
+ (damageMap != null ? damageMap.size() : 0);
@@ -151,16 +156,12 @@ public class ItemStackMap<T> {
public void addEntries(Item item, List<Entry<T>> list) {
if (wildcard != null) list.add(new Entry<>(newItemStack(item, 1, WILDCARD_VALUE, WILDCARD_TAG), wildcard));
if (damageMap != null)
for (Map.Entry<Integer, T> entry : damageMap.entrySet())
list.add(new Entry<>(newItemStack(item, 1, entry.getKey(), WILDCARD_TAG), entry.getValue()));
if (tagMap != null)
for (Map.Entry<NBTTagCompound, T> entry : tagMap.entrySet())
list.add(new Entry<>(newItemStack(item, 1, WILDCARD_VALUE, entry.getKey()), entry.getValue()));
if (metaMap != null)
for (Map.Entry<StackMetaKey, T> entry : metaMap.entrySet())
list.add(new Entry<>(
newItemStack(item, 1, entry.getKey().damage, entry.getKey().tag), entry.getValue()));
if (damageMap != null) for (Map.Entry<Integer, T> entry : damageMap.entrySet())
list.add(new Entry<>(newItemStack(item, 1, entry.getKey(), WILDCARD_TAG), entry.getValue()));
if (tagMap != null) for (Map.Entry<NBTTagCompound, T> entry : tagMap.entrySet())
list.add(new Entry<>(newItemStack(item, 1, WILDCARD_VALUE, entry.getKey()), entry.getValue()));
if (metaMap != null) for (Map.Entry<StackMetaKey, T> entry : metaMap.entrySet()) list.add(
new Entry<>(newItemStack(item, 1, entry.getKey().damage, entry.getKey().tag), entry.getValue()));
}
}
@@ -223,8 +224,7 @@ public class ItemStackMap<T> {
public List<ItemStack> keys() {
LinkedList<ItemStack> list = new LinkedList<>();
for (Map.Entry<Item, DetailMap> entry : itemMap.entrySet())
entry.getValue().addKeys(entry.getKey(), list);
for (Map.Entry<Item, DetailMap> entry : itemMap.entrySet()) entry.getValue().addKeys(entry.getKey(), list);
return list;
}
@@ -236,8 +236,7 @@ public class ItemStackMap<T> {
public List<Entry<T>> entries() {
LinkedList<Entry<T>> list = new LinkedList<>();
for (Map.Entry<Item, DetailMap> entry : itemMap.entrySet())
entry.getValue().addEntries(entry.getKey(), list);
for (Map.Entry<Item, DetailMap> entry : itemMap.entrySet()) entry.getValue().addEntries(entry.getKey(), list);
return list;
}
@@ -1,11 +1,13 @@
package codechicken.nei;
import codechicken.nei.api.ItemFilter;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import codechicken.nei.api.ItemFilter;
public class ItemStackSet extends ItemStackMap<ItemStack> implements ItemFilter {
public ItemStackSet with(ItemStack... items) {
for (ItemStack item : items) add(item);
return this;
+47 -13
View File
@@ -2,15 +2,12 @@ package codechicken.nei;
import static codechicken.lib.gui.GuiDraw.drawRect;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemPanel.ItemPanelSlot;
import codechicken.nei.api.GuiInfo;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.StackInfo;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -18,9 +15,17 @@ import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemPanel.ItemPanelSlot;
import codechicken.nei.api.GuiInfo;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.StackInfo;
public class ItemsGrid {
public static final int SLOT_SIZE = 18;
protected int width;
@@ -41,6 +46,8 @@ public class ItemsGrid {
protected boolean[] invalidSlotMap;
protected Label messageLabel = new Label(getMessageOnEmpty(), true);
@Nullable
private Framebuffer framebuffer = null;
@@ -61,7 +68,7 @@ public class ItemsGrid {
public int indexOf(ItemStack stackA, boolean useNBT) {
for (int idx = 0; idx < realItems.size(); idx++) {
if (StackInfo.equalItemAndNBT(stackA, realItems.get(idx), useNBT)) {
if (StackInfo.equalItemAndNBT(stackA, getItem(idx), useNBT)) {
return idx;
}
}
@@ -69,6 +76,11 @@ public class ItemsGrid {
return -1;
}
public void setPage(int page) {
this.page = Math.max(0, Math.min(page, getNumPages() - 1));
onGridChanged();
}
public int getPage() {
return page + 1;
}
@@ -104,6 +116,9 @@ public class ItemsGrid {
rows = height / SLOT_SIZE;
paddingLeft = (width % SLOT_SIZE) / 2;
messageLabel.x = marginLeft + width / 2;
messageLabel.y = marginTop + height / 2;
}
public void shiftPage(int shift) {
@@ -148,8 +163,12 @@ public class ItemsGrid {
invalidSlotMap = new boolean[rows * columns];
perPage = columns * rows;
checkGuiOverlap(gui, 0, columns - 2, 1);
checkGuiOverlap(gui, columns - 1, 1, -1);
if (NEIClientConfig.optimizeGuiOverlapComputation()) {
checkGuiOverlap(gui, 0, columns - 2, 1);
checkGuiOverlap(gui, columns - 1, 1, -1);
} else {
checkGuiOverlap(gui, 0, columns, 1);
}
if (oldRows != rows || oldColumns != columns || !Arrays.equals(oldSlotMap, invalidSlotMap)) {
onGridChanged();
@@ -159,13 +178,12 @@ public class ItemsGrid {
private void checkGuiOverlap(GuiContainer gui, int start, int end, int dir) {
boolean validColumn = false;
for (int c = start; c != end && !validColumn; c += dir) {
for (int c = start; c != end && (!NEIClientConfig.optimizeGuiOverlapComputation() || !validColumn); c += dir) {
validColumn = true;
for (int r = 0; r < rows; r++) {
final int idx = columns * r + c;
if (GuiInfo.hideItemPanelSlot(gui, getSlotRect(r, c))
&& idx >= 0
if (GuiInfo.hideItemPanelSlot(gui, getSlotRect(r, c)) && idx >= 0
&& idx < invalidSlotMap.length
&& !invalidSlotMap[idx]) {
invalidSlotMap[idx] = true;
@@ -194,7 +212,10 @@ public class ItemsGrid {
public Rectangle4i getSlotRect(int row, int column) {
return new Rectangle4i(
marginLeft + paddingLeft + column * SLOT_SIZE, marginTop + row * SLOT_SIZE, SLOT_SIZE, SLOT_SIZE);
marginLeft + paddingLeft + column * SLOT_SIZE,
marginTop + row * SLOT_SIZE,
SLOT_SIZE,
SLOT_SIZE);
}
public boolean isInvalidSlot(int index) {
@@ -288,7 +309,10 @@ public class ItemsGrid {
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
OpenGlHelper.glBlendFunc(
GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.GL_SRC_ALPHA,
GL11.GL_ONE_MINUS_SRC_ALPHA,
GL11.GL_SRC_ALPHA,
GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
drawItems();
@@ -305,6 +329,12 @@ public class ItemsGrid {
}
}
public void setVisible() {
if (getItems().isEmpty() && getMessageOnEmpty() != null) {
LayoutManager.addWidget(messageLabel);
}
}
protected void drawItem(Rectangle4i rect, int idx) {
GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, getItem(idx));
}
@@ -345,4 +375,8 @@ public class ItemsGrid {
return r >= rows || c >= columns || !isInvalidSlot(slt);
}
public String getMessageOnEmpty() {
return null;
}
}
@@ -8,11 +8,14 @@ import java.util.Map.Entry;
* Good old down/held/up keystate tracker
*/
public class KeyManager {
public static interface IKeyStateTracker {
public void tickKeyStates();
}
public static class KeyState {
public boolean down;
public boolean held;
public boolean up;
+1
View File
@@ -4,6 +4,7 @@ import static codechicken.lib.gui.GuiDraw.drawString;
import static codechicken.lib.gui.GuiDraw.drawStringC;
public class Label extends Widget {
final boolean centered;
final int colour;
public String text;
@@ -32,6 +32,23 @@ import static codechicken.nei.NEIClientUtils.toggleMagnetMode;
import static codechicken.nei.NEIClientUtils.toggleRaining;
import static codechicken.nei.NEIClientUtils.translate;
import java.util.HashMap;
import java.util.List;
import java.util.TreeSet;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.client.renderer.InventoryEffectRenderer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.KeyManager.IKeyStateTracker;
import codechicken.nei.api.API;
@@ -48,27 +65,10 @@ import codechicken.nei.guihook.IContainerObjectHandler;
import codechicken.nei.guihook.IContainerTooltipHandler;
import codechicken.nei.recipe.GuiRecipeTab;
import codechicken.nei.recipe.RecipeCatalysts;
import java.util.HashMap;
import java.util.List;
import java.util.TreeSet;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.client.renderer.InventoryEffectRenderer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
public class LayoutManager
implements IContainerInputHandler,
IContainerTooltipHandler,
IContainerDrawHandler,
IContainerObjectHandler,
IKeyStateTracker {
public class LayoutManager implements IContainerInputHandler, IContainerTooltipHandler, IContainerDrawHandler,
IContainerObjectHandler, IKeyStateTracker {
private static LayoutManager instance;
/** Note: this variable isn't actually used by this mod, but NEI add-ons might need it. */
@@ -112,6 +112,11 @@ public class LayoutManager
public static HashMap<Integer, LayoutStyle> layoutStyles = new HashMap<>();
/**
* This is set to true immediately after item loading thread is started, to prevent duplicated loading thread from
* being executed. If you want to know if item list is actually finished loading, Use {@link ItemList#loadFinished}
* instead.
*/
public static boolean itemsLoaded = false;
/**
@@ -133,11 +138,8 @@ public class LayoutManager
@Override
public void onPreDraw(GuiContainer gui) {
if (!isHidden()
&& isEnabled()
&& gui
instanceof
InventoryEffectRenderer) // Reset the gui to the center of the screen, for potion effect offsets
if (!isHidden() && isEnabled() && gui instanceof InventoryEffectRenderer) // Reset the gui to the center of the
// screen, for potion effect offsets
// etc
{
gui.guiLeft = (gui.width - gui.xSize) / 2;
@@ -177,9 +179,9 @@ public class LayoutManager
for (Widget widget : controlWidgets) {
widget.onGuiClick(mousex, mousey);
if (widget.contains(mousex, mousey)
? widget.handleClick(mousex, mousey, button)
: widget.handleClickExt(mousex, mousey, button)) return true;
if (widget.contains(mousex, mousey) ? widget.handleClick(mousex, mousey, button)
: widget.handleClickExt(mousex, mousey, button))
return true;
}
return false;
@@ -219,6 +221,11 @@ public class LayoutManager
return true;
}
if (NEIClientConfig.isKeyHashDown("gui.next_tooltip")) {
GuiContainerManager.incrementTooltipPage();
return true;
}
if (isEnabled() && !isHidden()) {
for (Widget widget : controlWidgets) if (inputFocused == null) widget.lastKeyTyped(keyID, keyChar);
}
@@ -298,8 +305,8 @@ public class LayoutManager
}
@Override
public List<String> handleItemTooltip(
GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List<String> currenttip) {
public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey,
List<String> currenttip) {
return currenttip;
}
@@ -344,6 +351,7 @@ public class LayoutManager
searchField = new SearchField("search");
options = new ButtonCycled(3) {
@Override
public void init() {
this.icons[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 32, 0, 16, 16).build();
@@ -351,17 +359,22 @@ public class LayoutManager
this.icons[2] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 64, 0, 16, 16).build();
}
private boolean getIsAccessibleControlEventKey() {
if (Minecraft.isRunningOnMac) {
return Keyboard.getEventKey() == Keyboard.KEY_LMETA || Keyboard.getEventKey() == Keyboard.KEY_RMETA;
}
return Keyboard.getEventKey() == Keyboard.KEY_LCONTROL
|| Keyboard.getEventKey() == Keyboard.KEY_RCONTROL;
}
@Override
public boolean onButtonPress(boolean rightclick) {
if (!rightclick) {
if (Keyboard.getEventKeyState()
&& (Keyboard.getEventKey() == Keyboard.KEY_LCONTROL
|| Keyboard.getEventKey() == Keyboard.KEY_RCONTROL)) {
if (Keyboard.getEventKeyState() && getIsAccessibleControlEventKey()) {
NEIClientConfig.cycleSetting("inventory.cheatmode", 3);
} else {
if (Keyboard.getEventKeyState()
&& (Keyboard.getEventKey() == Keyboard.KEY_LSHIFT
|| Keyboard.getEventKey() == Keyboard.KEY_RSHIFT)) {
if (Keyboard.getEventKeyState() && (Keyboard.getEventKey() == Keyboard.KEY_LSHIFT
|| Keyboard.getEventKey() == Keyboard.KEY_RSHIFT)) {
GuiRecipeTab.loadHandlerInfo();
RecipeCatalysts.loadCatalystInfo();
}
@@ -391,6 +404,7 @@ public class LayoutManager
};
bookmarksButton = new ButtonCycled(2) {
@Override
public void init() {
this.icons[0] = new DrawableBuilder("nei:textures/nei_tabbed_sprites.png", 0, 0, 16, 16).build();
@@ -417,6 +431,7 @@ public class LayoutManager
less = ItemPanels.itemPanel.less;
quantity = ItemPanels.itemPanel.quantity;
delete = new Button() {
@Override
public boolean onButtonPress(boolean rightclick) {
if ((state & 0x3) == 2) return false;
@@ -444,16 +459,16 @@ public class LayoutManager
@Override
public void postDraw(int mousex, int mousey) {
if (contains(mousex, mousey) && getHeldItem() != null && (state & 0x3) != 2)
GuiDraw.drawTip(
mousex + 9,
mousey,
translate(
"inventory.delete." + (shiftKey() ? "all" : "one"),
GuiContainerManager.itemDisplayNameShort(getHeldItem())));
if (contains(mousex, mousey) && getHeldItem() != null && (state & 0x3) != 2) GuiDraw.drawTip(
mousex + 9,
mousey,
translate(
"inventory.delete." + (shiftKey() ? "all" : "one"),
GuiContainerManager.itemDisplayNameShort(getHeldItem())));
}
};
gamemode = new ButtonCycled(3) {
@Override
public boolean onButtonPress(boolean rightclick) {
if (!rightclick) {
@@ -469,6 +484,7 @@ public class LayoutManager
}
};
rain = new Button() {
@Override
public boolean onButtonPress(boolean rightclick) {
if (handleDisabledButtonPress("rain", rightclick)) return true;
@@ -485,6 +501,7 @@ public class LayoutManager
}
};
magnet = new Button() {
@Override
public boolean onButtonPress(boolean rightclick) {
if (!rightclick) {
@@ -501,6 +518,7 @@ public class LayoutManager
for (int i = 0; i < 4; i++) {
final int zone = i;
timeButtons[i] = new Button() {
@Override
public boolean onButtonPress(boolean rightclick) {
if (handleDisabledButtonPress(NEIActions.timeZones[zone], rightclick)) return true;
@@ -519,6 +537,7 @@ public class LayoutManager
};
}
heal = new Button() {
@Override
public boolean onButtonPress(boolean rightclick) {
if (!rightclick) {
@@ -592,9 +611,9 @@ public class LayoutManager
NEIController.load(gui);
if (checkCreativeInv(gui)
&& gui.mc.currentScreen instanceof GuiContainerCreative) // override creative with creative+
gui.mc.displayGuiScreen(null); // close the screen and wait for the server to open it for us
if (checkCreativeInv(gui) && gui.mc.currentScreen instanceof GuiContainerCreative) // override creative with
// creative+
gui.mc.displayGuiScreen(null); // close the screen and wait for the server to open it for us
}
@Override
@@ -724,15 +743,15 @@ public class LayoutManager
@Override
public void renderSlotOverlay(GuiContainer window, Slot slot) {
ItemStack item = slot.getStack();
if (world.nbt.getBoolean("searchinventories")
&& (item == null
? !getSearchExpression().equals("")
: !((SearchField) searchField).getFilter().matches(item))) {
if (world.nbt.getBoolean("searchinventories") && (item == null ? !getSearchExpression().equals("")
: !((SearchField) searchField).getFilter().matches(item))) {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef(0, 0, 150);
drawRect(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, 0x80000000);
GL11.glTranslatef(0, 0, -150);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
}
@@ -745,7 +764,7 @@ public class LayoutManager
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (!isDrawableResource) drawTexturedModalRect(x, y, image.x, image.y, image.width, image.height);
else ((DrawableResource) image).draw(x, y);
else((DrawableResource) image).draw(x, y);
GL11.glDisable(GL11.GL_BLEND);
}
@@ -20,12 +20,15 @@ import static codechicken.nei.NEIClientConfig.disabledActions;
import static codechicken.nei.NEIClientConfig.getMagnetMode;
import static codechicken.nei.NEIClientConfig.isEnabled;
import codechicken.nei.api.LayoutStyle;
import codechicken.nei.drawable.DrawableBuilder;
import net.minecraft.client.gui.inventory.GuiContainer;
import org.lwjgl.opengl.GL11;
import codechicken.nei.api.LayoutStyle;
import codechicken.nei.drawable.DrawableBuilder;
public class LayoutStyleMinecraft extends LayoutStyle {
public int buttonCount;
public int leftSize;
public int numButtons;
@@ -88,9 +91,9 @@ public class LayoutStyleMinecraft extends LayoutStyle {
if (canPerformAction("delete")) layoutButton(delete);
if (canPerformAction("rain")) layoutButton(rain);
if (NEIClientUtils.isValidGamemode("creative")
|| NEIClientUtils.isValidGamemode("creative+")
|| NEIClientUtils.isValidGamemode("adventure")) layoutButton(gamemode);
if (NEIClientUtils.isValidGamemode("creative") || NEIClientUtils.isValidGamemode("creative+")
|| NEIClientUtils.isValidGamemode("adventure"))
layoutButton(gamemode);
if (canPerformAction("magnet")) layoutButton(magnet);
if (canPerformAction("time")) {
for (int i = 0; i < 4; i++) {
@@ -124,8 +127,13 @@ public class LayoutStyleMinecraft extends LayoutStyle {
presetsPanel.x = (gui.width - gui.xSize) / 2 + gui.xSize - presetsPanel.w;
searchField.h = 20;
searchField.w = 150;
searchField.x = (gui.width - searchField.w) / 2;
if (NEIClientConfig.isSearchWidgetCentered()) {
searchField.w = 150;
searchField.x = (gui.width - searchField.w) / 2;
} else {
searchField.w = (int) (itemPanel.w * (NEIClientConfig.showItemQuantityWidget() ? 0.7 : 1));
searchField.x = itemPanel.x;
}
searchField.y = gui.height - searchField.h - 2;
if (!visiblity.showItemSection) {
@@ -150,10 +158,9 @@ public class LayoutStyleMinecraft extends LayoutStyle {
int tex;
if ((b.state & 0x3) == 2) tex = 0;
else if ((b.state & 0x4) == 0 && b.contains(mousex, mousey)
|| // not a state button and mouseover
else if ((b.state & 0x4) == 0 && b.contains(mousex, mousey) || // not a state button and mouseover
(b.state & 0x3) == 1) // state active
tex = 2;
tex = 2;
else tex = 1;
LayoutManager.drawButtonBackground(b.x, b.y, b.w, b.h, true, tex);
@@ -6,6 +6,7 @@ import java.util.LinkedList;
import java.util.List;
public class NEIActions {
public static final int protocol = 0;
public static HashMap<String, NEIActions> nameActionMap = new HashMap<>();
@@ -61,8 +62,8 @@ public class NEIActions {
canDisable.add("rain");
}
public static final String[] timeZones = new String[] {"dawn", "noon", "dusk", "midnight"};
public static final String[] gameModes = new String[] {"survival", "creative", "creative+", "adventure"};
public static final String[] timeZones = new String[] { "dawn", "noon", "dusk", "midnight" };
public static final String[] gameModes = new String[] { "survival", "creative", "creative+", "adventure" };
public String name;
public String base;
+19 -11
View File
@@ -1,10 +1,5 @@
package codechicken.nei;
import codechicken.core.ClientUtils;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.lib.packet.PacketCustom;
import codechicken.lib.packet.PacketCustom.IClientPacketHandler;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.item.ItemStack;
@@ -12,7 +7,14 @@ import net.minecraft.network.play.INetHandlerPlayClient;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.World;
import codechicken.core.ClientUtils;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.lib.packet.PacketCustom;
import codechicken.lib.packet.PacketCustom.IClientPacketHandler;
import cpw.mods.fml.relauncher.Side;
public class NEICPH implements IClientPacketHandler {
public static final String channel = "NEI";
@Override
@@ -38,14 +40,14 @@ public class NEICPH implements IClientPacketHandler {
break;
case 21:
ClientUtils.openSMPGui(
packet.readUByte(), new GuiEnchantmentModifier(mc.thePlayer.inventory, mc.theWorld, 0, 0, 0));
packet.readUByte(),
new GuiEnchantmentModifier(mc.thePlayer.inventory, mc.theWorld, 0, 0, 0));
break;
case 23:
if (packet.readBoolean())
ClientUtils.openSMPGui(
packet.readUByte(),
new GuiExtendedCreativeInv(new ContainerCreativeInv(
mc.thePlayer, new ExtendedCreativeInv(null, Side.CLIENT))));
if (packet.readBoolean()) ClientUtils.openSMPGui(
packet.readUByte(),
new GuiExtendedCreativeInv(
new ContainerCreativeInv(mc.thePlayer, new ExtendedCreativeInv(null, Side.CLIENT))));
else mc.displayGuiScreen(new GuiInventory(mc.thePlayer));
break;
case 24:
@@ -141,6 +143,12 @@ public class NEICPH implements IClientPacketHandler {
packet.sendToServer();
}
public static void sendRequestContainer() {
PacketCustom packet = new PacketCustom(channel, 16);
packet.writeInt(Minecraft.getMinecraft().thePlayer.openContainer.getInventory().size());
packet.sendToServer();
}
public static void sendSetSlot(int slot, ItemStack stack, boolean container) {
PacketCustom packet = new PacketCustom(channel, 5);
packet.writeBoolean(container);
@@ -1,15 +1,18 @@
package codechicken.nei;
import codechicken.nei.api.INEIGuiAdapter;
import codechicken.nei.api.TaggedInventoryArea;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.item.ItemStack;
import codechicken.nei.api.INEIGuiAdapter;
import codechicken.nei.api.TaggedInventoryArea;
public class NEIChestGuiHandler extends INEIGuiAdapter {
public int chestSize(GuiContainer gui) {
return ((ContainerChest) gui.inventorySlots).getLowerChestInventory().getSizeInventory();
}
@@ -1,5 +1,28 @@
package codechicken.nei;
import java.io.File;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.function.Function;
import java.util.regex.Pattern;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraft.world.storage.SaveFormatComparator;
import net.minecraftforge.common.MinecraftForge;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import com.google.common.base.Objects;
import codechicken.core.CCUpdateChecker;
import codechicken.core.ClassDiscoverer;
import codechicken.core.ClientUtils;
@@ -31,35 +54,18 @@ import codechicken.nei.recipe.IRecipeHandler;
import codechicken.nei.recipe.RecipeCatalysts;
import codechicken.nei.recipe.RecipeInfo;
import codechicken.obfuscator.ObfuscationRun;
import com.google.common.base.Objects;
import java.io.File;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.function.Function;
import java.util.regex.Pattern;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraft.world.storage.SaveFormatComparator;
import net.minecraftforge.common.MinecraftForge;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
public class NEIClientConfig {
private static boolean configLoaded;
private static boolean enabledOverride;
private static String worldPath;
public static Logger logger = LogManager.getLogger("NotEnoughItems");
public static File configDir = new File(CommonUtils.getMinecraftDir(), "config/NEI/");
public static ConfigSet global =
new ConfigSet(new File("saves/NEI/client.dat"), new ConfigFile(new File(configDir, "client.cfg")));
public static ConfigSet global = new ConfigSet(
new File("saves/NEI/client.dat"),
new ConfigFile(new File(configDir, "client.cfg")));
public static ConfigSet world;
public static final File handlerFile = new File(configDir, "handlers.csv");
public static final File catalystFile = new File(configDir, "catalysts.csv");
@@ -84,12 +90,22 @@ public class NEIClientConfig {
// Function that extracts the handler ID from a handler, with special logic for
// TemplateRecipeHandler: prefer using the overlay ID if it exists.
public static final Function<IRecipeHandler, String> HANDLER_ID_FUNCTION =
handler -> Objects.firstNonNull(handler.getOverlayIdentifier(), handler.getHandlerId());
public static final Function<IRecipeHandler, String> HANDLER_ID_FUNCTION = handler -> Objects
.firstNonNull(handler.getOverlayIdentifier(), handler.getHandlerId());
public static int getHandlerOrder(IRecipeHandler handler) {
if (handlerOrdering.get(handler.getOverlayIdentifier()) != null) {
return handlerOrdering.get(handler.getOverlayIdentifier());
}
if (handlerOrdering.get(handler.getHandlerId()) != null) {
return handlerOrdering.get(handler.getHandlerId());
}
return 0;
}
// Comparator that compares handlers using the handlerOrdering map.
public static final Comparator<IRecipeHandler> HANDLER_COMPARATOR =
Comparator.comparingInt(handler -> handlerOrdering.getOrDefault(HANDLER_ID_FUNCTION.apply(handler), 0));
public static final Comparator<IRecipeHandler> HANDLER_COMPARATOR = Comparator
.comparingInt(NEIClientConfig::getHandlerOrder);
public static ItemStack[] creativeInv;
@@ -111,10 +127,8 @@ public class NEIClientConfig {
tag.setComment(
"Main configuration of NEI.\nMost of these options can be changed ingame.\nDeleting any element will restore it to it's default value");
tag.getTag("command")
.useBraces()
.setComment(
"Change these options if you have a different mod installed on the server that handles the commands differently, Eg. Bukkit Essentials");
tag.getTag("command").useBraces().setComment(
"Change these options if you have a different mod installed on the server that handles the commands differently, Eg. Bukkit Essentials");
tag.setNewLineMode(1);
tag.getTag("inventory.widgetsenabled").getBooleanValue(true);
@@ -122,11 +136,11 @@ public class NEIClientConfig {
tag.getTag("inventory.hidden").getBooleanValue(false);
tag.getTag("inventory.cheatmode").getIntValue(2);
tag.getTag("inventory.lockmode")
.setComment(
"For those who can't help themselves.\nSet this to a mode and you will be unable to change it ingame")
tag.getTag("inventory.lockmode").setComment(
"For those who can't help themselves.\nSet this to a mode and you will be unable to change it ingame")
.getIntValue(-1);
API.addOption(new OptionCycled("inventory.cheatmode", 3) {
@Override
public boolean optionValid(int index) {
return getLockedMode() == -1 || getLockedMode() == index && NEIInfo.isValidMode(index);
@@ -173,6 +187,7 @@ public class NEIClientConfig {
tag.getTag("inventory.invertMouseScrollTransfer").getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.invertMouseScrollTransfer", true) {
@Override
public boolean isEnabled() {
return isMouseScrollTransferEnabled();
@@ -195,10 +210,10 @@ public class NEIClientConfig {
tag.getTag("command.heal").setDefaultValue("");
API.addOption(new OptionTextField("command.heal"));
tag.getTag("inventory.worldSpecificBookmarks")
.setComment("Global or world specific bookmarks")
tag.getTag("inventory.worldSpecificBookmarks").setComment("Global or world specific bookmarks")
.getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.worldSpecificBookmarks", true) {
@Override
public boolean onClick(int button) {
super.onClick(button);
@@ -207,10 +222,10 @@ public class NEIClientConfig {
}
});
tag.getTag("inventory.worldSpecificPresets")
.setComment("Global or world specific presets")
tag.getTag("inventory.worldSpecificPresets").setComment("Global or world specific presets")
.getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.worldSpecificPresets", true) {
@Override
public boolean onClick(int button) {
super.onClick(button);
@@ -219,51 +234,54 @@ public class NEIClientConfig {
}
});
tag.getTag("inventory.bookmarksEnabled")
.setComment("Enable/disable bookmarks")
.getBooleanValue(true);
tag.getTag("inventory.bookmarksEnabled").setComment("Enable/disable bookmarks").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.bookmarksEnabled", true));
tag.getTag("inventory.useNBTInBookmarks")
.setComment("Use NBT in Bookmarks")
.getBooleanValue(true);
tag.getTag("inventory.useNBTInBookmarks").setComment("Use NBT in Bookmarks").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.useNBTInBookmarks", true));
tag.getTag("inventory.showRecipeMarker")
.setComment("Show Recipe Marker")
.getBooleanValue(false);
tag.getTag("inventory.bookmarksAnimationEnabled").setComment("REI Style Animation in Bookmarks")
.getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.bookmarksAnimationEnabled", true));
tag.getTag("inventory.showRecipeMarker").setComment("Show Recipe Marker").getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.showRecipeMarker", true));
tag.getTag("inventory.showItemQuantityWidget")
.setComment("Show Item Quantity Widget")
.getBooleanValue(true);
tag.getTag("inventory.showItemQuantityWidget").setComment("Show Item Quantity Widget").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.showItemQuantityWidget", true));
tag.getTag("inventory.jei_style_tabs")
.setComment("Enable/disable JEI Style Tabs")
.getBooleanValue(true);
tag.getTag("inventory.centerSearchWidget").setComment("Center Search Widget").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.centerSearchWidget", true));
tag.getTag("inventory.jei_style_tabs").setComment("Enable/disable JEI Style Tabs").getBooleanValue(true);
API.addOption(new OptionToggleButtonBoubs("inventory.jei_style_tabs", true));
tag.getTag("inventory.jei_style_item_presence_overlay")
.setComment("Enable/disable JEI Style item presence overlay on ?-hover")
.getBooleanValue(true);
.setComment("Enable/disable JEI Style item presence overlay on ?-hover").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.jei_style_item_presence_overlay", true));
tag.getTag("inventory.jei_style_recipe_catalyst")
.setComment("Enable/disable JEI Style Recipe Catalysts")
tag.getTag("inventory.jei_style_recipe_catalyst").setComment("Enable/disable JEI Style Recipe Catalysts")
.getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.jei_style_recipe_catalyst", true));
tag.getTag("inventory.creative_tab_style")
.setComment("Creative or JEI style tabs")
.getBooleanValue(false);
tag.getTag("inventory.creative_tab_style").setComment("Creative or JEI style tabs").getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.creative_tab_style", true));
tag.getTag("inventory.ignore_potion_overlap")
.setComment("Ignore overlap with potion effect HUD")
tag.getTag("inventory.ignore_potion_overlap").setComment("Ignore overlap with potion effect HUD")
.getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.ignore_potion_overlap", true));
tag.getTag("tools.handler_load_from_config")
.setComment("ADVANCED: Load handlers from config")
tag.getTag("inventory.optimize_gui_overlap_computation").setComment("Optimize computation for GUI overlap")
.getBooleanValue(false);
API.addOption(new OptionToggleButton("inventory.optimize_gui_overlap_computation", true));
tag.getTag("inventory.jei_style_cycled_ingredients").setComment("JEI styled cycled ingredients")
.getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.jei_style_cycled_ingredients", true));
tag.getTag("inventory.shift_overlay_recipe")
.setComment("Require holding shift to move items when overlaying recipe").getBooleanValue(true);
API.addOption(new OptionToggleButton("inventory.shift_overlay_recipe", true));
tag.getTag("tools.handler_load_from_config").setComment("ADVANCED: Load handlers from config")
.getBooleanValue(false);
API.addOption(new OptionToggleButton("tools.handler_load_from_config", true) {
@Override
public boolean onClick(int button) {
super.onClick(button);
@@ -272,10 +290,10 @@ public class NEIClientConfig {
}
});
tag.getTag("tools.catalyst_load_from_config")
.setComment("ADVANCED: Load catalysts from config")
tag.getTag("tools.catalyst_load_from_config").setComment("ADVANCED: Load catalysts from config")
.getBooleanValue(false);
API.addOption(new OptionToggleButton("tools.catalyst_load_from_config", true) {
@Override
public boolean onClick(int button) {
super.onClick(button);
@@ -289,6 +307,7 @@ public class NEIClientConfig {
private static void linkOptionList() {
OptionList.setOptionList(new OptionList("nei.options") {
@Override
public ConfigSet globalConfigSet() {
return global;
@@ -329,11 +348,15 @@ public class NEIClientConfig {
API.addHashBind("gui.bookmark_recipe", Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH);
API.addHashBind("gui.bookmark_count", Keyboard.KEY_A + NEIClientUtils.CTRL_HASH);
API.addHashBind(
"gui.bookmark_recipe_count", Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH + NEIClientUtils.CTRL_HASH);
"gui.bookmark_recipe_count",
Keyboard.KEY_A + NEIClientUtils.SHIFT_HASH + NEIClientUtils.CTRL_HASH);
API.addHashBind("gui.overlay", Keyboard.KEY_S);
API.addHashBind("gui.overlay_use", Keyboard.KEY_S + NEIClientUtils.SHIFT_HASH);
API.addHashBind("gui.overlay_hide", Keyboard.KEY_S + NEIClientUtils.CTRL_HASH);
API.addHashBind("gui.hide_bookmarks", Keyboard.KEY_B);
API.addKeyBind("gui.getprevioussearch", Keyboard.KEY_UP);
API.addKeyBind("gui.getnextsearch", Keyboard.KEY_DOWN);
API.addHashBind("gui.next_tooltip", Keyboard.KEY_Z);
API.addKeyBind("world.chunkoverlay", Keyboard.KEY_F9);
API.addKeyBind("world.moboverlay", Keyboard.KEY_F7);
@@ -381,10 +404,8 @@ public class NEIClientConfig {
ItemPanels.itemPanel.quantity.setText(Integer.toString(getItemQuantity()));
SubsetWidget.loadHidden();
if (newWorld && Minecraft.getMinecraft().isSingleplayer())
world.config
.getTag("inventory.cheatmode")
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) world.config.getTag("inventory.cheatmode")
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
NEIInfo.load(ClientUtils.getWorld());
}
@@ -399,7 +420,7 @@ public class NEIClientConfig {
}
public static int getKeyBinding(String string) {
return getSetting("keys." + string).getIntValue();
return getSetting("keys." + string).getIntValue(Keyboard.KEY_NONE);
}
public static void setDefaultKeyBinding(String string, int key) {
@@ -411,6 +432,36 @@ public class NEIClientConfig {
return hash != Keyboard.CHAR_NONE && hash == NEIClientUtils.getKeyHash();
}
public static String getKeyName(int keyBind, boolean useHash) {
return getKeyName(keyBind, useHash, false);
}
public static String getKeyName(int keyBind, boolean useHash, boolean showOnlyHash) {
String keyText = "";
if (useHash) {
final String DELIMITER = " + ";
if ((keyBind & NEIClientUtils.CTRL_HASH) != 0) {
keyText += NEIClientUtils.translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl") + DELIMITER;
}
if ((keyBind & NEIClientUtils.SHIFT_HASH) != 0) {
keyText += "SHIFT" + DELIMITER;
}
if ((keyBind & NEIClientUtils.ALT_HASH) != 0) {
keyText += "ALT" + DELIMITER;
}
}
if (!showOnlyHash) {
keyText += Keyboard.getKeyName(unHashKey(keyBind));
}
return keyText;
}
public static int unHashKey(int keyBind) {
return keyBind & ~(NEIClientUtils.CTRL_HASH | NEIClientUtils.SHIFT_HASH | NEIClientUtils.ALT_HASH);
}
public static void bootNEI(World world) {
if (configLoaded) return;
@@ -421,13 +472,13 @@ public class NEIClientConfig {
NEIController.load();
RecipeCatalysts.loadCatalystInfo();
configLoaded = true;
new Thread("NEI Plugin Loader") {
@Override
public void run() {
ClassDiscoverer classDiscoverer = new ClassDiscoverer(
test -> test.startsWith("NEI") && test.endsWith("Config.class"), IConfigureNEI.class);
test -> test.startsWith("NEI") && test.endsWith("Config.class"),
IConfigureNEI.class);
classDiscoverer.findClasses();
@@ -443,6 +494,7 @@ public class NEIClientConfig {
}
MinecraftForge.EVENT_BUS.post(new NEIConfigsLoadedEvent());
configLoaded = true;
}
}.start();
ItemSorter.loadConfig();
@@ -492,6 +544,10 @@ public class NEIClientConfig {
return getBooleanSetting("inventory.useNBTInBookmarks");
}
public static boolean areBookmarksAnimated() {
return getBooleanSetting("inventory.bookmarksAnimationEnabled");
}
public static boolean showRecipeMarker() {
return getBooleanSetting("inventory.showRecipeMarker");
}
@@ -500,6 +556,10 @@ public class NEIClientConfig {
return getBooleanSetting("inventory.showItemQuantityWidget");
}
public static boolean isSearchWidgetCentered() {
return getBooleanSetting("inventory.centerSearchWidget");
}
public static boolean areJEIStyleTabsVisible() {
return getBooleanSetting("inventory.jei_style_tabs");
}
@@ -520,10 +580,26 @@ public class NEIClientConfig {
return getBooleanSetting("inventory.ignore_potion_overlap");
}
public static boolean optimizeGuiOverlapComputation() {
return getBooleanSetting("inventory.optimize_gui_overlap_computation");
}
public static boolean useJEIStyledCycledIngredients() {
return getBooleanSetting("inventory.jei_style_cycled_ingredients");
}
public static boolean requireShiftForOverlayRecipe() {
return getBooleanSetting("inventory.shift_overlay_recipe");
}
public static boolean isEnabled() {
return enabledOverride && getBooleanSetting("inventory.widgetsenabled");
}
public static boolean isLoaded() {
return configLoaded;
}
public static boolean loadHandlersFromJar() {
return !getBooleanSetting("tools.handler_load_from_config");
}
@@ -8,13 +8,8 @@ import static codechicken.nei.NEIClientConfig.hasSMPCounterPart;
import static codechicken.nei.NEIClientConfig.invCreativeMode;
import static codechicken.nei.NEIClientConfig.world;
import codechicken.lib.inventory.InventoryRange;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.lib.util.LangProxy;
import codechicken.nei.api.GuiInfo;
import codechicken.nei.api.IInfiniteItemHandler;
import codechicken.nei.api.ItemInfo;
import com.google.common.collect.Iterables;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
@@ -29,7 +24,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
@@ -39,11 +36,24 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import com.google.common.collect.Iterables;
import codechicken.lib.inventory.InventoryRange;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.lib.util.LangProxy;
import codechicken.nei.api.GuiInfo;
import codechicken.nei.api.IInfiniteItemHandler;
import codechicken.nei.api.ItemInfo;
public class NEIClientUtils extends NEIServerUtils {
public static LangProxy lang = new LangProxy("nei");
/** Formats a number with group separator and at most 2 fraction digits. */
@@ -105,8 +115,7 @@ public class NEIClientUtils extends NEIServerUtils {
}
public static void decreaseSlotStack(int slotNumber) {
ItemStack stack = slotNumber == -999
? getHeldItem()
ItemStack stack = slotNumber == -999 ? getHeldItem()
: mc().thePlayer.openContainer.getSlot(slotNumber).getStack();
if (stack == null) return;
@@ -147,7 +156,7 @@ public class NEIClientUtils extends NEIServerUtils {
}
/**
* @param mode -1 = normal cheats, 0 = no infinites, 1 = replenish stack
* @param mode -1 = normal cheats, 0 = no infinites, 1 = replenish stack
*/
public static void cheatItem(ItemStack stack, int button, int mode) {
if (!canCheatItem(stack)) return;
@@ -186,16 +195,14 @@ public class NEIClientUtils extends NEIServerUtils {
ItemStack stack = copyStack(base, i);
if (hasSMPCounterPart()) {
ItemStack typestack = copyStack(stack, 1);
if (!infinite
&& !canItemFitInInventory(mc().thePlayer, stack)
if (!infinite && !canItemFitInInventory(mc().thePlayer, stack)
&& (mc().currentScreen instanceof GuiContainer)) {
GuiContainer gui = getGuiContainer();
final List<Iterable<Integer>> handlerSlots;
try {
GuiInfo.readLock.lock();
handlerSlots = GuiInfo.guiHandlers.stream()
.map(handler -> handler.getItemSpawnSlots(gui, typestack))
.filter(x -> x != null)
.map(handler -> handler.getItemSpawnSlots(gui, typestack)).filter(x -> x != null)
.collect(Collectors.toCollection(LinkedList::new));
} finally {
GuiInfo.readLock.unlock();
@@ -220,7 +227,7 @@ public class NEIClientUtils extends NEIServerUtils {
if (given > 0) NEICPH.sendGiveItem(copyStack(typestack, given), false, false);
} else NEICPH.sendGiveItem(stack, infinite, true);
} else {
for (int given = 0; given < stack.stackSize; ) {
for (int given = 0; given < stack.stackSize;) {
int qty = Math.min(stack.stackSize - given, stack.getMaxStackSize());
sendCommand(
getStringSetting("command.item"),
@@ -244,6 +251,9 @@ public class NEIClientUtils extends NEIServerUtils {
}
public static boolean controlKey() {
if (Minecraft.isRunningOnMac) {
return Keyboard.isKeyDown(Keyboard.KEY_LMETA) || Keyboard.isKeyDown(Keyboard.KEY_RMETA);
}
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
}
@@ -256,9 +266,7 @@ public class NEIClientUtils extends NEIServerUtils {
public static boolean isValidGamemode(String s) {
return s.equals("survival")
|| canPerformAction(s)
&& Arrays.asList(getStringArrSetting("inventory.gamemodes"))
.contains(s);
|| canPerformAction(s) && Arrays.asList(getStringArrSetting("inventory.gamemodes")).contains(s);
}
public static int getNextGamemode() {
@@ -277,11 +285,10 @@ public class NEIClientUtils extends NEIServerUtils {
if (mode == nmode) return;
if (hasSMPCounterPart()) NEICPH.sendGamemode(nmode);
else
sendCommand(
getStringSetting("command.creative"),
getGameType(nmode),
mc().thePlayer.getCommandSenderName());
else sendCommand(
getStringSetting("command.creative"),
getGameType(nmode),
mc().thePlayer.getCommandSenderName());
}
public static long getTime() {
@@ -306,9 +313,8 @@ public class NEIClientUtils extends NEIServerUtils {
NumberFormat numberformat = NumberFormat.getIntegerInstance();
numberformat.setGroupingUsed(false);
MessageFormat messageformat = new MessageFormat(command);
for (int i = 0; i < args.length; i++)
if (args[i] instanceof Integer || args[i] instanceof Long)
messageformat.setFormatByArgumentIndex(i, numberformat);
for (int i = 0; i < args.length; i++) if (args[i] instanceof Integer || args[i] instanceof Long)
messageformat.setFormatByArgumentIndex(i, numberformat);
mc().thePlayer.sendChatMessage(messageformat.format(args));
}
@@ -344,13 +350,13 @@ public class NEIClientUtils extends NEIServerUtils {
continue;
}
if (next + 1 != i) {
ranges.add(new int[] {start, next});
ranges.add(new int[] { start, next });
start = next = i;
continue;
}
next = i;
}
ranges.add(new int[] {start, next});
ranges.add(new int[] { start, next });
return ranges;
}
@@ -428,8 +434,7 @@ public class NEIClientUtils extends NEIServerUtils {
if (Keyboard.getEventKeyState()) {
final int keycode = Keyboard.getEventKey();
if (keycode != Keyboard.KEY_LSHIFT
&& keycode != Keyboard.KEY_RSHIFT
if (keycode != Keyboard.KEY_LSHIFT && keycode != Keyboard.KEY_RSHIFT
&& keycode != Keyboard.KEY_LCONTROL
&& keycode != Keyboard.KEY_RCONTROL
&& keycode != Keyboard.KEY_LMENU
@@ -445,4 +450,30 @@ public class NEIClientUtils extends NEIServerUtils {
mc().getSoundHandler()
.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
}
public static void reportErrorBuffered(Throwable e, Set<String> buffer, String cause) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String stackTrace = cause + sw;
if (buffer.contains(stackTrace)) return;
System.err.println("Error while rendering: " + cause);
e.printStackTrace();
buffer.add(stackTrace);
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (player != null) {
IChatComponent chat = new ChatComponentTranslation("nei.chat.render.error");
chat.getChatStyle().setColor(EnumChatFormatting.RED);
player.addChatComponentMessage(chat);
}
}
public static void reportErrorBuffered(Throwable e, Set<String> buffer, ItemStack cause) {
if (cause != null) {
reportErrorBuffered(e, buffer, cause.toString());
} else {
reportErrorBuffered(e, buffer, "null");
}
}
}
@@ -1,3 +1,4 @@
package codechicken.nei;
public class NEICompatibility {}
public class NEICompatibility {
}
@@ -2,6 +2,16 @@ package codechicken.nei;
import static codechicken.lib.gui.GuiDraw.getMousePosition;
import java.awt.Point;
import java.util.LinkedList;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
import codechicken.nei.api.API;
import codechicken.nei.api.GuiInfo;
import codechicken.nei.api.IInfiniteItemHandler;
@@ -11,16 +21,9 @@ import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerInputHandler;
import codechicken.nei.guihook.IContainerSlotClickHandler;
import codechicken.nei.recipe.GuiRecipe;
import java.awt.Point;
import java.util.LinkedList;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack;
public class NEIController implements IContainerSlotClickHandler, IContainerInputHandler {
private static final NEIController instance = new NEIController();
public static GuiContainerManager manager;
@@ -82,16 +85,15 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
public static void processCreativeCycling(InventoryPlayer inventory) {
if (NEIClientConfig.invCreativeMode() && NEIClientUtils.controlKey()) {
if (selectedItem != inventory.currentItem) {
if (inventory.currentItem == selectedItem + 1
|| (inventory.currentItem == 0 && selectedItem == 8)) // foward
if (inventory.currentItem == selectedItem + 1 || (inventory.currentItem == 0 && selectedItem == 8)) // foward
{
NEICPH.sendCreativeScroll(1);
inventory.currentItem = selectedItem;
} else if (inventory.currentItem == selectedItem - 1
|| (inventory.currentItem == 8 && selectedItem == 0)) {
NEICPH.sendCreativeScroll(-1);
inventory.currentItem = selectedItem;
}
NEICPH.sendCreativeScroll(-1);
inventory.currentItem = selectedItem;
}
}
}
@@ -106,8 +108,8 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
}
@Override
public boolean handleSlotClick(
GuiContainer gui, int slotIndex, int button, Slot slot, int modifier, boolean eventconsumed) {
public boolean handleSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier,
boolean eventconsumed) {
if (eventconsumed || !NEIClientConfig.isEnabled() || isSpreading(gui)) return eventconsumed;
if (deleteMode && slotIndex >= 0 && slot != null) {
@@ -123,12 +125,12 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
if (button == 1 && slot instanceof SlotCrafting) // right click
{
for (int i1 = 0; i1 < 64; i1++) // click this slot 64 times
manager.handleSlotClick(slot.slotNumber, button, 0);
manager.handleSlotClick(slot.slotNumber, button, 0);
return true;
}
if (NEIClientUtils.controlKey()
&& modifier != 4 // Drop key pressed: net.minecraft.client.gui.inventory.GuiContainer.keyTyped
if (NEIClientUtils.controlKey() && modifier != 4 // Drop key pressed:
// net.minecraft.client.gui.inventory.GuiContainer.keyTyped
&& slot != null
&& slot.getStack() != null
&& slot.isItemValid(slot.getStack())) {
@@ -138,8 +140,7 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
if (GuiInfo.hasCustomSlots(gui)) return false;
if (slotIndex >= 0
&& NEIClientUtils.shiftKey()
if (slotIndex >= 0 && NEIClientUtils.shiftKey()
&& NEIClientUtils.getHeldItem() != null
&& !slot.getHasStack()) {
ItemStack held = NEIClientUtils.getHeldItem();
@@ -167,8 +168,7 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
if (firstheld != nowHeld) pickedUpFromSlot = slotIndex;
if (NEIClientConfig.canPerformAction("item") && NEIClientConfig.hasSMPCounterPart()) {
if (heldStackInfinite != null
&& slot != null
if (heldStackInfinite != null && slot != null
&& slot.inventory == NEIClientUtils.mc().thePlayer.inventory) {
ItemStack stack = slot.getStack();
if (stack != null) {
@@ -214,9 +214,9 @@ public class NEIController implements IContainerSlotClickHandler, IContainerInpu
@Override
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
if (!NEIClientConfig.isEnabled()
|| GuiInfo.hasCustomSlots(gui)
|| !NEIClientConfig.isMouseScrollTransferEnabled()) return false;
if (!NEIClientConfig.isEnabled() || GuiInfo.hasCustomSlots(gui)
|| !NEIClientConfig.isMouseScrollTransferEnabled())
return false;
// slot in GuiRecipe does not contain actual stack
// and scroll should be handled by GuiRecipe, not here
@@ -1,11 +1,13 @@
package codechicken.nei;
import codechicken.nei.api.INEIGuiAdapter;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.creativetab.CreativeTabs;
import codechicken.nei.api.INEIGuiAdapter;
public class NEICreativeGuiHandler extends INEIGuiAdapter {
@Override
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
if (!(gui instanceof GuiContainerCreative)) return currentVisibility;
@@ -1,18 +1,19 @@
package codechicken.nei;
import codechicken.lib.inventory.ContainerExtended;
import codechicken.lib.inventory.SlotDummy;
import codechicken.nei.api.INEIGuiAdapter;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import codechicken.lib.inventory.ContainerExtended;
import codechicken.lib.inventory.SlotDummy;
import codechicken.nei.api.INEIGuiAdapter;
public class NEIDummySlotHandler extends INEIGuiAdapter {
@Override
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) {
Slot slot = gui.getSlotAtPosition(mousex, mousey);
if (slot instanceof SlotDummy
&& slot.isItemValid(draggedStack)
if (slot instanceof SlotDummy && slot.isItemValid(draggedStack)
&& gui.inventorySlots instanceof ContainerExtended) {
((SlotDummy) slot).slotClick(draggedStack, button, NEIClientUtils.shiftKey());
NEICPH.sendDummySlotSet(slot.slotNumber, slot.getStack());
@@ -1,13 +1,19 @@
package codechicken.nei;
import java.io.File;
import java.util.*;
import net.minecraft.util.EnumChatFormatting;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import codechicken.core.CommonUtils;
import codechicken.core.launch.CodeChickenCorePlugin;
import codechicken.nei.api.IConfigureNEI;
import codechicken.nei.asm.NEICorePlugin;
import codechicken.nei.config.IMCHandler;
import codechicken.nei.recipe.GuiRecipeTab;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import cpw.mods.fml.client.FMLFileResourcePack;
import cpw.mods.fml.client.FMLFolderResourcePack;
import cpw.mods.fml.common.DummyModContainer;
@@ -21,11 +27,9 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.versioning.ArtifactVersion;
import cpw.mods.fml.common.versioning.VersionParser;
import cpw.mods.fml.common.versioning.VersionRange;
import java.io.File;
import java.util.*;
import net.minecraft.util.EnumChatFormatting;
public class NEIModContainer extends DummyModContainer {
public static LinkedList<IConfigureNEI> plugins = new LinkedList<>();
private static boolean gregTech5Loaded;
@@ -37,13 +41,12 @@ public class NEIModContainer extends DummyModContainer {
private static ModMetadata getModMetadata() {
final ModMetadata modMetadata = new ModMetadata();
modMetadata.name = "GRADLETOKEN_MODNAME";
modMetadata.modId = "GRADLETOKEN_MODID";
modMetadata.version = "GRADLETOKEN_VERSION";
modMetadata.name = "NotEnoughItems";
modMetadata.modId = "NotEnoughItems";
modMetadata.version = Tags.VERSION;
modMetadata.authorList = Arrays.asList("ChickenBones", "mitchej123");
modMetadata.url = "https://github.com/GTNewHorizons/NotEnoughItems";
modMetadata.description =
"Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many enhancements.";
modMetadata.description = "Recipe Viewer, Inventory Manager, Item Spawner, Cheats and more; GTNH Version includes many enhancements.";
return modMetadata;
}
@@ -1,18 +1,21 @@
package codechicken.nei;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.api.INEIGuiAdapter;
import java.util.Collection;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.InventoryEffectRenderer;
import net.minecraft.potion.PotionEffect;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.api.INEIGuiAdapter;
/**
* Inspired by InventoryEffectRendererGuiHandler.java in JEI
*/
public class NEIPotionGuiHandler extends INEIGuiAdapter {
@Override
public boolean hideItemPanelSlot(GuiContainer guiContainer, int slotX, int slotY, int slotW, int slotH) {
if (NEIClientConfig.ignorePotionOverlap()) {
+20 -8
View File
@@ -1,14 +1,8 @@
package codechicken.nei;
import codechicken.core.CommonUtils;
import codechicken.core.ServerUtils;
import codechicken.lib.inventory.SlotDummy;
import codechicken.lib.packet.PacketCustom;
import codechicken.lib.packet.PacketCustom.IServerPacketHandler;
import codechicken.lib.vec.BlockCoord;
import cpw.mods.fml.relauncher.Side;
import java.util.LinkedList;
import java.util.Set;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.InventoryBasic;
@@ -19,7 +13,16 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.world.World;
import codechicken.core.CommonUtils;
import codechicken.core.ServerUtils;
import codechicken.lib.inventory.SlotDummy;
import codechicken.lib.packet.PacketCustom;
import codechicken.lib.packet.PacketCustom.IServerPacketHandler;
import codechicken.lib.vec.BlockCoord;
import cpw.mods.fml.relauncher.Side;
public class NEISPH implements IServerPacketHandler {
@Override
public void handlePacket(PacketCustom packet, EntityPlayerMP sender, INetHandlerPlayServer netHandler) {
if (!NEIServerConfig.authenticatePacket(sender, packet)) return;
@@ -64,6 +67,9 @@ public class NEISPH implements IServerPacketHandler {
case 15:
handleMobSpawnerID(sender.worldObj, packet.readCoord(), packet.readString());
break;
case 16:
handleRequestContainer(sender, packet.readInt());
break;
case 21:
openEnchantmentGui(sender);
break;
@@ -99,6 +105,11 @@ public class NEISPH implements IServerPacketHandler {
}
}
private void handleRequestContainer(EntityPlayerMP sender, int containerSize) {
if (sender.openContainer.getInventory().size() != containerSize) return;
sender.sendContainerToPlayer(sender.openContainer);
}
private void handlePropertyChange(EntityPlayerMP sender, PacketCustom packet) {
String name = packet.readString();
if (NEIServerConfig.canPlayerPerformAction(sender.getCommandSenderName(), name))
@@ -112,7 +123,8 @@ public class NEISPH implements IServerPacketHandler {
new ContainerCreativeInv(
sender,
new ExtendedCreativeInv(
NEIServerConfig.forPlayer(sender.getCommandSenderName()), Side.SERVER)),
NEIServerConfig.forPlayer(sender.getCommandSenderName()),
Side.SERVER)),
(player, windowId) -> {
PacketCustom packet = new PacketCustom(channel, 23);
packet.writeBoolean(true);
@@ -1,10 +1,5 @@
package codechicken.nei;
import codechicken.core.CommonUtils;
import codechicken.core.ServerUtils;
import codechicken.lib.config.ConfigFile;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.lib.packet.PacketCustom;
import java.io.File;
import java.io.FileReader;
import java.io.PrintWriter;
@@ -16,6 +11,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
@@ -25,11 +21,20 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import codechicken.core.CommonUtils;
import codechicken.core.ServerUtils;
import codechicken.lib.config.ConfigFile;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.lib.packet.PacketCustom;
public class NEIServerConfig {
private static MinecraftServer server;
public static Logger logger = LogManager.getLogger("NotEnoughItems");
@@ -73,8 +78,7 @@ public class NEIServerConfig {
serverConfig.setNewLineMode(1);
serverConfig.getTag("permissions").useBraces();
serverConfig
.getTag("permissions")
serverConfig.getTag("permissions")
.setComment("List of players who can use these features.\nEg. time=CodeChicken, Friend1");
setDefaultFeature("time");
@@ -93,7 +97,7 @@ public class NEIServerConfig {
}
private static void setDefaultFeature(String featurename, String... names) {
if (names.length == 0) names = new String[] {"OP"};
if (names.length == 0) names = new String[] { "OP" };
StringBuilder list = new StringBuilder();
for (int i = 0; i < names.length; i++) {
@@ -105,7 +109,11 @@ public class NEIServerConfig {
private static void saveWorld(int dim) {
try {
File file = new File(getSaveDir(DimensionManager.getWorld(dim)), "world.dat");
final File saveDir = getSaveDir(DimensionManager.getWorld(dim));
if (!saveDir.isDirectory()) {
FileUtils.forceMkdir(saveDir);
}
File file = new File(saveDir, "world.dat");
NEIServerUtils.writeNBT(dimTags.get(dim), file);
} catch (Exception e) {
throw new RuntimeException(e);
@@ -1,13 +1,5 @@
package codechicken.nei;
import codechicken.core.CommonUtils;
import codechicken.core.ServerUtils;
import codechicken.lib.inventory.InventoryRange;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.lib.packet.PacketCustom;
import codechicken.nei.util.NBTHelper;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.registry.GameRegistry;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -19,6 +11,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.zip.ZipException;
import net.minecraft.command.ICommandSender;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.player.EntityPlayer;
@@ -41,9 +34,20 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.WorldSettings.GameType;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.logging.log4j.Level;
import codechicken.core.CommonUtils;
import codechicken.core.ServerUtils;
import codechicken.lib.inventory.InventoryRange;
import codechicken.lib.inventory.InventoryUtils;
import codechicken.lib.packet.PacketCustom;
import codechicken.nei.util.NBTHelper;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.registry.GameRegistry;
public class NEIServerUtils {
public static boolean isRaining(World world) {
return world.getWorldInfo().isRaining();
}
@@ -51,7 +55,7 @@ public class NEIServerUtils {
public static void toggleRaining(World world, boolean notify) {
boolean raining = !world.isRaining();
if (!raining) // turn off
((WorldServer) world).provider.resetRainAndThunder();
((WorldServer) world).provider.resetRainAndThunder();
else world.getWorldInfo().setRaining(!isRaining(world));
if (notify)
@@ -114,17 +118,18 @@ public class NEIServerUtils {
}
public static void sendNotice(ICommandSender sender, IChatComponent msg, String permission) {
ChatComponentTranslation notice =
new ChatComponentTranslation("chat.type.admin", sender.getCommandSenderName(), msg.createCopy());
ChatComponentTranslation notice = new ChatComponentTranslation(
"chat.type.admin",
sender.getCommandSenderName(),
msg.createCopy());
notice.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true);
if (NEIServerConfig.canPlayerPerformAction("CONSOLE", permission))
MinecraftServer.getServer().addChatMessage(notice);
for (EntityPlayer p : ServerUtils.getPlayers())
if (p == sender) p.addChatComponentMessage(msg);
else if (NEIServerConfig.canPlayerPerformAction(p.getCommandSenderName(), permission))
p.addChatComponentMessage(notice);
for (EntityPlayer p : ServerUtils.getPlayers()) if (p == sender) p.addChatComponentMessage(msg);
else if (NEIServerConfig.canPlayerPerformAction(p.getCommandSenderName(), permission))
p.addChatComponentMessage(notice);
}
/**
@@ -133,8 +138,7 @@ public class NEIServerUtils {
* @return whether the two items are the same in terms of damage and itemID.
*/
public static boolean areStacksSameType(ItemStack stack1, ItemStack stack2) {
return stack1 != null
&& stack2 != null
return stack1 != null && stack2 != null
&& (stack1.getItem() == stack2.getItem()
&& (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage())
&& ItemStack.areItemStackTagsEqual(stack2, stack1));
@@ -142,28 +146,28 @@ public class NEIServerUtils {
/**
* NBT-friendly version of {@link #areStacksSameType(ItemStack, ItemStack)}
*
* @param stack1 The {@link ItemStack} being compared.
* @param stack2 The {@link ItemStack} to compare to.
* @return whether the two items are the same in terms of itemID, damage and NBT.
*/
public static boolean areStacksSameTypeWithNBT(ItemStack stack1, ItemStack stack2) {
return stack1 != null
&& stack2 != null
return stack1 != null && stack2 != null
&& stack1.getItem() == stack2.getItem()
&& (!stack2.getHasSubtypes() || stack2.getItemDamage() == stack1.getItemDamage())
&& NBTHelper.matchTag(stack1.getTagCompound(), stack2.getTagCompound());
}
/**
* {@link ItemStack}s with damage -1 are wildcards allowing all damages. Eg all colours of wool are allowed to create Beds.
* {@link ItemStack}s with damage -1 are wildcards allowing all damages. Eg all colours of wool are allowed to
* create Beds.
*
* @param stack1 The {@link ItemStack} being compared.
* @param stack2 The {@link ItemStack} to compare to.
* @return whether the two items are the same from the perspective of a crafting inventory.
*/
public static boolean areStacksSameTypeCrafting(ItemStack stack1, ItemStack stack2) {
return stack1 != null
&& stack2 != null
return stack1 != null && stack2 != null
&& stack1.getItem() == stack2.getItem()
&& (stack1.getItemDamage() == stack2.getItemDamage()
|| stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE
@@ -173,13 +177,13 @@ public class NEIServerUtils {
/**
* NBT-friendly version of {@link #areStacksSameTypeCrafting(ItemStack, ItemStack)}
*
* @param stack1 The {@link ItemStack} being compared.
* @param stack2 The {@link ItemStack} to compare to.
* @return whether the two items are the same from the perspective of a crafting inventory.
*/
public static boolean areStacksSameTypeCraftingWithNBT(ItemStack stack1, ItemStack stack2) {
return stack1 != null
&& stack2 != null
return stack1 != null && stack2 != null
&& stack1.getItem() == stack2.getItem()
&& (stack1.getItemDamage() == stack2.getItemDamage()
|| stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE
@@ -276,18 +280,16 @@ public class NEIServerUtils {
}
public static void setGamemode(EntityPlayerMP player, int mode) {
if (mode < 0
|| mode >= NEIActions.gameModes.length
|| NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode])
&& !NEIServerConfig.canPlayerPerformAction(
player.getCommandSenderName(), NEIActions.gameModes[mode])) return;
if (mode < 0 || mode >= NEIActions.gameModes.length
|| NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode]) && !NEIServerConfig
.canPlayerPerformAction(player.getCommandSenderName(), NEIActions.gameModes[mode]))
return;
// creative+
NEIServerConfig.forPlayer(player.getCommandSenderName()).enableAction("creative+", mode == 2);
if (mode == 2
&& !(player.openContainer
instanceof ContainerCreativeInv)) // open the container immediately for the client
NEISPH.processCreativeInv(player, true);
if (mode == 2 && !(player.openContainer instanceof ContainerCreativeInv)) // open the container immediately for
// the client
NEISPH.processCreativeInv(player, true);
// change it on the server
player.theItemInWorldManager.setGameType(getGameType(mode));
@@ -331,11 +333,10 @@ public class NEIServerUtils {
ArrayList<int[]> arraylist = new ArrayList<>();
if (itemstack != null) {
NBTTagList nbttaglist = itemstack.getEnchantmentTagList();
if (nbttaglist != null)
for (int i = 0; i < nbttaglist.tagCount(); i++) {
NBTTagCompound tag = nbttaglist.getCompoundTagAt(i);
arraylist.add(new int[] {tag.getShort("id"), tag.getShort("lvl")});
}
if (nbttaglist != null) for (int i = 0; i < nbttaglist.tagCount(); i++) {
NBTTagCompound tag = nbttaglist.getCompoundTagAt(i);
arraylist.add(new int[] { tag.getShort("id"), tag.getShort("lvl") });
}
}
return arraylist;
}
@@ -368,7 +369,7 @@ public class NEIServerUtils {
@SuppressWarnings("unchecked")
public static ItemStack[] extractRecipeItems(Object obj) {
if (obj instanceof ItemStack) return new ItemStack[] {(ItemStack) obj};
if (obj instanceof ItemStack) return new ItemStack[] { (ItemStack) obj };
if (obj instanceof ItemStack[]) return (ItemStack[]) obj;
if (obj instanceof List) return ((List<ItemStack>) obj).toArray(new ItemStack[0]);
@@ -377,6 +378,7 @@ public class NEIServerUtils {
public static List<Integer> getRange(final int start, final int end) {
return new AbstractList<Integer>() {
@Override
public Integer get(int index) {
return start + index;
@@ -1,9 +1,11 @@
package codechicken.nei;
import codechicken.nei.api.IStackPositioner;
import java.util.ArrayList;
import codechicken.nei.api.IStackPositioner;
public class OffsetPositioner implements IStackPositioner {
public OffsetPositioner(int x, int y) {
offsetx = x;
offsety = y;
+42 -33
View File
@@ -1,5 +1,10 @@
package codechicken.nei;
import java.util.ArrayList;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemPanel.ItemPanelSlot;
import codechicken.nei.api.GuiInfo;
@@ -8,11 +13,9 @@ import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.GuiUsageRecipe;
import java.util.ArrayList;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
public abstract class PanelWidget extends Widget {
protected static final int PADDING = 2;
public ItemStack draggedStack;
@@ -36,6 +39,7 @@ public abstract class PanelWidget extends Widget {
pageLabel = new Label("0/0", true);
pagePrev = new Button("Prev") {
public boolean onButtonPress(boolean rightclick) {
if (!rightclick) {
grid.shiftPage(-1);
@@ -50,6 +54,7 @@ public abstract class PanelWidget extends Widget {
}
};
pageNext = new Button("Next") {
public boolean onButtonPress(boolean rightclick) {
if (!rightclick) {
grid.shiftPage(1);
@@ -78,21 +83,24 @@ public abstract class PanelWidget extends Widget {
public abstract int getHeight(GuiContainer gui);
public void resize(GuiContainer gui) {
final Rectangle4i margin =
new Rectangle4i(getMarginLeft(gui), getMarginTop(gui), getWidth(gui), getHeight(gui));
final Rectangle4i margin = new Rectangle4i(
getMarginLeft(gui),
getMarginTop(gui),
getWidth(gui),
getHeight(gui));
final int minWidth = 5 * ItemsGrid.SLOT_SIZE;
final int minHeight = 9 * ItemsGrid.SLOT_SIZE;
final String settingName = getPositioningSettingName();
int paddingLeft = (int) Math.ceil(
margin.w * NEIClientConfig.getSetting(settingName + ".left").getIntValue() / 100000.0);
int paddingTop = (int) Math.ceil(
margin.h * NEIClientConfig.getSetting(settingName + ".top").getIntValue() / 100000.0);
int paddingRight = (int) Math.ceil(
margin.w * NEIClientConfig.getSetting(settingName + ".right").getIntValue() / 100000.0);
int paddingBottom = (int) Math.ceil(
margin.h * NEIClientConfig.getSetting(settingName + ".bottom").getIntValue() / 100000.0);
int paddingLeft = (int) Math
.ceil(margin.w * NEIClientConfig.getSetting(settingName + ".left").getIntValue() / 100000.0);
int paddingTop = (int) Math
.ceil(margin.h * NEIClientConfig.getSetting(settingName + ".top").getIntValue() / 100000.0);
int paddingRight = (int) Math
.ceil(margin.w * NEIClientConfig.getSetting(settingName + ".right").getIntValue() / 100000.0);
int paddingBottom = (int) Math
.ceil(margin.h * NEIClientConfig.getSetting(settingName + ".bottom").getIntValue() / 100000.0);
int deltaHeight = Math.min(0, margin.h - paddingTop - paddingBottom - minHeight) / 2;
@@ -118,20 +126,19 @@ public abstract class PanelWidget extends Widget {
int paddingLeft = 0;
int paddingRight = 0;
while (paddingLeft < w
&& GuiInfo.hideItemPanelSlot(
gui, new Rectangle4i(x + paddingLeft, y, ItemsGrid.SLOT_SIZE, ItemsGrid.SLOT_SIZE))) {
while (paddingLeft < w && GuiInfo.hideItemPanelSlot(
gui,
new Rectangle4i(x + paddingLeft, y, ItemsGrid.SLOT_SIZE, ItemsGrid.SLOT_SIZE))) {
paddingLeft += ItemsGrid.SLOT_SIZE;
}
while (paddingRight < w
&& GuiInfo.hideItemPanelSlot(
gui,
new Rectangle4i(
x + w - paddingRight - ItemsGrid.SLOT_SIZE,
y,
ItemsGrid.SLOT_SIZE,
ItemsGrid.SLOT_SIZE))) {
while (paddingRight < w && GuiInfo.hideItemPanelSlot(
gui,
new Rectangle4i(
x + w - paddingRight - ItemsGrid.SLOT_SIZE,
y,
ItemsGrid.SLOT_SIZE,
ItemsGrid.SLOT_SIZE))) {
paddingRight += ItemsGrid.SLOT_SIZE;
}
@@ -160,6 +167,7 @@ public abstract class PanelWidget extends Widget {
LayoutManager.addWidget(pagePrev);
LayoutManager.addWidget(pageNext);
LayoutManager.addWidget(pageLabel);
grid.setVisible();
}
}
@@ -179,11 +187,9 @@ public abstract class PanelWidget extends Widget {
@Override
public void mouseDragged(int mousex, int mousey, int button, long heldTime) {
if (mouseDownSlot >= 0
&& draggedStack == null
if (mouseDownSlot >= 0 && draggedStack == null
&& NEIClientUtils.getHeldItem() == null
&& NEIClientConfig.hasSMPCounterPart()
&& !GuiInfo.hasCustomSlots(NEIClientUtils.getGuiContainer())) {
&& NEIClientConfig.hasSMPCounterPart()) {
ItemPanelSlot mouseOverSlot = getSlotMouseOver(mousex, mousey);
if (mouseOverSlot == null || mouseOverSlot.slotIndex != mouseDownSlot || heldTime > 500) {
@@ -240,6 +246,13 @@ public abstract class PanelWidget extends Widget {
@Override
public boolean handleClickExt(int mouseX, int mouseY, int button) {
if (ItemPanels.itemPanel.draggedStack != null && ItemPanels.bookmarkPanel.contains(mouseX, mouseY)) {
ItemPanels.bookmarkPanel.addOrRemoveItem(ItemPanels.itemPanel.draggedStack, null, null, false, true);
ItemPanels.itemPanel.draggedStack = null;
return true;
}
if (ItemPanels.itemPanel.draggedStack != null) {
return ItemPanels.itemPanel.handleDraggedClick(mouseX, mouseY, button);
}
@@ -271,8 +284,7 @@ public abstract class PanelWidget extends Widget {
}
final GuiContainer gui = NEIClientUtils.getGuiContainer();
if (mouseX < gui.guiLeft
|| mouseY < gui.guiTop
if (mouseX < gui.guiLeft || mouseY < gui.guiTop
|| mouseX >= gui.guiLeft + gui.xSize
|| mouseY >= gui.guiTop + gui.ySize) {
draggedStack = null;
@@ -289,9 +301,6 @@ public abstract class PanelWidget extends Widget {
GuiInfo.readLock.lock();
for (INEIGuiHandler handler : GuiInfo.guiHandlers) {
if (handler.handleDragNDrop(gui, mouseX, mouseY, draggedStack, button)) {
NEIClientConfig.logger.info(handler);
handled = true;
break;
}
@@ -1,14 +1,17 @@
package codechicken.nei;
import codechicken.core.ServerUtils;
import codechicken.lib.inventory.InventoryUtils;
import java.io.File;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import codechicken.core.ServerUtils;
import codechicken.lib.inventory.InventoryUtils;
public class PlayerSave {
public String username;
private File saveFile;
@@ -2,10 +2,12 @@ package codechicken.nei;
import static codechicken.nei.NEIClientConfig.canPerformAction;
import codechicken.nei.guihook.IContainerInputHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import codechicken.nei.guihook.IContainerInputHandler;
public class PopupInputHandler implements IContainerInputHandler {
@Override
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) {
return false;
@@ -2,16 +2,17 @@ package codechicken.nei;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
/**
* Simply an {@link ItemStack} with position.
* Mainly used in the recipe handlers.
* Simply an {@link ItemStack} with position. Mainly used in the recipe handlers.
*/
public class PositionedStack {
public int relx;
public int rely;
public ItemStack[] items;
@@ -43,7 +44,11 @@ public class PositionedStack {
if (item.getItemDamage() == Short.MAX_VALUE) {
List<ItemStack> permutations = ItemList.itemMap.get(item.getItem());
if (!permutations.isEmpty()) {
for (ItemStack stack : permutations) stacks.add(stack.copy());
for (ItemStack stack : permutations) {
ItemStack toAdd = stack.copy();
toAdd.stackSize = item.stackSize;
stacks.add(toAdd);
}
} else {
ItemStack base = new ItemStack(item.getItem(), item.stackSize);
base.stackTagCompound = item.stackTagCompound;
@@ -56,7 +61,7 @@ public class PositionedStack {
}
items = stacks.toArray(new ItemStack[0]);
if (items.length == 0) items = new ItemStack[] {new ItemStack(Blocks.fire)};
if (items.length == 0) items = new ItemStack[] { new ItemStack(Blocks.fire) };
permutated = true;
setPermutationToRender(0);
@@ -73,9 +78,9 @@ public class PositionedStack {
public void setPermutationToRender(int index) {
item = items[index].copy();
if (item.getItem() == null) item = new ItemStack(Blocks.fire);
else if (item.getItemDamage() == OreDictionary.WILDCARD_VALUE
&& item.getItem() != null
&& item.getItem().isRepairable()) item.setItemDamage(0);
else if (item.getItemDamage() == OreDictionary.WILDCARD_VALUE && item.getItem() != null
&& item.getItem().isRepairable())
item.setItemDamage(0);
}
public boolean contains(ItemStack ingredient) {
@@ -2,20 +2,6 @@ package codechicken.nei;
import static codechicken.nei.NEIClientUtils.translate;
import codechicken.core.CommonUtils;
import codechicken.core.gui.GuiScrollSlot;
import codechicken.lib.gui.GuiDraw;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemPanel.ItemPanelSlot;
import codechicken.nei.api.ItemFilter;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.StackInfo;
import codechicken.nei.util.NBTJson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import cpw.mods.fml.common.registry.GameRegistry;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -27,15 +13,34 @@ import java.util.HashSet;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.ItemStack;
import org.apache.commons.io.IOUtils;
import org.lwjgl.input.Keyboard;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException;
import codechicken.core.CommonUtils;
import codechicken.core.gui.GuiScrollSlot;
import codechicken.lib.gui.GuiDraw;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemPanel.ItemPanelSlot;
import codechicken.nei.api.ItemFilter;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.StackInfo;
import codechicken.nei.util.NBTJson;
import cpw.mods.fml.common.registry.GameRegistry;
public class PresetsWidget extends Widget {
public static class PresetTag implements ItemFilter {
public String filename = null;
public String displayName = "";
public boolean whitelist = true;
@@ -77,8 +82,7 @@ public class PresetsWidget extends Widget {
}
final JsonParser parser = new JsonParser();
final JsonObject metaObject =
parser.parse(itemStrings.remove(0)).getAsJsonObject();
final JsonObject metaObject = parser.parse(itemStrings.remove(0)).getAsJsonObject();
final String displayName = metaObject.get("displayName").getAsString();
final boolean whitelist = metaObject.get("whitelist").getAsBoolean();
final HashSet<String> items = new HashSet<>();
@@ -149,6 +153,7 @@ public class PresetsWidget extends Widget {
}
protected static class SubsetListBox extends GuiScrollSlot {
protected final List<PresetTag> presets = new ArrayList<>();
protected final List<PresetTag> selected = new ArrayList<>();
protected int lastSelectedIndex = 0;
@@ -159,12 +164,12 @@ public class PresetsWidget extends Widget {
try {
presets.addAll(ItemList.forkJoinPool
.submit(() -> Arrays.asList(presetsDir.listFiles()).parallelStream()
.map(f -> PresetTag.loadFromFile(f))
.filter(p -> p != null)
.collect(Collectors.toCollection(ArrayList::new)))
.get());
presets.addAll(
ItemList.forkJoinPool.submit(
() -> Arrays.asList(presetsDir.listFiles()).parallelStream()
.map(f -> PresetTag.loadFromFile(f)).filter(p -> p != null)
.collect(Collectors.toCollection(ArrayList::new)))
.get());
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
@@ -312,9 +317,10 @@ public class PresetsWidget extends Widget {
final int directionState = direction.contains(x + mx, y + my) ? 1 : 2;
final int deleteState = delete.contains(x + mx, y + my) ? 1 : 2;
final String displayName = NEIClientUtils.cropText(fontRenderer, tag.displayName, option.w - 6);
final String dirName =
tag.whitelist ? translate("presets.whitelist.label") : translate("presets.blacklist.label");
final String displayName = NEIClientUtils
.cropText(PresetsWidget.fontRenderer, tag.displayName, option.w - 6);
final String dirName = tag.whitelist ? translate("presets.whitelist.label")
: translate("presets.blacklist.label");
// blacklist or whitelist
LayoutManager.getLayoutStyle()
@@ -407,6 +413,7 @@ public class PresetsWidget extends Widget {
}
protected static class MouseSelection {
public int startX = -1;
public int startY = -1;
public int startIndex = -1;
@@ -519,8 +526,7 @@ public class PresetsWidget extends Widget {
@Override
public String getRenderLabel() {
return edit != null && edit.whitelist
? translate("presets.whitelist.label")
return edit != null && edit.whitelist ? translate("presets.whitelist.label")
: translate("presets.blacklist.label");
}
@@ -528,8 +534,7 @@ public class PresetsWidget extends Widget {
public void addTooltips(List<String> tooltip) {
if (edit != null) {
tooltip.add(
edit.whitelist
? translate("presets.whitelist.tooltip")
edit.whitelist ? translate("presets.whitelist.tooltip")
: translate("presets.blacklist.tooltip"));
}
}
@@ -626,8 +631,7 @@ public class PresetsWidget extends Widget {
protected static String getModId(final ItemStack stack) {
try {
return GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId;
} catch (Exception ignored) {
}
} catch (Exception ignored) {}
return null;
}
@@ -673,8 +677,7 @@ public class PresetsWidget extends Widget {
final List<PresetTag> selected = listbox.getSelected();
final int size = selected.size();
selectedValue.text = size > 1
? translate("presets.label.selected", size)
selectedValue.text = size > 1 ? translate("presets.label.selected", size)
: (size == 1 ? selected.get(0).displayName : "");
selectedValue.y = y;
selectedValue.h = h;
@@ -781,8 +784,7 @@ public class PresetsWidget extends Widget {
return false;
}
if (selectedDisplayName.focused()
&& (keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_NUMPADENTER)
if (selectedDisplayName.focused() && (keyID == Keyboard.KEY_RETURN || keyID == Keyboard.KEY_NUMPADENTER)
&& !selectedDisplayName.text().isEmpty()) {
selectedDisplayName.handleKeyPress(keyID, keyChar);
selectedDisplayName.setFocus(false);
@@ -1,6 +1,7 @@
package codechicken.nei;
public abstract class RestartableTask {
public final String name;
private Thread thread;
private volatile boolean restart;
@@ -14,14 +15,13 @@ public abstract class RestartableTask {
private void start() {
thread = new Thread(name) {
@Override
public void run() {
do {
while (stopped)
try {
Thread.sleep(1);
} catch (InterruptedException ignored) {
}
while (stopped) try {
Thread.sleep(1);
} catch (InterruptedException ignored) {}
if (!restart) execute();
} while (!finish());
}
@@ -52,7 +52,8 @@ public abstract class RestartableTask {
}
/**
* Stops execution until restart is called. If a thread is running, the restart flag will be set, and the thread will be paused once the execute method exits.
* Stops execution until restart is called. If a thread is running, the restart flag will be set, and the thread
* will be paused once the execute method exits.
*/
public synchronized void stop() {
if (thread != null) {
+40 -7
View File
@@ -2,6 +2,13 @@ package codechicken.nei;
import static codechicken.nei.NEIClientConfig.world;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import net.minecraft.util.EnumChatFormatting;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.ItemList.AnyMultiItemFilter;
import codechicken.nei.ItemList.EverythingItemFilter;
@@ -9,17 +16,15 @@ import codechicken.nei.ItemList.PatternItemFilter;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemFilter;
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import net.minecraft.util.EnumChatFormatting;
import codechicken.nei.util.TextHistory;
public class SearchField extends TextField implements ItemFilterProvider {
/**
* Interface for returning a custom filter based on search field text
*/
public static interface ISearchProvider {
/**
* @return false if this filter should only be used if no other non-default filters match the search string
*/
@@ -32,6 +37,7 @@ public class SearchField extends TextField implements ItemFilterProvider {
}
private static class DefaultSearchProvider implements ISearchProvider {
@Override
public boolean isPrimary() {
return false;
@@ -45,6 +51,7 @@ public class SearchField extends TextField implements ItemFilterProvider {
}
public static List<ISearchProvider> searchProviders = new LinkedList<>();
private static final TextHistory history = new TextHistory();
private boolean isVisible = true;
long lastclicktime;
@@ -116,6 +123,13 @@ public class SearchField extends TextField implements ItemFilterProvider {
if (isVisible() && NEIClientConfig.isKeyHashDown("gui.search")) {
setFocus(true);
}
if (NEIClientConfig.isKeyHashDown("gui.getprevioussearch") && focused()) {
handleNavigateHistory(TextHistory.Direction.PREVIOUS);
}
if (NEIClientConfig.isKeyHashDown("gui.getnextsearch") && focused()) {
handleNavigateHistory(TextHistory.Direction.NEXT);
}
}
@Override
@@ -136,8 +150,7 @@ public class SearchField extends TextField implements ItemFilterProvider {
Pattern pattern = null;
try {
pattern = Pattern.compile(search);
} catch (PatternSyntaxException ignored) {
}
} catch (PatternSyntaxException ignored) {}
return pattern == null || pattern.toString().length() == 0 ? null : pattern;
}
@@ -156,4 +169,24 @@ public class SearchField extends TextField implements ItemFilterProvider {
if (!secondary.isEmpty()) return new AnyMultiItemFilter(secondary);
return new EverythingItemFilter();
}
@Override
public void setFocus(boolean focus) {
final boolean previousFocus = field.isFocused();
if (previousFocus != focus) {
history.add(text());
}
super.setFocus(focus);
}
private boolean handleNavigateHistory(TextHistory.Direction direction) {
if (focused()) {
return history.get(direction, text()).map(newText -> {
setText(newText);
return true;
}).orElse(false);
}
return false;
}
}
@@ -1,5 +1,13 @@
package codechicken.nei;
import java.util.List;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import codechicken.core.CommonUtils;
import codechicken.lib.packet.PacketCustom;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -10,14 +18,9 @@ import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import java.util.List;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
public class ServerHandler {
private static ServerHandler instance;
public static void load() {
@@ -32,11 +35,10 @@ public class ServerHandler {
@SubscribeEvent
public void tickEvent(TickEvent.WorldTickEvent event) {
if (event.phase == Phase.START
&& !event.world.isRemote
&& NEIServerConfig.dimTags.containsKey(
CommonUtils.getDimension(event.world))) // fake worlds that don't call Load
processDisabledProperties(event.world);
if (event.phase == Phase.START && !event.world.isRemote
&& NEIServerConfig.dimTags.containsKey(CommonUtils.getDimension(event.world))) // fake worlds that don't
// call Load
processDisabledProperties(event.world);
}
@SubscribeEvent
@@ -72,8 +74,8 @@ public class ServerHandler {
double maxspeedy = 0.5;
double speedxz = 0.05;
double speedy = 0.07;
List<EntityItem> items = player.worldObj.getEntitiesWithinAABB(
EntityItem.class, player.boundingBox.expand(distancexz, distancey, distancexz));
List<EntityItem> items = player.worldObj
.getEntitiesWithinAABB(EntityItem.class, player.boundingBox.expand(distancexz, distancey, distancexz));
for (EntityItem item : items) {
if (item.delayBeforeCanPickup > 0) continue;
if (!NEIServerUtils.canItemFitInInventory(player, item.getEntityItem())) continue;
@@ -1,6 +1,7 @@
package codechicken.nei;
public abstract class SlotOP {
public abstract String getDescription();
public abstract int[] getKeyBind();
@@ -1,7 +1,5 @@
package codechicken.nei;
import codechicken.core.ClientUtils;
import codechicken.lib.render.CCRenderState;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
@@ -13,10 +11,15 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import codechicken.core.ClientUtils;
import codechicken.lib.render.CCRenderState;
public class SpawnerRenderer implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return true;
+24 -19
View File
@@ -2,18 +2,6 @@ package codechicken.nei;
import static codechicken.nei.NEIClientUtils.translate;
import codechicken.core.gui.GuiScrollSlot;
import codechicken.lib.gui.GuiDraw;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemList.AnyMultiItemFilter;
import codechicken.nei.ItemList.ItemsLoadedCallback;
import codechicken.nei.ItemList.NothingItemFilter;
import codechicken.nei.SearchField.ISearchProvider;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemFilter;
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.guihook.GuiContainerManager;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Collections;
@@ -27,24 +15,42 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Pattern;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
import codechicken.core.gui.GuiScrollSlot;
import codechicken.lib.gui.GuiDraw;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemList.AnyMultiItemFilter;
import codechicken.nei.ItemList.ItemsLoadedCallback;
import codechicken.nei.ItemList.NothingItemFilter;
import codechicken.nei.SearchField.ISearchProvider;
import codechicken.nei.api.API;
import codechicken.nei.api.ItemFilter;
import codechicken.nei.api.ItemFilter.ItemFilterProvider;
import codechicken.nei.api.ItemInfo;
import codechicken.nei.guihook.GuiContainerManager;
public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoadedCallback, ISearchProvider {
public static ReentrantReadWriteLock hiddenItemLock = new ReentrantReadWriteLock();
public static Lock writeLock = hiddenItemLock.writeLock();
public static Lock readLock = hiddenItemLock.readLock();
public static class SubsetState {
int state = 2;
ArrayList<ItemStack> items = new ArrayList<>();
}
public static class SubsetTag {
protected class SubsetSlot extends GuiScrollSlot {
public SubsetSlot() {
super(0, 0, 0, 0);
setSmoothScroll(false);
@@ -190,10 +196,9 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
} else {
String childname = name.substring(0, idx);
SubsetTag child = children.get(childname.toLowerCase());
if (child == null)
children.put(
childname.toLowerCase(),
child = new SubsetTag(fullname == null ? childname : fullname + '.' + childname));
if (child == null) children.put(
childname.toLowerCase(),
child = new SubsetTag(fullname == null ? childname : fullname + '.' + childname));
recacheChildren();
child.addTag(tag);
}
@@ -533,6 +538,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
}
private static final RestartableTask prepareDirtyHiddenItems = new RestartableTask("NEI Subset Save Thread") {
private List<ItemStack> getList() {
try {
if (readLock.tryLock(5, TimeUnit.SECONDS)) {
@@ -566,6 +572,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
private static final UpdateStateTask updateState = new UpdateStateTask();
private static class UpdateStateTask extends RestartableTask {
private volatile boolean reallocate;
public UpdateStateTask() {
@@ -599,9 +606,7 @@ public class SubsetWidget extends Button implements ItemFilterProvider, ItemsLoa
for (ItemStack item : ItemList.items) {
if (interrupted()) return;
if (ItemInfo.isHidden(item)) continue;
for (SubsetTag tag : tags)
if (tag.filter.matches(item))
state.get(tag.fullname).items.add(item);
for (SubsetTag tag : tags) if (tag.filter.matches(item)) state.get(tag.fullname).items.add(item);
}
}
+3 -1
View File
@@ -2,9 +2,11 @@ package codechicken.nei;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiTextField;
import org.lwjgl.input.Keyboard;
public abstract class TextField extends Widget {
protected GuiTextField field;
private static final int maxSearchLength = 256;
@@ -23,7 +25,7 @@ public abstract class TextField extends Widget {
public TextField(String ident) {
identifier = ident;
initInternalTextField();
// Keyboard.enableRepeatEvents(true);
// Keyboard.enableRepeatEvents(true);
}
public int getTextColour() {
@@ -1,11 +1,14 @@
package codechicken.nei;
import com.google.common.base.Objects;
import cpw.mods.fml.common.FMLCommonHandler;
public class ThreadOperationTimer extends Thread {
@SuppressWarnings("serial")
public static class TimeoutException extends RuntimeException {
public final Object operation;
public TimeoutException(String msg, Object op) {
@@ -48,10 +51,13 @@ public class ThreadOperationTimer extends Thread {
@SuppressWarnings("deprecation")
@Override
public void run() {
if (FMLCommonHandler.instance()
.findContainerFor("NotEnoughItems")
.getVersion()
.contains("$")) return; // don't run this thread in a source environment
if (FMLCommonHandler.instance().findContainerFor("NotEnoughItems").getVersion().contains("$")) return; // don't
// run
// this
// thread
// in a
// source
// environment
while (thread.isAlive()) {
synchronized (this) {
@@ -63,8 +69,7 @@ public class ThreadOperationTimer extends Thread {
}
try {
Thread.sleep(50);
} catch (InterruptedException ie) {
}
} catch (InterruptedException ie) {}
}
}
@@ -1,6 +1,7 @@
package codechicken.nei;
public class VisiblityData {
public boolean showUtilityButtons = true;
/**
* Item panel and associated buttons
+4 -1
View File
@@ -1,10 +1,13 @@
package codechicken.nei;
import codechicken.lib.vec.Rectangle4i;
import java.util.List;
import net.minecraft.item.ItemStack;
import codechicken.lib.vec.Rectangle4i;
public abstract class Widget {
public Widget() {}
public abstract void draw(int mx, int my);
@@ -3,6 +3,7 @@ package codechicken.nei;
import java.util.Comparator;
public class WidgetZOrder implements Comparator<Widget> {
final boolean topfirst;
public WidgetZOrder(boolean topfirst) {
@@ -1,9 +1,7 @@
package codechicken.nei;
import codechicken.lib.math.MathHelper;
import codechicken.lib.render.RenderUtils;
import codechicken.nei.KeyManager.IKeyStateTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.passive.EntityPig;
@@ -13,8 +11,12 @@ import net.minecraft.world.SpawnerAnimals;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import org.lwjgl.opengl.GL11;
import codechicken.lib.math.MathHelper;
import codechicken.nei.KeyManager.IKeyStateTracker;
public class WorldOverlayRenderer implements IKeyStateTracker {
public static int chunkOverlay = 0;
@@ -40,10 +42,19 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
public static void render(float frame) {
GL11.glPushMatrix();
Entity entity = Minecraft.getMinecraft().renderViewEntity;
RenderUtils.translateToWorldCoords(entity, frame);
renderChunkBounds(entity);
renderMobSpawnOverlay(entity);
double interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame;
double interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame;
double interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame;
int intOffsetX = (int) interpPosX;
int intOffsetY = (int) interpPosY;
int intOffsetZ = (int) interpPosZ;
GL11.glTranslated(-interpPosX + intOffsetX, -interpPosY + intOffsetY, -interpPosZ + intOffsetZ);
renderChunkBounds(entity, intOffsetX, intOffsetY, intOffsetZ);
renderMobSpawnOverlay(entity, intOffsetX, intOffsetY, intOffsetZ);
GL11.glPopMatrix();
}
@@ -84,7 +95,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
}
}
private static void renderMobSpawnOverlay(Entity entity) {
private static void renderMobSpawnOverlay(Entity entity, int intOffsetX, int intOffsetY, int intOffsetZ) {
if (mobOverlay == 0) {
if (mobSpawnCache != null) {
mobSpawnCache = null;
@@ -103,15 +114,17 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glLineWidth(1.5F);
GL11.glBegin(GL11.GL_LINES);
GL11.glColor4f(1, 0, 0, 1);
int curSpawnMode = 2;
World world = entity.worldObj;
int x1 = (int) entity.posX;
int z1 = (int) entity.posZ;
int y1 = (int) MathHelper.clip(entity.posY, 16, world.getHeight() - 16);
int x1 = (int) entity.posX - intOffsetX;
int z1 = (int) entity.posZ - intOffsetZ;
int y1 = (int) MathHelper.clip(entity.posY, 16, world.getHeight() - 16) - intOffsetY;
final Tessellator tess = Tessellator.instance;
tess.startDrawing(GL11.GL_LINES);
tess.setColorOpaque(255, 0, 0);
for (int i = 0; i <= 32; i++) {
int x = x1 - 16 + i;
@@ -130,22 +143,22 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
if (spawnMode != curSpawnMode) {
if (spawnMode == 1) {
GL11.glColor4f(1, 1, 0, 1);
tess.setColorOpaque(255, 255, 0);
} else {
GL11.glColor4f(1, 0, 0, 1);
tess.setColorOpaque(255, 0, 0);
}
curSpawnMode = spawnMode;
}
GL11.glVertex3d(x, y + 0.02, z);
GL11.glVertex3d(x + 1, y + 0.02, z + 1);
GL11.glVertex3d(x + 1, y + 0.02, z);
GL11.glVertex3d(x, y + 0.02, z + 1);
tess.addVertex(x, y + 0.02, z);
tess.addVertex(x + 1, y + 0.02, z + 1);
tess.addVertex(x + 1, y + 0.02, z);
tess.addVertex(x, y + 0.02, z + 1);
}
}
}
GL11.glEnd();
tess.draw();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
@@ -155,8 +168,8 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
private static final AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
private static byte getSpawnMode(Chunk chunk, int x, int y, int z) {
if (!SpawnerAnimals.canCreatureTypeSpawnAtLocation(EnumCreatureType.monster, chunk.worldObj, x, y, z)
|| chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15) >= 8) {
if (chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15) >= 8
|| !SpawnerAnimals.canCreatureTypeSpawnAtLocation(EnumCreatureType.monster, chunk.worldObj, x, y, z)) {
return 0;
}
@@ -174,7 +187,7 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
return (byte) (chunk.getSavedLightValue(EnumSkyBlock.Sky, x & 15, y, z & 15) >= 8 ? 1 : 2);
}
private static void renderChunkBounds(Entity entity) {
private static void renderChunkBounds(Entity entity, int intOffsetX, int intOffsetY, int intOffsetZ) {
if (chunkOverlay == 0) return;
GL11.glDisable(GL11.GL_TEXTURE_2D);
@@ -184,136 +197,143 @@ public class WorldOverlayRenderer implements IKeyStateTracker {
GL11.glLineWidth(1.5F);
GL11.glBegin(GL11.GL_LINES);
for (int cx = -4; cx <= 4; cx++)
for (int cz = -4; cz <= 4; cz++) {
double x1 = (entity.chunkCoordX + cx) << 4;
double z1 = (entity.chunkCoordZ + cz) << 4;
double x2 = x1 + 16;
double z2 = z1 + 16;
for (int cx = -4; cx <= 4; cx++) for (int cz = -4; cz <= 4; cz++) {
double x1 = ((entity.chunkCoordX + cx) << 4) - intOffsetX;
double z1 = ((entity.chunkCoordZ + cz) << 4) - intOffsetZ;
double x2 = x1 + 16;
double z2 = z1 + 16;
double dy = 128;
double y1 = Math.floor(entity.posY - dy / 2);
double y2 = y1 + dy;
if (y1 < 0) {
y1 = 0;
y2 = dy;
}
double dy = 128;
double y1 = Math.floor(entity.posY - dy / 2);
double y2 = y1 + dy;
if (y1 < 0) {
y1 = 0;
y2 = dy;
}
if (y1 > entity.worldObj.getHeight()) {
y2 = entity.worldObj.getHeight();
y1 = y2 - dy;
}
if (y1 > entity.worldObj.getHeight()) {
y2 = entity.worldObj.getHeight();
y1 = y2 - dy;
}
double dist = Math.pow(1.5, -(cx * cx + cz * cz));
y1 -= intOffsetY;
y2 -= intOffsetY;
GL11.glColor4d(0.9, 0, 0, dist);
if (cx >= 0 && cz >= 0) {
GL11.glVertex3d(x2, y1, z2);
GL11.glVertex3d(x2, y2, z2);
}
if (cx >= 0 && cz <= 0) {
GL11.glVertex3d(x2, y1, z1);
GL11.glVertex3d(x2, y2, z1);
}
if (cx <= 0 && cz >= 0) {
GL11.glVertex3d(x1, y1, z2);
GL11.glVertex3d(x1, y2, z2);
}
if (cx <= 0 && cz <= 0) {
GL11.glVertex3d(x1, y1, z1);
GL11.glVertex3d(x1, y2, z1);
}
double dist = Math.pow(1.5, -(cx * cx + cz * cz));
if (cx == 0 && cz == 0) {
if (chunkOverlay == 2) {
dy = 32;
y1 = Math.floor(entity.posY - dy / 2);
y2 = y1 + dy;
if (y1 < 0) {
y1 = 0;
y2 = dy;
}
GL11.glColor4d(0.9, 0, 0, dist);
if (cx >= 0 && cz >= 0) {
GL11.glVertex3d(x2, y1, z2);
GL11.glVertex3d(x2, y2, z2);
}
if (cx >= 0 && cz <= 0) {
GL11.glVertex3d(x2, y1, z1);
GL11.glVertex3d(x2, y2, z1);
}
if (cx <= 0 && cz >= 0) {
GL11.glVertex3d(x1, y1, z2);
GL11.glVertex3d(x1, y2, z2);
}
if (cx <= 0 && cz <= 0) {
GL11.glVertex3d(x1, y1, z1);
GL11.glVertex3d(x1, y2, z1);
}
if (y1 > entity.worldObj.getHeight()) {
y2 = entity.worldObj.getHeight();
y1 = y2 - dy;
}
GL11.glColor4d(0, 0.9, 0, 0.4);
for (double y = (int) y1; y <= y2; y++) {
GL11.glVertex3d(x2, y, z1);
GL11.glVertex3d(x2, y, z2);
GL11.glVertex3d(x1, y, z1);
GL11.glVertex3d(x1, y, z2);
GL11.glVertex3d(x1, y, z2);
GL11.glVertex3d(x2, y, z2);
GL11.glVertex3d(x1, y, z1);
GL11.glVertex3d(x2, y, z1);
}
for (double h = 1; h <= 15; h++) {
GL11.glVertex3d(x1 + h, y1, z1);
GL11.glVertex3d(x1 + h, y2, z1);
GL11.glVertex3d(x1 + h, y1, z2);
GL11.glVertex3d(x1 + h, y2, z2);
GL11.glVertex3d(x1, y1, z1 + h);
GL11.glVertex3d(x1, y2, z1 + h);
GL11.glVertex3d(x2, y1, z1 + h);
GL11.glVertex3d(x2, y2, z1 + h);
}
} else if (chunkOverlay == 3) {
int gx1 = ((entity.chunkCoordX < 0 ? entity.chunkCoordX - 3 : entity.chunkCoordX) / 3 * 3) << 4;
int gz1 = ((entity.chunkCoordZ < 0 ? entity.chunkCoordZ - 3 : entity.chunkCoordZ) / 3 * 3) << 4;
if (entity.chunkCoordX < 0) {
gx1 += 16;
}
if (entity.chunkCoordZ < 0) {
gz1 += 16;
}
int gx2 = gx1 + 48;
int gz2 = gz1 + 48;
GL11.glColor4d(0, 0.9, 0, 0.4);
for (double y = (int) y1; y <= y2; y++) {
GL11.glVertex3d(gx2, y, gz1);
GL11.glVertex3d(gx2, y, gz2);
GL11.glVertex3d(gx1, y, gz1);
GL11.glVertex3d(gx1, y, gz2);
GL11.glVertex3d(gx1, y, gz2);
GL11.glVertex3d(gx2, y, gz2);
GL11.glVertex3d(gx1, y, gz1);
GL11.glVertex3d(gx2, y, gz1);
}
for (double h = 4; h <= 44; h += 4) {
if (h % 16 == 0) {
continue;
}
GL11.glVertex3d(gx1 + h, y1, gz1);
GL11.glVertex3d(gx1 + h, y2, gz1);
GL11.glVertex3d(gx1 + h, y1, gz2);
GL11.glVertex3d(gx1 + h, y2, gz2);
GL11.glVertex3d(gx1, y1, gz1 + h);
GL11.glVertex3d(gx1, y2, gz1 + h);
GL11.glVertex3d(gx2, y1, gz1 + h);
GL11.glVertex3d(gx2, y2, gz1 + h);
}
GL11.glColor4d(0, 0, 0.9, 0.4);
gx1 += 23;
gz1 += 23;
gx2 = gx1 + 1;
gz2 = gz1 + 1;
GL11.glVertex3d(gx1, y1, gz1);
GL11.glVertex3d(gx1, y2, gz1);
GL11.glVertex3d(gx2, y1, gz1);
GL11.glVertex3d(gx2, y2, gz1);
GL11.glVertex3d(gx1, y1, gz2);
GL11.glVertex3d(gx1, y2, gz2);
GL11.glVertex3d(gx2, y1, gz2);
GL11.glVertex3d(gx2, y2, gz2);
if (cx == 0 && cz == 0) {
if (chunkOverlay == 2) {
dy = 32;
y1 = Math.floor(entity.posY - dy / 2);
y2 = y1 + dy;
if (y1 < 0) {
y1 = 0;
y2 = dy;
}
if (y1 > entity.worldObj.getHeight()) {
y2 = entity.worldObj.getHeight();
y1 = y2 - dy;
}
y1 -= intOffsetY;
y2 -= intOffsetY;
GL11.glColor4d(0, 0.9, 0, 0.4);
for (double y = (int) y1; y <= y2; y++) {
GL11.glVertex3d(x2, y, z1);
GL11.glVertex3d(x2, y, z2);
GL11.glVertex3d(x1, y, z1);
GL11.glVertex3d(x1, y, z2);
GL11.glVertex3d(x1, y, z2);
GL11.glVertex3d(x2, y, z2);
GL11.glVertex3d(x1, y, z1);
GL11.glVertex3d(x2, y, z1);
}
for (double h = 1; h <= 15; h++) {
GL11.glVertex3d(x1 + h, y1, z1);
GL11.glVertex3d(x1 + h, y2, z1);
GL11.glVertex3d(x1 + h, y1, z2);
GL11.glVertex3d(x1 + h, y2, z2);
GL11.glVertex3d(x1, y1, z1 + h);
GL11.glVertex3d(x1, y2, z1 + h);
GL11.glVertex3d(x2, y1, z1 + h);
GL11.glVertex3d(x2, y2, z1 + h);
}
} else if (chunkOverlay == 3) {
int gx1 = (((entity.chunkCoordX < 0 ? entity.chunkCoordX - 3 : entity.chunkCoordX) / 3 * 3) << 4)
- intOffsetX;
int gz1 = (((entity.chunkCoordZ < 0 ? entity.chunkCoordZ - 3 : entity.chunkCoordZ) / 3 * 3) << 4)
- intOffsetZ;
if (entity.chunkCoordX < 0) {
gx1 += 16;
}
if (entity.chunkCoordZ < 0) {
gz1 += 16;
}
int gx2 = gx1 + 48;
int gz2 = gz1 + 48;
GL11.glColor4d(0, 0.9, 0, 0.4);
for (double y = (int) y1; y <= y2; y++) {
GL11.glVertex3d(gx2, y, gz1);
GL11.glVertex3d(gx2, y, gz2);
GL11.glVertex3d(gx1, y, gz1);
GL11.glVertex3d(gx1, y, gz2);
GL11.glVertex3d(gx1, y, gz2);
GL11.glVertex3d(gx2, y, gz2);
GL11.glVertex3d(gx1, y, gz1);
GL11.glVertex3d(gx2, y, gz1);
}
for (double h = 4; h <= 44; h += 4) {
if (h % 16 == 0) {
continue;
}
GL11.glVertex3d(gx1 + h, y1, gz1);
GL11.glVertex3d(gx1 + h, y2, gz1);
GL11.glVertex3d(gx1 + h, y1, gz2);
GL11.glVertex3d(gx1 + h, y2, gz2);
GL11.glVertex3d(gx1, y1, gz1 + h);
GL11.glVertex3d(gx1, y2, gz1 + h);
GL11.glVertex3d(gx2, y1, gz1 + h);
GL11.glVertex3d(gx2, y2, gz1 + h);
}
GL11.glColor4d(0, 0, 0.9, 0.4);
gx1 += 23;
gz1 += 23;
gx2 = gx1 + 1;
gz2 = gz1 + 1;
GL11.glVertex3d(gx1, y1, gz1);
GL11.glVertex3d(gx1, y2, gz1);
GL11.glVertex3d(gx2, y1, gz1);
GL11.glVertex3d(gx2, y2, gz1);
GL11.glVertex3d(gx1, y1, gz2);
GL11.glVertex3d(gx1, y2, gz2);
GL11.glVertex3d(gx2, y1, gz2);
GL11.glVertex3d(gx2, y2, gz2);
}
}
}
GL11.glEnd();
GL11.glEnable(GL11.GL_LIGHTING);
+91 -49
View File
@@ -1,5 +1,19 @@
package codechicken.nei.api;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import com.google.common.collect.Sets;
import codechicken.nei.ItemList;
import codechicken.nei.ItemSorter;
import codechicken.nei.ItemStackSet;
@@ -24,22 +38,13 @@ import codechicken.nei.recipe.IUsageHandler;
import codechicken.nei.recipe.RecipeCatalysts;
import codechicken.nei.recipe.RecipeInfo;
import codechicken.nei.recipe.StackInfo;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
/**
* This is the main class that handles item property configuration.
* WARNING: DO NOT access this class until the world has been loaded
* These methods should be called from INEIConfig implementors
* This is the main class that handles item property configuration. WARNING: DO NOT access this class until the world
* has been loaded These methods should be called from INEIConfig implementors
*/
public class API {
/**
* Register a new Crafting Recipe handler;
*
@@ -62,8 +67,7 @@ public class API {
* Add a gui to the default overlay renderer with the default position
*
* @param classz The class of your gui
* @param ident The identification string, currently
* {crafting, crafting2x2, smelting, fuel, brewing}
* @param ident The identification string, currently {crafting, crafting2x2, smelting, fuel, brewing}
*/
public static void registerGuiOverlay(Class<? extends GuiContainer> classz, String ident) {
registerGuiOverlay(classz, ident, 5, 11);
@@ -73,8 +77,7 @@ public class API {
* Add a gui to the default overlay renderer with an offset
*
* @param classz The class of your gui
* @param ident The identification string, currently
* {crafting, crafting2x2, smelting, fuel, brewing}
* @param ident The identification string, currently {crafting, crafting2x2, smelting, fuel, brewing}
* @param x x-offset
* @param y y-offset
*/
@@ -86,12 +89,11 @@ public class API {
* Add a gui to the default overlay renderer
*
* @param classz The class of your gui
* @param ident The identification string, currently
* {crafting, crafting2x2, smelting, fuel, brewing}
* @param ident The identification string, currently {crafting, crafting2x2, smelting, fuel, brewing}
* @param positioner A Stack Repositioner for moving the items to the right place
*/
public static void registerGuiOverlay(
Class<? extends GuiContainer> classz, String ident, IStackPositioner positioner) {
public static void registerGuiOverlay(Class<? extends GuiContainer> classz, String ident,
IStackPositioner positioner) {
RecipeInfo.registerGuiOverlay(classz, ident, positioner);
}
@@ -100,13 +102,22 @@ public class API {
* @param handler The handler to register
* @param ident The recipe identification string
*/
public static void registerGuiOverlayHandler(
Class<? extends GuiContainer> classz, IOverlayHandler handler, String ident) {
public static void registerGuiOverlayHandler(Class<? extends GuiContainer> classz, IOverlayHandler handler,
String ident) {
RecipeInfo.registerOverlayHandler(classz, handler, ident);
}
/**
* Set the offset to be added to items to translate them into recipe coords on the actual gui, default is 5, 11. Primarily RecipeTransferRects
* @param classz The class of your gui
* @param ident The recipe identification string
*/
public static boolean hasGuiOverlayHandler(Class<? extends GuiContainer> classz, String ident) {
return RecipeInfo.hasOverlayHandler(classz, ident);
}
/**
* Set the offset to be added to items to translate them into recipe coords on the actual gui, default is 5, 11.
* Primarily RecipeTransferRects
*
* @param classz The class of your gui
* @param x
@@ -126,29 +137,36 @@ public class API {
}
/**
* Hide an item from the item panel
* Damage values of OreDictionary.WILDCARD_VALUE and ItemStackMap.WILDCARD_TAG tags function as wildcards for their respective variables
* Hide an item from the item panel Damage values of OreDictionary.WILDCARD_VALUE and ItemStackMap.WILDCARD_TAG tags
* function as wildcards for their respective variables
*/
public static void hideItem(ItemStack item) {
ItemInfo.hiddenItems.add(item);
LayoutManager.markItemsDirty();
if (!ItemInfo.hiddenItems.contains(item)) {
ItemInfo.hiddenItems.add(item);
LayoutManager.markItemsDirty();
}
}
/**
* Add or replace the name normally shown on the item tooltip
*/
public static void setOverrideName(ItemStack item, String name) {
ItemInfo.nameOverrides.put(item, name);
LayoutManager.markItemsDirty();
if (!name.equals(ItemInfo.nameOverrides.get(item))) {
ItemInfo.nameOverrides.put(item, name);
LayoutManager.markItemsDirty();
}
}
/**
* Adds an item to the item panel. Any items added using this function will override the default search pattern.
*
* @param item an item with data
*/
public static void addItemListEntry(ItemStack item) {
ItemInfo.itemOverrides.put(item.getItem(), item);
LayoutManager.markItemsDirty();
if (!ItemInfo.itemOverrides.containsEntry(item.getItem(), item)) {
ItemInfo.itemOverrides.put(item.getItem(), item);
LayoutManager.markItemsDirty();
}
}
/**
@@ -156,12 +174,15 @@ public class API {
*/
public static void setItemListEntries(Item item, Iterable<ItemStack> items) {
if (items == null) items = Collections.emptyList();
ItemInfo.itemOverrides.replaceValues(item, items);
LayoutManager.markItemsDirty();
if (!Sets.newHashSet(items).equals(Sets.newHashSet(ItemInfo.itemOverrides.get(item)))) {
ItemInfo.itemOverrides.replaceValues(item, items);
LayoutManager.markItemsDirty();
}
}
/**
* Add a custom KeyBinding to be configured in the Controls menu.
*
* @param ident An identifier for your key, eg "shoot"
* @param defaultKey The default value, commonly obtained from {@link Keyboard}
*/
@@ -173,6 +194,7 @@ public class API {
/**
* Add a custom KeyBinding to be configured in the Controls menu.
*
* @param ident An identifier for your key, eg "shoot"
* @param defaultKey The default value, commonly obtained from {@link Keyboard}
*/
@@ -187,6 +209,7 @@ public class API {
/**
* Add a new Layout Style for the NEI interface
*
* @param styleID The Unique ID to be used for storing your style in the config and cycling through avaliable styles
* @param style The style to add.
*/
@@ -196,6 +219,7 @@ public class API {
/**
* Registers a new Infinite Item Handler.
*
* @param handler The handler to be registered.
*/
public static void addInfiniteItemHandler(IInfiniteItemHandler handler) {
@@ -204,6 +228,7 @@ public class API {
/**
* Registers a new Infinite Item Handler.
*
* @param block The block to handle, null for all.
* @param handler The handler to be registered.
*/
@@ -213,6 +238,7 @@ public class API {
/**
* Tells NEI not to perform any Fast Transfer operations on slots of a particular class
*
* @param slotClass The class of slot to be exempted
*/
public static void addFastTransferExemptSlot(Class<? extends Slot> slotClass) {
@@ -221,8 +247,10 @@ public class API {
/**
* Register a new text handler for the block highlight tooltip with a layout specification (HEADER, BODY or FOOTER).
*
* @param handler The handler to be registered.
* @param layout A HUDAugmenterRegistry.Layout entry. HEADER is displayed before BODY which is displayed before FOOTER.
* @param layout A HUDAugmenterRegistry.Layout entry. HEADER is displayed before BODY which is displayed before
* FOOTER.
*/
public static void registerHighlightHandler(IHighlightHandler handler, ItemInfo.Layout... layout) {
ItemInfo.registerHighlightHandler(handler, layout);
@@ -230,6 +258,7 @@ public class API {
/**
* Register a mode handler for overriding NEI recipe/utility/cheat mode settings.
*
* @param handler The handler to be registered.
*/
public static void registerModeHandler(INEIModeHandler handler) {
@@ -238,6 +267,7 @@ public class API {
/**
* Register a filter provider for the item panel.
*
* @param filterProvider The filter provider to be registered.
*/
public static void addItemFilter(ItemFilterProvider filterProvider) {
@@ -248,7 +278,8 @@ public class API {
/**
* Adds a new tag to the item subset dropdown.
* @param name The fully qualified name, Eg Blocks.MobSpawners. NOT case sensitive
*
* @param name The fully qualified name, Eg Blocks.MobSpawners. NOT case sensitive
* @param filter A filter for matching items that fit in this subset
*/
public static void addSubset(String name, ItemFilter filter) {
@@ -257,7 +288,8 @@ public class API {
/**
* Adds a new tag to the item subset dropdown.
* @param name The fully qualified name, Eg Blocks.MobSpawners. NOT case sensitive
*
* @param name The fully qualified name, Eg Blocks.MobSpawners. NOT case sensitive
* @param items An iterable of itemstacks to be added as a subset
*/
public static void addSubset(String name, Iterable<ItemStack> items) {
@@ -282,20 +314,26 @@ public class API {
/**
* Adds a new sorting option to the item panel sort menu
* @param name A unique id for this sort option. Will be used in the config for saving and translated in the options gui. Note that if the translation key name.tip exists, it will be used for a tooltip
*
* @param name A unique id for this sort option. Will be used in the config for saving and translated in the options
* gui. Note that if the translation key name.tip exists, it will be used for a tooltip
*/
public static void addSortOption(String name, Comparator<ItemStack> comparator) {
ItemSorter.add(name, comparator);
}
/**
* Adds an additional item list entry for an item, sorted after the rest of the items are found through the normal process
* @param item The item to add the variant for
* Adds an additional item list entry for an item, sorted after the rest of the items are found through the normal
* process
*
* @param item The item to add the variant for
* @param variant The stack to appear in the item panel
*/
public static void addItemVariant(Item item, ItemStack variant) {
ItemInfo.itemVariants.put(item, variant);
LayoutManager.markItemsDirty();
if (!ItemInfo.itemVariants.containsEntry(item, variant)) {
ItemInfo.itemVariants.put(item, variant);
LayoutManager.markItemsDirty();
}
}
public static void registerStackStringifyHandler(IStackStringifyHandler handler) {
@@ -303,10 +341,12 @@ public class API {
}
/**
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel Recipes)
* Allows players to see what ingredient they need to craft in order to make recipes from a recipe category.
* @param stack the ingredient that can craft recipes (like a furnace or crafting table)
* @param handler the recipe category handled by the ingredient
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel
* Recipes) Allows players to see what ingredient they need to craft in order to make recipes from a recipe
* category.
*
* @param stack the ingredient that can craft recipes (like a furnace or crafting table)
* @param handler the recipe category handled by the ingredient
* @param priority higher priority comes first, default to 0
*/
public static void addRecipeCatalyst(ItemStack stack, IRecipeHandler handler, int priority) {
@@ -322,11 +362,13 @@ public class API {
}
/**
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel Recipes)
* Allows players to see what ingredient they need to craft in order to make recipes from a recipe category.
* @param stack the ingredient that can craft recipes (like a furnace or crafting table)
* Adds an association between an ingredient and what it can craft. (i.e. Furnace ItemStack -> Smelting and Fuel
* Recipes) Allows players to see what ingredient they need to craft in order to make recipes from a recipe
* category.
*
* @param stack the ingredient that can craft recipes (like a furnace or crafting table)
* @param handlerID recipe category identifier (see also {@link RecipeCatalysts#getRecipeID(IRecipeHandler)})
* @param priority higher priority comes first, default to 0
* @param priority higher priority comes first, default to 0
*/
public static void addRecipeCatalyst(ItemStack stack, String handlerID, int priority) {
RecipeCatalysts.addRecipeCatalyst(handlerID, new CatalystInfo(stack, priority));
@@ -1,13 +1,17 @@
package codechicken.nei.api;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.inventory.Slot;
import org.lwjgl.opengl.GL11;
import codechicken.nei.PositionedStack;
import codechicken.nei.guihook.GuiContainerManager;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.inventory.Slot;
import org.lwjgl.opengl.GL11;
public class DefaultOverlayRenderer implements IRecipeOverlayRenderer {
public DefaultOverlayRenderer(List<PositionedStack> ai, IStackPositioner positioner) {
positioner = this.positioner = positioner;
ingreds = new ArrayList<>();
+10 -7
View File
@@ -1,5 +1,14 @@
package codechicken.nei.api;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.NEIChestGuiHandler;
import codechicken.nei.NEICreativeGuiHandler;
@@ -9,15 +18,9 @@ import codechicken.nei.recipe.CheatItemHandler;
import codechicken.nei.recipe.FillFluidContainerHandler;
import codechicken.nei.recipe.GuiRecipeCatalyst;
import codechicken.nei.recipe.SearchInputDropHandler;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
public class GuiInfo {
public static final LinkedList<INEIGuiHandler> guiHandlers = new LinkedList<>();
public static final HashSet<Class<? extends GuiContainer>> customSlotGuis = new HashSet<>();
public static ReentrantReadWriteLock guiHandlersLock = new ReentrantReadWriteLock();
@@ -1,10 +1,11 @@
package codechicken.nei.api;
/**
* An nei configuration entry point should implement this class and have name "NEI<someting>Config"
* loadConfig will only be called when NEI is installed.
* An nei configuration entry point should implement this class and have name "NEI<someting>Config" loadConfig will only
* be called when NEI is installed.
*/
public interface IConfigureNEI {
public void loadConfig();
public String getName();
@@ -4,6 +4,7 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
public interface IGuiContainerOverlay {
GuiContainer getFirstScreen();
default GuiScreen getFirstScreenGeneral() {
@@ -1,19 +1,16 @@
package codechicken.nei.api;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public interface IHighlightHandler {
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop);
public List<String> handleTextData(
ItemStack itemStack,
World world,
EntityPlayer player,
MovingObjectPosition mop,
List<String> currenttip,
ItemInfo.Layout layout);
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop,
List<String> currenttip, ItemInfo.Layout layout);
}
@@ -4,6 +4,7 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public interface IInfiniteItemHandler {
void onPickup(ItemStack heldItem);
void onPlaceInfinite(ItemStack heldItem);
@@ -1,15 +1,22 @@
package codechicken.nei.api;
import codechicken.nei.VisiblityData;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import codechicken.nei.VisiblityData;
/**
* Lets you just override those things you want to
*/
public class INEIGuiAdapter implements INEIGuiHandler {
static final Pattern SPECIAL_REGEX_CHARS = Pattern.compile("[{}()\\[\\].+*?^$\\\\|]");
@Override
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
return currentVisibility;
@@ -34,4 +41,9 @@ public class INEIGuiAdapter implements INEIGuiHandler {
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
return false;
}
protected String formattingText(String displayName) {
return SPECIAL_REGEX_CHARS.matcher(EnumChatFormatting.getTextWithoutFormattingCodes(displayName))
.replaceAll("\\\\$0");
}
}
@@ -1,19 +1,22 @@
package codechicken.nei.api;
import codechicken.nei.VisiblityData;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.nei.VisiblityData;
/**
* If this is implemented on a gui, it will be automatically registered
*/
public interface INEIGuiHandler {
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility);
/**
* NEI will give the specified item to the InventoryRange returned if the player's inventory is full.
* Should not return null, just an empty list
* NEI will give the specified item to the InventoryRange returned if the player's inventory is full. Should not
* return null, just an empty list
*/
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item);
@@ -23,20 +26,24 @@ public interface INEIGuiHandler {
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui);
/**
* Handles clicks while an itemstack has been dragged from the item panel. Use this to set configurable slots and the like.
* Changes made to the stackSize of the dragged stack will be kept
* @param gui The current gui instance
* @param mousex The x position of the mouse
* @param mousey The y position of the mouse
* Handles clicks while an itemstack has been dragged from the item panel. Use this to set configurable slots and
* the like. Changes made to the stackSize of the dragged stack will be kept
*
* @param gui The current gui instance
* @param mousex The x position of the mouse
* @param mousey The y position of the mouse
* @param draggedStack The stack being dragged from the item panel
* @param button The button presed
* @return True if the drag n drop was handled. False to resume processing through other routes. The held stack will be deleted if draggedStack.stackSize == 0
* @param button The button presed
* @return True if the drag n drop was handled. False to resume processing through other routes. The held stack will
* be deleted if draggedStack.stackSize == 0
*/
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button);
/**
* Used to prevent the item panel from drawing on top of other gui elements.
* This function will also be called with a 1x1 size rectangle on the mouse position for determining if the given coordinate should override item panel functions such as scrolling
* Used to prevent the item panel from drawing on top of other gui elements. This function will also be called with
* a 1x1 size rectangle on the mouse position for determining if the given coordinate should override item panel
* functions such as scrolling
*
* @param x The x coordinate of the rectangle bounding the slot
* @param y The y coordinate of the rectangle bounding the slot
* @param w The w coordinate of the rectangle bounding the slot
@@ -1,5 +1,6 @@
package codechicken.nei.api;
public interface INEIModeHandler {
public boolean isModeValid(int mode);
}
@@ -1,8 +1,10 @@
package codechicken.nei.api;
import codechicken.nei.recipe.IRecipeHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import codechicken.nei.recipe.IRecipeHandler;
public interface IOverlayHandler {
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift);
void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift);
}
@@ -1,8 +1,10 @@
package codechicken.nei.api;
import codechicken.nei.guihook.GuiContainerManager;
import net.minecraft.inventory.Slot;
import codechicken.nei.guihook.GuiContainerManager;
public interface IRecipeOverlayRenderer {
public void renderOverlay(GuiContainerManager gui, Slot slot);
}
@@ -1,12 +1,14 @@
package codechicken.nei.api;
import codechicken.nei.PositionedStack;
import java.util.ArrayList;
import codechicken.nei.PositionedStack;
/**
* For repositioning recipes in overlay renderers.
*
*/
public interface IStackPositioner {
public ArrayList<PositionedStack> positionStacks(ArrayList<PositionedStack> ai);
}
@@ -3,10 +3,13 @@ package codechicken.nei.api;
import net.minecraft.item.ItemStack;
public interface ItemFilter {
/**
* Provides an item filter. May be called from any thread. Returned filter should only reference objects with immutable state.
* Provides an item filter. May be called from any thread. Returned filter should only reference objects with
* immutable state.
*/
public static interface ItemFilterProvider {
public ItemFilter getFilter();
}
+78 -109
View File
@@ -1,26 +1,5 @@
package codechicken.nei.api;
import codechicken.core.featurehack.GameDataManipulator;
import codechicken.nei.InfiniteStackSizeHandler;
import codechicken.nei.InfiniteToolHandler;
import codechicken.nei.ItemList;
import codechicken.nei.ItemMobSpawner;
import codechicken.nei.ItemStackMap;
import codechicken.nei.ItemStackSet;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.PopupInputHandler;
import codechicken.nei.config.ArrayDumper;
import codechicken.nei.config.HandlerDumper;
import codechicken.nei.config.ItemPanelDumper;
import codechicken.nei.config.RegistryDumper;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.BrewingRecipeHandler;
import codechicken.nei.recipe.RecipeItemInputHandler;
import com.google.common.collect.ArrayListMultimap;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -28,6 +7,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraft.block.Block;
import net.minecraft.client.resources.I18n;
import net.minecraft.creativetab.CreativeTabs;
@@ -59,10 +39,34 @@ import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.IShearable;
import net.minecraftforge.oredict.OreDictionary;
import com.google.common.collect.ArrayListMultimap;
import codechicken.core.featurehack.GameDataManipulator;
import codechicken.nei.InfiniteStackSizeHandler;
import codechicken.nei.InfiniteToolHandler;
import codechicken.nei.ItemList;
import codechicken.nei.ItemMobSpawner;
import codechicken.nei.ItemStackMap;
import codechicken.nei.ItemStackSet;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.PopupInputHandler;
import codechicken.nei.config.ArrayDumper;
import codechicken.nei.config.HandlerDumper;
import codechicken.nei.config.ItemPanelDumper;
import codechicken.nei.config.RegistryDumper;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.BrewingRecipeHandler;
import codechicken.nei.recipe.RecipeItemInputHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
/**
* This is an internal class for storing information about items, to be accessed by the API
*/
public class ItemInfo {
public static enum Layout {
HEADER,
BODY,
@@ -83,6 +87,7 @@ public class ItemInfo {
public static final HashMap<Item, String> itemOwners = new HashMap<>();
private static class ItemStackKey {
public final ItemStack stack;
public ItemStackKey(ItemStack stack) {
@@ -96,8 +101,7 @@ public class ItemInfo {
hashCode = 31 * hashCode + stack.stackSize;
hashCode = 31 * hashCode + Item.getIdFromItem(stack.getItem());
hashCode = 31 * hashCode + stack.getItemDamage();
hashCode = 31 * hashCode
+ (!stack.hasTagCompound() ? 0 : stack.getTagCompound().hashCode());
hashCode = 31 * hashCode + (!stack.hasTagCompound() ? 0 : stack.getTagCompound().hashCode());
return hashCode;
}
@@ -129,8 +133,7 @@ public class ItemInfo {
}
/**
* @deprecated
* Use field directly
* @deprecated Use field directly
*/
@Deprecated
public static List<ItemStack> getItemOverrides(Item item) {
@@ -176,22 +179,18 @@ public class ItemInfo {
private static void addIDDumps() {
API.addOption(new RegistryDumper<Item>("tools.dump.item") {
@Override
public String[] header() {
return new String[] {"Name", "ID", "Has Block", "Mod", "Class", "Display Name"};
return new String[] { "Name", "ID", "Has Block", "Mod", "Class", "Display Name" };
}
@Override
public String[] dump(Item item, int id, String name) {
return new String[] {
name,
Integer.toString(id),
Boolean.toString(Block.getBlockFromItem(item) != Blocks.air),
ItemInfo.itemOwners.get(item),
item.getClass().getCanonicalName(),
EnumChatFormatting.getTextWithoutFormattingCodes(
GuiContainerManager.itemDisplayNameShort(new ItemStack(item)))
};
return new String[] { name, Integer.toString(id),
Boolean.toString(Block.getBlockFromItem(item) != Blocks.air), ItemInfo.itemOwners.get(item),
item.getClass().getCanonicalName(), EnumChatFormatting.getTextWithoutFormattingCodes(
GuiContainerManager.itemDisplayNameShort(new ItemStack(item))) };
}
@Override
@@ -200,25 +199,19 @@ public class ItemInfo {
}
});
API.addOption(new RegistryDumper<Block>("tools.dump.block") {
@Override
public String[] header() {
return new String[] {"Name", "ID", "Has Item", "Mod", "Class", "Display Name"};
return new String[] { "Name", "ID", "Has Item", "Mod", "Class", "Display Name" };
}
@Override
public String[] dump(Block block, int id, String name) {
final Item item = Item.getItemFromBlock(block);
return new String[] {
name,
Integer.toString(id),
Boolean.toString(item != null),
ItemInfo.itemOwners.get(block),
block.getClass().getCanonicalName(),
item != null
? EnumChatFormatting.getTextWithoutFormattingCodes(
GuiContainerManager.itemDisplayNameShort(new ItemStack(item)))
: "null"
};
return new String[] { name, Integer.toString(id), Boolean.toString(item != null),
ItemInfo.itemOwners.get(block), block.getClass().getCanonicalName(),
item != null ? EnumChatFormatting.getTextWithoutFormattingCodes(
GuiContainerManager.itemDisplayNameShort(new ItemStack(item))) : "null" };
}
@Override
@@ -227,15 +220,14 @@ public class ItemInfo {
}
});
API.addOption(new ArrayDumper<Potion>("tools.dump.potion") {
public String[] header() {
return new String[] {"ID", "Unlocalised name", "Class"};
return new String[] { "ID", "Unlocalised name", "Class" };
}
@Override
public String[] dump(Potion potion, int id) {
return new String[] {
Integer.toString(id), potion.getName(), potion.getClass().getCanonicalName()
};
return new String[] { Integer.toString(id), potion.getName(), potion.getClass().getCanonicalName() };
}
@Override
@@ -244,20 +236,16 @@ public class ItemInfo {
}
});
API.addOption(new ArrayDumper<Enchantment>("tools.dump.enchantment") {
public String[] header() {
return new String[] {"ID", "Unlocalised name", "Type", "Min Level", "Max Level", "Class"};
return new String[] { "ID", "Unlocalised name", "Type", "Min Level", "Max Level", "Class" };
}
@Override
public String[] dump(Enchantment ench, int id) {
return new String[] {
Integer.toString(id),
ench.getName(),
ench.type.toString(),
Integer.toString(ench.getMinLevel()),
Integer.toString(ench.getMaxLevel()),
ench.getClass().getCanonicalName()
};
return new String[] { Integer.toString(id), ench.getName(), ench.type.toString(),
Integer.toString(ench.getMinLevel()), Integer.toString(ench.getMaxLevel()),
ench.getClass().getCanonicalName() };
}
@Override
@@ -266,19 +254,11 @@ public class ItemInfo {
}
});
API.addOption(new ArrayDumper<BiomeGenBase>("tools.dump.biome") {
@Override
public String[] header() {
return new String[] {
"ID",
"Name",
"Temperature",
"Rainfall",
"Spawn Chance",
"Root Height",
"Height Variation",
"Types",
"Class"
};
return new String[] { "ID", "Name", "Temperature", "Rainfall", "Spawn Chance", "Root Height",
"Height Variation", "Types", "Class" };
}
@Override
@@ -290,17 +270,11 @@ public class ItemInfo {
s_types.append(t.name());
}
return new String[] {
Integer.toString(id),
biome.biomeName,
Float.toString(biome.getFloatTemperature(0, 0, 0)),
Float.toString(biome.getFloatRainfall()),
Float.toString(biome.getSpawningChance()),
Float.toString(biome.rootHeight),
Float.toString(biome.heightVariation),
s_types.toString(),
biome.getClass().getCanonicalName()
};
return new String[] { Integer.toString(id), biome.biomeName,
Float.toString(biome.getFloatTemperature(0, 0, 0)), Float.toString(biome.getFloatRainfall()),
Float.toString(biome.getSpawningChance()), Float.toString(biome.rootHeight),
Float.toString(biome.heightVariation), s_types.toString(),
biome.getClass().getCanonicalName() };
}
@Override
@@ -319,8 +293,7 @@ public class ItemInfo {
UniqueIdentifier ident = null;
try {
ident = GameRegistry.findUniqueIdentifierFor(item);
} catch (Exception ignored) {
}
} catch (Exception ignored) {}
if (ident == null) {
NEIClientConfig.logger.error("Failed to find identifier for: " + item);
@@ -410,8 +383,8 @@ public class ItemInfo {
item.getSubItems(item, itemTab, stackList);
for (ItemStack stack : stackList) set.add(stack);
} catch (Exception e) {
NEIClientConfig.logger.error(
"Error loading sub-items for: " + item + ". Tab: " + itemTab.getTabLabel(), e);
NEIClientConfig.logger
.error("Error loading sub-items for: " + item + ". Tab: " + itemTab.getTabLabel(), e);
}
}
}
@@ -423,21 +396,20 @@ public class ItemInfo {
else if (item instanceof ItemAxe) axes.with(item);
else if (item instanceof ItemHoe) hoes.with(item);
else if (item instanceof ItemSword) swords.with(item);
else if (item instanceof ItemArmor)
switch (((ItemArmor) item).armorType) {
case 0:
helmets.with(item);
break;
case 1:
chest.with(item);
break;
case 2:
legs.with(item);
break;
case 3:
boots.with(item);
break;
}
else if (item instanceof ItemArmor) switch (((ItemArmor) item).armorType) {
case 0:
helmets.with(item);
break;
case 1:
chest.with(item);
break;
case 2:
legs.with(item);
break;
case 3:
boots.with(item);
break;
}
else if (item == Items.arrow || item == Items.bow) ranged.with(item);
else if (item == Items.fishing_rod || item == Items.flint_and_steel || item == Items.shears)
other.with(item);
@@ -517,8 +489,7 @@ public class ItemInfo {
try {
items.addAll(mouseoverBlock.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0));
} catch (Exception ignored) {
}
} catch (Exception ignored) {}
if (mouseoverBlock instanceof IShearable) {
IShearable shearable = (IShearable) mouseoverBlock;
if (shearable.isShearable(new ItemStack(Items.shears), world, x, y, z))
@@ -531,12 +502,11 @@ public class ItemInfo {
}
public static void registerHighlightHandler(IHighlightHandler handler, ItemInfo.Layout... layouts) {
for (ItemInfo.Layout layout : layouts)
ItemInfo.highlightHandlers.get(layout).add(handler);
for (ItemInfo.Layout layout : layouts) ItemInfo.highlightHandlers.get(layout).add(handler);
}
public static List<String> getText(
ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop) {
public static List<String> getText(ItemStack itemStack, World world, EntityPlayer player,
MovingObjectPosition mop) {
List<String> retString = new ArrayList<>();
for (ItemInfo.Layout layout : ItemInfo.Layout.values())
@@ -550,7 +520,6 @@ public class ItemInfo {
return itemSearchNames.computeIfAbsent(
new ItemStackKey(stack),
key -> EnumChatFormatting.getTextWithoutFormattingCodes(
GuiContainerManager.concatenatedDisplayName(key.stack, true)
.toLowerCase()));
GuiContainerManager.concatenatedDisplayName(key.stack, true).toLowerCase()));
}
}
@@ -1,11 +1,13 @@
package codechicken.nei.api;
import net.minecraft.client.gui.inventory.GuiContainer;
import codechicken.nei.Button;
import codechicken.nei.VisiblityData;
import codechicken.nei.guihook.GuiContainerManager;
import net.minecraft.client.gui.inventory.GuiContainer;
public abstract class LayoutStyle {
public abstract void init();
public abstract void reset();
@@ -1,11 +1,14 @@
package codechicken.nei.api;
import java.util.LinkedList;
import net.minecraft.world.World;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.config.OptionCycled;
import java.util.LinkedList;
import net.minecraft.world.World;
public class NEIInfo {
public static final LinkedList<INEIModeHandler> modeHandlers = new LinkedList<>();
public static void load(World world) {
@@ -0,0 +1,123 @@
package codechicken.nei.api;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import codechicken.nei.ItemPanels;
import codechicken.nei.LayoutManager;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.GuiUsageRecipe;
public abstract class ShortcutInputHandler {
public static boolean handleKeyEvent(ItemStack stackover) {
if (NEIClientConfig.isKeyHashDown("gui.overlay_hide")) {
return hideOverlayRecipe();
}
if (stackover == null) {
return false;
}
stackover = stackover.copy();
if (NEIClientConfig.isKeyHashDown("gui.overlay")) {
return openOverlayRecipe(stackover, false);
}
if (NEIClientConfig.isKeyHashDown("gui.overlay_use")) {
return openOverlayRecipe(stackover, true);
}
if (NEIClientConfig.isKeyHashDown("gui.recipe")) {
return GuiCraftingRecipe.openRecipeGui("item", stackover);
}
if (NEIClientConfig.isKeyHashDown("gui.usage")) {
return GuiUsageRecipe.openRecipeGui("item", stackover);
}
if (NEIClientConfig.isKeyHashDown("gui.bookmark")) {
return saveRecipeInBookmark(stackover, false, false);
}
if (NEIClientConfig.isKeyHashDown("gui.bookmark_recipe")) {
return saveRecipeInBookmark(stackover, true, false);
}
if (NEIClientConfig.isKeyHashDown("gui.bookmark_count")) {
return saveRecipeInBookmark(stackover, false, true);
}
if (NEIClientConfig.isKeyHashDown("gui.bookmark_recipe_count")) {
return saveRecipeInBookmark(stackover, true, true);
}
return false;
}
public static boolean handleMouseClick(ItemStack stackover) {
if (stackover != null) {
final int button = Mouse.getEventButton();
stackover = stackover.copy();
if (button == 0) {
return GuiCraftingRecipe.openRecipeGui("item", stackover);
} else if (button == 1) {
return GuiUsageRecipe.openRecipeGui("item", stackover);
}
}
return false;
}
private static boolean hideOverlayRecipe() {
if (LayoutManager.overlayRenderer != null) {
LayoutManager.overlayRenderer = null;
return true;
}
return false;
}
private static boolean openOverlayRecipe(ItemStack stack, boolean shift) {
final GuiContainer gui = NEIClientUtils.getGuiContainer();
if (gui == null || gui instanceof GuiRecipe) {
return false;
}
return GuiCraftingRecipe.openRecipeGui("item", true, shift, stack);
}
private static boolean saveRecipeInBookmark(ItemStack stack, boolean saveIngredients, boolean saveStackSize) {
if (stack != null) {
final GuiContainer gui = NEIClientUtils.getGuiContainer();
List<PositionedStack> ingredients = null;
String handlerName = "";
if (gui instanceof GuiRecipe) {
ingredients = ((GuiRecipe<?>) gui).getFocusedRecipeIngredients();
handlerName = ((GuiRecipe<?>) gui).getHandlerName();
stack.stackSize = ((GuiRecipe<?>) gui).prepareFocusedRecipeResultStackSize(stack);
}
ItemPanels.bookmarkPanel.addOrRemoveItem(stack, handlerName, ingredients, saveIngredients, saveStackSize);
return true;
}
return false;
}
}
@@ -1,12 +1,14 @@
package codechicken.nei.api;
import java.util.HashSet;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class TaggedInventoryArea {
public final HashSet<Integer> slots = new HashSet<>();
public final String tagName;
/**
@@ -3,11 +3,13 @@ package codechicken.nei.asm;
import static org.objectweb.asm.Opcodes.POP;
import static org.objectweb.asm.Opcodes.PUTSTATIC;
import codechicken.lib.asm.ASMHelper;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import codechicken.lib.asm.ASMHelper;
public class GuiContainerManagerAPITransformer extends ClassVisitor {
private final String tname;
private boolean changed = false;
@@ -19,14 +21,18 @@ public class GuiContainerManagerAPITransformer extends ClassVisitor {
@Override
public MethodVisitor visitMethod(int access, String mname, String mdesc, String signature, String[] exceptions) {
return new MethodVisitor(api, super.visitMethod(access, mname, mdesc, signature, exceptions)) {
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
if (opcode == PUTSTATIC
&& "codechicken/nei/guihook/GuiContainerManager".equals(owner)
if (opcode == PUTSTATIC && "codechicken/nei/guihook/GuiContainerManager".equals(owner)
&& name.endsWith("Handlers")
&& desc.equals("Ljava/util/LinkedList;")) {
ASMHelper.logger.warn(
"Found suspicious PUTSTATIC {} in {}#{}{}, replacing with POP!", name, tname, mname, mdesc);
"Found suspicious PUTSTATIC {} in {}#{}{}, replacing with POP!",
name,
tname,
mname,
mdesc);
changed = true;
super.visitInsn(POP);
} else {
@@ -1,17 +1,19 @@
package codechicken.nei.asm;
import java.io.File;
import java.util.Map;
import codechicken.core.launch.CodeChickenCorePlugin;
import codechicken.lib.asm.ASMInit;
import cpw.mods.fml.relauncher.IFMLCallHook;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
import java.io.File;
import java.util.Map;
@TransformerExclusions(value = {"codechicken.nei.asm"})
@TransformerExclusions(value = { "codechicken.nei.asm" })
@MCVersion("1.7.10")
public class NEICorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
public static File location;
public NEICorePlugin() {
@@ -21,7 +23,7 @@ public class NEICorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
@Override
public String[] getASMTransformerClass() {
CodeChickenCorePlugin.versionCheck(CodeChickenCorePlugin.mcVersion, "NotEnoughItems");
return new String[] {"codechicken.nei.asm.NEITransformer"};
return new String[] { "codechicken.nei.asm.NEITransformer" };
}
@Override
@@ -38,11 +40,7 @@ public class NEICorePlugin implements IFMLLoadingPlugin, IFMLCallHook {
public void injectData(Map<String, Object> data) {
location = (File) data.get("coremodLocation");
if (location == null)
location = new File(getClass()
.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath());
location = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
}
@Override
Loaded 100 of 191 files, more files were not shown because too many files have changed in this diff. Show more