Compare commits

...
6 Commits
Author SHA1 Message Date
D-Cysteine 8612980782 Add distance limit for out-of-range message (#91)
Also fix the check so that we only display the message for travel anchors within the angle limit.
2023-01-28 18:50:06 +01:00
D-Cysteine 0902a8956b Add staff of teleportation (#89)
* Add teleport staff

* Add support for long-range travel anchor teleportation

* Update buildscript + apply spotless

* Replace creative staff of travelling

* Add missing mapping handler and fix extract energy
2023-01-27 20:22:06 +01:00
Alexdoru d9b99f6888 unbind keys by default (#90)
* unbind all keys by default

* show "EnderIO - Tools" instead of "Tools" in the controls menu

* check if keybind is pressed first
2023-01-27 20:21:27 +01:00
miozune e03011cd40 Fix behavior on Enchanter NEI while holding shift (#88) 2022-12-20 07:51:17 +01:00
miozune 864e5c03b3 Add Fertilized Dirt from RandomThings to recognized farmland list for CustomSeedFarmer (#87)
* Update buildscript & NEI version

* Add Fertilized Dirt from RandomThings to recognized farmland list for CustomSeedFarmer
2022-10-13 09:57:40 +02:00
Raven Szewczyk 727aed1335 Guard against ClassCastExceptions in BlockConduitBundle (#86)
Remove null checks that are already covered by instanceof

Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11474>
2022-09-30 08:54:16 +02:00
40 changed files with 935 additions and 294 deletions

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
* text eol=lf
*.[jJ][aA][rR] binary
*.[pP][nN][gG] binary
*.[jJ][pP][gG] binary
*.[jJ][pP][eE][gG] binary
*.[gG][iI][fF] binary
*.[tT][iI][fF] binary
*.[tT][iI][fF][fF] binary
*.[iI][cC][oO] binary
*.[sS][vV][gG] text
*.[eE][pP][sS] binary
*.[xX][cC][fF] binary
*.[kK][aA][rR] binary
*.[mM]4[aA] binary
*.[mM][iI][dD] binary
*.[mM][iI][dD][iI] binary
*.[mM][pP]3 binary
*.[oO][gG][gG] binary
*.[rR][aA] binary
*.7[zZ] binary
*.[gG][zZ] binary
*.[tT][aA][rR] binary
*.[tT][gG][zZ] binary
*.[zZ][iI][pP] binary
*.[tT][cC][nN] binary
*.[sS][oO] binary
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary
*.[nN][bB][tT] binary
*.[pP][aA][tT][cC][hH] -text
*.[bB][aA][tT] text eol=crlf
*.[cC][mM][dD] text eol=crlf
*.[pP][sS]1 text eol=crlf
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
+358 -140
View File
@@ -1,13 +1,17 @@
//version: 1658080040
//version: 1674409054
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/master/build.gradle for updates.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseRelation
import com.modrinth.minotaur.dependencies.ModDependency
import com.modrinth.minotaur.dependencies.VersionDependency
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
@@ -26,6 +30,11 @@ buildscript {
name 'forge'
url 'https://maven.minecraftforge.net'
}
maven {
// GTNH ForgeGradle and ASM Fork
name = "GTNH Maven"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
}
maven {
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
@@ -34,32 +43,35 @@ buildscript {
name 'Scala CI dependencies'
url 'https://repo1.maven.org/maven2/'
}
maven {
name 'jitpack'
url 'https://jitpack.io'
}
}
dependencies {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7'
//Overwrite the current ASM version to fix shading newer than java 8 applicatations.
classpath 'org.ow2.asm:asm-debug-all-custom:5.0.3'
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.13'
}
}
plugins {
id 'java-library'
id 'idea'
id 'eclipse'
id 'scala'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false
id 'org.ajoberstar.grgit' version '4.1.1'
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false
id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.github.johnrengelman.shadow' version '4.0.4'
id 'com.palantir.git-version' version '0.13.0' apply false
id 'de.undercouch.download' version '5.0.1'
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
id "com.diffplug.spotless" version "6.7.2"
id 'com.palantir.git-version' version '0.13.0' apply false
id 'de.undercouch.download' version '5.0.1'
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
id 'com.diffplug.spotless' version '6.7.2' apply false
id 'com.modrinth.minotaur' version '2.+' apply false
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
}
boolean settingsupdated = verifySettingsGradle()
settingsupdated = verifyGitAttributes() || settingsupdated
if (settingsupdated)
throw new GradleException("Settings has been updated, please re-run task.")
dependencies {
implementation 'com.diffplug:blowdryer:1.6.0'
@@ -90,9 +102,15 @@ idea {
downloadSources = true
}
}
apply from: Blowdryer.file('spotless.gradle')
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false
if (!disableSpotless) {
apply plugin: 'com.diffplug.spotless'
apply from: Blowdryer.file('spotless.gradle')
}
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
}
@@ -117,67 +135,80 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly")
checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
boolean usesMixinDebug = project.findProperty('usesMixinDebug') ?: project.usesMixins.toBoolean()
boolean forceEnableMixins = project.findProperty('forceEnableMixins') ? project.forceEnableMixins.toBoolean() : false
String channel = project.findProperty('channel') ? project.channel : 'stable'
String mappingsVersion = project.findProperty('mappingsVersion') ? project.mappingsVersion : '12'
String remoteMappings = project.findProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/'
propertyDefaultIfUnset("noPublishedSources", false)
propertyDefaultIfUnset("usesMixinDebug", project.usesMixins)
propertyDefaultIfUnset("forceEnableMixins", false)
propertyDefaultIfUnset("channel", "stable")
propertyDefaultIfUnset("mappingsVersion", "12")
propertyDefaultIfUnset("modrinthProjectId", "")
propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnset("curseForgeProjectId", "")
propertyDefaultIfUnset("curseForgeRelations", "")
propertyDefaultIfUnset("minimizeShadowedDependencies", true)
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String kotlinSourceDir = "src/main/kotlin/"
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
final String modGroupPath = modGroup.toString().replaceAll("\\.", "/")
final String apiPackagePath = apiPackage.toString().replaceAll("\\.", "/")
String targetPackageJava = javaSourceDir + modGroupPath
String targetPackageScala = scalaSourceDir + modGroupPath
String targetPackageKotlin = kotlinSourceDir + modGroupPath
if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
if(apiPackage) {
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
if (apiPackage) {
targetPackageJava = javaSourceDir + modGroupPath + "/" + apiPackagePath
targetPackageScala = scalaSourceDir + modGroupPath + "/" + apiPackagePath
targetPackageKotlin = kotlinSourceDir + modGroupPath + "/" + apiPackagePath
if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
}
if(accessTransformersFile) {
if (accessTransformersFile) {
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
if(!getFile(targetFile).exists()) {
if (!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
}
}
if(usesMixins.toBoolean()) {
if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
if (usesMixins.toBoolean()) {
if (mixinsPackage.isEmpty()) {
throw new GradleException("\"usesMixins\" requires \"mixinsPackage\" to be set!")
}
final String mixinPackagePath = mixinsPackage.toString().replaceAll("\\.", "/")
final String mixinPluginPath = mixinPlugin.toString().replaceAll("\\.", "/")
targetPackageJava = javaSourceDir + modGroupPath + "/" + mixinPackagePath
targetPackageScala = scalaSourceDir + modGroupPath + "/" + mixinPackagePath
targetPackageKotlin = kotlinSourceDir + modGroupPath + "/" + mixinPackagePath
if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt"
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
if (!mixinPlugin.isEmpty()) {
String targetFileJava = javaSourceDir + modGroupPath + "/" + mixinPluginPath + ".java"
String targetFileScala = scalaSourceDir + modGroupPath + "/" + mixinPluginPath + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroupPath + "/" + mixinPluginPath + ".java"
String targetFileKotlin = kotlinSourceDir + modGroupPath + "/" + mixinPluginPath + ".kt"
if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
}
}
}
if(coreModClass) {
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".kt"
if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
if (coreModClass) {
final String coreModPath = coreModClass.toString().replaceAll("\\.", "/")
String targetFileJava = javaSourceDir + modGroupPath + "/" + coreModPath + ".java"
String targetFileScala = scalaSourceDir + modGroupPath + "/" + coreModPath + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroupPath + "/" + coreModPath + ".java"
String targetFileKotlin = kotlinSourceDir + modGroupPath + "/" + coreModPath + ".kt"
if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
}
}
@@ -218,22 +249,21 @@ ext {
modVersion = identifiedVersion
}
if(identifiedVersion == versionOverride) {
if (identifiedVersion == versionOverride) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
}
group = modGroup
if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
archivesBaseName = customArchiveBaseName
}
else {
} else {
archivesBaseName = modId
}
def arguments = []
def jvmArguments = []
if (usesMixins.toBoolean() || forceEnableMixins) {
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
arguments += [
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
@@ -251,17 +281,19 @@ minecraft {
runDir = 'run'
if (replaceGradleTokenInFile) {
replaceIn replaceGradleTokenInFile
if(gradleTokenModId) {
for (f in replaceGradleTokenInFile.split(',')) {
replaceIn f
}
if (gradleTokenModId) {
replace gradleTokenModId, modId
}
if(gradleTokenModName) {
if (gradleTokenModName) {
replace gradleTokenModName, modName
}
if(gradleTokenVersion) {
if (gradleTokenVersion) {
replace gradleTokenVersion, modVersion
}
if(gradleTokenGroupName) {
if (gradleTokenGroupName) {
replace gradleTokenGroupName, modGroup
}
}
@@ -270,7 +302,7 @@ minecraft {
args(arguments)
jvmArgs(jvmArguments)
if(developmentEnvironmentUserName) {
if (developmentEnvironmentUserName) {
args("--username", developmentEnvironmentUserName)
}
}
@@ -281,16 +313,24 @@ minecraft {
}
}
if(file('addon.gradle').exists()) {
if (file('addon.gradle').exists()) {
apply from: 'addon.gradle'
}
apply from: 'repositories.gradle'
configurations {
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
implementation.extendsFrom(shadowCompile)
implementation.extendsFrom(shadeCompile)
// TODO: remove Compile after all uses are refactored to Implementation
for (config in [
shadowImplementation,
shadowCompile,
shadeCompile
]) {
compileClasspath.extendsFrom(config)
runtimeClasspath.extendsFrom(config)
testCompileClasspath.extendsFrom(config)
testRuntimeClasspath.extendsFrom(config)
}
}
repositories {
@@ -298,35 +338,33 @@ repositories {
name 'Overmind forge repo mirror'
url 'https://gregtech.overminddl1.com/'
}
if(usesMixins.toBoolean() || forceEnableMixins) {
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
maven {
name 'sponge'
url 'https://repo.spongepowered.org/repository/maven-public'
name = "GTNH Maven"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
}
maven {
url 'https://jitpack.io'
if (usesMixinDebug.toBoolean()) {
maven {
name = "Fabric Maven"
url = "https://maven.fabricmc.net/"
}
}
}
}
dependencies {
if(usesMixins.toBoolean()) {
if (usesMixins.toBoolean()) {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT')
}
if(usesMixins.toBoolean() || forceEnableMixins) {
// using 0.8 to workaround a issue in 0.7 which fails mixin application
compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.3:processor')
if (usesMixinDebug.toBoolean()) {
runtimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16')
testRuntimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16')
}
compile('com.github.GTNewHorizons:SpongeMixins:1.5.0')
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
compile('com.gtnewhorizon:gtnhmixins:2.1.3')
}
}
@@ -338,13 +376,18 @@ def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
task generateAssets {
if (usesMixins.toBoolean()) {
def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json");
def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json")
if (!mixinConfigFile.exists()) {
def mixinPluginLine = ""
if(!mixinPlugin.isEmpty()) {
// We might not have a mixin plugin if we're using early/late mixins
mixinPluginLine += """\n "plugin": "${modGroup}.${mixinPlugin}", """
}
mixinConfigFile.text = """{
"required": true,
"minVersion": "0.7.11",
"package": "${modGroup}.${mixinsPackage}",
"plugin": "${modGroup}.${mixinPlugin}",
"minVersion": "0.8.5-GTNH",
"package": "${modGroup}.${mixinsPackage}",${mixinPluginLine}
"refmap": "${mixingConfigRefMap}",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
@@ -373,7 +416,9 @@ shadowJar {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
if (minimizeShadowedDependencies.toBoolean()) {
minimize() // This will only allow shading for actually used classes
}
configurations = [
project.configurations.shadowImplementation,
project.configurations.shadowCompile
@@ -392,20 +437,20 @@ jar {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
if (usesShadowedDependencies.toBoolean()) {
dependsOn(shadowJar)
enabled = false
}
}
reobf {
if(usesMixins.toBoolean()) {
if (usesMixins.toBoolean()) {
addExtraSrgFile mixinSrg
}
}
afterEvaluate {
if(usesMixins.toBoolean()) {
if (usesMixins.toBoolean()) {
tasks.compileJava {
options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobf.srg}",
@@ -420,7 +465,7 @@ afterEvaluate {
}
runClient {
if(developmentEnvironmentUserName) {
if (developmentEnvironmentUserName) {
arguments += [
"--username",
developmentEnvironmentUserName
@@ -461,7 +506,7 @@ processResources {
"modName": modName
}
if(usesMixins.toBoolean()) {
if (usesMixins.toBoolean()) {
from refMap
}
@@ -474,31 +519,31 @@ processResources {
def getManifestAttributes() {
def manifestAttributes = [:]
if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
if (!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
}
if(accessTransformersFile) {
manifestAttributes += ["FMLAT" : accessTransformersFile.toString()]
if (accessTransformersFile) {
manifestAttributes += ["FMLAT": accessTransformersFile.toString()]
}
if(coreModClass) {
if (coreModClass) {
manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass]
}
if(usesMixins.toBoolean()) {
if (usesMixins.toBoolean()) {
manifestAttributes += [
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
"MixinConfigs" : "mixins." + modId + ".json",
"ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean()
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
"MixinConfigs" : "mixins." + modId + ".json",
"ForceLoadAsMod": !containsMixinsAndOrCoreModOnly.toBoolean()
]
}
return manifestAttributes
}
task sourcesJar(type: Jar) {
from (sourceSets.main.allSource)
from (file("$projectDir/LICENSE"))
from(sourceSets.main.allSource)
from(file("$projectDir/LICENSE"))
getArchiveClassifier().set('sources')
}
@@ -516,7 +561,9 @@ task shadowDevJar(type: ShadowJar) {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
if (minimizeShadowedDependencies.toBoolean()) {
minimize() // This will only allow shading for actually used classes
}
configurations = [
project.configurations.shadowImplementation,
project.configurations.shadowCompile
@@ -548,22 +595,22 @@ task devJar(type: Jar) {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
if (usesShadowedDependencies.toBoolean()) {
dependsOn(circularResolverJar)
enabled = false
}
}
task apiJar(type: Jar) {
from (sourceSets.main.allSource) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
from(sourceSets.main.allSource) {
include modGroupPath + "/" + apiPackagePath + '/**'
}
from (sourceSets.main.output) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
from(sourceSets.main.output) {
include modGroupPath + "/" + apiPackagePath + '/**'
}
from (sourceSets.main.resources.srcDirs) {
from(sourceSets.main.resources.srcDirs) {
include("LICENSE")
}
@@ -571,11 +618,11 @@ task apiJar(type: Jar) {
}
artifacts {
if(!noPublishedSources) {
if (!noPublishedSources) {
archives sourcesJar
}
archives devJar
if(apiPackage) {
if (apiPackage) {
archives apiJar
}
}
@@ -593,10 +640,10 @@ publishing {
publications {
maven(MavenPublication) {
from components.java
if(usesShadowedDependencies.toBoolean()) {
if (usesShadowedDependencies.toBoolean()) {
artifact source: shadowJar, classifier: ""
}
if(!noPublishedSources) {
if (!noPublishedSources) {
artifact source: sourcesJar, classifier: "sources"
}
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
@@ -611,7 +658,7 @@ publishing {
// remove extra garbage from minecraft and minecraftDeps configuration
pom.withXml {
def badArtifacts = [:].withDefault {[] as Set<String>}
def badArtifacts = [:].withDefault { [] as Set<String> }
for (configuration in [
projectConfigs.minecraft,
projectConfigs.minecraftDeps
@@ -644,6 +691,124 @@ publishing {
}
}
if (modrinthProjectId.size() != 0 && System.getenv("MODRINTH_TOKEN") != null) {
apply plugin: 'com.modrinth.minotaur'
File changelogFile = new File(System.getenv("CHANGELOG_FILE") ?: "CHANGELOG.md")
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = modrinthProjectId
versionNumber = identifiedVersion
versionType = identifiedVersion.endsWith("-pre") ? "beta" : "release"
changelog = changelogFile.exists() ? changelogFile.getText("UTF-8") : ""
uploadFile = jar
additionalFiles = getSecondaryArtifacts()
gameVersions = [minecraftVersion]
loaders = ["forge"]
debugMode = false
}
if (modrinthRelations.size() != 0) {
String[] deps = modrinthRelations.split(";")
deps.each { dep ->
if (dep.size() == 0) {
return
}
String[] parts = dep.split(":")
String[] qual = parts[0].split("-")
addModrinthDep(qual[0], qual[1], parts[1])
}
}
if (usesMixins.toBoolean()) {
addModrinthDep("required", "project", "gtnhmixins")
}
tasks.modrinth.dependsOn(build)
tasks.publish.dependsOn(tasks.modrinth)
}
if (curseForgeProjectId.size() != 0 && System.getenv("CURSEFORGE_TOKEN") != null) {
apply plugin: 'com.matthewprenger.cursegradle'
File changelogFile = new File(System.getenv("CHANGELOG_FILE") ?: "CHANGELOG.md")
curseforge {
apiKey = System.getenv("CURSEFORGE_TOKEN")
project {
id = curseForgeProjectId
if (changelogFile.exists()) {
changelogType = "markdown"
changelog = changelogFile
}
releaseType = identifiedVersion.endsWith("-pre") ? "beta" : "release"
addGameVersion minecraftVersion
addGameVersion "Forge"
mainArtifact jar
for (artifact in getSecondaryArtifacts()) addArtifact artifact
}
options {
javaIntegration = false
forgeGradleIntegration = false
debug = false
}
}
if (curseForgeRelations.size() != 0) {
String[] deps = curseForgeRelations.split(";")
deps.each { dep ->
if (dep.size() == 0) {
return
}
String[] parts = dep.split(":")
addCurseForgeRelation(parts[0], parts[1])
}
}
if (usesMixins.toBoolean()) {
addCurseForgeRelation("requiredDependency", "gtnhmixins")
}
tasks.curseforge.dependsOn(build)
tasks.publish.dependsOn(tasks.curseforge)
}
def addModrinthDep(scope, type, name) {
com.modrinth.minotaur.dependencies.Dependency dep;
if (!(scope in [
"required",
"optional",
"incompatible",
"embedded"
])) {
throw new Exception("Invalid modrinth dependency scope: " + scope)
}
switch (type) {
case "project":
dep = new ModDependency(name, scope)
break
case "version":
dep = new VersionDependency(name, scope)
break
default:
throw new Exception("Invalid modrinth dependency type: " + type)
}
project.modrinth.dependencies.add(dep)
}
def addCurseForgeRelation(type, name) {
if (!(type in [
"requiredDependency",
"embeddedLibrary",
"optionalDependency",
"tool",
"incompatible"
])) {
throw new Exception("Invalid CurseForge relation type: " + type)
}
CurseArtifact artifact = project.curseforge.curseProjects[0].mainArtifact
CurseRelation rel = (artifact.curseRelations ?: (artifact.curseRelations = new CurseRelation()))
rel."$type"(name)
}
// Updating
task updateBuildScript {
doLast {
@@ -653,7 +818,7 @@ task updateBuildScript {
}
}
if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
@@ -662,7 +827,40 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
}
static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/build.gradle")
}
static URL exampleSettingsGradleUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/settings.gradle.example")
}
static URL exampleGitAttributesUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/.gitattributes")
}
boolean verifyGitAttributes() {
def gitattributesFile = getFile(".gitattributes")
if (!gitattributesFile.exists()) {
println("Downloading default .gitattributes")
exampleGitAttributesUrl().withInputStream { i -> gitattributesFile.withOutputStream { it << i } }
exec {
workingDir '.'
commandLine 'git', 'add', '--renormalize', '.'
}
return true
}
return false
}
boolean verifySettingsGradle() {
def settingsFile = getFile("settings.gradle")
if (!settingsFile.exists()) {
println("Downloading default settings.gradle")
exampleSettingsGradleUrl().withInputStream { i -> settingsFile.withOutputStream { it << i } }
return true
}
return false
}
boolean performBuildScriptUpdate(String projectDir) {
@@ -670,6 +868,10 @@ boolean performBuildScriptUpdate(String projectDir) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
boolean settingsupdated = verifySettingsGradle()
settingsupdated = verifyGitAttributes() || settingsupdated
if (settingsupdated)
throw new GradleException("Settings has been updated, please re-run task.")
return true
}
return false
@@ -689,7 +891,7 @@ boolean isNewBuildScriptVersionAvailable(String projectDir) {
static String getVersionHash(String buildScriptContent) {
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
if(versionLine != null) {
if (versionLine != null) {
return versionLine.split(": ").last()
}
return ""
@@ -715,16 +917,16 @@ task deobfParams {
overwrite false
}
if(!file(paramsCSV).exists()) {
if (!file(paramsCSV).exists()) {
println("Extracting MCP archive ...")
unzip(mcpZIP, mcpDir)
}
println("Parsing params.csv ...")
Map<String, String> params = new HashMap<>()
Files.lines(Paths.get(paramsCSV)).forEach{line ->
Files.lines(Paths.get(paramsCSV)).forEach { line ->
String[] cells = line.split(",")
if(cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) {
if (cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) {
params.put(cells[0], cells[1])
}
}
@@ -737,8 +939,8 @@ task deobfParams {
static int replaceParams(File file, Map<String, String> params) {
int fileCount = 0
if(file.isDirectory()) {
for(File f : file.listFiles()) {
if (file.isDirectory()) {
for (File f : file.listFiles()) {
fileCount += replaceParams(f, params)
}
return fileCount
@@ -747,14 +949,14 @@ println("Visiting ${file.getName()} ...")
try {
String content = new String(Files.readAllBytes(file.toPath()))
int hash = content.hashCode()
params.forEach{key, value ->
params.forEach { key, value ->
content = content.replaceAll(key, value)
}
if(hash != content.hashCode()) {
if (hash != content.hashCode()) {
Files.write(file.toPath(), content.getBytes("UTF-8"))
return 1
}
} catch(Exception e) {
} catch (Exception e) {
e.printStackTrace()
}
return 0
@@ -805,16 +1007,16 @@ try {
//get rid of directories:
int lastSlash = fileName.lastIndexOf("/")
if(lastSlash > 0) {
if (lastSlash > 0) {
fileName = fileName.substring(lastSlash + 1)
}
//get rid of extension:
if(fileName.endsWith(".jar") || fileName.endsWith(".litemod")) {
if (fileName.endsWith(".jar") || fileName.endsWith(".litemod")) {
fileName = fileName.substring(0, fileName.lastIndexOf("."))
}
String hostName = url.getHost()
if(hostName.startsWith("www.")) {
if (hostName.startsWith("www.")) {
hostName = hostName.substring(4)
}
List parts = Arrays.asList(hostName.split("\\."))
@@ -822,7 +1024,7 @@ try {
hostName = String.join(".", parts)
return deobf(sourceURL, "$hostName/$fileName")
} catch(Exception e) {
} catch (Exception e) {
return deobf(sourceURL, "deobf/${sourceURL.hashCode()}")
}
}
@@ -837,12 +1039,13 @@ String bon2File = "$bon2Dir/BON2-${bon2Version}.jar"
String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar"
String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar"
if(file(deobfFile).exists()) {
if (file(deobfFile).exists()) {
return files(deobfFile)
}
String mappingsVer
if(remoteMappings) {
String remoteMappings = project.hasProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/'
if (remoteMappings) {
String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion"
String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip"
@@ -878,7 +1081,7 @@ return files(deobfFile)
def zipMappings(String zipPath, String url, String bon2Dir) {
File zipFile = new File(zipPath)
if(zipFile.exists()) {
if (zipFile.exists()) {
return
}
@@ -918,6 +1121,21 @@ if (!project.hasProperty(propertyName)) {
}
}
def propertyDefaultIfUnset(String propertyName, defaultValue) {
if (!project.hasProperty(propertyName) || project.property(propertyName) == "") {
project.ext.setProperty(propertyName, defaultValue)
}
}
def getFile(String relativePath) {
return new File(projectDir, relativePath)
}
def getSecondaryArtifacts() {
// Because noPublishedSources from the beginning of the script is somehow not visible here...
boolean noPublishedSources = project.hasProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
def secondaryArtifacts = [devJar]
if (!noPublishedSources) secondaryArtifacts += [sourcesJar]
if (apiPackage) secondaryArtifacts += [apiJar]
return secondaryArtifacts
}
+1 -1
View File
@@ -3,7 +3,7 @@
dependencies {
compile('com.github.GTNewHorizons:EnderCore:0.2.9:dev')
compile('com.github.GTNewHorizons:ForestryMC:4.4.6:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.15-GTNH:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.7-GTNH:dev')
compile('com.github.GTNewHorizons:BuildCraft:7.1.27:dev')
compile('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
shadowImplementation('cglib:cglib-nodep:3.3.0')
+3
View File
@@ -62,6 +62,9 @@ coreModClass =
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = true
Binary file not shown.
Vendored
+14 -17
View File
@@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@@ -154,19 +156,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -175,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
Vendored
+7 -18
View File
@@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -51,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -61,28 +64,14 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
+15 -3
View File
@@ -17,6 +17,7 @@ import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
@@ -24,6 +25,7 @@ import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import crazypants.enderio.api.IMC;
import crazypants.enderio.block.BlockDarkSteelAnvil;
@@ -150,7 +152,7 @@ import crazypants.enderio.material.endergy.ItemAlloyEndergy;
import crazypants.enderio.material.endergy.ItemGrindingBallEndergy;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.rail.BlockEnderRail;
import crazypants.enderio.teleport.ItemInfiniteTravelStaff;
import crazypants.enderio.teleport.ItemTeleportStaff;
import crazypants.enderio.teleport.ItemTravelStaff;
import crazypants.enderio.teleport.TeleportRecipes;
import crazypants.enderio.teleport.TravelController;
@@ -229,7 +231,7 @@ public class EnderIO {
public static BlockTelePad blockTelePad;
public static ItemCoordSelector itemCoordSelector;
public static ItemTravelStaff itemTravelStaff;
public static ItemInfiniteTravelStaff itemInfiniteTravelStaff;
public static ItemTeleportStaff itemTeleportStaff;
// Painter
public static BlockPainter blockPainter;
@@ -481,7 +483,7 @@ public class EnderIO {
itemYetaWench = ItemYetaWrench.create();
itemEnderface = ItemEnderface.create();
itemTravelStaff = ItemTravelStaff.create();
itemInfiniteTravelStaff = ItemInfiniteTravelStaff.create();
itemTeleportStaff = ItemTeleportStaff.create();
itemConduitProbe = ItemConduitProbe.create();
itemXpTransfer = ItemXpTransfer.create();
@@ -883,4 +885,14 @@ public class EnderIO {
public void serverStopped(FMLServerStoppedEvent event) {
HyperCubeRegister.unload();
}
@EventHandler
public void remap(FMLMissingMappingsEvent event) {
for (FMLMissingMappingsEvent.MissingMapping missingMapping : event.getAll()) {
if (missingMapping.type == GameRegistry.Type.ITEM
&& missingMapping.name.equals("EnderIO:itemInfiniteTravelStaff")) {
missingMapping.remap(itemTeleportStaff);
}
}
}
}
@@ -122,7 +122,7 @@ public enum ModObject {
itemEnderFood,
itemInfiniteTravelStaff;
itemTeleportStaff;
public final String unlocalisedName;
@@ -37,6 +37,29 @@ public enum TravelSource {
return Config.travelStaffPowerPerBlockRF;
}
},
TELEPORT_STAFF() {
@Override
public int getMaxDistanceTravelled() {
return Config.teleportStaffMaxDistance;
}
@Override
public float getPowerCostPerBlockTraveledRF() {
return 0f;
}
},
TELEPORT_STAFF_BLINK() {
@Override
public int getMaxDistanceTravelled() {
return Config.teleportStaffMaxBlinkDistance;
}
@Override
public float getPowerCostPerBlockTraveledRF() {
return 0f;
}
},
TELEPAD(EnderIO.DOMAIN + ":telepad.teleport");
public static int getMaxDistance() {
@@ -51,9 +74,12 @@ public enum TravelSource {
return 0;
}
return TravelController.instance.isTravelItemActive(player)
? TravelSource.STAFF.getMaxDistanceTravelledSq()
: TravelSource.BLOCK.getMaxDistanceTravelledSq();
TravelSource source = TravelController.instance.getTravelItemTravelSource(player);
if (source == null) {
return TravelSource.BLOCK.getMaxDistanceTravelledSq();
} else {
return source.getMaxDistanceTravelledSq();
}
}
public final String sound;
@@ -167,7 +167,11 @@ public class BlockConduitBundle extends BlockEio
IIcon tex = null;
TileConduitBundle cb = (TileConduitBundle) world.getTileEntity(target.blockX, target.blockY, target.blockZ);
TileEntity cbe = world.getTileEntity(target.blockX, target.blockY, target.blockZ);
if (!(cbe instanceof TileConduitBundle)) {
return false;
}
TileConduitBundle cb = (TileConduitBundle) cbe;
if (ConduitUtil.isSolidFacadeRendered(cb, Minecraft.getMinecraft().thePlayer)) {
if (cb.getFacadeId() != null) {
tex = cb.getFacadeId().getIcon(target.sideHit, cb.getFacadeMetadata());
@@ -258,7 +262,7 @@ public class BlockConduitBundle extends BlockEio
World world = EnderIO.proxy.getClientWorld();
BlockCoord bc = new BlockCoord(snd.getXPosF(), snd.getYPosF(), snd.getZPosF());
TileEntity te = bc.getTileEntity(world);
if (te != null && te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
if (te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playHitSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
@@ -275,7 +279,7 @@ public class BlockConduitBundle extends BlockEio
if ("EnderIO:silence.step".equals(path) && world.isRemote) {
BlockCoord bc = new BlockCoord(event.entity.posX, event.entity.posY - 2, event.entity.posZ);
TileEntity te = bc.getTileEntity(world);
if (te != null && te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
if (te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playStepSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
@@ -306,7 +310,11 @@ public class BlockConduitBundle extends BlockEio
}
if (ret == null && target != null && target.hitInfo instanceof CollidableComponent) {
CollidableComponent cc = (CollidableComponent) target.hitInfo;
TileConduitBundle bundle = (TileConduitBundle) world.getTileEntity(x, y, z);
TileEntity te = world.getTileEntity(x, y, z);
if (!(te instanceof TileConduitBundle)) {
return null;
}
TileConduitBundle bundle = (TileConduitBundle) te;
IConduit conduit = bundle.getConduit(cc.conduitType);
if (conduit != null) {
ret = conduit.createItem();
@@ -410,8 +418,10 @@ public class BlockConduitBundle extends BlockEio
@Override
public float getBlockHardness(World world, int x, int y, int z) {
IConduitBundle te = (IConduitBundle) world.getTileEntity(x, y, z);
return te != null && te.getFacadeType() == FacadeType.HARDENED ? blockHardness * 10 : blockHardness;
TileEntity te = world.getTileEntity(x, y, z);
return te instanceof IConduitBundle && ((IConduitBundle) te).getFacadeType() == FacadeType.HARDENED
? blockHardness * 10
: blockHardness;
}
@Override
@@ -425,8 +435,10 @@ public class BlockConduitBundle extends BlockEio
double explosionY,
double explosionZ) {
float resist = getExplosionResistance(par1Entity);
IConduitBundle te = (IConduitBundle) world.getTileEntity(x, y, z);
return te != null && te.getFacadeType() == FacadeType.HARDENED ? resist * 10 : resist;
TileEntity te = world.getTileEntity(x, y, z);
return te instanceof IConduitBundle && ((IConduitBundle) te).getFacadeType() == FacadeType.HARDENED
? resist * 10
: resist;
}
@SubscribeEvent
@@ -485,10 +497,11 @@ public class BlockConduitBundle extends BlockEio
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
IConduitBundle te = (IConduitBundle) world.getTileEntity(x, y, z);
if (te == null) {
TileEntity rte = world.getTileEntity(x, y, z);
if (!(rte instanceof IConduitBundle)) {
return true;
}
IConduitBundle te = (IConduitBundle) rte;
boolean breakBlock = true;
List<ItemStack> drop = new ArrayList<ItemStack>();
@@ -609,10 +622,11 @@ public class BlockConduitBundle extends BlockEio
public boolean onBlockActivated(
World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
IConduitBundle bundle = (IConduitBundle) world.getTileEntity(x, y, z);
if (bundle == null) {
TileEntity te = world.getTileEntity(x, y, z);
if (!(te instanceof IConduitBundle)) {
return false;
}
IConduitBundle bundle = (IConduitBundle) te;
ItemStack stack = player.getCurrentEquippedItem();
if (stack != null && stack.getItem() == EnderIO.itemConduitFacade) {
@@ -805,10 +819,11 @@ public class BlockConduitBundle extends BlockEio
@Override
public boolean tryRotateFacade(World world, int x, int y, int z, ForgeDirection axis) {
IConduitBundle bundle = (IConduitBundle) world.getTileEntity(x, y, z);
if (bundle == null) {
TileEntity te = world.getTileEntity(x, y, z);
if (!(te instanceof IConduitBundle)) {
return false;
}
IConduitBundle bundle = (IConduitBundle) te;
int oldMeta = bundle.getFacadeMetadata();
int newMeta = PainterUtil.rotateFacadeMetadata(bundle.getFacadeId(), oldMeta, axis);
@@ -157,6 +157,15 @@ public final class Config {
public static float travelAnchorZoomScale = 0.2f;
public static boolean travelStaffSearchOptimize = true;
/** The max distance for travelling to a Travel Anchor. */
public static int teleportStaffMaxDistance = 2048;
/** The max distance for travelling to player look. */
public static int teleportStaffMaxBlinkDistance = 512;
/**
* The distance travelled when no block is found within {@link #teleportStaffMaxBlinkDistance}.
*/
public static int teleportStaffFailedBlinkDistance = 64;
public static int enderIoRange = 8;
public static boolean enderIoMeAccessEnabled = true;
@@ -1181,6 +1190,27 @@ public final class Config {
+ "This config is experimental, so if you encounter any strange behavior, please report to GTNH developer.")
.getBoolean(travelStaffSearchOptimize);
teleportStaffMaxDistance = config.get(
sectionStaff.name,
"teleportStaffMaxDistance",
teleportStaffMaxDistance,
"Max number of blocks teleported when travelling to a Travel Anchor.")
.getInt(teleportStaffMaxDistance);
teleportStaffMaxBlinkDistance = config.get(
sectionStaff.name,
"teleportStaffMaxBlinkDistance",
teleportStaffMaxBlinkDistance,
"Max number of blocks teleported when travelling to player look.")
.getInt(teleportStaffMaxBlinkDistance);
teleportStaffFailedBlinkDistance = config.get(
sectionStaff.name,
"teleportStaffFailedBlinkDistance",
teleportStaffFailedBlinkDistance,
"Number of blocks teleported when no block is being looked at.")
.getInt(teleportStaffFailedBlinkDistance);
enderIoRange = config.get(
sectionEfficiency.name,
"enderIoRange",
@@ -55,22 +55,22 @@ public class KeyTracker {
public KeyTracker() {
glideKey = new KeyBinding(
EnderIO.lang.localize("keybind.glidertoggle"),
Keyboard.KEY_G,
Keyboard.KEY_NONE,
EnderIO.lang.localize("category.darksteelarmor"));
ClientRegistry.registerKeyBinding(glideKey);
soundDetectorKey = new KeyBinding(
EnderIO.lang.localize("keybind.soundlocator"),
Keyboard.KEY_L,
Keyboard.KEY_NONE,
EnderIO.lang.localize("category.darksteelarmor"));
ClientRegistry.registerKeyBinding(soundDetectorKey);
nightVisionKey = new KeyBinding(
EnderIO.lang.localize("keybind.nightvision"),
Keyboard.KEY_P,
Keyboard.KEY_NONE,
EnderIO.lang.localize("category.darksteelarmor"));
ClientRegistry.registerKeyBinding(nightVisionKey);
gogglesKey = new KeyBinding(
EnderIO.lang.localize("keybind.gogglesofrevealing"),
Keyboard.KEY_R,
Keyboard.KEY_NONE,
EnderIO.lang.localize("category.darksteelarmor"));
ClientRegistry.registerKeyBinding(gogglesKey);
@@ -94,12 +94,12 @@ public class KeyTracker {
yetaWrenchMode = new KeyBinding(
EnderIO.lang.localize("keybind.yetawrenchmode"),
Keyboard.KEY_Y,
Keyboard.KEY_NONE,
EnderIO.lang.localize("category.tools"));
ClientRegistry.registerKeyBinding(yetaWrenchMode);
magnetKey = new KeyBinding(
EnderIO.lang.localize("keybind.magnet"), Keyboard.CHAR_NONE, EnderIO.lang.localize("category.tools"));
EnderIO.lang.localize("keybind.magnet"), Keyboard.KEY_NONE, EnderIO.lang.localize("category.tools"));
ClientRegistry.registerKeyBinding(magnetKey);
}
@@ -155,38 +155,38 @@ public class KeyTracker {
}
private void handleJump() {
if (!JumpUpgrade.isEquipped(Minecraft.getMinecraft().thePlayer)) {
return;
}
if (jumpKey.isPressed()) {
if (!JumpUpgrade.isEquipped(Minecraft.getMinecraft().thePlayer)) {
return;
}
toggleDarkSteelController(Type.JUMP, "darksteel.upgrade.jump");
}
}
private void handleSpeed() {
if (!SpeedUpgrade.isEquipped(Minecraft.getMinecraft().thePlayer)) {
return;
}
if (speedKey.isPressed()) {
if (!SpeedUpgrade.isEquipped(Minecraft.getMinecraft().thePlayer)) {
return;
}
toggleDarkSteelController(Type.SPEED, "darksteel.upgrade.speed");
}
}
private void handleStepAssist() {
if (!JumpUpgrade.isEquipped(Minecraft.getMinecraft().thePlayer)) {
return;
}
if (stepAssistKey.isPressed()) {
if (!JumpUpgrade.isEquipped(Minecraft.getMinecraft().thePlayer)) {
return;
}
toggleDarkSteelController(Type.STEP_ASSIST, "darksteel.upgrade.stepAssist");
}
}
private void handleGoggles() {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (!GogglesOfRevealingUpgrade.isUpgradeEquipped(player)) {
return;
}
if (gogglesKey.isPressed()) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (!GogglesOfRevealingUpgrade.isUpgradeEquipped(player)) {
return;
}
boolean isActive = !DarkSteelItems.itemDarkSteelHelmet.isGogglesUgradeActive();
sendEnabledChatMessage("darksteel.upgrade.gogglesOfRevealing", isActive);
DarkSteelItems.itemDarkSteelHelmet.setGogglesUgradeActive(isActive);
@@ -235,20 +235,18 @@ public class KeyTracker {
}
private void handleGlide() {
if (!DarkSteelController.instance.isGliderUpgradeEquipped(Minecraft.getMinecraft().thePlayer)) {
return;
}
if (glideKey.isPressed()) {
if (glideKey.isPressed()
&& DarkSteelController.instance.isGliderUpgradeEquipped(Minecraft.getMinecraft().thePlayer)) {
toggleDarkSteelController(Type.GLIDE, "darksteel.upgrade.glider");
}
}
private void handleNightVision() {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (!DarkSteelController.instance.isNightVisionUpgradeOrEnchEquipped(player)) {
return;
}
if (nightVisionKey.isPressed()) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (!DarkSteelController.instance.isNightVisionUpgradeOrEnchEquipped(player)) {
return;
}
boolean isActive = !DarkSteelController.instance.isNightVisionActive();
if (isActive) {
player.worldObj.playSound(
@@ -276,10 +274,7 @@ public class KeyTracker {
public boolean isSoundDetectorUpgradeEquipped(EntityClientPlayerMP player) {
ItemStack helmet = player.getEquipmentInSlot(4);
SoundDetectorUpgrade upgrade = SoundDetectorUpgrade.loadFromItem(helmet);
if (upgrade == null) {
return false;
}
return true;
return upgrade != null;
}
public KeyBinding getYetaWrenchMode() {
@@ -44,6 +44,10 @@ public class CustomSeedFarmer implements IFarmerJoe {
if (ztonesSoil != null) {
addTilledBlock(ztonesSoil);
}
Block rtSoil = GameRegistry.findBlock("RandomThings", "fertilizedDirt_tilled");
if (rtSoil != null) {
addTilledBlock(rtSoil);
}
}
public void addTilledBlock(Block block) {
@@ -164,7 +164,7 @@ public class EnchanterRecipeHandler extends TemplateRecipeHandler {
int maxLevel = recipe.getEnchantment().getMaxLevel();
if (maxLevel > 1) {
int level = cycle % maxLevel + 1;
input.get(1).item.stackSize *= level;
input.get(1).item.stackSize = recipe.getItemsPerLevel() * level;
}
return input;
}
@@ -52,7 +52,7 @@ public class NEIEnderIOConfig implements IConfigureNEI {
}
if (!Config.travelAnchorEnabled) {
API.hideItem(new ItemStack(EnderIO.itemTravelStaff));
API.hideItem(new ItemStack(EnderIO.itemInfiniteTravelStaff));
API.hideItem(new ItemStack(EnderIO.itemTeleportStaff));
}
if (!Config.reinforcedObsidianEnabled) {
API.hideItem(new ItemStack(EnderIO.blockReinforcedObsidian));
@@ -124,7 +124,7 @@ public class SagMillRecipeHandler extends TemplateRecipeHandler {
}
@Override
public List<String> handleItemTooltip(GuiRecipe gui, ItemStack stack, List<String> currenttip, int recipeIndex) {
public List<String> handleItemTooltip(GuiRecipe<?> gui, ItemStack stack, List<String> currenttip, int recipeIndex) {
MillRecipe recipe = (MillRecipe) arecipes.get(recipeIndex);
float chance = recipe.getChanceForOutput(stack);
if (chance > 0 && chance < 1) {
@@ -189,12 +189,12 @@ public class VatRecipeHandler extends TemplateRecipeHandler {
}
@Override
public List<String> handleItemTooltip(GuiRecipe gui, ItemStack stack, List<String> currenttip, int recipeIndex) {
public List<String> handleItemTooltip(GuiRecipe<?> gui, ItemStack stack, List<String> currenttip, int recipeIndex) {
return currenttip;
}
@Override
public List<String> handleTooltip(GuiRecipe gui, List<String> currenttip, int recipeIndex) {
public List<String> handleTooltip(GuiRecipe<?> gui, List<String> currenttip, int recipeIndex) {
InnerVatRecipe rec = (InnerVatRecipe) arecipes.get(recipeIndex);
Point pos = GuiDraw.getMousePosition();
Point offset = gui.getRecipePosition(recipeIndex);
@@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.ModObject;
import crazypants.enderio.api.teleport.TravelSource;
import crazypants.enderio.machine.power.PowerDisplayUtil;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -14,15 +15,15 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemInfiniteTravelStaff extends ItemTravelStaff {
public class ItemTeleportStaff extends ItemTravelStaff {
protected ItemInfiniteTravelStaff() {
protected ItemTeleportStaff() {
super();
setUnlocalizedName(ModObject.itemInfiniteTravelStaff.name());
setUnlocalizedName(ModObject.itemTeleportStaff.name());
}
public static ItemInfiniteTravelStaff create() {
ItemInfiniteTravelStaff result = new ItemInfiniteTravelStaff();
public static ItemTeleportStaff create() {
ItemTeleportStaff result = new ItemTeleportStaff();
result.init();
return result;
}
@@ -31,12 +32,12 @@ public class ItemInfiniteTravelStaff extends ItemTravelStaff {
if (ep == null || ep.getCurrentEquippedItem() == null) {
return false;
}
return ep.getCurrentEquippedItem().getItem() == EnderIO.itemInfiniteTravelStaff;
return ep.getCurrentEquippedItem().getItem() == EnderIO.itemTeleportStaff;
}
@Override
protected void init() {
GameRegistry.registerItem(this, ModObject.itemInfiniteTravelStaff.unlocalisedName);
GameRegistry.registerItem(this, ModObject.itemTeleportStaff.unlocalisedName);
}
@Override
@@ -47,12 +48,32 @@ public class ItemInfiniteTravelStaff extends ItemTravelStaff {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
itemIcon = IIconRegister.registerIcon("enderio:itemInfiniteTravelStaff");
itemIcon = IIconRegister.registerIcon("enderio:itemTeleportStaff");
}
@Override
public ItemStack onItemRightClick(ItemStack equipped, World world, EntityPlayer player) {
if (world.isRemote) {
if (player.isSneaking()) {
TravelController.instance.activateTravelAccessable(
equipped, world, player, TravelSource.TELEPORT_STAFF);
} else {
TravelController.instance.doTeleport(player);
}
}
player.swingItem();
return equipped;
}
@Override
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
// Don't allow extracting energy.
return 0;
}
@Override
public void extractInternal(ItemStack item, int powerUse) {
return;
// Do nothing, as we have infinite energy.
}
@Override
@@ -80,10 +101,4 @@ public class ItemInfiniteTravelStaff extends ItemTravelStaff {
public boolean isActive(EntityPlayer ep, ItemStack equipped) {
return isEquipped(ep);
}
@Override
@SideOnly(Side.CLIENT)
public boolean isFull3D() {
return true;
}
}
@@ -24,12 +24,19 @@ import crazypants.enderio.config.Config;
import crazypants.enderio.enderface.TileEnderIO;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.teleport.packet.PacketDrainStaff;
import crazypants.enderio.teleport.packet.PacketLongDistanceTravelEvent;
import crazypants.enderio.teleport.packet.PacketOpenAuthGui;
import crazypants.enderio.teleport.packet.PacketTravelEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
@@ -52,6 +59,14 @@ public class TravelController {
public static final TravelController instance = new TravelController();
/**
* Server-side only list of valid travel destinations (travel anchors and active telepads).
*
* <p>This is used by {@code PacketLongDistanceTravelEvent} to try to find travel destinations that
* are out of client render range.
*/
public Set<BlockCoord> travelDestinations = new HashSet<>();
private Random rand = new Random();
private boolean wasJumping = false;
@@ -99,6 +114,9 @@ public class TravelController {
public boolean activateTravelAccessable(ItemStack equipped, World world, EntityPlayer player, TravelSource source) {
if (!hasTarget()) {
PacketLongDistanceTravelEvent p = new PacketLongDistanceTravelEvent(player, false, source);
PacketHandler.INSTANCE.sendToServer(p);
// We have no way of knowing if it will succeed, so just return false.
return false;
}
BlockCoord target = selectedCoord;
@@ -120,6 +138,8 @@ public class TravelController {
}
public boolean doBlink(ItemStack equipped, EntityPlayer player) {
TravelSource source = TravelSource.STAFF_BLINK;
Vector3d eye = Util.getEyePositionEio(player);
Vector3d look = Util.getLookVecEio(player);
@@ -146,7 +166,7 @@ public class TravelController {
sample.add(eye);
// we test against our feets location
sample.y -= playerHeight;
if (doBlinkAround(player, sample, true)) {
if (doBlinkAround(player, source, sample, true)) {
return true;
}
}
@@ -184,7 +204,7 @@ public class TravelController {
// we test against our feets location
sample.y -= playerHeight;
if (doBlinkAround(player, sample, false)) {
if (doBlinkAround(player, source, sample, false)) {
return true;
}
teleDistance++;
@@ -200,7 +220,7 @@ public class TravelController {
// we test against our feets location
sample.y -= playerHeight;
if (doBlinkAround(player, sample, false)) {
if (doBlinkAround(player, source, sample, false)) {
return true;
}
sampleDistance--;
@@ -210,6 +230,116 @@ public class TravelController {
return false;
}
/** This is the teleport staff super-teleport. */
public boolean doTeleport(EntityPlayer player) {
TravelSource source = TravelSource.TELEPORT_STAFF_BLINK;
Vector3d eye = Util.getEyePositionEio(player);
Vector3d look = Util.getLookVecEio(player);
double playerHeight = player.yOffset;
// +2 to compensate for the standard distance decrement of -2
double teleDistance = Config.teleportStaffFailedBlinkDistance + 2;
Vec3 eye3 = Vec3.createVectorHelper(eye.x, eye.y, eye.z);
// rayTraceBlocks has a limit of 200 distance.
double maxDistance = Config.teleportStaffMaxBlinkDistance;
double currDistance = 0;
Vec3 pos = eye3;
boolean loop = true;
while (loop) {
double distance = 200;
if (maxDistance - currDistance < 200) {
distance = maxDistance - currDistance;
loop = false;
}
Vector3d sample = new Vector3d(look);
sample.scale(distance);
sample.add(eye);
Vec3 end = Vec3.createVectorHelper(sample.x, sample.y, sample.z);
MovingObjectPosition p =
player.worldObj.rayTraceBlocks(pos, end, !Config.travelStaffBlinkThroughClearBlocksEnabled);
if (p != null) {
teleDistance = VecmathUtil.distance(eye, new Vector3d(p.blockX + 0.5, p.blockY + 0.5, p.blockZ + 0.5));
break;
}
pos = end;
currDistance += distance;
}
Vector3d sample = new Vector3d(look);
sample.scale(Config.teleportStaffMaxBlinkDistance);
sample.add(eye);
Vec3 end = Vec3.createVectorHelper(sample.x, sample.y, sample.z);
MovingObjectPosition p =
player.worldObj.rayTraceBlocks(eye3, end, !Config.travelStaffBlinkThroughClearBlocksEnabled);
if (p != null) {
teleDistance = VecmathUtil.distance(eye, new Vector3d(p.blockX + 0.5, p.blockY + 0.5, p.blockZ + 0.5));
}
double distanceIncrement = -2;
// Special case: if the targeted block is too close, we'll try to teleport through it.
if (teleDistance < 3) {
distanceIncrement = 2;
}
for (int i = 0; i < 8; i++) {
teleDistance += distanceIncrement;
sample.set(look);
sample.scale(teleDistance);
sample.add(eye);
// we test against our feets location
sample.y -= playerHeight;
if (doBlinkAround(player, source, sample, false)) {
return true;
}
}
return false;
}
/** Returns empty optional if no travel destination was found. */
public Optional<BlockCoord> findTravelDestination(EntityPlayer player, TravelSource source) {
Vector3d eye = Util.getEyePositionEio(player);
Vector3d look = Util.getLookVecEio(player);
// Map of distance to coordinate for eligible travel destinations (within angle).
Map<Double, BlockCoord> distanceMap = new TreeMap<>();
// Limit the max distance at which we'll display an out of range message.
// Otherwise, you could trigger the message for any travel anchor on the entire server.
double maxMessageDistance = 1.25 * source.getMaxDistanceTravelled();
boolean displayOutOfRangeMessage = false;
for (BlockCoord p : travelDestinations) {
Vector3d block = new Vector3d(p.x + 0.5, p.y + 0.5, p.z + 0.5);
block.sub(eye);
double distance = block.length();
if (distance > maxMessageDistance) {
continue;
}
block.normalize();
double angle = Math.acos(look.dot(block));
// Roughly 5 degrees
if (angle < 0.087) {
if (distance > source.getMaxDistanceTravelled()) {
displayOutOfRangeMessage = true;
} else {
distanceMap.put(distance, p);
}
}
}
if (displayOutOfRangeMessage && distanceMap.isEmpty()) {
player.addChatComponentMessage(new ChatComponentTranslation("enderio.blockTravelPlatform.outOfRange"));
}
return distanceMap.values().stream().findFirst();
}
private boolean isBlackListedBlock(EntityPlayer player, MovingObjectPosition pos, Block hitBlock) {
UniqueIdentifier ui = GameRegistry.findUniqueIdentifierFor(hitBlock);
if (ui == null) {
@@ -220,22 +350,25 @@ public class TravelController {
|| !Config.travelStaffBlinkThroughUnbreakableBlocksEnabled);
}
private boolean doBlinkAround(EntityPlayer player, Vector3d sample, boolean conserveMomentum) {
if (doBlink(
private boolean doBlinkAround(EntityPlayer player, TravelSource source, Vector3d sample, boolean conserveMomentum) {
if (travelToLocation(
player,
source,
new BlockCoord((int) Math.floor(sample.x), (int) Math.floor(sample.y), (int) Math.floor(sample.z)),
conserveMomentum)) {
return true;
}
if (doBlink(
if (travelToLocation(
player,
source,
new BlockCoord((int) Math.floor(sample.x), (int) Math.floor(sample.y) + 1, (int) Math.floor(sample.z)),
conserveMomentum)) {
return true;
}
if (!Config.travelStaffSearchOptimize) {
if (doBlink(
if (travelToLocation(
player,
source,
new BlockCoord(
(int) Math.floor(sample.x), (int) Math.floor(sample.y) - 1, (int) Math.floor(sample.z)),
conserveMomentum)) {
@@ -245,10 +378,6 @@ public class TravelController {
return false;
}
private boolean doBlink(EntityPlayer player, BlockCoord coord, boolean conserveMomentum) {
return travelToLocation(player, TravelSource.STAFF_BLINK, coord, conserveMomentum);
}
public boolean showTargets() {
return showTargets && selectionEnabled;
}
@@ -410,14 +539,26 @@ public class TravelController {
}
public boolean isTravelItemActive(EntityPlayer ep) {
return getTravelItemTravelSource(ep) != null;
}
/** Returns null if no travel item is equipped. */
@Nullable
public TravelSource getTravelItemTravelSource(EntityPlayer ep) {
if (ep == null || ep.getCurrentEquippedItem() == null) {
return false;
return null;
}
ItemStack equipped = ep.getCurrentEquippedItem();
if (equipped.getItem() instanceof IItemOfTravel) {
return ((IItemOfTravel) equipped.getItem()).isActive(ep, equipped);
if (equipped.getItem() instanceof ItemTravelStaff) {
if (((ItemTravelStaff) equipped.getItem()).isActive(ep, equipped)) {
return TravelSource.TELEPORT_STAFF;
}
} else if (equipped.getItem() instanceof IItemOfTravel) {
if (((IItemOfTravel) equipped.getItem()).isActive(ep, equipped)) {
return TravelSource.STAFF;
}
}
return false;
return null;
}
public boolean travelToSelectedTarget(EntityPlayer player, TravelSource source, boolean conserveMomentum) {
@@ -427,7 +568,7 @@ public class TravelController {
public boolean travelToLocation(
EntityPlayer player, TravelSource source, BlockCoord coord, boolean conserveMomentum) {
if (source != TravelSource.STAFF_BLINK) {
if (source != TravelSource.STAFF_BLINK && source != TravelSource.TELEPORT_STAFF_BLINK) {
TileEntity te = player.worldObj.getTileEntity(coord.x, coord.y, coord.z);
if (te instanceof ITravelAccessable) {
ITravelAccessable ta = (ITravelAccessable) te;
@@ -446,13 +587,13 @@ public class TravelController {
}
if (!isInRangeTarget(player, coord, source.getMaxDistanceTravelledSq())) {
if (source != TravelSource.STAFF_BLINK) {
if (source != TravelSource.STAFF_BLINK && source != TravelSource.TELEPORT_STAFF_BLINK) {
player.addChatComponentMessage(new ChatComponentTranslation("enderio.blockTravelPlatform.outOfRange"));
}
return false;
}
if (!isValidTarget(player, coord, source)) {
if (source != TravelSource.STAFF_BLINK) {
if (source != TravelSource.STAFF_BLINK && source != TravelSource.TELEPORT_STAFF_BLINK) {
player.addChatComponentMessage(
new ChatComponentTranslation("enderio.blockTravelPlatform.invalidTarget"));
}
@@ -515,7 +656,7 @@ public class TravelController {
}
World w = player.worldObj;
BlockCoord baseLoc = bc;
if (source != TravelSource.STAFF_BLINK) {
if (source != TravelSource.STAFF_BLINK && source != TravelSource.TELEPORT_STAFF_BLINK) {
// targeting a block so go one up
baseLoc = bc.getLocation(ForgeDirection.UP);
}
@@ -757,10 +898,11 @@ public class TravelController {
@SideOnly(Side.CLIENT)
private int getMaxTravelDistanceSqForPlayer(EntityPlayer player) {
if (isTravelItemActive(player)) {
return TravelSource.STAFF.getMaxDistanceTravelledSq();
TravelSource source = getTravelItemTravelSource(player);
if (source == null) {
return TravelSource.BLOCK.getMaxDistanceTravelledSq();
}
return TravelSource.BLOCK.getMaxDistanceTravelledSq();
return source.getMaxDistanceTravelledSq();
}
@SideOnly(Side.CLIENT)
@@ -26,6 +26,7 @@ import crazypants.enderio.teleport.GuiTravelAuth;
import crazypants.enderio.teleport.packet.PacketAccessMode;
import crazypants.enderio.teleport.packet.PacketDrainStaff;
import crazypants.enderio.teleport.packet.PacketLabel;
import crazypants.enderio.teleport.packet.PacketLongDistanceTravelEvent;
import crazypants.enderio.teleport.packet.PacketOpenAuthGui;
import crazypants.enderio.teleport.packet.PacketPassword;
import crazypants.enderio.teleport.packet.PacketTravelEvent;
@@ -60,6 +61,11 @@ public class BlockTravelAnchor extends BlockEio
PacketLabel.class, PacketLabel.class, PacketHandler.nextID(), Side.SERVER);
PacketHandler.INSTANCE.registerMessage(
PacketTravelEvent.class, PacketTravelEvent.class, PacketHandler.nextID(), Side.SERVER);
PacketHandler.INSTANCE.registerMessage(
PacketLongDistanceTravelEvent.class,
PacketLongDistanceTravelEvent.class,
PacketHandler.nextID(),
Side.SERVER);
PacketHandler.INSTANCE.registerMessage(
PacketDrainStaff.class, PacketDrainStaff.class, PacketHandler.nextID(), Side.SERVER);
PacketHandler.INSTANCE.registerMessage(
@@ -6,6 +6,7 @@ import crazypants.enderio.TileEntityEio;
import crazypants.enderio.api.teleport.ITravelAccessable;
import crazypants.enderio.api.teleport.TravelSource;
import crazypants.enderio.machine.painter.IPaintableTileEntity;
import crazypants.enderio.teleport.TravelController;
import crazypants.util.UserIdent;
import java.util.ArrayList;
import java.util.List;
@@ -329,4 +330,24 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
public void setVisible(boolean visible) {
this.visible = visible;
}
@Override
public void validate() {
super.validate();
if (isTravelSource()) {
TravelController.instance.travelDestinations.add(getLocation());
}
}
@Override
public void invalidate() {
super.invalidate();
TravelController.instance.travelDestinations.remove(getLocation());
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
TravelController.instance.travelDestinations.remove(getLocation());
}
}
@@ -65,9 +65,11 @@ public class TravelEntitySpecialRenderer extends TileEntitySpecialRenderer {
Vector3d eye = Util.getEyePositionEio(Minecraft.getMinecraft().thePlayer);
Vector3d loc = new Vector3d(tileentity.xCoord + 0.5, tileentity.yCoord + 0.5, tileentity.zCoord + 0.5);
double maxDistance = TravelController.instance.isTravelItemActive(Minecraft.getMinecraft().thePlayer)
? TravelSource.STAFF.getMaxDistanceTravelledSq()
: TravelSource.BLOCK.getMaxDistanceTravelledSq();
double maxDistance = TravelSource.BLOCK.getMaxDistanceTravelledSq();
TravelSource source = TravelController.instance.getTravelItemTravelSource(Minecraft.getMinecraft().thePlayer);
if (source != null) {
maxDistance = source.getMaxDistanceTravelledSq();
}
if (eye.distanceSquared(loc) > maxDistance) {
return;
}
@@ -0,0 +1,119 @@
package crazypants.enderio.teleport.packet;
import com.enderio.core.common.util.BlockCoord;
import com.enderio.core.common.util.Util;
import com.enderio.core.common.vecmath.Vector3d;
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 crazypants.enderio.api.teleport.IItemOfTravel;
import crazypants.enderio.api.teleport.TeleportEntityEvent;
import crazypants.enderio.api.teleport.TravelSource;
import crazypants.enderio.teleport.TravelController;
import io.netty.buffer.ByteBuf;
import java.util.Optional;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.server.S12PacketEntityVelocity;
import net.minecraftforge.common.MinecraftForge;
public class PacketLongDistanceTravelEvent
implements IMessage, IMessageHandler<PacketLongDistanceTravelEvent, IMessage> {
boolean conserveMotion;
int entityId;
int source;
public PacketLongDistanceTravelEvent() {}
public PacketLongDistanceTravelEvent(Entity entity, boolean conserveMotion, TravelSource source) {
this.conserveMotion = conserveMotion;
this.entityId = entity instanceof EntityPlayer ? -1 : entity.getEntityId();
this.source = source.ordinal();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeBoolean(conserveMotion);
buf.writeInt(entityId);
buf.writeInt(source);
}
@Override
public void fromBytes(ByteBuf buf) {
conserveMotion = buf.readBoolean();
entityId = buf.readInt();
source = buf.readInt();
}
@Override
public IMessage onMessage(PacketLongDistanceTravelEvent message, MessageContext ctx) {
Entity toTp = message.entityId == -1
? ctx.getServerHandler().playerEntity
: ctx.getServerHandler().playerEntity.worldObj.getEntityByID(message.entityId);
TravelSource source = TravelSource.values()[message.source];
doServerTeleport(toTp, message.conserveMotion, source);
return null;
}
public static boolean doServerTeleport(Entity toTp, boolean conserveMotion, TravelSource source) {
EntityPlayer player = toTp instanceof EntityPlayer ? (EntityPlayer) toTp : null;
Optional<BlockCoord> travelDestination = TravelController.instance.findTravelDestination(player, source);
if (!travelDestination.isPresent()) {
return false;
}
BlockCoord destination = travelDestination.get();
int x = destination.x;
int y = destination.y;
int z = destination.z;
int powerUse = TravelController.instance.getRequiredPower(player, source, destination);
if (powerUse < 0) {
return false;
}
TeleportEntityEvent evt = new TeleportEntityEvent(toTp, source, x, y, z);
if (MinecraftForge.EVENT_BUS.post(evt)) {
return false;
}
x = evt.targetX;
y = evt.targetY;
z = evt.targetZ;
toTp.worldObj.playSoundEffect(toTp.posX, toTp.posY, toTp.posZ, source.sound, 1.0F, 1.0F);
toTp.playSound(source.sound, 1.0F, 1.0F);
if (player != null) {
player.setPositionAndUpdate(x + 0.5, y + 1.1, z + 0.5);
} else {
toTp.setPosition(x, y, z);
}
toTp.worldObj.playSoundEffect(x, y, z, source.sound, 1.0F, 1.0F);
toTp.fallDistance = 0;
if (player != null) {
if (conserveMotion) {
Vector3d velocityVex = Util.getLookVecEio(player);
S12PacketEntityVelocity p =
new S12PacketEntityVelocity(toTp.getEntityId(), velocityVex.x, velocityVex.y, velocityVex.z);
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(p);
}
if (powerUse > 0
&& player.getCurrentEquippedItem() != null
&& player.getCurrentEquippedItem().getItem() instanceof IItemOfTravel) {
ItemStack item = player.getCurrentEquippedItem().copy();
((IItemOfTravel) item.getItem()).extractInternal(item, powerUse);
toTp.setCurrentItemOrArmor(0, item);
}
}
return true;
}
}
@@ -46,7 +46,7 @@ public class TelePadSpecialRenderer extends TravelEntitySpecialRenderer {
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float p_147500_8_) {
TileTelePad tp = (TileTelePad) te;
if (tp.isMaster() && tp.inNetwork()) {
if (tp.isTravelSource()) {
TravelController.instance.addCandidate(tp.getLocation());
{
GL11.glPushMatrix();
@@ -243,6 +243,7 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
}
this.master = this;
this.isMaster = true;
TravelController.instance.travelDestinations.add(getLocation());
return true;
}
@@ -260,6 +261,7 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
telepad.updateNeighborTEs();
}
}
TravelController.instance.travelDestinations.remove(getLocation());
}
private List<BlockCoord> getSurroundingCoords() {
@@ -693,7 +695,7 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
@Override
public boolean canSeeBlock(EntityPlayer playerName) {
return isMaster() && inNetwork();
return isTravelSource();
}
/* IInternalPowerReceiver */
@@ -1216,7 +1216,7 @@ enderio.weatherObelisk.fuelTank=Barometric Flux Tank
enchantment.enderio.soulBound=Soulbound
description.enchantment.enderio.soulBound=Prevents item from being lost on death
enderio.category.darksteelarmor=Dark Steel Armor
enderio.category.tools=Tools
enderio.category.tools=EnderIO - Tools
enderio.keybind.glidertoggle=Glider Toggle
enderio.keybind.gogglesofrevealing=Goggles of Revealing
enderio.keybind.nightvision=Night Vision
@@ -1107,7 +1107,7 @@ enderio.config.spawner.tooltip=Mir sind die geistreichen Tooltips ausgegangen
#Keybinds/Waila/NEI/Tooltips
enderio.category.darksteelarmor=Dunkelstahlrüstung
enderio.category.tools=Werkzeuge
enderio.category.tools=EnderIO - Werkzeuge
enderio.keybind.glidertoggle=Gleiterschaltung
enderio.keybind.gogglesofrevealing=Brille der Enthüllung
enderio.keybind.nightvision=Nachtsicht
@@ -726,12 +726,12 @@ item.itemTravelStaff.tooltip.detailed.line4=Shift-R-Click will teleport the
item.itemTravelStaff.tooltip.detailed.line5=player a short distance
enderio.itemTravelStaff.notEnoughPower=Not enough power
item.itemInfiniteTravelStaff.name=Creative Staff of Traveling
item.itemInfiniteTravelStaff.tooltip.detailed.line1=When held Travel Anchors and EnderIO
item.itemInfiniteTravelStaff.tooltip.detailed.line2=blocks become visible and can be
item.itemInfiniteTravelStaff.tooltip.detailed.line3=activated by R-Click
item.itemInfiniteTravelStaff.tooltip.detailed.line4=Shift-R-Click will teleport the
item.itemInfiniteTravelStaff.tooltip.detailed.line5=player a short distance
item.itemTeleportStaff.name=Staff of Teleportation
item.itemTeleportStaff.tooltip.detailed.line1=R-Click to teleport wherever you are looking
item.itemTeleportStaff.tooltip.detailed.line2=Shift-R-Click to teleport to Travel Anchors
item.itemTeleportStaff.tooltip.detailed.line3=R-Click on a nearby block to try to teleport
item.itemTeleportStaff.tooltip.detailed.line4=to the other side
item.itemCoordSelector.name=Coordinate Selector
item.itemCoordSelector.tooltip.detailed.line1=Stores coordinates of a block.
item.itemCoordSelector.tooltip.detailed.line2=Right click at block to select
@@ -1375,7 +1375,7 @@ enderio.config.spawner.tooltip=I ran out of witty tooltips.
#Keybinds/Waila/NEI/Tooltips
enderio.category.darksteelarmor=Dark Steel Armor
enderio.category.tools=Tools
enderio.category.tools=EnderIO - Tools
enderio.keybind.glidertoggle=Glider Toggle
enderio.keybind.gogglesofrevealing=Goggles of Revealing
enderio.keybind.nightvision=Night Vision
@@ -976,7 +976,7 @@ enderio.config.spawner.tooltip=Me he quedado sin descripciones ingeniosas.
#Keybinds/Waila/NEI/Tooltips
enderio.category.darksteelarmor=Armadura de Acero Oscuro
enderio.category.tools=Herramientas
enderio.category.tools=EnderIO - Herramientas
enderio.keybind.glidertoggle=Activar/Desactivar Planeador
enderio.keybind.gogglesofrevealing=Gafas de Revelación
enderio.keybind.nightvision=Visión Nocturna
@@ -978,7 +978,7 @@ enderio.config.spawner.tooltip=Me he quedado sin descripciones ingeniosas.
#Keybinds/Waila/NEI/Tooltips
enderio.category.darksteelarmor=Armadura de Acero Oscuro
enderio.category.tools=Herramientas
enderio.category.tools=EnderIO - Herramientas
enderio.keybind.glidertoggle=Activar/Desactivar Planeador
enderio.keybind.gogglesofrevealing=Gafas de Revelación
enderio.keybind.nightvision=Visión Nocturna
@@ -976,7 +976,7 @@ enderio.config.spawner.tooltip=Me he quedado sin descripciones ingeniosas.
#Keybinds/Waila/NEI/Tooltips
enderio.category.darksteelarmor=Armadura de Acero Oscuro
enderio.category.tools=Herramientas
enderio.category.tools=EnderIO - Herramientas
enderio.keybind.glidertoggle=Activar/Desactivar Planeador
enderio.keybind.gogglesofrevealing=Gafas de Revelación
enderio.keybind.nightvision=Visión Nocturna
@@ -976,7 +976,7 @@ enderio.config.spawner.tooltip=Me he quedado sin descripciones ingeniosas.
#Keybinds/Waila/NEI/Tooltips
enderio.category.darksteelarmor=Armadura de Acero Oscuro
enderio.category.tools=Herramientas
enderio.category.tools=EnderIO - Herramientas
enderio.keybind.glidertoggle=Activar/Desactivar Planeador
enderio.keybind.gogglesofrevealing=Gafas de Revelación
enderio.keybind.nightvision=Visión Nocturna
@@ -976,7 +976,7 @@ enderio.config.spawner.tooltip=Me he quedado sin descripciones ingeniosas.
#Keybinds/Waila/NEI/Tooltips
enderio.category.darksteelarmor=Armadura de Acero Oscuro
enderio.category.tools=Herramientas
enderio.category.tools=EnderIO - Herramientas
enderio.keybind.glidertoggle=Activar/Desactivar Planeador
enderio.keybind.gogglesofrevealing=Gafas de Revelación
enderio.keybind.nightvision=Visión Nocturna
@@ -993,7 +993,7 @@ enderio.config.spawner.tooltip=Je suis a cours d'infobulles marrantes.
#Keybinds/Waila/NEI/Tooltips
enderio.category.darksteelarmor=Armure d'Acier Sombre
enderio.category.tools=Outils
enderio.category.tools=EnderIO - Outils
enderio.keybind.glidertoggle=Mode Planeur
enderio.keybind.gogglesofrevealing=Lunettes de Révélation
enderio.keybind.nightvision=Vision Nocturne
@@ -1289,7 +1289,7 @@ enderio.config.spawner.tooltip=У меня закончились остроум
#Keybinds/Waila/NEI/Tooltips
enderio.category.darksteelarmor=Броня из тёмной стали
enderio.category.tools=Инструменты
enderio.category.tools=EnderIO - Инструменты
enderio.keybind.glidertoggle=Переключить планер
enderio.keybind.gogglesofrevealing=Очки откровения
enderio.keybind.nightvision=Ночное зрение
@@ -1369,7 +1369,7 @@ enderio.config.spawner.tooltip=我已经想不出什么有趣的提示文本了.
#Keybinds/Waila/NEI/Tooltips
enderio.category.darksteelarmor=玄铁护甲
enderio.category.tools=工具
enderio.category.tools=EnderIO - 工具
enderio.keybind.glidertoggle=滑翔开关
enderio.keybind.gogglesofrevealing=揭示护目镜
enderio.keybind.nightvision=夜视
@@ -1391,4 +1391,4 @@ enderio.tooltip.oredict=矿物辞典:
enderio.tooltip.meta=Meta:
enderio.tooltip.uid=UID:
enderio.tooltip.anvilupgrades=铁砧升级:
enderio.waila.config.hiddenfacades=隐形栅栏
enderio.waila.config.hiddenfacades=隐形栅栏
@@ -1225,7 +1225,7 @@ enderio.gui.weather.requiredfluid=Required Fluid: %s L
enderio.weatherObelisk.fuelTank=Barometric Flux Tank
description.enchantment.enderio.soulBound=Prevents item from being lost on death
enderio.category.darksteelarmor=Dark Steel Armor
enderio.category.tools=Tools
enderio.category.tools=EnderIO - Tools
enderio.keybind.glidertoggle=Glider Toggle
enderio.keybind.gogglesofrevealing=Goggles of Revealing
enderio.keybind.nightvision=Night Vision
Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB