mirror of
https://github.com/GTNewHorizons/FindIt.git
synced 2026-11-24 18:24:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2961c8ad9e | ||
|
|
63b1fc85ec |
No files matched your search
@@ -3,9 +3,9 @@ name: Build and test
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master, main, release/** ]
|
branches: [ master, main ]
|
||||||
push:
|
push:
|
||||||
branches: [ master, main, release/** ]
|
branches: [ master, main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-and-test:
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
name: Optimize images
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: [ master, main, release/** ]
|
|
||||||
paths:
|
|
||||||
- "**/*.png"
|
|
||||||
|
|
||||||
push:
|
|
||||||
branches: [ master, main, release/** ]
|
|
||||||
paths:
|
|
||||||
- "**/*.png"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
optimize-images:
|
|
||||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
|
|
||||||
secrets: inherit
|
|
||||||
@@ -29,4 +29,3 @@ src/main/resources/mixins.*.json
|
|||||||
*.bat
|
*.bat
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
!gradlew.bat
|
!gradlew.bat
|
||||||
layout.json
|
|
||||||
@@ -1,22 +1,8 @@
|
|||||||
# FindIt
|
# FindIt
|
||||||
##### For those times when you just can't remember where you placed your EV Mixer!
|
##### For those times when you just can't remember where you placed your EV Mixer!
|
||||||
|
|
||||||
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). As well as searching for items and fluids in inventories, FindIt will also search the world for placed tile entities!
|
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?
|
Did you forget where you placed your EV Mixer?
|
||||||
|
|
||||||
Well, no problem now! Locate the item in NEI, hover over it, and hit 'Y' (the default keybind). If it's within range (+/-16 blocks), an outline will flash around it for you to locate it!
|
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!
|
||||||
|
|
||||||
Dependencies:
|
|
||||||
[NotEnoughItems](https://github.com/GTNewHorizons/NotEnoughItems)
|
|
||||||
[GTNHLib](https://github.com/GTNewHorizons/GTNHLib)
|
|
||||||
|
|
||||||
FindIt has special support for the following mods' containers:
|
|
||||||
* [AdventureBackpack](https://github.com/GTNewHorizons/AdventureBackpack2): Finds items and fluids inside backpacks when inside another container.
|
|
||||||
* [Minecraft Backpack Mod](https://github.com/GTNewHorizons/Minecraft-Backpack-Mod/): Finds items inside backpacks when inside another container.
|
|
||||||
* [Forestry](https://github.com/GTNewHorizons/ForestryMC): Finds items inside backpacks when inside another container.
|
|
||||||
* [ProjectRedExploration](https://github.com/GTNewHorizons/ProjectRed): Finds items inside backpacks when inside another container.
|
|
||||||
* [Draconic Evolution](https://github.com/GTNewHorizons/Draconic-Evolution/): Finds placed items.
|
|
||||||
* [Thaumcraft 4](https://www.curseforge.com/minecraft/mc-mods/thaumcraft/files/2227552): Finds essentia in placed containers.
|
|
||||||
* [Aspect Recipe Index](https://github.com/GTNewHorizons/AspectRecipeIndex): Also finds essentia when trying to "find" its aspect items.
|
|
||||||
* [Thaumcraft NEI Plugin](https://www.curseforge.com/minecraft/mc-mods/thaumcraft-nei-plugin) Also finds essentia when trying to "find" its aspect items.
|
|
||||||
+2
-23
@@ -1,27 +1,6 @@
|
|||||||
// Add your dependencies here
|
// Add your dependencies here
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.121-GTNH:dev")
|
implementation('com.github.GTNewHorizons:NotEnoughItems:2.5.23-GTNH:dev')
|
||||||
implementation("com.github.GTNewHorizons:GTNHLib:0.11.37:dev")
|
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.84:dev')
|
||||||
|
|
||||||
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.54.80:dev")
|
|
||||||
compileOnly("com.github.GTNewHorizons:EnderIO:2.10.36:dev")
|
|
||||||
compileOnly("com.github.GTNewHorizons:Draconic-Evolution:1.5.31-GTNH:dev")
|
|
||||||
compileOnly("com.github.GTNewHorizons:ForestryMC:4.11.34:dev")
|
|
||||||
compileOnly("com.github.GTNewHorizons:AdventureBackpack2:1.4.23-GTNH:dev")
|
|
||||||
compileOnly("com.github.GTNewHorizons:ProjectRed:4.12.41-GTNH:dev")
|
|
||||||
compileOnly("com.github.GTNewHorizons:Minecraft-Backpack-Mod:2.6.16-GTNH:dev")
|
|
||||||
compileOnly("curse.maven:thaumcraft-nei-plugin-225095:2241913")
|
|
||||||
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
|
|
||||||
compileOnly("com.github.GTNewHorizons:AspectRecipeIndex:1.1.3:dev")
|
|
||||||
compileOnly("net.xonich.mc:NoHotbarNeeded:0.0.3:dev")
|
|
||||||
|
|
||||||
// For testing in dev environment.
|
|
||||||
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:StorageDrawers:2.2.28-GTNH")
|
|
||||||
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:waila:1.19.31")
|
|
||||||
// runtimeOnlyNonPublishable("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
|
|
||||||
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:Baubles-Expanded:2.2.22-GTNH:dev")
|
|
||||||
// runtimeOnlyNonPublishable(rfg.deobf("curse.maven:thaumcraft-nei-plugin-225095:2241913"))
|
|
||||||
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:AspectRecipeIndex:1.1.3:dev")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+7
-53
@@ -14,7 +14,7 @@ modId = findit
|
|||||||
modGroup = com.gtnh.findit
|
modGroup = com.gtnh.findit
|
||||||
|
|
||||||
# Whether to use modGroup as the maven publishing group.
|
# Whether to use modGroup as the maven publishing group.
|
||||||
# When false, com.github.GTNewHorizons is used.
|
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
|
||||||
useModGroupForPublishing = false
|
useModGroupForPublishing = false
|
||||||
|
|
||||||
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
||||||
@@ -39,33 +39,9 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
|
|||||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||||
developmentEnvironmentUserName = Developer
|
developmentEnvironmentUserName = Developer
|
||||||
|
|
||||||
# Enables modern Java syntax support. Valid values:
|
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||||
# - false: No modern syntax, Java 8 only
|
# See https://github.com/bsideup/jabel for details on how this works.
|
||||||
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
|
enableModernJavaSyntax = true
|
||||||
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
|
|
||||||
# - modern: Native modern Java bytecode, no downgrading
|
|
||||||
enableModernJavaSyntax = jabel
|
|
||||||
|
|
||||||
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
|
|
||||||
# and should *not* be used in most situations. -1 disables this.
|
|
||||||
# forceToolchainVersion = -1
|
|
||||||
|
|
||||||
# Target JVM version for JVM Downgrader bytecode downgrading.
|
|
||||||
# Only used when enableModernJavaSyntax = jvmDowngrader
|
|
||||||
# downgradeTargetVersion = 8
|
|
||||||
|
|
||||||
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
|
|
||||||
# Classes will be available in META-INF/versions/N/ for each version N in this list.
|
|
||||||
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
|
|
||||||
# jvmDowngraderMultiReleaseVersions = 21,25
|
|
||||||
|
|
||||||
# Specifies how JVM Downgrader API stubs are provided. Options:
|
|
||||||
# - shade: Shade minimized stubs into the jar
|
|
||||||
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
|
|
||||||
# - external: Another dependency provides stubs (no constraint, no warning)
|
|
||||||
# - (empty): Warning reminding you to configure stubs
|
|
||||||
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
|
|
||||||
# jvmDowngraderStubsProvider =
|
|
||||||
|
|
||||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
# 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.
|
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||||
@@ -109,20 +85,13 @@ accessTransformersFile = findit_at.cfg
|
|||||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||||
usesMixins = false
|
usesMixins = false
|
||||||
|
|
||||||
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
|
|
||||||
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
|
|
||||||
# Mixin classes will have access to "main" classes, but not the other way around.
|
|
||||||
separateMixinSourceSet =
|
|
||||||
|
|
||||||
# Adds some debug arguments like verbose output and class export.
|
# Adds some debug arguments like verbose output and class export.
|
||||||
usesMixinDebug = false
|
usesMixinDebug = false
|
||||||
|
|
||||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||||
mixinPlugin =
|
mixinPlugin =
|
||||||
|
|
||||||
# Specify the package that contains all of your Mixins. The package must exist or
|
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||||
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
|
||||||
# it must match with this or the build will fail.
|
|
||||||
mixinsPackage =
|
mixinsPackage =
|
||||||
|
|
||||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||||
@@ -148,15 +117,9 @@ minimizeShadowedDependencies = true
|
|||||||
# If disabled, won't rename the shadowed classes.
|
# If disabled, won't rename the shadowed classes.
|
||||||
relocateShadowedDependencies = true
|
relocateShadowedDependencies = true
|
||||||
|
|
||||||
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
|
# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories.
|
||||||
includeWellKnownRepositories = true
|
includeWellKnownRepositories = true
|
||||||
|
|
||||||
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
|
|
||||||
# list of strings, with the acceptable keys being(case does not matter):
|
|
||||||
# cursemaven
|
|
||||||
# modrinth
|
|
||||||
excludeWellKnownRepositories =
|
|
||||||
|
|
||||||
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
|
# 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.
|
# 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.
|
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
|
||||||
@@ -177,7 +140,7 @@ modrinthProjectId =
|
|||||||
# type can be one of [project, version],
|
# type can be one of [project, version],
|
||||||
# and the name is the Modrinth project or version slug/id of the other mod.
|
# 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
|
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
|
||||||
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
||||||
modrinthRelations =
|
modrinthRelations =
|
||||||
|
|
||||||
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
||||||
@@ -198,12 +161,6 @@ curseForgeRelations =
|
|||||||
# projects. New projects should not use this parameter.
|
# projects. New projects should not use this parameter.
|
||||||
# customArchiveBaseName =
|
# customArchiveBaseName =
|
||||||
|
|
||||||
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
|
|
||||||
# runClientWorkingDirectory = run/client
|
|
||||||
|
|
||||||
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
|
|
||||||
# runServerWorkingDirectory = run/server
|
|
||||||
|
|
||||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
# 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'.
|
# 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.
|
# The check is ONLY performed if the version is a git tag.
|
||||||
@@ -233,6 +190,3 @@ curseForgeRelations =
|
|||||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||||
# ideaCheckSpotlessOnBuild = true
|
# ideaCheckSpotlessOnBuild = true
|
||||||
|
|
||||||
# Non-GTNH properties
|
|
||||||
org.gradle.configuration-cache = true
|
|
||||||
org.gradle.parallel = true
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#This file is generated by updateDaemonJvm
|
|
||||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/97d46b5ff4df0bf61e95652a190a5567/redirect
|
|
||||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/9ef54a08e06b0754cee9fc95ed3a3134/redirect
|
|
||||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/97d46b5ff4df0bf61e95652a190a5567/redirect
|
|
||||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/9ef54a08e06b0754cee9fc95ed3a3134/redirect
|
|
||||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1df82b76031285ef2e6a4f59ffe9299d/redirect
|
|
||||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/c7d5be6a02945ac2e045048ee54a7d32/redirect
|
|
||||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/97d46b5ff4df0bf61e95652a190a5567/redirect
|
|
||||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/9ef54a08e06b0754cee9fc95ed3a3134/redirect
|
|
||||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/643f404f769811f5f265fd66f7af5d89/redirect
|
|
||||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/38256085a73e137cb4937ea9c4807fec/redirect
|
|
||||||
toolchainVersion=25
|
|
||||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015 the original authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -15,8 +15,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@@ -57,7 +55,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -86,7 +84,7 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -114,6 +112,7 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@@ -171,6 +170,7 @@ fi
|
|||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if "$cygwin" || "$msys" ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
@@ -203,14 +203,15 @@ fi
|
|||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command:
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# and any embedded shellness will be escaped.
|
# 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
|
# * 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.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
# Stop when "xargs" is not available.
|
||||||
|
|||||||
Vendored
+2
-3
@@ -13,8 +13,6 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
@rem SPDX-License-Identifier: Apache-2.0
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@@ -70,10 +68,11 @@ goto fail
|
|||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.29'
|
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.15'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +1,5 @@
|
|||||||
package com.gtnh.findit;
|
package com.gtnh.findit;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.gtnewhorizon.gtnhlib.config.ConfigException;
|
|
||||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
import com.gtnh.findit.handler.AdventureBackpackProvider;
|
|
||||||
import com.gtnh.findit.handler.BackpackProvider;
|
|
||||||
import com.gtnh.findit.handler.DraconicEvolutionProvider;
|
|
||||||
import com.gtnh.findit.handler.ForestryStackFilterProvider;
|
|
||||||
import com.gtnh.findit.handler.GregTechCoverChestProvider;
|
|
||||||
import com.gtnh.findit.handler.GregTechCoverProvider;
|
|
||||||
import com.gtnh.findit.handler.MinecraftProvider;
|
|
||||||
import com.gtnh.findit.handler.ProjectRedExplorationProvider;
|
|
||||||
import com.gtnh.findit.handler.ThaumcraftProvider;
|
|
||||||
import com.gtnh.findit.service.blockfinder.BlockFindService;
|
import com.gtnh.findit.service.blockfinder.BlockFindService;
|
||||||
import com.gtnh.findit.service.blockfinder.ClientBlockFindService;
|
import com.gtnh.findit.service.blockfinder.ClientBlockFindService;
|
||||||
import com.gtnh.findit.service.cooldown.SearchCooldownService;
|
import com.gtnh.findit.service.cooldown.SearchCooldownService;
|
||||||
@@ -43,66 +28,23 @@ public class FindIt {
|
|||||||
@Mod.Instance(MOD_ID)
|
@Mod.Instance(MOD_ID)
|
||||||
public static FindIt INSTANCE;
|
public static FindIt INSTANCE;
|
||||||
|
|
||||||
private boolean isEnderIOLoaded;
|
private boolean extraUtilitiesLoaded;
|
||||||
private boolean isExtraUtilitiesLoaded;
|
private boolean gregTechloaded;
|
||||||
private boolean isGregTechLoaded;
|
|
||||||
|
|
||||||
private SearchCooldownService cooldownService;
|
private SearchCooldownService cooldownService;
|
||||||
private BlockFindService blockFindService;
|
private BlockFindService blockFindService;
|
||||||
private ItemFindService itemFindService;
|
private ItemFindService itemFindService;
|
||||||
|
|
||||||
public final List<IStackFilterProvider> pluginsList = new ArrayList<>();
|
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
this.isExtraUtilitiesLoaded = Loader.isModLoaded("ExtraUtilities");
|
this.extraUtilitiesLoaded = Loader.isModLoaded("ExtraUtilities");
|
||||||
this.isGregTechLoaded = Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi");
|
this.gregTechloaded = Loader.isModLoaded("gregtech");
|
||||||
this.isEnderIOLoaded = Loader.isModLoaded("EnderIO");
|
FindItConfig.setup(event.getSuggestedConfigurationFile());
|
||||||
|
boolean isClient = event.getSide() == Side.CLIENT;
|
||||||
|
|
||||||
this.cooldownService = new SearchCooldownService();
|
this.cooldownService = new SearchCooldownService();
|
||||||
try {
|
this.blockFindService = isClient ? new ClientBlockFindService() : new BlockFindService();
|
||||||
ConfigurationManager.registerConfig(FindItConfig.class);
|
this.itemFindService = isClient ? new ClientItemFindService() : new ItemFindService();
|
||||||
} catch (ConfigException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getSide() == Side.CLIENT) {
|
|
||||||
this.blockFindService = new ClientBlockFindService();
|
|
||||||
this.itemFindService = new ClientItemFindService();
|
|
||||||
} else {
|
|
||||||
this.blockFindService = new BlockFindService();
|
|
||||||
this.itemFindService = new ItemFindService();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Loader.isModLoaded("Forestry")) {
|
|
||||||
this.pluginsList.add(new ForestryStackFilterProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Loader.isModLoaded("adventurebackpack")) {
|
|
||||||
this.pluginsList.add(new AdventureBackpackProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Loader.isModLoaded("ProjRed|Exploration")) {
|
|
||||||
this.pluginsList.add(new ProjectRedExplorationProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Loader.isModLoaded("DraconicEvolution")) {
|
|
||||||
this.pluginsList.add(new DraconicEvolutionProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Loader.isModLoaded("Backpack")) {
|
|
||||||
this.pluginsList.add(new BackpackProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Loader.isModLoaded("Thaumcraft")) {
|
|
||||||
this.pluginsList.add(new ThaumcraftProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isGregTechLoaded) {
|
|
||||||
this.pluginsList.add(new GregTechCoverProvider());
|
|
||||||
this.pluginsList.add(new GregTechCoverChestProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.pluginsList.add(new MinecraftProvider());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchCooldownService getCooldownService() {
|
public static SearchCooldownService getCooldownService() {
|
||||||
@@ -118,15 +60,10 @@ public class FindIt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExtraUtilitiesLoaded() {
|
public static boolean isExtraUtilitiesLoaded() {
|
||||||
return INSTANCE.isExtraUtilitiesLoaded;
|
return INSTANCE.extraUtilitiesLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isGregTechLoaded() {
|
public static boolean isGregTechLoaded() {
|
||||||
return INSTANCE.isGregTechLoaded;
|
return INSTANCE.gregTechloaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEnderIOLoaded() {
|
|
||||||
return INSTANCE.isEnderIOLoaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,73 +1,59 @@
|
|||||||
package com.gtnh.findit;
|
package com.gtnh.findit;
|
||||||
|
|
||||||
import com.gtnewhorizon.gtnhlib.config.Config;
|
import java.io.File;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
|
||||||
@Config(modid = "findit")
|
|
||||||
public class FindItConfig {
|
public class FindItConfig {
|
||||||
|
|
||||||
@Config.Comment("Radius to search within")
|
public static int SEARCH_RADIUS = 16;
|
||||||
@Config.DefaultInt(16)
|
public static int SEARCH_COOLDOWN = 10;
|
||||||
@Config.RangeInt(min = 1)
|
public static int MAX_RESPONSE_SIZE = 20;
|
||||||
@Config.Name("SearchRadius")
|
public static boolean ENABLE_ROTATE_VIEW = false;
|
||||||
public static int SEARCH_RADIUS;
|
public static boolean USE_PARTICLE_HIGHLIGHTER = false;
|
||||||
|
public static int ITEM_HIGHLIGHTING_DURATION = 10;
|
||||||
|
public static int BLOCK_HIGHLIGHTING_DURATION = 8;
|
||||||
|
|
||||||
@Config.Comment("Search cooldown in ticks")
|
public static void setup(final File file) {
|
||||||
@Config.DefaultInt(10)
|
final Configuration config = new Configuration(file);
|
||||||
@Config.RangeInt(min = 0)
|
try {
|
||||||
@Config.Name("SearchCooldown")
|
config.load();
|
||||||
public static int SEARCH_COOLDOWN;
|
|
||||||
|
|
||||||
@Config.Comment("Maximum number of positions that can be displayed by item/block search")
|
SEARCH_RADIUS = config.get(Configuration.CATEGORY_GENERAL, "SearchRadius", "16", "Radius to search within")
|
||||||
@Config.DefaultInt(20)
|
.getInt();
|
||||||
@Config.RangeInt(min = 0)
|
|
||||||
@Config.Name("MaxResponseSize")
|
|
||||||
public static int MAX_RESPONSE_SIZE;
|
|
||||||
|
|
||||||
@Config.Comment("Rotate the player's view to face found items/blocks after searching")
|
SEARCH_COOLDOWN = config
|
||||||
@Config.DefaultBoolean(false)
|
.get(Configuration.CATEGORY_GENERAL, "SearchCooldown", "10", "Search cooldown in ticks").getInt();
|
||||||
@Config.Name("EnableRotateView")
|
|
||||||
public static boolean ENABLE_ROTATE_VIEW;
|
|
||||||
|
|
||||||
@Config.Comment("Use particles for the block highlighter instead of outlining found blocks")
|
MAX_RESPONSE_SIZE = config.get(
|
||||||
@Config.DefaultBoolean(false)
|
Configuration.CATEGORY_GENERAL,
|
||||||
@Config.Name("UseParticleHighlighter")
|
"MaxResponseSize",
|
||||||
public static boolean USE_PARTICLE_HIGHLIGHTER;
|
"20",
|
||||||
|
"Maximum number of positions that can be displayed by item/block search").getInt();
|
||||||
|
|
||||||
@Config.Comment("Search items dropped on the ground")
|
USE_PARTICLE_HIGHLIGHTER = config.get(
|
||||||
@Config.DefaultBoolean(true)
|
Configuration.CATEGORY_GENERAL,
|
||||||
@Config.Name("SearchItemsOnGround")
|
"UseParticleHighlighter",
|
||||||
public static boolean SEARCH_ITEMS_ON_GROUND;
|
"false",
|
||||||
|
"Use Particle for Block Highlighter").getBoolean();
|
||||||
|
|
||||||
@Config.Comment("Search items and fluids in GT pipes")
|
ITEM_HIGHLIGHTING_DURATION = config
|
||||||
@Config.DefaultBoolean(false)
|
.get(Configuration.CATEGORY_GENERAL, "ItemHighlightingDuration", "10", "Item highlighting duration")
|
||||||
@Config.Name("SearchInGregTechPipes")
|
.getInt();
|
||||||
public static boolean SEARCH_IN_GT_PIPES;
|
|
||||||
|
|
||||||
@Config.Comment("Search items and fluids in EnderIO conduits")
|
BLOCK_HIGHLIGHTING_DURATION = config.get(
|
||||||
@Config.DefaultBoolean(false)
|
Configuration.CATEGORY_GENERAL,
|
||||||
@Config.Name("SearchInEnderIOConduits")
|
"BlockHighlightingDuration",
|
||||||
public static boolean SEARCH_IN_ENDERIO_CONDUITS;
|
"8",
|
||||||
|
"Block highlighting duration").getInt();
|
||||||
|
|
||||||
@Config.Comment("Item highlighting duration in seconds")
|
ENABLE_ROTATE_VIEW = config.get(
|
||||||
@Config.DefaultInt(10)
|
Configuration.CATEGORY_GENERAL,
|
||||||
@Config.RangeInt(min = 1)
|
"EnableRotateView",
|
||||||
@Config.Name("ItemHighlightingDuration")
|
"false",
|
||||||
public static int ITEM_HIGHLIGHTING_DURATION;
|
"Rotate player's view when searched").getBoolean();
|
||||||
|
} catch (Exception ignore) {} finally {
|
||||||
@Config.Comment("Block highlighting duration in seconds")
|
if (config.hasChanged()) config.save();
|
||||||
@Config.DefaultInt(8)
|
}
|
||||||
@Config.RangeInt(min = 1)
|
}
|
||||||
@Config.Name("BlockHighlightingDuration")
|
|
||||||
public static int BLOCK_HIGHLIGHTING_DURATION;
|
|
||||||
|
|
||||||
@Config.Comment("Item highlighting color as an ARGB hexadecimal color code.\nDo not prefix with \"0x\"")
|
|
||||||
@Config.DefaultString("FFFF8726")
|
|
||||||
@Config.Name("ItemHighlightingColor")
|
|
||||||
public static String ITEM_HIGHLIGHTING_COLOR;
|
|
||||||
|
|
||||||
@Config.Comment("If true, the item stack size is ignored. If false, items are only highlighted if their stack size is greater than zero.\n"
|
|
||||||
+ "This is useful when working with barrels or storage drawers.")
|
|
||||||
@Config.DefaultBoolean(true)
|
|
||||||
@Config.Name("ItemHighlightingEmptyItemStacks")
|
|
||||||
public static boolean ITEM_HIGHLIGHTING_EMPTY_ITEMSTACKS;
|
|
||||||
}
|
}
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
package com.gtnh.findit;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
|
|
||||||
import com.gtnh.findit.service.itemfinder.FindItemRequest;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface IStackFilter {
|
|
||||||
|
|
||||||
boolean matches(FindItemRequest request);
|
|
||||||
|
|
||||||
public static interface IStackFilterProvider {
|
|
||||||
|
|
||||||
IStackFilter getFilter(EntityPlayer player, TileEntity tileEntity);
|
|
||||||
|
|
||||||
IStackFilter getFilter(EntityPlayer player, ItemStack stack);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class InventoryStackFilter implements IStackFilter {
|
|
||||||
|
|
||||||
private final IInventory inventory;
|
|
||||||
private final EntityPlayer player;
|
|
||||||
|
|
||||||
public InventoryStackFilter(EntityPlayer player, IInventory inventory) {
|
|
||||||
this.inventory = inventory;
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(FindItemRequest request) {
|
|
||||||
|
|
||||||
for (int slot = 0; slot < this.inventory.getSizeInventory(); slot++) {
|
|
||||||
ItemStack slotItem = this.inventory.getStackInSlot(slot);
|
|
||||||
if (slotItem != null && request.isStackSatisfies(this.player, slotItem)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class FluidStackFilter implements IStackFilter {
|
|
||||||
|
|
||||||
private final List<FluidStack> fluids;
|
|
||||||
|
|
||||||
public FluidStackFilter(List<FluidStack> fluids) {
|
|
||||||
this.fluids = fluids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FluidStackFilter() {
|
|
||||||
this(new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
public FluidStackFilter(FluidStack fluid) {
|
|
||||||
this();
|
|
||||||
add(fluid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(FluidStack fluid) {
|
|
||||||
if (fluid != null) {
|
|
||||||
this.fluids.add(fluid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return this.fluids.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(FindItemRequest request) {
|
|
||||||
|
|
||||||
for (FluidStack fluid : this.fluids) {
|
|
||||||
if (fluid != null && request.isFluidSatisfies(fluid)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class AnyMultiItemFilter implements IStackFilter {
|
|
||||||
|
|
||||||
private final List<IStackFilter> filters;
|
|
||||||
|
|
||||||
public AnyMultiItemFilter(List<IStackFilter> filters) {
|
|
||||||
this.filters = filters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AnyMultiItemFilter() {
|
|
||||||
this(new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(IStackFilter filter) {
|
|
||||||
if (filter != null) {
|
|
||||||
this.filters.add(filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return this.filters.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(FindItemRequest request) {
|
|
||||||
|
|
||||||
for (IStackFilter filter : this.filters) {
|
|
||||||
if (filter != null && filter.matches(request)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
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.multiplayer.WorldClient;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityLivingBase p = mc.renderViewEntity != null ? mc.renderViewEntity : 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
package com.gtnh.findit.fx;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityLivingBase p = mc.renderViewEntity != null ? mc.renderViewEntity : 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
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,99 @@
|
|||||||
|
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.world.ChunkPosition;
|
||||||
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
// inspired by McJtyLib
|
||||||
|
|
||||||
|
public class HighlighterHandler {
|
||||||
|
|
||||||
|
private static List<ChunkPosition> positions = new ArrayList<>();
|
||||||
|
private static long expireHighlight;
|
||||||
|
|
||||||
|
public static void highlightBlocks(List<ChunkPosition> positions, long expireHighlight) {
|
||||||
|
HighlighterHandler.positions = positions;
|
||||||
|
HighlighterHandler.expireHighlight = expireHighlight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renderHilightedBlock(RenderWorldLastEvent event) {
|
||||||
|
List<ChunkPosition> list = HighlighterHandler.positions;
|
||||||
|
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (((time / 500) & 1) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time > expireHighlight) {
|
||||||
|
positions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ChunkPosition c : list) {
|
||||||
|
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);
|
||||||
|
renderHighLightedBlocksOutline(c.chunkPosX, c.chunkPosY, c.chunkPosZ);
|
||||||
|
|
||||||
|
GL11.glPopAttrib();
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void renderHighLightedBlocksOutline(double x, double y, double z) {
|
||||||
|
GL11.glBegin(GL11.GL_LINE_STRIP);
|
||||||
|
|
||||||
|
GL11.glVertex3d(x, y, z);
|
||||||
|
GL11.glVertex3d(x, y + 1, z);
|
||||||
|
GL11.glVertex3d(x, y + 1, z + 1);
|
||||||
|
GL11.glVertex3d(x, y, z + 1);
|
||||||
|
GL11.glVertex3d(x, y, z);
|
||||||
|
|
||||||
|
GL11.glVertex3d(x + 1, y, z);
|
||||||
|
GL11.glVertex3d(x + 1, y + 1, z);
|
||||||
|
GL11.glVertex3d(x + 1, y + 1, z + 1);
|
||||||
|
GL11.glVertex3d(x + 1, y, z + 1);
|
||||||
|
GL11.glVertex3d(x + 1, y, z);
|
||||||
|
|
||||||
|
GL11.glVertex3d(x, y, z);
|
||||||
|
GL11.glVertex3d(x + 1, y, z);
|
||||||
|
GL11.glVertex3d(x + 1, y, z + 1);
|
||||||
|
GL11.glVertex3d(x, y, z + 1);
|
||||||
|
GL11.glVertex3d(x, y + 1, z + 1);
|
||||||
|
GL11.glVertex3d(x + 1, y + 1, z + 1);
|
||||||
|
GL11.glVertex3d(x + 1, y + 1, z);
|
||||||
|
GL11.glVertex3d(x + 1, y, z);
|
||||||
|
GL11.glVertex3d(x, y, z);
|
||||||
|
GL11.glVertex3d(x + 1, y, z);
|
||||||
|
GL11.glVertex3d(x + 1, y + 1, z);
|
||||||
|
GL11.glVertex3d(x, y + 1, z);
|
||||||
|
GL11.glVertex3d(x, y + 1, z + 1);
|
||||||
|
GL11.glVertex3d(x + 1, y + 1, z + 1);
|
||||||
|
GL11.glVertex3d(x + 1, y, z + 1);
|
||||||
|
GL11.glVertex3d(x, y, z + 1);
|
||||||
|
|
||||||
|
GL11.glEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,14 +49,13 @@ public class ParticlePosition extends EntityReddustFX {
|
|||||||
float rotationYZ, float rotationXY, float rotationXZ) {
|
float rotationYZ, float rotationXY, float rotationXZ) {
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
|
||||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||||
|
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
super.renderParticle(tessellator, partialTickTime, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
|
super.renderParticle(tessellator, partialTickTime, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
GL11.glPopAttrib();
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||||
tessellator.startDrawingQuads();
|
tessellator.startDrawingQuads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,14 +53,10 @@ public class SlotHighlighter implements IContainerDrawHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderSlotUnderlay(GuiContainer gui, Slot slot) {
|
public void renderSlotUnderlay(GuiContainer gui, Slot slot) {
|
||||||
if (this.gui == gui && this.slots.contains(slot)) {
|
|
||||||
GL11.glPushAttrib(
|
|
||||||
GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT
|
|
||||||
| GL11.GL_CURRENT_BIT
|
|
||||||
| GL11.GL_LIGHTING_BIT
|
|
||||||
| GL11.GL_TEXTURE_BIT);
|
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
if (this.gui == gui && this.slots.contains(slot)) {
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
@@ -75,7 +71,11 @@ public class SlotHighlighter implements IContainerDrawHandler {
|
|||||||
highlightSlot(tessellator, slot.xDisplayPosition, slot.yDisplayPosition);
|
highlightSlot(tessellator, slot.xDisplayPosition, slot.yDisplayPosition);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
GL11.glPopAttrib();
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
package com.gtnh.findit.handler;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.fluids.FluidTank;
|
|
||||||
|
|
||||||
import com.darkona.adventurebackpack.inventory.IInventoryBackpack;
|
|
||||||
import com.darkona.adventurebackpack.inventory.InventoryBackpack;
|
|
||||||
import com.darkona.adventurebackpack.item.ItemAdventureBackpack;
|
|
||||||
import com.gtnh.findit.IStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.AnyMultiItemFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.FluidStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
import com.gtnh.findit.IStackFilter.InventoryStackFilter;
|
|
||||||
|
|
||||||
public class AdventureBackpackProvider implements IStackFilterProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, TileEntity tileEntity) {
|
|
||||||
|
|
||||||
if (tileEntity instanceof IInventoryBackpack inventory) {
|
|
||||||
return getFilter(player, inventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, ItemStack stack) {
|
|
||||||
final Item item = stack.getItem();
|
|
||||||
|
|
||||||
if (item instanceof ItemAdventureBackpack) {
|
|
||||||
return getFilter(player, new InventoryBackpack(stack));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IStackFilter getFilter(EntityPlayer player, IInventoryBackpack inventory) {
|
|
||||||
final AnyMultiItemFilter filter = new AnyMultiItemFilter();
|
|
||||||
final FluidStackFilter fluidFilter = new FluidStackFilter();
|
|
||||||
|
|
||||||
filter.add(new InventoryStackFilter(player, inventory));
|
|
||||||
|
|
||||||
for (FluidTank tank : inventory.getTanksArray()) {
|
|
||||||
fluidFilter.add(tank.getFluid());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fluidFilter.isEmpty()) {
|
|
||||||
filter.add(fluidFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package com.gtnh.findit.handler;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
|
|
||||||
import com.gtnh.findit.IStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
import com.gtnh.findit.IStackFilter.InventoryStackFilter;
|
|
||||||
|
|
||||||
import de.eydamos.backpack.item.ItemBackpack;
|
|
||||||
|
|
||||||
public class BackpackProvider implements IStackFilterProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, TileEntity tileEntity) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, ItemStack stack) {
|
|
||||||
final Item item = stack.getItem();
|
|
||||||
|
|
||||||
if (item instanceof ItemBackpack) {
|
|
||||||
return new InventoryStackFilter(player, ItemBackpack.getInventory(stack, player));
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.gtnh.findit.handler;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
|
|
||||||
import com.brandon3055.draconicevolution.common.tileentities.TilePlacedItem;
|
|
||||||
import com.gtnh.findit.IStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
|
|
||||||
public class DraconicEvolutionProvider implements IStackFilterProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, TileEntity tileEntity) {
|
|
||||||
|
|
||||||
if (tileEntity instanceof TilePlacedItem placedItem) {
|
|
||||||
final ItemStack stack = placedItem.getStack();
|
|
||||||
return request -> request.isStackSatisfies(player, stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, ItemStack stack) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package com.gtnh.findit.handler;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
|
|
||||||
import com.gtnh.findit.IStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
import com.gtnh.findit.IStackFilter.InventoryStackFilter;
|
|
||||||
|
|
||||||
import forestry.storage.inventory.ItemInventoryBackpack;
|
|
||||||
import forestry.storage.items.ItemBackpack;
|
|
||||||
|
|
||||||
public class ForestryStackFilterProvider implements IStackFilterProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, TileEntity tileEntity) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, ItemStack stack) {
|
|
||||||
final Item item = stack.getItem();
|
|
||||||
|
|
||||||
if (item instanceof ItemBackpack backpack) {
|
|
||||||
final IInventory inventory = new ItemInventoryBackpack(player, backpack.getBackpackSize(), stack);
|
|
||||||
|
|
||||||
return new InventoryStackFilter(player, inventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
package com.gtnh.findit.handler;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
|
|
||||||
import com.gtnewhorizons.modularui.api.forge.IItemHandler;
|
|
||||||
import com.gtnh.findit.IStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
import com.gtnh.findit.service.itemfinder.FindItemRequest;
|
|
||||||
|
|
||||||
import gregtech.api.interfaces.tileentity.ICoverable;
|
|
||||||
import gregtech.common.covers.Cover;
|
|
||||||
import gregtech.common.covers.CoverChest;
|
|
||||||
|
|
||||||
public class GregTechCoverChestProvider implements IStackFilterProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, TileEntity tileEntity) {
|
|
||||||
if (!(tileEntity instanceof ICoverable coverable)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return request -> {
|
|
||||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
|
|
||||||
if (!coverable.hasCoverAtSide(side)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (coverChestMatches(player, request, coverable.getCoverAtSide(side))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, ItemStack stack) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean coverChestMatches(EntityPlayer player, FindItemRequest request, Cover cover) {
|
|
||||||
if (!(cover instanceof CoverChest coverChest)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IItemHandler items = coverChest.getItems();
|
|
||||||
for (int slot = 0; slot < items.getSlots(); slot++) {
|
|
||||||
ItemStack slotItem = items.getStackInSlot(slot);
|
|
||||||
if (slotItem != null && request.isStackSatisfies(player, slotItem)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
package com.gtnh.findit.handler;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
|
|
||||||
import com.gtnh.findit.IStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
|
|
||||||
import gregtech.api.covers.CoverRegistry;
|
|
||||||
import gregtech.api.interfaces.tileentity.ICoverable;
|
|
||||||
import gregtech.api.util.GTUtility;
|
|
||||||
|
|
||||||
public class GregTechCoverProvider implements IStackFilterProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, TileEntity tileEntity) {
|
|
||||||
if (!(tileEntity instanceof ICoverable coverable)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return request -> {
|
|
||||||
ItemStack stackToFind = request.getStackToFind();
|
|
||||||
if (stackToFind == null || !CoverRegistry.isCover(stackToFind)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
|
|
||||||
if (!coverable.hasCoverAtSide(side)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack coverStack = coverable.getCoverItemAtSide(side);
|
|
||||||
if (GTUtility.areStacksEqual(stackToFind, coverStack, true)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, ItemStack stack) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package com.gtnh.findit.handler;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
|
||||||
import net.minecraftforge.fluids.IFluidTank;
|
|
||||||
|
|
||||||
import com.gtnh.findit.IStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.AnyMultiItemFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.FluidStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
import com.gtnh.findit.IStackFilter.InventoryStackFilter;
|
|
||||||
|
|
||||||
import codechicken.nei.recipe.StackInfo;
|
|
||||||
|
|
||||||
public class MinecraftProvider implements IStackFilterProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, TileEntity tileEntity) {
|
|
||||||
AnyMultiItemFilter anyFilter = new AnyMultiItemFilter();
|
|
||||||
|
|
||||||
if (tileEntity instanceof IInventory inventory) {
|
|
||||||
anyFilter.add(new InventoryStackFilter(player, inventory));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tileEntity instanceof IFluidTank tank) {
|
|
||||||
anyFilter.add(new FluidStackFilter(tank.getFluid()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tileEntity instanceof IFluidHandler handler) {
|
|
||||||
FluidTankInfo[] tankInfo = handler.getTankInfo(ForgeDirection.UNKNOWN);
|
|
||||||
FluidStackFilter filter = new FluidStackFilter();
|
|
||||||
if (tankInfo != null) {
|
|
||||||
for (FluidTankInfo info : tankInfo) {
|
|
||||||
filter.add(info.fluid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!filter.isEmpty()) anyFilter.add(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
return anyFilter.isEmpty() ? null : anyFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, ItemStack stack) {
|
|
||||||
AnyMultiItemFilter filter = new AnyMultiItemFilter();
|
|
||||||
|
|
||||||
final FluidStack fluid = StackInfo.getFluid(stack);
|
|
||||||
|
|
||||||
if (fluid != null) {
|
|
||||||
filter.add(new FluidStackFilter(fluid));
|
|
||||||
}
|
|
||||||
|
|
||||||
filter.add(request -> StackInfo.equalItemAndNBT(request.getStackToFind(), stack, true));
|
|
||||||
|
|
||||||
return filter.isEmpty() ? null : filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package com.gtnh.findit.handler;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
|
|
||||||
import com.gtnh.findit.IStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
import com.gtnh.findit.IStackFilter.InventoryStackFilter;
|
|
||||||
|
|
||||||
import mrtjp.core.inventory.SimpleInventory;
|
|
||||||
import mrtjp.projectred.exploration.ItemBackpack;
|
|
||||||
|
|
||||||
public class ProjectRedExplorationProvider implements IStackFilterProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, TileEntity tileEntity) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, ItemStack stack) {
|
|
||||||
final Item item = stack.getItem();
|
|
||||||
|
|
||||||
if (item instanceof ItemBackpack) {
|
|
||||||
SimpleInventory inventory = new SimpleInventory(27, "", 64);
|
|
||||||
inventory.loadInv(ItemBackpack.getBagTag(stack));
|
|
||||||
|
|
||||||
return new InventoryStackFilter(player, inventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
package com.gtnh.findit.handler;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
|
|
||||||
import com.gtnewhorizons.aspectrecipeindex.common.items.ItemAspect;
|
|
||||||
import com.gtnh.findit.IStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
import com.gtnh.findit.service.itemfinder.FindItemRequest;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.Loader;
|
|
||||||
import thaumcraft.api.aspects.Aspect;
|
|
||||||
import thaumcraft.api.aspects.AspectList;
|
|
||||||
import thaumcraft.api.aspects.IAspectContainer;
|
|
||||||
import thaumcraft.api.aspects.IEssentiaContainerItem;
|
|
||||||
|
|
||||||
public class ThaumcraftProvider implements IStackFilterProvider {
|
|
||||||
|
|
||||||
public static final boolean ASPECTRECIPEINDEX = Loader.isModLoaded("aspectrecipeindex");
|
|
||||||
public static final boolean TCNEIPLUGIN = Loader.isModLoaded("thaumcraftneiplugin");
|
|
||||||
|
|
||||||
static class AspectStackFilter implements IStackFilter {
|
|
||||||
|
|
||||||
AspectList filterAspects;
|
|
||||||
|
|
||||||
AspectStackFilter(AspectList filterAspects) {
|
|
||||||
this.filterAspects = filterAspects;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(FindItemRequest request) {
|
|
||||||
ItemStack stack = request.getStackToFind();
|
|
||||||
Item item = stack.getItem();
|
|
||||||
if (item instanceof IEssentiaContainerItem container) {
|
|
||||||
AspectList stackAspects = container.getAspects(stack);
|
|
||||||
if (stackAspects == null || stackAspects.aspects.isEmpty()) return false;
|
|
||||||
for (Aspect a : stackAspects.getAspects()) {
|
|
||||||
if (filterAspects.getAmount(a) > 0) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Aspect aspect;
|
|
||||||
if (ASPECTRECIPEINDEX && item instanceof ItemAspect) {
|
|
||||||
aspect = ItemAspect.getAspect(stack);
|
|
||||||
} else if (TCNEIPLUGIN && item instanceof com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect) {
|
|
||||||
AspectList stackAspects = com.djgiannuzz.thaumcraftneiplugin.items.ItemAspect.getAspects(stack);
|
|
||||||
if (stackAspects == null || stackAspects.aspects.isEmpty()) return false;
|
|
||||||
aspect = stackAspects.getAspects()[0];
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return filterAspects.getAmount(aspect) > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, TileEntity tileEntity) {
|
|
||||||
if (!(tileEntity instanceof IAspectContainer aspectContainer)) return null;
|
|
||||||
AspectList aspects = aspectContainer.getAspects();
|
|
||||||
if (aspects == null) return null;
|
|
||||||
return new AspectStackFilter(aspects);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStackFilter getFilter(EntityPlayer player, ItemStack stack) {
|
|
||||||
if (!(stack.getItem() instanceof IEssentiaContainerItem containerItem)) return null;
|
|
||||||
AspectList aspects = containerItem.getAspects(stack);
|
|
||||||
if (aspects == null) return null;
|
|
||||||
return new AspectStackFilter(aspects);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,6 +14,7 @@ import com.gtnh.findit.FindItNetwork;
|
|||||||
import com.gtnh.findit.util.WorldUtils;
|
import com.gtnh.findit.util.WorldUtils;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||||
|
|
||||||
public class BlockFindService {
|
public class BlockFindService {
|
||||||
|
|
||||||
@@ -36,11 +37,12 @@ public class BlockFindService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tileMeta = tileBlock.getDamageValue(
|
int tileMeta;
|
||||||
tileEntity.getWorldObj(),
|
if (FindIt.isGregTechLoaded() && tileEntity instanceof IGregTechTileEntity) {
|
||||||
tileEntity.xCoord,
|
tileMeta = ((IGregTechTileEntity) tileEntity).getMetaTileID();
|
||||||
tileEntity.yCoord,
|
} else {
|
||||||
tileEntity.zCoord);
|
tileMeta = tileEntity.getBlockMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
if (request.getMetaToFind() == tileMeta) {
|
if (request.getMetaToFind() == tileMeta) {
|
||||||
positions.add(new ChunkPosition(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
positions.add(new ChunkPosition(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
||||||
|
|||||||
@@ -6,33 +6,24 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
|
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import com.gtnh.findit.FindIt;
|
import com.gtnh.findit.FindIt;
|
||||||
import com.gtnh.findit.FindItConfig;
|
import com.gtnh.findit.FindItConfig;
|
||||||
import com.gtnh.findit.FindItNetwork;
|
import com.gtnh.findit.FindItNetwork;
|
||||||
import com.gtnh.findit.fx.BlockHighlighter;
|
import com.gtnh.findit.fx.HighlighterHandler;
|
||||||
import com.gtnh.findit.fx.ParticlePosition;
|
import com.gtnh.findit.fx.ParticlePosition;
|
||||||
import com.gtnh.findit.util.AbstractStackFinder;
|
import com.gtnh.findit.util.AbstractStackFinder;
|
||||||
|
|
||||||
import codechicken.nei.api.API;
|
import codechicken.nei.api.API;
|
||||||
import codechicken.nei.guihook.GuiContainerManager;
|
import codechicken.nei.guihook.GuiContainerManager;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
|
|
||||||
public class ClientBlockFindService extends BlockFindService {
|
public class ClientBlockFindService extends BlockFindService {
|
||||||
|
|
||||||
private final BlockHighlighter blockHighlighter;
|
|
||||||
|
|
||||||
public ClientBlockFindService() {
|
public ClientBlockFindService() {
|
||||||
this.blockHighlighter = new BlockHighlighter();
|
|
||||||
|
|
||||||
API.addHashBind("gui.findit.find_block", Keyboard.KEY_Y);
|
API.addHashBind("gui.findit.find_block", Keyboard.KEY_Y);
|
||||||
GuiContainerManager.addInputHandler(new BlockFindInputHandler());
|
GuiContainerManager.addInputHandler(new BlockFindInputHandler());
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new WorldRenderListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleResponse(EntityClientPlayerMP player, BlockFoundResponse response) {
|
public void handleResponse(EntityClientPlayerMP player, BlockFoundResponse response) {
|
||||||
@@ -48,17 +39,9 @@ public class ClientBlockFindService extends BlockFindService {
|
|||||||
if (FindItConfig.USE_PARTICLE_HIGHLIGHTER) {
|
if (FindItConfig.USE_PARTICLE_HIGHLIGHTER) {
|
||||||
ParticlePosition.highlightBlocks(player.worldObj, response.getPositions());
|
ParticlePosition.highlightBlocks(player.worldObj, response.getPositions());
|
||||||
} else {
|
} else {
|
||||||
this.blockHighlighter.highlightBlocks(
|
HighlighterHandler.highlightBlocks(
|
||||||
response.getPositions(),
|
response.getPositions(),
|
||||||
System.currentTimeMillis() + FindItConfig.BLOCK_HIGHLIGHTING_DURATION * 1000L);
|
System.currentTimeMillis() + FindItConfig.BLOCK_HIGHLIGHTING_DURATION * 1000);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class WorldRenderListener {
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void renderWorldLastEvent(RenderWorldLastEvent event) {
|
|
||||||
blockHighlighter.renderHighlightedBlock(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.gtnh.findit.service.itemfinder;
|
package com.gtnh.findit.service.itemfinder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -8,12 +7,9 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
@@ -22,7 +18,7 @@ import org.lwjgl.input.Keyboard;
|
|||||||
import com.gtnh.findit.FindIt;
|
import com.gtnh.findit.FindIt;
|
||||||
import com.gtnh.findit.FindItConfig;
|
import com.gtnh.findit.FindItConfig;
|
||||||
import com.gtnh.findit.FindItNetwork;
|
import com.gtnh.findit.FindItNetwork;
|
||||||
import com.gtnh.findit.fx.EntityHighlighter;
|
import com.gtnh.findit.fx.HighlighterHandler;
|
||||||
import com.gtnh.findit.fx.SlotHighlighter;
|
import com.gtnh.findit.fx.SlotHighlighter;
|
||||||
import com.gtnh.findit.util.AbstractStackFinder;
|
import com.gtnh.findit.util.AbstractStackFinder;
|
||||||
|
|
||||||
@@ -36,9 +32,7 @@ import cpw.mods.fml.common.gameevent.TickEvent;
|
|||||||
public class ClientItemFindService extends ItemFindService {
|
public class ClientItemFindService extends ItemFindService {
|
||||||
|
|
||||||
private final SlotHighlighter slotHighlighter;
|
private final SlotHighlighter slotHighlighter;
|
||||||
private final EntityHighlighter itemEntitiesHighlighter;
|
private FindItemRequest request = null;
|
||||||
|
|
||||||
private FindItemRequest foundItem = null;
|
|
||||||
private long expirationTime = 0;
|
private long expirationTime = 0;
|
||||||
|
|
||||||
public ClientItemFindService() {
|
public ClientItemFindService() {
|
||||||
@@ -47,44 +41,19 @@ public class ClientItemFindService extends ItemFindService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.slotHighlighter = new SlotHighlighter();
|
this.slotHighlighter = new SlotHighlighter();
|
||||||
this.itemEntitiesHighlighter = new EntityHighlighter();
|
|
||||||
|
|
||||||
GuiContainerManager.addDrawHandler(this.slotHighlighter);
|
GuiContainerManager.addDrawHandler(this.slotHighlighter);
|
||||||
GuiContainerManager.addInputHandler(new ItemFindInputHandler());
|
GuiContainerManager.addInputHandler(new ItemFindInputHandler());
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.register(new GuiListener());
|
||||||
MinecraftForge.EVENT_BUS.register(new NEIEventListener());
|
MinecraftForge.EVENT_BUS.register(new NEIEventListener());
|
||||||
MinecraftForge.EVENT_BUS.register(new WorldRenderListener());
|
|
||||||
FMLCommonHandler.instance().bus().register(new TickListener());
|
FMLCommonHandler.instance().bus().register(new TickListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleResponse(EntityClientPlayerMP player, ItemFoundResponse response) {
|
public void handleResponse(EntityClientPlayerMP player, ItemFoundResponse response) {
|
||||||
this.slotHighlighter.highlightSlots(null, new HashSet<>(), 0xFFFF8726);
|
this.slotHighlighter.highlightSlots(null, new HashSet<>(), 0xFFFF8726);
|
||||||
this.foundItem = response.getFoundStack() != null ? new FindItemRequest(response.getFoundStack()) : null;
|
this.request = response.getFoundStack() != null ? new FindItemRequest(response.getFoundStack()) : null;
|
||||||
this.expirationTime = System.currentTimeMillis() + FindItConfig.ITEM_HIGHLIGHTING_DURATION * 1000L;
|
this.expirationTime = System.currentTimeMillis() + FindItConfig.ITEM_HIGHLIGHTING_DURATION * 1000;
|
||||||
|
|
||||||
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(player, itemEntity.getEntityItem())) {
|
|
||||||
foundItemEntities.add(itemEntity.getEntityId());
|
|
||||||
if (foundItemEntities.size() >= FindItConfig.MAX_RESPONSE_SIZE) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.itemEntitiesHighlighter.highlightEntities(foundItemEntities, expirationTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TickListener {
|
public class TickListener {
|
||||||
@@ -92,18 +61,14 @@ public class ClientItemFindService extends ItemFindService {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onClientPostTick(TickEvent.ClientTickEvent event) {
|
public void onClientPostTick(TickEvent.ClientTickEvent event) {
|
||||||
|
|
||||||
if (foundItem == null || event.phase != TickEvent.Phase.END) {
|
if (request == null || event.phase != TickEvent.Phase.END) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// `WorldClient` is only available on the client-side, thus effectively checking if the game is running on
|
|
||||||
// the client. We are only interested in highlighting slots when the player is in a GUI; the operation is
|
|
||||||
// bound client-side.
|
|
||||||
if (Minecraft.getMinecraft().theWorld == null) {
|
if (Minecraft.getMinecraft().theWorld == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are only interested in GUIs that contain some kind of inventory.
|
|
||||||
final GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
final GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
||||||
if (!(screen instanceof GuiContainer)) {
|
if (!(screen instanceof GuiContainer)) {
|
||||||
return;
|
return;
|
||||||
@@ -112,49 +77,34 @@ public class ClientItemFindService extends ItemFindService {
|
|||||||
final GuiContainer gui = (GuiContainer) screen;
|
final GuiContainer gui = (GuiContainer) screen;
|
||||||
final HashSet<Slot> highlightedSlots = new HashSet<>();
|
final HashSet<Slot> highlightedSlots = new HashSet<>();
|
||||||
|
|
||||||
// If the expiration time has passed, we reset the found item. This is done to prevent the item from being
|
|
||||||
// highlighted indefinitely.
|
|
||||||
if (System.currentTimeMillis() > expirationTime) {
|
if (System.currentTimeMillis() > expirationTime) {
|
||||||
foundItem = null;
|
request = null;
|
||||||
}
|
|
||||||
if (foundItem == null) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We continue to iterate over each slot of the given GUI's inventory and checking if the slot contains the
|
if (request != null) {
|
||||||
// item that we are looking for.
|
@SuppressWarnings("unchecked")
|
||||||
@SuppressWarnings("unchecked")
|
List<Slot> slots = gui.inventorySlots.inventorySlots;
|
||||||
List<Slot> slots = gui.inventorySlots.inventorySlots;
|
|
||||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
|
||||||
|
|
||||||
for (Slot slot : slots) {
|
for (Slot slot : slots) {
|
||||||
if (!(slot.inventory instanceof InventoryPlayer)
|
if (!(slot.inventory instanceof InventoryPlayer) && request.equals(slot.getStack())) {
|
||||||
&& foundItem.isStackSatisfies(player, slot.getStack())) {
|
highlightedSlots.add(slot);
|
||||||
highlightedSlots.add(slot);
|
|
||||||
|
|
||||||
if (highlightedSlots.size() > 256) {
|
if (highlightedSlots.size() > 256) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
slotHighlighter.highlightSlots(gui, highlightedSlots, getItemHighlightingColor());
|
slotHighlighter.highlightSlots(gui, highlightedSlots, 0xFFFF8726);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getItemHighlightingColor() {
|
public class GuiListener {
|
||||||
try {
|
|
||||||
return Integer.parseUnsignedInt(FindItConfig.ITEM_HIGHLIGHTING_COLOR, 16);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return 0xFFFF8726;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class WorldRenderListener {
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void renderWorldLastEvent(RenderWorldLastEvent event) {
|
public void renderWorldLastEvent(RenderWorldLastEvent event) {
|
||||||
itemEntitiesHighlighter.renderHighlightedEntities(event);
|
HighlighterHandler.renderHilightedBlock(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,10 +122,6 @@ public class ClientItemFindService extends ItemFindService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is responsible for removing the NEI ping handler from the list of input handlers. This is done to
|
|
||||||
* prevent the NEI ping handler from interfering with the FindIt keybind.
|
|
||||||
*/
|
|
||||||
public static class NEIEventListener {
|
public static class NEIEventListener {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@@ -188,9 +134,6 @@ public class ClientItemFindService extends ItemFindService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the instance of the client item find service.
|
|
||||||
*/
|
|
||||||
public static ClientItemFindService getInstance() {
|
public static ClientItemFindService getInstance() {
|
||||||
return (ClientItemFindService) FindIt.getItemFindService();
|
return (ClientItemFindService) FindIt.getItemFindService();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
package com.gtnh.findit.service.itemfinder;
|
package com.gtnh.findit.service.itemfinder;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
import com.gtnh.findit.FindIt;
|
import com.gtnh.findit.FindIt;
|
||||||
import com.gtnh.findit.FindItConfig;
|
|
||||||
import com.gtnh.findit.IStackFilter;
|
|
||||||
import com.gtnh.findit.IStackFilter.IStackFilterProvider;
|
|
||||||
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
|
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
|
||||||
import com.gtnh.findit.util.ProtoUtils;
|
import com.gtnh.findit.util.ProtoUtils;
|
||||||
|
|
||||||
@@ -17,86 +11,59 @@ import codechicken.nei.recipe.StackInfo;
|
|||||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||||
import crazypants.enderio.conduit.TileConduitBundle;
|
|
||||||
import gregtech.api.metatileentity.BaseMetaPipeEntity;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public class FindItemRequest implements IMessage {
|
public class FindItemRequest implements IMessage {
|
||||||
|
|
||||||
private ItemStack targetStack;
|
private ItemStack targetStack;
|
||||||
private FluidStack targetFluidStack;
|
private FluidStack targetFluidStack;
|
||||||
private boolean highlightingEmptyItemStacks;
|
|
||||||
private boolean searchInGTPipes;
|
|
||||||
private boolean searchConduits;
|
|
||||||
|
|
||||||
public FindItemRequest(ItemStack targetStack) {
|
public FindItemRequest(ItemStack targetStack) {
|
||||||
this.targetStack = targetStack;
|
this.targetStack = targetStack;
|
||||||
this.targetFluidStack = StackInfo.getFluid(targetStack);
|
this.targetFluidStack = StackInfo.getFluid(targetStack);
|
||||||
this.highlightingEmptyItemStacks = FindItConfig.ITEM_HIGHLIGHTING_EMPTY_ITEMSTACKS;
|
|
||||||
this.searchInGTPipes = FindItConfig.SEARCH_IN_GT_PIPES;
|
|
||||||
this.searchConduits = FindItConfig.SEARCH_IN_ENDERIO_CONDUITS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindItemRequest() {}
|
public FindItemRequest() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromBytes(ByteBuf buf) {
|
public void fromBytes(ByteBuf buf) {
|
||||||
this.targetStack = ProtoUtils.readItemStack(buf);
|
targetStack = ProtoUtils.readItemStack(buf);
|
||||||
this.targetFluidStack = StackInfo.getFluid(targetStack);
|
targetFluidStack = StackInfo.getFluid(targetStack);
|
||||||
this.highlightingEmptyItemStacks = buf.readBoolean();
|
|
||||||
this.searchInGTPipes = buf.readBoolean();
|
|
||||||
this.searchConduits = buf.readBoolean();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toBytes(ByteBuf buf) {
|
public void toBytes(ByteBuf buf) {
|
||||||
ProtoUtils.writeItemStack(buf, this.targetStack);
|
ProtoUtils.writeItemStack(buf, targetStack);
|
||||||
buf.writeBoolean(this.highlightingEmptyItemStacks);
|
|
||||||
buf.writeBoolean(this.searchInGTPipes);
|
|
||||||
buf.writeBoolean(this.searchConduits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getStackToFind() {
|
public ItemStack getStackToFind() {
|
||||||
return this.targetStack;
|
return targetStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFluidSatisfies(FluidStack fluid) {
|
public boolean hasFluidStack() {
|
||||||
if (fluid == null || !this.highlightingEmptyItemStacks && fluid.amount == 0) return false;
|
return targetFluidStack != null;
|
||||||
if (fluid.getFluid() == FluidRegistry.WATER && fluid.amount == 0) return false;
|
|
||||||
|
|
||||||
return this.targetFluidStack != null && this.targetFluidStack.isFluidEqual(fluid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStackSatisfies(EntityPlayer player, ItemStack stack) {
|
public boolean equals(FluidStack fluid) {
|
||||||
if (stack == null || !this.highlightingEmptyItemStacks && stack.stackSize == 0) return false;
|
|
||||||
|
|
||||||
for (IStackFilterProvider provider : FindIt.INSTANCE.pluginsList) {
|
if (fluid != null && targetFluidStack != null) {
|
||||||
IStackFilter filter = provider.getFilter(player, stack);
|
return targetFluidStack.isFluidEqual(fluid);
|
||||||
if (filter != null && filter.matches(this)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTileSatisfies(EntityPlayer player, TileEntity tileEntity) {
|
public boolean equals(ItemStack stack) {
|
||||||
if (FindIt.isGregTechLoaded() && !this.searchInGTPipes && tileEntity instanceof BaseMetaPipeEntity) {
|
|
||||||
|
if (stack == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FindIt.isEnderIOLoaded() && !this.searchConduits && tileEntity instanceof TileConduitBundle) {
|
if (targetFluidStack != null) {
|
||||||
return false;
|
return targetFluidStack.isFluidEqual(StackInfo.getFluid(stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IStackFilterProvider provider : FindIt.INSTANCE.pluginsList) {
|
return StackInfo.equalItemAndNBT(targetStack, stack, true);
|
||||||
IStackFilter filter = provider.getFilter(player, tileEntity);
|
|
||||||
if (filter != null && filter.matches(this)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Handler implements IMessageHandler<FindItemRequest, BlockFoundResponse> {
|
public static class Handler implements IMessageHandler<FindItemRequest, BlockFoundResponse> {
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
|
import net.minecraftforge.fluids.IFluidHandler;
|
||||||
|
|
||||||
import com.gtnh.findit.FindIt;
|
import com.gtnh.findit.FindIt;
|
||||||
import com.gtnh.findit.FindItConfig;
|
import com.gtnh.findit.FindItConfig;
|
||||||
@@ -23,6 +27,7 @@ public class ItemFindService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleRequest(EntityPlayerMP player, FindItemRequest request) {
|
public void handleRequest(EntityPlayerMP player, FindItemRequest request) {
|
||||||
|
|
||||||
if (FindIt.getCooldownService().checkSearchCooldown(player)) {
|
if (FindIt.getCooldownService().checkSearchCooldown(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -31,7 +36,7 @@ public class ItemFindService {
|
|||||||
|
|
||||||
for (TileEntity tileEntity : WorldUtils.getTileEntitiesAround(player, FindItConfig.SEARCH_RADIUS)) {
|
for (TileEntity tileEntity : WorldUtils.getTileEntitiesAround(player, FindItConfig.SEARCH_RADIUS)) {
|
||||||
try {
|
try {
|
||||||
if (request.isTileSatisfies(player, tileEntity)) {
|
if (tileEntity instanceof IInventory && findItemInInventory((IInventory) tileEntity, request)) {
|
||||||
positions.add(new ChunkPosition(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
positions.add(new ChunkPosition(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
||||||
if (positions.size() == FindItConfig.MAX_RESPONSE_SIZE) {
|
if (positions.size() == FindItConfig.MAX_RESPONSE_SIZE) {
|
||||||
break;
|
break;
|
||||||
@@ -45,4 +50,25 @@ public class ItemFindService {
|
|||||||
FindItNetwork.CHANNEL.sendTo(new BlockFoundResponse(positions), player);
|
FindItNetwork.CHANNEL.sendTo(new BlockFoundResponse(positions), player);
|
||||||
FindItNetwork.CHANNEL.sendTo(new ItemFoundResponse(request.getStackToFind()), player);
|
FindItNetwork.CHANNEL.sendTo(new ItemFoundResponse(request.getStackToFind()), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean findItemInInventory(IInventory inventory, FindItemRequest request) {
|
||||||
|
|
||||||
|
if (request.hasFluidStack() && inventory instanceof IFluidHandler) {
|
||||||
|
FluidTankInfo[] tankInfo = ((IFluidHandler) inventory).getTankInfo(ForgeDirection.UNKNOWN);
|
||||||
|
|
||||||
|
for (FluidTankInfo info : tankInfo) {
|
||||||
|
if (request.equals(info.fluid)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
|
||||||
|
if (request.equals(inventory.getStackInSlot(slot))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.gtnh.findit.util;
|
||||||
|
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
|
||||||
|
public class AxisUtils {
|
||||||
|
|
||||||
|
public static final class AxisPair {
|
||||||
|
|
||||||
|
private final float yaw;
|
||||||
|
private final float pitch;
|
||||||
|
|
||||||
|
public AxisPair(float yaw, float pitch) {
|
||||||
|
this.yaw = yaw;
|
||||||
|
this.pitch = pitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float yaw() {
|
||||||
|
return yaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float pitch() {
|
||||||
|
return pitch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AxisPair calculateAxisPair(Vec3 player, Vec3 target) {
|
||||||
|
double deltaX = target.xCoord - player.xCoord;
|
||||||
|
double deltaY = target.yCoord - player.yCoord;
|
||||||
|
double deltaZ = target.zCoord - player.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 AxisPair(yaw, pitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ package com.gtnh.findit.util;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
|
|
||||||
@@ -16,15 +15,13 @@ public class ClientFinderHelperUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void rotateViewHelper(EntityClientPlayerMP player, List<ChunkPosition> targets) {
|
public static void rotateViewHelper(EntityClientPlayerMP player, List<ChunkPosition> targets) {
|
||||||
if (targets.isEmpty()) {
|
Vec3 playerVec = player.getPosition(1.0F);
|
||||||
return;
|
Vec3 first = center(getNearBlock(playerVec, targets));
|
||||||
}
|
|
||||||
|
|
||||||
Vec3 eyesPos = player.getPosition(1.0F);
|
AxisUtils.AxisPair pair = AxisUtils.calculateAxisPair(playerVec, first);
|
||||||
Vec3 nearestPos = center(getNearBlock(eyesPos, targets));
|
|
||||||
|
|
||||||
Rotation targetRotation = Rotation.lookAt(eyesPos, nearestPos);
|
player.rotationYaw = pair.yaw();
|
||||||
targetRotation.apply(player);
|
player.rotationPitch = pair.pitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vec3 center(ChunkPosition p) {
|
public static Vec3 center(ChunkPosition p) {
|
||||||
@@ -36,7 +33,7 @@ public class ClientFinderHelperUtils {
|
|||||||
double minDistance = Double.MAX_VALUE;
|
double minDistance = Double.MAX_VALUE;
|
||||||
|
|
||||||
for (ChunkPosition target : targets) {
|
for (ChunkPosition target : targets) {
|
||||||
double distance = getDistanceToCenter(player, target);
|
double distance = getDistance(player, target);
|
||||||
if (distance < minDistance) {
|
if (distance < minDistance) {
|
||||||
result = target;
|
result = target;
|
||||||
minDistance = distance;
|
minDistance = distance;
|
||||||
@@ -46,21 +43,11 @@ public class ClientFinderHelperUtils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double getDistanceToCenter(Vec3 player, ChunkPosition target) {
|
private static double getDistance(Vec3 player, ChunkPosition target) {
|
||||||
double deltaX = target.chunkPosX + 0.5 - player.xCoord;
|
double deltaX = target.chunkPosX - player.xCoord;
|
||||||
double deltaY = target.chunkPosY + 0.5 - player.yCoord;
|
double deltaY = target.chunkPosY - player.yCoord;
|
||||||
double deltaZ = target.chunkPosZ + 0.5 - player.zCoord;
|
double deltaZ = target.chunkPosZ - player.zCoord;
|
||||||
|
|
||||||
return Math.sqrt(deltaX * deltaX + deltaZ * deltaZ + deltaY * deltaY);
|
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ public class ProtoUtils {
|
|||||||
buf.writeInt(positions.size());
|
buf.writeInt(positions.size());
|
||||||
for (ChunkPosition pos : positions) {
|
for (ChunkPosition pos : positions) {
|
||||||
buf.writeInt(pos.chunkPosX);
|
buf.writeInt(pos.chunkPosX);
|
||||||
buf.writeInt(pos.chunkPosY);
|
buf.writeByte(pos.chunkPosY);
|
||||||
buf.writeInt(pos.chunkPosZ);
|
buf.writeInt(pos.chunkPosZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ public class ProtoUtils {
|
|||||||
List<ChunkPosition> positions = new ArrayList<>();
|
List<ChunkPosition> positions = new ArrayList<>();
|
||||||
while (amount > 0) {
|
while (amount > 0) {
|
||||||
final int x = buf.readInt();
|
final int x = buf.readInt();
|
||||||
final int y = buf.readInt();
|
final int y = buf.readUnsignedByte();
|
||||||
final int z = buf.readInt();
|
final int z = buf.readInt();
|
||||||
positions.add(new ChunkPosition(x, y, z));
|
positions.add(new ChunkPosition(x, y, z));
|
||||||
--amount;
|
--amount;
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 274 B |
@@ -1,17 +1,21 @@
|
|||||||
{
|
{
|
||||||
"modListVersion": 2,
|
"modListVersion": 2,
|
||||||
"modList": [{
|
"modList": [{
|
||||||
"modid": "${modId}",
|
"modid": "${modId}",
|
||||||
"name": "${modName}",
|
"name": "${modName}",
|
||||||
"description": "Now where did I put that EV mixer...",
|
"description": "Now where did I put that EV mixer...",
|
||||||
"version": "${modVersion}",
|
"version": "${modVersion}",
|
||||||
"mcversion": "${minecraftVersion}",
|
"mcversion": "${minecraftVersion}",
|
||||||
"url": "https://github.com/GTNewHorizons/FindIt",
|
"url": "https://github.com/GTNewHorizons/FindIt",
|
||||||
"updateUrl": "",
|
"updateUrl": "",
|
||||||
"authorList": ["mitchej123"],
|
"authorList": ["mitchej123"],
|
||||||
"credits": "Heavily inspired from Buuz135/findme",
|
"credits": "Heavily inspired from Buuz135/findme",
|
||||||
"logoFile": "",
|
"logoFile": "",
|
||||||
"screenshots": [],
|
"screenshots": [],
|
||||||
"parent": ""
|
"parent": "",
|
||||||
}]
|
"requiredMods": [],
|
||||||
|
"dependencies": ["NotEnoughItems"],
|
||||||
|
"dependants": [],
|
||||||
|
"useDependencyInformation": true
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user