Compare commits

...
33 Commits
Author SHA1 Message Date
Martin Robertz 18972388a7 update 2024-06-28 20:07:26 +02:00
glowredman 270bc77fbd Disable useDependencyInformation (#17) 2024-06-25 23:41:29 +02:00
Martin Robertz 2e73da4e25 update 2024-06-15 22:52:17 +02:00
slprimeandslprime 3fbc4eebac Fix find fluid from Bookmarks without amount (#16)
Co-authored-by: slprime <[email protected]>
2024-06-15 17:03:03 +02:00
Martin Robertz fc56416560 update 2024-05-22 21:24:01 +02:00
Oleg Ivanov 41e2db4644 Improvements and fixes (#15)
* Improvements and fixes

* Add config option not to search in EnderIO conduits
2024-05-22 19:28:12 +02:00
Martin Robertz 4a11c18f99 update 2024-03-10 22:53:59 +01:00
slprimeandslprime 35b27ed27f Rotate to Near Block (#14)
Co-authored-by: slprime <[email protected]>
2024-03-10 22:52:53 +01:00
slprimeandslprime fc025b3b85 Search Fluids; Changed Block Highlighter (#13)
* Search Fluids; Changed Block Highlighter

* fix hightlight when use rotate view

---------

Co-authored-by: slprime <[email protected]>
2024-02-18 15:39:55 +01:00
Martin Robertz 9d6ce05d9e update 2024-02-17 10:02:56 +01:00
gitboy14 0c2a7beed9 [QoF] Adding feature that automatically rotate player view when find a item/tile entity successfully (#12)
* init

* Configuration & Separating lookAtTarget()

* Spotless

* Move to center
2024-02-17 02:04:21 -06:00
Raven Szewczyk f1313bfc48 [ci skip] upgraded build system 2024-02-04 19:58:27 +00:00
bombcar 28859a3f6e [bs] spotless apply for jenkins (#11)
* spotless apply for jenkins

* remove *
2024-01-09 15:27:38 -06:00
Raven Szewczyk 58b41c6bb5 [ci skip] upgraded build system 2024-01-08 21:25:38 +00:00
glowredman f6eb09de3a Remove hard-dependency on GregTech (#10)
* Update buildscript

* Make GregTech a soft-dependency

* Small cleanup
2023-03-25 14:45:43 +01:00
Raven Szewczyk f31f2e3adf [ci skip] upgraded build system 2023-01-31 09:52:43 +00:00
Jason Mitchell 1bf51f5a48 [ci skip] Add git-blame-ignore-revs for spotlessApply 2023-01-29 12:45:21 -08:00
Jason Mitchell f2dc81704a [ci skip] spotlessApply with the new settings 2023-01-29 12:45:21 -08:00
Jason Mitchell 0e2d9e02a4 [ci skip] Update buildscript to RetroFuturaGradle 2023-01-29 12:44:20 -08:00
miozune 1f4c5b0058 Fix inventory slots not being highlighted (#9) 2022-09-01 16:07:31 +02:00
firenoo bdf41e7ed8 findit/util/AbstractStackFinder: Add check for whether NEI Search is focused (#8)
* findit/util/AbstractStackFinder: Add check for whether NEI Search is
focused

	This adds a check to make sure that FindIt doesn't start a
search when searching in NEI

Signed-off-by: Firenoo <[email protected]>

* findit/util/AbstractStackFinder: Move key handling code to lastKeyTyped

	Moves FindIt's keyhandling code to lastKeyTyped to avoid
conflicting with textfields.

Signed-off-by: Firenoo <[email protected]>

* findit/util/AbstractStackFinder: Code cleanup

Signed-off-by: Firenoo <[email protected]>

* findit/service: Revert default keybinds to T/Y.

Signed-off-by: Firenoo <[email protected]>

Signed-off-by: Firenoo <[email protected]>
2022-08-31 10:24:49 +02:00
slprime 84f2cf1182 Add Shortcut to KeyBinding (#7) 2022-08-21 19:28:02 +02:00
Jason Mitchell 5be63a3f25 [ci skip] Migrate github actions to GTNH-Actions-Workflows 2022-07-16 10:48:09 -07:00
Zereff06 be83b0edf9 Create ru_RU.lang (#6) 2022-07-15 02:21:06 +01:00
Kiwi 4045a075a2 Create zh_CN.lang (#5) 2022-04-29 14:09:51 +08:00
Oleg Ivanov f3deeacf6d Fix cooldown time usage (#4) 2022-02-21 13:24:40 +01:00
Oleg Ivanov dad262c9cb Full mod rewrite (#3)
* Full mod rewrite

* Remove legacy code

* Remove second draw call for position particle
2022-02-15 10:10:52 +01:00
bombcar d707559c4b build (#2)
* build

* not needed
2022-02-09 17:36:09 -06:00
bombcar d05ce2902c update buildscript 2022-02-07 20:28:11 -08:00
DreamMasterXXL 6c3bd8c8df bump version 2021-08-16 13:50:52 +02:00
DreamMasterXXL 64df820e7a update gradle and build script
upload gt as lib
2021-08-07 23:30:07 +02:00
DreamMasterXXL edafa3dc56 update gradle 2021-08-07 23:09:43 +02:00
Martin Robertz 10bb340eb7 Update build.gradle 2021-08-07 23:05:56 +02:00
52 changed files with 2170 additions and 657 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# Ignore spotlessApply reformat
f2dc81704a965d1f2ada7500842bc904f0ca7ddc
+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
+27
View File
@@ -0,0 +1,27 @@
if [[ -d "run/crash-reports" ]]; then
echo "Crash reports detected:"
cat $directory/*
exit 1
fi
if grep --quiet "Fatal errors were detected" server.log; then
echo "Fatal errors detected:"
cat server.log
exit 1
fi
if grep --quiet "The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED" server.log; then
echo "Server force stopped:"
cat server.log
exit 1
fi
if grep --quiet 'Done .+ For help, type "help" or "?"' server.log; then
echo "Server didn't finish startup:"
cat server.log
exit 1
fi
echo "No crash reports detected"
exit 0
+13
View File
@@ -0,0 +1,13 @@
name: Build and test
on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]
jobs:
build-and-test:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
secrets: inherit
+14
View File
@@ -0,0 +1,14 @@
name: Release tagged build
on:
push:
tags: [ '*' ]
permissions:
contents: write
jobs:
release-tags:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
secrets: inherit
+26 -20
View File
@@ -1,25 +1,31 @@
# eclipse
bin
*.launch
.gradle
.settings
.metadata
/.idea/
/run/
/build/
/eclipse/
.classpath
.project
# idea
out
/bin/
/config/
/crash-reports/
/logs/
options.txt
/saves/
usernamecache.json
banned-ips.json
banned-players.json
eula.txt
ops.json
server.properties
servers.dat
usercache.json
whitelist.json
/out/
*.iml
*.ipr
*.iws
*.iml
.idea
# gradle
build
.gradle
# other
eclipse
run
classes
/libs/
src/main/resources/mixins.*.json
*.bat
*.DS_Store
!gradlew.bat
+3
View File
@@ -0,0 +1,3 @@
# Any Github changes require admin approval
/.github/** @GTNewHorizons/admin
-1
View File
@@ -3,7 +3,6 @@
This is inspired by the "Search in nearby inventories" feature from 1.7.10 Extra Utilities, and from 1.12+ [FindMe](https://github.com/Buuz135/FindMe). Instead of searching inventories, FindIt will search the world for placed tile entities!
Did you forget where you placed your EV Mixer?
Well no problem now! Locate the item in NEI; however over it and hit 'Y' (the default keybind); if it's within range (+/-16 blocks) it will flash particle effects for you to locate it!
+4 -74
View File
@@ -1,75 +1,5 @@
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
apply plugin: 'forge'
apply plugin: 'idea'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = "${project.minecraftVersion}-${modVersion}"
group = modGroup
archivesBaseName = modBaseName
minecraft {
version = project.forgeVersion
runDir = "run"
}
configurations {
provided
embedded
compile.extendsFrom provided, embedded
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
maven {
name = "chickenbones"
url = "http://chickenbones.net/maven/"
}
}
dependencies {
compile "codechicken:CodeChickenLib:${project.minecraftVersion}-${project.codechickenlibVersion}:dev"
compile "codechicken:CodeChickenCore:${project.minecraftVersion}-${project.codechickencoreVersion}:dev"
compile "codechicken:NotEnoughItems:${project.minecraftVersion}-${project.neiVersion}:dev"
provided "gregtech:gregtech:${project.gregtechVersion}:dev"
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"
// replace version and mcversion
expand "version": project.version, "mcversion": project.minecraft.version
}
// copy everything else, that's not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
//version: 1707058017
plugins {
id 'com.gtnewhorizons.gtnhconvention'
}
+7
View File
@@ -0,0 +1,7 @@
// Add your dependencies here
dependencies {
implementation('com.github.GTNewHorizons:NotEnoughItems:2.6.11-GTNH:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.48.56:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.8.6:dev')
}
+192 -9
View File
@@ -1,9 +1,192 @@
modGroup=com.gtnh
modVersion=1.0.1
modBaseName=findit
forgeVersion=10.13.4.1614-1.7.10
minecraftVersion=1.7.10
codechickenlibVersion=1.1.3.140
codechickencoreVersion=1.0.7.47
neiVersion=1.0.3.57
gregtechVersion=5.09.32.30
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
# LOCAL to test local config updates.
gtnh.settings.blowdryerTag = 0.2.0
# Human-readable mod name, available for mcmod.info population.
modName = FindIt
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
modId = findit
# Root package of the mod, used to find various classes in other properties,
# mcmod.info substitution, enabling assertions in run tasks, etc.
modGroup = com.gtnh.findit
# Whether to use modGroup as the maven publishing group.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
useModGroupForPublishing = false
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
autoUpdateBuildScript = false
# Version of Minecraft to target
minecraftVersion = 1.7.10
# Version of Minecraft Forge to target
forgeVersion = 10.13.4.1614
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
channel = stable
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
mappingsVersion = 12
# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = Developer
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = true
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass = com.gtnh.findit.Tags
# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = VERSION
# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =
# [DEPRECATED] Mod name replacement token.
gradleTokenModName =
# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated 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.
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
apiPackage =
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile = findit_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
# responsibility to check the license and request permission for distribution if required.
usesShadowedDependencies = false
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true
# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
usesMavenPublishing = true
# Maven repository to publish the mod to.
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
# 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 to Modrinth.
modrinthProjectId =
# 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.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
modrinthRelations =
# 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 =
# 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 slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations =
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
# versionPattern =
# Uncomment to prevent the source code from being published.
# noPublishedSources = true
# Uncomment this to disable Spotless checks.
# This should only be uncommented to keep it easier to sync with upstream/other forks.
# That is, if there is no other active fork/upstream, NEVER change this.
# disableSpotless = true
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
# disableCheckstyle = true
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
# (force use delegated build).
# This is meant to be set in $HOME/.gradle/gradle.properties.
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
# ideaOverrideBuildType = idea
# Whether IDEA should run spotless checks when pressing the Build button.
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true
Binary file not shown.
+3 -1
View File
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
Vendored Regular → Executable
+193 -116
View File
@@ -1,78 +1,127 @@
#!/usr/bin/env sh
#!/bin/sh
#
# 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.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## 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/platforms/jvm/plugins-application/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
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
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# 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
@@ -81,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
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.
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
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
location of your Java installation."
fi
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, switch paths to Windows format before running java
if $cygwin ; 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=SC2039,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=SC2039,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
# 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"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
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
+42 -34
View File
@@ -1,4 +1,20 @@
@if "%DEBUG%" == "" @echo off
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -9,25 +25,29 @@
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=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
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.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@@ -35,48 +55,36 @@ 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%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
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
+2
View File
@@ -0,0 +1,2 @@
before_install:
- ./gradlew setupCIWorkspace
+4
View File
@@ -0,0 +1,4 @@
// Add any additional repositories for your dependencies here
repositories {
}
+23
View File
@@ -0,0 +1,23 @@
pluginManagement {
repositories {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "https://nexus.gtnewhorizons.com/repository/public/"
mavenContent {
includeGroup("com.gtnewhorizons")
includeGroupByRegex("com\\.gtnewhorizons\\..+")
}
}
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.23'
}
+46 -49
View File
@@ -1,79 +1,76 @@
package com.gtnh.findit;
import com.gtnh.findit.proxy.FindItCommon;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import com.gtnh.findit.service.blockfinder.BlockFindService;
import com.gtnh.findit.service.blockfinder.ClientBlockFindService;
import com.gtnh.findit.service.cooldown.SearchCooldownService;
import com.gtnh.findit.service.itemfinder.ClientItemFindService;
import com.gtnh.findit.service.itemfinder.ItemFindService;
import java.io.File;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.relauncher.Side;
@Mod(
modid = FindIt.MOD_ID,
name = FindIt.MOD_NAME,
version = FindIt.VERSION,
dependencies = "required-after:NotEnoughItems;required-after:gregtech",
acceptableRemoteVersions = "*"
)
dependencies = "required-after:NotEnoughItems;after:gregtech",
acceptableRemoteVersions = "*",
acceptedMinecraftVersions = "[1.7.10]")
public class FindIt {
// Mod info
public static final String MOD_ID = "findit";
public static final String MOD_NAME = "FindIt";
public static final String VERSION = "1.0.1";
// Config
public static int SEARCH_RADIUS = 16;
public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID);
public static final String VERSION = Tags.VERSION;
@Mod.Instance(MOD_ID)
public static FindIt INSTANCE;
@SidedProxy(serverSide = "com.gtnh.findit.proxy.FindItCommon", clientSide = "com.gtnh.findit.proxy.FindItClient")
public static FindItCommon proxy;
private boolean extraUtilitiesLoaded;
private boolean gregTechloaded;
private boolean enderIOloaded;
private SearchCooldownService cooldownService;
private BlockFindService blockFindService;
private ItemFindService itemFindService;
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent event) {
this.setupConfig(event.getSuggestedConfigurationFile());
proxy.preinit(event);
public void preInit(FMLPreInitializationEvent event) {
this.extraUtilitiesLoaded = Loader.isModLoaded("ExtraUtilities");
this.gregTechloaded = Loader.isModLoaded("gregtech");
this.enderIOloaded = Loader.isModLoaded("EnderIO");
FindItConfig.setup(event.getSuggestedConfigurationFile());
boolean isClient = event.getSide() == Side.CLIENT;
this.cooldownService = new SearchCooldownService();
this.blockFindService = isClient ? new ClientBlockFindService() : new BlockFindService();
this.itemFindService = isClient ? new ClientItemFindService() : new ItemFindService();
}
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
proxy.init(event);
public static SearchCooldownService getCooldownService() {
return INSTANCE.cooldownService;
}
@Mod.EventHandler
public void postinit(FMLPostInitializationEvent event) {
proxy.postinit(event);
public static BlockFindService getBlockFindService() {
return INSTANCE.blockFindService;
}
public void setupConfig(final File file) {
final Configuration config = new Configuration(file);
try {
// Load config
config.load();
public static ItemFindService getItemFindService() {
return INSTANCE.itemFindService;
}
// Read props from config
Property searchRadiousProp = config.get(Configuration.CATEGORY_GENERAL,
"SearchRadius", // Property name
"16", // Default value
"Radius to search within"); // Comment
public static boolean isExtraUtilitiesLoaded() {
return INSTANCE.extraUtilitiesLoaded;
}
FindIt.SEARCH_RADIUS = searchRadiousProp.getInt();
} catch (Exception e) {
// Failed reading/writing, just continue
} finally {
// Save props to config IF config changed
if (config.hasChanged()) config.save();
}
public static boolean isGregTechLoaded() {
return INSTANCE.gregTechloaded;
}
public static boolean isEnderIOLoaded() {
return INSTANCE.enderIOloaded;
}
}
@@ -0,0 +1,80 @@
package com.gtnh.findit;
import java.io.File;
import net.minecraftforge.common.config.Configuration;
public class FindItConfig {
public static int SEARCH_RADIUS = 16;
public static int SEARCH_COOLDOWN = 10;
public static int MAX_RESPONSE_SIZE = 20;
public static boolean ENABLE_ROTATE_VIEW = false;
public static boolean USE_PARTICLE_HIGHLIGHTER = false;
public static boolean SEARCH_ITEMS_ON_GROUND = true;
public static boolean SEARCH_IN_GT_PIPES = false;
public static boolean SEARCH_IN_ENDERIO_CONDUITS = false;
public static int ITEM_HIGHLIGHTING_DURATION = 10;
public static int BLOCK_HIGHLIGHTING_DURATION = 8;
public static void setup(final File file) {
final Configuration config = new Configuration(file);
try {
config.load();
SEARCH_RADIUS = config.get(Configuration.CATEGORY_GENERAL, "SearchRadius", "16", "Radius to search within")
.getInt();
SEARCH_COOLDOWN = config
.get(Configuration.CATEGORY_GENERAL, "SearchCooldown", "10", "Search cooldown in ticks").getInt();
MAX_RESPONSE_SIZE = config.get(
Configuration.CATEGORY_GENERAL,
"MaxResponseSize",
"20",
"Maximum number of positions that can be displayed by item/block search").getInt();
USE_PARTICLE_HIGHLIGHTER = config.get(
Configuration.CATEGORY_GENERAL,
"UseParticleHighlighter",
"false",
"Use Particle for Block Highlighter").getBoolean();
SEARCH_IN_GT_PIPES = config.get(
Configuration.CATEGORY_GENERAL,
"SearchInGregTechPipes",
"false",
"Search items & fluids in GT pipes").getBoolean();
SEARCH_IN_ENDERIO_CONDUITS = config.get(
Configuration.CATEGORY_GENERAL,
"SearchInEnderIOConduits",
"false",
"Search items & fluids in EnderIO conduits").getBoolean();
SEARCH_ITEMS_ON_GROUND = config.get(
Configuration.CATEGORY_GENERAL,
"SearchItemsOnGround",
"true",
"Search items dropped on ground").getBoolean();
ITEM_HIGHLIGHTING_DURATION = config
.get(Configuration.CATEGORY_GENERAL, "ItemHighlightingDuration", "10", "Item highlighting duration")
.getInt();
BLOCK_HIGHLIGHTING_DURATION = config.get(
Configuration.CATEGORY_GENERAL,
"BlockHighlightingDuration",
"8",
"Block highlighting duration in seconds").getInt();
ENABLE_ROTATE_VIEW = config.get(
Configuration.CATEGORY_GENERAL,
"EnableRotateView",
"false",
"Rotate player's view when searched").getBoolean();
} catch (Exception ignore) {} finally {
if (config.hasChanged()) config.save();
}
}
}
@@ -0,0 +1,18 @@
package com.gtnh.findit;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
public class FindItNetwork {
private static int lastMessageId = -1;
public static final SimpleNetworkWrapper CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(FindIt.MOD_ID);
public static <REQ extends IMessage, REPLY extends IMessage> void registerMessage(
Class<? extends IMessageHandler<REQ, REPLY>> messageHandler, Class<REQ> requestMessageType, Side side) {
CHANNEL.registerMessage(messageHandler, requestMessageType, ++lastMessageId, side);
}
}
@@ -0,0 +1,123 @@
package com.gtnh.findit.fx;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockChest;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.ChunkPosition;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
import com.gtnh.findit.util.ClientFinderHelperUtils;
public class BlockHighlighter {
private List<ChunkPosition> positions = new ArrayList<>();
private long expireHighlight;
public void highlightBlocks(List<ChunkPosition> positions, long expireHighlight) {
this.positions = positions;
this.expireHighlight = expireHighlight;
}
public void renderHighlightedBlock(RenderWorldLastEvent event) {
if (this.positions.isEmpty()) {
return;
}
Minecraft mc = Minecraft.getMinecraft();
long time = System.currentTimeMillis();
if (((time / 500) & 1) == 0) {
return;
}
if (time > expireHighlight) {
positions.clear();
}
EntityPlayerSP p = mc.thePlayer;
double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * event.partialTicks;
double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * event.partialTicks;
double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * event.partialTicks;
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glLineWidth(3);
GL11.glTranslated(-doubleX, -doubleY, -doubleZ);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
for (ChunkPosition pos : this.positions) {
drawBlockHighlightBox(mc.theWorld, pos);
}
GL11.glPopAttrib();
GL11.glPopMatrix();
}
private static void drawBlockHighlightBox(WorldClient world, ChunkPosition pos) {
Block block = world.getBlock(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
AxisAlignedBB box;
if (block instanceof BlockChest) {
box = getChestHighlightBox(world, (BlockChest) block, pos);
} else {
box = getBlockHighlightBox(world, block, pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
}
FxHelper.renderBoxOutline(box);
}
private static AxisAlignedBB getChestHighlightBox(WorldClient world, BlockChest block, ChunkPosition pos) {
AxisAlignedBB chestBox = getBlockHighlightBox(world, block, pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
TileEntity tileEntity = world.getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
if (!(tileEntity instanceof TileEntityChest)) {
return chestBox;
}
TileEntityChest chest = (TileEntityChest) tileEntity;
TileEntityChest nearChest = null;
if (chest.adjacentChestXNeg != null) {
nearChest = chest.adjacentChestXNeg;
} else if (chest.adjacentChestXPos != null) {
nearChest = chest.adjacentChestXPos;
} else if (chest.adjacentChestZNeg != null) {
nearChest = chest.adjacentChestZNeg;
} else if (chest.adjacentChestZPos != null) {
nearChest = chest.adjacentChestZPos;
}
if (nearChest == null) {
return chestBox;
}
AxisAlignedBB nearChestBox = getBlockHighlightBox(
world,
nearChest.getBlockType(),
nearChest.xCoord,
nearChest.yCoord,
nearChest.zCoord);
return ClientFinderHelperUtils.mergeAABB(chestBox, nearChestBox);
}
private static AxisAlignedBB getBlockHighlightBox(WorldClient world, Block block, int x, int y, int z) {
block.setBlockBoundsBasedOnState(world, x, y, z);
AxisAlignedBB box = block.getSelectedBoundingBoxFromPool(world, x, y, z);
if (box.maxX - box.minX < 0.25f || box.maxY - box.minY < 0.25f || box.maxZ - box.minZ < 0.25f) {
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
}
return box;
}
}
@@ -0,0 +1,95 @@
package com.gtnh.findit.fx;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.util.MathHelper;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
public class EntityHighlighter {
private List<Integer> entityIds = new ArrayList<>();
private long expireHighlight;
public void highlightEntities(List<Integer> entityIds, long expireHighlight) {
this.entityIds = entityIds;
this.expireHighlight = expireHighlight;
}
public void renderHighlightedEntities(RenderWorldLastEvent event) {
if (this.entityIds.isEmpty()) {
return;
}
Minecraft mc = Minecraft.getMinecraft();
RenderItem renderItem = RenderItem.getInstance();
long time = System.currentTimeMillis();
if (((time / 500) & 1) == 0) {
return;
}
if (time > expireHighlight) {
entityIds.clear();
}
EntityPlayerSP p = mc.thePlayer;
double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * event.partialTicks;
double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * event.partialTicks;
double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * event.partialTicks;
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glLineWidth(3);
GL11.glTranslated(-doubleX, -doubleY, -doubleZ);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor4f(0.75f, 0.0f, 1.0f, 1.0f);
for (int entityId : this.entityIds) {
Entity entity = mc.theWorld.getEntityByID(entityId);
if (entity != null) {
float scale = 1f;
if (entity instanceof EntityItem) {
EntityItem item = (EntityItem) entity;
GL11.glPushMatrix();
double itemX = item.lastTickPosX + (item.posX - item.lastTickPosX) * event.partialTicks;
double itemY = item.lastTickPosY + (item.posY - item.lastTickPosY) * event.partialTicks;
double itemZ = item.lastTickPosZ + (item.posZ - item.lastTickPosZ) * event.partialTicks;
float age = item.age + event.partialTicks;
float elevation = renderItem.shouldBob()
? MathHelper.sin(age / 10.0F + item.hoverStart) * 0.1F + 0.1F
: 0F;
float angle = (age / 20.0F + item.hoverStart) * (180F / (float) Math.PI);
GL11.glTranslated(itemX, itemY, itemZ);
GL11.glRotated(angle, 0, 1, 0);
GL11.glTranslated(-itemX, -itemY + elevation, -itemZ);
scale = 1.2f;
}
FxHelper.renderEntityOutline(entity, scale, event.partialTicks);
if (entity instanceof EntityItem) {
GL11.glPopMatrix();
}
}
}
GL11.glPopAttrib();
GL11.glPopMatrix();
}
}
@@ -0,0 +1,75 @@
package com.gtnh.findit.fx;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.ChunkPosition;
import org.lwjgl.opengl.GL11;
public class FxHelper {
public static void renderBlockOutline(ChunkPosition pos) {
renderOutline(
pos.chunkPosX,
pos.chunkPosY,
pos.chunkPosZ,
pos.chunkPosX + 1,
pos.chunkPosY + 1,
pos.chunkPosZ + 1);
}
public static void renderBoxOutline(AxisAlignedBB box) {
renderOutline(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
}
public static void renderEntityOutline(Entity entity, float scale, float partialTicks) {
double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
float w = entity.width / 2.0F;
float h = entity.height;
if (scale != 1f) {
w *= scale;
h *= scale;
y -= entity.height * (scale - 1f) / 2f;
}
renderOutline(x - (double) w, y, z - (double) w, x + (double) w, y + (double) h, z + (double) w);
}
public static void renderOutline(double x0, double y0, double z0, double x1, double y1, double z1) {
GL11.glBegin(GL11.GL_LINE_STRIP);
GL11.glVertex3d(x0, y0, z0);
GL11.glVertex3d(x0, y1, z0);
GL11.glVertex3d(x0, y1, z1);
GL11.glVertex3d(x0, y0, z1);
GL11.glVertex3d(x0, y0, z0);
GL11.glVertex3d(x1, y0, z0);
GL11.glVertex3d(x1, y1, z0);
GL11.glVertex3d(x1, y1, z1);
GL11.glVertex3d(x1, y0, z1);
GL11.glVertex3d(x1, y0, z0);
GL11.glVertex3d(x0, y0, z0);
GL11.glVertex3d(x1, y0, z0);
GL11.glVertex3d(x1, y0, z1);
GL11.glVertex3d(x0, y0, z1);
GL11.glVertex3d(x0, y1, z1);
GL11.glVertex3d(x1, y1, z1);
GL11.glVertex3d(x1, y1, z0);
GL11.glVertex3d(x1, y0, z0);
GL11.glVertex3d(x0, y0, z0);
GL11.glVertex3d(x1, y0, z0);
GL11.glVertex3d(x1, y1, z0);
GL11.glVertex3d(x0, y1, z0);
GL11.glVertex3d(x0, y1, z1);
GL11.glVertex3d(x1, y1, z1);
GL11.glVertex3d(x1, y0, z1);
GL11.glVertex3d(x0, y0, z1);
GL11.glEnd();
}
}
@@ -0,0 +1,71 @@
package com.gtnh.findit.fx;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityReddustFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
public class ParticlePosition extends EntityReddustFX {
private static int validVersion = 0;
private int version;
public ParticlePosition(World world, ChunkPosition pos) {
this(
world,
pos.chunkPosX + (0.5 + (world.rand.nextDouble() - 0.5) * world.rand.nextDouble()),
pos.chunkPosY + (0.5 + (world.rand.nextDouble() - 0.5) * world.rand.nextDouble()),
pos.chunkPosZ + (0.5 + (world.rand.nextDouble() - 0.5) * world.rand.nextDouble()));
version = validVersion;
}
@Override
public void onUpdate() {
if (version == validVersion) {
super.onUpdate();
} else {
setDead();
}
}
public ParticlePosition(World world, double posX, double posY, double posZ) {
super(world, posX, posY, posZ, 255 / 255f, 165 / 255f, 255 / 255f);
this.noClip = true;
this.particleMaxAge *= 10;
this.motionX *= 0.1;
this.motionY *= 0.1;
this.motionZ *= 0.1;
this.particleScale *= 2.0f;
}
@Override
public void renderParticle(final Tessellator tessellator, float partialTickTime, float rotationX, float rotationZ,
float rotationYZ, float rotationXY, float rotationXZ) {
tessellator.draw();
GL11.glDisable(GL11.GL_DEPTH_TEST);
tessellator.startDrawingQuads();
super.renderParticle(tessellator, partialTickTime, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
tessellator.draw();
GL11.glEnable(GL11.GL_DEPTH_TEST);
tessellator.startDrawingQuads();
}
public static void highlightBlocks(World world, List<ChunkPosition> positions) {
validVersion++;
int particleCount = positions.size() <= 10 ? 12 : Math.max(12 - (positions.size() - 10) / 2, 2);
for (ChunkPosition pos : positions) {
for (int i = 0; i < particleCount; ++i) {
Minecraft.getMinecraft().effectRenderer.addEffect(new ParticlePosition(world, pos));
}
}
}
}
@@ -0,0 +1,93 @@
package com.gtnh.findit.fx;
import java.util.HashSet;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.inventory.Slot;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import com.gtnh.findit.FindIt;
import codechicken.nei.guihook.IContainerDrawHandler;
public class SlotHighlighter implements IContainerDrawHandler {
private static final ResourceLocation highlightTexture = new ResourceLocation(
FindIt.MOD_ID,
"textures/gui/slot_highlight.png");
private GuiContainer gui = null;
private HashSet<Slot> slots = new HashSet<>();
private float red = 0;
private float green = 0;
private float blue = 0;
private float alpha = 0;
public void highlightSlots(GuiContainer gui, HashSet<Slot> slots, int color) {
this.gui = gui;
this.slots = slots;
this.red = (float) (color >> 16 & 255) / 255.0F;
this.green = (float) (color >> 8 & 255) / 255.0F;
this.blue = (float) (color & 255) / 255.0F;
this.alpha = (float) (color >> 24 & 255) / 255.0F;
}
@Override
public void onPreDraw(GuiContainer gui) {}
@Override
public void renderObjects(GuiContainer gui, int mousex, int mousey) {}
@Override
public void postRenderObjects(GuiContainer gui, int mousex, int mousey) {}
@Override
public void renderSlotOverlay(GuiContainer gui, Slot slot) {}
@Override
public void renderSlotUnderlay(GuiContainer gui, Slot slot) {
if (this.gui == gui && this.slots.contains(slot)) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glEnable(GL11.GL_TEXTURE_2D);
Minecraft.getMinecraft().getTextureManager().bindTexture(highlightTexture);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(red, green, blue, alpha);
highlightSlot(tessellator, slot.xDisplayPosition, slot.yDisplayPosition);
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
private void highlightSlot(Tessellator tessellator, int x, int y) {
double zLevel = 1;
int x2 = x + 16;
int y2 = y + 16;
tessellator.addVertexWithUV(x2, y, zLevel, 18 / 32.0, 0);
tessellator.addVertexWithUV(x, y, zLevel, 0, 0);
tessellator.addVertexWithUV(x, y2, zLevel, 0, 18 / 32.0);
tessellator.addVertexWithUV(x2, y2, zLevel, 18 / 32.0, 18 / 32.0);
}
}
@@ -1,76 +0,0 @@
package com.gtnh.findit.network;
import com.gtnh.findit.proxy.client.ParticlePosition;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.network.PacketBuffer;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class KIFoundItMessage implements IMessage {
private List<ChunkPosition> positions;
public KIFoundItMessage(List<ChunkPosition> positions) {
this.positions = positions;
}
public KIFoundItMessage() {
}
@Override
public void fromBytes(ByteBuf buf) {
PacketBuffer packetBuffer = new PacketBuffer(buf);
int amount = packetBuffer.readInt();
positions = new ArrayList<>();
while (amount > 0) {
final int x = packetBuffer.readInt();
final int y = packetBuffer.readUnsignedByte();
final int z = packetBuffer.readInt();
positions.add(new ChunkPosition(x, y, z));
--amount;
}
}
@Override
public void toBytes(ByteBuf buf) {
PacketBuffer packetBuffer = new PacketBuffer(buf);
packetBuffer.writeInt(positions.size());
for (ChunkPosition pos : positions) {
packetBuffer.writeInt(pos.chunkPosX);
packetBuffer.writeByte(pos.chunkPosY);
packetBuffer.writeInt(pos.chunkPosZ);
}
}
public static class Handler implements IMessageHandler<KIFoundItMessage, IMessage> {
@SideOnly(Side.CLIENT)
@Override
public IMessage onMessage(KIFoundItMessage message, MessageContext ctx) {
Minecraft.getMinecraft().thePlayer.closeScreen();
World world = Minecraft.getMinecraft().thePlayer.worldObj;
for (ChunkPosition pos : message.positions) {
for (int i = 0; i < 2; ++i)
Minecraft.getMinecraft().effectRenderer.addEffect(
new ParticlePosition(
Minecraft.getMinecraft().thePlayer.worldObj,
pos.chunkPosX + (0.5 + (world.rand.nextDouble() - 0.5) * world.rand.nextDouble()),
pos.chunkPosY + (0.5 + (world.rand.nextDouble() - 0.5) * world.rand.nextDouble()),
pos.chunkPosZ + (0.5 + (world.rand.nextDouble() - 0.5) * world.rand.nextDouble())
)
);
}
return null;
}
}
}
@@ -1,125 +0,0 @@
package com.gtnh.findit.network;
import com.gtnh.findit.FindIt;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.WeakHashMap;
public class PlzFindItMessage implements IMessage {
static WeakHashMap<EntityPlayerMP, Long> lastCalled = new WeakHashMap<>();
private ItemStack stack;
public PlzFindItMessage(ItemStack stack) {
this.stack = stack;
}
public PlzFindItMessage() {
}
public static List<ChunkPosition> getBlockPosInAABB(AxisAlignedBB axisAlignedBB) {
List<ChunkPosition> blocks = new ArrayList<>();
int maxY = (int) Math.round(axisAlignedBB.maxY),
maxX = (int) Math.round(axisAlignedBB.maxX),
maxZ = (int) Math.round(axisAlignedBB.maxZ);
for (int y = (int) Math.round(axisAlignedBB.minY); y < maxY; ++y) {
for (int x = (int) Math.round(axisAlignedBB.minX); x < maxX; ++x) {
for (int z = (int) Math.round(axisAlignedBB.minZ); z < maxZ; ++z) {
blocks.add(new ChunkPosition(x, y, z));
}
}
}
return blocks;
}
@Override
public void fromBytes(ByteBuf buf) {
PacketBuffer packetBuffer = new PacketBuffer(buf);
stack = null;
try {
stack = packetBuffer.readItemStackFromBuffer();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void toBytes(ByteBuf buf) {
PacketBuffer packetBuffer = new PacketBuffer(buf);
try {
packetBuffer.writeItemStackToBuffer(stack);
} catch (IOException e) {
e.printStackTrace();
}
}
public static class Handler implements IMessageHandler<PlzFindItMessage, KIFoundItMessage> {
@Override
public KIFoundItMessage onMessage(PlzFindItMessage message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
World world = player.worldObj;
// Don't let people spam this, otherwise bad performance and they'll probably get disconnected
final long time = world.getTotalWorldTime();
final Long lastCalled = PlzFindItMessage.lastCalled.get(player);
if (lastCalled != null && time - lastCalled < 10L) {
return null;
}
final Item toFind = message.stack.getItem();
final int metaToFind = message.stack.getItemDamage();
final double x = player.posX,
y = player.posY,
z = player.posZ;
int r = FindIt.SEARCH_RADIUS;
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(x - r, y - r, z -r, x + r, y + r, z + r);
List<ChunkPosition> posList = new ArrayList<>();
for (ChunkPosition pos : getBlockPosInAABB(box)) {
try {
final TileEntity tileEntity = world.getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
if(tileEntity == null) continue;
final Item tileItem = Item.getItemFromBlock(tileEntity.getBlockType());
if (tileItem == null) continue;
final int tileMeta;
if (tileEntity instanceof IGregTechTileEntity)
tileMeta = ((IGregTechTileEntity)tileEntity).getMetaTileID();
else
tileMeta = world.getBlockMetadata(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
if (toFind.equals(tileItem) && metaToFind == tileMeta) {
posList.add(pos);
}
} catch (NullPointerException e) {
e.printStackTrace();
}
}
if (!posList.isEmpty())
FindIt.NETWORK.sendTo(new KIFoundItMessage(posList), player);
return null;
}
}
}
@@ -1,72 +0,0 @@
package com.gtnh.findit.proxy;
import codechicken.nei.LayoutManager;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.api.API;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerInputHandler;
import com.gtnh.findit.FindIt;
import com.gtnh.findit.network.PlzFindItMessage;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
public class FindItClient extends FindItCommon implements IContainerInputHandler{
@Override
public void preinit(FMLPreInitializationEvent event) {
super.preinit(event);
API.addKeyBind("gui.findit", Keyboard.KEY_Y);
GuiContainerManager.addInputHandler((IContainerInputHandler)new FindItClient());
}
public boolean keyTyped(final GuiContainer window, final char c, final int k) {
final int keyBinding = NEIClientConfig.getKeyBinding("gui.findit");
if (k != keyBinding) {
return false;
}
final LayoutManager layout = LayoutManager.instance();
if (layout == null || LayoutManager.itemPanel == null || NEIClientConfig.isHidden()) {
return false;
}
final ItemStack stack = GuiContainerManager.getStackMouseOver(window);
if (stack == null || stack.getItem() == null) {
return false;
}
FindIt.NETWORK.sendToServer(new PlzFindItMessage(stack));
return true;
}
public void onKeyTyped(final GuiContainer guiContainer, final char c, final int i) {
}
public boolean lastKeyTyped(final GuiContainer guiContainer, final char c, final int i) {
return false;
}
public boolean mouseClicked(final GuiContainer guiContainer, final int i, final int i1, final int i2) {
return false;
}
public void onMouseClicked(final GuiContainer guiContainer, final int i, final int i1, final int i2) {
}
public void onMouseUp(final GuiContainer guiContainer, final int i, final int i1, final int i2) {
}
public boolean mouseScrolled(final GuiContainer guiContainer, final int i, final int i1, final int i2) {
return false;
}
public void onMouseScrolled(final GuiContainer guiContainer, final int i, final int i1, final int i2) {
}
public void onMouseDragged(final GuiContainer guiContainer, final int i, final int i1, final int i2, final long l) {
}
}
@@ -1,29 +0,0 @@
package com.gtnh.findit.proxy;
import com.gtnh.findit.network.KIFoundItMessage;
import com.gtnh.findit.network.PlzFindItMessage;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.relauncher.Side;
import static com.gtnh.findit.FindIt.NETWORK;
public class FindItCommon {
public void preinit(FMLPreInitializationEvent event) {
NETWORK.registerMessage(PlzFindItMessage.Handler.class, PlzFindItMessage.class, 0, Side.SERVER);
NETWORK.registerMessage(KIFoundItMessage.Handler.class, KIFoundItMessage.class, 1, Side.CLIENT);
}
public void init(FMLInitializationEvent event) {
}
public void postinit(FMLPostInitializationEvent event) {
}
}
@@ -1,35 +0,0 @@
package com.gtnh.findit.proxy.client;
import net.minecraft.client.particle.EntityReddustFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
public class ParticlePosition extends EntityReddustFX {
public ParticlePosition(World world, double posX, double posY, double posZ) {
super(world, posX, posY, posZ, 1.0f, 1.0f, 1.0f);
this.noClip = true;
this.particleMaxAge *= 10;
this.motionX *= 0.1;
this.motionY *= 0.1;
this.motionZ *= 0.1;
this.particleScale *= 2.0f;
}
@Override
public void renderParticle(final Tessellator tessellator, float partialTickTime, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
super.renderParticle(tessellator, partialTickTime, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
tessellator.draw();
GL11.glDisable(2929 /*GL_DEPTH_TEST*/);
tessellator.startDrawingQuads();
super.renderParticle(tessellator, partialTickTime, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
tessellator.draw();
GL11.glEnable(2929 /*GL_DEPTH_TEST*/);
tessellator.startDrawingQuads();
}
}
@@ -0,0 +1,60 @@
package com.gtnh.findit.service.blockfinder;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.ChunkPosition;
import com.gtnh.findit.FindIt;
import com.gtnh.findit.FindItConfig;
import com.gtnh.findit.FindItNetwork;
import com.gtnh.findit.util.WorldUtils;
import cpw.mods.fml.relauncher.Side;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
public class BlockFindService {
public BlockFindService() {
FindItNetwork.registerMessage(FindBlockRequest.Handler.class, FindBlockRequest.class, Side.SERVER);
FindItNetwork.registerMessage(BlockFoundResponse.Handler.class, BlockFoundResponse.class, Side.CLIENT);
}
public void handleRequest(EntityPlayerMP player, FindBlockRequest request) {
if (FindIt.getCooldownService().checkSearchCooldown(player)) {
return;
}
List<ChunkPosition> positions = new ArrayList<>();
for (TileEntity tileEntity : WorldUtils.getTileEntitiesAround(player, FindItConfig.SEARCH_RADIUS)) {
try {
Block tileBlock = tileEntity.getBlockType();
if (!request.getBlockToFind().equals(tileBlock)) {
continue;
}
int tileMeta;
if (FindIt.isGregTechLoaded() && tileEntity instanceof IGregTechTileEntity) {
tileMeta = ((IGregTechTileEntity) tileEntity).getMetaTileID();
} else {
tileMeta = tileEntity.getBlockMetadata();
}
if (request.getMetaToFind() == tileMeta) {
positions.add(new ChunkPosition(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
if (positions.size() == FindItConfig.MAX_RESPONSE_SIZE) {
break;
}
}
} catch (NullPointerException e) {
e.printStackTrace();
}
}
FindItNetwork.CHANNEL.sendTo(new BlockFoundResponse(positions), player);
}
}
@@ -0,0 +1,50 @@
package com.gtnh.findit.service.blockfinder;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.world.ChunkPosition;
import com.gtnh.findit.util.ProtoUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
public class BlockFoundResponse implements IMessage {
private List<ChunkPosition> positions;
public BlockFoundResponse(List<ChunkPosition> positions) {
this.positions = positions;
}
public BlockFoundResponse() {}
public List<ChunkPosition> getPositions() {
return positions;
}
@Override
public void fromBytes(ByteBuf buf) {
positions = ProtoUtils.readPositions(buf);
}
@Override
public void toBytes(ByteBuf buf) {
ProtoUtils.writePositions(buf, positions);
}
public static class Handler implements IMessageHandler<BlockFoundResponse, IMessage> {
@SideOnly(Side.CLIENT)
@Override
public IMessage onMessage(BlockFoundResponse message, MessageContext ctx) {
ClientBlockFindService.getInstance().handleResponse(Minecraft.getMinecraft().thePlayer, message);
return null;
}
}
}
@@ -0,0 +1,88 @@
package com.gtnh.findit.service.blockfinder;
import static com.gtnh.findit.util.ClientFinderHelperUtils.lookAtTarget;
import net.minecraft.block.Block;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.input.Keyboard;
import com.gtnh.findit.FindIt;
import com.gtnh.findit.FindItConfig;
import com.gtnh.findit.FindItNetwork;
import com.gtnh.findit.fx.BlockHighlighter;
import com.gtnh.findit.fx.ParticlePosition;
import com.gtnh.findit.util.AbstractStackFinder;
import codechicken.nei.api.API;
import codechicken.nei.guihook.GuiContainerManager;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class ClientBlockFindService extends BlockFindService {
private final BlockHighlighter blockHighlighter;
public ClientBlockFindService() {
this.blockHighlighter = new BlockHighlighter();
API.addHashBind("gui.findit.find_block", Keyboard.KEY_Y);
GuiContainerManager.addInputHandler(new BlockFindInputHandler());
MinecraftForge.EVENT_BUS.register(new WorldRenderListener());
}
public void handleResponse(EntityClientPlayerMP player, BlockFoundResponse response) {
if (!response.getPositions().isEmpty()) {
player.closeScreen();
if (FindItConfig.ENABLE_ROTATE_VIEW) {
lookAtTarget(player, response);
}
}
if (FindItConfig.USE_PARTICLE_HIGHLIGHTER) {
ParticlePosition.highlightBlocks(player.worldObj, response.getPositions());
} else {
this.blockHighlighter.highlightBlocks(
response.getPositions(),
System.currentTimeMillis() + FindItConfig.BLOCK_HIGHLIGHTING_DURATION * 1000L);
}
}
public class WorldRenderListener {
@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event) {
blockHighlighter.renderHighlightedBlock(event);
}
}
private static class BlockFindInputHandler extends AbstractStackFinder {
@Override
protected String getKeyBindId() {
return "gui.findit.find_block";
}
@Override
protected boolean findStack(ItemStack stack) {
Block block = Block.getBlockFromItem(stack.getItem());
if (block == Blocks.air) {
return false;
}
FindItNetwork.CHANNEL.sendToServer(new FindBlockRequest(block, stack.getItemDamage()));
return true;
}
}
public static ClientBlockFindService getInstance() {
return (ClientBlockFindService) FindIt.getBlockFindService();
}
}
@@ -0,0 +1,55 @@
package com.gtnh.findit.service.blockfinder;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import com.gtnh.findit.FindIt;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
public class FindBlockRequest implements IMessage {
private Block blockToFind;
private int metaToFind;
public FindBlockRequest(Block block, int meta) {
this.blockToFind = block;
this.metaToFind = meta;
}
public FindBlockRequest() {}
@Override
public void fromBytes(ByteBuf buf) {
blockToFind = Block.getBlockById(buf.readShort());
metaToFind = buf.readShort();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeShort(Block.getIdFromBlock(blockToFind));
buf.writeShort(metaToFind);
}
public Block getBlockToFind() {
return blockToFind;
}
public int getMetaToFind() {
return metaToFind;
}
public static class Handler implements IMessageHandler<FindBlockRequest, BlockFoundResponse> {
@Override
public BlockFoundResponse onMessage(FindBlockRequest message, MessageContext ctx) {
if (message.blockToFind != null && message.blockToFind != Blocks.air) {
FindIt.getBlockFindService().handleRequest(ctx.getServerHandler().playerEntity, message);
}
return null;
}
}
}
@@ -0,0 +1,26 @@
package com.gtnh.findit.service.cooldown;
import java.util.WeakHashMap;
import net.minecraft.entity.player.EntityPlayerMP;
import com.gtnh.findit.FindItConfig;
public class SearchCooldownService {
private final WeakHashMap<EntityPlayerMP, Long> lastSearchTime = new WeakHashMap<>();
/**
* @return true if player has active cooldown
*/
public boolean checkSearchCooldown(EntityPlayerMP player) {
long time = player.getServerForPlayer().func_73046_m().getTickCounter();
Long lastTime = lastSearchTime.get(player);
if (lastTime != null && time - lastTime < FindItConfig.SEARCH_COOLDOWN) {
return true;
}
lastSearchTime.put(player, time);
return false;
}
}
@@ -0,0 +1,170 @@
package com.gtnh.findit.service.itemfinder;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.input.Keyboard;
import com.gtnh.findit.FindIt;
import com.gtnh.findit.FindItConfig;
import com.gtnh.findit.FindItNetwork;
import com.gtnh.findit.fx.EntityHighlighter;
import com.gtnh.findit.fx.SlotHighlighter;
import com.gtnh.findit.util.AbstractStackFinder;
import codechicken.nei.api.API;
import codechicken.nei.event.NEIConfigsLoadedEvent;
import codechicken.nei.guihook.GuiContainerManager;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
public class ClientItemFindService extends ItemFindService {
private final SlotHighlighter slotHighlighter;
private final EntityHighlighter itemEntitiesHighlighter;
private FindItemRequest foundItem = null;
private long expirationTime = 0;
public ClientItemFindService() {
if (!FindIt.isExtraUtilitiesLoaded()) {
API.addHashBind("gui.findit.find_item", Keyboard.KEY_T);
}
this.slotHighlighter = new SlotHighlighter();
this.itemEntitiesHighlighter = new EntityHighlighter();
GuiContainerManager.addDrawHandler(this.slotHighlighter);
GuiContainerManager.addInputHandler(new ItemFindInputHandler());
MinecraftForge.EVENT_BUS.register(new NEIEventListener());
MinecraftForge.EVENT_BUS.register(new WorldRenderListener());
FMLCommonHandler.instance().bus().register(new TickListener());
}
public void handleResponse(EntityClientPlayerMP player, ItemFoundResponse response) {
this.slotHighlighter.highlightSlots(null, new HashSet<>(), 0xFFFF8726);
this.foundItem = response.getFoundStack() != null ? new FindItemRequest(response.getFoundStack()) : null;
this.expirationTime = System.currentTimeMillis() + FindItConfig.ITEM_HIGHLIGHTING_DURATION * 1000L;
if (foundItem == null || !FindItConfig.SEARCH_ITEMS_ON_GROUND) {
return;
}
int searchRadius = FindItConfig.SEARCH_RADIUS;
AxisAlignedBB searchBox = AxisAlignedBB
.getBoundingBox(player.posX, player.posY, player.posZ, player.posX, player.posY, player.posZ)
.expand(searchRadius, searchRadius, searchRadius);
@SuppressWarnings("unchecked")
List<EntityItem> itemEntities = player.worldObj.getEntitiesWithinAABB(EntityItem.class, searchBox);
List<Integer> foundItemEntities = new ArrayList<>();
for (EntityItem itemEntity : itemEntities) {
if (foundItem.isStackSatisfies(itemEntity.getEntityItem())) {
foundItemEntities.add(itemEntity.getEntityId());
if (foundItemEntities.size() >= FindItConfig.MAX_RESPONSE_SIZE) {
break;
}
}
}
this.itemEntitiesHighlighter.highlightEntities(foundItemEntities, expirationTime);
}
public class TickListener {
@SubscribeEvent
public void onClientPostTick(TickEvent.ClientTickEvent event) {
if (foundItem == null || event.phase != TickEvent.Phase.END) {
return;
}
if (Minecraft.getMinecraft().theWorld == null) {
return;
}
final GuiScreen screen = Minecraft.getMinecraft().currentScreen;
if (!(screen instanceof GuiContainer)) {
return;
}
final GuiContainer gui = (GuiContainer) screen;
final HashSet<Slot> highlightedSlots = new HashSet<>();
if (System.currentTimeMillis() > expirationTime) {
foundItem = null;
}
if (foundItem != null) {
@SuppressWarnings("unchecked")
List<Slot> slots = gui.inventorySlots.inventorySlots;
for (Slot slot : slots) {
if (!(slot.inventory instanceof InventoryPlayer) && foundItem.isStackSatisfies(slot.getStack())) {
highlightedSlots.add(slot);
if (highlightedSlots.size() > 256) {
break;
}
}
}
}
slotHighlighter.highlightSlots(gui, highlightedSlots, 0xFFFF8726);
}
}
public class WorldRenderListener {
@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event) {
itemEntitiesHighlighter.renderHighlightedEntities(event);
}
}
private static class ItemFindInputHandler extends AbstractStackFinder {
@Override
protected String getKeyBindId() {
return FindIt.isExtraUtilitiesLoaded() ? "gui.xu_ping" : "gui.findit.find_item";
}
@Override
protected boolean findStack(ItemStack stack) {
FindItNetwork.CHANNEL.sendToServer(new FindItemRequest(stack));
return true;
}
}
public static class NEIEventListener {
@SubscribeEvent
public void onNEIConfigsLoaded(NEIConfigsLoadedEvent event) {
if (FindIt.isExtraUtilitiesLoaded()) {
GuiContainerManager.inputHandlers.removeIf(
(inputHandler) -> inputHandler.getClass().getName()
.equals("com.rwtema.extrautils.nei.ping.NEIPing"));
}
}
}
public static ClientItemFindService getInstance() {
return (ClientItemFindService) FindIt.getItemFindService();
}
}
@@ -0,0 +1,76 @@
package com.gtnh.findit.service.itemfinder;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.gtnh.findit.FindIt;
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
import com.gtnh.findit.util.ProtoUtils;
import codechicken.nei.recipe.StackInfo;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
public class FindItemRequest implements IMessage {
private ItemStack targetStack;
private FluidStack targetFluidStack;
public FindItemRequest(ItemStack targetStack) {
this.targetStack = targetStack;
this.targetFluidStack = StackInfo.getFluid(targetStack);
}
public FindItemRequest() {}
@Override
public void fromBytes(ByteBuf buf) {
targetStack = ProtoUtils.readItemStack(buf);
targetFluidStack = StackInfo.getFluid(targetStack);
}
@Override
public void toBytes(ByteBuf buf) {
ProtoUtils.writeItemStack(buf, targetStack);
}
public ItemStack getStackToFind() {
return targetStack;
}
public boolean hasFluidStack() {
return targetFluidStack != null;
}
public boolean isFluidSatisfies(FluidStack fluid) {
if (fluid != null && targetFluidStack != null) {
return targetFluidStack.isFluidEqual(fluid);
}
return false;
}
public boolean isStackSatisfies(ItemStack stack) {
if (stack == null) {
return false;
}
if (hasFluidStack()) {
return targetFluidStack.isFluidEqual(StackInfo.getFluid(stack));
}
return StackInfo.equalItemAndNBT(targetStack, stack, true);
}
public static class Handler implements IMessageHandler<FindItemRequest, BlockFoundResponse> {
@Override
public BlockFoundResponse onMessage(FindItemRequest message, MessageContext ctx) {
if (message.targetStack != null) {
FindIt.getItemFindService().handleRequest(ctx.getServerHandler().playerEntity, message);
}
return null;
}
}
}
@@ -0,0 +1,95 @@
package com.gtnh.findit.service.itemfinder;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.ChunkPosition;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.IFluidTank;
import com.gtnh.findit.FindIt;
import com.gtnh.findit.FindItConfig;
import com.gtnh.findit.FindItNetwork;
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
import com.gtnh.findit.util.WorldUtils;
import cpw.mods.fml.relauncher.Side;
import crazypants.enderio.conduit.TileConduitBundle;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
public class ItemFindService {
public ItemFindService() {
FindItNetwork.registerMessage(FindItemRequest.Handler.class, FindItemRequest.class, Side.SERVER);
FindItNetwork.registerMessage(ItemFoundResponse.Handler.class, ItemFoundResponse.class, Side.CLIENT);
}
public void handleRequest(EntityPlayerMP player, FindItemRequest request) {
if (FindIt.getCooldownService().checkSearchCooldown(player)) {
return;
}
List<ChunkPosition> positions = new ArrayList<>();
for (TileEntity tileEntity : WorldUtils.getTileEntitiesAround(player, FindItConfig.SEARCH_RADIUS)) {
try {
if (findItemInTile(tileEntity, request)) {
positions.add(new ChunkPosition(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
if (positions.size() == FindItConfig.MAX_RESPONSE_SIZE) {
break;
}
}
} catch (NullPointerException e) {
e.printStackTrace();
}
}
FindItNetwork.CHANNEL.sendTo(new BlockFoundResponse(positions), player);
FindItNetwork.CHANNEL.sendTo(new ItemFoundResponse(request.getStackToFind()), player);
}
private boolean findItemInTile(TileEntity tileEntity, FindItemRequest request) {
if (FindIt.isGregTechLoaded()) {
if (!FindItConfig.SEARCH_IN_GT_PIPES && tileEntity instanceof BaseMetaPipeEntity) {
return false;
}
}
if (FindIt.isEnderIOLoaded()) {
if (!FindItConfig.SEARCH_IN_ENDERIO_CONDUITS && tileEntity instanceof TileConduitBundle) {
return false;
}
}
if (request.hasFluidStack()) {
if (tileEntity instanceof IFluidTank && request.isFluidSatisfies(((IFluidTank) tileEntity).getFluid())) {
return true;
}
if (tileEntity instanceof IFluidHandler) {
FluidTankInfo[] tankInfo = ((IFluidHandler) tileEntity).getTankInfo(ForgeDirection.UNKNOWN);
for (FluidTankInfo info : tankInfo) {
if (request.isFluidSatisfies(info.fluid)) {
return true;
}
}
}
}
if (tileEntity instanceof IInventory) {
IInventory inventory = (IInventory) tileEntity;
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
if (request.isStackSatisfies(inventory.getStackInSlot(slot))) {
return true;
}
}
}
return false;
}
}
@@ -0,0 +1,49 @@
package com.gtnh.findit.service.itemfinder;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import com.gtnh.findit.util.ProtoUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
public class ItemFoundResponse implements IMessage {
private ItemStack foundStack;
public ItemFoundResponse(ItemStack foundStack) {
this.foundStack = foundStack;
}
public ItemFoundResponse() {}
@Override
public void fromBytes(ByteBuf buf) {
foundStack = ProtoUtils.readItemStack(buf);
}
@Override
public void toBytes(ByteBuf buf) {
ProtoUtils.writeItemStack(buf, foundStack);
}
public ItemStack getFoundStack() {
return foundStack;
}
public static class Handler implements IMessageHandler<ItemFoundResponse, IMessage> {
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(ItemFoundResponse message, MessageContext ctx) {
ClientItemFindService.getInstance().handleResponse(Minecraft.getMinecraft().thePlayer, message);
return null;
}
}
}
@@ -0,0 +1,59 @@
package com.gtnh.findit.util;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerInputHandler;
public abstract class AbstractStackFinder implements IContainerInputHandler {
protected abstract String getKeyBindId();
protected abstract boolean findStack(ItemStack stack);
@Override
public boolean keyTyped(GuiContainer window, char c, int key) {
return false;
}
@Override
public void onKeyTyped(GuiContainer guiContainer, char c, int i) {}
@Override
public boolean lastKeyTyped(GuiContainer guiContainer, char c, int i) {
if (!NEIClientConfig.isKeyHashDown(getKeyBindId())) {
return false;
}
ItemStack stack = GuiContainerManager.getStackMouseOver(guiContainer);
if (stack == null || stack.getItem() == null) {
return false;
}
return findStack(stack);
}
@Override
public boolean mouseClicked(GuiContainer guiContainer, int i, int i1, int i2) {
return false;
}
@Override
public void onMouseClicked(GuiContainer guiContainer, int i, int i1, int i2) {}
@Override
public void onMouseUp(GuiContainer guiContainer, int i, int i1, int i2) {}
@Override
public boolean mouseScrolled(GuiContainer guiContainer, int i, int i1, int i2) {
return false;
}
@Override
public void onMouseScrolled(GuiContainer guiContainer, int i, int i1, int i2) {}
@Override
public void onMouseDragged(GuiContainer guiContainer, int i, int i1, int i2, long l) {}
}
@@ -0,0 +1,66 @@
package com.gtnh.findit.util;
import java.util.List;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkPosition;
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
public class ClientFinderHelperUtils {
public static void lookAtTarget(EntityClientPlayerMP player, BlockFoundResponse response) {
rotateViewHelper(player, response.getPositions());
}
public static void rotateViewHelper(EntityClientPlayerMP player, List<ChunkPosition> targets) {
if (targets.isEmpty()) {
return;
}
Vec3 eyesPos = player.getPosition(1.0F);
Vec3 nearestPos = center(getNearBlock(eyesPos, targets));
Rotation targetRotation = Rotation.lookAt(eyesPos, nearestPos);
targetRotation.apply(player);
}
public static Vec3 center(ChunkPosition p) {
return Vec3.createVectorHelper(p.chunkPosX + 0.5, p.chunkPosY + 0.5, p.chunkPosZ + 0.5);
}
private static ChunkPosition getNearBlock(Vec3 player, List<ChunkPosition> targets) {
ChunkPosition result = null;
double minDistance = Double.MAX_VALUE;
for (ChunkPosition target : targets) {
double distance = getDistanceToCenter(player, target);
if (distance < minDistance) {
result = target;
minDistance = distance;
}
}
return result;
}
private static double getDistanceToCenter(Vec3 player, ChunkPosition target) {
double deltaX = target.chunkPosX + 0.5 - player.xCoord;
double deltaY = target.chunkPosY + 0.5 - player.yCoord;
double deltaZ = target.chunkPosZ + 0.5 - player.zCoord;
return Math.sqrt(deltaX * deltaX + deltaZ * deltaZ + deltaY * deltaY);
}
public static AxisAlignedBB mergeAABB(AxisAlignedBB box1, AxisAlignedBB box2) {
return AxisAlignedBB.getBoundingBox(
Math.min(box1.minX, box2.minX),
Math.min(box1.minY, box2.minY),
Math.min(box1.minZ, box2.minZ),
Math.max(box1.maxX, box2.maxX),
Math.max(box1.maxY, box2.maxY),
Math.max(box1.maxZ, box2.maxZ));
}
}
@@ -0,0 +1,55 @@
package com.gtnh.findit.util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.world.ChunkPosition;
import io.netty.buffer.ByteBuf;
public class ProtoUtils {
public static void writePositions(ByteBuf buf, List<ChunkPosition> positions) {
buf.writeInt(positions.size());
for (ChunkPosition pos : positions) {
buf.writeInt(pos.chunkPosX);
buf.writeByte(pos.chunkPosY);
buf.writeInt(pos.chunkPosZ);
}
}
public static void writeItemStack(ByteBuf buf, ItemStack stack) {
PacketBuffer packetBuffer = new PacketBuffer(buf);
try {
packetBuffer.writeItemStackToBuffer(stack);
} catch (IOException e) {
e.printStackTrace();
}
}
public static List<ChunkPosition> readPositions(ByteBuf buf) {
int amount = buf.readInt();
List<ChunkPosition> positions = new ArrayList<>();
while (amount > 0) {
final int x = buf.readInt();
final int y = buf.readUnsignedByte();
final int z = buf.readInt();
positions.add(new ChunkPosition(x, y, z));
--amount;
}
return positions;
}
public static ItemStack readItemStack(ByteBuf buf) {
PacketBuffer packetBuffer = new PacketBuffer(buf);
try {
return packetBuffer.readItemStackFromBuffer();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
@@ -0,0 +1,41 @@
package com.gtnh.findit.util;
import net.minecraft.entity.Entity;
import net.minecraft.util.Vec3;
public class Rotation {
private final float yaw;
private final float pitch;
public Rotation(float yaw, float pitch) {
this.yaw = yaw;
this.pitch = pitch;
}
public float yaw() {
return yaw;
}
public float pitch() {
return pitch;
}
public void apply(Entity entity) {
entity.rotationYaw = yaw;
entity.rotationPitch = pitch;
}
public static Rotation lookAt(Vec3 source, Vec3 target) {
double deltaX = target.xCoord - source.xCoord;
double deltaY = target.yCoord - source.yCoord;
double deltaZ = target.zCoord - source.zCoord;
double distanceXZ = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
float yaw = (float) Math.toDegrees(Math.atan2(-deltaX, deltaZ));
float pitch = (float) Math.toDegrees(Math.atan2(-deltaY, distanceXZ));
return new Rotation(yaw, pitch);
}
}
@@ -0,0 +1,54 @@
package com.gtnh.findit.util;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
public class WorldUtils {
public static List<TileEntity> getTileEntitiesAround(Entity entity, int r) {
int x = (int) Math.floor(entity.posX);
int y = (int) entity.posY;
int z = (int) Math.floor(entity.posZ);
return getTileEntitiesInRegion(entity.worldObj, x - r, y - r, z - r, x + r + 1, y + r + 1, z + r + 1);
}
/**
* @param (x1,y1,z1) included
* @param (x2,y2,z2) excluded
*/
public static List<TileEntity> getTileEntitiesInRegion(World world, int x1, int y1, int z1, int x2, int y2,
int z2) {
List<TileEntity> result = new ArrayList<>();
int cx1 = x2 >> 4;
int cz1 = z2 >> 4;
for (int cx = x1 >> 4; cx <= cx1; cx++) {
for (int cz = z1 >> 4; cz <= cz1; cz++) {
Chunk chunk = world.getChunkFromChunkCoords(cx, cz);
if (chunk != null) {
@SuppressWarnings("unchecked")
Map<ChunkPosition, TileEntity> tiles = chunk.chunkTileEntityMap;
for (TileEntity tile : tiles.values()) {
if (!tile.isInvalid() && tile.xCoord >= x1
&& tile.xCoord < x2
&& tile.yCoord >= y1
&& tile.yCoord < y2
&& tile.zCoord >= z1
&& tile.zCoord < z2) {
result.add(tile);
}
}
}
}
}
return result;
}
}
@@ -0,0 +1,4 @@
public net.minecraft.client.gui.inventory.GuiContainer field_147003_i #guiLeft
public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop
public net.minecraft.inventory.InventoryLargeChest field_70477_b #upperChest
public net.minecraft.inventory.InventoryLargeChest field_70478_c #lowerChest
@@ -0,0 +1,3 @@
nei.options.keys.gui.findit=Find-It Keys
nei.options.keys.gui.findit.find_block=Search For Block Nearby
nei.options.keys.gui.findit.find_item=Search For Item In Nearby Inventories
@@ -0,0 +1,3 @@
nei.options.keys.gui.findit=Find-It клавиши
nei.options.keys.gui.findit.find_block=Поиск блока поблизости
nei.options.keys.gui.findit.find_item=Поиск предмета в инвентарях поблизости
@@ -0,0 +1,4 @@
nei.options.keys.gui.findit=搜索世界
nei.options.keys.gui.findit.find_block=搜索附近的方块
nei.options.keys.gui.findit.find_item=搜索附近库存中的物品
Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

@@ -1 +0,0 @@
nei.options.keys.gui.findit=Search the world
+12 -15
View File
@@ -1,20 +1,17 @@
[
{
"modid": "findit",
"name": "FindIt",
{
"modListVersion": 2,
"modList": [{
"modid": "${modId}",
"name": "${modName}",
"description": "Now where did I put that EV mixer...",
"version": "${version}",
"mcversion": "${mcversion}",
"url": "",
"version": "${modVersion}",
"mcversion": "${minecraftVersion}",
"url": "https://github.com/GTNewHorizons/FindIt",
"updateUrl": "",
"authorList": [
"mitchej123"
],
"authorList": ["mitchej123"],
"credits": "Heavily inspired from Buuz135/findme",
"logoFile": "",
"screenshots": [],
"dependencies": [
"NotEnoughItems"
]
}
]
"parent": ""
}]
}