From 05cd61286ee5569af05ef8c40fae8d84bbd79665 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Tue, 6 Feb 2024 16:32:45 +0100 Subject: [PATCH] migrate to gtnh build script --- .editorconfig | 22 + .gitattributes | 44 ++ .github/workflows/build-and-test.yml | 13 + .github/workflows/release-tags.yml | 14 + .gitignore | 64 +- CODEOWNERS | 3 + build.gradle | 368 +--------- dependencies.gradle | 38 + gradle.properties | 183 +++++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43462 bytes gradle/wrapper/gradle-wrapper.properties | 7 + gradlew | 249 +++++++ gradlew.bat | 92 +++ jitpack.yml | 2 + repositories.gradle | 5 + settings.gradle | 21 + .../lookingglass/api/APIVersionRemoved.java | 18 - .../lookingglass/api/IWorldViewAPI.java | 27 - .../api/animator/CameraAnimatorPivot.java | 184 ----- .../api/animator/CameraAnimatorPlayer.java | 102 --- .../api/animator/ICameraAnimator.java | 24 - .../lookingglass/api/hook/WorldViewAPI2.java | 33 - .../lookingglass/api/view/IViewCamera.java | 85 --- .../lookingglass/api/view/IWorldView.java | 47 -- .../xcompwiz/lookingglass/LookingGlass.java | 160 +++-- .../lookingglass/api/APIInstanceProvider.java | 109 +-- .../lookingglass/api/APIUndefined.java | 35 +- .../lookingglass/api/APIVersionRemoved.java | 20 + .../lookingglass/api/APIVersionUndefined.java | 35 +- .../lookingglass/api/IWorldViewAPI.java | 29 + .../api/animator/CameraAnimatorPivot.java | 199 +++++ .../api/animator/CameraAnimatorPlayer.java | 111 +++ .../api/animator/ICameraAnimator.java | 26 + .../api/event/ClientWorldInfoEvent.java | 14 +- .../lookingglass/api/hook/WorldViewAPI2.java | 38 + .../lookingglass/api/package-info.java | 18 +- .../lookingglass/api/view/IViewCamera.java | 96 +++ .../lookingglass/api/view/IWorldView.java | 50 ++ .../lookingglass/apiimpl/APIProviderImpl.java | 279 ++++---- .../lookingglass/apiimpl/APIWrapper.java | 29 +- .../lookingglass/apiimpl/InternalAPI.java | 49 +- .../apiimpl/LookingGlassAPI2Wrapper.java | 31 +- .../apiimpl/LookingGlassAPIWrapper.java | 58 +- .../lookingglass/apiimpl/WrapperBuilder.java | 66 +- .../lookingglass/client/ClientProxy.java | 62 +- .../client/proxyworld/ProxyWorld.java | 48 +- .../client/proxyworld/ProxyWorldManager.java | 305 ++++---- .../client/proxyworld/ViewCameraImpl.java | 137 ++-- .../client/proxyworld/WorldView.java | 310 ++++---- .../client/render/FrameBufferContainer.java | 235 +++--- .../client/render/RenderPortal.java | 138 ++-- .../client/render/RenderUtils.java | 174 ++--- .../lookingglass/command/CommandBaseAdv.java | 234 +++--- .../command/CommandCreateView.java | 128 ++-- .../lookingglass/core/CommonProxy.java | 11 +- .../core/LookingGlassForgeEventHandler.java | 50 +- .../lookingglass/entity/EntityCamera.java | 677 +++++++++--------- .../lookingglass/entity/EntityPortal.java | 216 +++--- .../lookingglass/imc/IMCAPIRegister.java | 111 +-- .../xcompwiz/lookingglass/imc/IMCHandler.java | 84 +-- .../lookingglass/log/LoggerUtils.java | 98 +-- .../network/LookingGlassPacketManager.java | 182 ++--- .../lookingglass/network/PacketHolder.java | 35 +- .../network/ServerPacketDispatcher.java | 136 ++-- .../network/packet/PacketChunkInfo.java | 479 +++++++------ .../network/packet/PacketCloseView.java | 28 +- .../network/packet/PacketCreateView.java | 111 +-- .../network/packet/PacketHandlerBase.java | 77 +- .../network/packet/PacketRequestChunk.java | 63 +- .../network/packet/PacketRequestTE.java | 79 +- .../packet/PacketRequestWorldInfo.java | 36 +- .../network/packet/PacketTileEntityNBT.java | 87 +-- .../network/packet/PacketWorldInfo.java | 109 +-- .../lookingglass/proxyworld/ChunkFinder.java | 567 ++++++++------- .../proxyworld/ChunkFinderManager.java | 34 +- .../proxyworld/LookingGlassEventHandler.java | 241 ++++--- .../lookingglass/proxyworld/ModConfigs.java | 60 +- .../proxyworld/SubChunkUtils.java | 71 +- .../render/PerspectiveRenderManager.java | 8 +- .../render/WorldViewRenderManager.java | 120 ++-- .../lookingglass/utils/MathUtils.java | 27 +- src/main/resources/mcmod.info | 33 +- 82 files changed, 4696 insertions(+), 4002 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/workflows/build-and-test.yml create mode 100644 .github/workflows/release-tags.yml create mode 100644 CODEOWNERS create mode 100644 dependencies.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 jitpack.yml create mode 100644 repositories.gradle create mode 100644 settings.gradle delete mode 100644 src/api/java/com/xcompwiz/lookingglass/api/APIVersionRemoved.java delete mode 100644 src/api/java/com/xcompwiz/lookingglass/api/IWorldViewAPI.java delete mode 100644 src/api/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPivot.java delete mode 100644 src/api/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPlayer.java delete mode 100644 src/api/java/com/xcompwiz/lookingglass/api/animator/ICameraAnimator.java delete mode 100644 src/api/java/com/xcompwiz/lookingglass/api/hook/WorldViewAPI2.java delete mode 100644 src/api/java/com/xcompwiz/lookingglass/api/view/IViewCamera.java delete mode 100644 src/api/java/com/xcompwiz/lookingglass/api/view/IWorldView.java rename src/{api => main}/java/com/xcompwiz/lookingglass/api/APIInstanceProvider.java (51%) rename src/{api => main}/java/com/xcompwiz/lookingglass/api/APIUndefined.java (51%) create mode 100644 src/main/java/com/xcompwiz/lookingglass/api/APIVersionRemoved.java rename src/{api => main}/java/com/xcompwiz/lookingglass/api/APIVersionUndefined.java (52%) create mode 100644 src/main/java/com/xcompwiz/lookingglass/api/IWorldViewAPI.java create mode 100644 src/main/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPivot.java create mode 100644 src/main/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPlayer.java create mode 100644 src/main/java/com/xcompwiz/lookingglass/api/animator/ICameraAnimator.java rename src/{api => main}/java/com/xcompwiz/lookingglass/api/event/ClientWorldInfoEvent.java (61%) create mode 100644 src/main/java/com/xcompwiz/lookingglass/api/hook/WorldViewAPI2.java rename src/{api => main}/java/com/xcompwiz/lookingglass/api/package-info.java (70%) create mode 100644 src/main/java/com/xcompwiz/lookingglass/api/view/IViewCamera.java create mode 100644 src/main/java/com/xcompwiz/lookingglass/api/view/IWorldView.java diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4ffbd90 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# This is the universal Text Editor Configuration +# for all GTNewHorizons projects +# See: https://editorconfig.org/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{bat,ini}] +end_of_line = crlf + +[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}] +indent_size = 2 + +[*.lang] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fd2792b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,44 @@ +* text eol=lf + +*.[jJ][aA][rR] binary + +*.[pP][nN][gG] binary +*.[jJ][pP][gG] binary +*.[jJ][pP][eE][gG] binary +*.[gG][iI][fF] binary +*.[tT][iI][fF] binary +*.[tT][iI][fF][fF] binary +*.[iI][cC][oO] binary +*.[sS][vV][gG] text +*.[eE][pP][sS] binary +*.[xX][cC][fF] binary + +*.[kK][aA][rR] binary +*.[mM]4[aA] binary +*.[mM][iI][dD] binary +*.[mM][iI][dD][iI] binary +*.[mM][pP]3 binary +*.[oO][gG][gG] binary +*.[rR][aA] binary + +*.7[zZ] binary +*.[gG][zZ] binary +*.[tT][aA][rR] binary +*.[tT][gG][zZ] binary +*.[zZ][iI][pP] binary + +*.[tT][cC][nN] binary +*.[sS][oO] binary +*.[dD][lL][lL] binary +*.[dD][yY][lL][iI][bB] binary +*.[pP][sS][dD] binary +*.[tT][tT][fF] binary +*.[oO][tT][fF] binary + +*.[pP][aA][tT][cC][hH] -text + +*.[bB][aA][tT] text eol=crlf +*.[cC][mM][dD] text eol=crlf +*.[pP][sS]1 text eol=crlf + +*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..3ee2f68 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,13 @@ + +name: Build and test + +on: + pull_request: + branches: [ master, main ] + push: + branches: [ master, main ] + +jobs: + build-and-test: + uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master + secrets: inherit diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml new file mode 100644 index 0000000..e4c0be6 --- /dev/null +++ b/.github/workflows/release-tags.yml @@ -0,0 +1,14 @@ + +name: Release tagged build + +on: + push: + tags: [ '*' ] + +permissions: + contents: write + +jobs: + release-tags: + uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master + secrets: inherit diff --git a/.gitignore b/.gitignore index ba9af14..5e80e0a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,38 @@ -__* -*.bak -*.xlsx - -/releases -/test - -/.gradle -/.settings -/bin -/build -/gradle -/run - -/.classpath -/.project -/gradlew -/gradlew.bat -/forge*.zip - -/build.properties -/locations.gradle - -/todo.txt -/changes.txt -/changelog.txt +.gradle +.settings +/.idea/ +/.vscode/ +/run/ +/build/ +/eclipse/ +.classpath +.project +/bin/ +/config/ +/crash-reports/ +/logs/ +options.txt +/saves/ +usernamecache.json +banned-ips.json +banned-players.json +eula.txt +ops.json +server.properties +servers.dat +usercache.json +whitelist.json +/out/ +*.iml +*.ipr +*.iws +src/main/resources/mixins.*([!.]).json +*.bat +*.DS_Store +!gradlew.bat +.factorypath +addon.local.gradle +addon.local.gradle.kts +addon.late.local.gradle +addon.late.local.gradle.kts +layout.json diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..a6b5f68 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,3 @@ +# Any Github changes require admin approval +/.github/** @GTNewHorizons/admin + diff --git a/build.gradle b/build.gradle index 34f9f85..e57a16f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,367 +1,5 @@ -ext.forgeversion = "1.7.10-10.13.3.1428-1.7.10" -group = "com.xcompwiz.lookingglass" // http://maven.apache.org/guides/mini/guide-naming-conventions.html -ext.archivesBaseName = "lookingglass" -ext.nameCased = "LookingGlass" -ext.curseId = "230541" // project url is http://minecraft.curseforge.com/mc-mods/230541-lookingglass/ -ext.curseReleaseType = "release" //The release type must be either 'alpha', 'beta', or 'release' -ext.curseIncludeAPI = true -ext.curseIncludeDev = true +//version: 1707058017 -// define some stuff. hereafter referenced as project.varName -ext.configFile = file "build.properties" -ext.smallChangelog = file("changes.txt") -ext.releaseChangelog = file("changelog.txt") -ext.publishChangelog = file("changes.txt") -ext.userHome = System.properties["user.home"] - -// -------------------------- -// End local config -// -------------------------- - -//Configure these through locations.gradle -ext.jarDeploys = [] -ext.devDeploys = [] -ext.APIDeploys = [] -ext.changelogDeploys = [] - -buildscript { - repositories { - mavenCentral() - maven { - name = "forge" - url = "http://files.minecraftforge.net/maven" - } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" - } - } - dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' - } -} - -repositories { - mavenLocal() - mavenCentral() - ivy { - name 'Forge FS legacy' - artifactPattern "http://files.minecraftforge.net/[module]/[module]-dev-[revision].[ext]" - } - maven { - name 'ForgeFS' - url 'http://files.minecraftforge.net/maven' - } - maven { - name 'MinecraftS3' - url 'http://s3.amazonaws.com/Minecraft.Download/libraries' - } -} - -apply plugin: 'curseforge' -apply plugin: 'forge' - -if (file('locations.gradle').exists()) { - apply from: 'locations.gradle' -} - -if (file('dependencies.gradle').exists()) { - apply from: 'dependencies.gradle' -} - -configFile.withReader { - // read config. it shall from now on be referenced as simply config or as project.config - def prop = new Properties() - prop.load(it) - ext.config = new ConfigSlurper().parse prop -} - -version = "${config.version.super}.${config.version.major}.${config.version.minor}.${config.version.build}" - -// Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here -minecraft { - version = project.forgeversion - runDir = "../run/client" - - replace "@VERSION@", project.version -} - -processResources -{ - // this will ensure that this task is redone when the versions change. - inputs.property "version", {"${project.version}"} - inputs.property "mcversion", {project.minecraft.version} - - // replace stuff in mcmod.info, nothing else - from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' - - // replace version and mcversion - expand 'version':"${-> project.version}", 'mcversion':project.minecraft.version - } - - // copy everything else, thats not the mcmod.info - from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' - } -} - -// this sets our output jar to have a 'tag' of 'universal' on it -// It also adds the minecraft version in a custom version name -// The result is files named --.jar -jar { - classifier = project.version - version = project.minecraft.version - includeEmptyDirs = false - from sourceSets.api.output -} - -// ------------- -// extra jars -// ------------- - -// because the normal output has been made to be obfuscated -task devJar(type: Jar) { - from sourceSets.main.output - from sourceSets.api.output - from sourceSets.api.allSource - classifier = 'dev' - version = "${project.minecraft.version}-${project.version}" -} - -task apiJar(type: Jar) { - from sourceSets.api.output - from sourceSets.api.allSource - classifier = 'api' - version = "${project.minecraft.version}-${project.version}" -} - -task srcJar(type: Jar) { - from sourceSets.main.java - from sourceSets.api.java - classifier = 'src' - version = "${project.minecraft.version}-${project.version}" -} - -build.dependsOn apiJar, devJar - -// specify artifacts to be uploaded -artifacts { - // the default jar is already here by default - archives devJar - archives apiJar -} - -// --------------------------- -// Changelog and Deployments -// --------------------------- - -task("updateChangelog") { - inputs.file project.smallChangelog - inputs.file project.releaseChangelog - outputs.file project.smallChangelog - outputs.file project.releaseChangelog - - doLast { - def small = project.smallChangelog - def release = project.releaseChangelog - - release.text = "[${project.version}]\n${small.text}\n${release.text}" - small.text = "" - } +plugins { + id 'com.gtnewhorizons.gtnhconvention' } - -task("markChangelog") { - inputs.file project.releaseChangelog - outputs.file project.releaseChangelog - - doLast { - def release = project.releaseChangelog - release.text = "[RELEASE]\n${release.text}" - } - mustRunAfter updateChangelog -} - -project.tasks.curse.dependsOn "markChangelog" - -task "deploy" // creates it for later -task "deployjar" // creates it for later - -project.tasks.deploy.dependsOn project.tasks.deployjar - -project.tasks.deployjar.dependsOn project.tasks.reobf -project.tasks.deployjar.dependsOn project.tasks.devJar -project.tasks.deployjar.dependsOn project.tasks.apiJar - -jarDeploys.each { name, dir -> - def deployer = task("deploy-${name}", type: Copy) { - //from project.configurations.archives // jars, API jars, whatever - - from {project.tasks.jar.getArchivePath()} // just release jar - into dir - dependsOn "reobf" - } - project.tasks.deployjar.dependsOn deployer - - def deleter = task("clean-${name}") << { - fileTree(dir()).each { file -> - if (!file.isDirectory() && file.name.startsWith(project.archivesBaseName)) - file.delete() - } - } - deployer.dependsOn deleter -} - -devDeploys.each { name, dir -> - def deployer = task("deploy-devjar-${name}", type: Copy) { - from {project.tasks.devJar.getArchivePath()} // the dev jar - into dir - dependsOn "devJar" - mustRunAfter "deployjar" - } - project.tasks.deploy.dependsOn deployer - - def deleter = task("clean-devjar-${name}") << { - fileTree(dir()).each { file -> - if (!file.isDirectory() && file.name.startsWith(project.archivesBaseName) && file.name.endsWith("${project.devJar.classifier}.jar")) - file.delete() - } - } - deleter.mustRunAfter "devJar" - deployer.dependsOn deleter -} - -APIDeploys.each { name, dir -> - def deployer = task("deploy-apijar-${name}", type: Copy) { - from {project.tasks.apiJar.getArchivePath()} // the API - into dir - dependsOn "apiJar" - mustRunAfter "deployjar" - } - project.tasks.deploy.dependsOn deployer - - def deleter = task("clean-apijar-${name}") << { - fileTree(dir()).each { file -> - if (!file.isDirectory() && file.name.startsWith(project.archivesBaseName) && file.name.endsWith("${project.apiJar.classifier}.jar")) - file.delete() - } - } - deleter.mustRunAfter "apiJar" - deployer.dependsOn deleter -} - -changelogDeploys.each { name, dir -> - def deployer = task("deploy-changelog-${name}", type: Copy) { - from project.releaseChangelog - into dir - mustRunAfter "updateChangelog" - } - project.tasks.deploy.dependsOn deployer -} - -// ---------------------- -// Incrementer handling -// ---------------------- - -import java.text.DecimalFormat -def formatter = new DecimalFormat('00') -def formatters = [new DecimalFormat('0'), new DecimalFormat('0'), new DecimalFormat('0'), new DecimalFormat('00')] - -// increment tasks -def types = ["super", "major", "minor", "build"] -types.eachWithIndex { type, index -> - def incrementer = task("increment-${type}").doLast { - // increment - int newNum = (config.version[type.toLowerCase()].toString().toInteger()) + 1 - config.version[type.toLowerCase()] = formatters[index].format(newNum) - // set lower #'s to 0 - types.eachWithIndex { type2, index2 -> - if (index2 > index) { - config.version[type2.toLowerCase()] = formatters[index2].format(0) - } - } - - // write back to the file - configFile.withWriter { - config.toProperties().store(it, "") - } - project.version = "${config.version.super}.${config.version.major}.${config.version.minor}.${config.version.build}" - jar.classifier = "${project.version}" - devJar.version = "${project.minecraft.version}-${project.version}" - apiJar.version = "${project.minecraft.version}-${project.version}" - srcJar.version = "${project.minecraft.version}-${project.version}" - project.tasks.sourceMainJava.replace "@VERSION@", project.version - } - - task("deploy-$type") { - dependsOn incrementer, project.tasks.updateChangelog, project.tasks.deploy - group = "Mystcraft" - description = "Increments ${type.toLowerCase()} by 1 and the deploys the artifacts" - } - - project.tasks.sourceMainJava.mustRunAfter incrementer - project.tasks.updateChangelog.mustRunAfter incrementer - project.tasks.deploy.mustRunAfter incrementer - project.tasks.uploadArchives.mustRunAfter incrementer - project.tasks.processResources.mustRunAfter incrementer - project.tasks.compileApiJava.mustRunAfter incrementer -} - -curse { - apiKey = config.curseforge_key // saved in my properties file. http://minecraft.curseforge.com/my-api-tokens - projectId = project.curseId - releaseType = project.curseReleaseType //The release type must be either 'alpha', 'beta', or 'release' - - changelog = project.publishChangelog.text - - // the default obfuscated jar is uploaded by default - // artifact = project.file("some/jar/to/upload.jar") - if (project.curseIncludeAPI) { - additionalArtifact {project.tasks.apiJar.getArchivePath()} - } - if (project.curseIncludeDev) { - additionalArtifact {project.tasks.devJar.getArchivePath()} - } - - // allows you to add extra compatible MC versions. The one specified in the minecraft{} block is used by default. - // addGameVersion "1.7.1" - // addGameversion "1.7.0", "1.7.4" -} - -// deployment stuff - -configurations { deployerJars } - -dependencies { deployerJars "org.apache.maven.wagon:wagon-ssh:2.2" } - -uploadArchives { - repositories { - mavenDeployer { - configuration = configurations.deployerJars - - repository(url: config.mavenurl) { - authentication(userName: config.mavenuser, password: config.mavenpass) - } - - pom { - groupId = project.group - version = "${-> project.version}" - artifactId = project.archivesBaseName - project { - name project.archivesBaseName - packaging 'jar' - description project.nameCased - //url project.url //'https://github.com/XCompWiz/...' - - developers { - developer { - id 'XCompWiz' - name 'XCompWiz' - roles { role 'developer' } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/dependencies.gradle b/dependencies.gradle new file mode 100644 index 0000000..b470f13 --- /dev/null +++ b/dependencies.gradle @@ -0,0 +1,38 @@ +/* + * Add your dependencies here. Supported configurations: + * - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod + * Available at runtime and compiletime for mods depending on this mod + * - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API + * Available at runtime but not compiletime for mods depending on this mod + * - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods + * Not available at all for mods depending on this mod, only visible at compiletime for this mod + * - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod + * Available at compiletime but not runtime for mods depending on this mod + * - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency + * Not available at all for mods depending on this mod, only visible at runtime for this mod + * - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime, + * but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing + * - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime + * Available at runtime for mods depending on this mod + * - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry + * - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main + * + * - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name + * Requires you to enable usesShadowedDependencies in gradle.properties + * + * - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient) + * + * You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed, + * but use this sparingly as it can break using your mod as another mod's dependency if you're not careful. + * + * To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven, + * or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file. + * + * Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not. + * The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published. + * + * For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph + */ +dependencies { + runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev") +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..b3901bd --- /dev/null +++ b/gradle.properties @@ -0,0 +1,183 @@ +# 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.2 + +# Human-readable mod name, available for mcmod.info population. +modName = Looking Glass + +# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation. +# Conventionally lowercase. +modId = LookingGlass + +# Root package of the mod, used to find various classes in other properties, +# mcmod.info substitution, enabling assertions in run tasks, etc. +modGroup = com.xcompwiz.lookingglass + +# Whether to use modGroup as the maven publishing group. +# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods. +useModGroupForPublishing = false + +# Updates your build.gradle and settings.gradle automatically whenever an update is available. +autoUpdateBuildScript = false + +# Version of Minecraft to target +minecraftVersion = 1.7.10 + +# Version of Minecraft Forge to target +forgeVersion = 10.13.4.1614 + +# Specify an MCP channel for dependency deobfuscation and the deobfParams task. +channel = stable + +# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task. +mappingsVersion = 12 + +# Defines other MCP mappings for dependency deobfuscation. +remoteMappings = https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/ + +# Select a default username for testing your mod. You can always override this per-run by running +# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE. +developmentEnvironmentUserName = Developer + +# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8. +# See https://github.com/bsideup/jabel for details on how this works. +enableModernJavaSyntax = true + +# Enables injecting missing generics into the decompiled source code for a better coding experience. +# Turns most publicly visible List, Map, etc. into proper List, Map types. +enableGenericInjection = true + +# 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.xcompwiz.lookingglass.Tags + +# Name of the token containing the project's current version to generate/replace. +gradleTokenVersion = VERSION + +# [DEPRECATED] +# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java +# public static final String VERSION = "GRADLETOKEN_VERSION"; +# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's +# version in @Mod([...], version = VERSION, [...]). +# Leave these properties empty to skip individual token replacements. +replaceGradleTokenInFile = + +# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can +# leave this property empty. +# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api +apiPackage = api + +# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/ +# There can be multiple files in a space-separated list. +# Example value: mymodid_at.cfg nei_at.cfg +accessTransformersFile = + +# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled! +usesMixins = false + +# Adds some debug arguments like verbose output and class export. +usesMixinDebug = false + +# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise. +mixinPlugin = + +# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail! +mixinsPackage = + +# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin! +# This parameter is for legacy compatibility only +# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin +coreModClass = + +# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class +# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false! +containsMixinsAndOrCoreModOnly = false + +# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins. +forceEnableMixins = false + +# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your +# responsibility to check the license and request permission for distribution if required. +usesShadowedDependencies = false + +# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access +# their own classes, making the minimization unreliable. +minimizeShadowedDependencies = true + +# If disabled, won't rename the shadowed classes. +relocateShadowedDependencies = true + +# Adds the GTNH maven, CurseMaven, IC2/Player maven, and some more well-known 1.7.10 repositories. +includeWellKnownRepositories = true + +# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven. +# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables. +# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle. +usesMavenPublishing = true + +# Maven repository to publish the mod to. +# mavenPublishUrl = https://nexus.gtnewhorizons.com/repository/releases/ + +# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token. +# +# The project's ID on Modrinth. Can be either the slug or the ID. +# Leave this empty if you don't want to publish to Modrinth. +modrinthProjectId = + +# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth. +# Syntax: scope1-type1:name1;scope2-type2:name2;... +# Where scope can be one of [required, optional, incompatible, embedded], +# type can be one of [project, version], +# and the name is the Modrinth project or version slug/id of the other mod. +# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech +# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true +modrinthRelations = + +# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens. +# +# The project's numeric ID on CurseForge. You can find this in the About Project box. +# Leave this empty if you don't want to publish on CurseForge. +curseForgeProjectId = + +# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge. +# Syntax: type1:name1;type2:name2;... +# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible], +# and the name is the CurseForge project slug of the other mod. +# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft +# Note: UniMixins is automatically set as a required dependency if usesMixins = true. +curseForgeRelations = + +# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older +# projects. New projects should not use this parameter. +# customArchiveBaseName = + +# Optional parameter to have the build automatically fail if an illegal version is used. +# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'. +# The check is ONLY performed if the version is a git tag. +# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+ +# versionPattern = + +# Uncomment to prevent the source code from being published. +# noPublishedSources = true + +# Uncomment this to disable Spotless checks. +# This should only be uncommented to keep it easier to sync with upstream/other forks. +# That is, if there is no other active fork/upstream, NEVER change this. +# disableSpotless = true + +# Uncomment this to disable Checkstyle checks (currently wildcard import check). +# disableCheckstyle = true + +# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle" +# (force use delegated build). +# This is meant to be set in $HOME/.gradle/gradle.properties. +# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build. +# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want! +# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you. +# ideaOverrideBuildType = idea + +# Whether IDEA should run spotless checks when pressing the Build button. +# This is meant to be set in $HOME/.gradle/gradle.properties. +# ideaCheckSpotlessOnBuild = true + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..d64cd4917707c1f8861d8cb53dd15194d4248596 GIT binary patch literal 43462 zcma&NWl&^owk(X(xVyW%ySuwf;qI=D6|RlDJ2cR^yEKh!@I- zp9QeisK*rlxC>+~7Dk4IxIRsKBHqdR9b3+fyL=ynHmIDe&|>O*VlvO+%z5;9Z$|DJ zb4dO}-R=MKr^6EKJiOrJdLnCJn>np?~vU-1sSFgPu;pthGwf}bG z(1db%xwr#x)r+`4AGu$j7~u2MpVs3VpLp|mx&;>`0p0vH6kF+D2CY0fVdQOZ@h;A` z{infNyvmFUiu*XG}RNMNwXrbec_*a3N=2zJ|Wh5z* z5rAX$JJR{#zP>KY**>xHTuw?|-Rg|o24V)74HcfVT;WtQHXlE+_4iPE8QE#DUm%x0 zEKr75ur~W%w#-My3Tj`hH6EuEW+8K-^5P62$7Sc5OK+22qj&Pd1;)1#4tKihi=~8C zHiQSst0cpri6%OeaR`PY>HH_;CPaRNty%WTm4{wDK8V6gCZlG@U3$~JQZ;HPvDJcT1V{ z?>H@13MJcCNe#5z+MecYNi@VT5|&UiN1D4ATT+%M+h4c$t;C#UAs3O_q=GxK0}8%8 z8J(_M9bayxN}69ex4dzM_P3oh@ZGREjVvn%%r7=xjkqxJP4kj}5tlf;QosR=%4L5y zWhgejO=vao5oX%mOHbhJ8V+SG&K5dABn6!WiKl{|oPkq(9z8l&Mm%(=qGcFzI=eLu zWc_oCLyf;hVlB@dnwY98?75B20=n$>u3b|NB28H0u-6Rpl((%KWEBOfElVWJx+5yg z#SGqwza7f}$z;n~g%4HDU{;V{gXIhft*q2=4zSezGK~nBgu9-Q*rZ#2f=Q}i2|qOp z!!y4p)4o=LVUNhlkp#JL{tfkhXNbB=Ox>M=n6soptJw-IDI|_$is2w}(XY>a=H52d z3zE$tjPUhWWS+5h=KVH&uqQS=$v3nRs&p$%11b%5qtF}S2#Pc`IiyBIF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i8i|jp(@OnRrY5B8t|LFXFQVQ895n*P16cEKTrT*~yLH6Z4e*bZ5otpRDri&+A zfNbK1D5@O=sm`fN=WzWyse!za5n%^+6dHPGX#8DyIK>?9qyX}2XvBWVqbP%%D)7$= z=#$WulZlZR<{m#gU7lwqK4WS1Ne$#_P{b17qe$~UOXCl>5b|6WVh;5vVnR<%d+Lnp z$uEmML38}U4vaW8>shm6CzB(Wei3s#NAWE3)a2)z@i{4jTn;;aQS)O@l{rUM`J@K& l00vQ5JBs~;vo!vr%%-k{2_Fq1Mn4QF81S)AQ99zk{{c4yR+0b! literal 0 HcmV?d00001 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..a80b22c --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..1aa94a4 --- /dev/null +++ b/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..25da30d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +: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 %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..09bbb51 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +before_install: + - ./gradlew setupCIWorkspace \ No newline at end of file diff --git a/repositories.gradle b/repositories.gradle new file mode 100644 index 0000000..7e002f2 --- /dev/null +++ b/repositories.gradle @@ -0,0 +1,5 @@ +// Add any additional repositories for your dependencies here. + +repositories { + +} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..ac267e2 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,21 @@ + +pluginManagement { + repositories { + maven { + // RetroFuturaGradle + name "GTNH Maven" + url "https://nexus.gtnewhorizons.com/repository/public/" + mavenContent { + includeGroup("com.gtnewhorizons") + includeGroupByRegex("com\\.gtnewhorizons\\..+") + } + } + gradlePluginPortal() + mavenCentral() + mavenLocal() + } +} + +plugins { + id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.8' +} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/APIVersionRemoved.java b/src/api/java/com/xcompwiz/lookingglass/api/APIVersionRemoved.java deleted file mode 100644 index cc45033..0000000 --- a/src/api/java/com/xcompwiz/lookingglass/api/APIVersionRemoved.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.xcompwiz.lookingglass.api; - -/** - * Thrown in the case of an API version having been removed entirely and no longer supported. This can be interpreted as the request being for below the minimum - * supported version for the API. - * @author xcompwiz - */ -public class APIVersionRemoved extends Exception { - - /** - * Generated Serial UID - */ - private static final long serialVersionUID = -7702376017254522430L; - - public APIVersionRemoved(String string) { - super(string); - } -} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/IWorldViewAPI.java b/src/api/java/com/xcompwiz/lookingglass/api/IWorldViewAPI.java deleted file mode 100644 index 557e28b..0000000 --- a/src/api/java/com/xcompwiz/lookingglass/api/IWorldViewAPI.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.xcompwiz.lookingglass.api; - -import net.minecraft.util.ChunkCoordinates; - -import com.xcompwiz.lookingglass.api.view.IWorldView; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * @deprecated This interface will be removed in a future version. You should switch to the IWorldViewAPI2. - * @author xcompwiz - */ -@Deprecated -public interface IWorldViewAPI { - - /** - * Creates a world viewer object which will handle the rendering and retrieval of the remote location. Can return null. - * @param dimid The target dimension - * @param coords The coordinates of the target location. If null, world spawn is used. - * @param width Texture resolution width - * @param height Texture resolution height - * @return A IWorldView object for your use or null if something goes wrong. - */ - @SideOnly(Side.CLIENT) - IWorldView createWorldView(Integer dimid, ChunkCoordinates coords, int width, int height); -} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPivot.java b/src/api/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPivot.java deleted file mode 100644 index 21d7f5b..0000000 --- a/src/api/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPivot.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.xcompwiz.lookingglass.api.animator; - -import net.minecraft.block.Block; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.IBlockAccess; - -import com.xcompwiz.lookingglass.api.view.IViewCamera; - -/** - * This is a standard sample implementation of a camera animator. It simply uses the target location as a LookAt target and does a fly pivot around it. It can - * be extended for more control, if desired. - * @author xcompwiz - */ -public class CameraAnimatorPivot implements ICameraAnimator { - /** This is a list of recommended, preset offsets that the animator will choose from. It's use can be overridden via function. */ - private static final int[][] presets = { { 2, 5 }, { 5, 9 }, { 9, 15 }, { 1, 3 }, { 2, 1 }, { 0, 2 } }; - /** This is a pair used when the animator cannot find a good path from the presets. It's use can be overridden via function. */ - private static final int[] defaults = { 1, 3 }; - - private final IViewCamera camera; - private ChunkCoordinates target; - - private boolean positionSet = false; - - private int xCenter; - private int yCenter; - private int zCenter; - - private int yUp = 0; - private int radius = 0; - private float pitch = 0; - - public CameraAnimatorPivot(IViewCamera camera) { - this.camera = camera; - } - - @Override - public void setTarget(ChunkCoordinates target) { - this.target = target; - positionSet = false; - } - - @Override - public void update(long dt) { - if (camera == null) return; - camera.addRotations(dt*0.1F, 0); - camera.setPitch(-pitch); - - double x = Math.cos(Math.toRadians(camera.getYaw() + 90)) * radius; - double z = Math.sin(Math.toRadians(camera.getYaw() + 90)) * radius; - camera.setLocation(xCenter + 0.5 - x, yCenter - 0.5 + yUp, zCenter + 0.5 - z); - } - - @Override - public void refresh() { - if (camera == null) return; - if (target == null) return; - if (!positionSet) this.checkCameraY(); - - int chunkX = xCenter >> 4; - int chunkY = yCenter >> 4; - int chunkZ = zCenter >> 4; - - int[][] presets = this.getPresets(); - - for (int i = 0; i < presets.length; ++i) { - if (checkPath(presets[i][0], presets[i][1], chunkX, chunkY, chunkZ)) { - yUp = presets[i][0]; - radius = presets[i][1]; - pitch = (float) Math.toDegrees(Math.atan(((double) -yUp) / radius)); - return; - } - } - int[] defaults = this.getDefaults(); - yUp = defaults[0]; - radius = defaults[1]; - pitch = (float) Math.toDegrees(Math.atan(((double) -yUp) / radius)); - } - - /** - * Should the selection from the offsets fail, the pair of values in this array will be used instead. - * @return A pair of numbers up and distance in an array of length 2 - */ - public int[] getDefaults() { - return defaults; - } - - /** - * Overriding his function allows you specify your own offset presets. - * @return An array of integer pairs up and distance from which to select the first functional pair - */ - public int[][] getPresets() { - return presets; - } - - /** - * @author Ken Butler/shadowking97 - */ - private boolean checkPath(int up, int distance, int chunkX, int chunkY, int chunkZ) { - if ((yCenter & 15) > 15 - up) { - if (isAboveNullLayer(chunkX, chunkY, chunkZ)) return false; - if ((xCenter & 15) < distance) { - if (isAboveNullLayer(chunkX - 1, chunkY, chunkZ)) return false; - if ((zCenter & 15) < distance) { - if (isAboveNullLayer(chunkX - 1, chunkY, chunkZ - 1)) return false; - if (isAboveNullLayer(chunkX, chunkY, chunkZ - 1)) return false; - } else if ((zCenter & 15) > 15 - distance) { - if (isAboveNullLayer(chunkX - 1, chunkY, chunkZ + 1)) return false; - if (isAboveNullLayer(chunkX, chunkY, chunkZ + 1)) return false; - } - } else if ((xCenter & 15) > 15 - distance) { - if (isAboveNullLayer(chunkX + 1, chunkY, chunkZ)) return false; - if ((zCenter & 15) < distance) { - if (isAboveNullLayer(chunkX + 1, chunkY, chunkZ - 1)) return false; - if (isAboveNullLayer(chunkX, chunkY, chunkZ - 1)) return false; - } else if ((zCenter & 15) > 15 - distance) { - if (isAboveNullLayer(chunkX + 1, chunkY, chunkZ + 1)) return false; - if (isAboveNullLayer(chunkX, chunkY, chunkZ + 1)) return false; - } - } else { - if ((zCenter & 15) < distance) { - if (isAboveNullLayer(chunkX, chunkY, chunkZ - 1)) return false; - } else if ((zCenter & 15) > 15 - distance) { - if (isAboveNullLayer(chunkX, chunkY, chunkZ + 1)) return false; - } - } - } - for (int j = -distance; j <= distance; ++j) { - for (int k = -distance; k <= distance; ++k) { - if (!camera.getBlockData().isAirBlock(xCenter + j, yCenter + up, zCenter + k)) return false; - } - } - return true; - } - - /** - * @author Ken Butler/shadowking97 - */ - private boolean isAboveNullLayer(int x, int y, int z) { - if (y + 1 > 15) return true; - int x2 = x << 4; - int z2 = z << 4; - int y2 = (y << 4) + 15; - int yl = (y + 1) << 4; - for (int i = 0; i < 15; i++) - for (int j = 0; j < 15; j++) - if (!isBlockNormalCube(camera.getBlockData(), x2 + i, y2, z2 + i)) return false; - if (camera.chunkLevelsExist(x, z, yl, yl + 15)) return true; - return false; - } - - private boolean isBlockNormalCube(IBlockAccess blockData, int x, int y, int z) { - Block block = blockData.getBlock(x, y, z); - return block.isNormalCube(blockData, x, y, z); - } - - private void checkCameraY() { - int x = target.posX; - int y = target.posY; - int z = target.posZ; - int yBackup = y; - if (camera.chunkExists(x, z)) { - if (camera.getBlockData().getBlock(x, y, z).getBlocksMovement(camera.getBlockData(), x, y, z)) { - while (y > 0 && camera.getBlockData().getBlock(x, --y, z).getBlocksMovement(camera.getBlockData(), x, y, z)) - ; - if (y == 0) y = yBackup; - else y += 2; - } else { - while (y < 256 && !camera.getBlockData().getBlock(x, ++y, z).getBlocksMovement(camera.getBlockData(), x, y, z)) - ; - if (y == 256) y = yBackup; - else ++y; - } - this.setCenterPoint(x, y, z); - } - } - - private void setCenterPoint(int x, int y, int z) { - xCenter = x; - yCenter = y - 1; - zCenter = z; - positionSet = true; - } -} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPlayer.java b/src/api/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPlayer.java deleted file mode 100644 index 29506ff..0000000 --- a/src/api/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPlayer.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.xcompwiz.lookingglass.api.animator; - -import net.minecraft.entity.Entity; -import net.minecraft.util.ChunkCoordinates; - -import com.xcompwiz.lookingglass.api.view.IViewCamera; - -/** - * This is a badly approximated "portal render" animator, which makes the camera move based on what direction the player is from some defined point. It doesn't - * do quite what it was meant to, but it's neat enough looking, so I'll leave it be. It does make a view look more "alive" or 3D, so if you just want a slightly - * animated view that doesn't look like you could walk through it, then this works great. It produces an effect more akin to Harry Potter's portraits than it - * does to Portal's portals. - * @author xcompwiz - */ -public class CameraAnimatorPlayer implements ICameraAnimator { - // This is the camera object we are animating - private final IViewCamera camera; - - // The entity was are using as our reference point, such as our portrait view. - private Entity reference; - // The entity we are facing. Expected to be the client side player, but could be anything, really. - private Entity player; - // The point we are looking at in block coordinates. - private ChunkCoordinates target; - - private boolean updateY; - private float accum; - - /** - * - * @param camera - * @param reference The entity was are using as our reference point, such as our portrait view. - * @param player The entity we are facing. Expected to be the client side player, but could be anything, really. - */ - public CameraAnimatorPlayer(IViewCamera camera, Entity reference, Entity player) { - this.camera = camera; - this.reference = reference; - this.player = player; - } - - /** - * Sets the point we are looking at using block coordinates. - */ - @Override - public void setTarget(ChunkCoordinates target) { - this.target = new ChunkCoordinates(target); - } - - @Override - public void refresh() { - updateY = true; - } - - @Override - public void update(long dt) { - // This animator is incomplete and broken. It's a rough approximation I made at 4AM one night. - // However, it's also pretty cool looking, so I'm not going to bother fixing it. :P - // Note: Needs base yaw and pitch of view - if (reference.worldObj.provider.dimensionId != player.worldObj.provider.dimensionId) return; - - // A standard accumulator trick to force periodic rechecks of the y position. Probably superfluous. - // Ticks every 10 seconds - if ((accum += dt) >= 10000) { - updateY = true; - accum -= 10000; - } - if (updateY) updateTargetPosition(); - double dx = player.posX - reference.posX; - double dy = player.posY - (reference.posY + player.yOffset); - double dz = player.posZ - reference.posZ; - double length = Math.sqrt(dx * dx + dz * dz + dy * dy); //TODO: Needs Go Faster - float yaw = -(float) Math.atan2(dx, dz); - yaw *= 180 / Math.PI; - float pitch = (float) Math.asin(dy / length); - pitch *= 180 / Math.PI; - camera.setLocation(target.posX, target.posY, target.posZ); - camera.setYaw(yaw); - camera.setPitch(pitch); - } - - private void updateTargetPosition() { - updateY = false; - int x = target.posX; - int y = target.posY; - int z = target.posZ; - if (!camera.chunkExists(x, z)) { - if (camera.getBlockData().getBlock(x, y, z).getBlocksMovement(camera.getBlockData(), x, y, z)) { - while (y > 0 && camera.getBlockData().getBlock(x, --y, z).getBlocksMovement(camera.getBlockData(), x, y, z)) - ; - if (y == 0) y = target.posY; - else y += 2; - } else { - while (y < 256 && !camera.getBlockData().getBlock(x, ++y, z).getBlocksMovement(camera.getBlockData(), x, y, z)) - ; - if (y == 256) y = target.posY; - else ++y; - } - target.posY = y; - } - } - -} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/animator/ICameraAnimator.java b/src/api/java/com/xcompwiz/lookingglass/api/animator/ICameraAnimator.java deleted file mode 100644 index 7409b72..0000000 --- a/src/api/java/com/xcompwiz/lookingglass/api/animator/ICameraAnimator.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xcompwiz.lookingglass.api.animator; - -import net.minecraft.util.ChunkCoordinates; - -public interface ICameraAnimator { - - /** - * Sets the look-at target (in block coordinates) - * @param target The block target - */ - void setTarget(ChunkCoordinates target); - - /** - * Allows the animator to refresh/reboot its settings - */ - void refresh(); - - /** - * Tick! - * @param dt Delta time in milliseconds since last render tick - */ - void update(long dt); - -} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/hook/WorldViewAPI2.java b/src/api/java/com/xcompwiz/lookingglass/api/hook/WorldViewAPI2.java deleted file mode 100644 index 5731883..0000000 --- a/src/api/java/com/xcompwiz/lookingglass/api/hook/WorldViewAPI2.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.xcompwiz.lookingglass.api.hook; - -import net.minecraft.util.ChunkCoordinates; - -import com.xcompwiz.lookingglass.api.view.IWorldView; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * Available via "view-2" from the API provider - * @author xcompwiz - */ -public interface WorldViewAPI2 { - - /** - * Creates a world viewer object which will handle the rendering and retrieval of the remote location. Can return null. - * @param dimid The target dimension - * @param coords The coordinates of the target location. If null, world spawn is used. - * @param width Texture resolution width - * @param height Texture resolution height - * @return A IWorldView object for your use or null if something goes wrong. - */ - @SideOnly(Side.CLIENT) - IWorldView createWorldView(Integer dimid, ChunkCoordinates coords, int width, int height); - - /** - * This function is available should you wish to explicitly have the world view clean up its framebuffer. You should not use a view after calling this on - * the view. - * @param worldview The view to clean up (effectively "destroy") - */ - void cleanupWorldView(IWorldView worldview); -} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/view/IViewCamera.java b/src/api/java/com/xcompwiz/lookingglass/api/view/IViewCamera.java deleted file mode 100644 index b07e373..0000000 --- a/src/api/java/com/xcompwiz/lookingglass/api/view/IViewCamera.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.xcompwiz.lookingglass.api.view; - -import net.minecraft.world.IBlockAccess; - -public interface IViewCamera { - - /** - * Adds par1*0.15 to the entity's yaw, and *subtracts* par2*0.15 from the pitch. Clamps pitch from -90 to 90. Both arguments in degrees. - * @param yaw The yaw to be added - * @param pitch The pitch to be subtracted - */ - public void addRotations(float yaw, int pitch); - - /** - * Sets the yaw rotation of the camera - * @param f The camera's new yaw in degrees - */ - public void setYaw(float f); - - /** - * @return The camera's yaw in degrees - */ - public float getYaw(); - - /** - * Sets the pitch rotation of the camera - * @param f The camera's new pitch in degrees - */ - public void setPitch(float f); - - /** - * @return The camera's pitch in degrees - */ - public float getPitch(); - - /** - * Sets the position of the camera - * @param x X Coordinate (Block space) - * @param y Y Coordinate (Block space) - * @param z Z Coordinate (Block space) - */ - public void setLocation(double x, double y, double z); - - /** - * @return The camera's X coordinate (Block space) - */ - public double getX(); - - /** - * @return The camera's Y coordinate (Block space) - */ - public double getY(); - - /** - * @return The camera's Z coordinate (Block space) - */ - public double getZ(); - - /** - * This is provided to allow for checking for air blocks and similar. Technically, it is a WorldClient object, but it is provided as a IBlockAccess to - * discourage modifying the world. Modifying the world object would break things for everyone, so please don't do that. Should it become an issue, this will - * be replaced with something that isn't a WorldClient, so be wary of casting it. - * @return A read-only reference to the world which the camera inhabits - */ - public IBlockAccess getBlockData(); - - /** - * An easy check for if a chunk exists in the local data copy - * @param x The X coordinate in block space - * @param z The Z coordinate in block space - * @return True if the chunk at those coordinates is available locally - */ - public boolean chunkExists(int x, int z); - - /** - * Since LookingGlass utilizes partial chunk loading to minimize data traffic and storage, it's useful to be able to check if certain levels of a chunk are - * loaded locally. - * @param x The X coordinate in block space - * @param z The Z coordinate in block space - * @param yl1 The lower (closer to 0) y coordinate of the levels to check for in block space - * @param yl2 The larger (farther from 0) y coordinate of the levels to check for in block space - * @return True if the levels are loaded locally - */ - public boolean chunkLevelsExist(int x, int z, int yl1, int yl2); -} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/view/IWorldView.java b/src/api/java/com/xcompwiz/lookingglass/api/view/IWorldView.java deleted file mode 100644 index 09a7732..0000000 --- a/src/api/java/com/xcompwiz/lookingglass/api/view/IWorldView.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.xcompwiz.lookingglass.api.view; - -import com.xcompwiz.lookingglass.api.animator.ICameraAnimator; - -public interface IWorldView { - - /** - * @return The OpenGL texture id for rendering the view - */ - public int getTexture(); - - /** - * This needs to be called to request LookingGlass rerender the view to the texture - */ - public void markDirty(); - - /** - * This will be activated once the view has chunks and is ready to render - * @return True if the view has been rendered to the texture. - */ - public boolean isReady(); - - /** - * Sets the animator object for the camera. This will be updated before each render frame. - * @param animator - */ - public void setAnimator(ICameraAnimator animator); - - /** - * Returns the view's camera object. This allows you to create animators for it and adjust its location locally. - * @return the entity object from which rendering is handled - */ - public IViewCamera getCamera(); - - /** - * @deprecated This function no longer does anything and will be removed in an upcoming version. - */ - @Deprecated - public void grab(); - - /** - * @deprecated This function no longer does anything and will be removed in an upcoming version. - */ - @Deprecated - public boolean release(); - -} diff --git a/src/main/java/com/xcompwiz/lookingglass/LookingGlass.java b/src/main/java/com/xcompwiz/lookingglass/LookingGlass.java index 3019b25..31f4846 100644 --- a/src/main/java/com/xcompwiz/lookingglass/LookingGlass.java +++ b/src/main/java/com/xcompwiz/lookingglass/LookingGlass.java @@ -43,75 +43,93 @@ @Mod(modid = LookingGlass.MODID, name = "LookingGlass", version = LookingGlass.VERSION) public class LookingGlass { - public static final String MODID = "LookingGlass"; - public static final String VERSION = "@VERSION@"; - - @Instance(LookingGlass.MODID) - public static LookingGlass instance; - - @SidedProxy(clientSide = "com.xcompwiz.lookingglass.client.ClientProxy", serverSide = "com.xcompwiz.lookingglass.core.CommonProxy") - public static CommonProxy sidedProxy; - - @EventHandler - public void preinit(FMLPreInitializationEvent event) { - //Initialize the packet handling - LookingGlassPacketManager.registerPacketHandler(new PacketCreateView(), (byte) 10); - LookingGlassPacketManager.registerPacketHandler(new PacketCloseView(), (byte) 11); - LookingGlassPacketManager.registerPacketHandler(new PacketWorldInfo(), (byte) 100); - LookingGlassPacketManager.registerPacketHandler(new PacketChunkInfo(), (byte) 101); - LookingGlassPacketManager.registerPacketHandler(new PacketTileEntityNBT(), (byte) 102); - LookingGlassPacketManager.registerPacketHandler(new PacketRequestWorldInfo(), (byte) 200); - LookingGlassPacketManager.registerPacketHandler(new PacketRequestChunk(), (byte) 201); - LookingGlassPacketManager.registerPacketHandler(new PacketRequestTE(), (byte) 202); - - LookingGlassPacketManager.bus = NetworkRegistry.INSTANCE.newEventDrivenChannel(LookingGlassPacketManager.CHANNEL); - LookingGlassPacketManager.bus.register(new LookingGlassPacketManager()); - - // Load our basic configs - ModConfigs.loadConfigs(new Configuration(event.getSuggestedConfigurationFile())); - - // Here we use the recommended config file to establish a good place to put a log file for any proxy world error logs. Used primarily to log the full errors when ticking or rendering proxy worlds. - File configroot = event.getSuggestedConfigurationFile().getParentFile(); - // Main tick handler. Handles FML events. - FMLCommonHandler.instance().bus().register(new LookingGlassEventHandler(new File(configroot.getParentFile(), "logs/proxyworlds.log"))); - // Forge event handler - MinecraftForge.EVENT_BUS.register(new LookingGlassForgeEventHandler()); - - // Initialize the API provider system. Beware, this way be dragons. - APIProviderImpl.init(); - } - - @EventHandler - public void init(FMLInitializationEvent event) { - // Our one and only entity. - EntityRegistry.registerModEntity(com.xcompwiz.lookingglass.entity.EntityPortal.class, "lookingglass.portal", 216, this, 64, 10, false); - - sidedProxy.init(); - } - - @EventHandler - public void handleIMC(IMCEvent event) { - // Catch IMC messages and send them off to our IMC handler - ImmutableList messages = event.getMessages(); - IMCHandler.process(messages); - } - - @EventHandler - public void postinit(FMLPostInitializationEvent event) {} - - @EventHandler - public void serverStart(FMLServerStartingEvent event) { - MinecraftServer mcserver = event.getServer(); - // Register commands - ((ServerCommandManager) mcserver.getCommandManager()).registerCommand(new CommandCreateView()); - // Start up the packet dispatcher we use for throttled data to client. - ServerPacketDispatcher.getInstance().start(); //Note: This might need to be preceded by a force init of the ServerPacketDispatcher. Doesn't seem to currently have any issues, though. - } - - @EventHandler - public void serverStop(FMLServerStoppedEvent event) { - // Shutdown our throttled packet dispatcher - ServerPacketDispatcher.getInstance().halt(); - ServerPacketDispatcher.shutdown(); - } + + public static final String MODID = "LookingGlass"; + public static final String VERSION = "@VERSION@"; + + @Instance(LookingGlass.MODID) + public static LookingGlass instance; + + @SidedProxy( + clientSide = "com.xcompwiz.lookingglass.client.ClientProxy", + serverSide = "com.xcompwiz.lookingglass.core.CommonProxy") + public static CommonProxy sidedProxy; + + @EventHandler + public void preinit(FMLPreInitializationEvent event) { + // Initialize the packet handling + LookingGlassPacketManager.registerPacketHandler(new PacketCreateView(), (byte) 10); + LookingGlassPacketManager.registerPacketHandler(new PacketCloseView(), (byte) 11); + LookingGlassPacketManager.registerPacketHandler(new PacketWorldInfo(), (byte) 100); + LookingGlassPacketManager.registerPacketHandler(new PacketChunkInfo(), (byte) 101); + LookingGlassPacketManager.registerPacketHandler(new PacketTileEntityNBT(), (byte) 102); + LookingGlassPacketManager.registerPacketHandler(new PacketRequestWorldInfo(), (byte) 200); + LookingGlassPacketManager.registerPacketHandler(new PacketRequestChunk(), (byte) 201); + LookingGlassPacketManager.registerPacketHandler(new PacketRequestTE(), (byte) 202); + + LookingGlassPacketManager.bus = NetworkRegistry.INSTANCE + .newEventDrivenChannel(LookingGlassPacketManager.CHANNEL); + LookingGlassPacketManager.bus.register(new LookingGlassPacketManager()); + + // Load our basic configs + ModConfigs.loadConfigs(new Configuration(event.getSuggestedConfigurationFile())); + + // Here we use the recommended config file to establish a good place to put a log file for any proxy world error + // logs. Used primarily to log the full errors when ticking or rendering proxy worlds. + File configroot = event.getSuggestedConfigurationFile() + .getParentFile(); + // Main tick handler. Handles FML events. + FMLCommonHandler.instance() + .bus() + .register(new LookingGlassEventHandler(new File(configroot.getParentFile(), "logs/proxyworlds.log"))); + // Forge event handler + MinecraftForge.EVENT_BUS.register(new LookingGlassForgeEventHandler()); + + // Initialize the API provider system. Beware, this way be dragons. + APIProviderImpl.init(); + } + + @EventHandler + public void init(FMLInitializationEvent event) { + // Our one and only entity. + EntityRegistry.registerModEntity( + com.xcompwiz.lookingglass.entity.EntityPortal.class, + "lookingglass.portal", + 216, + this, + 64, + 10, + false); + + sidedProxy.init(); + } + + @EventHandler + public void handleIMC(IMCEvent event) { + // Catch IMC messages and send them off to our IMC handler + ImmutableList messages = event.getMessages(); + IMCHandler.process(messages); + } + + @EventHandler + public void postinit(FMLPostInitializationEvent event) {} + + @EventHandler + public void serverStart(FMLServerStartingEvent event) { + MinecraftServer mcserver = event.getServer(); + // Register commands + ((ServerCommandManager) mcserver.getCommandManager()).registerCommand(new CommandCreateView()); + // Start up the packet dispatcher we use for throttled data to client. + ServerPacketDispatcher.getInstance() + .start(); // Note: This might need to be preceded by a force init of the ServerPacketDispatcher. Doesn't + // seem to currently have any issues, though. + } + + @EventHandler + public void serverStop(FMLServerStoppedEvent event) { + // Shutdown our throttled packet dispatcher + ServerPacketDispatcher.getInstance() + .halt(); + ServerPacketDispatcher.shutdown(); + } } diff --git a/src/api/java/com/xcompwiz/lookingglass/api/APIInstanceProvider.java b/src/main/java/com/xcompwiz/lookingglass/api/APIInstanceProvider.java similarity index 51% rename from src/api/java/com/xcompwiz/lookingglass/api/APIInstanceProvider.java rename to src/main/java/com/xcompwiz/lookingglass/api/APIInstanceProvider.java index 74d1c20..1aa5c64 100644 --- a/src/api/java/com/xcompwiz/lookingglass/api/APIInstanceProvider.java +++ b/src/main/java/com/xcompwiz/lookingglass/api/APIInstanceProvider.java @@ -1,50 +1,59 @@ -package com.xcompwiz.lookingglass.api; - -import java.util.Map; -import java.util.Set; - -/** - * The purpose of this interface is simply to provide instances of the API interfaces. Request an instance via IMC (see below). This interface supports - * providing multiple versions of an API, so you can request ex. 'symbol-1' and always get the same interface, enabling the API to move forward without breaking - * compatibility. The provider instance provided to you, as well as any API interface instances created by it, will belong to the mod which requested the - * provider. - * @author xcompwiz - */ -public interface APIInstanceProvider { - - /** - * Returns a constructed version of the requested API. If the API requested doesn't exist then an exception will be thrown. Be wary when attempting to cast - * the returned instance, as, if you try using an interface not included in the class path, you may get missing definition crashes. It is wiser to, after - * verifying success, pass the object to another class dedicated to handling the casting. - * @param api The name of the API and version desired, formatted as ex. "symbol-1". - * @return The requested API instance as an Object. If you get an object, it is guaranteed to be of the requested API and version. - */ - public Object getAPIInstance(String api) throws APIUndefined, APIVersionUndefined, APIVersionRemoved; - - /** - * Returns a collection of all available APIs by name and what versions are supported in this environment. - * @return A map of API names and their available versions - */ - public Map> getAvailableAPIs(); - -//@formatter:off - /* Example Usage - In order to get an instance of this class, send an IMC message to LookingGlass with the key "API" and a string value which is a static method (with classpath) - which takes an instance of APIInstanceProvider as it's only param. - Example: FMLInterModComms.sendMessage("LookingGlass", "API", "com.xcompwiz.newmod.integration.lookingglass.register"); - - public static void register(APIInstanceProvider provider) { - try { - Object apiinst = provider.getAPIInstance("awesomeAPI-3"); - OtherClass.apiGet(apiinst); //At this point, we've got an object of the right interface. - } catch (APIUndefined e) { - // The API we requested doesn't exist. Give up with a nice log message. - } catch (APIVersionUndefined e) { - // The API we requested exists, but the version we wanted is missing in the local environment. We can try falling back to an older version. - } catch (APIVersionRemoved e) { - // The API we requested exists, but the version we wanted has been removed and is no longer supported. Better update. - } - } - */ -//formatter:on -} +package com.xcompwiz.lookingglass.api; + +import java.util.Map; +import java.util.Set; + +/** + * The purpose of this interface is simply to provide instances of the API interfaces. Request an instance via IMC (see + * below). This interface supports + * providing multiple versions of an API, so you can request ex. 'symbol-1' and always get the same interface, enabling + * the API to move forward without breaking + * compatibility. The provider instance provided to you, as well as any API interface instances created by it, will + * belong to the mod which requested the + * provider. + * + * @author xcompwiz + */ +public interface APIInstanceProvider { + + /** + * Returns a constructed version of the requested API. If the API requested doesn't exist then an exception will be + * thrown. Be wary when attempting to cast + * the returned instance, as, if you try using an interface not included in the class path, you may get missing + * definition crashes. It is wiser to, after + * verifying success, pass the object to another class dedicated to handling the casting. + * + * @param api The name of the API and version desired, formatted as ex. "symbol-1". + * @return The requested API instance as an Object. If you get an object, it is guaranteed to be of the requested + * API and version. + */ + public Object getAPIInstance(String api) throws APIUndefined, APIVersionUndefined, APIVersionRemoved; + + /** + * Returns a collection of all available APIs by name and what versions are supported in this environment. + * + * @return A map of API names and their available versions + */ + public Map> getAvailableAPIs(); + +//@formatter:off + /* Example Usage + In order to get an instance of this class, send an IMC message to LookingGlass with the key "API" and a string value which is a static method (with classpath) + which takes an instance of APIInstanceProvider as it's only param. + Example: FMLInterModComms.sendMessage("LookingGlass", "API", "com.xcompwiz.newmod.integration.lookingglass.register"); + + public static void register(APIInstanceProvider provider) { + try { + Object apiinst = provider.getAPIInstance("awesomeAPI-3"); + OtherClass.apiGet(apiinst); //At this point, we've got an object of the right interface. + } catch (APIUndefined e) { + // The API we requested doesn't exist. Give up with a nice log message. + } catch (APIVersionUndefined e) { + // The API we requested exists, but the version we wanted is missing in the local environment. We can try falling back to an older version. + } catch (APIVersionRemoved e) { + // The API we requested exists, but the version we wanted has been removed and is no longer supported. Better update. + } + } + */ +//formatter:on +} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/APIUndefined.java b/src/main/java/com/xcompwiz/lookingglass/api/APIUndefined.java similarity index 51% rename from src/api/java/com/xcompwiz/lookingglass/api/APIUndefined.java rename to src/main/java/com/xcompwiz/lookingglass/api/APIUndefined.java index 6ce8e17..b0b5979 100644 --- a/src/api/java/com/xcompwiz/lookingglass/api/APIUndefined.java +++ b/src/main/java/com/xcompwiz/lookingglass/api/APIUndefined.java @@ -1,17 +1,18 @@ -package com.xcompwiz.lookingglass.api; - -/** - * Thrown in the case of an API name being unrecognized (ex. requesting 'zymbol-1') - * @author xcompwiz - */ -public class APIUndefined extends Exception { - - /** - * Generated Serial UID - */ - private static final long serialVersionUID = 7033833326135545759L; - - public APIUndefined(String string) { - super(string); - } -} +package com.xcompwiz.lookingglass.api; + +/** + * Thrown in the case of an API name being unrecognized (ex. requesting 'zymbol-1') + * + * @author xcompwiz + */ +public class APIUndefined extends Exception { + + /** + * Generated Serial UID + */ + private static final long serialVersionUID = 7033833326135545759L; + + public APIUndefined(String string) { + super(string); + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/api/APIVersionRemoved.java b/src/main/java/com/xcompwiz/lookingglass/api/APIVersionRemoved.java new file mode 100644 index 0000000..3e0bb8b --- /dev/null +++ b/src/main/java/com/xcompwiz/lookingglass/api/APIVersionRemoved.java @@ -0,0 +1,20 @@ +package com.xcompwiz.lookingglass.api; + +/** + * Thrown in the case of an API version having been removed entirely and no longer supported. This can be interpreted as + * the request being for below the minimum + * supported version for the API. + * + * @author xcompwiz + */ +public class APIVersionRemoved extends Exception { + + /** + * Generated Serial UID + */ + private static final long serialVersionUID = -7702376017254522430L; + + public APIVersionRemoved(String string) { + super(string); + } +} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/APIVersionUndefined.java b/src/main/java/com/xcompwiz/lookingglass/api/APIVersionUndefined.java similarity index 52% rename from src/api/java/com/xcompwiz/lookingglass/api/APIVersionUndefined.java rename to src/main/java/com/xcompwiz/lookingglass/api/APIVersionUndefined.java index 2c08a87..4fd735d 100644 --- a/src/api/java/com/xcompwiz/lookingglass/api/APIVersionUndefined.java +++ b/src/main/java/com/xcompwiz/lookingglass/api/APIVersionUndefined.java @@ -1,17 +1,18 @@ -package com.xcompwiz.lookingglass.api; - -/** - * Thrown in the case of an API version not being available (ex. requesting 'symbol-4096') - * @author xcompwiz - */ -public class APIVersionUndefined extends Exception { - - /** - * Generated Serial UID - */ - private static final long serialVersionUID = -6195164554156957083L; - - public APIVersionUndefined(String string) { - super(string); - } -} +package com.xcompwiz.lookingglass.api; + +/** + * Thrown in the case of an API version not being available (ex. requesting 'symbol-4096') + * + * @author xcompwiz + */ +public class APIVersionUndefined extends Exception { + + /** + * Generated Serial UID + */ + private static final long serialVersionUID = -6195164554156957083L; + + public APIVersionUndefined(String string) { + super(string); + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/api/IWorldViewAPI.java b/src/main/java/com/xcompwiz/lookingglass/api/IWorldViewAPI.java new file mode 100644 index 0000000..758bfc2 --- /dev/null +++ b/src/main/java/com/xcompwiz/lookingglass/api/IWorldViewAPI.java @@ -0,0 +1,29 @@ +package com.xcompwiz.lookingglass.api; + +import net.minecraft.util.ChunkCoordinates; + +import com.xcompwiz.lookingglass.api.view.IWorldView; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * @deprecated This interface will be removed in a future version. You should switch to the IWorldViewAPI2. + * @author xcompwiz + */ +@Deprecated +public interface IWorldViewAPI { + + /** + * Creates a world viewer object which will handle the rendering and retrieval of the remote location. Can return + * null. + * + * @param dimid The target dimension + * @param coords The coordinates of the target location. If null, world spawn is used. + * @param width Texture resolution width + * @param height Texture resolution height + * @return A IWorldView object for your use or null if something goes wrong. + */ + @SideOnly(Side.CLIENT) + IWorldView createWorldView(Integer dimid, ChunkCoordinates coords, int width, int height); +} diff --git a/src/main/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPivot.java b/src/main/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPivot.java new file mode 100644 index 0000000..4d285b7 --- /dev/null +++ b/src/main/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPivot.java @@ -0,0 +1,199 @@ +package com.xcompwiz.lookingglass.api.animator; + +import net.minecraft.block.Block; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.IBlockAccess; + +import com.xcompwiz.lookingglass.api.view.IViewCamera; + +/** + * This is a standard sample implementation of a camera animator. It simply uses the target location as a LookAt target + * and does a fly pivot around it. It can + * be extended for more control, if desired. + * + * @author xcompwiz + */ +public class CameraAnimatorPivot implements ICameraAnimator { + + /** + * This is a list of recommended, preset offsets that the animator will choose from. It's use can be overridden via + * function. + */ + private static final int[][] presets = { { 2, 5 }, { 5, 9 }, { 9, 15 }, { 1, 3 }, { 2, 1 }, { 0, 2 } }; + /** + * This is a pair used when the animator cannot find a good path from the presets. It's use can be overridden via + * function. + */ + private static final int[] defaults = { 1, 3 }; + + private final IViewCamera camera; + private ChunkCoordinates target; + + private boolean positionSet = false; + + private int xCenter; + private int yCenter; + private int zCenter; + + private int yUp = 0; + private int radius = 0; + private float pitch = 0; + + public CameraAnimatorPivot(IViewCamera camera) { + this.camera = camera; + } + + @Override + public void setTarget(ChunkCoordinates target) { + this.target = target; + positionSet = false; + } + + @Override + public void update(long dt) { + if (camera == null) return; + camera.addRotations(dt * 0.1F, 0); + camera.setPitch(-pitch); + + double x = Math.cos(Math.toRadians(camera.getYaw() + 90)) * radius; + double z = Math.sin(Math.toRadians(camera.getYaw() + 90)) * radius; + camera.setLocation(xCenter + 0.5 - x, yCenter - 0.5 + yUp, zCenter + 0.5 - z); + } + + @Override + public void refresh() { + if (camera == null) return; + if (target == null) return; + if (!positionSet) this.checkCameraY(); + + int chunkX = xCenter >> 4; + int chunkY = yCenter >> 4; + int chunkZ = zCenter >> 4; + + int[][] presets = this.getPresets(); + + for (int i = 0; i < presets.length; ++i) { + if (checkPath(presets[i][0], presets[i][1], chunkX, chunkY, chunkZ)) { + yUp = presets[i][0]; + radius = presets[i][1]; + pitch = (float) Math.toDegrees(Math.atan(((double) -yUp) / radius)); + return; + } + } + int[] defaults = this.getDefaults(); + yUp = defaults[0]; + radius = defaults[1]; + pitch = (float) Math.toDegrees(Math.atan(((double) -yUp) / radius)); + } + + /** + * Should the selection from the offsets fail, the pair of values in this array will be used instead. + * + * @return A pair of numbers up and distance in an array of length 2 + */ + public int[] getDefaults() { + return defaults; + } + + /** + * Overriding his function allows you specify your own offset presets. + * + * @return An array of integer pairs up and distance from which to select the first functional pair + */ + public int[][] getPresets() { + return presets; + } + + /** + * @author Ken Butler/shadowking97 + */ + private boolean checkPath(int up, int distance, int chunkX, int chunkY, int chunkZ) { + if ((yCenter & 15) > 15 - up) { + if (isAboveNullLayer(chunkX, chunkY, chunkZ)) return false; + if ((xCenter & 15) < distance) { + if (isAboveNullLayer(chunkX - 1, chunkY, chunkZ)) return false; + if ((zCenter & 15) < distance) { + if (isAboveNullLayer(chunkX - 1, chunkY, chunkZ - 1)) return false; + if (isAboveNullLayer(chunkX, chunkY, chunkZ - 1)) return false; + } else if ((zCenter & 15) > 15 - distance) { + if (isAboveNullLayer(chunkX - 1, chunkY, chunkZ + 1)) return false; + if (isAboveNullLayer(chunkX, chunkY, chunkZ + 1)) return false; + } + } else if ((xCenter & 15) > 15 - distance) { + if (isAboveNullLayer(chunkX + 1, chunkY, chunkZ)) return false; + if ((zCenter & 15) < distance) { + if (isAboveNullLayer(chunkX + 1, chunkY, chunkZ - 1)) return false; + if (isAboveNullLayer(chunkX, chunkY, chunkZ - 1)) return false; + } else if ((zCenter & 15) > 15 - distance) { + if (isAboveNullLayer(chunkX + 1, chunkY, chunkZ + 1)) return false; + if (isAboveNullLayer(chunkX, chunkY, chunkZ + 1)) return false; + } + } else { + if ((zCenter & 15) < distance) { + if (isAboveNullLayer(chunkX, chunkY, chunkZ - 1)) return false; + } else if ((zCenter & 15) > 15 - distance) { + if (isAboveNullLayer(chunkX, chunkY, chunkZ + 1)) return false; + } + } + } + for (int j = -distance; j <= distance; ++j) { + for (int k = -distance; k <= distance; ++k) { + if (!camera.getBlockData() + .isAirBlock(xCenter + j, yCenter + up, zCenter + k)) return false; + } + } + return true; + } + + /** + * @author Ken Butler/shadowking97 + */ + private boolean isAboveNullLayer(int x, int y, int z) { + if (y + 1 > 15) return true; + int x2 = x << 4; + int z2 = z << 4; + int y2 = (y << 4) + 15; + int yl = (y + 1) << 4; + for (int i = 0; i < 15; i++) for (int j = 0; j < 15; j++) + if (!isBlockNormalCube(camera.getBlockData(), x2 + i, y2, z2 + i)) return false; + if (camera.chunkLevelsExist(x, z, yl, yl + 15)) return true; + return false; + } + + private boolean isBlockNormalCube(IBlockAccess blockData, int x, int y, int z) { + Block block = blockData.getBlock(x, y, z); + return block.isNormalCube(blockData, x, y, z); + } + + private void checkCameraY() { + int x = target.posX; + int y = target.posY; + int z = target.posZ; + int yBackup = y; + if (camera.chunkExists(x, z)) { + if (camera.getBlockData() + .getBlock(x, y, z) + .getBlocksMovement(camera.getBlockData(), x, y, z)) { + while (y > 0 && camera.getBlockData() + .getBlock(x, --y, z) + .getBlocksMovement(camera.getBlockData(), x, y, z)); + if (y == 0) y = yBackup; + else y += 2; + } else { + while (y < 256 && !camera.getBlockData() + .getBlock(x, ++y, z) + .getBlocksMovement(camera.getBlockData(), x, y, z)); + if (y == 256) y = yBackup; + else++y; + } + this.setCenterPoint(x, y, z); + } + } + + private void setCenterPoint(int x, int y, int z) { + xCenter = x; + yCenter = y - 1; + zCenter = z; + positionSet = true; + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPlayer.java b/src/main/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPlayer.java new file mode 100644 index 0000000..0f9ec39 --- /dev/null +++ b/src/main/java/com/xcompwiz/lookingglass/api/animator/CameraAnimatorPlayer.java @@ -0,0 +1,111 @@ +package com.xcompwiz.lookingglass.api.animator; + +import net.minecraft.entity.Entity; +import net.minecraft.util.ChunkCoordinates; + +import com.xcompwiz.lookingglass.api.view.IViewCamera; + +/** + * This is a badly approximated "portal render" animator, which makes the camera move based on what direction the player + * is from some defined point. It doesn't + * do quite what it was meant to, but it's neat enough looking, so I'll leave it be. It does make a view look more + * "alive" or 3D, so if you just want a slightly + * animated view that doesn't look like you could walk through it, then this works great. It produces an effect more + * akin to Harry Potter's portraits than it + * does to Portal's portals. + * + * @author xcompwiz + */ +public class CameraAnimatorPlayer implements ICameraAnimator { + + // This is the camera object we are animating + private final IViewCamera camera; + + // The entity was are using as our reference point, such as our portrait view. + private Entity reference; + // The entity we are facing. Expected to be the client side player, but could be anything, really. + private Entity player; + // The point we are looking at in block coordinates. + private ChunkCoordinates target; + + private boolean updateY; + private float accum; + + /** + * + * @param camera + * @param reference The entity was are using as our reference point, such as our portrait view. + * @param player The entity we are facing. Expected to be the client side player, but could be anything, really. + */ + public CameraAnimatorPlayer(IViewCamera camera, Entity reference, Entity player) { + this.camera = camera; + this.reference = reference; + this.player = player; + } + + /** + * Sets the point we are looking at using block coordinates. + */ + @Override + public void setTarget(ChunkCoordinates target) { + this.target = new ChunkCoordinates(target); + } + + @Override + public void refresh() { + updateY = true; + } + + @Override + public void update(long dt) { + // This animator is incomplete and broken. It's a rough approximation I made at 4AM one night. + // However, it's also pretty cool looking, so I'm not going to bother fixing it. :P + // Note: Needs base yaw and pitch of view + if (reference.worldObj.provider.dimensionId != player.worldObj.provider.dimensionId) return; + + // A standard accumulator trick to force periodic rechecks of the y position. Probably superfluous. + // Ticks every 10 seconds + if ((accum += dt) >= 10000) { + updateY = true; + accum -= 10000; + } + if (updateY) updateTargetPosition(); + double dx = player.posX - reference.posX; + double dy = player.posY - (reference.posY + player.yOffset); + double dz = player.posZ - reference.posZ; + double length = Math.sqrt(dx * dx + dz * dz + dy * dy); // TODO: Needs Go Faster + float yaw = -(float) Math.atan2(dx, dz); + yaw *= 180 / Math.PI; + float pitch = (float) Math.asin(dy / length); + pitch *= 180 / Math.PI; + camera.setLocation(target.posX, target.posY, target.posZ); + camera.setYaw(yaw); + camera.setPitch(pitch); + } + + private void updateTargetPosition() { + updateY = false; + int x = target.posX; + int y = target.posY; + int z = target.posZ; + if (!camera.chunkExists(x, z)) { + if (camera.getBlockData() + .getBlock(x, y, z) + .getBlocksMovement(camera.getBlockData(), x, y, z)) { + while (y > 0 && camera.getBlockData() + .getBlock(x, --y, z) + .getBlocksMovement(camera.getBlockData(), x, y, z)); + if (y == 0) y = target.posY; + else y += 2; + } else { + while (y < 256 && !camera.getBlockData() + .getBlock(x, ++y, z) + .getBlocksMovement(camera.getBlockData(), x, y, z)); + if (y == 256) y = target.posY; + else++y; + } + target.posY = y; + } + } + +} diff --git a/src/main/java/com/xcompwiz/lookingglass/api/animator/ICameraAnimator.java b/src/main/java/com/xcompwiz/lookingglass/api/animator/ICameraAnimator.java new file mode 100644 index 0000000..246b47c --- /dev/null +++ b/src/main/java/com/xcompwiz/lookingglass/api/animator/ICameraAnimator.java @@ -0,0 +1,26 @@ +package com.xcompwiz.lookingglass.api.animator; + +import net.minecraft.util.ChunkCoordinates; + +public interface ICameraAnimator { + + /** + * Sets the look-at target (in block coordinates) + * + * @param target The block target + */ + void setTarget(ChunkCoordinates target); + + /** + * Allows the animator to refresh/reboot its settings + */ + void refresh(); + + /** + * Tick! + * + * @param dt Delta time in milliseconds since last render tick + */ + void update(long dt); + +} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/event/ClientWorldInfoEvent.java b/src/main/java/com/xcompwiz/lookingglass/api/event/ClientWorldInfoEvent.java similarity index 61% rename from src/api/java/com/xcompwiz/lookingglass/api/event/ClientWorldInfoEvent.java rename to src/main/java/com/xcompwiz/lookingglass/api/event/ClientWorldInfoEvent.java index 8968abc..cb3a184 100644 --- a/src/api/java/com/xcompwiz/lookingglass/api/event/ClientWorldInfoEvent.java +++ b/src/main/java/com/xcompwiz/lookingglass/api/event/ClientWorldInfoEvent.java @@ -1,20 +1,22 @@ package com.xcompwiz.lookingglass.api.event; import net.minecraft.entity.player.EntityPlayerMP; + import cpw.mods.fml.common.eventhandler.Event; /** * Called on the server side to allow mods to send dimension information to clients + * * @author xcompwiz */ public class ClientWorldInfoEvent extends Event { - public final int dim; - public final EntityPlayerMP player; + public final int dim; + public final EntityPlayerMP player; - public ClientWorldInfoEvent(int dim, EntityPlayerMP player) { - this.dim = dim; - this.player = player; - } + public ClientWorldInfoEvent(int dim, EntityPlayerMP player) { + this.dim = dim; + this.player = player; + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/api/hook/WorldViewAPI2.java b/src/main/java/com/xcompwiz/lookingglass/api/hook/WorldViewAPI2.java new file mode 100644 index 0000000..5308ddc --- /dev/null +++ b/src/main/java/com/xcompwiz/lookingglass/api/hook/WorldViewAPI2.java @@ -0,0 +1,38 @@ +package com.xcompwiz.lookingglass.api.hook; + +import net.minecraft.util.ChunkCoordinates; + +import com.xcompwiz.lookingglass.api.view.IWorldView; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Available via "view-2" from the API provider + * + * @author xcompwiz + */ +public interface WorldViewAPI2 { + + /** + * Creates a world viewer object which will handle the rendering and retrieval of the remote location. Can return + * null. + * + * @param dimid The target dimension + * @param coords The coordinates of the target location. If null, world spawn is used. + * @param width Texture resolution width + * @param height Texture resolution height + * @return A IWorldView object for your use or null if something goes wrong. + */ + @SideOnly(Side.CLIENT) + IWorldView createWorldView(Integer dimid, ChunkCoordinates coords, int width, int height); + + /** + * This function is available should you wish to explicitly have the world view clean up its framebuffer. You should + * not use a view after calling this on + * the view. + * + * @param worldview The view to clean up (effectively "destroy") + */ + void cleanupWorldView(IWorldView worldview); +} diff --git a/src/api/java/com/xcompwiz/lookingglass/api/package-info.java b/src/main/java/com/xcompwiz/lookingglass/api/package-info.java similarity index 70% rename from src/api/java/com/xcompwiz/lookingglass/api/package-info.java rename to src/main/java/com/xcompwiz/lookingglass/api/package-info.java index 918c79e..5936da6 100644 --- a/src/api/java/com/xcompwiz/lookingglass/api/package-info.java +++ b/src/main/java/com/xcompwiz/lookingglass/api/package-info.java @@ -1,9 +1,9 @@ -/** - * This package contains API for LookingGlass. You should never directly reference anything outside of this package (and it's sub-packages) when interacting - * with LookingGlass. - */ -@API(owner = "LookingGlass", apiVersion = "1.0", provides = "LookingGlass|API") -package com.xcompwiz.lookingglass.api; - -import cpw.mods.fml.common.API; - +/** + * This package contains API for LookingGlass. You should never directly reference anything outside of this package (and + * it's sub-packages) when interacting + * with LookingGlass. + */ +@API(owner = "LookingGlass", apiVersion = "1.0", provides = "LookingGlass|API") +package com.xcompwiz.lookingglass.api; + +import cpw.mods.fml.common.API; diff --git a/src/main/java/com/xcompwiz/lookingglass/api/view/IViewCamera.java b/src/main/java/com/xcompwiz/lookingglass/api/view/IViewCamera.java new file mode 100644 index 0000000..2cb289e --- /dev/null +++ b/src/main/java/com/xcompwiz/lookingglass/api/view/IViewCamera.java @@ -0,0 +1,96 @@ +package com.xcompwiz.lookingglass.api.view; + +import net.minecraft.world.IBlockAccess; + +public interface IViewCamera { + + /** + * Adds par1*0.15 to the entity's yaw, and *subtracts* par2*0.15 from the pitch. Clamps pitch from -90 to 90. Both + * arguments in degrees. + * + * @param yaw The yaw to be added + * @param pitch The pitch to be subtracted + */ + public void addRotations(float yaw, int pitch); + + /** + * Sets the yaw rotation of the camera + * + * @param f The camera's new yaw in degrees + */ + public void setYaw(float f); + + /** + * @return The camera's yaw in degrees + */ + public float getYaw(); + + /** + * Sets the pitch rotation of the camera + * + * @param f The camera's new pitch in degrees + */ + public void setPitch(float f); + + /** + * @return The camera's pitch in degrees + */ + public float getPitch(); + + /** + * Sets the position of the camera + * + * @param x X Coordinate (Block space) + * @param y Y Coordinate (Block space) + * @param z Z Coordinate (Block space) + */ + public void setLocation(double x, double y, double z); + + /** + * @return The camera's X coordinate (Block space) + */ + public double getX(); + + /** + * @return The camera's Y coordinate (Block space) + */ + public double getY(); + + /** + * @return The camera's Z coordinate (Block space) + */ + public double getZ(); + + /** + * This is provided to allow for checking for air blocks and similar. Technically, it is a WorldClient object, but + * it is provided as a IBlockAccess to + * discourage modifying the world. Modifying the world object would break things for everyone, so please don't do + * that. Should it become an issue, this will + * be replaced with something that isn't a WorldClient, so be wary of casting it. + * + * @return A read-only reference to the world which the camera inhabits + */ + public IBlockAccess getBlockData(); + + /** + * An easy check for if a chunk exists in the local data copy + * + * @param x The X coordinate in block space + * @param z The Z coordinate in block space + * @return True if the chunk at those coordinates is available locally + */ + public boolean chunkExists(int x, int z); + + /** + * Since LookingGlass utilizes partial chunk loading to minimize data traffic and storage, it's useful to be able to + * check if certain levels of a chunk are + * loaded locally. + * + * @param x The X coordinate in block space + * @param z The Z coordinate in block space + * @param yl1 The lower (closer to 0) y coordinate of the levels to check for in block space + * @param yl2 The larger (farther from 0) y coordinate of the levels to check for in block space + * @return True if the levels are loaded locally + */ + public boolean chunkLevelsExist(int x, int z, int yl1, int yl2); +} diff --git a/src/main/java/com/xcompwiz/lookingglass/api/view/IWorldView.java b/src/main/java/com/xcompwiz/lookingglass/api/view/IWorldView.java new file mode 100644 index 0000000..a3696a8 --- /dev/null +++ b/src/main/java/com/xcompwiz/lookingglass/api/view/IWorldView.java @@ -0,0 +1,50 @@ +package com.xcompwiz.lookingglass.api.view; + +import com.xcompwiz.lookingglass.api.animator.ICameraAnimator; + +public interface IWorldView { + + /** + * @return The OpenGL texture id for rendering the view + */ + public int getTexture(); + + /** + * This needs to be called to request LookingGlass rerender the view to the texture + */ + public void markDirty(); + + /** + * This will be activated once the view has chunks and is ready to render + * + * @return True if the view has been rendered to the texture. + */ + public boolean isReady(); + + /** + * Sets the animator object for the camera. This will be updated before each render frame. + * + * @param animator + */ + public void setAnimator(ICameraAnimator animator); + + /** + * Returns the view's camera object. This allows you to create animators for it and adjust its location locally. + * + * @return the entity object from which rendering is handled + */ + public IViewCamera getCamera(); + + /** + * @deprecated This function no longer does anything and will be removed in an upcoming version. + */ + @Deprecated + public void grab(); + + /** + * @deprecated This function no longer does anything and will be removed in an upcoming version. + */ + @Deprecated + public boolean release(); + +} diff --git a/src/main/java/com/xcompwiz/lookingglass/apiimpl/APIProviderImpl.java b/src/main/java/com/xcompwiz/lookingglass/apiimpl/APIProviderImpl.java index 8ca9d47..ee0cdbe 100644 --- a/src/main/java/com/xcompwiz/lookingglass/apiimpl/APIProviderImpl.java +++ b/src/main/java/com/xcompwiz/lookingglass/apiimpl/APIProviderImpl.java @@ -1,134 +1,145 @@ -package com.xcompwiz.lookingglass.apiimpl; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import com.xcompwiz.lookingglass.api.APIInstanceProvider; -import com.xcompwiz.lookingglass.api.APIUndefined; -import com.xcompwiz.lookingglass.api.APIVersionRemoved; -import com.xcompwiz.lookingglass.api.APIVersionUndefined; -import com.xcompwiz.lookingglass.log.LoggerUtils; - -/** - * The implementation of the API provider interface. Instances of this class are given to mods requesting an API provider and bound to that mod's name. The - * class also functions as the registration manager for what APIs we have available. - */ -public class APIProviderImpl implements APIInstanceProvider { - private String modname; - - public APIProviderImpl(String modname) { - this.modname = modname; - } - - public String getOwnerMod() { - return modname; - } - - private HashMap instances = new HashMap(); - - // See parent/javadoc for doc - @Override - public Object getAPIInstance(String api) throws APIUndefined, APIVersionUndefined, APIVersionRemoved { - Object ret = instances.get(api); - // First, we check if the API has already been constructed up for this provider - if (ret != null) return ret; - // Get the id and version from the passed in arg - String[] splitName = api.split("-"); - // If we can't get a name and version then we throw APIUndefined. - if (splitName.length != 2) throw new APIUndefined(api); - String apiname = splitName[0]; - int version = Integer.parseInt(splitName[1]); - // Ask the magical constructor to provide us an instance of the API for the specified version. - ret = constructAPIWrapper(modname, apiname, version); - instances.put(api, ret); - return ret; - } - - private static Map> apiCtors; - private static Map> apiVersions; - private static Map> apiVersions_immutable_sets; - private static Map> apiVersions_immutable; - - /** - * This init function sets up the wrapper constructors for the different APIs and versions of APIs we support. - */ - public static void init() { - // Skip if already initialized - if (apiCtors != null) return; - apiCtors = new HashMap>(); - apiVersions = new HashMap>(); - // Immutable views to the internal stuff to allow for the getAvailableAPIs functionality without breaking containment - apiVersions_immutable_sets = new HashMap>(); - apiVersions_immutable = Collections.unmodifiableMap(apiVersions_immutable_sets); - - // Register the APIs we support - registerAPI("view", 1, new WrapperBuilder(LookingGlassAPIWrapper.class)); - registerAPI("view", 2, new WrapperBuilder(LookingGlassAPI2Wrapper.class)); - // Note that removed API versions should be registered as null. - } - - private static void registerAPI(String apiname, int version, WrapperBuilder builder) { - getVersions(apiname).add(version); - getCtors(apiname).put(version, builder); - } - - private static Map getCtors(String apiname) { - Map ctors = apiCtors.get(apiname); - if (ctors == null) { - ctors = new HashMap(); - apiCtors.put(apiname, ctors); - } - return ctors; - } - - private static Set getVersions(String apiname) { - Set versions = apiVersions.get(apiname); - if (versions == null) { - versions = new HashSet(); - apiVersions.put(apiname, versions); - apiVersions_immutable_sets.put(apiname, Collections.unmodifiableSet(versions)); - } - return versions; - } - - /** - * ** This function is voodoo.**
This is the function which actually calls the builders to produce the wrappers which implement the version of the requested API. - * @param owner The name of the mod wanting the API - * @param apiname The name of the API wanted - * @param version The version of the API wanted - * @return An object which is an instance of the interface matching the API version - * @throws APIUndefined The API requested doesn't exist - * @throws APIVersionUndefined The API requested exists, but the version requested is missing in the local environment - * @throws APIVersionRemoved The API requested exists, but the version requested has been removed and is no longer supported - */ - private static Object constructAPIWrapper(String owner, String apiname, int version) throws APIUndefined, APIVersionUndefined, APIVersionRemoved { - // First, check to make sure we initialized before - if (apiCtors == null) throw new RuntimeException("Something is broken. The LookingGlass API Provider hasn't constructed properly."); - // Get the builders for the API we want - Map ctors = apiCtors.get(apiname); - // If there are no builders, then the API doesn't exist - if (ctors == null) throw new APIUndefined(apiname); - // If the builders collection doesn't have an entry for the version we wanted, it never existed - if (!ctors.containsKey(version)) throw new APIVersionUndefined(apiname + "-" + version); - // Get the builder entry - WrapperBuilder ctor = ctors.get(version); - // If the builder is null, then the API has been removed. - if (ctor == null) throw new APIVersionRemoved(apiname + "-" + version); - // Now, the magic itself. Use the builder to produce an instance of the API - try { - return ctor.newInstance(owner); // Poof! - } catch (Exception e) { - // If there are any problems then we need to report them. Theoretically there shouldn't be, but one never knows. - LoggerUtils.error("Caught an exception while building an API wrapper. Go kick XCompWiz."); - throw new RuntimeException("Caught an exception while building an API wrapper. Go kick XCompWiz.", e); - } - } - - @Override - public Map> getAvailableAPIs() { - return apiVersions_immutable; - } -} +package com.xcompwiz.lookingglass.apiimpl; + +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import com.xcompwiz.lookingglass.api.APIInstanceProvider; +import com.xcompwiz.lookingglass.api.APIUndefined; +import com.xcompwiz.lookingglass.api.APIVersionRemoved; +import com.xcompwiz.lookingglass.api.APIVersionUndefined; +import com.xcompwiz.lookingglass.log.LoggerUtils; + +/** + * The implementation of the API provider interface. Instances of this class are given to mods requesting an API + * provider and bound to that mod's name. The + * class also functions as the registration manager for what APIs we have available. + */ +public class APIProviderImpl implements APIInstanceProvider { + + private String modname; + + public APIProviderImpl(String modname) { + this.modname = modname; + } + + public String getOwnerMod() { + return modname; + } + + private HashMap instances = new HashMap(); + + // See parent/javadoc for doc + @Override + public Object getAPIInstance(String api) throws APIUndefined, APIVersionUndefined, APIVersionRemoved { + Object ret = instances.get(api); + // First, we check if the API has already been constructed up for this provider + if (ret != null) return ret; + // Get the id and version from the passed in arg + String[] splitName = api.split("-"); + // If we can't get a name and version then we throw APIUndefined. + if (splitName.length != 2) throw new APIUndefined(api); + String apiname = splitName[0]; + int version = Integer.parseInt(splitName[1]); + // Ask the magical constructor to provide us an instance of the API for the specified version. + ret = constructAPIWrapper(modname, apiname, version); + instances.put(api, ret); + return ret; + } + + private static Map> apiCtors; + private static Map> apiVersions; + private static Map> apiVersions_immutable_sets; + private static Map> apiVersions_immutable; + + /** + * This init function sets up the wrapper constructors for the different APIs and versions of APIs we support. + */ + public static void init() { + // Skip if already initialized + if (apiCtors != null) return; + apiCtors = new HashMap>(); + apiVersions = new HashMap>(); + // Immutable views to the internal stuff to allow for the getAvailableAPIs functionality without breaking + // containment + apiVersions_immutable_sets = new HashMap>(); + apiVersions_immutable = Collections.unmodifiableMap(apiVersions_immutable_sets); + + // Register the APIs we support + registerAPI("view", 1, new WrapperBuilder(LookingGlassAPIWrapper.class)); + registerAPI("view", 2, new WrapperBuilder(LookingGlassAPI2Wrapper.class)); + // Note that removed API versions should be registered as null. + } + + private static void registerAPI(String apiname, int version, WrapperBuilder builder) { + getVersions(apiname).add(version); + getCtors(apiname).put(version, builder); + } + + private static Map getCtors(String apiname) { + Map ctors = apiCtors.get(apiname); + if (ctors == null) { + ctors = new HashMap(); + apiCtors.put(apiname, ctors); + } + return ctors; + } + + private static Set getVersions(String apiname) { + Set versions = apiVersions.get(apiname); + if (versions == null) { + versions = new HashSet(); + apiVersions.put(apiname, versions); + apiVersions_immutable_sets.put(apiname, Collections.unmodifiableSet(versions)); + } + return versions; + } + + /** + * ** This function is voodoo.**
+ * This is the function which actually calls the builders to produce the wrappers which implement the version of the + * requested API. + * + * @param owner The name of the mod wanting the API + * @param apiname The name of the API wanted + * @param version The version of the API wanted + * @return An object which is an instance of the interface matching the API version + * @throws APIUndefined The API requested doesn't exist + * @throws APIVersionUndefined The API requested exists, but the version requested is missing in the local + * environment + * @throws APIVersionRemoved The API requested exists, but the version requested has been removed and is no longer + * supported + */ + private static Object constructAPIWrapper(String owner, String apiname, int version) + throws APIUndefined, APIVersionUndefined, APIVersionRemoved { + // First, check to make sure we initialized before + if (apiCtors == null) throw new RuntimeException( + "Something is broken. The LookingGlass API Provider hasn't constructed properly."); + // Get the builders for the API we want + Map ctors = apiCtors.get(apiname); + // If there are no builders, then the API doesn't exist + if (ctors == null) throw new APIUndefined(apiname); + // If the builders collection doesn't have an entry for the version we wanted, it never existed + if (!ctors.containsKey(version)) throw new APIVersionUndefined(apiname + "-" + version); + // Get the builder entry + WrapperBuilder ctor = ctors.get(version); + // If the builder is null, then the API has been removed. + if (ctor == null) throw new APIVersionRemoved(apiname + "-" + version); + // Now, the magic itself. Use the builder to produce an instance of the API + try { + return ctor.newInstance(owner); // Poof! + } catch (Exception e) { + // If there are any problems then we need to report them. Theoretically there shouldn't be, but one never + // knows. + LoggerUtils.error("Caught an exception while building an API wrapper. Go kick XCompWiz."); + throw new RuntimeException("Caught an exception while building an API wrapper. Go kick XCompWiz.", e); + } + } + + @Override + public Map> getAvailableAPIs() { + return apiVersions_immutable; + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/apiimpl/APIWrapper.java b/src/main/java/com/xcompwiz/lookingglass/apiimpl/APIWrapper.java index 9b2e1e0..5fe8959 100644 --- a/src/main/java/com/xcompwiz/lookingglass/apiimpl/APIWrapper.java +++ b/src/main/java/com/xcompwiz/lookingglass/apiimpl/APIWrapper.java @@ -1,14 +1,15 @@ -package com.xcompwiz.lookingglass.apiimpl; - -public class APIWrapper { - private String modname; - - public APIWrapper(String modname) { - this.modname = modname; - } - - public String getOwnerMod() { - return modname; - } - -} +package com.xcompwiz.lookingglass.apiimpl; + +public class APIWrapper { + + private String modname; + + public APIWrapper(String modname) { + this.modname = modname; + } + + public String getOwnerMod() { + return modname; + } + +} diff --git a/src/main/java/com/xcompwiz/lookingglass/apiimpl/InternalAPI.java b/src/main/java/com/xcompwiz/lookingglass/apiimpl/InternalAPI.java index e11a8f9..84370ba 100644 --- a/src/main/java/com/xcompwiz/lookingglass/apiimpl/InternalAPI.java +++ b/src/main/java/com/xcompwiz/lookingglass/apiimpl/InternalAPI.java @@ -1,24 +1,25 @@ -package com.xcompwiz.lookingglass.apiimpl; - -import java.util.HashMap; - -import com.xcompwiz.lookingglass.api.APIInstanceProvider; - -/** - * This class simply manages the construction and tracking of the API provider instances. The Mystcraft version was enormously more complex and did lots more, - * but I simplified it here. The class is intentionally not named APIInstanceProviderProvider.... - */ -public class InternalAPI { - - private static HashMap instances = new HashMap(); - - public synchronized static APIInstanceProvider getAPIProviderInstance(String modname) { - APIInstanceProvider instance = instances.get(modname); - if (instance == null) { - instance = new APIProviderImpl(modname); - instances.put(modname, instance); - } - return instance; - } - -} +package com.xcompwiz.lookingglass.apiimpl; + +import java.util.HashMap; + +import com.xcompwiz.lookingglass.api.APIInstanceProvider; + +/** + * This class simply manages the construction and tracking of the API provider instances. The Mystcraft version was + * enormously more complex and did lots more, + * but I simplified it here. The class is intentionally not named APIInstanceProviderProvider.... + */ +public class InternalAPI { + + private static HashMap instances = new HashMap(); + + public synchronized static APIInstanceProvider getAPIProviderInstance(String modname) { + APIInstanceProvider instance = instances.get(modname); + if (instance == null) { + instance = new APIProviderImpl(modname); + instances.put(modname, instance); + } + return instance; + } + +} diff --git a/src/main/java/com/xcompwiz/lookingglass/apiimpl/LookingGlassAPI2Wrapper.java b/src/main/java/com/xcompwiz/lookingglass/apiimpl/LookingGlassAPI2Wrapper.java index f7ae4e8..d4a6b6d 100644 --- a/src/main/java/com/xcompwiz/lookingglass/apiimpl/LookingGlassAPI2Wrapper.java +++ b/src/main/java/com/xcompwiz/lookingglass/apiimpl/LookingGlassAPI2Wrapper.java @@ -12,24 +12,27 @@ /** * This is the API wrapper (instance) class for the WorldView API at version 2. + * * @author xcompwiz */ public class LookingGlassAPI2Wrapper extends APIWrapper implements WorldViewAPI2 { - public LookingGlassAPI2Wrapper(String modname) { - super(modname); - } + public LookingGlassAPI2Wrapper(String modname) { + super(modname); + } - @Override - @SideOnly(Side.CLIENT) - public IWorldView createWorldView(Integer dimid, ChunkCoordinates spawn, int width, int height) { - return ProxyWorldManager.createWorldView(dimid, (spawn != null ? new ChunkCoordinates(spawn) : null), width, height); - } + @Override + @SideOnly(Side.CLIENT) + public IWorldView createWorldView(Integer dimid, ChunkCoordinates spawn, int width, int height) { + return ProxyWorldManager + .createWorldView(dimid, (spawn != null ? new ChunkCoordinates(spawn) : null), width, height); + } - @Override - public void cleanupWorldView(IWorldView worldview) { - if (worldview == null) return; - if (!(worldview instanceof WorldView)) throw new RuntimeException("[%s] is misusing the LookingGlass API. Cannot cleanup custom IWorldView objects."); - ProxyWorldManager.destroyWorldView((WorldView) worldview); - } + @Override + public void cleanupWorldView(IWorldView worldview) { + if (worldview == null) return; + if (!(worldview instanceof WorldView)) throw new RuntimeException( + "[%s] is misusing the LookingGlass API. Cannot cleanup custom IWorldView objects."); + ProxyWorldManager.destroyWorldView((WorldView) worldview); + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/apiimpl/LookingGlassAPIWrapper.java b/src/main/java/com/xcompwiz/lookingglass/apiimpl/LookingGlassAPIWrapper.java index ad63cea..e1d3a2c 100644 --- a/src/main/java/com/xcompwiz/lookingglass/apiimpl/LookingGlassAPIWrapper.java +++ b/src/main/java/com/xcompwiz/lookingglass/apiimpl/LookingGlassAPIWrapper.java @@ -1,28 +1,30 @@ -package com.xcompwiz.lookingglass.apiimpl; - -import net.minecraft.util.ChunkCoordinates; - -import com.xcompwiz.lookingglass.api.IWorldViewAPI; -import com.xcompwiz.lookingglass.api.view.IWorldView; -import com.xcompwiz.lookingglass.client.proxyworld.ProxyWorldManager; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * This is the API wrapper (instance) class for the WorldView API at version 1. - * @author xcompwiz - */ -@SuppressWarnings("deprecation") -public class LookingGlassAPIWrapper extends APIWrapper implements IWorldViewAPI { - - public LookingGlassAPIWrapper(String modname) { - super(modname); - } - - @Override - @SideOnly(Side.CLIENT) - public IWorldView createWorldView(Integer dimid, ChunkCoordinates spawn, int width, int height) { - return ProxyWorldManager.createWorldView(dimid, (spawn != null ? new ChunkCoordinates(spawn) : null), width, height); - } -} +package com.xcompwiz.lookingglass.apiimpl; + +import net.minecraft.util.ChunkCoordinates; + +import com.xcompwiz.lookingglass.api.IWorldViewAPI; +import com.xcompwiz.lookingglass.api.view.IWorldView; +import com.xcompwiz.lookingglass.client.proxyworld.ProxyWorldManager; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * This is the API wrapper (instance) class for the WorldView API at version 1. + * + * @author xcompwiz + */ +@SuppressWarnings("deprecation") +public class LookingGlassAPIWrapper extends APIWrapper implements IWorldViewAPI { + + public LookingGlassAPIWrapper(String modname) { + super(modname); + } + + @Override + @SideOnly(Side.CLIENT) + public IWorldView createWorldView(Integer dimid, ChunkCoordinates spawn, int width, int height) { + return ProxyWorldManager + .createWorldView(dimid, (spawn != null ? new ChunkCoordinates(spawn) : null), width, height); + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/apiimpl/WrapperBuilder.java b/src/main/java/com/xcompwiz/lookingglass/apiimpl/WrapperBuilder.java index 3354c90..cd8c073 100644 --- a/src/main/java/com/xcompwiz/lookingglass/apiimpl/WrapperBuilder.java +++ b/src/main/java/com/xcompwiz/lookingglass/apiimpl/WrapperBuilder.java @@ -1,31 +1,35 @@ -package com.xcompwiz.lookingglass.apiimpl; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -/** - * This is a bit of a magic class. We use it to build API instances (API wrappers). It requires that the target class have a constructor which takes a string. - * It passes the API instance "owner" to the constructor when building the wrapper instance. Basically a cheap and easy class factory. - */ -public class WrapperBuilder { - - private final Constructor itemCtor; - - public WrapperBuilder(Class clazz) { - try { - itemCtor = clazz.getConstructor(String.class); - } catch (Exception e) { - throw new RuntimeException("LookingGlass has derped.", e); - } - } - - /** - * Called by the APIProviderImpl to construct the API wrapper passed to it on its construction. - * @param owner - * @return The instance - */ - public Object newInstance(String owner) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { - return itemCtor.newInstance(owner); - } - -} +package com.xcompwiz.lookingglass.apiimpl; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +/** + * This is a bit of a magic class. We use it to build API instances (API wrappers). It requires that the target class + * have a constructor which takes a string. + * It passes the API instance "owner" to the constructor when building the wrapper instance. Basically a cheap and easy + * class factory. + */ +public class WrapperBuilder { + + private final Constructor itemCtor; + + public WrapperBuilder(Class clazz) { + try { + itemCtor = clazz.getConstructor(String.class); + } catch (Exception e) { + throw new RuntimeException("LookingGlass has derped.", e); + } + } + + /** + * Called by the APIProviderImpl to construct the API wrapper passed to it on its construction. + * + * @param owner + * @return The instance + */ + public Object newInstance(String owner) + throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { + return itemCtor.newInstance(owner); + } + +} diff --git a/src/main/java/com/xcompwiz/lookingglass/client/ClientProxy.java b/src/main/java/com/xcompwiz/lookingglass/client/ClientProxy.java index 4e6a3b2..0198bb7 100644 --- a/src/main/java/com/xcompwiz/lookingglass/client/ClientProxy.java +++ b/src/main/java/com/xcompwiz/lookingglass/client/ClientProxy.java @@ -1,31 +1,31 @@ -package com.xcompwiz.lookingglass.client; - -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; - -import com.xcompwiz.lookingglass.client.render.RenderPortal; -import com.xcompwiz.lookingglass.core.CommonProxy; -import com.xcompwiz.lookingglass.entity.EntityPortal; - -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * Our faithful proxy class. Allows for running code differently dependent on whether we are client- or server-side. - */ -@SideOnly(Side.CLIENT) -public class ClientProxy extends CommonProxy { - - /** - * Run during mod init. - */ - @Override - public void init() { - // We register the portal renderer here - Render render; - render = new RenderPortal(); - render.setRenderManager(RenderManager.instance); - RenderingRegistry.registerEntityRenderingHandler(EntityPortal.class, render); - } -} +package com.xcompwiz.lookingglass.client; + +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; + +import com.xcompwiz.lookingglass.client.render.RenderPortal; +import com.xcompwiz.lookingglass.core.CommonProxy; +import com.xcompwiz.lookingglass.entity.EntityPortal; + +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Our faithful proxy class. Allows for running code differently dependent on whether we are client- or server-side. + */ +@SideOnly(Side.CLIENT) +public class ClientProxy extends CommonProxy { + + /** + * Run during mod init. + */ + @Override + public void init() { + // We register the portal renderer here + Render render; + render = new RenderPortal(); + render.setRenderManager(RenderManager.instance); + RenderingRegistry.registerEntityRenderingHandler(EntityPortal.class, render); + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ProxyWorld.java b/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ProxyWorld.java index 6a6e367..b84a287 100644 --- a/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ProxyWorld.java +++ b/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ProxyWorld.java @@ -10,19 +10,41 @@ // FIXME: AAHH! Fake world classes! EXTERMINATE! public class ProxyWorld extends WorldClient { - public ProxyWorld(int dimensionID) { - super(Minecraft.getMinecraft().getNetHandler(), new WorldSettings(0L, GameType.SURVIVAL, true, false, WorldType.DEFAULT), dimensionID, Minecraft.getMinecraft().gameSettings.difficulty, Minecraft.getMinecraft().theWorld.theProfiler); - } - // TODO: In order to eliminate this class we may need an event in this function to allow canceling/redirecting sounds - @Override - public void playSound(double par1, double par3, double par5, String par7Str, float par8, float par9, boolean par10) {} + public ProxyWorld(int dimensionID) { + super( + Minecraft.getMinecraft() + .getNetHandler(), + new WorldSettings(0L, GameType.SURVIVAL, true, false, WorldType.DEFAULT), + dimensionID, + Minecraft.getMinecraft().gameSettings.difficulty, + Minecraft.getMinecraft().theWorld.theProfiler); + } - // TODO: In order to eliminate this class we need to create a redirection wrapper class for the mc.effectRenderer which does this for all views. - @Override - public void makeFireworks(double par1, double par3, double par5, double par7, double par9, double par11, NBTTagCompound par13NBTTagCompound) { - for (WorldView activeview : ProxyWorldManager.getWorldViews(this.provider.dimensionId)) { - activeview.getEffectRenderer().addEffect(new EntityFireworkStarterFX(this, par1, par3, par5, par7, par9, par11, activeview.getEffectRenderer(), par13NBTTagCompound)); - } - } + // TODO: In order to eliminate this class we may need an event in this function to allow canceling/redirecting + // sounds + @Override + public void playSound(double par1, double par3, double par5, String par7Str, float par8, float par9, + boolean par10) {} + + // TODO: In order to eliminate this class we need to create a redirection wrapper class for the mc.effectRenderer + // which does this for all views. + @Override + public void makeFireworks(double par1, double par3, double par5, double par7, double par9, double par11, + NBTTagCompound par13NBTTagCompound) { + for (WorldView activeview : ProxyWorldManager.getWorldViews(this.provider.dimensionId)) { + activeview.getEffectRenderer() + .addEffect( + new EntityFireworkStarterFX( + this, + par1, + par3, + par5, + par7, + par9, + par11, + activeview.getEffectRenderer(), + par13NBTTagCompound)); + } + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ProxyWorldManager.java b/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ProxyWorldManager.java index 8534135..9ffacb0 100644 --- a/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ProxyWorldManager.java +++ b/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ProxyWorldManager.java @@ -1,144 +1,161 @@ -package com.xcompwiz.lookingglass.client.proxyworld; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.WeakHashMap; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.ChunkCoordinates; -import net.minecraftforge.common.DimensionManager; - -import com.xcompwiz.lookingglass.client.render.FrameBufferContainer; -import com.xcompwiz.lookingglass.entity.EntityCamera; -import com.xcompwiz.lookingglass.log.LoggerUtils; -import com.xcompwiz.lookingglass.network.LookingGlassPacketManager; -import com.xcompwiz.lookingglass.network.packet.PacketCreateView; -import com.xcompwiz.lookingglass.proxyworld.ModConfigs; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class ProxyWorldManager { - private static Map proxyworlds = new HashMap(); - private static Collection proxyworldset = Collections.unmodifiableCollection(proxyworlds.values()); - /** We actually populate this with weak sets. This allows for the world views to be freed without us needing to do anything. */ - private static Map> worldviewsets = new HashMap>(); - - /** - * This is a complex bit. As we want to reuse the current client world when rendering, if possible, we need to handle when that world changes. We could - * simply destroy all the views pointing to the existing proxy world, but that would be annoying to mods using the API. Instead, we replace our proxy world - * with the new client world. This should only be called by LookingGlass, and only from the handling of the client world change detection. - * @param world The new client world - */ - public static void handleWorldChange(WorldClient world) { - if (ModConfigs.disabled) return; - if (world == null) return; - int dimid = world.provider.dimensionId; - if (!proxyworlds.containsKey(dimid)) return; //BEST CASE! We don't have to do anything! - proxyworlds.put(dimid, world); - Collection worldviews = worldviewsets.get(dimid); - for (WorldView view : worldviews) { - // Handle the change on the view object - view.replaceWorldObject(world); - } - } - - public static synchronized void detectFreedWorldViews() { - FrameBufferContainer.detectFreedWorldViews(); - //TODO: closeViewConnection(worldviewID); - HashSet emptyLists = new HashSet(); - for (Map.Entry> entry : worldviewsets.entrySet()) { - if (entry.getValue().isEmpty()) emptyLists.add(entry.getKey()); - } - for (Integer dimId : emptyLists) { - unloadProxyWorld(dimId); - } - } - - public static synchronized WorldClient getProxyworld(int dimid) { - if (ModConfigs.disabled) return null; - WorldClient proxyworld = proxyworlds.get(dimid); - if (proxyworld == null) { - if (!DimensionManager.isDimensionRegistered(dimid)) return null; - // We really don't want to be doing this during a render cycle - if (Minecraft.getMinecraft().thePlayer instanceof EntityCamera) return null; //TODO: This check probably needs to be altered - WorldClient theWorld = Minecraft.getMinecraft().theWorld; - if (theWorld != null && theWorld.provider.dimensionId == dimid) proxyworld = theWorld; - if (proxyworld == null) proxyworld = new ProxyWorld(dimid); - proxyworlds.put(dimid, proxyworld); - worldviewsets.put(dimid, Collections.newSetFromMap(new WeakHashMap())); - } - return proxyworld; - } - - private static void unloadProxyWorld(int dimId) { - Collection set = worldviewsets.remove(dimId); - if (set != null && set.size() > 0) LoggerUtils.warn("Unloading ProxyWorld with live views"); - WorldClient proxyworld = proxyworlds.remove(dimId); - WorldClient theWorld = Minecraft.getMinecraft().theWorld; - if (theWorld != null && theWorld == proxyworld) return; - if (proxyworld != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(proxyworld)); - } - - public static void clearProxyworlds() { - while (!proxyworlds.isEmpty()) { - unloadProxyWorld(proxyworlds.keySet().iterator().next()); - } - } - - public static Collection getProxyworlds() { - return proxyworldset; - } - - public static Collection getWorldViews(int dimid) { - Collection set = worldviewsets.get(dimid); - if (set == null) return Collections.emptySet(); - return Collections.unmodifiableCollection(set); - } - - public static WorldView createWorldView(int dimid, ChunkCoordinates spawn, int width, int height) { - if (ModConfigs.disabled) return null; - if (!DimensionManager.isDimensionRegistered(dimid)) return null; - - WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimid); - if (proxyworld == null) return null; - - Collection worldviews = worldviewsets.get(dimid); - if (worldviews == null) return null; - - WorldView view = new WorldView(proxyworld, spawn, width, height); - - // Initialize the view rendering system - Minecraft mc = Minecraft.getMinecraft(); - EntityLivingBase backup = mc.renderViewEntity; - mc.renderViewEntity = view.camera; - view.getRenderGlobal().setWorldAndLoadRenderers(proxyworld); - mc.renderViewEntity = backup; - - // Inform the server of the new view - LookingGlassPacketManager.bus.sendToServer(PacketCreateView.createPacket(view)); - worldviews.add(view); - return view; - } - - //TODO: private static void closeViewConnection(long worldviewID) { - //LookingGlassPacketManager.bus.sendToServer(PacketCloseView.createPacket(worldviewID)); - //} - - /** - * Handles explicit shutdown of a world view. Tells the view to clean itself up and removes it from the tracked world views here (encouraging the world to unload). - * @param view The view to kill - */ - public static void destroyWorldView(WorldView view) { - Collection set = worldviewsets.get(view.getWorldObj().provider.dimensionId); - if (set != null) set.remove(view); - //TODO: closeViewConnection(worldviewID); - view.cleanup(); - } -} +package com.xcompwiz.lookingglass.client.proxyworld; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.WeakHashMap; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.ChunkCoordinates; +import net.minecraftforge.common.DimensionManager; + +import com.xcompwiz.lookingglass.client.render.FrameBufferContainer; +import com.xcompwiz.lookingglass.entity.EntityCamera; +import com.xcompwiz.lookingglass.log.LoggerUtils; +import com.xcompwiz.lookingglass.network.LookingGlassPacketManager; +import com.xcompwiz.lookingglass.network.packet.PacketCreateView; +import com.xcompwiz.lookingglass.proxyworld.ModConfigs; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ProxyWorldManager { + + private static Map proxyworlds = new HashMap(); + private static Collection proxyworldset = Collections.unmodifiableCollection(proxyworlds.values()); + /** + * We actually populate this with weak sets. This allows for the world views to be freed without us needing to do + * anything. + */ + private static Map> worldviewsets = new HashMap>(); + + /** + * This is a complex bit. As we want to reuse the current client world when rendering, if possible, we need to + * handle when that world changes. We could + * simply destroy all the views pointing to the existing proxy world, but that would be annoying to mods using the + * API. Instead, we replace our proxy world + * with the new client world. This should only be called by LookingGlass, and only from the handling of the client + * world change detection. + * + * @param world The new client world + */ + public static void handleWorldChange(WorldClient world) { + if (ModConfigs.disabled) return; + if (world == null) return; + int dimid = world.provider.dimensionId; + if (!proxyworlds.containsKey(dimid)) return; // BEST CASE! We don't have to do anything! + proxyworlds.put(dimid, world); + Collection worldviews = worldviewsets.get(dimid); + for (WorldView view : worldviews) { + // Handle the change on the view object + view.replaceWorldObject(world); + } + } + + public static synchronized void detectFreedWorldViews() { + FrameBufferContainer.detectFreedWorldViews(); + // TODO: closeViewConnection(worldviewID); + HashSet emptyLists = new HashSet(); + for (Map.Entry> entry : worldviewsets.entrySet()) { + if (entry.getValue() + .isEmpty()) emptyLists.add(entry.getKey()); + } + for (Integer dimId : emptyLists) { + unloadProxyWorld(dimId); + } + } + + public static synchronized WorldClient getProxyworld(int dimid) { + if (ModConfigs.disabled) return null; + WorldClient proxyworld = proxyworlds.get(dimid); + if (proxyworld == null) { + if (!DimensionManager.isDimensionRegistered(dimid)) return null; + // We really don't want to be doing this during a render cycle + if (Minecraft.getMinecraft().thePlayer instanceof EntityCamera) return null; // TODO: This check probably + // needs to be altered + WorldClient theWorld = Minecraft.getMinecraft().theWorld; + if (theWorld != null && theWorld.provider.dimensionId == dimid) proxyworld = theWorld; + if (proxyworld == null) proxyworld = new ProxyWorld(dimid); + proxyworlds.put(dimid, proxyworld); + worldviewsets.put(dimid, Collections.newSetFromMap(new WeakHashMap())); + } + return proxyworld; + } + + private static void unloadProxyWorld(int dimId) { + Collection set = worldviewsets.remove(dimId); + if (set != null && set.size() > 0) LoggerUtils.warn("Unloading ProxyWorld with live views"); + WorldClient proxyworld = proxyworlds.remove(dimId); + WorldClient theWorld = Minecraft.getMinecraft().theWorld; + if (theWorld != null && theWorld == proxyworld) return; + if (proxyworld != null) net.minecraftforge.common.MinecraftForge.EVENT_BUS + .post(new net.minecraftforge.event.world.WorldEvent.Unload(proxyworld)); + } + + public static void clearProxyworlds() { + while (!proxyworlds.isEmpty()) { + unloadProxyWorld( + proxyworlds.keySet() + .iterator() + .next()); + } + } + + public static Collection getProxyworlds() { + return proxyworldset; + } + + public static Collection getWorldViews(int dimid) { + Collection set = worldviewsets.get(dimid); + if (set == null) return Collections.emptySet(); + return Collections.unmodifiableCollection(set); + } + + public static WorldView createWorldView(int dimid, ChunkCoordinates spawn, int width, int height) { + if (ModConfigs.disabled) return null; + if (!DimensionManager.isDimensionRegistered(dimid)) return null; + + WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimid); + if (proxyworld == null) return null; + + Collection worldviews = worldviewsets.get(dimid); + if (worldviews == null) return null; + + WorldView view = new WorldView(proxyworld, spawn, width, height); + + // Initialize the view rendering system + Minecraft mc = Minecraft.getMinecraft(); + EntityLivingBase backup = mc.renderViewEntity; + mc.renderViewEntity = view.camera; + view.getRenderGlobal() + .setWorldAndLoadRenderers(proxyworld); + mc.renderViewEntity = backup; + + // Inform the server of the new view + LookingGlassPacketManager.bus.sendToServer(PacketCreateView.createPacket(view)); + worldviews.add(view); + return view; + } + + // TODO: private static void closeViewConnection(long worldviewID) { + // LookingGlassPacketManager.bus.sendToServer(PacketCloseView.createPacket(worldviewID)); + // } + + /** + * Handles explicit shutdown of a world view. Tells the view to clean itself up and removes it from the tracked + * world views here (encouraging the world to unload). + * + * @param view The view to kill + */ + public static void destroyWorldView(WorldView view) { + Collection set = worldviewsets.get(view.getWorldObj().provider.dimensionId); + if (set != null) set.remove(view); + // TODO: closeViewConnection(worldviewID); + view.cleanup(); + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ViewCameraImpl.java b/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ViewCameraImpl.java index 2c9c5c7..6bd18ad 100644 --- a/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ViewCameraImpl.java +++ b/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/ViewCameraImpl.java @@ -6,72 +6,75 @@ import com.xcompwiz.lookingglass.entity.EntityCamera; public class ViewCameraImpl implements IViewCamera { - private EntityCamera camera; - - public ViewCameraImpl(EntityCamera camera) { - this.camera = camera; - } - - @Override - public void addRotations(float yaw, int pitch) { - this.camera.setAngles(yaw, pitch); - } - - @Override - public void setYaw(float f) { - this.camera.prevRotationYaw = f; - this.camera.rotationYaw = f; - } - - @Override - public float getYaw() { - return this.camera.rotationYaw; - } - - @Override - public void setPitch(float f) { - this.camera.prevRotationPitch = f; - this.camera.rotationPitch = f; - } - - @Override - public float getPitch() { - return this.camera.rotationPitch; - } - - @Override - public void setLocation(double x, double y, double z) { - this.camera.setLocationAndAngles(x, y, z, this.camera.rotationYaw, this.camera.rotationPitch); - } - - @Override - public double getX() { - return this.camera.posX; - } - - @Override - public double getY() { - return this.camera.posY; - } - - @Override - public double getZ() { - return this.camera.posZ; - } - - @Override - public IBlockAccess getBlockData() { - return this.camera.worldObj; - } - - @Override - public boolean chunkExists(int x, int z) { - return !camera.worldObj.getChunkFromBlockCoords(x, z).isEmpty(); - } - - @Override - public boolean chunkLevelsExist(int x, int z, int yl1, int yl2) { - return !camera.worldObj.getChunkFromBlockCoords(x, z).getAreLevelsEmpty(yl1, yl2); - } + + private EntityCamera camera; + + public ViewCameraImpl(EntityCamera camera) { + this.camera = camera; + } + + @Override + public void addRotations(float yaw, int pitch) { + this.camera.setAngles(yaw, pitch); + } + + @Override + public void setYaw(float f) { + this.camera.prevRotationYaw = f; + this.camera.rotationYaw = f; + } + + @Override + public float getYaw() { + return this.camera.rotationYaw; + } + + @Override + public void setPitch(float f) { + this.camera.prevRotationPitch = f; + this.camera.rotationPitch = f; + } + + @Override + public float getPitch() { + return this.camera.rotationPitch; + } + + @Override + public void setLocation(double x, double y, double z) { + this.camera.setLocationAndAngles(x, y, z, this.camera.rotationYaw, this.camera.rotationPitch); + } + + @Override + public double getX() { + return this.camera.posX; + } + + @Override + public double getY() { + return this.camera.posY; + } + + @Override + public double getZ() { + return this.camera.posZ; + } + + @Override + public IBlockAccess getBlockData() { + return this.camera.worldObj; + } + + @Override + public boolean chunkExists(int x, int z) { + return !camera.worldObj.getChunkFromBlockCoords(x, z) + .isEmpty(); + } + + @Override + public boolean chunkLevelsExist(int x, int z, int yl1, int yl2) { + return !camera.worldObj.getChunkFromBlockCoords(x, z) + .getAreLevelsEmpty(yl1, yl2); + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/WorldView.java b/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/WorldView.java index 852d35d..50c599c 100644 --- a/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/WorldView.java +++ b/src/main/java/com/xcompwiz/lookingglass/client/proxyworld/WorldView.java @@ -1,150 +1,160 @@ -package com.xcompwiz.lookingglass.client.proxyworld; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.client.particle.EffectRenderer; -import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.util.MathHelper; - -import com.xcompwiz.lookingglass.api.animator.ICameraAnimator; -import com.xcompwiz.lookingglass.api.view.IViewCamera; -import com.xcompwiz.lookingglass.api.view.IWorldView; -import com.xcompwiz.lookingglass.client.render.FrameBufferContainer; -import com.xcompwiz.lookingglass.entity.EntityCamera; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class WorldView implements IWorldView { - private WorldClient worldObj; - public final ChunkCoordinates coords; - public final EntityCamera camera; - public final IViewCamera camerawrapper; - - public final int width; - public final int height; - - private boolean update; - private boolean ready; - private boolean hasChunks; - private long last_render_time = -1; - - private RenderGlobal renderGlobal; - private EffectRenderer effectRenderer; - - private FrameBufferContainer fbo; - - public WorldView(WorldClient worldObj, ChunkCoordinates coords, int width, int height) { - this.width = width; - this.height = height; - this.worldObj = worldObj; - this.coords = coords; - this.camera = new EntityCamera(worldObj, coords); - this.camerawrapper = new ViewCameraImpl(camera); - this.renderGlobal = new RenderGlobal(Minecraft.getMinecraft()); - this.effectRenderer = new EffectRenderer(worldObj, Minecraft.getMinecraft().getTextureManager()); - // Technically speaking, this is poor practice as it leaks a reference to the view before it's done constructing. - this.fbo = FrameBufferContainer.createNewFramebuffer(this, width, height); - } - - /** - * Explicitly shuts down the view. Informs the frame buffer manager that we don't want our framebuffer anymore (so it can be cleaned up for certain on the - * next cleanup pass) and kills our fbo reference. The view is no longer usable after this is called. - */ - public void cleanup() { - this.fbo = null; - FrameBufferContainer.removeWorldView(this); - } - - @Override - public boolean isReady() { - return fbo == null ? false : ready; - } - - public boolean hasChunks() { - return fbo == null ? false : hasChunks; - } - - @Override - public void markDirty() { - update = true; - } - - public boolean markClean() { - if (fbo == null) return false; - ready = true; - boolean temp = update; - update = false; - return temp; - } - - public int getFramebuffer() { - return fbo == null ? 0 : fbo.getFramebuffer(); - } - - public RenderGlobal getRenderGlobal() { - return this.renderGlobal; - } - - public EffectRenderer getEffectRenderer() { - return this.effectRenderer; - } - - @Override - public int getTexture() { - return fbo == null ? 0 : fbo.getTexture(); - } - - @Override - public void grab() {} - - @Override - public boolean release() { - return false; - } - - public void onChunkReceived(int cx, int cz) { - this.hasChunks = true; - int cam_cx = MathHelper.floor_double(this.camera.posX) >> 4; - int cam_cz = MathHelper.floor_double(this.camera.posZ) >> 4; - if (cam_cx >= cx - 1 && cam_cx <= cx + 1 && cam_cz > cz - 1 && cam_cz < cz + 1) this.camera.refreshAnimator(); - } - - public void updateWorldSpawn(ChunkCoordinates cc) { - this.camera.updateWorldSpawn(cc); - } - - public void startRender(long renderT) { - if (this.last_render_time > 0) this.camera.tick(renderT - this.last_render_time); - this.last_render_time = renderT; - } - - @Override - public void setAnimator(ICameraAnimator animator) { - this.camera.setAnimator(animator); - } - - @Override - public IViewCamera getCamera() { - return camerawrapper; - } - - /** - * This is a really complex bit. As we want to reuse the current client world when rendering, if possible, we need to handle when that world changes. We - * could simply destroy all the views pointing to the existing proxy world, but that would be annoying to mods using the API. Instead, we replace our proxy - * world with the new client world. This should only be called by LookingGlass, and only from the handling of the client world change detection. - * @param world The new world - */ - public void replaceWorldObject(WorldClient world) { - this.worldObj = world; - this.camera.worldObj = world; - this.effectRenderer.clearEffects(world); - this.renderGlobal.setWorldAndLoadRenderers(world); - } - - public WorldClient getWorldObj() { - return this.worldObj; - } -} +package com.xcompwiz.lookingglass.client.proxyworld; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.MathHelper; + +import com.xcompwiz.lookingglass.api.animator.ICameraAnimator; +import com.xcompwiz.lookingglass.api.view.IViewCamera; +import com.xcompwiz.lookingglass.api.view.IWorldView; +import com.xcompwiz.lookingglass.client.render.FrameBufferContainer; +import com.xcompwiz.lookingglass.entity.EntityCamera; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class WorldView implements IWorldView { + + private WorldClient worldObj; + public final ChunkCoordinates coords; + public final EntityCamera camera; + public final IViewCamera camerawrapper; + + public final int width; + public final int height; + + private boolean update; + private boolean ready; + private boolean hasChunks; + private long last_render_time = -1; + + private RenderGlobal renderGlobal; + private EffectRenderer effectRenderer; + + private FrameBufferContainer fbo; + + public WorldView(WorldClient worldObj, ChunkCoordinates coords, int width, int height) { + this.width = width; + this.height = height; + this.worldObj = worldObj; + this.coords = coords; + this.camera = new EntityCamera(worldObj, coords); + this.camerawrapper = new ViewCameraImpl(camera); + this.renderGlobal = new RenderGlobal(Minecraft.getMinecraft()); + this.effectRenderer = new EffectRenderer( + worldObj, + Minecraft.getMinecraft() + .getTextureManager()); + // Technically speaking, this is poor practice as it leaks a reference to the view before it's done + // constructing. + this.fbo = FrameBufferContainer.createNewFramebuffer(this, width, height); + } + + /** + * Explicitly shuts down the view. Informs the frame buffer manager that we don't want our framebuffer anymore (so + * it can be cleaned up for certain on the + * next cleanup pass) and kills our fbo reference. The view is no longer usable after this is called. + */ + public void cleanup() { + this.fbo = null; + FrameBufferContainer.removeWorldView(this); + } + + @Override + public boolean isReady() { + return fbo == null ? false : ready; + } + + public boolean hasChunks() { + return fbo == null ? false : hasChunks; + } + + @Override + public void markDirty() { + update = true; + } + + public boolean markClean() { + if (fbo == null) return false; + ready = true; + boolean temp = update; + update = false; + return temp; + } + + public int getFramebuffer() { + return fbo == null ? 0 : fbo.getFramebuffer(); + } + + public RenderGlobal getRenderGlobal() { + return this.renderGlobal; + } + + public EffectRenderer getEffectRenderer() { + return this.effectRenderer; + } + + @Override + public int getTexture() { + return fbo == null ? 0 : fbo.getTexture(); + } + + @Override + public void grab() {} + + @Override + public boolean release() { + return false; + } + + public void onChunkReceived(int cx, int cz) { + this.hasChunks = true; + int cam_cx = MathHelper.floor_double(this.camera.posX) >> 4; + int cam_cz = MathHelper.floor_double(this.camera.posZ) >> 4; + if (cam_cx >= cx - 1 && cam_cx <= cx + 1 && cam_cz > cz - 1 && cam_cz < cz + 1) this.camera.refreshAnimator(); + } + + public void updateWorldSpawn(ChunkCoordinates cc) { + this.camera.updateWorldSpawn(cc); + } + + public void startRender(long renderT) { + if (this.last_render_time > 0) this.camera.tick(renderT - this.last_render_time); + this.last_render_time = renderT; + } + + @Override + public void setAnimator(ICameraAnimator animator) { + this.camera.setAnimator(animator); + } + + @Override + public IViewCamera getCamera() { + return camerawrapper; + } + + /** + * This is a really complex bit. As we want to reuse the current client world when rendering, if possible, we need + * to handle when that world changes. We + * could simply destroy all the views pointing to the existing proxy world, but that would be annoying to mods using + * the API. Instead, we replace our proxy + * world with the new client world. This should only be called by LookingGlass, and only from the handling of the + * client world change detection. + * + * @param world The new world + */ + public void replaceWorldObject(WorldClient world) { + this.worldObj = world; + this.camera.worldObj = world; + this.effectRenderer.clearEffects(world); + this.renderGlobal.setWorldAndLoadRenderers(world); + } + + public WorldClient getWorldObj() { + return this.worldObj; + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/client/render/FrameBufferContainer.java b/src/main/java/com/xcompwiz/lookingglass/client/render/FrameBufferContainer.java index a47af8b..6855d0f 100644 --- a/src/main/java/com/xcompwiz/lookingglass/client/render/FrameBufferContainer.java +++ b/src/main/java/com/xcompwiz/lookingglass/client/render/FrameBufferContainer.java @@ -15,104 +15,139 @@ import com.xcompwiz.lookingglass.log.LoggerUtils; public class FrameBufferContainer { - /** - * Using this map we can detect which FBOs should be freed. The map will delete any entry where the world view object is garbage collected. It unfortunately - * can't detect that the world view is otherwise leaked, though, just when it's gone. - */ - private static ConcurrentMap weakfbomap = new MapMaker().weakKeys(). makeMap(); - private static Collection framebuffers = new HashSet(); - - public static FrameBufferContainer createNewFramebuffer(WorldView view, int width, int height) { - FrameBufferContainer fbo = new FrameBufferContainer(width, height); - weakfbomap.put(view, fbo); - framebuffers.add(fbo); - return fbo; - } - - public static void removeWorldView(WorldView view) { - weakfbomap.remove(view); - } - - public static void clearAll() { - for (FrameBufferContainer fbo : framebuffers) { - fbo.release(); - } - framebuffers.clear(); - } - - public static synchronized void detectFreedWorldViews() { - Collection unpairedFBOs = new HashSet(framebuffers); - unpairedFBOs.removeAll(weakfbomap.values()); - if (unpairedFBOs.isEmpty()) return; - LoggerUtils.info("Freeing %d loose framebuffers from expired world views", unpairedFBOs.size()); - for (FrameBufferContainer fbo : unpairedFBOs) { - fbo.release(); - } - framebuffers.removeAll(unpairedFBOs); - } - - public final int width; - public final int height; - - private int framebuffer; - private int depthBuffer; - private int texture; - - private FrameBufferContainer(int width, int height) { - this.width = width; - this.height = height; - allocateFrameBuffer(); - } - - private void release() { - freeFrameBuffer(); - } - - public int getFramebuffer() { - return framebuffer; - } - - public int getTexture() { - return texture; - } - - // Always clean up your allocations - private synchronized void freeFrameBuffer() { - try { - if (this.texture != 0) GL11.glDeleteTextures(this.texture); - this.texture = 0; - if (depthBuffer != 0) EXTFramebufferObject.glDeleteRenderbuffersEXT(depthBuffer); - depthBuffer = 0; - if (this.framebuffer != 0) EXTFramebufferObject.glDeleteFramebuffersEXT(this.framebuffer); - this.framebuffer = 0; - } catch (Exception e) { - // Just in case, we make sure we don't crash. Because crashing is bad. - LoggerUtils.error("Error while cleaning up a world view frame buffer."); - } - } - - // This method builds the frame buffer and texture references - private void allocateFrameBuffer() { - if (this.framebuffer != 0) return; - - this.framebuffer = EXTFramebufferObject.glGenFramebuffersEXT(); //Release via: EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffer); - this.depthBuffer = EXTFramebufferObject.glGenRenderbuffersEXT(); //Release via: EXTFramebufferObject.glDeleteRenderbuffersEXT(depthBuffer); - - EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, this.framebuffer); - - EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthBuffer); - if (MinecraftForgeClient.getStencilBits() == 0) EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT24, width, height); - else EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, org.lwjgl.opengl.EXTPackedDepthStencil.GL_DEPTH24_STENCIL8_EXT, width, height); - - EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthBuffer); - if (MinecraftForgeClient.getStencilBits() != 0) EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthBuffer); - - this.texture = GL11.glGenTextures(); //Release via: GL11.glDeleteTextures(colorTexture); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.texture); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); - GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_INT, (java.nio.ByteBuffer) null); - EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, this.texture, 0); - - EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); - } + + /** + * Using this map we can detect which FBOs should be freed. The map will delete any entry where the world view + * object is garbage collected. It unfortunately + * can't detect that the world view is otherwise leaked, though, just when it's gone. + */ + private static ConcurrentMap weakfbomap = new MapMaker().weakKeys() + .makeMap(); + private static Collection framebuffers = new HashSet(); + + public static FrameBufferContainer createNewFramebuffer(WorldView view, int width, int height) { + FrameBufferContainer fbo = new FrameBufferContainer(width, height); + weakfbomap.put(view, fbo); + framebuffers.add(fbo); + return fbo; + } + + public static void removeWorldView(WorldView view) { + weakfbomap.remove(view); + } + + public static void clearAll() { + for (FrameBufferContainer fbo : framebuffers) { + fbo.release(); + } + framebuffers.clear(); + } + + public static synchronized void detectFreedWorldViews() { + Collection unpairedFBOs = new HashSet(framebuffers); + unpairedFBOs.removeAll(weakfbomap.values()); + if (unpairedFBOs.isEmpty()) return; + LoggerUtils.info("Freeing %d loose framebuffers from expired world views", unpairedFBOs.size()); + for (FrameBufferContainer fbo : unpairedFBOs) { + fbo.release(); + } + framebuffers.removeAll(unpairedFBOs); + } + + public final int width; + public final int height; + + private int framebuffer; + private int depthBuffer; + private int texture; + + private FrameBufferContainer(int width, int height) { + this.width = width; + this.height = height; + allocateFrameBuffer(); + } + + private void release() { + freeFrameBuffer(); + } + + public int getFramebuffer() { + return framebuffer; + } + + public int getTexture() { + return texture; + } + + // Always clean up your allocations + private synchronized void freeFrameBuffer() { + try { + if (this.texture != 0) GL11.glDeleteTextures(this.texture); + this.texture = 0; + if (depthBuffer != 0) EXTFramebufferObject.glDeleteRenderbuffersEXT(depthBuffer); + depthBuffer = 0; + if (this.framebuffer != 0) EXTFramebufferObject.glDeleteFramebuffersEXT(this.framebuffer); + this.framebuffer = 0; + } catch (Exception e) { + // Just in case, we make sure we don't crash. Because crashing is bad. + LoggerUtils.error("Error while cleaning up a world view frame buffer."); + } + } + + // This method builds the frame buffer and texture references + private void allocateFrameBuffer() { + if (this.framebuffer != 0) return; + + this.framebuffer = EXTFramebufferObject.glGenFramebuffersEXT(); // Release via: + // EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffer); + this.depthBuffer = EXTFramebufferObject.glGenRenderbuffersEXT(); // Release via: + // EXTFramebufferObject.glDeleteRenderbuffersEXT(depthBuffer); + + EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, this.framebuffer); + + EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthBuffer); + if (MinecraftForgeClient.getStencilBits() == 0) EXTFramebufferObject.glRenderbufferStorageEXT( + EXTFramebufferObject.GL_RENDERBUFFER_EXT, + GL14.GL_DEPTH_COMPONENT24, + width, + height); + else EXTFramebufferObject.glRenderbufferStorageEXT( + EXTFramebufferObject.GL_RENDERBUFFER_EXT, + org.lwjgl.opengl.EXTPackedDepthStencil.GL_DEPTH24_STENCIL8_EXT, + width, + height); + + EXTFramebufferObject.glFramebufferRenderbufferEXT( + EXTFramebufferObject.GL_FRAMEBUFFER_EXT, + EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, + EXTFramebufferObject.GL_RENDERBUFFER_EXT, + depthBuffer); + if (MinecraftForgeClient.getStencilBits() != 0) EXTFramebufferObject.glFramebufferRenderbufferEXT( + EXTFramebufferObject.GL_FRAMEBUFFER_EXT, + EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, + EXTFramebufferObject.GL_RENDERBUFFER_EXT, + depthBuffer); + + this.texture = GL11.glGenTextures(); // Release via: GL11.glDeleteTextures(colorTexture); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.texture); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + GL11.glTexImage2D( + GL11.GL_TEXTURE_2D, + 0, + GL11.GL_RGBA8, + width, + height, + 0, + GL11.GL_RGBA, + GL11.GL_INT, + (java.nio.ByteBuffer) null); + EXTFramebufferObject.glFramebufferTexture2DEXT( + EXTFramebufferObject.GL_FRAMEBUFFER_EXT, + EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, + GL11.GL_TEXTURE_2D, + this.texture, + 0); + + EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/client/render/RenderPortal.java b/src/main/java/com/xcompwiz/lookingglass/client/render/RenderPortal.java index a7e56e8..cb74a95 100644 --- a/src/main/java/com/xcompwiz/lookingglass/client/render/RenderPortal.java +++ b/src/main/java/com/xcompwiz/lookingglass/client/render/RenderPortal.java @@ -1,69 +1,69 @@ -package com.xcompwiz.lookingglass.client.render; - -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - -import com.xcompwiz.lookingglass.api.view.IWorldView; -import com.xcompwiz.lookingglass.entity.EntityPortal; - -public class RenderPortal extends Render { - - @Override - public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) { - if (!(entity instanceof EntityPortal)) return; - EntityPortal portal = (EntityPortal) entity; - IWorldView activeview = portal.getActiveView(); - if (activeview == null) return; - - int texture = activeview.getTexture(); - if (texture == 0) return; - - int width = 2; - int height = 3; - double left = -width / 2.; - double top = 0; - - activeview.markDirty(); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_LIGHTING); - - GL11.glPushMatrix(); - GL11.glTranslatef((float) d, (float) d1, (float) d2); - - GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); - Tessellator tessellator = Tessellator.instance; - tessellator.setColorRGBA_F(1, 1, 1, 1); - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(left, top, 0.0D, 0.0D, 0.0D); //inc=bl out; inc=bl down - tessellator.addVertexWithUV(width + left, top, 0.0D, 1.0D, 0.0D); //dc=br out; inc=br down - tessellator.addVertexWithUV(width + left, height + top, 0.0D, 1.0D, 1.0D); //dec=tr out; dec=tr up - tessellator.addVertexWithUV(left, height + top, 0.0D, 0.0D, 1.0D); //inc=lt out; dec=tl up - tessellator.draw(); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); - //XXX: Make the back of the portals a little nicer - tessellator.setColorRGBA_F(0, 0, 1, 1); - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(left, height + top, 0.0D, 0.0D, 1.0D); - tessellator.addVertexWithUV(width + left, height + top, 0.0D, 1.0D, 1.0D); - tessellator.addVertexWithUV(width + left, top, 0.0D, 1.0D, 0.0D); - tessellator.addVertexWithUV(left, top, 0.0D, 0.0D, 0.0D); - tessellator.draw(); - GL11.glPopMatrix(); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_ALPHA_TEST); - } - - @Override - protected void bindEntityTexture(Entity entity) {} - - @Override - protected ResourceLocation getEntityTexture(Entity entity) { - return null; - } - -} +package com.xcompwiz.lookingglass.client.render; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import com.xcompwiz.lookingglass.api.view.IWorldView; +import com.xcompwiz.lookingglass.entity.EntityPortal; + +public class RenderPortal extends Render { + + @Override + public void doRender(Entity entity, double d, double d1, double d2, float f, float f1) { + if (!(entity instanceof EntityPortal)) return; + EntityPortal portal = (EntityPortal) entity; + IWorldView activeview = portal.getActiveView(); + if (activeview == null) return; + + int texture = activeview.getTexture(); + if (texture == 0) return; + + int width = 2; + int height = 3; + double left = -width / 2.; + double top = 0; + + activeview.markDirty(); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_LIGHTING); + + GL11.glPushMatrix(); + GL11.glTranslatef((float) d, (float) d1, (float) d2); + + GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); + Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA_F(1, 1, 1, 1); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(left, top, 0.0D, 0.0D, 0.0D); // inc=bl out; inc=bl down + tessellator.addVertexWithUV(width + left, top, 0.0D, 1.0D, 0.0D); // dc=br out; inc=br down + tessellator.addVertexWithUV(width + left, height + top, 0.0D, 1.0D, 1.0D); // dec=tr out; dec=tr up + tessellator.addVertexWithUV(left, height + top, 0.0D, 0.0D, 1.0D); // inc=lt out; dec=tl up + tessellator.draw(); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); + // XXX: Make the back of the portals a little nicer + tessellator.setColorRGBA_F(0, 0, 1, 1); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(left, height + top, 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV(width + left, height + top, 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV(width + left, top, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV(left, top, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + GL11.glPopMatrix(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + @Override + protected void bindEntityTexture(Entity entity) {} + + @Override + protected ResourceLocation getEntityTexture(Entity entity) { + return null; + } + +} diff --git a/src/main/java/com/xcompwiz/lookingglass/client/render/RenderUtils.java b/src/main/java/com/xcompwiz/lookingglass/client/render/RenderUtils.java index 9547709..4efaf59 100644 --- a/src/main/java/com/xcompwiz/lookingglass/client/render/RenderUtils.java +++ b/src/main/java/com/xcompwiz/lookingglass/client/render/RenderUtils.java @@ -1,87 +1,87 @@ -package com.xcompwiz.lookingglass.client.render; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.EntityRenderer; -import net.minecraft.client.renderer.Tessellator; - -import org.lwjgl.opengl.EXTFramebufferObject; -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class RenderUtils { - - @SideOnly(Side.CLIENT) - public final static void renderWorldToTexture(float renderTime, int framebuffer, int width, int height) { - if (framebuffer == 0) return; - Minecraft mc = Minecraft.getMinecraft(); - if (mc.skipRenderWorld) return; - EntityRenderer entityRenderer = mc.entityRenderer; - - //Backup current render settings - int heightBackup = mc.displayHeight; - int widthBackup = mc.displayWidth; - - int thirdPersonBackup = mc.gameSettings.thirdPersonView; - boolean hideGuiBackup = mc.gameSettings.hideGUI; - int particleBackup = mc.gameSettings.particleSetting; - boolean anaglyphBackup = mc.gameSettings.anaglyph; - int renderDistanceBackup = mc.gameSettings.renderDistanceChunks; - float FOVbackup = mc.gameSettings.fovSetting; - - //Render world - try { - //Set all of the render setting to work on the proxy world - mc.displayHeight = height; - mc.displayWidth = width; - - //TODO: params (FOV, Particle setting, renderDistance) - mc.gameSettings.thirdPersonView = 0; - mc.gameSettings.hideGUI = true; - //mc.gameSettings.particleSetting = ; - mc.gameSettings.anaglyph = false; - //mc.gameSettings.renderDistanceChunks = ; - //mc.gameSettings.fovSetting = ; - - //Set gl options - GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); - EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer); - GL11.glClearColor(1.0f, 0.0f, 0.0f, 0.5f); - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); - - int i1 = mc.gameSettings.limitFramerate; - if (mc.isFramerateLimitBelowMax()) { - entityRenderer.renderWorld(renderTime, (1000000000 / i1)); - } else { - entityRenderer.renderWorld(renderTime, 0L); - } - } catch (Exception e) { - try { - //Clean up the tessellator, just in case. - Tessellator.instance.draw(); - } catch (Exception e2) { - //It might throw an exception, but that just means we didn't need to clean it up (this time) - } - throw new RuntimeException("Error while rendering proxy world", e); - } finally { - GL11.glEnable(GL11.GL_TEXTURE_2D); - EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); - - GL11.glViewport(0, 0, widthBackup, heightBackup); - GL11.glLoadIdentity(); - - mc.gameSettings.thirdPersonView = thirdPersonBackup; - mc.gameSettings.hideGUI = hideGuiBackup; - mc.gameSettings.particleSetting = particleBackup; - mc.gameSettings.anaglyph = anaglyphBackup; - mc.gameSettings.renderDistanceChunks = renderDistanceBackup; - mc.gameSettings.fovSetting = FOVbackup; - - mc.displayHeight = heightBackup; - mc.displayWidth = widthBackup; - } - } - -} +package com.xcompwiz.lookingglass.client.render; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.Tessellator; + +import org.lwjgl.opengl.EXTFramebufferObject; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class RenderUtils { + + @SideOnly(Side.CLIENT) + public final static void renderWorldToTexture(float renderTime, int framebuffer, int width, int height) { + if (framebuffer == 0) return; + Minecraft mc = Minecraft.getMinecraft(); + if (mc.skipRenderWorld) return; + EntityRenderer entityRenderer = mc.entityRenderer; + + // Backup current render settings + int heightBackup = mc.displayHeight; + int widthBackup = mc.displayWidth; + + int thirdPersonBackup = mc.gameSettings.thirdPersonView; + boolean hideGuiBackup = mc.gameSettings.hideGUI; + int particleBackup = mc.gameSettings.particleSetting; + boolean anaglyphBackup = mc.gameSettings.anaglyph; + int renderDistanceBackup = mc.gameSettings.renderDistanceChunks; + float FOVbackup = mc.gameSettings.fovSetting; + + // Render world + try { + // Set all of the render setting to work on the proxy world + mc.displayHeight = height; + mc.displayWidth = width; + + // TODO: params (FOV, Particle setting, renderDistance) + mc.gameSettings.thirdPersonView = 0; + mc.gameSettings.hideGUI = true; + // mc.gameSettings.particleSetting = ; + mc.gameSettings.anaglyph = false; + // mc.gameSettings.renderDistanceChunks = ; + // mc.gameSettings.fovSetting = ; + + // Set gl options + GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); + EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer); + GL11.glClearColor(1.0f, 0.0f, 0.0f, 0.5f); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); + + int i1 = mc.gameSettings.limitFramerate; + if (mc.isFramerateLimitBelowMax()) { + entityRenderer.renderWorld(renderTime, (1000000000 / i1)); + } else { + entityRenderer.renderWorld(renderTime, 0L); + } + } catch (Exception e) { + try { + // Clean up the tessellator, just in case. + Tessellator.instance.draw(); + } catch (Exception e2) { + // It might throw an exception, but that just means we didn't need to clean it up (this time) + } + throw new RuntimeException("Error while rendering proxy world", e); + } finally { + GL11.glEnable(GL11.GL_TEXTURE_2D); + EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); + + GL11.glViewport(0, 0, widthBackup, heightBackup); + GL11.glLoadIdentity(); + + mc.gameSettings.thirdPersonView = thirdPersonBackup; + mc.gameSettings.hideGUI = hideGuiBackup; + mc.gameSettings.particleSetting = particleBackup; + mc.gameSettings.anaglyph = anaglyphBackup; + mc.gameSettings.renderDistanceChunks = renderDistanceBackup; + mc.gameSettings.fovSetting = FOVbackup; + + mc.displayHeight = heightBackup; + mc.displayWidth = widthBackup; + } + } + +} diff --git a/src/main/java/com/xcompwiz/lookingglass/command/CommandBaseAdv.java b/src/main/java/com/xcompwiz/lookingglass/command/CommandBaseAdv.java index 9fa3681..f14f40e 100644 --- a/src/main/java/com/xcompwiz/lookingglass/command/CommandBaseAdv.java +++ b/src/main/java/com/xcompwiz/lookingglass/command/CommandBaseAdv.java @@ -1,108 +1,126 @@ -package com.xcompwiz.lookingglass.command; - -import java.util.Random; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.NumberInvalidException; -import net.minecraft.command.PlayerNotFoundException; -import net.minecraft.command.PlayerSelector; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.World; - -public abstract class CommandBaseAdv extends CommandBase { - - public void sendToAdmins(ICommandSender agent, String text, Object[] objects) { - func_152373_a(agent, this, text, objects); - } - - public static EntityPlayerMP getTargetPlayer(ICommandSender sender, String target) { - EntityPlayerMP entityplayermp = PlayerSelector.matchOnePlayer(sender, target); - - if (entityplayermp == null) { - entityplayermp = MinecraftServer.getServer().getConfigurationManager().func_152612_a(target); - } - if (entityplayermp == null) { throw new PlayerNotFoundException(); } - return entityplayermp; - } - - public static Integer getSenderDimension(ICommandSender sender) { - World w = sender.getEntityWorld(); - if (w == null) throw new CommandException("You must specify a dimension to use this command from the commandline"); - return w.provider.dimensionId; - } - - /** - * Returns the given ICommandSender as a EntityPlayer or throw an exception. - */ - public static TileEntity getCommandSenderAsTileEntity(ICommandSender sender) { - try { - World world = sender.getEntityWorld(); - ChunkCoordinates coords = sender.getPlayerCoordinates(); - return world.getTileEntity(coords.posX, coords.posY, coords.posZ); - } catch (Exception e) { - throw new CommandException("Could not get tile entity"); - } - } - - public static double handleRelativeNumber(ICommandSender sender, double origin, String arg) { - return handleRelativeNumber(sender, origin, arg, -30000000, 30000000); - } - - public static double handleRelativeNumber(ICommandSender par1ICommandSender, double origin, String arg, int min, int max) { - boolean relative = arg.startsWith("~"); - boolean random = arg.startsWith("?"); - if (random) relative = true; - double d1 = relative ? origin : 0.0D; - - if (!relative || arg.length() > 1) { - boolean flag1 = arg.contains("."); - - if (relative) { - arg = arg.substring(1); - } - - double d2 = parseDouble(par1ICommandSender, arg); - if (random) { - Random rand = new Random(); - d1 += (rand.nextDouble() * 2 - 1) * d2; - } else { - d1 += d2; - } - - if (!flag1 && !relative) { - d1 += 0.5D; - } - } - - if (min != 0 || max != 0) { - if (d1 < min) { throw new NumberInvalidException("commands.generic.double.tooSmall", new Object[] { Double.valueOf(d1), Integer.valueOf(min) }); } - - if (d1 > max) { throw new NumberInvalidException("commands.generic.double.tooBig", new Object[] { Double.valueOf(d1), Integer.valueOf(max) }); } - } - - return d1; - } - - /** - * Returns the player for a username as an Entity or throws an exception. - */ - public static Entity parsePlayerByName(String name) throws PlayerNotFoundException { - EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(name); - if (player != null) { return player; } - throw new PlayerNotFoundException("lookingglass.commands.generic.player.notfound", new Object[] { name }); - } - - public static float parseFloat(ICommandSender par0ICommandSender, String par1Str) { - try { - return Float.parseFloat(par1Str); - } catch (NumberFormatException numberformatexception) { - throw new NumberInvalidException("commands.generic.num.invalid", new Object[] { par1Str }); - } - } -} +package com.xcompwiz.lookingglass.command; + +import java.util.Random; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.NumberInvalidException; +import net.minecraft.command.PlayerNotFoundException; +import net.minecraft.command.PlayerSelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +public abstract class CommandBaseAdv extends CommandBase { + + public void sendToAdmins(ICommandSender agent, String text, Object[] objects) { + func_152373_a(agent, this, text, objects); + } + + public static EntityPlayerMP getTargetPlayer(ICommandSender sender, String target) { + EntityPlayerMP entityplayermp = PlayerSelector.matchOnePlayer(sender, target); + + if (entityplayermp == null) { + entityplayermp = MinecraftServer.getServer() + .getConfigurationManager() + .func_152612_a(target); + } + if (entityplayermp == null) { + throw new PlayerNotFoundException(); + } + return entityplayermp; + } + + public static Integer getSenderDimension(ICommandSender sender) { + World w = sender.getEntityWorld(); + if (w == null) + throw new CommandException("You must specify a dimension to use this command from the commandline"); + return w.provider.dimensionId; + } + + /** + * Returns the given ICommandSender as a EntityPlayer or throw an exception. + */ + public static TileEntity getCommandSenderAsTileEntity(ICommandSender sender) { + try { + World world = sender.getEntityWorld(); + ChunkCoordinates coords = sender.getPlayerCoordinates(); + return world.getTileEntity(coords.posX, coords.posY, coords.posZ); + } catch (Exception e) { + throw new CommandException("Could not get tile entity"); + } + } + + public static double handleRelativeNumber(ICommandSender sender, double origin, String arg) { + return handleRelativeNumber(sender, origin, arg, -30000000, 30000000); + } + + public static double handleRelativeNumber(ICommandSender par1ICommandSender, double origin, String arg, int min, + int max) { + boolean relative = arg.startsWith("~"); + boolean random = arg.startsWith("?"); + if (random) relative = true; + double d1 = relative ? origin : 0.0D; + + if (!relative || arg.length() > 1) { + boolean flag1 = arg.contains("."); + + if (relative) { + arg = arg.substring(1); + } + + double d2 = parseDouble(par1ICommandSender, arg); + if (random) { + Random rand = new Random(); + d1 += (rand.nextDouble() * 2 - 1) * d2; + } else { + d1 += d2; + } + + if (!flag1 && !relative) { + d1 += 0.5D; + } + } + + if (min != 0 || max != 0) { + if (d1 < min) { + throw new NumberInvalidException( + "commands.generic.double.tooSmall", + new Object[] { Double.valueOf(d1), Integer.valueOf(min) }); + } + + if (d1 > max) { + throw new NumberInvalidException( + "commands.generic.double.tooBig", + new Object[] { Double.valueOf(d1), Integer.valueOf(max) }); + } + } + + return d1; + } + + /** + * Returns the player for a username as an Entity or throws an exception. + */ + public static Entity parsePlayerByName(String name) throws PlayerNotFoundException { + EntityPlayerMP player = MinecraftServer.getServer() + .getConfigurationManager() + .func_152612_a(name); + if (player != null) { + return player; + } + throw new PlayerNotFoundException("lookingglass.commands.generic.player.notfound", new Object[] { name }); + } + + public static float parseFloat(ICommandSender par0ICommandSender, String par1Str) { + try { + return Float.parseFloat(par1Str); + } catch (NumberFormatException numberformatexception) { + throw new NumberInvalidException("commands.generic.num.invalid", new Object[] { par1Str }); + } + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/command/CommandCreateView.java b/src/main/java/com/xcompwiz/lookingglass/command/CommandCreateView.java index f38fc65..fa92621 100644 --- a/src/main/java/com/xcompwiz/lookingglass/command/CommandCreateView.java +++ b/src/main/java/com/xcompwiz/lookingglass/command/CommandCreateView.java @@ -1,63 +1,65 @@ -package com.xcompwiz.lookingglass.command; - -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.command.WrongUsageException; -import net.minecraft.entity.Entity; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.DimensionManager; - -import com.xcompwiz.lookingglass.entity.EntityPortal; - -public class CommandCreateView extends CommandBaseAdv { - @Override - public String getCommandName() { - return "lg-viewdim"; - } - - @Override - public String getCommandUsage(ICommandSender par1ICommandSender) { - return "/" + this.getCommandName() + " targetdim [dim, x, y, z]"; - } - - @Override - public void processCommand(ICommandSender agent, String[] args) { - int targetdim = 0; - Integer dim = null; - ChunkCoordinates coords = null; - - //XXX: Set Coordinates of view location? - if (args.length > 0) { - String sTarget = args[0]; - targetdim = parseInt(agent, sTarget); - } else { - throw new WrongUsageException("Could not parse command."); - } - if (args.length > 4) { - dim = parseInt(agent, args[1]); - Entity caller = null; - try { - caller = getCommandSenderAsPlayer(agent); - } catch (Exception e) { - } - int x = (int) handleRelativeNumber(agent, (caller != null ? caller.posX : 0), args[2]); - int y = (int) handleRelativeNumber(agent, (caller != null ? caller.posY : 0), args[3], 0, 0); - int z = (int) handleRelativeNumber(agent, (caller != null ? caller.posZ : 0), args[4]); - coords = new ChunkCoordinates(x, y, z); - } - if (coords == null) { - dim = getSenderDimension(agent); - coords = agent.getPlayerCoordinates(); - } - if (coords == null) throw new WrongUsageException("Location Required"); - - WorldServer worldObj = DimensionManager.getWorld(dim); - if (worldObj == null) { throw new CommandException("The target world is not loaded"); } - - EntityPortal portal = new EntityPortal(worldObj, targetdim, coords.posX, coords.posY, coords.posZ); - worldObj.spawnEntityInWorld(portal); - - sendToAdmins(agent, "A window to dimension " + targetdim + " has been created.", new Object[0]); - } -} +package com.xcompwiz.lookingglass.command; + +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.entity.Entity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.DimensionManager; + +import com.xcompwiz.lookingglass.entity.EntityPortal; + +public class CommandCreateView extends CommandBaseAdv { + + @Override + public String getCommandName() { + return "lg-viewdim"; + } + + @Override + public String getCommandUsage(ICommandSender par1ICommandSender) { + return "/" + this.getCommandName() + " targetdim [dim, x, y, z]"; + } + + @Override + public void processCommand(ICommandSender agent, String[] args) { + int targetdim = 0; + Integer dim = null; + ChunkCoordinates coords = null; + + // XXX: Set Coordinates of view location? + if (args.length > 0) { + String sTarget = args[0]; + targetdim = parseInt(agent, sTarget); + } else { + throw new WrongUsageException("Could not parse command."); + } + if (args.length > 4) { + dim = parseInt(agent, args[1]); + Entity caller = null; + try { + caller = getCommandSenderAsPlayer(agent); + } catch (Exception e) {} + int x = (int) handleRelativeNumber(agent, (caller != null ? caller.posX : 0), args[2]); + int y = (int) handleRelativeNumber(agent, (caller != null ? caller.posY : 0), args[3], 0, 0); + int z = (int) handleRelativeNumber(agent, (caller != null ? caller.posZ : 0), args[4]); + coords = new ChunkCoordinates(x, y, z); + } + if (coords == null) { + dim = getSenderDimension(agent); + coords = agent.getPlayerCoordinates(); + } + if (coords == null) throw new WrongUsageException("Location Required"); + + WorldServer worldObj = DimensionManager.getWorld(dim); + if (worldObj == null) { + throw new CommandException("The target world is not loaded"); + } + + EntityPortal portal = new EntityPortal(worldObj, targetdim, coords.posX, coords.posY, coords.posZ); + worldObj.spawnEntityInWorld(portal); + + sendToAdmins(agent, "A window to dimension " + targetdim + " has been created.", new Object[0]); + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/core/CommonProxy.java b/src/main/java/com/xcompwiz/lookingglass/core/CommonProxy.java index 5a0d984..306d38f 100644 --- a/src/main/java/com/xcompwiz/lookingglass/core/CommonProxy.java +++ b/src/main/java/com/xcompwiz/lookingglass/core/CommonProxy.java @@ -1,5 +1,6 @@ -package com.xcompwiz.lookingglass.core; - -public class CommonProxy { - public void init() {} -} +package com.xcompwiz.lookingglass.core; + +public class CommonProxy { + + public void init() {} +} diff --git a/src/main/java/com/xcompwiz/lookingglass/core/LookingGlassForgeEventHandler.java b/src/main/java/com/xcompwiz/lookingglass/core/LookingGlassForgeEventHandler.java index 35ce34e..9e50e36 100644 --- a/src/main/java/com/xcompwiz/lookingglass/core/LookingGlassForgeEventHandler.java +++ b/src/main/java/com/xcompwiz/lookingglass/core/LookingGlassForgeEventHandler.java @@ -15,29 +15,31 @@ public class LookingGlassForgeEventHandler { - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onChunkUnload(ChunkEvent.Unload event) { - if (!event.world.isRemote) return; - Chunk chunk = event.getChunk(); - // When we unload a chunk client side, we want to make sure that any view entities clean up. Not strictly necessary, but a good practice. - // I don't trust vanilla to unload entity references quickly/correctly/completely. - for (int i = 0; i < chunk.entityLists.length; ++i) { - List list = chunk.entityLists[i]; - for (Entity entity : list) { - if (entity instanceof EntityPortal) ((EntityPortal) entity).releaseActiveView(); - } - } - } + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onChunkUnload(ChunkEvent.Unload event) { + if (!event.world.isRemote) return; + Chunk chunk = event.getChunk(); + // When we unload a chunk client side, we want to make sure that any view entities clean up. Not strictly + // necessary, but a good practice. + // I don't trust vanilla to unload entity references quickly/correctly/completely. + for (int i = 0; i < chunk.entityLists.length; ++i) { + List list = chunk.entityLists[i]; + for (Entity entity : list) { + if (entity instanceof EntityPortal) ((EntityPortal) entity).releaseActiveView(); + } + } + } - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onWorldUnload(WorldEvent.Unload event) { - if (!event.world.isRemote) return; - // When we unload a world client side, we want to make sure that any view entities clean up. Not strictly necessary, but a good practice. - // I don't trust vanilla to unload entity references quickly/correctly/completely. - for (Object entity : event.world.loadedEntityList) { - if (entity instanceof EntityPortal) ((EntityPortal) entity).releaseActiveView(); - } - } + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onWorldUnload(WorldEvent.Unload event) { + if (!event.world.isRemote) return; + // When we unload a world client side, we want to make sure that any view entities clean up. Not strictly + // necessary, but a good practice. + // I don't trust vanilla to unload entity references quickly/correctly/completely. + for (Object entity : event.world.loadedEntityList) { + if (entity instanceof EntityPortal) ((EntityPortal) entity).releaseActiveView(); + } + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/entity/EntityCamera.java b/src/main/java/com/xcompwiz/lookingglass/entity/EntityCamera.java index bb1b2af..05b4125 100644 --- a/src/main/java/com/xcompwiz/lookingglass/entity/EntityCamera.java +++ b/src/main/java/com/xcompwiz/lookingglass/entity/EntityCamera.java @@ -20,379 +20,388 @@ /** * Our camera entity. This is made a player so that we can replace the player client-side when doing rendering. - * At the bottom of the class we create a bunch of method stubs to override higher level logic, so that our "player" doesn't act like one. + * At the bottom of the class we create a bunch of method stubs to override higher level logic, so that our "player" + * doesn't act like one. */ public class EntityCamera extends EntityClientPlayerMP { - private ICameraAnimator animator; - private ChunkCoordinates target; - private boolean defaultSpawn = false; - - private float fovmultiplier = 1; - - public EntityCamera(World worldObj, ChunkCoordinates spawn) { - super(Minecraft.getMinecraft(), worldObj, Minecraft.getMinecraft().getSession(), null, null); - this.target = spawn; - if (target == null) { - defaultSpawn = true; - ChunkCoordinates cc = worldObj.provider.getSpawnPoint(); - int y = updateTargetPosition(cc); - target = new ChunkCoordinates(cc.posX, y, cc.posZ); - } - this.setPositionAndUpdate(target.posX, target.posY, target.posZ); - } - - public void setAnimator(ICameraAnimator animator) { - this.animator = animator; - if (this.animator != null) this.animator.setTarget(target); - } - - @Override - protected void applyEntityAttributes() { - super.applyEntityAttributes(); - getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(1); - getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.0D); - } - - public void updateWorldSpawn(ChunkCoordinates cc) { - if (defaultSpawn) { - int y = updateTargetPosition(cc); - target = new ChunkCoordinates(cc.posX, y, cc.posZ); - this.setPositionAndUpdate(target.posX, target.posY, target.posZ); - if (animator != null) animator.setTarget(cc); - this.refreshAnimator(); - } - } - - private int updateTargetPosition(ChunkCoordinates target) { - int x = target.posX; - int y = target.posY; - int z = target.posZ; - if (!this.worldObj.getChunkFromBlockCoords(x, z).isEmpty()) { - if (this.worldObj.getBlock(x, y, z).getBlocksMovement(this.worldObj, x, y, z)) { - while (y > 0 && this.worldObj.getBlock(x, --y, z).getBlocksMovement(this.worldObj, x, y, z)) - ; - if (y == 0) y = target.posY; - else ++y; - } else { - while (y < 256 && !this.worldObj.getBlock(x, ++y, z).getBlocksMovement(this.worldObj, x, y, z)) - ; - if (y == 256) y = target.posY; - } - return y; - } - return target.posY; - } - - public void refreshAnimator() { - if (this.animator != null) animator.refresh(); - } - - public void tick(long dt) { - if (this.animator != null) animator.update(dt); - } - - @Override - public float getFOVMultiplier() { - return fovmultiplier; - } - - public void setFOVMult(float fovmult) { - fovmultiplier = fovmult; - } - - /* - * POSSIBLY UNNECESSARY CODE TO PREVENT OTHER CODE FROM RUNNING - */ - @Override - public void onEntityUpdate() {} - - @Override - public void onLivingUpdate() {} - - @Override - public void onUpdate() {} - - @Override - protected int getExperiencePoints(EntityPlayer par1EntityPlayer) { - return 0; - } - - @Override - protected boolean isAIEnabled() { - return false; - } - - @Override - public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} - - @Override - public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {} - - @Override - public void setAIMoveSpeed(float par1) {} - - @Override - protected void updateAITasks() {} - - @Override - public ItemStack getHeldItem() { - return null; - } - - @Override - public ItemStack getEquipmentInSlot(int par1) { - return null; - } - - @Override - public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) {} - - @Override - public ItemStack[] getLastActiveItems() { - return null; - } - - @Override - protected void dropEquipment(boolean par1, int par2) {} - - @Override - protected void fall(float par1) {} - - @Override - protected void updateFallState(double par1, boolean par3) {} - - @Override - protected void onDeathUpdate() { - this.setDead(); - } - - @Override - public EntityLivingBase getAITarget() { - return null; - } - - @Override - public void setRevengeTarget(EntityLivingBase par1) {} - - @Override - public EntityLivingBase getLastAttacker() { - return null; - } + private ICameraAnimator animator; + private ChunkCoordinates target; + private boolean defaultSpawn = false; + + private float fovmultiplier = 1; + + public EntityCamera(World worldObj, ChunkCoordinates spawn) { + super( + Minecraft.getMinecraft(), + worldObj, + Minecraft.getMinecraft() + .getSession(), + null, + null); + this.target = spawn; + if (target == null) { + defaultSpawn = true; + ChunkCoordinates cc = worldObj.provider.getSpawnPoint(); + int y = updateTargetPosition(cc); + target = new ChunkCoordinates(cc.posX, y, cc.posZ); + } + this.setPositionAndUpdate(target.posX, target.posY, target.posZ); + } + + public void setAnimator(ICameraAnimator animator) { + this.animator = animator; + if (this.animator != null) this.animator.setTarget(target); + } + + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(1); + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.0D); + } + + public void updateWorldSpawn(ChunkCoordinates cc) { + if (defaultSpawn) { + int y = updateTargetPosition(cc); + target = new ChunkCoordinates(cc.posX, y, cc.posZ); + this.setPositionAndUpdate(target.posX, target.posY, target.posZ); + if (animator != null) animator.setTarget(cc); + this.refreshAnimator(); + } + } + + private int updateTargetPosition(ChunkCoordinates target) { + int x = target.posX; + int y = target.posY; + int z = target.posZ; + if (!this.worldObj.getChunkFromBlockCoords(x, z) + .isEmpty()) { + if (this.worldObj.getBlock(x, y, z) + .getBlocksMovement(this.worldObj, x, y, z)) { + while (y > 0 && this.worldObj.getBlock(x, --y, z) + .getBlocksMovement(this.worldObj, x, y, z)); + if (y == 0) y = target.posY; + else++y; + } else { + while (y < 256 && !this.worldObj.getBlock(x, ++y, z) + .getBlocksMovement(this.worldObj, x, y, z)); + if (y == 256) y = target.posY; + } + return y; + } + return target.posY; + } + + public void refreshAnimator() { + if (this.animator != null) animator.refresh(); + } + + public void tick(long dt) { + if (this.animator != null) animator.update(dt); + } + + @Override + public float getFOVMultiplier() { + return fovmultiplier; + } + + public void setFOVMult(float fovmult) { + fovmultiplier = fovmult; + } + + /* + * POSSIBLY UNNECESSARY CODE TO PREVENT OTHER CODE FROM RUNNING + */ + @Override + public void onEntityUpdate() {} + + @Override + public void onLivingUpdate() {} + + @Override + public void onUpdate() {} + + @Override + protected int getExperiencePoints(EntityPlayer par1EntityPlayer) { + return 0; + } + + @Override + protected boolean isAIEnabled() { + return false; + } + + @Override + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} + + @Override + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {} + + @Override + public void setAIMoveSpeed(float par1) {} + + @Override + protected void updateAITasks() {} + + @Override + public ItemStack getHeldItem() { + return null; + } + + @Override + public ItemStack getEquipmentInSlot(int par1) { + return null; + } + + @Override + public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) {} + + @Override + public ItemStack[] getLastActiveItems() { + return null; + } + + @Override + protected void dropEquipment(boolean par1, int par2) {} + + @Override + protected void fall(float par1) {} + + @Override + protected void updateFallState(double par1, boolean par3) {} + + @Override + protected void onDeathUpdate() { + this.setDead(); + } + + @Override + public EntityLivingBase getAITarget() { + return null; + } + + @Override + public void setRevengeTarget(EntityLivingBase par1) {} + + @Override + public EntityLivingBase getLastAttacker() { + return null; + } - @Override - public void setLastAttacker(Entity par1) {} + @Override + public void setLastAttacker(Entity par1) {} - @Override - protected void updatePotionEffects() {} + @Override + protected void updatePotionEffects() {} - @Override - public void clearActivePotions() {} + @Override + public void clearActivePotions() {} - @Override - public boolean isPotionActive(int par1) { - return false; - } + @Override + public boolean isPotionActive(int par1) { + return false; + } - @Override - public boolean isPotionActive(Potion par1) { - return false; - } + @Override + public boolean isPotionActive(Potion par1) { + return false; + } - @Override - public PotionEffect getActivePotionEffect(Potion par1) { - return null; - } + @Override + public PotionEffect getActivePotionEffect(Potion par1) { + return null; + } - @Override - public void addPotionEffect(PotionEffect par1) {} + @Override + public void addPotionEffect(PotionEffect par1) {} - @Override - public boolean isPotionApplicable(PotionEffect par1) { - return false; - } + @Override + public boolean isPotionApplicable(PotionEffect par1) { + return false; + } - @Override - public boolean isEntityUndead() { - return false; - } + @Override + public boolean isEntityUndead() { + return false; + } - @Override - public void removePotionEffectClient(int par1) {} + @Override + public void removePotionEffectClient(int par1) {} - @Override - public void removePotionEffect(int par1) {} + @Override + public void removePotionEffect(int par1) {} - @Override - protected void onNewPotionEffect(PotionEffect par1) {} + @Override + protected void onNewPotionEffect(PotionEffect par1) {} - @Override - protected void onChangedPotionEffect(PotionEffect par1, boolean par2) {} + @Override + protected void onChangedPotionEffect(PotionEffect par1, boolean par2) {} - @Override - protected void onFinishedPotionEffect(PotionEffect par1) {} + @Override + protected void onFinishedPotionEffect(PotionEffect par1) {} - @Override - public void heal(float par1) {} + @Override + public void heal(float par1) {} - @Override - public boolean attackEntityFrom(DamageSource par1, float par2) { - return false; - } + @Override + public boolean attackEntityFrom(DamageSource par1, float par2) { + return false; + } - @Override - public void renderBrokenItemStack(ItemStack par1) {} + @Override + public void renderBrokenItemStack(ItemStack par1) {} - @Override - public void onDeath(DamageSource par1) { - this.worldObj.setEntityState(this, (byte) 3); - } + @Override + public void onDeath(DamageSource par1) { + this.worldObj.setEntityState(this, (byte) 3); + } - @Override - public void knockBack(Entity par1Entity, float par2, double par3, double par5) {} + @Override + public void knockBack(Entity par1Entity, float par2, double par3, double par5) {} - @Override - public boolean isOnLadder() { - return false; - } + @Override + public boolean isOnLadder() { + return false; + } - @Override - public int getTotalArmorValue() { - return 0; - } + @Override + public int getTotalArmorValue() { + return 0; + } - @Override - protected float applyArmorCalculations(DamageSource par1DamageSource, float par2) { - return par2; - } + @Override + protected float applyArmorCalculations(DamageSource par1DamageSource, float par2) { + return par2; + } - @Override - protected float applyPotionDamageCalculations(DamageSource par1DamageSource, float par2) { - return par2; - } + @Override + protected float applyPotionDamageCalculations(DamageSource par1DamageSource, float par2) { + return par2; + } - @Override - protected void damageEntity(DamageSource par1, float par2) {} + @Override + protected void damageEntity(DamageSource par1, float par2) {} - @Override - public void swingItem() {} + @Override + public void swingItem() {} - @Override - protected void updateArmSwingProgress() {} + @Override + protected void updateArmSwingProgress() {} - @Override - public void setSprinting(boolean par1) {} + @Override + public void setSprinting(boolean par1) {} - @Override - protected float getSoundVolume() { - return 0F; - } + @Override + protected float getSoundVolume() { + return 0F; + } - @Override - public void dismountEntity(Entity par1Entity) {} + @Override + public void dismountEntity(Entity par1Entity) {} - @Override - public void moveEntityWithHeading(float par1, float par2) {} + @Override + public void moveEntityWithHeading(float par1, float par2) {} - @Override - public void updateRidden() {} + @Override + public void updateRidden() {} - @Override - public void setJumping(boolean par1) {} - - @Override - public void onItemPickup(Entity par1Entity, int par2) {} + @Override + public void setJumping(boolean par1) {} + + @Override + public void onItemPickup(Entity par1Entity, int par2) {} - @Override - public boolean canEntityBeSeen(Entity par1Entity) { - return false; - } - - @Override - public boolean canBeCollidedWith() { - return false; - } + @Override + public boolean canEntityBeSeen(Entity par1Entity) { + return false; + } + + @Override + public boolean canBeCollidedWith() { + return false; + } - @Override - public boolean canBePushed() { - return false; - } + @Override + public boolean canBePushed() { + return false; + } - @Override - protected boolean canTriggerWalking() { - return false; - } + @Override + protected boolean canTriggerWalking() { + return false; + } - @Override - public boolean handleWaterMovement() { - return false; - } - - @Override - public boolean isInsideOfMaterial(Material par1Material) { - return false; - } - - @Override - public boolean handleLavaMovement() { - return false; - } - - @Override - public void moveFlying(float par1, float par2, float par3) {} - - @Override - public float getBrightness(float par1) { - return 0; - } - - @Override - public void applyEntityCollision(Entity par1Entity) {} - - @Override - public boolean isBurning() { - return false; - } - - @Override - public boolean isRiding() { - return false; - } - - @Override - public boolean isSneaking() { - return false; - } - - @Override - public boolean isInvisible() { - return true; - } + @Override + public boolean handleWaterMovement() { + return false; + } + + @Override + public boolean isInsideOfMaterial(Material par1Material) { + return false; + } + + @Override + public boolean handleLavaMovement() { + return false; + } + + @Override + public void moveFlying(float par1, float par2, float par3) {} + + @Override + public float getBrightness(float par1) { + return 0; + } + + @Override + public void applyEntityCollision(Entity par1Entity) {} + + @Override + public boolean isBurning() { + return false; + } + + @Override + public boolean isRiding() { + return false; + } + + @Override + public boolean isSneaking() { + return false; + } + + @Override + public boolean isInvisible() { + return true; + } - @Override - public void onStruckByLightning(EntityLightningBolt par1) {} - - @Override - public boolean isEntityInvulnerable() { - return true; - } + @Override + public void onStruckByLightning(EntityLightningBolt par1) {} + + @Override + public boolean isEntityInvulnerable() { + return true; + } - @Override - public void travelToDimension(int par1) {} - - @Override - public boolean shouldRenderInPass(int pass) { - return false; - } - - @Override - protected void collideWithEntity(Entity par1Entity) {} - - @Override - protected void collideWithNearbyEntities() {} - - @Override - public boolean doesEntityNotTriggerPressurePlate() { - return true; - } + @Override + public void travelToDimension(int par1) {} + + @Override + public boolean shouldRenderInPass(int pass) { + return false; + } + + @Override + protected void collideWithEntity(Entity par1Entity) {} + + @Override + protected void collideWithNearbyEntities() {} + + @Override + public boolean doesEntityNotTriggerPressurePlate() { + return true; + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/entity/EntityPortal.java b/src/main/java/com/xcompwiz/lookingglass/entity/EntityPortal.java index a17936d..9687251 100644 --- a/src/main/java/com/xcompwiz/lookingglass/entity/EntityPortal.java +++ b/src/main/java/com/xcompwiz/lookingglass/entity/EntityPortal.java @@ -1,105 +1,111 @@ -package com.xcompwiz.lookingglass.entity; - -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - -import com.xcompwiz.lookingglass.api.animator.CameraAnimatorPlayer; -import com.xcompwiz.lookingglass.api.view.IWorldView; -import com.xcompwiz.lookingglass.client.proxyworld.ProxyWorldManager; -import com.xcompwiz.lookingglass.client.proxyworld.WorldView; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * Despite it's name, this isn't so much a doorway or window as it is a moving picture. More Harry Potter's portraits than Portal's portals. (Man I wish the - * best example of portal rendering in games wasn't called Portal.... So hard to reference sanely.) - */ -public class EntityPortal extends Entity { - // We store the dimension ID we point at in the dataWatcher at this index. - private static final int targetID = 20; - - // How long the window has to live. Functions as a countdown timer. - private long lifetime = 1000L; - - @SideOnly(Side.CLIENT) - private IWorldView activeview; - - public EntityPortal(World world) { - super(world); - dataWatcher.addObject(targetID, Integer.valueOf(0)); - } - - public EntityPortal(World world, int targetdim, int posX, int posY, int posZ) { - this(world); - this.setTarget(targetdim); - this.setPosition(posX, posY, posZ); - } - - /** Puts the dim id target in the datawatcher. */ - private void setTarget(int targetdim) { - dataWatcher.updateObject(targetID, targetdim); - //XXX: Technically speaking, it might be wise to design this so that it can change targets, but that's not needed for this class. - // If it was, we'd have this function kill any active views when the target changed, causing it to open a new view for the new target. - } - - /** Gets the target dimension id */ - private int getTarget() { - return dataWatcher.getWatchableObjectInt(targetID); - } - - @Override - protected void entityInit() {} - - @Override - @SideOnly(Side.CLIENT) - public void setDead() { - super.setDead(); - releaseActiveView(); - } - - @Override - public void onUpdate() { - // Countdown to die - --lifetime; - if (lifetime <= 0) { - this.setDead(); - return; - } - super.onUpdate(); - } - - @SideOnly(Side.CLIENT) - public IWorldView getActiveView() { - if (!worldObj.isRemote) return null; - if (activeview == null) { - activeview = ProxyWorldManager.createWorldView(getTarget(), null, 160, 240); - if (activeview != null) { - // We set the player animator on our portrait. This makes the view move a little depending on how the user looks at it. Not quite a replacement for portal rendering, but cool looking anyway. - activeview.setAnimator(new CameraAnimatorPlayer(activeview.getCamera(), this, Minecraft.getMinecraft().thePlayer)); - } - } - return activeview; - } - - @SideOnly(Side.CLIENT) - public void releaseActiveView() { - if (activeview != null) ProxyWorldManager.destroyWorldView((WorldView) activeview); - activeview = null; - } - - @Override - protected void readEntityFromNBT(NBTTagCompound nbt) { - setTarget(nbt.getInteger("Dimension")); - lifetime = nbt.getLong("lifetime"); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbt) { - nbt.setInteger("Dimension", getTarget()); - nbt.setLong("lifetime", lifetime); - } - -} +package com.xcompwiz.lookingglass.entity; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +import com.xcompwiz.lookingglass.api.animator.CameraAnimatorPlayer; +import com.xcompwiz.lookingglass.api.view.IWorldView; +import com.xcompwiz.lookingglass.client.proxyworld.ProxyWorldManager; +import com.xcompwiz.lookingglass.client.proxyworld.WorldView; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Despite it's name, this isn't so much a doorway or window as it is a moving picture. More Harry Potter's portraits + * than Portal's portals. (Man I wish the + * best example of portal rendering in games wasn't called Portal.... So hard to reference sanely.) + */ +public class EntityPortal extends Entity { + + // We store the dimension ID we point at in the dataWatcher at this index. + private static final int targetID = 20; + + // How long the window has to live. Functions as a countdown timer. + private long lifetime = 1000L; + + @SideOnly(Side.CLIENT) + private IWorldView activeview; + + public EntityPortal(World world) { + super(world); + dataWatcher.addObject(targetID, Integer.valueOf(0)); + } + + public EntityPortal(World world, int targetdim, int posX, int posY, int posZ) { + this(world); + this.setTarget(targetdim); + this.setPosition(posX, posY, posZ); + } + + /** Puts the dim id target in the datawatcher. */ + private void setTarget(int targetdim) { + dataWatcher.updateObject(targetID, targetdim); + // XXX: Technically speaking, it might be wise to design this so that it can change targets, but that's not + // needed for this class. + // If it was, we'd have this function kill any active views when the target changed, causing it to open a new + // view for the new target. + } + + /** Gets the target dimension id */ + private int getTarget() { + return dataWatcher.getWatchableObjectInt(targetID); + } + + @Override + protected void entityInit() {} + + @Override + @SideOnly(Side.CLIENT) + public void setDead() { + super.setDead(); + releaseActiveView(); + } + + @Override + public void onUpdate() { + // Countdown to die + --lifetime; + if (lifetime <= 0) { + this.setDead(); + return; + } + super.onUpdate(); + } + + @SideOnly(Side.CLIENT) + public IWorldView getActiveView() { + if (!worldObj.isRemote) return null; + if (activeview == null) { + activeview = ProxyWorldManager.createWorldView(getTarget(), null, 160, 240); + if (activeview != null) { + // We set the player animator on our portrait. This makes the view move a little depending on how the + // user looks at it. Not quite a replacement for portal rendering, but cool looking anyway. + activeview.setAnimator( + new CameraAnimatorPlayer(activeview.getCamera(), this, Minecraft.getMinecraft().thePlayer)); + } + } + return activeview; + } + + @SideOnly(Side.CLIENT) + public void releaseActiveView() { + if (activeview != null) ProxyWorldManager.destroyWorldView((WorldView) activeview); + activeview = null; + } + + @Override + protected void readEntityFromNBT(NBTTagCompound nbt) { + setTarget(nbt.getInteger("Dimension")); + lifetime = nbt.getLong("lifetime"); + } + + @Override + protected void writeEntityToNBT(NBTTagCompound nbt) { + nbt.setInteger("Dimension", getTarget()); + nbt.setLong("lifetime", lifetime); + } + +} diff --git a/src/main/java/com/xcompwiz/lookingglass/imc/IMCAPIRegister.java b/src/main/java/com/xcompwiz/lookingglass/imc/IMCAPIRegister.java index 48b3a3b..0501c45 100644 --- a/src/main/java/com/xcompwiz/lookingglass/imc/IMCAPIRegister.java +++ b/src/main/java/com/xcompwiz/lookingglass/imc/IMCAPIRegister.java @@ -1,53 +1,58 @@ -package com.xcompwiz.lookingglass.imc; - -import java.lang.reflect.Method; - -import com.xcompwiz.lookingglass.api.APIInstanceProvider; -import com.xcompwiz.lookingglass.apiimpl.InternalAPI; -import com.xcompwiz.lookingglass.imc.IMCHandler.IMCProcessor; -import com.xcompwiz.lookingglass.log.LoggerUtils; - -import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; - -public class IMCAPIRegister implements IMCProcessor { - - @Override - public void process(IMCMessage message) { - if (!message.isStringMessage()) return; - LoggerUtils.info(String.format("Receiving API registration request from [%s] for method %s", message.getSender(), message.getStringValue())); - callbackRegistration(message.getStringValue(), message.getSender()); - } - - /** - * This handles the classpath and method location and calling for API IMC calls Based on some code from WAILA. - * @param method The method (prefixed by classname) to call - * @param modname The name of the mod which made the request - */ - public static void callbackRegistration(String method, String modname) { - String[] splitName = method.split("\\."); - String methodName = splitName[splitName.length - 1]; - String className = method.substring(0, method.length() - methodName.length() - 1); - - APIInstanceProvider providerinst = InternalAPI.getAPIProviderInstance(modname); - if (providerinst == null) { - LoggerUtils.error(String.format("Could not initialize API provider instance for %s", modname)); - return; - } - - LoggerUtils.info(String.format("Trying to call (reflection) %s %s", className, methodName)); - - try { - Class reflectClass = Class.forName(className); - Method reflectMethod = reflectClass.getDeclaredMethod(methodName, APIInstanceProvider.class); - reflectMethod.invoke(null, providerinst); - LoggerUtils.info(String.format("API provided to %s", modname)); - } catch (ClassNotFoundException e) { - LoggerUtils.error(String.format("Could not find class %s", className)); - } catch (NoSuchMethodException e) { - LoggerUtils.error(String.format("Could not find method %s", methodName)); - } catch (Exception e) { - LoggerUtils.error(String.format("Exception while calling the method %s.%s", className, methodName)); - e.printStackTrace(); - } - } -} +package com.xcompwiz.lookingglass.imc; + +import java.lang.reflect.Method; + +import com.xcompwiz.lookingglass.api.APIInstanceProvider; +import com.xcompwiz.lookingglass.apiimpl.InternalAPI; +import com.xcompwiz.lookingglass.imc.IMCHandler.IMCProcessor; +import com.xcompwiz.lookingglass.log.LoggerUtils; + +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + +public class IMCAPIRegister implements IMCProcessor { + + @Override + public void process(IMCMessage message) { + if (!message.isStringMessage()) return; + LoggerUtils.info( + String.format( + "Receiving API registration request from [%s] for method %s", + message.getSender(), + message.getStringValue())); + callbackRegistration(message.getStringValue(), message.getSender()); + } + + /** + * This handles the classpath and method location and calling for API IMC calls Based on some code from WAILA. + * + * @param method The method (prefixed by classname) to call + * @param modname The name of the mod which made the request + */ + public static void callbackRegistration(String method, String modname) { + String[] splitName = method.split("\\."); + String methodName = splitName[splitName.length - 1]; + String className = method.substring(0, method.length() - methodName.length() - 1); + + APIInstanceProvider providerinst = InternalAPI.getAPIProviderInstance(modname); + if (providerinst == null) { + LoggerUtils.error(String.format("Could not initialize API provider instance for %s", modname)); + return; + } + + LoggerUtils.info(String.format("Trying to call (reflection) %s %s", className, methodName)); + + try { + Class reflectClass = Class.forName(className); + Method reflectMethod = reflectClass.getDeclaredMethod(methodName, APIInstanceProvider.class); + reflectMethod.invoke(null, providerinst); + LoggerUtils.info(String.format("API provided to %s", modname)); + } catch (ClassNotFoundException e) { + LoggerUtils.error(String.format("Could not find class %s", className)); + } catch (NoSuchMethodException e) { + LoggerUtils.error(String.format("Could not find method %s", methodName)); + } catch (Exception e) { + LoggerUtils.error(String.format("Exception while calling the method %s.%s", className, methodName)); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/imc/IMCHandler.java b/src/main/java/com/xcompwiz/lookingglass/imc/IMCHandler.java index 3b5a8e8..1cd3fce 100644 --- a/src/main/java/com/xcompwiz/lookingglass/imc/IMCHandler.java +++ b/src/main/java/com/xcompwiz/lookingglass/imc/IMCHandler.java @@ -1,41 +1,43 @@ -package com.xcompwiz.lookingglass.imc; - -import java.util.HashMap; -import java.util.Map; - -import com.google.common.collect.ImmutableList; -import com.xcompwiz.lookingglass.log.LoggerUtils; - -import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; - -public class IMCHandler { - public interface IMCProcessor { - public void process(IMCMessage message); - } - - private static Map processors = new HashMap(); - - static { - registerProcessor("api", new IMCAPIRegister()); - } - - private static void registerProcessor(String key, IMCProcessor processor) { - processors.put(key.toLowerCase(), processor); - } - - public static void process(ImmutableList messages) { - for (IMCMessage message : messages) { - String key = message.key.toLowerCase(); - IMCProcessor process = processors.get(key); - if (process == null) { - LoggerUtils.error("IMC message '%s' from [%s] unrecognized", key, message.getSender()); - } - try { - process.process(message); - } catch (Exception e) { - LoggerUtils.error("Failed to process IMC message '%s' from [%s]", key, message.getSender()); - e.printStackTrace(); - } - } - } -} +package com.xcompwiz.lookingglass.imc; + +import java.util.HashMap; +import java.util.Map; + +import com.google.common.collect.ImmutableList; +import com.xcompwiz.lookingglass.log.LoggerUtils; + +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; + +public class IMCHandler { + + public interface IMCProcessor { + + public void process(IMCMessage message); + } + + private static Map processors = new HashMap(); + + static { + registerProcessor("api", new IMCAPIRegister()); + } + + private static void registerProcessor(String key, IMCProcessor processor) { + processors.put(key.toLowerCase(), processor); + } + + public static void process(ImmutableList messages) { + for (IMCMessage message : messages) { + String key = message.key.toLowerCase(); + IMCProcessor process = processors.get(key); + if (process == null) { + LoggerUtils.error("IMC message '%s' from [%s] unrecognized", key, message.getSender()); + } + try { + process.process(message); + } catch (Exception e) { + LoggerUtils.error("Failed to process IMC message '%s' from [%s]", key, message.getSender()); + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/log/LoggerUtils.java b/src/main/java/com/xcompwiz/lookingglass/log/LoggerUtils.java index 5d025dd..780feb0 100644 --- a/src/main/java/com/xcompwiz/lookingglass/log/LoggerUtils.java +++ b/src/main/java/com/xcompwiz/lookingglass/log/LoggerUtils.java @@ -1,49 +1,49 @@ -package com.xcompwiz.lookingglass.log; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.xcompwiz.lookingglass.LookingGlass; - -public final class LoggerUtils { - private static Logger log = null; - - /** - * Configure the logger - */ - private static void configureLogging() { - log = LogManager.getLogger(LookingGlass.MODID); - } - - public static void log(Level level, String message, Object... params) { - if (log == null) { - configureLogging(); - } - if (message == null) { - log.log(level, "Attempted to log null message."); - } else { - try { - message = String.format(message, params); - } catch (Exception e) { - } - log.log(level, message); - } - } - - public static void info(String message, Object... params) { - log(Level.INFO, message, params); - } - - public static void warn(String message, Object... params) { - log(Level.WARN, message, params); - } - - public static void error(String message, Object... params) { - log(Level.ERROR, message, params); - } - - public static void debug(String message, Object... params) { - //NOPE - } -} +package com.xcompwiz.lookingglass.log; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.xcompwiz.lookingglass.LookingGlass; + +public final class LoggerUtils { + + private static Logger log = null; + + /** + * Configure the logger + */ + private static void configureLogging() { + log = LogManager.getLogger(LookingGlass.MODID); + } + + public static void log(Level level, String message, Object... params) { + if (log == null) { + configureLogging(); + } + if (message == null) { + log.log(level, "Attempted to log null message."); + } else { + try { + message = String.format(message, params); + } catch (Exception e) {} + log.log(level, message); + } + } + + public static void info(String message, Object... params) { + log(Level.INFO, message, params); + } + + public static void warn(String message, Object... params) { + log(Level.WARN, message, params); + } + + public static void error(String message, Object... params) { + log(Level.ERROR, message, params); + } + + public static void debug(String message, Object... params) { + // NOPE + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/network/LookingGlassPacketManager.java b/src/main/java/com/xcompwiz/lookingglass/network/LookingGlassPacketManager.java index d8453c1..78f27c4 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/LookingGlassPacketManager.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/LookingGlassPacketManager.java @@ -1,87 +1,95 @@ -package com.xcompwiz.lookingglass.network; - -import io.netty.buffer.ByteBuf; - -import java.util.HashMap; - -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.network.NetworkManager; - -import com.xcompwiz.lookingglass.log.LoggerUtils; -import com.xcompwiz.lookingglass.network.packet.PacketHandlerBase; - -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.network.FMLEventChannel; -import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; -import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; -import cpw.mods.fml.common.network.internal.FMLProxyPacket; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class LookingGlassPacketManager { - - public static final String CHANNEL = "lookingglass"; - public static FMLEventChannel bus; - - private static HashMap packethandlers = new HashMap(); - private static HashMap, Byte> idmap = new HashMap, Byte>(); - - /** - * Register a new packet handler to the manager. We use pre-defined packet ids to avoid mismatched packet ids across client-server communications. - * @param handler The packet handler to register - * @param id The id to which the handler should be bound - */ - public static void registerPacketHandler(PacketHandlerBase handler, byte id) { - if (packethandlers.get(id) != null) { throw new RuntimeException("Multiple id registrations for packet type on " + CHANNEL + " channel"); } - packethandlers.put(id, handler); - idmap.put(handler.getClass(), id); - } - - public static byte getId(PacketHandlerBase handler) { - return getId(handler.getClass()); - } - - public static byte getId(Class handlerclass) { - if (!idmap.containsKey(handlerclass)) throw new RuntimeException("Attempted to get id for unregistered network message handler."); - return idmap.get(handlerclass); - } - - @SubscribeEvent - @SideOnly(Side.CLIENT) - public void onPacketData(ClientCustomPacketEvent event) { - FMLProxyPacket pkt = event.packet; - - onPacketData(event.manager, pkt, Minecraft.getMinecraft().thePlayer); - } - - @SubscribeEvent - public void onPacketData(ServerCustomPacketEvent event) { - FMLProxyPacket pkt = event.packet; - - onPacketData(event.manager, pkt, ((NetHandlerPlayServer) event.handler).playerEntity); - } - - public void onPacketData(NetworkManager manager, FMLProxyPacket packet, EntityPlayer player) { - try { - if (packet == null || packet.payload() == null) { throw new RuntimeException("Empty packet sent to " + CHANNEL + " channel"); } - ByteBuf data = packet.payload(); - byte type = data.readByte(); - - try { - PacketHandlerBase handler = packethandlers.get(type); - if (handler == null) { throw new RuntimeException("Unrecognized packet sent to " + CHANNEL + " channel"); } - handler.handle(data, player); - } catch (Exception e) { - LoggerUtils.warn("PacketHandler: Failed to handle packet type " + type); - LoggerUtils.warn(e.toString()); - e.printStackTrace(); - } - } catch (Exception e) { - LoggerUtils.warn("PacketHandler: Failed to read packet"); - LoggerUtils.warn(e.toString()); - e.printStackTrace(); - } - } -} +package com.xcompwiz.lookingglass.network; + +import java.util.HashMap; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.network.NetworkManager; + +import com.xcompwiz.lookingglass.log.LoggerUtils; +import com.xcompwiz.lookingglass.network.packet.PacketHandlerBase; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.FMLEventChannel; +import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; +import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; + +public class LookingGlassPacketManager { + + public static final String CHANNEL = "lookingglass"; + public static FMLEventChannel bus; + + private static HashMap packethandlers = new HashMap(); + private static HashMap, Byte> idmap = new HashMap, Byte>(); + + /** + * Register a new packet handler to the manager. We use pre-defined packet ids to avoid mismatched packet ids across + * client-server communications. + * + * @param handler The packet handler to register + * @param id The id to which the handler should be bound + */ + public static void registerPacketHandler(PacketHandlerBase handler, byte id) { + if (packethandlers.get(id) != null) { + throw new RuntimeException("Multiple id registrations for packet type on " + CHANNEL + " channel"); + } + packethandlers.put(id, handler); + idmap.put(handler.getClass(), id); + } + + public static byte getId(PacketHandlerBase handler) { + return getId(handler.getClass()); + } + + public static byte getId(Class handlerclass) { + if (!idmap.containsKey(handlerclass)) + throw new RuntimeException("Attempted to get id for unregistered network message handler."); + return idmap.get(handlerclass); + } + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void onPacketData(ClientCustomPacketEvent event) { + FMLProxyPacket pkt = event.packet; + + onPacketData(event.manager, pkt, Minecraft.getMinecraft().thePlayer); + } + + @SubscribeEvent + public void onPacketData(ServerCustomPacketEvent event) { + FMLProxyPacket pkt = event.packet; + + onPacketData(event.manager, pkt, ((NetHandlerPlayServer) event.handler).playerEntity); + } + + public void onPacketData(NetworkManager manager, FMLProxyPacket packet, EntityPlayer player) { + try { + if (packet == null || packet.payload() == null) { + throw new RuntimeException("Empty packet sent to " + CHANNEL + " channel"); + } + ByteBuf data = packet.payload(); + byte type = data.readByte(); + + try { + PacketHandlerBase handler = packethandlers.get(type); + if (handler == null) { + throw new RuntimeException("Unrecognized packet sent to " + CHANNEL + " channel"); + } + handler.handle(data, player); + } catch (Exception e) { + LoggerUtils.warn("PacketHandler: Failed to handle packet type " + type); + LoggerUtils.warn(e.toString()); + e.printStackTrace(); + } + } catch (Exception e) { + LoggerUtils.warn("PacketHandler: Failed to read packet"); + LoggerUtils.warn(e.toString()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/network/PacketHolder.java b/src/main/java/com/xcompwiz/lookingglass/network/PacketHolder.java index d69a451..12b23ec 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/PacketHolder.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/PacketHolder.java @@ -2,6 +2,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; + import cpw.mods.fml.common.network.internal.FMLProxyPacket; /** @@ -9,23 +10,25 @@ */ // TODO: This class doesn't need to exist, it's just a (Player, Packet) tuple public class PacketHolder { - EntityPlayer player; - FMLProxyPacket packet; - public PacketHolder(EntityPlayer player, FMLProxyPacket packet) { - this.player = player; - this.packet = packet; - } + EntityPlayer player; + FMLProxyPacket packet; + + public PacketHolder(EntityPlayer player, FMLProxyPacket packet) { + this.player = player; + this.packet = packet; + } - public boolean belongsToPlayer(EntityPlayer p) { - return player.equals(p); - } + public boolean belongsToPlayer(EntityPlayer p) { + return player.equals(p); + } - public int sendPacket() { - if (packet != null) { - LookingGlassPacketManager.bus.sendTo(packet, (EntityPlayerMP) player); - return packet.payload().writerIndex(); - } - return 0; - } + public int sendPacket() { + if (packet != null) { + LookingGlassPacketManager.bus.sendTo(packet, (EntityPlayerMP) player); + return packet.payload() + .writerIndex(); + } + return 0; + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/network/ServerPacketDispatcher.java b/src/main/java/com/xcompwiz/lookingglass/network/ServerPacketDispatcher.java index 971736c..7516364 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/ServerPacketDispatcher.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/ServerPacketDispatcher.java @@ -10,84 +10,86 @@ import cpw.mods.fml.common.network.internal.FMLProxyPacket; /** - * This class is a variant o nthe vanilla server packet dispatcher. We use it so that we can send data to cleitns in a limited (throttled) manner. This allows + * This class is a variant o nthe vanilla server packet dispatcher. We use it so that we can send data to cleitns in a + * limited (throttled) manner. This allows * server admins to limit how much bandwidth LookingGlass consumes on a server. */ public class ServerPacketDispatcher extends Thread { - private static ServerPacketDispatcher instance; + private static ServerPacketDispatcher instance; - private List packets; - private boolean isRunning = true; + private List packets; + private boolean isRunning = true; - private ServerPacketDispatcher() { - packets = new LinkedList(); - } + private ServerPacketDispatcher() { + packets = new LinkedList(); + } - public static ServerPacketDispatcher getInstance() { - if (instance == null) instance = new ServerPacketDispatcher(); - return instance; - } + public static ServerPacketDispatcher getInstance() { + if (instance == null) instance = new ServerPacketDispatcher(); + return instance; + } - public static void shutdown() { - if (instance != null) instance.halt(); - instance = null; - } + public static void shutdown() { + if (instance != null) instance.halt(); + instance = null; + } - public void addPacket(EntityPlayer player, FMLProxyPacket packet) { - synchronized (this) { - packets.add(new PacketHolder(player, packet)); - this.notify(); - } - } + public void addPacket(EntityPlayer player, FMLProxyPacket packet) { + synchronized (this) { + packets.add(new PacketHolder(player, packet)); + this.notify(); + } + } - public void removeAllPacketsOf(EntityPlayer player) { - synchronized (this) { - for (int j = 0; j < packets.size(); ++j) { - if (packets.get(j).belongsToPlayer(player)) { - packets.remove(--j); - } - } - } - } + public void removeAllPacketsOf(EntityPlayer player) { + synchronized (this) { + for (int j = 0; j < packets.size(); ++j) { + if (packets.get(j) + .belongsToPlayer(player)) { + packets.remove(--j); + } + } + } + } - public void tick() { - int byteLimit = ModConfigs.dataRate; - for (int bytes = 0; bytes < byteLimit && !packets.isEmpty();) { - PacketHolder p = packets.get(0); - bytes += p.sendPacket(); - packets.remove(0); - } - } + public void tick() { + int byteLimit = ModConfigs.dataRate; + for (int bytes = 0; bytes < byteLimit && !packets.isEmpty();) { + PacketHolder p = packets.get(0); + bytes += p.sendPacket(); + packets.remove(0); + } + } - public void halt() { - synchronized (this) { - isRunning = false; - packets.clear(); - } - } + public void halt() { + synchronized (this) { + isRunning = false; + packets.clear(); + } + } - @Override - public void run() { - while (isRunning) { - if (packets.size() > 0) { - try { - synchronized (this) { - tick(); - this.wait(20); - } - } catch (InterruptedException e) { - e.printStackTrace(); - } - } else { - try { - synchronized (this) { - this.wait(1000); - } - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } + @Override + public void run() { + while (isRunning) { + if (packets.size() > 0) { + try { + synchronized (this) { + tick(); + this.wait(20); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + } else { + try { + synchronized (this) { + this.wait(1000); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketChunkInfo.java b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketChunkInfo.java index 40aec1e..34bbc3d 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketChunkInfo.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketChunkInfo.java @@ -1,7 +1,5 @@ package com.xcompwiz.lookingglass.network.packet; -import io.netty.buffer.ByteBuf; - import java.util.concurrent.Semaphore; import java.util.zip.DataFormatException; import java.util.zip.Deflater; @@ -22,237 +20,258 @@ import com.xcompwiz.lookingglass.network.LookingGlassPacketManager; import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import io.netty.buffer.ByteBuf; /** * Based on code from Ken Butler/shadowking97 */ public class PacketChunkInfo extends PacketHandlerBase { - private static byte[] inflatearray; - private static byte[] dataarray; - private static Semaphore deflateGate = new Semaphore(1); - - private static int deflate(byte[] chunkData, byte[] compressedChunkData) { - Deflater deflater = new Deflater(-1); - if (compressedChunkData == null) return 0; - int bytesize = 0; - try { - deflater.setInput(chunkData, 0, chunkData.length); - deflater.finish(); - bytesize = deflater.deflate(compressedChunkData); - } finally { - deflater.end(); - } - return bytesize; - } - - public static FMLProxyPacket createPacket(Chunk chunk, boolean includeinit, int subid, int dim) { - int xPos = chunk.xPosition; - int zPos = chunk.zPosition; - Extracted extracted = getMapChunkData(chunk, includeinit, subid); - int yMSBPos = extracted.field_150281_c; - int yPos = extracted.field_150280_b; - byte[] chunkData = extracted.field_150282_a; - - deflateGate.acquireUninterruptibly(); - byte[] compressedChunkData = new byte[chunkData.length]; - int len = deflate(chunkData, compressedChunkData); - deflateGate.release(); - - // This line may look like black magic (and, well, it is), but it's actually just returning a class reference for this class. Copy-paste safe. - ByteBuf data = PacketHandlerBase.createDataBuffer((Class) new Object() {}.getClass().getEnclosingClass()); - - data.writeInt(dim); - data.writeInt(xPos); - data.writeInt(zPos); - data.writeBoolean(includeinit); - data.writeShort((short) (yPos & 65535)); - data.writeShort((short) (yMSBPos & 65535)); - data.writeInt(len); - data.writeInt(chunkData.length); - data.ensureWritable(len); - data.writeBytes(compressedChunkData, 0, len); - - return buildPacket(data); - } - - @Override - public void handle(ByteBuf in, EntityPlayer player) { - int dim = in.readInt(); - int xPos = in.readInt(); - int zPos = in.readInt(); - boolean reqinit = in.readBoolean(); - short yPos = in.readShort(); - short yMSBPos = in.readShort(); - int compressedsize = in.readInt(); - int uncompressedsize = in.readInt(); - byte[] chunkData = inflateChunkData(in, compressedsize, uncompressedsize); - - if (chunkData == null) { - LookingGlassPacketManager.bus.sendToServer(PacketRequestChunk.createPacket(xPos, yPos, zPos, dim)); - LoggerUtils.error("Chunk decompression failed: %d\t:\t%d\t\t%d : %d\n", yMSBPos, yPos, compressedsize, uncompressedsize); - return; - } - handle(player, chunkData, dim, xPos, zPos, reqinit, yPos, yMSBPos); - } - - public void handle(EntityPlayer player, byte[] chunkData, int dim, int xPos, int zPos, boolean reqinit, short yPos, short yMSBPos) { - WorldClient proxyworld = ProxyWorldManager.getProxyworld(dim); - if (proxyworld == null) return; - if (proxyworld.provider.dimensionId != dim) return; - - //TODO: Test to see if this first part is even necessary - Chunk chunk = proxyworld.getChunkProvider().provideChunk(xPos, zPos); - if (reqinit && (chunk == null || chunk.isEmpty())) { - if (yPos == 0) { - proxyworld.doPreChunk(xPos, zPos, false); - return; - } - proxyworld.doPreChunk(xPos, zPos, true); - } - // End possible removal section - proxyworld.invalidateBlockReceiveRegion(xPos << 4, 0, zPos << 4, (xPos << 4) + 15, 256, (zPos << 4) + 15); - chunk = proxyworld.getChunkFromChunkCoords(xPos, zPos); - if (reqinit && (chunk == null || chunk.isEmpty())) { - proxyworld.doPreChunk(xPos, zPos, true); - chunk = proxyworld.getChunkFromChunkCoords(xPos, zPos); - } - if (chunk != null) { - chunk.fillChunk(chunkData, yPos, yMSBPos, reqinit); - receivedChunk(proxyworld, xPos, zPos); - if (!reqinit || !(proxyworld.provider instanceof WorldProviderSurface)) { - chunk.resetRelightChecks(); - } - } - } - - public void receivedChunk(WorldClient worldObj, int cx, int cz) { - worldObj.markBlockRangeForRenderUpdate(cx << 4, 0, cz << 4, (cx << 4) + 15, 256, (cz << 4) + 15); - Chunk c = worldObj.getChunkFromChunkCoords(cx, cz); - if (c == null || c.isEmpty()) return; - - for (WorldView activeview : ProxyWorldManager.getWorldViews(worldObj.provider.dimensionId)) { - activeview.onChunkReceived(cx, cz); - } - - int x = (cx << 4); - int z = (cz << 4); - for (int y = 0; y < worldObj.getActualHeight(); y += 16) { - if (c.getAreLevelsEmpty(y, y)) continue; - for (int x2 = 0; x2 < 16; ++x2) { - for (int z2 = 0; z2 < 16; ++z2) { - for (int y2 = 0; y2 < 16; ++y2) { - int lx = x + x2; - int ly = y + y2; - int lz = z + z2; - if (worldObj.getBlock(lx, ly, lz).hasTileEntity(worldObj.getBlockMetadata(lx, ly, lz))) { - LookingGlassPacketManager.bus.sendToServer(PacketRequestTE.createPacket(lx, ly, lz, worldObj.provider.dimensionId)); - } - } - } - } - } - } - - private byte[] inflateChunkData(ByteBuf in, int compressedsize, int uncompressedsize) { - if (inflatearray == null || inflatearray.length < compressedsize) { - inflatearray = new byte[compressedsize]; - } - in.readBytes(inflatearray, 0, compressedsize); - byte[] chunkData = new byte[uncompressedsize]; - Inflater inflater = new Inflater(); - inflater.setInput(inflatearray, 0, compressedsize); - - try { - inflater.inflate(chunkData); - } catch (DataFormatException e) { - return null; - } finally { - inflater.end(); - } - return chunkData; - } - - public static Extracted getMapChunkData(Chunk chunk, boolean includeinit, int subid) { - int j = 0; - ExtendedBlockStorage[] aextendedblockstorage = chunk.getBlockStorageArray(); - int k = 0; - S21PacketChunkData.Extracted extracted = new S21PacketChunkData.Extracted(); - if (dataarray == null || dataarray.length < 196864) { - dataarray = new byte[196864]; - } - byte[] abyte = dataarray; - - if (includeinit) { - chunk.sendUpdates = true; - } - - int l; - - for (l = 0; l < aextendedblockstorage.length; ++l) { - if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && (subid & 1 << l) != 0) { - extracted.field_150280_b |= 1 << l; - - if (aextendedblockstorage[l].getBlockMSBArray() != null) { - extracted.field_150281_c |= 1 << l; - ++k; - } - } - } - - for (l = 0; l < aextendedblockstorage.length; ++l) { - if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && (subid & 1 << l) != 0) { - byte[] abyte1 = aextendedblockstorage[l].getBlockLSBArray(); - System.arraycopy(abyte1, 0, abyte, j, abyte1.length); - j += abyte1.length; - } - } - - NibbleArray nibblearray; - - for (l = 0; l < aextendedblockstorage.length; ++l) { - if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && (subid & 1 << l) != 0) { - nibblearray = aextendedblockstorage[l].getMetadataArray(); - System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); - j += nibblearray.data.length; - } - } - - for (l = 0; l < aextendedblockstorage.length; ++l) { - if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && (subid & 1 << l) != 0) { - nibblearray = aextendedblockstorage[l].getBlocklightArray(); - System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); - j += nibblearray.data.length; - } - } - - if (!chunk.worldObj.provider.hasNoSky) { - for (l = 0; l < aextendedblockstorage.length; ++l) { - if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && (subid & 1 << l) != 0) { - nibblearray = aextendedblockstorage[l].getSkylightArray(); - System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); - j += nibblearray.data.length; - } - } - } - - if (k > 0) { - for (l = 0; l < aextendedblockstorage.length; ++l) { - if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) && aextendedblockstorage[l].getBlockMSBArray() != null && (subid & 1 << l) != 0) { - nibblearray = aextendedblockstorage[l].getBlockMSBArray(); - System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); - j += nibblearray.data.length; - } - } - } - - if (includeinit) { - byte[] abyte2 = chunk.getBiomeArray(); - System.arraycopy(abyte2, 0, abyte, j, abyte2.length); - j += abyte2.length; - } - - extracted.field_150282_a = new byte[j]; - System.arraycopy(abyte, 0, extracted.field_150282_a, 0, j); - return extracted; - } + + private static byte[] inflatearray; + private static byte[] dataarray; + private static Semaphore deflateGate = new Semaphore(1); + + private static int deflate(byte[] chunkData, byte[] compressedChunkData) { + Deflater deflater = new Deflater(-1); + if (compressedChunkData == null) return 0; + int bytesize = 0; + try { + deflater.setInput(chunkData, 0, chunkData.length); + deflater.finish(); + bytesize = deflater.deflate(compressedChunkData); + } finally { + deflater.end(); + } + return bytesize; + } + + public static FMLProxyPacket createPacket(Chunk chunk, boolean includeinit, int subid, int dim) { + int xPos = chunk.xPosition; + int zPos = chunk.zPosition; + Extracted extracted = getMapChunkData(chunk, includeinit, subid); + int yMSBPos = extracted.field_150281_c; + int yPos = extracted.field_150280_b; + byte[] chunkData = extracted.field_150282_a; + + deflateGate.acquireUninterruptibly(); + byte[] compressedChunkData = new byte[chunkData.length]; + int len = deflate(chunkData, compressedChunkData); + deflateGate.release(); + + // This line may look like black magic (and, well, it is), but it's actually just returning a class reference + // for this class. Copy-paste safe. + ByteBuf data = PacketHandlerBase.createDataBuffer( + (Class) new Object() {}.getClass() + .getEnclosingClass()); + + data.writeInt(dim); + data.writeInt(xPos); + data.writeInt(zPos); + data.writeBoolean(includeinit); + data.writeShort((short) (yPos & 65535)); + data.writeShort((short) (yMSBPos & 65535)); + data.writeInt(len); + data.writeInt(chunkData.length); + data.ensureWritable(len); + data.writeBytes(compressedChunkData, 0, len); + + return buildPacket(data); + } + + @Override + public void handle(ByteBuf in, EntityPlayer player) { + int dim = in.readInt(); + int xPos = in.readInt(); + int zPos = in.readInt(); + boolean reqinit = in.readBoolean(); + short yPos = in.readShort(); + short yMSBPos = in.readShort(); + int compressedsize = in.readInt(); + int uncompressedsize = in.readInt(); + byte[] chunkData = inflateChunkData(in, compressedsize, uncompressedsize); + + if (chunkData == null) { + LookingGlassPacketManager.bus.sendToServer(PacketRequestChunk.createPacket(xPos, yPos, zPos, dim)); + LoggerUtils.error( + "Chunk decompression failed: %d\t:\t%d\t\t%d : %d\n", + yMSBPos, + yPos, + compressedsize, + uncompressedsize); + return; + } + handle(player, chunkData, dim, xPos, zPos, reqinit, yPos, yMSBPos); + } + + public void handle(EntityPlayer player, byte[] chunkData, int dim, int xPos, int zPos, boolean reqinit, short yPos, + short yMSBPos) { + WorldClient proxyworld = ProxyWorldManager.getProxyworld(dim); + if (proxyworld == null) return; + if (proxyworld.provider.dimensionId != dim) return; + + // TODO: Test to see if this first part is even necessary + Chunk chunk = proxyworld.getChunkProvider() + .provideChunk(xPos, zPos); + if (reqinit && (chunk == null || chunk.isEmpty())) { + if (yPos == 0) { + proxyworld.doPreChunk(xPos, zPos, false); + return; + } + proxyworld.doPreChunk(xPos, zPos, true); + } + // End possible removal section + proxyworld.invalidateBlockReceiveRegion(xPos << 4, 0, zPos << 4, (xPos << 4) + 15, 256, (zPos << 4) + 15); + chunk = proxyworld.getChunkFromChunkCoords(xPos, zPos); + if (reqinit && (chunk == null || chunk.isEmpty())) { + proxyworld.doPreChunk(xPos, zPos, true); + chunk = proxyworld.getChunkFromChunkCoords(xPos, zPos); + } + if (chunk != null) { + chunk.fillChunk(chunkData, yPos, yMSBPos, reqinit); + receivedChunk(proxyworld, xPos, zPos); + if (!reqinit || !(proxyworld.provider instanceof WorldProviderSurface)) { + chunk.resetRelightChecks(); + } + } + } + + public void receivedChunk(WorldClient worldObj, int cx, int cz) { + worldObj.markBlockRangeForRenderUpdate(cx << 4, 0, cz << 4, (cx << 4) + 15, 256, (cz << 4) + 15); + Chunk c = worldObj.getChunkFromChunkCoords(cx, cz); + if (c == null || c.isEmpty()) return; + + for (WorldView activeview : ProxyWorldManager.getWorldViews(worldObj.provider.dimensionId)) { + activeview.onChunkReceived(cx, cz); + } + + int x = (cx << 4); + int z = (cz << 4); + for (int y = 0; y < worldObj.getActualHeight(); y += 16) { + if (c.getAreLevelsEmpty(y, y)) continue; + for (int x2 = 0; x2 < 16; ++x2) { + for (int z2 = 0; z2 < 16; ++z2) { + for (int y2 = 0; y2 < 16; ++y2) { + int lx = x + x2; + int ly = y + y2; + int lz = z + z2; + if (worldObj.getBlock(lx, ly, lz) + .hasTileEntity(worldObj.getBlockMetadata(lx, ly, lz))) { + LookingGlassPacketManager.bus + .sendToServer(PacketRequestTE.createPacket(lx, ly, lz, worldObj.provider.dimensionId)); + } + } + } + } + } + } + + private byte[] inflateChunkData(ByteBuf in, int compressedsize, int uncompressedsize) { + if (inflatearray == null || inflatearray.length < compressedsize) { + inflatearray = new byte[compressedsize]; + } + in.readBytes(inflatearray, 0, compressedsize); + byte[] chunkData = new byte[uncompressedsize]; + Inflater inflater = new Inflater(); + inflater.setInput(inflatearray, 0, compressedsize); + + try { + inflater.inflate(chunkData); + } catch (DataFormatException e) { + return null; + } finally { + inflater.end(); + } + return chunkData; + } + + public static Extracted getMapChunkData(Chunk chunk, boolean includeinit, int subid) { + int j = 0; + ExtendedBlockStorage[] aextendedblockstorage = chunk.getBlockStorageArray(); + int k = 0; + S21PacketChunkData.Extracted extracted = new S21PacketChunkData.Extracted(); + if (dataarray == null || dataarray.length < 196864) { + dataarray = new byte[196864]; + } + byte[] abyte = dataarray; + + if (includeinit) { + chunk.sendUpdates = true; + } + + int l; + + for (l = 0; l < aextendedblockstorage.length; ++l) { + if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) + && (subid & 1 << l) != 0) { + extracted.field_150280_b |= 1 << l; + + if (aextendedblockstorage[l].getBlockMSBArray() != null) { + extracted.field_150281_c |= 1 << l; + ++k; + } + } + } + + for (l = 0; l < aextendedblockstorage.length; ++l) { + if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) + && (subid & 1 << l) != 0) { + byte[] abyte1 = aextendedblockstorage[l].getBlockLSBArray(); + System.arraycopy(abyte1, 0, abyte, j, abyte1.length); + j += abyte1.length; + } + } + + NibbleArray nibblearray; + + for (l = 0; l < aextendedblockstorage.length; ++l) { + if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) + && (subid & 1 << l) != 0) { + nibblearray = aextendedblockstorage[l].getMetadataArray(); + System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); + j += nibblearray.data.length; + } + } + + for (l = 0; l < aextendedblockstorage.length; ++l) { + if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) + && (subid & 1 << l) != 0) { + nibblearray = aextendedblockstorage[l].getBlocklightArray(); + System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); + j += nibblearray.data.length; + } + } + + if (!chunk.worldObj.provider.hasNoSky) { + for (l = 0; l < aextendedblockstorage.length; ++l) { + if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) + && (subid & 1 << l) != 0) { + nibblearray = aextendedblockstorage[l].getSkylightArray(); + System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); + j += nibblearray.data.length; + } + } + } + + if (k > 0) { + for (l = 0; l < aextendedblockstorage.length; ++l) { + if (aextendedblockstorage[l] != null && (!includeinit || !aextendedblockstorage[l].isEmpty()) + && aextendedblockstorage[l].getBlockMSBArray() != null + && (subid & 1 << l) != 0) { + nibblearray = aextendedblockstorage[l].getBlockMSBArray(); + System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); + j += nibblearray.data.length; + } + } + } + + if (includeinit) { + byte[] abyte2 = chunk.getBiomeArray(); + System.arraycopy(abyte2, 0, abyte, j, abyte2.length); + j += abyte2.length; + } + + extracted.field_150282_a = new byte[j]; + System.arraycopy(abyte, 0, extracted.field_150282_a, 0, j); + return extracted; + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketCloseView.java b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketCloseView.java index 5dbafab..f44997a 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketCloseView.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketCloseView.java @@ -1,6 +1,5 @@ package com.xcompwiz.lookingglass.network.packet; -import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; import com.xcompwiz.lookingglass.client.proxyworld.WorldView; @@ -9,20 +8,25 @@ import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; public class PacketCloseView extends PacketHandlerBase { - @SideOnly(Side.CLIENT) - public static FMLProxyPacket createPacket(WorldView worldview) { - // This line may look like black magic (and, well, it is), but it's actually just returning a class reference for this class. Copy-paste safe. - ByteBuf data = PacketHandlerBase.createDataBuffer((Class) new Object() {}.getClass().getEnclosingClass()); - return buildPacket(data); - } + @SideOnly(Side.CLIENT) + public static FMLProxyPacket createPacket(WorldView worldview) { + // This line may look like black magic (and, well, it is), but it's actually just returning a class reference + // for this class. Copy-paste safe. + ByteBuf data = PacketHandlerBase.createDataBuffer( + (Class) new Object() {}.getClass() + .getEnclosingClass()); + + return buildPacket(data); + } - @Override - public void handle(ByteBuf data, EntityPlayer player) { - if (ModConfigs.disabled) return; + @Override + public void handle(ByteBuf data, EntityPlayer player) { + if (ModConfigs.disabled) return; - //TODO: make closing viewpoint aware. See PacketCreateView - } + // TODO: make closing viewpoint aware. See PacketCreateView + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketCreateView.java b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketCreateView.java index 3e85563..cf80c4f 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketCreateView.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketCreateView.java @@ -1,6 +1,5 @@ package com.xcompwiz.lookingglass.network.packet; -import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -19,62 +18,70 @@ import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; public class PacketCreateView extends PacketHandlerBase { - @SideOnly(Side.CLIENT) - public static FMLProxyPacket createPacket(WorldView worldview) { - // This line may look like black magic (and, well, it is), but it's actually just returning a class reference for this class. Copy-paste safe. - ByteBuf data = PacketHandlerBase.createDataBuffer((Class) new Object() {}.getClass().getEnclosingClass()); - int x = 0; - int y = -1; - int z = 0; - if (worldview.coords != null) { - x = worldview.coords.posX >> 4; - y = worldview.coords.posY >> 4; - z = worldview.coords.posZ >> 4; - } + @SideOnly(Side.CLIENT) + public static FMLProxyPacket createPacket(WorldView worldview) { + // This line may look like black magic (and, well, it is), but it's actually just returning a class reference + // for this class. Copy-paste safe. + ByteBuf data = PacketHandlerBase.createDataBuffer( + (Class) new Object() {}.getClass() + .getEnclosingClass()); + + int x = 0; + int y = -1; + int z = 0; + if (worldview.coords != null) { + x = worldview.coords.posX >> 4; + y = worldview.coords.posY >> 4; + z = worldview.coords.posZ >> 4; + } - data.writeInt(worldview.getWorldObj().provider.dimensionId); - data.writeInt(x); - data.writeInt(y); - data.writeInt(z); - data.writeByte(Math.min(ModConfigs.renderDistance, Minecraft.getMinecraft().gameSettings.renderDistanceChunks)); + data.writeInt(worldview.getWorldObj().provider.dimensionId); + data.writeInt(x); + data.writeInt(y); + data.writeInt(z); + data.writeByte(Math.min(ModConfigs.renderDistance, Minecraft.getMinecraft().gameSettings.renderDistanceChunks)); - return buildPacket(data); - } + return buildPacket(data); + } - @Override - public void handle(ByteBuf data, EntityPlayer player) { - if (ModConfigs.disabled) return; - int dim = data.readInt(); - int xPos = data.readInt(); - int yPos = data.readInt(); - int zPos = data.readInt(); - byte renderDistance = data.readByte(); + @Override + public void handle(ByteBuf data, EntityPlayer player) { + if (ModConfigs.disabled) return; + int dim = data.readInt(); + int xPos = data.readInt(); + int yPos = data.readInt(); + int zPos = data.readInt(); + byte renderDistance = data.readByte(); - if (!DimensionManager.isDimensionRegistered(dim)) return; - WorldServer world = MinecraftServer.getServer().worldServerForDimension(dim); - if (world == null) return; - int x; - int y; - int z; - if (yPos < 0) { - ChunkCoordinates c = world.getSpawnPoint(); - x = c.posX >> 4; - y = c.posY >> 4; - z = c.posZ >> 4; - } else { - x = xPos; - y = yPos; - z = zPos; - } - if (renderDistance > ModConfigs.renderDistance) renderDistance = ModConfigs.renderDistance; - ChunkFinderManager.instance.addFinder(new ChunkFinder(new ChunkCoordinates(x, y, z), dim, world.getChunkProvider(), player, renderDistance)); - //TODO: Add to tracking list. Send time/data updates at intervals. Keep in mind to catch player disconnects when tracking clients. - //Register ChunkFinder, and support change of finder location. - //TODO: This is a repeat of the handling of PacketRequestWorldInfo - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new ClientWorldInfoEvent(dim, (EntityPlayerMP) player)); - LookingGlassPacketManager.bus.sendTo(PacketWorldInfo.createPacket(dim), (EntityPlayerMP) player); - } + if (!DimensionManager.isDimensionRegistered(dim)) return; + WorldServer world = MinecraftServer.getServer() + .worldServerForDimension(dim); + if (world == null) return; + int x; + int y; + int z; + if (yPos < 0) { + ChunkCoordinates c = world.getSpawnPoint(); + x = c.posX >> 4; + y = c.posY >> 4; + z = c.posZ >> 4; + } else { + x = xPos; + y = yPos; + z = zPos; + } + if (renderDistance > ModConfigs.renderDistance) renderDistance = ModConfigs.renderDistance; + ChunkFinderManager.instance.addFinder( + new ChunkFinder(new ChunkCoordinates(x, y, z), dim, world.getChunkProvider(), player, renderDistance)); + // TODO: Add to tracking list. Send time/data updates at intervals. Keep in mind to catch player disconnects + // when tracking clients. + // Register ChunkFinder, and support change of finder location. + // TODO: This is a repeat of the handling of PacketRequestWorldInfo + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new ClientWorldInfoEvent(dim, (EntityPlayerMP) player)); + LookingGlassPacketManager.bus.sendTo(PacketWorldInfo.createPacket(dim), (EntityPlayerMP) player); + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketHandlerBase.java b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketHandlerBase.java index e982ba3..839db7b 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketHandlerBase.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketHandlerBase.java @@ -1,37 +1,40 @@ -package com.xcompwiz.lookingglass.network.packet; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import net.minecraft.entity.player.EntityPlayer; - -import com.xcompwiz.lookingglass.network.LookingGlassPacketManager; - -import cpw.mods.fml.common.network.internal.FMLProxyPacket; - -/** - * This class is the parent of the packet handling classes for our network communication. Mostly contains helper functions. - */ -public abstract class PacketHandlerBase { - - /** - * Called by our packet manager to process packet data - */ - public abstract void handle(ByteBuf data, EntityPlayer player); - - /** - * Used by the progeny of this class in order to produce and prepare the buffer for packet data. Includes writing the correct packet id for the packet. - */ - public static ByteBuf createDataBuffer(Class handlerclass) { - ByteBuf data = Unpooled.buffer(); - data.writeByte(LookingGlassPacketManager.getId(handlerclass)); - return data; - } - - /** - * Used by the progeny of this class in order to produce a packet object from the data buffer. Automatically uses our packet channel so that the manager on - * the other side will receive the packet. - */ - protected static FMLProxyPacket buildPacket(ByteBuf payload) { - return new FMLProxyPacket(payload, LookingGlassPacketManager.CHANNEL); - } -} +package com.xcompwiz.lookingglass.network.packet; + +import net.minecraft.entity.player.EntityPlayer; + +import com.xcompwiz.lookingglass.network.LookingGlassPacketManager; + +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +/** + * This class is the parent of the packet handling classes for our network communication. Mostly contains helper + * functions. + */ +public abstract class PacketHandlerBase { + + /** + * Called by our packet manager to process packet data + */ + public abstract void handle(ByteBuf data, EntityPlayer player); + + /** + * Used by the progeny of this class in order to produce and prepare the buffer for packet data. Includes writing + * the correct packet id for the packet. + */ + public static ByteBuf createDataBuffer(Class handlerclass) { + ByteBuf data = Unpooled.buffer(); + data.writeByte(LookingGlassPacketManager.getId(handlerclass)); + return data; + } + + /** + * Used by the progeny of this class in order to produce a packet object from the data buffer. Automatically uses + * our packet channel so that the manager on + * the other side will receive the packet. + */ + protected static FMLProxyPacket buildPacket(ByteBuf payload) { + return new FMLProxyPacket(payload, LookingGlassPacketManager.CHANNEL); + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestChunk.java b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestChunk.java index 7211087..290e0dc 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestChunk.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestChunk.java @@ -1,6 +1,5 @@ package com.xcompwiz.lookingglass.network.packet; -import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.world.WorldServer; @@ -11,33 +10,41 @@ import com.xcompwiz.lookingglass.proxyworld.ModConfigs; import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import io.netty.buffer.ByteBuf; public class PacketRequestChunk extends PacketHandlerBase { - public static FMLProxyPacket createPacket(int xPos, int yPos, int zPos, int dim) { - // This line may look like black magic (and, well, it is), but it's actually just returning a class reference for this class. Copy-paste safe. - ByteBuf data = PacketHandlerBase.createDataBuffer((Class) new Object() {}.getClass().getEnclosingClass()); - - data.writeInt(dim); - data.writeInt(xPos); - data.writeInt(yPos); - data.writeInt(zPos); - - return buildPacket(data); - } - - @Override - public void handle(ByteBuf data, EntityPlayer player) { - if (ModConfigs.disabled) return; - int dim = data.readInt(); - int xPos = data.readInt(); - int yPos = data.readInt(); - int zPos = data.readInt(); - - if (!DimensionManager.isDimensionRegistered(dim)) return; - WorldServer world = MinecraftServer.getServer().worldServerForDimension(dim); - if (world == null) return; - Chunk chunk = world.getChunkFromChunkCoords(xPos, zPos); - if (!chunk.isChunkLoaded) chunk = world.getChunkProvider().loadChunk(xPos, zPos); - ServerPacketDispatcher.getInstance().addPacket(player, PacketChunkInfo.createPacket(chunk, true, yPos, dim)); - } + + public static FMLProxyPacket createPacket(int xPos, int yPos, int zPos, int dim) { + // This line may look like black magic (and, well, it is), but it's actually just returning a class reference + // for this class. Copy-paste safe. + ByteBuf data = PacketHandlerBase.createDataBuffer( + (Class) new Object() {}.getClass() + .getEnclosingClass()); + + data.writeInt(dim); + data.writeInt(xPos); + data.writeInt(yPos); + data.writeInt(zPos); + + return buildPacket(data); + } + + @Override + public void handle(ByteBuf data, EntityPlayer player) { + if (ModConfigs.disabled) return; + int dim = data.readInt(); + int xPos = data.readInt(); + int yPos = data.readInt(); + int zPos = data.readInt(); + + if (!DimensionManager.isDimensionRegistered(dim)) return; + WorldServer world = MinecraftServer.getServer() + .worldServerForDimension(dim); + if (world == null) return; + Chunk chunk = world.getChunkFromChunkCoords(xPos, zPos); + if (!chunk.isChunkLoaded) chunk = world.getChunkProvider() + .loadChunk(xPos, zPos); + ServerPacketDispatcher.getInstance() + .addPacket(player, PacketChunkInfo.createPacket(chunk, true, yPos, dim)); + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestTE.java b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestTE.java index 7aa20bf..31fedd3 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestTE.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestTE.java @@ -1,6 +1,5 @@ package com.xcompwiz.lookingglass.network.packet; -import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; @@ -12,40 +11,50 @@ import com.xcompwiz.lookingglass.proxyworld.ModConfigs; import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import io.netty.buffer.ByteBuf; public class PacketRequestTE extends PacketHandlerBase { - public static FMLProxyPacket createPacket(int xPos, int yPos, int zPos, int dim) { - // This line may look like black magic (and, well, it is), but it's actually just returning a class reference for this class. Copy-paste safe. - ByteBuf data = PacketHandlerBase.createDataBuffer((Class) new Object() {}.getClass().getEnclosingClass()); - - data.writeInt(dim); - data.writeInt(xPos); - data.writeInt(yPos); - data.writeInt(zPos); - - return buildPacket(data); - } - - @Override - public void handle(ByteBuf data, EntityPlayer player) { - if (ModConfigs.disabled) return; - int dim = data.readInt(); - int xPos = data.readInt(); - int yPos = data.readInt(); - int zPos = data.readInt(); - - if (!DimensionManager.isDimensionRegistered(dim)) return; - WorldServer world = MinecraftServer.getServer().worldServerForDimension(dim); - if (world == null) return; - TileEntity tile = world.getTileEntity(xPos, yPos, zPos); - if (tile != null) { - //FIXME: This is currently a very "forceful" method of doing this, and not technically guaranteed to produce correct results - // This would be much better handled by using the getDescriptionPacket method and wrapping that packet in a LookingGlass - // packet to control delivery timing, allowing for processing the packet while the correct target world is the active world - // This idea requires that that system be in place, though, so until then this hack will hopefully hold. - NBTTagCompound tag = new NBTTagCompound(); - tile.writeToNBT(tag); - ServerPacketDispatcher.getInstance().addPacket(player, PacketTileEntityNBT.createPacket(xPos, yPos, zPos, tag, dim)); - } - } + + public static FMLProxyPacket createPacket(int xPos, int yPos, int zPos, int dim) { + // This line may look like black magic (and, well, it is), but it's actually just returning a class reference + // for this class. Copy-paste safe. + ByteBuf data = PacketHandlerBase.createDataBuffer( + (Class) new Object() {}.getClass() + .getEnclosingClass()); + + data.writeInt(dim); + data.writeInt(xPos); + data.writeInt(yPos); + data.writeInt(zPos); + + return buildPacket(data); + } + + @Override + public void handle(ByteBuf data, EntityPlayer player) { + if (ModConfigs.disabled) return; + int dim = data.readInt(); + int xPos = data.readInt(); + int yPos = data.readInt(); + int zPos = data.readInt(); + + if (!DimensionManager.isDimensionRegistered(dim)) return; + WorldServer world = MinecraftServer.getServer() + .worldServerForDimension(dim); + if (world == null) return; + TileEntity tile = world.getTileEntity(xPos, yPos, zPos); + if (tile != null) { + // FIXME: This is currently a very "forceful" method of doing this, and not technically guaranteed to + // produce correct results + // This would be much better handled by using the getDescriptionPacket method and wrapping that packet in a + // LookingGlass + // packet to control delivery timing, allowing for processing the packet while the correct target world is + // the active world + // This idea requires that that system be in place, though, so until then this hack will hopefully hold. + NBTTagCompound tag = new NBTTagCompound(); + tile.writeToNBT(tag); + ServerPacketDispatcher.getInstance() + .addPacket(player, PacketTileEntityNBT.createPacket(xPos, yPos, zPos, tag, dim)); + } + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestWorldInfo.java b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestWorldInfo.java index 8fbc9ec..ccdbe58 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestWorldInfo.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketRequestWorldInfo.java @@ -1,6 +1,5 @@ package com.xcompwiz.lookingglass.network.packet; -import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.common.DimensionManager; @@ -12,25 +11,30 @@ import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; public class PacketRequestWorldInfo extends PacketHandlerBase { - @SideOnly(Side.CLIENT) - public static FMLProxyPacket createPacket(int xPos, int yPos, int zPos, int dim) { - // This line may look like black magic (and, well, it is), but it's actually just returning a class reference for this class. Copy-paste safe. - ByteBuf data = PacketHandlerBase.createDataBuffer((Class) new Object() {}.getClass().getEnclosingClass()); - data.writeInt(dim); + @SideOnly(Side.CLIENT) + public static FMLProxyPacket createPacket(int xPos, int yPos, int zPos, int dim) { + // This line may look like black magic (and, well, it is), but it's actually just returning a class reference + // for this class. Copy-paste safe. + ByteBuf data = PacketHandlerBase.createDataBuffer( + (Class) new Object() {}.getClass() + .getEnclosingClass()); + + data.writeInt(dim); - return buildPacket(data); - } + return buildPacket(data); + } - @Override - public void handle(ByteBuf data, EntityPlayer player) { - if (ModConfigs.disabled) return; - int dim = data.readInt(); + @Override + public void handle(ByteBuf data, EntityPlayer player) { + if (ModConfigs.disabled) return; + int dim = data.readInt(); - if (!DimensionManager.isDimensionRegistered(dim)) return; - net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new ClientWorldInfoEvent(dim, (EntityPlayerMP) player)); - LookingGlassPacketManager.bus.sendTo(PacketWorldInfo.createPacket(dim), (EntityPlayerMP) player); - } + if (!DimensionManager.isDimensionRegistered(dim)) return; + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new ClientWorldInfoEvent(dim, (EntityPlayerMP) player)); + LookingGlassPacketManager.bus.sendTo(PacketWorldInfo.createPacket(dim), (EntityPlayerMP) player); + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketTileEntityNBT.java b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketTileEntityNBT.java index e3f985e..c877079 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketTileEntityNBT.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketTileEntityNBT.java @@ -1,6 +1,5 @@ package com.xcompwiz.lookingglass.network.packet; -import io.netty.buffer.ByteBuf; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -10,51 +9,55 @@ import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import io.netty.buffer.ByteBuf; /** * Based on code from Ken Butler/shadowking97 */ public class PacketTileEntityNBT extends PacketHandlerBase { - public static FMLProxyPacket createPacket(int xPos, int yPos, int zPos, NBTTagCompound nbt, int dim) { - // This line may look like black magic (and, well, it is), but it's actually just returning a class reference for this class. Copy-paste safe. - ByteBuf data = PacketHandlerBase.createDataBuffer((Class) new Object() {}.getClass().getEnclosingClass()); - - data.writeInt(dim); - data.writeInt(xPos); - data.writeInt(yPos); - data.writeInt(zPos); - ByteBufUtils.writeTag(data, nbt); - - return buildPacket(data); - } - - @Override - public void handle(ByteBuf data, EntityPlayer player) { - int dimension = data.readInt(); - int xPos = data.readInt(); - int yPos = data.readInt(); - int zPos = data.readInt(); - NBTTagCompound nbt = ByteBufUtils.readTag(data); - - WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimension); - if (proxyworld == null) return; - if (proxyworld.provider.dimensionId != dimension) return; - if (proxyworld.blockExists(xPos, yPos, zPos)) { - TileEntity tileentity = proxyworld.getTileEntity(xPos, yPos, zPos); - - if (tileentity != null) { - tileentity.readFromNBT(nbt); - } else { - //Create tile entity from data - tileentity = TileEntity.createAndLoadEntity(nbt); - if (tileentity != null) { - proxyworld.addTileEntity(tileentity); - } - } - proxyworld.markTileEntityChunkModified(xPos, yPos, zPos, tileentity); - proxyworld.setTileEntity(xPos, yPos, zPos, tileentity); - proxyworld.markBlockForUpdate(xPos, yPos, zPos); - } - } + public static FMLProxyPacket createPacket(int xPos, int yPos, int zPos, NBTTagCompound nbt, int dim) { + // This line may look like black magic (and, well, it is), but it's actually just returning a class reference + // for this class. Copy-paste safe. + ByteBuf data = PacketHandlerBase.createDataBuffer( + (Class) new Object() {}.getClass() + .getEnclosingClass()); + + data.writeInt(dim); + data.writeInt(xPos); + data.writeInt(yPos); + data.writeInt(zPos); + ByteBufUtils.writeTag(data, nbt); + + return buildPacket(data); + } + + @Override + public void handle(ByteBuf data, EntityPlayer player) { + int dimension = data.readInt(); + int xPos = data.readInt(); + int yPos = data.readInt(); + int zPos = data.readInt(); + NBTTagCompound nbt = ByteBufUtils.readTag(data); + + WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimension); + if (proxyworld == null) return; + if (proxyworld.provider.dimensionId != dimension) return; + if (proxyworld.blockExists(xPos, yPos, zPos)) { + TileEntity tileentity = proxyworld.getTileEntity(xPos, yPos, zPos); + + if (tileentity != null) { + tileentity.readFromNBT(nbt); + } else { + // Create tile entity from data + tileentity = TileEntity.createAndLoadEntity(nbt); + if (tileentity != null) { + proxyworld.addTileEntity(tileentity); + } + } + proxyworld.markTileEntityChunkModified(xPos, yPos, zPos, tileentity); + proxyworld.setTileEntity(xPos, yPos, zPos, tileentity); + proxyworld.markBlockForUpdate(xPos, yPos, zPos); + } + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketWorldInfo.java b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketWorldInfo.java index d57a405..57451b8 100644 --- a/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketWorldInfo.java +++ b/src/main/java/com/xcompwiz/lookingglass/network/packet/PacketWorldInfo.java @@ -1,7 +1,5 @@ package com.xcompwiz.lookingglass.network.packet; -import io.netty.buffer.ByteBuf; - import java.util.Collection; import net.minecraft.client.multiplayer.WorldClient; @@ -15,68 +13,73 @@ import com.xcompwiz.lookingglass.log.LoggerUtils; import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import io.netty.buffer.ByteBuf; /** * Based on code from Ken Butler/shadowking97 */ public class PacketWorldInfo extends PacketHandlerBase { - public static FMLProxyPacket createPacket(int dimension) { - WorldServer world = MinecraftServer.getServer().worldServerForDimension(dimension); - if (world == null) { - LoggerUtils.warn("Server-side world for dimension %i is null!", dimension); - return null; - } - ChunkCoordinates cc = world.provider.getSpawnPoint(); - int posX = cc.posX; - int posY = cc.posY; - int posZ = cc.posZ; - int skylightSubtracted = world.skylightSubtracted; - float thunderingStrength = world.thunderingStrength; - float rainingStrength = world.rainingStrength; - long worldTime = world.provider.getWorldTime(); + public static FMLProxyPacket createPacket(int dimension) { + WorldServer world = MinecraftServer.getServer() + .worldServerForDimension(dimension); + if (world == null) { + LoggerUtils.warn("Server-side world for dimension %i is null!", dimension); + return null; + } + ChunkCoordinates cc = world.provider.getSpawnPoint(); + int posX = cc.posX; + int posY = cc.posY; + int posZ = cc.posZ; + int skylightSubtracted = world.skylightSubtracted; + float thunderingStrength = world.thunderingStrength; + float rainingStrength = world.rainingStrength; + long worldTime = world.provider.getWorldTime(); - // This line may look like black magic (and, well, it is), but it's actually just returning a class reference for this class. Copy-paste safe. - ByteBuf data = PacketHandlerBase.createDataBuffer((Class) new Object() {}.getClass().getEnclosingClass()); + // This line may look like black magic (and, well, it is), but it's actually just returning a class reference + // for this class. Copy-paste safe. + ByteBuf data = PacketHandlerBase.createDataBuffer( + (Class) new Object() {}.getClass() + .getEnclosingClass()); - data.writeInt(dimension); - data.writeInt(posX); - data.writeInt(posY); - data.writeInt(posZ); - data.writeInt(skylightSubtracted); - data.writeFloat(thunderingStrength); - data.writeFloat(rainingStrength); - data.writeLong(worldTime); + data.writeInt(dimension); + data.writeInt(posX); + data.writeInt(posY); + data.writeInt(posZ); + data.writeInt(skylightSubtracted); + data.writeFloat(thunderingStrength); + data.writeFloat(rainingStrength); + data.writeLong(worldTime); - return buildPacket(data); - } + return buildPacket(data); + } - @Override - public void handle(ByteBuf in, EntityPlayer player) { - int dimension = in.readInt(); - int posX = in.readInt(); - int posY = in.readInt(); - int posZ = in.readInt(); - int skylightSubtracted = in.readInt(); - float thunderingStrength = in.readFloat(); - float rainingStrength = in.readFloat(); - long worldTime = in.readLong(); + @Override + public void handle(ByteBuf in, EntityPlayer player) { + int dimension = in.readInt(); + int posX = in.readInt(); + int posY = in.readInt(); + int posZ = in.readInt(); + int skylightSubtracted = in.readInt(); + float thunderingStrength = in.readFloat(); + float rainingStrength = in.readFloat(); + long worldTime = in.readLong(); - WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimension); + WorldClient proxyworld = ProxyWorldManager.getProxyworld(dimension); - if (proxyworld == null) return; - if (proxyworld.provider.dimensionId != dimension) return; + if (proxyworld == null) return; + if (proxyworld.provider.dimensionId != dimension) return; - ChunkCoordinates cc = new ChunkCoordinates(); - cc.set(posX, posY, posZ); - Collection views = ProxyWorldManager.getWorldViews(dimension); - for (WorldView view : views) { - view.updateWorldSpawn(cc); - } - proxyworld.setSpawnLocation(posX, posY, posZ); - proxyworld.skylightSubtracted = skylightSubtracted; - proxyworld.thunderingStrength = thunderingStrength; - proxyworld.setRainStrength(rainingStrength); - proxyworld.setWorldTime(worldTime); - } + ChunkCoordinates cc = new ChunkCoordinates(); + cc.set(posX, posY, posZ); + Collection views = ProxyWorldManager.getWorldViews(dimension); + for (WorldView view : views) { + view.updateWorldSpawn(cc); + } + proxyworld.setSpawnLocation(posX, posY, posZ); + proxyworld.skylightSubtracted = skylightSubtracted; + proxyworld.thunderingStrength = thunderingStrength; + proxyworld.setRainStrength(rainingStrength); + proxyworld.setWorldTime(worldTime); + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/proxyworld/ChunkFinder.java b/src/main/java/com/xcompwiz/lookingglass/proxyworld/ChunkFinder.java index ba25a0b..42b064c 100644 --- a/src/main/java/com/xcompwiz/lookingglass/proxyworld/ChunkFinder.java +++ b/src/main/java/com/xcompwiz/lookingglass/proxyworld/ChunkFinder.java @@ -15,303 +15,320 @@ /** * Finds 16x16x16 chunks exposed to the passed chunk location. + * * @author Ken Butler/shadowking97 */ public class ChunkFinder { - private final IChunkProvider chunkProvider; - private final int rootX; - private final int rootZ; - private final int range; - private final int dimension; - private final EntityPlayer player; - private ChunkData[][] map; - private List cc; - private final int d; - private int step; - private int stepRange; - private long startTime; + private final IChunkProvider chunkProvider; + private final int rootX; + private final int rootZ; + private final int range; + private final int dimension; + private final EntityPlayer player; + private ChunkData[][] map; + private List cc; + private final int d; + private int step; + private int stepRange; + private long startTime; - /** - * Finds exposed chunks. Chunks must be loaded. - * @param root The chunk in chunk coordinates. - * @param dimension The target dimension - * @param chunkProvider The world server that contains the chunks - * @param player The player to send the chunks to - * @param range The radius of the chunkfinder. - * @return Sorted Chunk Data, by range. Prioritizes closest chunks. - */ - public ChunkFinder(ChunkCoordinates root, int dimension, IChunkProvider chunkProvider, EntityPlayer player, int range) { - this.chunkProvider = chunkProvider; - this.range = range; - this.dimension = dimension; - this.player = player; - this.d = (range << 1) + 1; - this.map = new ChunkData[d][d]; - this.rootX = root.posX - range; - this.rootZ = root.posZ - range; - this.stepRange = 16 - root.posY; - if (root.posY > stepRange) stepRange = root.posY; - startTime = System.nanoTime(); - LoggerUtils.debug("ChunkFinder scan started at nano: " + startTime); - for (int i = 0; i < d; i++) { - for (int j = 0; j < d; j++) { - map[i][j] = new ChunkData(i + rootX, j + rootZ); - int x1 = i - range; - int z1 = j - range; - map[i][j].distance = x1 * x1 + z1 * z1; - } - } - cc = new LinkedList(); - cc.add(new ChunkCoordinates(range, root.posY, range)); - step = 0; - List cc2 = new LinkedList(); - while (step - 1 < stepRange && !cc.isEmpty()) { - while (!cc.isEmpty()) { - cc2.addAll(scan(chunkProvider, map, cc.get(0), range)); - cc.remove(0); - } - step++; - cc.addAll(cc2); - cc2.clear(); - if (step >= stepRange) { - int range2 = step - stepRange + 1; - range2 *= range2; - int range3 = step - stepRange; - if (range3 < 0) range3 = 0; - range3 *= range3; - int minStep = range - (step - stepRange); - int maxStep = range + (step - stepRange) + 1; - if (minStep < 0) minStep = 0; - if (maxStep > d) maxStep = d; - for (int i = minStep; i < maxStep; i++) { - for (int j = minStep; j < maxStep; j++) { - int dist = map[i][j].distance; - if (map[i][j].doAdd() && dist < range2 && dist >= range3) { - ChunkData data = map[i][j]; - Chunk c2 = chunkProvider.provideChunk(data.x, data.z); - if (!c2.isChunkLoaded) c2 = chunkProvider.loadChunk(data.x, data.z); + /** + * Finds exposed chunks. Chunks must be loaded. + * + * @param root The chunk in chunk coordinates. + * @param dimension The target dimension + * @param chunkProvider The world server that contains the chunks + * @param player The player to send the chunks to + * @param range The radius of the chunkfinder. + * @return Sorted Chunk Data, by range. Prioritizes closest chunks. + */ + public ChunkFinder(ChunkCoordinates root, int dimension, IChunkProvider chunkProvider, EntityPlayer player, + int range) { + this.chunkProvider = chunkProvider; + this.range = range; + this.dimension = dimension; + this.player = player; + this.d = (range << 1) + 1; + this.map = new ChunkData[d][d]; + this.rootX = root.posX - range; + this.rootZ = root.posZ - range; + this.stepRange = 16 - root.posY; + if (root.posY > stepRange) stepRange = root.posY; + startTime = System.nanoTime(); + LoggerUtils.debug("ChunkFinder scan started at nano: " + startTime); + for (int i = 0; i < d; i++) { + for (int j = 0; j < d; j++) { + map[i][j] = new ChunkData(i + rootX, j + rootZ); + int x1 = i - range; + int z1 = j - range; + map[i][j].distance = x1 * x1 + z1 * z1; + } + } + cc = new LinkedList(); + cc.add(new ChunkCoordinates(range, root.posY, range)); + step = 0; + List cc2 = new LinkedList(); + while (step - 1 < stepRange && !cc.isEmpty()) { + while (!cc.isEmpty()) { + cc2.addAll(scan(chunkProvider, map, cc.get(0), range)); + cc.remove(0); + } + step++; + cc.addAll(cc2); + cc2.clear(); + if (step >= stepRange) { + int range2 = step - stepRange + 1; + range2 *= range2; + int range3 = step - stepRange; + if (range3 < 0) range3 = 0; + range3 *= range3; + int minStep = range - (step - stepRange); + int maxStep = range + (step - stepRange) + 1; + if (minStep < 0) minStep = 0; + if (maxStep > d) maxStep = d; + for (int i = minStep; i < maxStep; i++) { + for (int j = minStep; j < maxStep; j++) { + int dist = map[i][j].distance; + if (map[i][j].doAdd() && dist < range2 && dist >= range3) { + ChunkData data = map[i][j]; + Chunk c2 = chunkProvider.provideChunk(data.x, data.z); + if (!c2.isChunkLoaded) c2 = chunkProvider.loadChunk(data.x, data.z); - ServerPacketDispatcher.getInstance().addPacket(player, PacketChunkInfo.createPacket(c2, true, data.levels(), dimension)); - } - } - } - } - } - } + ServerPacketDispatcher.getInstance() + .addPacket(player, PacketChunkInfo.createPacket(c2, true, data.levels(), dimension)); + } + } + } + } + } + } - public boolean findChunks() { - if (!cc.isEmpty()) { - int tick = 0; - List cc2 = new LinkedList(); - while (!cc.isEmpty() && tick < 15) { - ChunkCoordinates ch = cc.get(0); - cc2.addAll(scan(chunkProvider, map, ch, range)); - cc.remove(0); - ++tick; - } - if (!cc.isEmpty()) return false; + public boolean findChunks() { + if (!cc.isEmpty()) { + int tick = 0; + List cc2 = new LinkedList(); + while (!cc.isEmpty() && tick < 15) { + ChunkCoordinates ch = cc.get(0); + cc2.addAll(scan(chunkProvider, map, ch, range)); + cc.remove(0); + ++tick; + } + if (!cc.isEmpty()) return false; - step++; + step++; - cc.addAll(cc2); - cc2.clear(); + cc.addAll(cc2); + cc2.clear(); - if (step >= stepRange) { - int range2 = step - stepRange + 1; - range2 *= range2; - int range3 = step - stepRange; - if (range3 < 0) range3 = 0; - range3 *= range3; - int minStep = range - (step - stepRange); - int maxStep = range + (step - stepRange) + 1; - if (minStep < 0) minStep = 0; - if (maxStep > d) maxStep = d; - for (int i = minStep; i < maxStep; i++) { - for (int j = minStep; j < maxStep; j++) { - int dist = map[i][j].distance; - if (map[i][j].doAdd() && dist < range2 && dist >= range3) { - ChunkData data = map[i][j]; - Chunk c2 = chunkProvider.provideChunk(data.x, data.z); - if (!c2.isChunkLoaded) c2 = chunkProvider.loadChunk(data.x, data.z); - ServerPacketDispatcher.getInstance().addPacket(player, PacketChunkInfo.createPacket(c2, true, data.levels(), dimension)); - } - } - } - } - return false; - } + if (step >= stepRange) { + int range2 = step - stepRange + 1; + range2 *= range2; + int range3 = step - stepRange; + if (range3 < 0) range3 = 0; + range3 *= range3; + int minStep = range - (step - stepRange); + int maxStep = range + (step - stepRange) + 1; + if (minStep < 0) minStep = 0; + if (maxStep > d) maxStep = d; + for (int i = minStep; i < maxStep; i++) { + for (int j = minStep; j < maxStep; j++) { + int dist = map[i][j].distance; + if (map[i][j].doAdd() && dist < range2 && dist >= range3) { + ChunkData data = map[i][j]; + Chunk c2 = chunkProvider.provideChunk(data.x, data.z); + if (!c2.isChunkLoaded) c2 = chunkProvider.loadChunk(data.x, data.z); + ServerPacketDispatcher.getInstance() + .addPacket(player, PacketChunkInfo.createPacket(c2, true, data.levels(), dimension)); + } + } + } + } + return false; + } - if (step >= stepRange) { - int range2 = step - stepRange; - range2 *= range2; - for (int i = 0; i < d; i++) { - for (int j = 0; j < d; j++) { - int dist = map[i][j].distance; - if (map[i][j].doAdd() && dist >= range2) { - ChunkData data = map[i][j]; - Chunk c2 = chunkProvider.provideChunk(data.x, data.z); - if (!c2.isChunkLoaded) c2 = chunkProvider.loadChunk(data.x, data.z); - ServerPacketDispatcher.getInstance().addPacket(player, PacketChunkInfo.createPacket(c2, true, data.levels(), dimension)); - } - } - } - } - LoggerUtils.debug("Scan finished. nanoseconds: " + (System.nanoTime() - startTime)); - return true; - } + if (step >= stepRange) { + int range2 = step - stepRange; + range2 *= range2; + for (int i = 0; i < d; i++) { + for (int j = 0; j < d; j++) { + int dist = map[i][j].distance; + if (map[i][j].doAdd() && dist >= range2) { + ChunkData data = map[i][j]; + Chunk c2 = chunkProvider.provideChunk(data.x, data.z); + if (!c2.isChunkLoaded) c2 = chunkProvider.loadChunk(data.x, data.z); + ServerPacketDispatcher.getInstance() + .addPacket(player, PacketChunkInfo.createPacket(c2, true, data.levels(), dimension)); + } + } + } + } + LoggerUtils.debug("Scan finished. nanoseconds: " + (System.nanoTime() - startTime)); + return true; + } - /** - * Recursive function to find all chunk segments attached to the surface. - */ - private static List scan(IChunkProvider chunkProvider, ChunkData[][] map, ChunkCoordinates coord, int range) { - int rangeSqr = range * range; - List cc3 = new LinkedList(); - int x = coord.posX; - int y = coord.posY; - int z = coord.posZ; - ChunkData data = map[x][z]; - if (data.isAdded(y) || data.distance > rangeSqr) return cc3; - data.add(y); - Chunk c = chunkProvider.provideChunk(data.x, data.z); - if (!c.isChunkLoaded) { - c = chunkProvider.loadChunk(data.x, data.z); - } - if (c.getAreLevelsEmpty(y << 4, (y << 4) + 15)) { - data.empty(y); - if (x < (range << 1) && !(map[x + 1][z].isAdded(y) || map[x + 1][z].distance > rangeSqr || map[x + 1][z].distance < map[x][z].distance)) cc3.add(new ChunkCoordinates(x + 1, y, z)); - if (x > 0 && !(map[x - 1][z].isAdded(y) || map[x - 1][z].distance > rangeSqr || map[x - 1][z].distance < map[x][z].distance)) cc3.add(new ChunkCoordinates(x - 1, y, z)); - if (y < 15 && !(map[x][z].isAdded(y + 1) || map[x][z].distance > rangeSqr)) cc3.add(new ChunkCoordinates(x, y + 1, z)); - if (y > 0 && !(map[x][z].isAdded(y - 1) || map[x][z].distance > rangeSqr)) cc3.add(new ChunkCoordinates(x, y - 1, z)); - ; - if (z < (range << 1) && !(map[x][z + 1].isAdded(y) || map[x][z + 1].distance > rangeSqr || map[x][z + 1].distance < map[x][z].distance)) cc3.add(new ChunkCoordinates(x, y, z + 1)); - if (z > 0 && !(map[x][z - 1].isAdded(y) || map[x][z - 1].distance > rangeSqr || map[x][z - 1].distance < map[x][z].distance)) cc3.add(new ChunkCoordinates(x, y, z - 1)); - } else { - boolean ok = false; - if (z > 0 && !(map[x][z - 1].isAdded(y) || map[x][z - 1].distance > rangeSqr || map[x][z - 1].distance < map[x][z].distance)) { - for (int i = 0; i < 16 && !ok; i++) { - for (int l = 0; l < 16 && !ok; l++) { - if (!isBlockNormalCubeDefault(c, l, (y << 4) + i, 0, false)) ok = true; - } - } - if (ok) { - cc3.add(new ChunkCoordinates(x, y, z - 1)); - } - ok = false; - } - if (z < (range << 1) && !(map[x][z + 1].isAdded(y) || map[x][z + 1].distance > rangeSqr || map[x][z + 1].distance < map[x][z].distance)) { - for (int i = 0; i < 16 && !ok; i++) { - for (int l = 0; l < 16 && !ok; l++) { - if (!isBlockNormalCubeDefault(c, l, (y << 4) + i, 15, false)) ok = true; - } - } - if (ok) { - cc3.add(new ChunkCoordinates(x, y, z + 1)); - } - ok = false; - } - if (y > 0 && !(map[x][z].isAdded(y - 1) || map[x][z].distance > rangeSqr)) { - for (int i = 0; i < 16 && !ok; i++) { - for (int l = 0; l < 16 && !ok; l++) { - if (!isBlockNormalCubeDefault(c, l, (y << 4), i, false)) ok = true; - } - } - if (ok) { - cc3.add(new ChunkCoordinates(x, y - 1, z)); - } - ok = false; - } - if (y < 15 && !(map[x][z].isAdded(y + 1) || map[x][z].distance > rangeSqr)) { - for (int i = 0; i < 16 && !ok; i++) { - for (int l = 0; l < 16 && !ok; l++) { - if (!isBlockNormalCubeDefault(c, l, (y << 4) + 15, i, false)) ok = true; - } - } - if (ok) { - cc3.add(new ChunkCoordinates(x, y + 1, z)); - } - ok = false; - } - if (x > 0 && !(map[x - 1][z].isAdded(y) || map[x - 1][z].distance > rangeSqr || map[x - 1][z].distance < map[x][z].distance)) { - for (int i = 0; i < 16 && !ok; i++) { - for (int l = 0; l < 16 && !ok; l++) { - if (!isBlockNormalCubeDefault(c, 0, (y << 4) + l, i, false)) ok = true; - } - } - if (ok) { - cc3.add(new ChunkCoordinates(x - 1, y, z)); - } - ok = false; - } - if (x < (range << 1) && !(map[x + 1][z].isAdded(y) || map[x + 1][z].distance > rangeSqr || map[x + 1][z].distance < map[x][z].distance)) { - for (int i = 0; i < 16 && !ok; i++) { - for (int l = 0; l < 16 && !ok; l++) { - if (!isBlockNormalCubeDefault(c, 15, (y << 4) + l, i, false)) ok = true; - } - } - if (ok) { - cc3.add(new ChunkCoordinates(x + 1, y, z)); - } - } - } - return cc3; - } + /** + * Recursive function to find all chunk segments attached to the surface. + */ + private static List scan(IChunkProvider chunkProvider, ChunkData[][] map, ChunkCoordinates coord, + int range) { + int rangeSqr = range * range; + List cc3 = new LinkedList(); + int x = coord.posX; + int y = coord.posY; + int z = coord.posZ; + ChunkData data = map[x][z]; + if (data.isAdded(y) || data.distance > rangeSqr) return cc3; + data.add(y); + Chunk c = chunkProvider.provideChunk(data.x, data.z); + if (!c.isChunkLoaded) { + c = chunkProvider.loadChunk(data.x, data.z); + } + if (c.getAreLevelsEmpty(y << 4, (y << 4) + 15)) { + data.empty(y); + if (x < (range << 1) && !(map[x + 1][z].isAdded(y) || map[x + 1][z].distance > rangeSqr + || map[x + 1][z].distance < map[x][z].distance)) cc3.add(new ChunkCoordinates(x + 1, y, z)); + if (x > 0 && !(map[x - 1][z].isAdded(y) || map[x - 1][z].distance > rangeSqr + || map[x - 1][z].distance < map[x][z].distance)) cc3.add(new ChunkCoordinates(x - 1, y, z)); + if (y < 15 && !(map[x][z].isAdded(y + 1) || map[x][z].distance > rangeSqr)) + cc3.add(new ChunkCoordinates(x, y + 1, z)); + if (y > 0 && !(map[x][z].isAdded(y - 1) || map[x][z].distance > rangeSqr)) + cc3.add(new ChunkCoordinates(x, y - 1, z));; + if (z < (range << 1) && !(map[x][z + 1].isAdded(y) || map[x][z + 1].distance > rangeSqr + || map[x][z + 1].distance < map[x][z].distance)) cc3.add(new ChunkCoordinates(x, y, z + 1)); + if (z > 0 && !(map[x][z - 1].isAdded(y) || map[x][z - 1].distance > rangeSqr + || map[x][z - 1].distance < map[x][z].distance)) cc3.add(new ChunkCoordinates(x, y, z - 1)); + } else { + boolean ok = false; + if (z > 0 && !(map[x][z - 1].isAdded(y) || map[x][z - 1].distance > rangeSqr + || map[x][z - 1].distance < map[x][z].distance)) { + for (int i = 0; i < 16 && !ok; i++) { + for (int l = 0; l < 16 && !ok; l++) { + if (!isBlockNormalCubeDefault(c, l, (y << 4) + i, 0, false)) ok = true; + } + } + if (ok) { + cc3.add(new ChunkCoordinates(x, y, z - 1)); + } + ok = false; + } + if (z < (range << 1) && !(map[x][z + 1].isAdded(y) || map[x][z + 1].distance > rangeSqr + || map[x][z + 1].distance < map[x][z].distance)) { + for (int i = 0; i < 16 && !ok; i++) { + for (int l = 0; l < 16 && !ok; l++) { + if (!isBlockNormalCubeDefault(c, l, (y << 4) + i, 15, false)) ok = true; + } + } + if (ok) { + cc3.add(new ChunkCoordinates(x, y, z + 1)); + } + ok = false; + } + if (y > 0 && !(map[x][z].isAdded(y - 1) || map[x][z].distance > rangeSqr)) { + for (int i = 0; i < 16 && !ok; i++) { + for (int l = 0; l < 16 && !ok; l++) { + if (!isBlockNormalCubeDefault(c, l, (y << 4), i, false)) ok = true; + } + } + if (ok) { + cc3.add(new ChunkCoordinates(x, y - 1, z)); + } + ok = false; + } + if (y < 15 && !(map[x][z].isAdded(y + 1) || map[x][z].distance > rangeSqr)) { + for (int i = 0; i < 16 && !ok; i++) { + for (int l = 0; l < 16 && !ok; l++) { + if (!isBlockNormalCubeDefault(c, l, (y << 4) + 15, i, false)) ok = true; + } + } + if (ok) { + cc3.add(new ChunkCoordinates(x, y + 1, z)); + } + ok = false; + } + if (x > 0 && !(map[x - 1][z].isAdded(y) || map[x - 1][z].distance > rangeSqr + || map[x - 1][z].distance < map[x][z].distance)) { + for (int i = 0; i < 16 && !ok; i++) { + for (int l = 0; l < 16 && !ok; l++) { + if (!isBlockNormalCubeDefault(c, 0, (y << 4) + l, i, false)) ok = true; + } + } + if (ok) { + cc3.add(new ChunkCoordinates(x - 1, y, z)); + } + ok = false; + } + if (x < (range << 1) && !(map[x + 1][z].isAdded(y) || map[x + 1][z].distance > rangeSqr + || map[x + 1][z].distance < map[x][z].distance)) { + for (int i = 0; i < 16 && !ok; i++) { + for (int l = 0; l < 16 && !ok; l++) { + if (!isBlockNormalCubeDefault(c, 15, (y << 4) + l, i, false)) ok = true; + } + } + if (ok) { + cc3.add(new ChunkCoordinates(x + 1, y, z)); + } + } + } + return cc3; + } - public static boolean isBlockNormalCubeDefault(Chunk chunk, int par1, int par2, int par3, boolean par4) { - if (par1 >= -30000000 && par3 >= -30000000 && par1 < 30000000 && par3 < 30000000) { - if (chunk != null && !chunk.isEmpty()) { - Block block = chunk.getBlock(par1 & 15, par2, par3 & 15); - return block.isNormalCube(); - } - } - return par4; - } + public static boolean isBlockNormalCubeDefault(Chunk chunk, int par1, int par2, int par3, boolean par4) { + if (par1 >= -30000000 && par3 >= -30000000 && par1 < 30000000 && par3 < 30000000) { + if (chunk != null && !chunk.isEmpty()) { + Block block = chunk.getBlock(par1 & 15, par2, par3 & 15); + return block.isNormalCube(); + } + } + return par4; + } - public class ChunkData implements Comparable { - public int x; - public int z; - public int added; - public int empty; - public int distance; + public class ChunkData implements Comparable { - public ChunkData(int x, int z) { - this.x = x; - this.z = z; - added = 0; - } + public int x; + public int z; + public int added; + public int empty; + public int distance; - public boolean isAdded(int level) { - return (added & (1 << level)) != 0; - } + public ChunkData(int x, int z) { + this.x = x; + this.z = z; + added = 0; + } - public boolean doAdd() { - return (added ^ empty) != 0; - } + public boolean isAdded(int level) { + return (added & (1 << level)) != 0; + } - public boolean doAdd(int level) { - return isAdded(level) && !isEmpty(level); - } + public boolean doAdd() { + return (added ^ empty) != 0; + } - public void add(int level) { - added |= 1 << level; - } + public boolean doAdd(int level) { + return isAdded(level) && !isEmpty(level); + } - public boolean isEmpty(int level) { - return (empty & (1 << level)) == 0; - } + public void add(int level) { + added |= 1 << level; + } - public void empty(int level) { - empty |= 1 << level; - } + public boolean isEmpty(int level) { + return (empty & (1 << level)) == 0; + } - public int levels() { - return added ^ empty; - } + public void empty(int level) { + empty |= 1 << level; + } - @Override - public int compareTo(ChunkData arg0) { + public int levels() { + return added ^ empty; + } - return this.distance - arg0.distance; - } - } + @Override + public int compareTo(ChunkData arg0) { + + return this.distance - arg0.distance; + } + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/proxyworld/ChunkFinderManager.java b/src/main/java/com/xcompwiz/lookingglass/proxyworld/ChunkFinderManager.java index 6491a7d..f8b44f9 100644 --- a/src/main/java/com/xcompwiz/lookingglass/proxyworld/ChunkFinderManager.java +++ b/src/main/java/com/xcompwiz/lookingglass/proxyworld/ChunkFinderManager.java @@ -7,24 +7,26 @@ * @author Ken Butler/shadowking97 */ public class ChunkFinderManager { - public static ChunkFinderManager instance = new ChunkFinderManager(); - private List finders; + public static ChunkFinderManager instance = new ChunkFinderManager(); - public ChunkFinderManager() { - finders = new LinkedList(); - } + private List finders; - public void addFinder(ChunkFinder f) { - finders.add(f); - } + public ChunkFinderManager() { + finders = new LinkedList(); + } - public void tick() { - for (int i = 0; i < finders.size(); ++i) { - if (finders.get(i).findChunks()) { - finders.remove(i); - --i; - } - } - } + public void addFinder(ChunkFinder f) { + finders.add(f); + } + + public void tick() { + for (int i = 0; i < finders.size(); ++i) { + if (finders.get(i) + .findChunks()) { + finders.remove(i); + --i; + } + } + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/proxyworld/LookingGlassEventHandler.java b/src/main/java/com/xcompwiz/lookingglass/proxyworld/LookingGlassEventHandler.java index 3178688..4117ad0 100644 --- a/src/main/java/com/xcompwiz/lookingglass/proxyworld/LookingGlassEventHandler.java +++ b/src/main/java/com/xcompwiz/lookingglass/proxyworld/LookingGlassEventHandler.java @@ -1,119 +1,122 @@ -package com.xcompwiz.lookingglass.proxyworld; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintStream; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; - -import com.xcompwiz.lookingglass.client.proxyworld.ProxyWorldManager; -import com.xcompwiz.lookingglass.log.LoggerUtils; -import com.xcompwiz.lookingglass.render.PerspectiveRenderManager; -import com.xcompwiz.lookingglass.render.WorldViewRenderManager; - -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent; -import cpw.mods.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * This class handles the FML events. Primarily it is used to listen for tick events. - */ -public class LookingGlassEventHandler { - - /** An output stream we can use for proxy world logging */ - private final PrintStream printstream; - - /** The client world as we last saw it. We use this to check if the client has changed worlds */ - @SideOnly(Side.CLIENT) - private WorldClient previousWorld; - - /** A simple accumulator to handle triggering freeing world views and such */ - @SideOnly(Side.CLIENT) - private int tickcounter; - - public LookingGlassEventHandler(File logfile) { - PrintStream stream = null; - try { - stream = new PrintStream(logfile); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } finally { - printstream = stream; - } - if (printstream == null) throw new RuntimeException("Could not set up debug exception logger file for Proxy World system"); - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onClientTick(TickEvent.ClientTickEvent event) { - Minecraft mc = Minecraft.getMinecraft(); - // If no client world we're not playing. Abort. - if (mc.theWorld == null) return; - // We don't want to tick twice per tick loop. Just once. We chose to tick at the start of the tick loop. - if (event.phase != TickEvent.Phase.START) return; - - // Every now and then we want to check to see if there are frame buffers we could free - if (++this.tickcounter % 200 == 0) ProxyWorldManager.detectFreedWorldViews(); - - // Handle whenever the client world has changed since we last looked - if (mc.theWorld != previousWorld) { - // We need to handle the removal of the old world. Particularly, the player will still be visible in it. - // We may consider replacing the old client world with a new proxy world. - if (previousWorld != null) previousWorld.removeAllEntities(); //TODO: This is hardly an ideal solution (It also doesn't seem to work well) - previousWorld = mc.theWorld; // At this point we can safely assert that the client world has changed - - // We let our local world manager know that the client world changed. - ProxyWorldManager.handleWorldChange(mc.theWorld); - } - - // Tick loop for our own worlds. - WorldClient worldBackup = mc.theWorld; - for (WorldClient proxyworld : ProxyWorldManager.getProxyworlds()) { - if (proxyworld.lastLightningBolt > 0) --proxyworld.lastLightningBolt; - if (worldBackup == proxyworld) continue; // This prevents us from double ticking the client world. - try { - mc.theWorld = proxyworld; - //TODO: relays for views (renderGlobal and effectRenderer) (See ProxyWorld.makeFireworks ln23) - proxyworld.tick(); - } catch (Exception e) { - LoggerUtils.error("Client Proxy Dim had error while ticking: %s", e.getLocalizedMessage()); - e.printStackTrace(printstream); - } - } - mc.theWorld = worldBackup; - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent event) { - // If no client world we're not playing. Abort. - if (Minecraft.getMinecraft().theWorld == null) return; - if (event.phase == TickEvent.Phase.START) { - // Anything we need to render for the current frame should happen either during or before the main world render - // Here we call the renderer for "live portal" renders. - PerspectiveRenderManager.onRenderTick(printstream); - return; - } - if (event.phase == TickEvent.Phase.END) { - // We render the world views at the end of the render tick. - WorldViewRenderManager.onRenderTick(printstream); - return; - } - } - - @SubscribeEvent - public void onServerTick(TickEvent.ServerTickEvent event) { - if (event.phase != TickEvent.Phase.END) return; - // On server ticks we try to send clients who need chunk data some of that data they need - ChunkFinderManager.instance.tick(); - } - - @SubscribeEvent - public void onClientDisconnect(ClientDisconnectionFromServerEvent event) { - // Abandon ship! - ProxyWorldManager.clearProxyworlds(); - } -} +package com.xcompwiz.lookingglass.proxyworld; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintStream; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; + +import com.xcompwiz.lookingglass.client.proxyworld.ProxyWorldManager; +import com.xcompwiz.lookingglass.log.LoggerUtils; +import com.xcompwiz.lookingglass.render.PerspectiveRenderManager; +import com.xcompwiz.lookingglass.render.WorldViewRenderManager; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * This class handles the FML events. Primarily it is used to listen for tick events. + */ +public class LookingGlassEventHandler { + + /** An output stream we can use for proxy world logging */ + private final PrintStream printstream; + + /** The client world as we last saw it. We use this to check if the client has changed worlds */ + @SideOnly(Side.CLIENT) + private WorldClient previousWorld; + + /** A simple accumulator to handle triggering freeing world views and such */ + @SideOnly(Side.CLIENT) + private int tickcounter; + + public LookingGlassEventHandler(File logfile) { + PrintStream stream = null; + try { + stream = new PrintStream(logfile); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } finally { + printstream = stream; + } + if (printstream == null) + throw new RuntimeException("Could not set up debug exception logger file for Proxy World system"); + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onClientTick(TickEvent.ClientTickEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + // If no client world we're not playing. Abort. + if (mc.theWorld == null) return; + // We don't want to tick twice per tick loop. Just once. We chose to tick at the start of the tick loop. + if (event.phase != TickEvent.Phase.START) return; + + // Every now and then we want to check to see if there are frame buffers we could free + if (++this.tickcounter % 200 == 0) ProxyWorldManager.detectFreedWorldViews(); + + // Handle whenever the client world has changed since we last looked + if (mc.theWorld != previousWorld) { + // We need to handle the removal of the old world. Particularly, the player will still be visible in it. + // We may consider replacing the old client world with a new proxy world. + if (previousWorld != null) previousWorld.removeAllEntities(); // TODO: This is hardly an ideal solution (It + // also doesn't seem to work well) + previousWorld = mc.theWorld; // At this point we can safely assert that the client world has changed + + // We let our local world manager know that the client world changed. + ProxyWorldManager.handleWorldChange(mc.theWorld); + } + + // Tick loop for our own worlds. + WorldClient worldBackup = mc.theWorld; + for (WorldClient proxyworld : ProxyWorldManager.getProxyworlds()) { + if (proxyworld.lastLightningBolt > 0) --proxyworld.lastLightningBolt; + if (worldBackup == proxyworld) continue; // This prevents us from double ticking the client world. + try { + mc.theWorld = proxyworld; + // TODO: relays for views (renderGlobal and effectRenderer) (See ProxyWorld.makeFireworks ln23) + proxyworld.tick(); + } catch (Exception e) { + LoggerUtils.error("Client Proxy Dim had error while ticking: %s", e.getLocalizedMessage()); + e.printStackTrace(printstream); + } + } + mc.theWorld = worldBackup; + } + + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent event) { + // If no client world we're not playing. Abort. + if (Minecraft.getMinecraft().theWorld == null) return; + if (event.phase == TickEvent.Phase.START) { + // Anything we need to render for the current frame should happen either during or before the main world + // render + // Here we call the renderer for "live portal" renders. + PerspectiveRenderManager.onRenderTick(printstream); + return; + } + if (event.phase == TickEvent.Phase.END) { + // We render the world views at the end of the render tick. + WorldViewRenderManager.onRenderTick(printstream); + return; + } + } + + @SubscribeEvent + public void onServerTick(TickEvent.ServerTickEvent event) { + if (event.phase != TickEvent.Phase.END) return; + // On server ticks we try to send clients who need chunk data some of that data they need + ChunkFinderManager.instance.tick(); + } + + @SubscribeEvent + public void onClientDisconnect(ClientDisconnectionFromServerEvent event) { + // Abandon ship! + ProxyWorldManager.clearProxyworlds(); + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/proxyworld/ModConfigs.java b/src/main/java/com/xcompwiz/lookingglass/proxyworld/ModConfigs.java index a4a78c9..6396ce2 100644 --- a/src/main/java/com/xcompwiz/lookingglass/proxyworld/ModConfigs.java +++ b/src/main/java/com/xcompwiz/lookingglass/proxyworld/ModConfigs.java @@ -1,29 +1,31 @@ -package com.xcompwiz.lookingglass.proxyworld; - -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; - -public class ModConfigs { - private static final String CATAGORY_SERVER = "server"; - - public static boolean disabled = false; - - public static int dataRate = 2048; - - public static byte renderDistance = 7; - - public static void loadConfigs(Configuration config) { - Property off = config.get(CATAGORY_SERVER, "disabled", disabled); - off.comment = "On the client this disables other world renders entirely, preventing world requests. On the server this disables sending world info to all clients."; - disabled = off.getBoolean(disabled); - - Property d = config.get(CATAGORY_SERVER, "datarate", dataRate); - d.comment = "The number of bytes to send per tick before the server cuts off sending. Only applies to other-world chunks. Default: " + dataRate; - dataRate = d.getInt(dataRate); - - if (dataRate <= 0) disabled = true; - - if (config.hasChanged()) config.save(); - } - -} +package com.xcompwiz.lookingglass.proxyworld; + +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; + +public class ModConfigs { + + private static final String CATAGORY_SERVER = "server"; + + public static boolean disabled = false; + + public static int dataRate = 2048; + + public static byte renderDistance = 7; + + public static void loadConfigs(Configuration config) { + Property off = config.get(CATAGORY_SERVER, "disabled", disabled); + off.comment = "On the client this disables other world renders entirely, preventing world requests. On the server this disables sending world info to all clients."; + disabled = off.getBoolean(disabled); + + Property d = config.get(CATAGORY_SERVER, "datarate", dataRate); + d.comment = "The number of bytes to send per tick before the server cuts off sending. Only applies to other-world chunks. Default: " + + dataRate; + dataRate = d.getInt(dataRate); + + if (dataRate <= 0) disabled = true; + + if (config.hasChanged()) config.save(); + } + +} diff --git a/src/main/java/com/xcompwiz/lookingglass/proxyworld/SubChunkUtils.java b/src/main/java/com/xcompwiz/lookingglass/proxyworld/SubChunkUtils.java index ce28159..c1b3d00 100644 --- a/src/main/java/com/xcompwiz/lookingglass/proxyworld/SubChunkUtils.java +++ b/src/main/java/com/xcompwiz/lookingglass/proxyworld/SubChunkUtils.java @@ -1,35 +1,36 @@ -package com.xcompwiz.lookingglass.proxyworld; - -import net.minecraft.util.ChunkCoordinates; - -public class SubChunkUtils { - public static final boolean withinDistance(ChunkCoordinates c1, int x, int y, int z, int distance) { - return distance * distance >= c1.getDistanceSquared(x, y, z); - } - - public static final boolean withinDistance(int x, int y, int z, int x2, int y2, int z2, int distance) { - int x3 = x - x2; - int y3 = y - y2; - int z3 = z - z2; - return distance * distance >= x3 * x3 + y3 * y3 + z3 * z3; - } - - public static final boolean withinRange(ChunkCoordinates c1, int x, int y, int z, int d1, int d2) { - float cDistance = c1.getDistanceSquared(x, y, z); - return d2 * d2 >= cDistance && d1 * d1 <= cDistance; - } - - public static final boolean withinDistance2D(int x, int z, int x2, int z2, int distance) { - int x3 = x - x2; - int z3 = z - z2; - int distance2 = x3 * x3 + z3 * z3; - return distance * distance >= distance2; - } - - public static final boolean withinRange2D(int x, int z, int x2, int z2, int d1, int d2) { - int x3 = x - x2; - int z3 = z - z2; - int distance = x3 * x3 + z3 * z3; - return d2 * d2 >= distance && d1 * d1 <= distance; - } -} +package com.xcompwiz.lookingglass.proxyworld; + +import net.minecraft.util.ChunkCoordinates; + +public class SubChunkUtils { + + public static final boolean withinDistance(ChunkCoordinates c1, int x, int y, int z, int distance) { + return distance * distance >= c1.getDistanceSquared(x, y, z); + } + + public static final boolean withinDistance(int x, int y, int z, int x2, int y2, int z2, int distance) { + int x3 = x - x2; + int y3 = y - y2; + int z3 = z - z2; + return distance * distance >= x3 * x3 + y3 * y3 + z3 * z3; + } + + public static final boolean withinRange(ChunkCoordinates c1, int x, int y, int z, int d1, int d2) { + float cDistance = c1.getDistanceSquared(x, y, z); + return d2 * d2 >= cDistance && d1 * d1 <= cDistance; + } + + public static final boolean withinDistance2D(int x, int z, int x2, int z2, int distance) { + int x3 = x - x2; + int z3 = z - z2; + int distance2 = x3 * x3 + z3 * z3; + return distance * distance >= distance2; + } + + public static final boolean withinRange2D(int x, int z, int x2, int z2, int d1, int d2) { + int x3 = x - x2; + int z3 = z - z2; + int distance = x3 * x3 + z3 * z3; + return d2 * d2 >= distance && d1 * d1 <= distance; + } +} diff --git a/src/main/java/com/xcompwiz/lookingglass/render/PerspectiveRenderManager.java b/src/main/java/com/xcompwiz/lookingglass/render/PerspectiveRenderManager.java index 08acee4..fd7c4ed 100644 --- a/src/main/java/com/xcompwiz/lookingglass/render/PerspectiveRenderManager.java +++ b/src/main/java/com/xcompwiz/lookingglass/render/PerspectiveRenderManager.java @@ -4,9 +4,9 @@ public class PerspectiveRenderManager { - public static void onRenderTick(PrintStream printstream) { - // TODO: OK, I lied. It doesn't do anything yet. - // I've been testing this in another mod. - } + public static void onRenderTick(PrintStream printstream) { + // TODO: OK, I lied. It doesn't do anything yet. + // I've been testing this in another mod. + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/render/WorldViewRenderManager.java b/src/main/java/com/xcompwiz/lookingglass/render/WorldViewRenderManager.java index 9103b02..1e8a48b 100644 --- a/src/main/java/com/xcompwiz/lookingglass/render/WorldViewRenderManager.java +++ b/src/main/java/com/xcompwiz/lookingglass/render/WorldViewRenderManager.java @@ -19,64 +19,78 @@ import com.xcompwiz.lookingglass.log.LoggerUtils; public class WorldViewRenderManager { - public static void onRenderTick(PrintStream printstream) { - Minecraft mc = Minecraft.getMinecraft(); - Collection worlds = ProxyWorldManager.getProxyworlds(); - if (worlds == null || worlds.isEmpty()) return; - long renderT = Minecraft.getSystemTime(); - //TODO: This and the renderWorldToTexture need to be remixed - WorldClient worldBackup = mc.theWorld; - RenderGlobal renderBackup = mc.renderGlobal; - EffectRenderer effectBackup = mc.effectRenderer; - EntityClientPlayerMP playerBackup = mc.thePlayer; - EntityLivingBase viewportBackup = mc.renderViewEntity; + public static void onRenderTick(PrintStream printstream) { + Minecraft mc = Minecraft.getMinecraft(); + Collection worlds = ProxyWorldManager.getProxyworlds(); + if (worlds == null || worlds.isEmpty()) return; - //TODO: This is a hack to work around some of the vanilla rendering hacks... Yay hacks. - float fovmult = playerBackup.getFOVMultiplier(); - ItemStack currentClientItem = playerBackup.inventory.getCurrentItem(); + long renderT = Minecraft.getSystemTime(); + // TODO: This and the renderWorldToTexture need to be remixed + WorldClient worldBackup = mc.theWorld; + RenderGlobal renderBackup = mc.renderGlobal; + EffectRenderer effectBackup = mc.effectRenderer; + EntityClientPlayerMP playerBackup = mc.thePlayer; + EntityLivingBase viewportBackup = mc.renderViewEntity; - for (WorldClient proxyworld : worlds) { - if (proxyworld == null) continue; - mc.theWorld = proxyworld; - RenderManager.instance.set(mc.theWorld); - for (WorldView activeview : ProxyWorldManager.getWorldViews(proxyworld.provider.dimensionId)) { - if (activeview.hasChunks() && activeview.markClean()) { - activeview.startRender(renderT); + // TODO: This is a hack to work around some of the vanilla rendering hacks... Yay hacks. + float fovmult = playerBackup.getFOVMultiplier(); + ItemStack currentClientItem = playerBackup.inventory.getCurrentItem(); - mc.renderGlobal = activeview.getRenderGlobal(); - mc.effectRenderer = activeview.getEffectRenderer(); - mc.renderViewEntity = activeview.camera; - mc.thePlayer = activeview.camera; - //Other half of hack - activeview.camera.setFOVMult(fovmult); //Prevents the FOV from flickering - activeview.camera.inventory.currentItem = playerBackup.inventory.currentItem; - activeview.camera.inventory.mainInventory[playerBackup.inventory.currentItem] = currentClientItem; //Prevents the hand from flickering + for (WorldClient proxyworld : worlds) { + if (proxyworld == null) continue; + mc.theWorld = proxyworld; + RenderManager.instance.set(mc.theWorld); + for (WorldView activeview : ProxyWorldManager.getWorldViews(proxyworld.provider.dimensionId)) { + if (activeview.hasChunks() && activeview.markClean()) { + activeview.startRender(renderT); - try { - mc.renderGlobal.updateClouds(); - mc.theWorld.doVoidFogParticles(MathHelper.floor_double(activeview.camera.posX), MathHelper.floor_double(activeview.camera.posY), MathHelper.floor_double(activeview.camera.posZ)); - mc.effectRenderer.updateEffects(); - } catch (Exception e) { - LoggerUtils.error("Client Proxy Dim had error while updating render elements: %s", e.getLocalizedMessage()); - e.printStackTrace(printstream); - } + mc.renderGlobal = activeview.getRenderGlobal(); + mc.effectRenderer = activeview.getEffectRenderer(); + mc.renderViewEntity = activeview.camera; + mc.thePlayer = activeview.camera; + // Other half of hack + activeview.camera.setFOVMult(fovmult); // Prevents the FOV from flickering + activeview.camera.inventory.currentItem = playerBackup.inventory.currentItem; + activeview.camera.inventory.mainInventory[playerBackup.inventory.currentItem] = currentClientItem; // Prevents + // the + // hand + // from + // flickering - try { - RenderUtils.renderWorldToTexture(0.1f, activeview.getFramebuffer(), activeview.width, activeview.height); - } catch (Exception e) { - LoggerUtils.error("Client Proxy Dim had error while rendering: %s", e.getLocalizedMessage()); - e.printStackTrace(printstream); - } - } - } - } - mc.renderViewEntity = viewportBackup; - mc.thePlayer = playerBackup; - mc.effectRenderer = effectBackup; - mc.renderGlobal = renderBackup; - mc.theWorld = worldBackup; - RenderManager.instance.set(mc.theWorld); - } + try { + mc.renderGlobal.updateClouds(); + mc.theWorld.doVoidFogParticles( + MathHelper.floor_double(activeview.camera.posX), + MathHelper.floor_double(activeview.camera.posY), + MathHelper.floor_double(activeview.camera.posZ)); + mc.effectRenderer.updateEffects(); + } catch (Exception e) { + LoggerUtils.error( + "Client Proxy Dim had error while updating render elements: %s", + e.getLocalizedMessage()); + e.printStackTrace(printstream); + } + + try { + RenderUtils.renderWorldToTexture( + 0.1f, + activeview.getFramebuffer(), + activeview.width, + activeview.height); + } catch (Exception e) { + LoggerUtils.error("Client Proxy Dim had error while rendering: %s", e.getLocalizedMessage()); + e.printStackTrace(printstream); + } + } + } + } + mc.renderViewEntity = viewportBackup; + mc.thePlayer = playerBackup; + mc.effectRenderer = effectBackup; + mc.renderGlobal = renderBackup; + mc.theWorld = worldBackup; + RenderManager.instance.set(mc.theWorld); + } } diff --git a/src/main/java/com/xcompwiz/lookingglass/utils/MathUtils.java b/src/main/java/com/xcompwiz/lookingglass/utils/MathUtils.java index cb8b01b..e4a3d77 100644 --- a/src/main/java/com/xcompwiz/lookingglass/utils/MathUtils.java +++ b/src/main/java/com/xcompwiz/lookingglass/utils/MathUtils.java @@ -1,13 +1,14 @@ -package com.xcompwiz.lookingglass.utils; - -import io.netty.buffer.ByteBuf; -import net.minecraft.util.Vec3; - -public class MathUtils { - - public static Vec3 readCoordinates(ByteBuf data) { - Vec3 coords = Vec3.createVectorHelper(data.readDouble(), data.readDouble(), data.readDouble()); - return coords; - } - -} +package com.xcompwiz.lookingglass.utils; + +import net.minecraft.util.Vec3; + +import io.netty.buffer.ByteBuf; + +public class MathUtils { + + public static Vec3 readCoordinates(ByteBuf data) { + Vec3 coords = Vec3.createVectorHelper(data.readDouble(), data.readDouble(), data.readDouble()); + return coords; + } + +} diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index fa3015c..f6da75c 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,16 +1,21 @@ -[ { - "modid": "LookingGlass", - "name": "Looking Glass", - "description": "\"In another moment Alice was through the glass, and had jumped lightly down into the Looking-glass room.\" - Through the Looking-Glass, and What Alice Found There; Lewis Carroll", - "version": "${version}", - "mcversion": "${mcversion}", - "url": "http://xcompwiz.com", - "updateUrl": "", - "authorList": ["XCompWiz"], - "credits": "shadowking97, for following the plan in my head", - "logoFile": "/logo.png", - "screenshots": [], - "dependencies": [] + "modListVersion": 2, + "modList": [{ + "modid": "${modId}", + "name": "${modName}", + "description": "\"In another moment Alice was through the glass, and had jumped lightly down into the Looking-glass room.\" - Through the Looking-Glass, and What Alice Found There; Lewis Carroll", + "version": "${modVersion}", + "mcversion": "${minecraftVersion}", + "url": "https://github.com/Pilzinsel64/LookingGlass", + "updateUrl": "", + "authorList": ["Pilzinsel64", "XCompWiz"], + "credits": "", + "logoFile": "/logo.png", + "screenshots": [], + "parent": "", + "requiredMods": [], + "dependencies": [], + "dependants": [], + "useDependencyInformation": false + }] } -]