Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast chunk loading/generation #360

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ dependencies {
transformedModCompileOnly(deobf("https://forum.industrial-craft.net/core/attachment/4316-advancedsolarpanel-1-7-10-3-5-1-jar/"))

runtimeOnly(deobf("https://github.com/makamys/CoreTweaks/releases/download/0.3.3.2/CoreTweaks-1.7.10-0.3.3.2+nomixin.jar"))
runtimeOnlyNonPublishable(deobfCurse("bsprint-227409:2725690"))
runtimeOnlyNonPublishable("com.github.GTNewHorizons:Angelica:1.0.0-alpha47")
}

// Replace when RFG support deobfuscation from notch mappings
Expand Down
191 changes: 191 additions & 0 deletions dependencies.gradle.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
configurations {
transformedMod // Mods that can be transformed - used for compiling hodgepodge, but not necessary at runtime
transformedMod.canBeConsumed = false
transformedModCompileOnly
transformedModCompileOnly.canBeConsumed = false

// Add the transformed mod dependencies to the compilation and runtime classpaths, but don't publish them in the Maven metadata
compileClasspath.extendsFrom(transformedMod, transformedModCompileOnly)
runtimeClasspath.extendsFrom(transformedMod)
testCompileClasspath.extendsFrom(transformedMod, transformedModCompileOnly)
testRuntimeClasspath.extendsFrom(transformedMod)
}

dependencies {
api("com.github.GTNewHorizons:GTNHLib:0.2.11:dev")

<<<<<<< HEAD
transformedMod("com.github.GTNewHorizons:NotEnoughItems:2.5.25-GTNH:dev") // force a more up-to-date NEI version
transformedModCompileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-346-GTNH")
transformedModCompileOnly("com.github.GTNewHorizons:Baubles:1.0.4:dev")
// Transitive updates to make runClient17 work
transformedModCompileOnly("com.github.GTNewHorizons:ForgeMultipart:1.4.8:dev")
transformedModCompileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.45.132:dev")
transformedModCompileOnly("com.github.GTNewHorizons:harvestcraft:1.1.10-GTNH:dev")
transformedModCompileOnly("com.github.GTNewHorizons:HungerOverhaul:1.1.0-GTNH:dev")
transformedModCompileOnly("com.github.GTNewHorizons:MrTJPCore:1.1.7:dev") // Do not update, fixed afterwards
transformedModCompileOnly("com.github.GTNewHorizons:Railcraft:9.15.7:dev") { exclude group: "thaumcraft", module: "Thaumcraft" }
transformedModCompileOnly("com.github.GTNewHorizons:TinkersConstruct:1.11.13-GTNH:dev")
=======
compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:1.0.2") { transitive = false }

transformedMod("com.github.GTNewHorizons:NotEnoughItems:2.5.27-GTNH:dev") // force a more up-to-date NEI version
transformedModCompileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-352-GTNH")
transformedModCompileOnly("com.github.GTNewHorizons:Baubles:1.0.4:dev")
// Transitive updates to make runClient17 work
transformedModCompileOnly("com.github.GTNewHorizons:ForgeMultipart:1.4.8:dev")
transformedModCompileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.45.163:dev")
transformedModCompileOnly("com.github.GTNewHorizons:harvestcraft:1.1.10-GTNH:dev")
transformedModCompileOnly("com.github.GTNewHorizons:HungerOverhaul:1.1.0-GTNH:dev")
transformedModCompileOnly("com.github.GTNewHorizons:MrTJPCore:1.1.7:dev") // Do not update, fixed afterwards
transformedModCompileOnly("com.github.GTNewHorizons:Railcraft:9.15.8:dev") { exclude group: "thaumcraft", module: "Thaumcraft" }
transformedModCompileOnly("com.github.GTNewHorizons:TinkersConstruct:1.11.15-GTNH:dev")
>>>>>>> origin/master
transformedModCompileOnly(deobfCurse("bibliocraft-228027:2423369"))
transformedModCompileOnly("curse.maven:biomes-o-plenty-220318:2499612")
transformedModCompileOnly("curse.maven:cofh-core-69162:2388751")
transformedModCompileOnly("curse.maven:minefactory-reloaded-66672:2277486")
transformedModCompileOnly(deobfCurse('damage-indicators-mod-59489:2692129'))
transformedModCompileOnly("curse.maven:extra-utilities-225561:2264384")
transformedModCompileOnly(deobfCurse("extratic-72728:2299292"))
transformedModCompileOnly(deobfCurse("journeymap-32274:4500658"))
transformedModCompileOnly(deobf('https://dist.creeper.host/ichun/filespg/PortalGun-4.0.0-beta-6.jar'))
transformedModCompileOnly("curse.maven:travellers-gear-224440:2262113")
transformedModCompileOnly(deobfCurse("witchery-69673:2234410"))
transformedModCompileOnly(deobfCurse("ztones-224369:2223720"))
transformedModCompileOnly("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
transformedModCompileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")

transformedModCompileOnly(deobfCurse("automagy-222153:2285272"))
transformedModCompileOnly("com.github.GTNewHorizons:Galacticraft:3.1.5-GTNH:dev")
transformedModCompileOnly("curse.maven:minechem-368422:2905830")
transformedModCompileOnly("curse.maven:thermal-dynamics-227443:2388756")
transformedModCompileOnly("curse.maven:thermal-expansion-69163:2388759")
transformedModCompileOnly(deobfCurse("projecte-226410:2340786"))
transformedModCompileOnly(deobfCurse("better-hud-286066:2523840"))
transformedModCompileOnly("curse.maven:immersive-engineering-231951:2299019")
// Contains an outdated copy of thaumcraft api that breaks class loading at runtime
transformedModCompileOnly(deobfCurse("pams-harvest-the-nether-231262:2241397"))
transformedModCompileOnly(deobfCurse("the-lord-of-the-rings-mod-legacy-423748:4091561"))
transformedModCompileOnly(deobfNotch("https://mediafiles.forgecdn.net/files/2462/146/mod_voxelMap_1.7.0b_for_1.7.10.litemod"))
transformedModCompileOnly(deobfCurse("xaeros-world-map-317780:4716737"))
transformedModCompileOnly(deobf("https://forum.industrial-craft.net/core/attachment/4316-advancedsolarpanel-1-7-10-3-5-1-jar/"))

runtimeOnly(deobf("https://github.com/makamys/CoreTweaks/releases/download/0.3.3.2/CoreTweaks-1.7.10-0.3.3.2+nomixin.jar"))
runtimeOnlyNonPublishable(deobfCurse("bsprint-227409:2725690"))
runtimeOnlyNonPublishable("com.github.GTNewHorizons:Angelica:1.0.0-alpha35")
}

// Replace when RFG support deobfuscation from notch mappings

import java.nio.file.Files
import java.nio.file.Paths
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream

def deobfNotch(String sourceURL) {
try {
URL url = new URL(sourceURL)
String fileName = url.getFile()

//get rid of directories:
int lastSlash = fileName.lastIndexOf("/")
if (lastSlash > 0) {
fileName = fileName.substring(lastSlash + 1)
}
//get rid of extension:
if (fileName.endsWith(".jar") || fileName.endsWith(".litemod")) {
fileName = fileName.substring(0, fileName.lastIndexOf("."))
}

String hostName = url.getHost()
if (hostName.startsWith("www.")) {
hostName = hostName.substring(4)
}
List parts = Arrays.asList(hostName.split("\\."))
Collections.reverse(parts)
hostName = String.join(".", parts)

return deobfNotch(sourceURL, "$hostName/$fileName")
} catch (Exception ignored) {
return deobfNotch(sourceURL, "deobf/${sourceURL.hashCode()}")
}
}

def deobfNotch(String sourceURL, String rawFileName) {
String bon2Version = "2.5.1"
String fileName = URLDecoder.decode(rawFileName, "UTF-8")
String cacheDir = "$project.gradle.gradleUserHomeDir/caches"
String bon2Dir = "$cacheDir/forge_gradle/deobf"
String bon2File = "$bon2Dir/BON2-${bon2Version}.jar"
String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar"
String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar"

if (file(deobfFile).exists()) {
return files(deobfFile)
}

String mappingsVer
String remoteMappings = project.hasProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/'
if (remoteMappings) {
String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion"
String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip"

zipMappings(mappingsZIP, remoteMappings, bon2Dir)

mappingsVer = "snapshot_$id"
} else {
mappingsVer = "${channel}_$mappingsVersion"
}

download.run {
src "https://github.com/GTNewHorizons/BON2/releases/download/$bon2Version/BON2-$bon2Version-CUSTOM-all.jar"
dest bon2File
overwrite false
}

download.run {
src sourceURL
dest obfFile
overwrite false
}

exec {
commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch'
workingDir bon2Dir
}

return files(deobfFile)
}

def zipMappings(String zipPath, String url, String bon2Dir) {
File zipFile = new File(zipPath)
if (zipFile.exists()) {
return
}

String fieldsCache = "$bon2Dir/data/fields.csv"
String methodsCache = "$bon2Dir/data/methods.csv"

download.run {
src "${url}fields.csv"
dest fieldsCache
}
download.run {
src "${url}methods.csv"
dest methodsCache
}

zipFile.getParentFile().mkdirs()
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))

zos.putNextEntry(new ZipEntry("fields.csv"))
Files.copy(Paths.get(fieldsCache), zos)
zos.closeEntry()

zos.putNextEntry(new ZipEntry("methods.csv"))
Files.copy(Paths.get(methodsCache), zos)
zos.closeEntry()

zos.close()
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enableModernJavaSyntax = true

# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public static boolean tryCompactMessage(IChatComponent imsg, List<ChatLine> chat
return false;
}

@SuppressWarnings("unchecked")
private static boolean areMessagesIdentical(IChatComponent imsg, IChatComponent prevMsg) {
final int size1 = imsg.getSiblings().size();
final int size2 = prevMsg.getSiblings().size();
Expand All @@ -38,7 +37,7 @@ private static boolean areMessagesIdentical(IChatComponent imsg, IChatComponent
if (!(prevMsg.getSiblings().get(size2 - 1) instanceof ChatComponentCount)) {
return false;
}
final Object removed = prevMsg.getSiblings().remove(size2 - 1);
final IChatComponent removed = prevMsg.getSiblings().remove(size2 - 1);
final boolean equals = imsg.equals(prevMsg);
prevMsg.getSiblings().add(removed);
if (equals) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public class SpeedupsConfig {
@Config.RequiresMcRestart
public static boolean tcpNoDelay;

@Config.Comment("Lightly threads chunk generation, loading, and discarding. Experimental, use at your own risk!")
@Config.DefaultBoolean(false)
@Config.RequiresMcRestart
public static boolean fastChunkHandling;

// Biomes O' Plenty

@Config.Comment("Speedup biome fog rendering in BiomesOPlenty")
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,17 @@ public enum Mixins {
.setSide(Side.BOTH).addTargetedMod(TargetedMod.VANILLA).addMixinClasses("minecraft.MixinBlock_LighterWater")
.setApplyIf(() -> TweaksConfig.useLighterWater)),

FAST_CHUNK_LOADING(new Builder("Lightly threads chunk generation and loading").setPhase(Phase.EARLY)
.setSide(Side.BOTH).addTargetedMod(TargetedMod.VANILLA)
.addMixinClasses(
"minecraft.fastload.MixinIntCache",
"minecraft.fastload.MixinWorldChunkManager",
"minecraft.fastload.MixinWorldServer",
"minecraft.fastload.MixinEntityPlayerMP",
"minecraft.fastload.MixinPlayerManager",
"minecraft.fastload.MixinPlayerInstance")
.setApplyIf(() -> SpeedupsConfig.fastChunkHandling)),

EARLY_CHUNK_TILE_COORDINATE_CHECK(
new Builder("Checks saved TileEntity coordinates earlier to provide a more descriptive error message")
.setPhase(Phase.EARLY).setSide(Side.BOTH).addTargetedMod(TargetedMod.VANILLA)
Expand Down
Loading