mirror of
https://github.com/GTNewHorizons/FindIt.git
synced 2026-11-24 18:24:21 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc025b3b85 | ||
|
|
9d6ce05d9e | ||
|
|
0c2a7beed9 | ||
|
|
f1313bfc48 |
No files matched your search
+2
-1602
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
// Add your dependencies here
|
// Add your dependencies here
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation('com.github.GTNewHorizons:NotEnoughItems:2.5.3-GTNH:dev')
|
implementation('com.github.GTNewHorizons:NotEnoughItems:2.5.18-GTNH:dev')
|
||||||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.23:dev')
|
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.68:dev')
|
||||||
}
|
}
|
||||||
+91
-41
@@ -1,76 +1,104 @@
|
|||||||
|
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
|
||||||
|
# LOCAL to test local config updates.
|
||||||
|
gtnh.settings.blowdryerTag = 0.2.0
|
||||||
|
|
||||||
|
# Human-readable mod name, available for mcmod.info population.
|
||||||
modName = FindIt
|
modName = FindIt
|
||||||
|
|
||||||
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
|
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
|
||||||
|
# Conventionally lowercase.
|
||||||
modId = findit
|
modId = findit
|
||||||
|
|
||||||
|
# Root package of the mod, used to find various classes in other properties,
|
||||||
|
# mcmod.info substitution, enabling assertions in run tasks, etc.
|
||||||
modGroup = com.gtnh.findit
|
modGroup = com.gtnh.findit
|
||||||
|
|
||||||
# WHY is there no version field?
|
# Whether to use modGroup as the maven publishing group.
|
||||||
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
|
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
|
||||||
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
|
useModGroupForPublishing = false
|
||||||
|
|
||||||
# Will update your build.gradle automatically whenever an update is available
|
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
||||||
autoUpdateBuildScript = false
|
autoUpdateBuildScript = false
|
||||||
|
|
||||||
|
# Version of Minecraft to target
|
||||||
minecraftVersion = 1.7.10
|
minecraftVersion = 1.7.10
|
||||||
|
|
||||||
|
# Version of Minecraft Forge to target
|
||||||
forgeVersion = 10.13.4.1614
|
forgeVersion = 10.13.4.1614
|
||||||
|
|
||||||
# Specify a MCP channel and mappings version for dependency deobfuscation and the deobfParams task.
|
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
|
||||||
channel = stable
|
channel = stable
|
||||||
|
|
||||||
|
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
|
||||||
mappingsVersion = 12
|
mappingsVersion = 12
|
||||||
|
|
||||||
# Define other MCP mappings for dependency deobfuscation
|
# Defines other MCP mappings for dependency deobfuscation.
|
||||||
remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
|
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
|
||||||
|
|
||||||
# Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you
|
# Select a default username for testing your mod. You can always override this per-run by running
|
||||||
# restart Minecraft in development. Choose this dependent on your mod:
|
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||||
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
|
|
||||||
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
|
|
||||||
developmentEnvironmentUserName = Developer
|
developmentEnvironmentUserName = Developer
|
||||||
|
|
||||||
# Enables using modern java syntax (up to version 17) via Jabel, while still targetting JVM 8.
|
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||||
# See https://github.com/bsideup/jabel for details on how this works.
|
# See https://github.com/bsideup/jabel for details on how this works.
|
||||||
enableModernJavaSyntax = true
|
enableModernJavaSyntax = true
|
||||||
|
|
||||||
# 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 publically visible List, Map, etc. into proper List<Type>, Map<K, V> types
|
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||||
enableGenericInjection = false
|
enableGenericInjection = false
|
||||||
|
|
||||||
# Generate a class with String fields for the mod id, name, version and group name named with the fields below
|
# Generate a class with a String field for the mod version named as defined below.
|
||||||
|
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
|
||||||
|
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
|
||||||
generateGradleTokenClass = com.gtnh.findit.Tags
|
generateGradleTokenClass = com.gtnh.findit.Tags
|
||||||
gradleTokenModId =
|
|
||||||
gradleTokenModName =
|
# Name of the token containing the project's current version to generate/replace.
|
||||||
gradleTokenVersion = VERSION
|
gradleTokenVersion = VERSION
|
||||||
|
|
||||||
|
# [DEPRECATED] Mod ID replacement token.
|
||||||
|
gradleTokenModId =
|
||||||
|
|
||||||
|
# [DEPRECATED] Mod name replacement token.
|
||||||
|
gradleTokenModName =
|
||||||
|
|
||||||
|
# [DEPRECATED] Mod Group replacement token.
|
||||||
gradleTokenGroupName =
|
gradleTokenGroupName =
|
||||||
|
|
||||||
# [DEPRECATED]
|
# [DEPRECATED]
|
||||||
# Multiple source files can be defined here by providing a comma-seperated list: Class1.java,Class2.java,Class3.java
|
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
|
||||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||||
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
|
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
|
||||||
# version in @Mod([...], version = VERSION, [...])
|
# version in @Mod([...], version = VERSION, [...]).
|
||||||
# Leave these properties empty to skip individual token replacements
|
# Leave these properties empty to skip individual token replacements.
|
||||||
replaceGradleTokenInFile =
|
replaceGradleTokenInFile =
|
||||||
|
|
||||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
||||||
# leave this property empty.
|
# leave this property empty.
|
||||||
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
|
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
|
||||||
apiPackage =
|
apiPackage =
|
||||||
|
|
||||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
||||||
# Example value: mymodid_at.cfg
|
# There can be multiple files in a space-separated list.
|
||||||
|
# Example value: mymodid_at.cfg nei_at.cfg
|
||||||
accessTransformersFile = findit_at.cfg
|
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
|
||||||
# Adds some debug arguments like verbose output and 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. You may only place Mixins in this package or the build will fail!
|
# Specify the package that contains all of your Mixins. You may only place Mixins in this package 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!
|
||||||
# This parameter is for legacy compatibility only
|
# This parameter is for legacy compatibility only
|
||||||
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
|
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
|
||||||
coreModClass =
|
coreModClass =
|
||||||
|
|
||||||
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
||||||
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
||||||
containsMixinsAndOrCoreModOnly = false
|
containsMixinsAndOrCoreModOnly = false
|
||||||
@@ -78,22 +106,32 @@ containsMixinsAndOrCoreModOnly = false
|
|||||||
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
|
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
|
||||||
forceEnableMixins = false
|
forceEnableMixins = false
|
||||||
|
|
||||||
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
|
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
|
||||||
# responsibility check the licence and request permission for distribution, if required.
|
# responsibility to check the license and request permission for distribution if required.
|
||||||
usesShadowedDependencies = false
|
usesShadowedDependencies = false
|
||||||
# If disabled, won't remove unused classes from shaded dependencies. Some libraries use reflection to access
|
|
||||||
|
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
|
||||||
# their own classes, making the minimization unreliable.
|
# their own classes, making the minimization unreliable.
|
||||||
minimizeShadowedDependencies = true
|
minimizeShadowedDependencies = true
|
||||||
|
|
||||||
# If disabled, won't rename the shadowed classes.
|
# If disabled, won't rename the shadowed classes.
|
||||||
relocateShadowedDependencies = true
|
relocateShadowedDependencies = true
|
||||||
|
|
||||||
# Adds the GTNH maven, CurseMaven, IC2/Player maven, 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
|
||||||
|
|
||||||
# Publishing to modrinth requires you to set the MODRINTH_TOKEN environment variable to your current modrinth API token.
|
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
|
||||||
|
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
|
||||||
|
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
|
||||||
|
usesMavenPublishing = true
|
||||||
|
|
||||||
|
# Maven repository to publish the mod to.
|
||||||
|
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
|
||||||
|
|
||||||
|
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
|
||||||
|
#
|
||||||
# The project's ID on Modrinth. Can be either the slug or the ID.
|
# The project's ID on Modrinth. Can be either the slug or the ID.
|
||||||
# Leave this empty if you don't want to publish on Modrinth.
|
# Leave this empty if you don't want to publish to Modrinth.
|
||||||
modrinthProjectId =
|
modrinthProjectId =
|
||||||
|
|
||||||
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
|
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
|
||||||
@@ -105,9 +143,8 @@ modrinthProjectId =
|
|||||||
# Note: GTNH Mixins 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.
|
||||||
|
#
|
||||||
# The project's numeric ID on CurseForge. You can find this in the About Project box.
|
# The project's numeric ID on CurseForge. You can find this in the About Project box.
|
||||||
# Leave this empty if you don't want to publish on CurseForge.
|
# Leave this empty if you don't want to publish on CurseForge.
|
||||||
curseForgeProjectId =
|
curseForgeProjectId =
|
||||||
@@ -117,26 +154,39 @@ curseForgeProjectId =
|
|||||||
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
|
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
|
||||||
# and the name is the CurseForge project slug of the other mod.
|
# and the name is the CurseForge project slug of the other mod.
|
||||||
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
|
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
|
||||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
||||||
curseForgeRelations =
|
curseForgeRelations =
|
||||||
|
|
||||||
|
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
|
||||||
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
|
|
||||||
# projects. New projects should not use this parameter.
|
# projects. New projects should not use this parameter.
|
||||||
# customArchiveBaseName =
|
# customArchiveBaseName =
|
||||||
|
|
||||||
# Optional parameter to prevent the source code from being published
|
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||||
# noPublishedSources =
|
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||||
|
# The check is ONLY performed if the version is a git tag.
|
||||||
|
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
|
||||||
|
# versionPattern =
|
||||||
|
|
||||||
# Uncomment this to disable spotless checks
|
# Uncomment to prevent the source code from being published.
|
||||||
|
# noPublishedSources = true
|
||||||
|
|
||||||
|
# Uncomment this to disable Spotless checks.
|
||||||
# This should only be uncommented to keep it easier to sync with upstream/other forks.
|
# This should only be uncommented to keep it easier to sync with upstream/other forks.
|
||||||
# That is, if there is no other active fork/upstream, NEVER change this.
|
# That is, if there is no other active fork/upstream, NEVER change this.
|
||||||
# disableSpotless = true
|
# disableSpotless = true
|
||||||
|
|
||||||
# Override the IDEA build type. Valid value is "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
|
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
|
||||||
|
# disableCheckstyle = true
|
||||||
|
|
||||||
|
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
|
||||||
# (force use delegated build).
|
# (force use delegated build).
|
||||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||||
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be always native build.
|
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
|
||||||
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
|
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
|
||||||
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
|
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
|
||||||
# ideaOverrideBuildType = idea
|
# ideaOverrideBuildType = idea
|
||||||
|
|
||||||
|
# Whether IDEA should run spotless checks when pressing the Build button.
|
||||||
|
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||||
|
# ideaCheckSpotlessOnBuild = true
|
||||||
|
|
||||||
+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-8.5-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
|
||||||
|
|||||||
Vendored
+10
-10
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
|||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
|||||||
+3
-7
@@ -6,6 +6,7 @@ pluginManagement {
|
|||||||
name "GTNH Maven"
|
name "GTNH Maven"
|
||||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||||
mavenContent {
|
mavenContent {
|
||||||
|
includeGroup("com.gtnewhorizons")
|
||||||
includeGroupByRegex("com\\.gtnewhorizons\\..+")
|
includeGroupByRegex("com\\.gtnewhorizons\\..+")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,12 +17,7 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.diffplug.blowdryerSetup' version '1.7.1'
|
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14'
|
||||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' // Provides java toolchains
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blowdryerSetup {
|
|
||||||
repoSubfolder 'gtnhShared'
|
|
||||||
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
|
|
||||||
//devLocal '.' // Use this when testing config updates locally
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,10 @@ public class FindItConfig {
|
|||||||
public static int SEARCH_RADIUS = 16;
|
public static int SEARCH_RADIUS = 16;
|
||||||
public static int SEARCH_COOLDOWN = 10;
|
public static int SEARCH_COOLDOWN = 10;
|
||||||
public static int MAX_RESPONSE_SIZE = 20;
|
public static int MAX_RESPONSE_SIZE = 20;
|
||||||
|
public static boolean ENABLE_ROTATE_VIEW = false;
|
||||||
|
public static boolean USE_PARTICLE_HIGHLIGHTER = false;
|
||||||
|
public static int ITEM_HIGHLIGHTING_DURATION = 10;
|
||||||
|
public static int BLOCK_HIGHLIGHTING_DURATION = 8;
|
||||||
|
|
||||||
public static void setup(final File file) {
|
public static void setup(final File file) {
|
||||||
final Configuration config = new Configuration(file);
|
final Configuration config = new Configuration(file);
|
||||||
@@ -26,6 +30,28 @@ public class FindItConfig {
|
|||||||
"MaxResponseSize",
|
"MaxResponseSize",
|
||||||
"20",
|
"20",
|
||||||
"Maximum number of positions that can be displayed by item/block search").getInt();
|
"Maximum number of positions that can be displayed by item/block search").getInt();
|
||||||
|
|
||||||
|
USE_PARTICLE_HIGHLIGHTER = config.get(
|
||||||
|
Configuration.CATEGORY_GENERAL,
|
||||||
|
"UseParticleHighlighter",
|
||||||
|
"false",
|
||||||
|
"Use Particle for Block Highlighter").getBoolean();
|
||||||
|
|
||||||
|
ITEM_HIGHLIGHTING_DURATION = config
|
||||||
|
.get(Configuration.CATEGORY_GENERAL, "ItemHighlightingDuration", "10", "Item highlighting duration")
|
||||||
|
.getInt();
|
||||||
|
|
||||||
|
BLOCK_HIGHLIGHTING_DURATION = config.get(
|
||||||
|
Configuration.CATEGORY_GENERAL,
|
||||||
|
"BlockHighlightingDuration",
|
||||||
|
"8",
|
||||||
|
"Block highlighting duration").getInt();
|
||||||
|
|
||||||
|
ENABLE_ROTATE_VIEW = config.get(
|
||||||
|
Configuration.CATEGORY_GENERAL,
|
||||||
|
"EnableRotateView",
|
||||||
|
"false",
|
||||||
|
"Rotate player's view when searched").getBoolean();
|
||||||
} catch (Exception ignore) {} finally {
|
} catch (Exception ignore) {} finally {
|
||||||
if (config.hasChanged()) config.save();
|
if (config.hasChanged()) config.save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.gtnh.findit.fx;
|
package com.gtnh.findit.fx;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
@@ -13,55 +13,76 @@ import org.lwjgl.opengl.GL11;
|
|||||||
|
|
||||||
import com.gtnh.findit.FindIt;
|
import com.gtnh.findit.FindIt;
|
||||||
|
|
||||||
public class SlotHighlighter {
|
import codechicken.nei.guihook.IContainerDrawHandler;
|
||||||
|
|
||||||
|
public class SlotHighlighter implements IContainerDrawHandler {
|
||||||
|
|
||||||
private static final ResourceLocation highlightTexture = new ResourceLocation(
|
private static final ResourceLocation highlightTexture = new ResourceLocation(
|
||||||
FindIt.MOD_ID,
|
FindIt.MOD_ID,
|
||||||
"textures/gui/slot_highlight.png");
|
"textures/gui/slot_highlight.png");
|
||||||
|
|
||||||
public static void highlightSlots(GuiContainer gui, List<Integer> slots, int color) {
|
private GuiContainer gui = null;
|
||||||
if (slots.isEmpty()) {
|
private HashSet<Slot> slots = new HashSet<>();
|
||||||
return;
|
private float red = 0;
|
||||||
}
|
private float green = 0;
|
||||||
|
private float blue = 0;
|
||||||
|
private float alpha = 0;
|
||||||
|
|
||||||
float red = (float) (color >> 16 & 255) / 255.0F;
|
public void highlightSlots(GuiContainer gui, HashSet<Slot> slots, int color) {
|
||||||
float green = (float) (color >> 8 & 255) / 255.0F;
|
|
||||||
float blue = (float) (color & 255) / 255.0F;
|
|
||||||
float alpha = (float) (color >> 24 & 255) / 255.0F;
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
this.gui = gui;
|
||||||
GL11.glTranslated(gui.guiLeft, gui.guiTop, 0);
|
this.slots = slots;
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
this.red = (float) (color >> 16 & 255) / 255.0F;
|
||||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
this.green = (float) (color >> 8 & 255) / 255.0F;
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
this.blue = (float) (color & 255) / 255.0F;
|
||||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
this.alpha = (float) (color >> 24 & 255) / 255.0F;
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(highlightTexture);
|
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
tessellator.setColorRGBA_F(red, green, blue, alpha);
|
|
||||||
|
|
||||||
for (int slotId : slots) {
|
|
||||||
Slot slot = gui.inventorySlots.getSlot(slotId);
|
|
||||||
highlightSlot(tessellator, slot.xDisplayPosition - 1, slot.yDisplayPosition - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
tessellator.draw();
|
|
||||||
|
|
||||||
GL11.glShadeModel(GL11.GL_FLAT);
|
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
|
||||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void highlightSlot(Tessellator tessellator, int x, int y) {
|
@Override
|
||||||
|
public void onPreDraw(GuiContainer gui) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderObjects(GuiContainer gui, int mousex, int mousey) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postRenderObjects(GuiContainer gui, int mousex, int mousey) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderSlotOverlay(GuiContainer gui, Slot slot) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderSlotUnderlay(GuiContainer gui, Slot slot) {
|
||||||
|
|
||||||
|
if (this.gui == gui && this.slots.contains(slot)) {
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||||
|
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||||
|
|
||||||
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
Minecraft.getMinecraft().getTextureManager().bindTexture(highlightTexture);
|
||||||
|
|
||||||
|
Tessellator tessellator = Tessellator.instance;
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setColorRGBA_F(red, green, blue, alpha);
|
||||||
|
highlightSlot(tessellator, slot.xDisplayPosition, slot.yDisplayPosition);
|
||||||
|
tessellator.draw();
|
||||||
|
|
||||||
|
GL11.glShadeModel(GL11.GL_FLAT);
|
||||||
|
GL11.glDisable(GL11.GL_BLEND);
|
||||||
|
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void highlightSlot(Tessellator tessellator, int x, int y) {
|
||||||
double zLevel = 1;
|
double zLevel = 1;
|
||||||
int x2 = x + 18;
|
int x2 = x + 16;
|
||||||
int y2 = y + 18;
|
int y2 = y + 16;
|
||||||
|
|
||||||
tessellator.addVertexWithUV(x2, y, zLevel, 18 / 32.0, 0);
|
tessellator.addVertexWithUV(x2, y, zLevel, 18 / 32.0, 0);
|
||||||
tessellator.addVertexWithUV(x, y, zLevel, 0, 0);
|
tessellator.addVertexWithUV(x, y, zLevel, 0, 0);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class BlockFindService {
|
|||||||
for (TileEntity tileEntity : WorldUtils.getTileEntitiesAround(player, FindItConfig.SEARCH_RADIUS)) {
|
for (TileEntity tileEntity : WorldUtils.getTileEntitiesAround(player, FindItConfig.SEARCH_RADIUS)) {
|
||||||
try {
|
try {
|
||||||
Block tileBlock = tileEntity.getBlockType();
|
Block tileBlock = tileEntity.getBlockType();
|
||||||
|
|
||||||
if (!request.getBlockToFind().equals(tileBlock)) {
|
if (!request.getBlockToFind().equals(tileBlock)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -54,8 +55,6 @@ public class BlockFindService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!positions.isEmpty()) {
|
FindItNetwork.CHANNEL.sendTo(new BlockFoundResponse(positions), player);
|
||||||
FindItNetwork.CHANNEL.sendTo(new BlockFoundResponse(positions), player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.gtnh.findit.service.blockfinder;
|
package com.gtnh.findit.service.blockfinder;
|
||||||
|
|
||||||
|
import static com.gtnh.findit.util.ClientFinderHelperUtils.lookAtTarget;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
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;
|
||||||
@@ -8,7 +10,9 @@ import net.minecraft.item.ItemStack;
|
|||||||
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.FindItNetwork;
|
import com.gtnh.findit.FindItNetwork;
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -23,8 +27,22 @@ public class ClientBlockFindService extends BlockFindService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleResponse(EntityClientPlayerMP player, BlockFoundResponse response) {
|
public void handleResponse(EntityClientPlayerMP player, BlockFoundResponse response) {
|
||||||
player.closeScreen();
|
|
||||||
ParticlePosition.highlightBlocks(player.worldObj, response.getPositions());
|
if (!response.getPositions().isEmpty()) {
|
||||||
|
player.closeScreen();
|
||||||
|
|
||||||
|
if (FindItConfig.ENABLE_ROTATE_VIEW) {
|
||||||
|
lookAtTarget(player, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FindItConfig.USE_PARTICLE_HIGHLIGHTER) {
|
||||||
|
ParticlePosition.highlightBlocks(player.worldObj, response.getPositions());
|
||||||
|
} else {
|
||||||
|
HighlighterHandler.highlightBlocks(
|
||||||
|
response.getPositions(),
|
||||||
|
System.currentTimeMillis() + FindItConfig.BLOCK_HIGHLIGHTING_DURATION * 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BlockFindInputHandler extends AbstractStackFinder {
|
private static class BlockFindInputHandler extends AbstractStackFinder {
|
||||||
@@ -37,6 +55,7 @@ public class ClientBlockFindService extends BlockFindService {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean findStack(ItemStack stack) {
|
protected boolean findStack(ItemStack stack) {
|
||||||
Block block = Block.getBlockFromItem(stack.getItem());
|
Block block = Block.getBlockFromItem(stack.getItem());
|
||||||
|
|
||||||
if (block == Blocks.air) {
|
if (block == Blocks.air) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,24 @@
|
|||||||
package com.gtnh.findit.service.itemfinder;
|
package com.gtnh.findit.service.itemfinder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
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.client.multiplayer.WorldClient;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
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.FindItNetwork;
|
import com.gtnh.findit.FindItNetwork;
|
||||||
import com.gtnh.findit.fx.ParticlePosition;
|
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;
|
||||||
|
|
||||||
@@ -32,12 +31,18 @@ import cpw.mods.fml.common.gameevent.TickEvent;
|
|||||||
|
|
||||||
public class ClientItemFindService extends ItemFindService {
|
public class ClientItemFindService extends ItemFindService {
|
||||||
|
|
||||||
private ContainerHighlightData highlightData = null;
|
private final SlotHighlighter slotHighlighter;
|
||||||
|
private FindItemRequest request = null;
|
||||||
|
private long expirationTime = 0;
|
||||||
|
|
||||||
public ClientItemFindService() {
|
public ClientItemFindService() {
|
||||||
if (!FindIt.isExtraUtilitiesLoaded()) {
|
if (!FindIt.isExtraUtilitiesLoaded()) {
|
||||||
API.addHashBind("gui.findit.find_item", Keyboard.KEY_T);
|
API.addHashBind("gui.findit.find_item", Keyboard.KEY_T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.slotHighlighter = new SlotHighlighter();
|
||||||
|
|
||||||
|
GuiContainerManager.addDrawHandler(this.slotHighlighter);
|
||||||
GuiContainerManager.addInputHandler(new ItemFindInputHandler());
|
GuiContainerManager.addInputHandler(new ItemFindInputHandler());
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new GuiListener());
|
MinecraftForge.EVENT_BUS.register(new GuiListener());
|
||||||
@@ -46,58 +51,60 @@ public class ClientItemFindService extends ItemFindService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleResponse(EntityClientPlayerMP player, ItemFoundResponse response) {
|
public void handleResponse(EntityClientPlayerMP player, ItemFoundResponse response) {
|
||||||
World world = player.worldObj;
|
this.slotHighlighter.highlightSlots(null, new HashSet<>(), 0xFFFF8726);
|
||||||
|
this.request = response.getFoundStack() != null ? new FindItemRequest(response.getFoundStack()) : null;
|
||||||
player.closeScreen();
|
this.expirationTime = System.currentTimeMillis() + FindItConfig.ITEM_HIGHLIGHTING_DURATION * 1000;
|
||||||
ParticlePosition.highlightBlocks(world, response.getPositions());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleSlotHighlight(HighlightSlotsPacket packet) {
|
|
||||||
highlightData = new ContainerHighlightData(
|
|
||||||
packet.getWindowId(),
|
|
||||||
packet.getTargetStack(),
|
|
||||||
packet.getTargetSlots());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TickListener {
|
public class TickListener {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onClientPostTick(TickEvent.ClientTickEvent event) {
|
public void onClientPostTick(TickEvent.ClientTickEvent event) {
|
||||||
if (event.phase != TickEvent.Phase.END) {
|
|
||||||
|
if (request == null || event.phase != TickEvent.Phase.END) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WorldClient world = Minecraft.getMinecraft().theWorld;
|
|
||||||
if (world == null) {
|
if (Minecraft.getMinecraft().theWorld == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
|
||||||
|
final GuiScreen screen = Minecraft.getMinecraft().currentScreen;
|
||||||
if (!(screen instanceof GuiContainer)) {
|
if (!(screen instanceof GuiContainer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GuiContainer gui = (GuiContainer) screen;
|
|
||||||
|
|
||||||
if (highlightData != null) {
|
final GuiContainer gui = (GuiContainer) screen;
|
||||||
if (highlightData.windowId == gui.inventorySlots.windowId) {
|
final HashSet<Slot> highlightedSlots = new HashSet<>();
|
||||||
highlightData.updateHighlightedSlots(gui);
|
|
||||||
} else {
|
if (System.currentTimeMillis() > expirationTime) {
|
||||||
highlightData = null;
|
request = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request != null) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<Slot> slots = gui.inventorySlots.inventorySlots;
|
||||||
|
|
||||||
|
for (Slot slot : slots) {
|
||||||
|
if (!(slot.inventory instanceof InventoryPlayer) && request.equals(slot.getStack())) {
|
||||||
|
highlightedSlots.add(slot);
|
||||||
|
|
||||||
|
if (highlightedSlots.size() > 256) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slotHighlighter.highlightSlots(gui, highlightedSlots, 0xFFFF8726);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GuiListener {
|
public class GuiListener {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Pre event) {
|
public void renderWorldLastEvent(RenderWorldLastEvent event) {
|
||||||
if (!(event.gui instanceof GuiContainer)) {
|
HighlighterHandler.renderHilightedBlock(event);
|
||||||
return;
|
|
||||||
}
|
|
||||||
GuiContainer gui = (GuiContainer) event.gui;
|
|
||||||
|
|
||||||
if (highlightData != null && highlightData.windowId == gui.inventorySlots.windowId) {
|
|
||||||
SlotHighlighter.highlightSlots(gui, highlightData.highlightedSlots, 0xFFFF8726);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,41 +122,6 @@ public class ClientItemFindService extends ItemFindService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ContainerHighlightData {
|
|
||||||
|
|
||||||
private final int windowId;
|
|
||||||
private final ItemStack targetStack;
|
|
||||||
private final List<Integer> targetSlots;
|
|
||||||
private final List<Integer> highlightedSlots = new ArrayList<>();
|
|
||||||
|
|
||||||
public ContainerHighlightData(int windowId, ItemStack targetStack, List<Integer> targetSlots) {
|
|
||||||
this.windowId = windowId;
|
|
||||||
this.targetStack = targetStack;
|
|
||||||
this.targetSlots = targetSlots;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateHighlightedSlots(GuiContainer gui) {
|
|
||||||
highlightedSlots.clear();
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<Slot> slots = (List<Slot>) gui.inventorySlots.inventorySlots;
|
|
||||||
Item targetItem = targetStack.getItem();
|
|
||||||
int targetMeta = targetStack.getItemDamage();
|
|
||||||
|
|
||||||
for (int slotId : targetSlots) {
|
|
||||||
if (slotId >= slots.size()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Slot slot = slots.get(slotId);
|
|
||||||
ItemStack stack = slot.getStack();
|
|
||||||
if (stack != null && stack.getItem() == targetItem && stack.getItemDamage() == targetMeta) {
|
|
||||||
highlightedSlots.add(slotId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class NEIEventListener {
|
public static class NEIEventListener {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package com.gtnh.findit.service.itemfinder;
|
package com.gtnh.findit.service.itemfinder;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
import com.gtnh.findit.FindIt;
|
import com.gtnh.findit.FindIt;
|
||||||
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;
|
||||||
|
|
||||||
|
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;
|
||||||
@@ -13,33 +15,62 @@ import io.netty.buffer.ByteBuf;
|
|||||||
|
|
||||||
public class FindItemRequest implements IMessage {
|
public class FindItemRequest implements IMessage {
|
||||||
|
|
||||||
private ItemStack stack;
|
private ItemStack targetStack;
|
||||||
|
private FluidStack targetFluidStack;
|
||||||
|
|
||||||
public FindItemRequest(ItemStack stack) {
|
public FindItemRequest(ItemStack targetStack) {
|
||||||
this.stack = stack;
|
this.targetStack = targetStack;
|
||||||
|
this.targetFluidStack = StackInfo.getFluid(targetStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindItemRequest() {}
|
public FindItemRequest() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromBytes(ByteBuf buf) {
|
public void fromBytes(ByteBuf buf) {
|
||||||
stack = ProtoUtils.readItemStack(buf);
|
targetStack = ProtoUtils.readItemStack(buf);
|
||||||
|
targetFluidStack = StackInfo.getFluid(targetStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toBytes(ByteBuf buf) {
|
public void toBytes(ByteBuf buf) {
|
||||||
ProtoUtils.writeItemStack(buf, stack);
|
ProtoUtils.writeItemStack(buf, targetStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getStackToFind() {
|
public ItemStack getStackToFind() {
|
||||||
return stack;
|
return targetStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasFluidStack() {
|
||||||
|
return targetFluidStack != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(FluidStack fluid) {
|
||||||
|
|
||||||
|
if (fluid != null && targetFluidStack != null) {
|
||||||
|
return targetFluidStack.isFluidEqual(fluid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(ItemStack stack) {
|
||||||
|
|
||||||
|
if (stack == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetFluidStack != null) {
|
||||||
|
return targetFluidStack.isFluidEqual(StackInfo.getFluid(stack));
|
||||||
|
}
|
||||||
|
|
||||||
|
return StackInfo.equalItemAndNBT(targetStack, stack, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Handler implements IMessageHandler<FindItemRequest, BlockFoundResponse> {
|
public static class Handler implements IMessageHandler<FindItemRequest, BlockFoundResponse> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockFoundResponse onMessage(FindItemRequest message, MessageContext ctx) {
|
public BlockFoundResponse onMessage(FindItemRequest message, MessageContext ctx) {
|
||||||
if (message.stack != null) {
|
if (message.targetStack != null) {
|
||||||
FindIt.getItemFindService().handleRequest(ctx.getServerHandler().playerEntity, message);
|
FindIt.getItemFindService().handleRequest(ctx.getServerHandler().playerEntity, message);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
package com.gtnh.findit.service.itemfinder;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
|
|
||||||
import com.gtnh.findit.util.ProtoUtils;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
|
||||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
|
|
||||||
public class HighlightSlotsPacket implements IMessage {
|
|
||||||
|
|
||||||
private int windowId;
|
|
||||||
private ItemStack targetStack;
|
|
||||||
private List<Integer> targetSlots;
|
|
||||||
|
|
||||||
public HighlightSlotsPacket(int windowId, ItemStack targetStack, List<Integer> targetSlots) {
|
|
||||||
this.windowId = windowId;
|
|
||||||
this.targetStack = targetStack;
|
|
||||||
this.targetSlots = targetSlots;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HighlightSlotsPacket() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf) {
|
|
||||||
windowId = buf.readInt();
|
|
||||||
targetStack = ProtoUtils.readItemStack(buf);
|
|
||||||
|
|
||||||
int slotCount = buf.readInt();
|
|
||||||
targetSlots = new ArrayList<>(slotCount);
|
|
||||||
for (int i = 0; i < slotCount; i++) {
|
|
||||||
targetSlots.add((int) buf.readShort());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf) {
|
|
||||||
buf.writeInt(windowId);
|
|
||||||
ProtoUtils.writeItemStack(buf, targetStack);
|
|
||||||
|
|
||||||
buf.writeInt(targetSlots.size());
|
|
||||||
targetSlots.forEach(buf::writeShort);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWindowId() {
|
|
||||||
return windowId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getTargetStack() {
|
|
||||||
return targetStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Integer> getTargetSlots() {
|
|
||||||
return targetSlots;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Handler implements IMessageHandler<HighlightSlotsPacket, BlockFoundResponse> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockFoundResponse onMessage(HighlightSlotsPacket message, MessageContext ctx) {
|
|
||||||
if (message.getTargetStack() != null) {
|
|
||||||
ClientItemFindService.getInstance().handleSlotHighlight(message);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +1,44 @@
|
|||||||
package com.gtnh.findit.service.itemfinder;
|
package com.gtnh.findit.service.itemfinder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.InventoryLargeChest;
|
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
import net.minecraft.world.World;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent;
|
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;
|
||||||
import com.gtnh.findit.FindItNetwork;
|
import com.gtnh.findit.FindItNetwork;
|
||||||
|
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
|
||||||
import com.gtnh.findit.util.WorldUtils;
|
import com.gtnh.findit.util.WorldUtils;
|
||||||
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
|
||||||
public class ItemFindService {
|
public class ItemFindService {
|
||||||
|
|
||||||
private final Map<EntityPlayerMP, ItemFoundResult> lastResults = new HashMap<>();
|
|
||||||
private final Map<EntityPlayerMP, Integer> lastProcessedContainers = new HashMap<>(); // (player) -> (windowId)
|
|
||||||
|
|
||||||
public ItemFindService() {
|
public ItemFindService() {
|
||||||
FindItNetwork.registerMessage(FindItemRequest.Handler.class, FindItemRequest.class, Side.SERVER);
|
FindItNetwork.registerMessage(FindItemRequest.Handler.class, FindItemRequest.class, Side.SERVER);
|
||||||
FindItNetwork.registerMessage(ItemFoundResponse.Handler.class, ItemFoundResponse.class, Side.CLIENT);
|
FindItNetwork.registerMessage(ItemFoundResponse.Handler.class, ItemFoundResponse.class, Side.CLIENT);
|
||||||
FindItNetwork.registerMessage(HighlightSlotsPacket.Handler.class, HighlightSlotsPacket.class, Side.CLIENT);
|
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new ContainerListener());
|
|
||||||
}
|
|
||||||
|
|
||||||
private ItemFoundResult getLastFoundResult(EntityPlayerMP player) {
|
|
||||||
ItemFoundResult lastResult = lastResults.get(player);
|
|
||||||
if (lastResult != null && !lastResult.isValid(player.getEntityWorld())) {
|
|
||||||
lastResults.remove(player);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return lastResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item itemToFind = request.getStackToFind().getItem();
|
|
||||||
int metaToFind = request.getStackToFind().getItemDamage();
|
|
||||||
|
|
||||||
List<ChunkPosition> positions = new ArrayList<>();
|
List<ChunkPosition> positions = new ArrayList<>();
|
||||||
|
|
||||||
tileIter: for (TileEntity tileEntity : WorldUtils.getTileEntitiesAround(player, FindItConfig.SEARCH_RADIUS)) {
|
for (TileEntity tileEntity : WorldUtils.getTileEntitiesAround(player, FindItConfig.SEARCH_RADIUS)) {
|
||||||
try {
|
try {
|
||||||
if (!(tileEntity instanceof IInventory)) {
|
if (tileEntity instanceof IInventory && findItemInInventory((IInventory) tileEntity, request)) {
|
||||||
continue;
|
positions.add(new ChunkPosition(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
||||||
}
|
if (positions.size() == FindItConfig.MAX_RESPONSE_SIZE) {
|
||||||
IInventory inventory = (IInventory) tileEntity;
|
|
||||||
|
|
||||||
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
|
|
||||||
ItemStack stackInSlot = inventory.getStackInSlot(slot);
|
|
||||||
if (stackInSlot == null || stackInSlot.getItem() != itemToFind) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!itemToFind.getHasSubtypes() || stackInSlot.getItemDamage() == metaToFind) {
|
|
||||||
positions.add(new ChunkPosition(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
|
||||||
if (positions.size() == FindItConfig.MAX_RESPONSE_SIZE) {
|
|
||||||
break tileIter;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,117 +47,28 @@ public class ItemFindService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!positions.isEmpty()) {
|
FindItNetwork.CHANNEL.sendTo(new BlockFoundResponse(positions), player);
|
||||||
ItemFoundResult foundResult = new ItemFindService.ItemFoundResult(
|
FindItNetwork.CHANNEL.sendTo(new ItemFoundResponse(request.getStackToFind()), player);
|
||||||
request.getStackToFind(),
|
|
||||||
positions,
|
|
||||||
player.getEntityWorld().getTotalWorldTime());
|
|
||||||
|
|
||||||
lastResults.put(player, foundResult);
|
|
||||||
FindItNetwork.CHANNEL.sendTo(new ItemFoundResponse(request.getStackToFind(), positions), player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processOpenContainer(EntityPlayerMP player) {
|
private boolean findItemInInventory(IInventory inventory, FindItemRequest request) {
|
||||||
lastProcessedContainers.put(player, player.openContainer.windowId);
|
|
||||||
Container container = player.openContainer;
|
|
||||||
|
|
||||||
ItemFoundResult lastFoundResult = getLastFoundResult(player);
|
if (request.hasFluidStack() && inventory instanceof IFluidHandler) {
|
||||||
if (lastFoundResult == null) {
|
FluidTankInfo[] tankInfo = ((IFluidHandler) inventory).getTankInfo(ForgeDirection.UNKNOWN);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
for (FluidTankInfo info : tankInfo) {
|
||||||
List<Slot> slots = (List<Slot>) container.inventorySlots;
|
if (request.equals(info.fluid)) {
|
||||||
List<Integer> targetSlots = new ArrayList<>();
|
return true;
|
||||||
Set<ChunkPosition> tilePositions = new HashSet<>();
|
|
||||||
|
|
||||||
for (int slotId = 0; slotId < slots.size(); slotId++) {
|
|
||||||
Slot slot = slots.get(slotId);
|
|
||||||
IInventory inventory = getSlotTrueInventory(slot);
|
|
||||||
if (!(inventory instanceof TileEntity)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TileEntity tile = (TileEntity) inventory;
|
|
||||||
ChunkPosition tilePos = new ChunkPosition(tile.xCoord, tile.yCoord, tile.zCoord);
|
|
||||||
|
|
||||||
if (lastFoundResult.containsPosition(tilePos)) {
|
|
||||||
targetSlots.add(slotId);
|
|
||||||
tilePositions.add(tilePos);
|
|
||||||
|
|
||||||
if (targetSlots.size() >= 256) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetSlots.isEmpty()) {
|
for (int slot = 0; slot < inventory.getSizeInventory(); slot++) {
|
||||||
tilePositions.forEach(lastFoundResult::pollPosition);
|
if (request.equals(inventory.getStackInSlot(slot))) {
|
||||||
|
return true;
|
||||||
FindItNetwork.CHANNEL.sendTo(
|
|
||||||
new HighlightSlotsPacket(container.windowId, lastFoundResult.foundStack, targetSlots),
|
|
||||||
player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IInventory getSlotTrueInventory(Slot slot) {
|
|
||||||
if (slot.inventory instanceof InventoryLargeChest) {
|
|
||||||
InventoryLargeChest largeChest = (InventoryLargeChest) slot.inventory;
|
|
||||||
return slot.slotNumber < largeChest.upperChest.getSizeInventory() ? largeChest.upperChest
|
|
||||||
: largeChest.lowerChest;
|
|
||||||
}
|
|
||||||
return slot.inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ContainerListener {
|
|
||||||
|
|
||||||
// called every tick to check if player can interact with container
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onContainerOpen(PlayerOpenContainerEvent event) {
|
|
||||||
if (event.entityPlayer.worldObj.isRemote) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
|
|
||||||
|
|
||||||
// may not spend time to process player inventory
|
|
||||||
if (player.openContainer == player.inventoryContainer) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int lastProcessedContainer = lastProcessedContainers.getOrDefault(player, -1);
|
|
||||||
if (player.openContainer.windowId != lastProcessedContainer) {
|
|
||||||
processOpenContainer(player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class ItemFoundResult {
|
return false;
|
||||||
|
|
||||||
private final ItemStack foundStack;
|
|
||||||
private final Set<ChunkPosition> positions = new HashSet<>();
|
|
||||||
private final long responseTime;
|
|
||||||
|
|
||||||
public ItemFoundResult(ItemStack foundStack, List<ChunkPosition> positions, long responseTime) {
|
|
||||||
this.foundStack = foundStack;
|
|
||||||
this.positions.addAll(positions);
|
|
||||||
this.responseTime = responseTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getFoundStack() {
|
|
||||||
return foundStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValid(World world) {
|
|
||||||
return !positions.isEmpty() && world.getTotalWorldTime() - responseTime < 20 * 60; // 60 sec
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean containsPosition(ChunkPosition position) {
|
|
||||||
return positions.contains(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pollPosition(ChunkPosition position) {
|
|
||||||
positions.remove(position);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
package com.gtnh.findit.service.itemfinder;
|
package com.gtnh.findit.service.itemfinder;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.ChunkPosition;
|
|
||||||
|
|
||||||
import com.gtnh.findit.util.ProtoUtils;
|
import com.gtnh.findit.util.ProtoUtils;
|
||||||
|
|
||||||
@@ -18,11 +15,9 @@ import io.netty.buffer.ByteBuf;
|
|||||||
public class ItemFoundResponse implements IMessage {
|
public class ItemFoundResponse implements IMessage {
|
||||||
|
|
||||||
private ItemStack foundStack;
|
private ItemStack foundStack;
|
||||||
private List<ChunkPosition> positions;
|
|
||||||
|
|
||||||
public ItemFoundResponse(ItemStack foundStack, List<ChunkPosition> positions) {
|
public ItemFoundResponse(ItemStack foundStack) {
|
||||||
this.foundStack = foundStack;
|
this.foundStack = foundStack;
|
||||||
this.positions = positions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemFoundResponse() {}
|
public ItemFoundResponse() {}
|
||||||
@@ -30,31 +25,23 @@ public class ItemFoundResponse implements IMessage {
|
|||||||
@Override
|
@Override
|
||||||
public void fromBytes(ByteBuf buf) {
|
public void fromBytes(ByteBuf buf) {
|
||||||
foundStack = ProtoUtils.readItemStack(buf);
|
foundStack = ProtoUtils.readItemStack(buf);
|
||||||
positions = ProtoUtils.readPositions(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toBytes(ByteBuf buf) {
|
public void toBytes(ByteBuf buf) {
|
||||||
ProtoUtils.writeItemStack(buf, foundStack);
|
ProtoUtils.writeItemStack(buf, foundStack);
|
||||||
ProtoUtils.writePositions(buf, positions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getFoundStack() {
|
public ItemStack getFoundStack() {
|
||||||
return foundStack;
|
return foundStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ChunkPosition> getPositions() {
|
|
||||||
return positions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Handler implements IMessageHandler<ItemFoundResponse, IMessage> {
|
public static class Handler implements IMessageHandler<ItemFoundResponse, IMessage> {
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public IMessage onMessage(ItemFoundResponse message, MessageContext ctx) {
|
public IMessage onMessage(ItemFoundResponse message, MessageContext ctx) {
|
||||||
if (message.foundStack != null && !message.positions.isEmpty()) {
|
ClientItemFindService.getInstance().handleResponse(Minecraft.getMinecraft().thePlayer, message);
|
||||||
ClientItemFindService.getInstance().handleResponse(Minecraft.getMinecraft().thePlayer, message);
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.gtnh.findit.util;
|
|||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import codechicken.nei.LayoutManager;
|
|
||||||
import codechicken.nei.NEIClientConfig;
|
import codechicken.nei.NEIClientConfig;
|
||||||
import codechicken.nei.guihook.GuiContainerManager;
|
import codechicken.nei.guihook.GuiContainerManager;
|
||||||
import codechicken.nei.guihook.IContainerInputHandler;
|
import codechicken.nei.guihook.IContainerInputHandler;
|
||||||
@@ -28,15 +27,11 @@ public abstract class AbstractStackFinder implements IContainerInputHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutManager layout = LayoutManager.instance();
|
|
||||||
if (layout == null || LayoutManager.itemPanel == null || NEIClientConfig.isHidden()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = GuiContainerManager.getStackMouseOver(guiContainer);
|
ItemStack stack = GuiContainerManager.getStackMouseOver(guiContainer);
|
||||||
if (stack == null || stack.getItem() == null) {
|
if (stack == null || stack.getItem() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return findStack(stack);
|
return findStack(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.gtnh.findit.util;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
|
import net.minecraft.world.ChunkPosition;
|
||||||
|
|
||||||
|
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
|
||||||
|
|
||||||
|
public class ClientFinderHelperUtils {
|
||||||
|
|
||||||
|
public static void lookAtTarget(EntityClientPlayerMP player, BlockFoundResponse response) {
|
||||||
|
rotateViewHelper(player, response.getPositions());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void rotateViewHelper(EntityClientPlayerMP player, List<ChunkPosition> targets) {
|
||||||
|
Vec3 playerVec = player.getPosition(1.0F);
|
||||||
|
Vec3 first = center(targets.get(0));
|
||||||
|
|
||||||
|
AxisUtils.AxisPair pair = AxisUtils.calculateAxisPair(playerVec, first);
|
||||||
|
|
||||||
|
player.rotationYaw = pair.yaw();
|
||||||
|
player.rotationPitch = pair.pitch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vec3 center(ChunkPosition p) {
|
||||||
|
return Vec3.createVectorHelper(p.chunkPosX + 0.5, p.chunkPosY + 0.5, p.chunkPosZ + 0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user