Combine all versions into a single tree
This commit is contained in:
257
build.gradle
257
build.gradle
@@ -1,119 +1,39 @@
|
|||||||
import groovy.json.JsonOutput
|
import groovy.json.JsonOutput
|
||||||
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven {
|
|
||||||
name = "forge"
|
|
||||||
url = "http://files.minecraftforge.net/maven"
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
name = "sponge"
|
|
||||||
url = "https://repo.spongepowered.org/maven"
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
name = "sonatype"
|
|
||||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
|
||||||
classpath 'org.spongepowered:mixingradle:0.4-SNAPSHOT'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
|
||||||
apply plugin: 'org.spongepowered.mixin'
|
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
|
||||||
targetCompatibility = 1.8
|
|
||||||
|
|
||||||
version = gitDescribe()
|
version = gitDescribe()
|
||||||
group= "com.replaymod"
|
group= "com.replaymod"
|
||||||
archivesBaseName = "replaymod"
|
|
||||||
|
|
||||||
minecraft {
|
subprojects {
|
||||||
coreMod = 'com.replaymod.core.LoadingPlugin'
|
buildscript {
|
||||||
version = '1.12.2-14.23.0.2486'
|
repositories {
|
||||||
runDir = "eclipse"
|
mavenLocal()
|
||||||
mappings = "snapshot_20170615"
|
mavenCentral()
|
||||||
replace '@MOD_VERSION@', project.version
|
maven {
|
||||||
// Includes intentional whitespace to stop Forge from declaring the mod to be compatible with
|
name = "forge"
|
||||||
// a newer srg-compatible MC version (that may be using a different protocol version)
|
url = "http://files.minecraftforge.net/maven"
|
||||||
replace '@MC_VERSION@', "[ ${project.minecraft.version} ]"
|
}
|
||||||
}
|
maven {
|
||||||
|
name = "sponge"
|
||||||
repositories {
|
url = "https://repo.spongepowered.org/maven"
|
||||||
maven {
|
}
|
||||||
name = "SpongePowered Repo"
|
maven {
|
||||||
url = "http://repo.spongepowered.org/maven/"
|
name = "sonatype"
|
||||||
}
|
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||||
maven { url 'https://jitpack.io' }
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
shade
|
|
||||||
compile.extendsFrom shade
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile 'org.projectlombok:lombok:1.16.4'
|
|
||||||
|
|
||||||
compile 'org.spongepowered:mixin:0.7.5-SNAPSHOT'
|
|
||||||
shade 'com.googlecode.mp4parser:isoparser:1.1.7'
|
|
||||||
shade 'org.apache.commons:commons-exec:1.3'
|
|
||||||
shade 'com.google.apis:google-api-services-youtube:v3-rev178-1.22.0'
|
|
||||||
shade 'com.google.api-client:google-api-client-gson:1.20.0'
|
|
||||||
shade 'com.google.api-client:google-api-client-java6:1.20.0'
|
|
||||||
shade 'com.google.oauth-client:google-oauth-client-jetty:1.20.0'
|
|
||||||
|
|
||||||
shade 'org.aspectj:aspectjrt:1.8.2'
|
|
||||||
|
|
||||||
shade 'com.github.replaymod:ReplayStudio:b040763'
|
|
||||||
|
|
||||||
testCompile 'junit:junit:4.11'
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
||||||
|
|
||||||
dependsOn configurations.compile
|
|
||||||
dependsOn configurations.shade
|
|
||||||
|
|
||||||
def shade = {files(
|
|
||||||
configurations.compile.findAll {it.name.startsWith 'mixin-'}
|
|
||||||
+ configurations.shade
|
|
||||||
)}
|
|
||||||
|
|
||||||
def noticeDir = file("$buildDir/NOTICE")
|
|
||||||
doFirst {
|
|
||||||
noticeDir.deleteDir()
|
|
||||||
noticeDir.mkdirs()
|
|
||||||
shade().collect { it.isDirectory() ? fileTree(it) : zipTree(it) }.each {
|
|
||||||
it.matching { include '**/NOTICE*' }.each {
|
|
||||||
new File(noticeDir, 'NOTICE.txt') << it.getText('UTF-8') + '\n'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
dependencies {
|
||||||
from noticeDir
|
classpath('org.spongepowered:mixingradle:0.6-SNAPSHOT'){
|
||||||
|
// Because forgegradle requires 6.0 (not -debug-all) while mixingradle depends on 5.0
|
||||||
from ({shade().collect { it.isDirectory() ? it : zipTree(it) }}) {
|
// and putting mixin right here will place it before forge in the class loader
|
||||||
exclude '**/NOTICE*'
|
exclude group: 'org.ow2.asm', module: 'asm-debug-all'
|
||||||
// exclude everything taken in from jGui for running the mod in a dev environment
|
|
||||||
exclude { new File(file('jGui/src/main/resources'), it.relativePath.pathString).exists() }
|
|
||||||
eachFile {
|
|
||||||
if (getName() == 'LICENSE.txt') {
|
|
||||||
setName(getFile().getParentFile().getName().split('.jar_')[0] + '-LICENSE.txt')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest {
|
// Thanks for wasting my time gradle...
|
||||||
attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
// Workaround for https://discuss.gradle.org/t/idea-plugin-bug/21525
|
||||||
'TweakOrder': '0',
|
apply plugin: 'eclipse'
|
||||||
'FMLCorePluginContainsFMLMod': 'true',
|
apply plugin: 'idea'
|
||||||
'FMLAT': 'replaymod_at.cfg'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def gitDescribe() {
|
def gitDescribe() {
|
||||||
@@ -129,129 +49,14 @@ def gitDescribe() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources
|
apply from: 'versions/preprocessor.gradle'
|
||||||
{
|
|
||||||
// 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'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
main {
|
|
||||||
// Directly include jGui into main build
|
|
||||||
// This could also be done by including it as a gradle subproject, however
|
|
||||||
// doing so caused classpath issues on some IntelliJ versions.
|
|
||||||
java {
|
|
||||||
srcDir 'jGui/src/main/java'
|
|
||||||
}
|
|
||||||
resources {
|
|
||||||
srcDir 'jGui/src/main/resources'
|
|
||||||
}
|
|
||||||
ext.refMap = "mixins.replaymod.refmap.json"
|
|
||||||
}
|
|
||||||
integrationTest {
|
|
||||||
compileClasspath += main.runtimeClasspath + main.output
|
|
||||||
java {
|
|
||||||
srcDir file('src/integration-test/java')
|
|
||||||
}
|
|
||||||
resources.srcDir file('src/integration-test/resources')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task copySrg(type: Copy, dependsOn: 'genSrgs') {
|
|
||||||
from {project.tasks.genSrgs.mcpToSrg}
|
|
||||||
into 'build'
|
|
||||||
}
|
|
||||||
|
|
||||||
setupDecompWorkspace.dependsOn copySrg
|
|
||||||
setupDevWorkspace.dependsOn copySrg
|
|
||||||
project.tasks.idea.dependsOn copySrg
|
|
||||||
|
|
||||||
|
|
||||||
import org.objectweb.asm.*
|
|
||||||
|
|
||||||
import java.util.zip.ZipEntry
|
|
||||||
import java.util.zip.ZipFile
|
|
||||||
import java.util.zip.ZipOutputStream
|
|
||||||
|
|
||||||
import static org.objectweb.asm.Opcodes.ASM5
|
|
||||||
|
|
||||||
// MC binaries were complied with a java version that produces invalid class files under certain circumstances
|
|
||||||
// This causes setupCIWorkspace to be insufficient for compiling.
|
|
||||||
// Related JDK bug: https://bugs.openjdk.java.net/browse/JDK-8066725
|
|
||||||
// As a workaround, to use setupCIWorkspace on Drone, we modify the bin jar in-place and remove all parameter annotations.
|
|
||||||
// WARNING: This piece of code ignores any and all gradle conventions and will probably fail horribly when run outside
|
|
||||||
// of a single-use environment (e.g. Drone). Use setupDecompWorkspace for normal use.
|
|
||||||
tasks.deobfMcMCP.doLast {
|
|
||||||
println "Applying RuntimeInvisibleParameterAnnotations workaround..."
|
|
||||||
File jar = getOutJar()
|
|
||||||
File tmp = new File((File) getTemporaryDir(), "workaround.jar")
|
|
||||||
tmp.withOutputStream {
|
|
||||||
new ZipOutputStream(it).withStream { dst ->
|
|
||||||
new ZipFile(jar).withCloseable { src ->
|
|
||||||
src.entries().each {
|
|
||||||
if (it.name.startsWith("net/minecraft/") && it.name.endsWith(".class")) {
|
|
||||||
def cw = new ClassWriter(0)
|
|
||||||
def cv = new ClassVisitor(ASM5, cw) {
|
|
||||||
@Override
|
|
||||||
MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
|
||||||
return new MethodVisitor(ASM5, cv.visitMethod(access, name, desc, signature, exceptions)) {
|
|
||||||
@Override
|
|
||||||
AnnotationVisitor visitParameterAnnotation(int parameter, String pdesc, boolean visible) {
|
|
||||||
return null // Strip all parameter annotations
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
new ClassReader(src.getInputStream(it)).accept(cv, 0)
|
|
||||||
dst.putNextEntry(new ZipEntry(it.name))
|
|
||||||
dst.write(cw.toByteArray())
|
|
||||||
} else {
|
|
||||||
dst.putNextEntry(it)
|
|
||||||
dst.write(src.getInputStream(it).bytes)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jar.delete()
|
|
||||||
tmp.renameTo(jar)
|
|
||||||
}
|
|
||||||
|
|
||||||
task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
|
|
||||||
main = 'GradleStart'
|
|
||||||
standardOutput = System.out
|
|
||||||
errorOutput = System.err
|
|
||||||
workingDir file(minecraft.runDir)
|
|
||||||
|
|
||||||
def testDir = new File(minecraft.runDir, "integration-test")
|
|
||||||
doFirst {
|
|
||||||
testDir.deleteDir()
|
|
||||||
testDir.mkdirs()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
task setCoreVersion() {
|
||||||
doLast {
|
doLast {
|
||||||
testDir.deleteDir()
|
def vars = [MC: project.mcVersion as int, DEV_ENV: 1]
|
||||||
}
|
project.convertTree(vars, 'src/main/java')
|
||||||
|
project.convertTree(vars, 'src/main/resources')
|
||||||
afterEvaluate {
|
project.convertTree(vars, 'versions/core/build.gradle')
|
||||||
def runClient = tasks.getByName("runClient")
|
|
||||||
runIntegrationTest.jvmArgs = runClient.jvmArgs + "-Dfml.noGrab=true"
|
|
||||||
runIntegrationTest.args = runClient.args + "--gameDir" + testDir.canonicalPath
|
|
||||||
runIntegrationTest.classpath runClient.classpath + sourceSets.integrationTest.output
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
jGui
2
jGui
Submodule jGui updated: 46c3086257...88cf678236
@@ -1,5 +1,30 @@
|
|||||||
if (System.getenv('REPRODUCIBLE_BUILD') == '1') {
|
if (System.getenv('REPRODUCIBLE_BUILD') == '1') {
|
||||||
rootProject.buildFileName = 'gradle/reprod/tmp/build.gradle'
|
rootProject.buildFileName = 'gradle/reprod/tmp/build.gradle'
|
||||||
} else {
|
}
|
||||||
include 'ReplayStudio'
|
|
||||||
|
include ':jGui'
|
||||||
|
([
|
||||||
|
'core',
|
||||||
|
'1.8',
|
||||||
|
'1.8.9',
|
||||||
|
'1.9.4',
|
||||||
|
'1.12'
|
||||||
|
].collect {":jGui:versions:$it"} as String[]).each {
|
||||||
|
include it
|
||||||
|
}
|
||||||
|
|
||||||
|
def versions = [
|
||||||
|
'core',
|
||||||
|
'1.8',
|
||||||
|
'1.8.9',
|
||||||
|
'1.9.4',
|
||||||
|
'1.10.2',
|
||||||
|
'1.11',
|
||||||
|
'1.11.2',
|
||||||
|
'1.12',
|
||||||
|
'1.12.1',
|
||||||
|
'1.12.2'
|
||||||
|
]
|
||||||
|
versions.collect {":versions:$it"}.each {
|
||||||
|
include it
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import com.replaymod.compat.bettersprinting.DisableBetterSprinting;
|
|||||||
import com.replaymod.compat.optifine.DisableFastRender;
|
import com.replaymod.compat.optifine.DisableFastRender;
|
||||||
import com.replaymod.compat.oranges17animations.HideInvisibleEntities;
|
import com.replaymod.compat.oranges17animations.HideInvisibleEntities;
|
||||||
import com.replaymod.compat.shaders.ShaderBeginRender;
|
import com.replaymod.compat.shaders.ShaderBeginRender;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mod(modid = ReplayModCompat.MOD_ID,
|
@Mod(modid = ReplayModCompat.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
@@ -29,7 +30,7 @@ public class ReplayModCompat {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
EventBus bus = MinecraftForge.EVENT_BUS;
|
EventBus bus = FML_BUS;
|
||||||
bus.register(new ShaderBeginRender());
|
bus.register(new ShaderBeginRender());
|
||||||
bus.register(new DisableFastRender());
|
bus.register(new DisableFastRender());
|
||||||
bus.register(new HideInvisibleEntities());
|
bus.register(new HideInvisibleEntities());
|
||||||
|
|||||||
@@ -2,16 +2,10 @@ package com.replaymod.compat.bettersprinting;
|
|||||||
|
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import com.replaymod.replay.events.ReplayChatMessageEvent;
|
import com.replaymod.replay.events.ReplayChatMessageEvent;
|
||||||
import net.minecraft.block.state.IBlockState;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.SoundEvent;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.IWorldEventListener;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
@@ -22,10 +16,24 @@ import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
|
|||||||
import net.minecraftforge.fml.common.versioning.Restriction;
|
import net.minecraftforge.fml.common.versioning.Restriction;
|
||||||
import net.minecraftforge.fml.common.versioning.VersionRange;
|
import net.minecraftforge.fml.common.versioning.VersionRange;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvent;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IWorldEventListener;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.util.BlockPos;
|
||||||
|
//$$ import net.minecraft.world.IWorldAccess;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static com.replaymod.compat.ReplayModCompat.LOGGER;
|
import static com.replaymod.compat.ReplayModCompat.LOGGER;
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Old Better Sprinting versions replace the vanilla player with their own, overridden instance (replacing the camera entity).
|
* Old Better Sprinting versions replace the vanilla player with their own, overridden instance (replacing the camera entity).
|
||||||
@@ -56,17 +64,25 @@ public class DisableBetterSprinting {
|
|||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||||
public void beforeGuiOpenEvent(GuiOpenEvent event) {
|
public void beforeGuiOpenEvent(GuiOpenEvent event) {
|
||||||
if (ReplayModReplay.instance.getReplayHandler() != null && mc.world != null) {
|
if (ReplayModReplay.instance.getReplayHandler() != null && world(mc) != null) {
|
||||||
// During replay, get ready to revert BetterSprinting's overwritten playerController
|
// During replay, get ready to revert BetterSprinting's overwritten playerController
|
||||||
originalController = mc.playerController;
|
originalController = mc.playerController;
|
||||||
mc.world.addEventListener(worldAccessHook);
|
//#if MC>=10904
|
||||||
|
world(mc).addEventListener(worldAccessHook);
|
||||||
|
//#else
|
||||||
|
//$$ world(mc).addWorldAccess(worldAccessHook);
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.LOW)
|
@SubscribeEvent(priority = EventPriority.LOW)
|
||||||
public void afterGuiOpenEvent(GuiOpenEvent event) {
|
public void afterGuiOpenEvent(GuiOpenEvent event) {
|
||||||
if (ReplayModReplay.instance.getReplayHandler() != null && mc.world != null) {
|
if (ReplayModReplay.instance.getReplayHandler() != null && world(mc) != null) {
|
||||||
mc.world.addEventListener(worldAccessHook);
|
//#if MC>=10904
|
||||||
|
world(mc).addEventListener(worldAccessHook);
|
||||||
|
//#else
|
||||||
|
//$$ world(mc).addWorldAccess(worldAccessHook);
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +98,13 @@ public class DisableBetterSprinting {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BetterSprintingWorldAccess implements IWorldEventListener {
|
private class BetterSprintingWorldAccess
|
||||||
|
//#if MC>=10904
|
||||||
|
implements IWorldEventListener
|
||||||
|
//#else
|
||||||
|
//$$ implements IWorldAccess
|
||||||
|
//#endif
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onEntityRemoved(Entity entityIn) {
|
public void onEntityRemoved(Entity entityIn) {
|
||||||
if (mc.playerController != null && mc.playerController.getClass().getName().equals(CONTROLLER_OVERRIDE_CLASS_NAME)) {
|
if (mc.playerController != null && mc.playerController.getClass().getName().equals(CONTROLLER_OVERRIDE_CLASS_NAME)) {
|
||||||
@@ -93,16 +115,34 @@ public class DisableBetterSprinting {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, IBlockState newState, int flags) {}
|
|
||||||
@Override public void notifyLightSet(BlockPos pos) {}
|
@Override public void notifyLightSet(BlockPos pos) {}
|
||||||
@Override public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {}
|
@Override public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {}
|
||||||
@Override public void playSoundToAllNearExcept(@Nullable EntityPlayer player, SoundEvent soundIn, SoundCategory category, double x, double y, double z, float volume, float pitch) {}
|
|
||||||
@Override public void playRecord(SoundEvent soundIn, BlockPos pos) {}
|
|
||||||
@Override public void spawnParticle(int p_180442_1_, boolean p_180442_2_, double p_180442_3_, double p_180442_5_, double p_180442_7_, double p_180442_9_, double p_180442_11_, double p_180442_13_, int... p_180442_15_) {}
|
@Override public void spawnParticle(int p_180442_1_, boolean p_180442_2_, double p_180442_3_, double p_180442_5_, double p_180442_7_, double p_180442_9_, double p_180442_11_, double p_180442_13_, int... p_180442_15_) {}
|
||||||
@Override public void spawnParticle(int p_190570_1_, boolean p_190570_2_, boolean p_190570_3_, double p_190570_4_, double p_190570_6_, double p_190570_8_, double p_190570_10_, double p_190570_12_, double p_190570_14_, int... p_190570_16_) {}
|
|
||||||
@Override public void onEntityAdded(Entity entityIn) {}
|
@Override public void onEntityAdded(Entity entityIn) {}
|
||||||
@Override public void broadcastSound(int p_180440_1_, BlockPos p_180440_2_, int p_180440_3_) {}
|
@Override public void broadcastSound(int p_180440_1_, BlockPos p_180440_2_, int p_180440_3_) {}
|
||||||
@Override public void playEvent(EntityPlayer player, int type, BlockPos blockPosIn, int data) {}
|
|
||||||
@Override public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {}
|
@Override public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {}
|
||||||
|
//#if MC>=10904
|
||||||
|
@Override public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, IBlockState newState, int flags) {}
|
||||||
|
@Override public void playSoundToAllNearExcept(@Nullable EntityPlayer player, SoundEvent soundIn, SoundCategory category, double x, double y, double z, float volume, float pitch) {}
|
||||||
|
@Override public void playRecord(SoundEvent soundIn, BlockPos pos) {}
|
||||||
|
@Override public void playEvent(EntityPlayer player, int type, BlockPos blockPosIn, int data) {}
|
||||||
|
//#if MC>=11100
|
||||||
|
//#if MC>=11102
|
||||||
|
@Override public void spawnParticle(int p_190570_1_, boolean p_190570_2_, boolean p_190570_3_, double p_190570_4_, double p_190570_6_, double p_190570_8_, double p_190570_10_, double p_190570_12_, double p_190570_14_, int... p_190570_16_) {}
|
||||||
|
//#else
|
||||||
|
//$$ @Override public void func_190570_a(int p_190570_1_, boolean p_190570_2_, boolean p_190570_3_, double p_190570_4_, double p_190570_6_, double p_190570_8_, double p_190570_10_, double p_190570_12_, double p_190570_14_, int... p_190570_16_) {}
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//$$ @Override public void markBlockForUpdate(BlockPos pos) {}
|
||||||
|
//$$ @Override public void playSound(String soundName, double x, double y, double z, float volume, float pitch) {}
|
||||||
|
//$$ @Override public void playSoundToNearExcept(EntityPlayer except, String soundName, double x, double y, double z, float volume, float pitch) {}
|
||||||
|
//$$ @Override public void playRecord(String recordName, BlockPos blockPosIn) {}
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ @Override public void playAuxSFX(EntityPlayer p_180439_1_, int p_180439_2_, BlockPos blockPosIn, int p_180439_4_) {}
|
||||||
|
//#else
|
||||||
|
//$$ @Override public void playAusSFX(EntityPlayer p_180439_1_, int p_180439_2_, BlockPos blockPosIn, int p_180439_4_) {}
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,11 @@ public abstract class MixinMinecraft {
|
|||||||
&& ReplayModReplay.instance.getReplayHandler() != null) {
|
&& ReplayModReplay.instance.getReplayHandler() != null) {
|
||||||
for (StackTraceElement elem : Thread.currentThread().getStackTrace()) {
|
for (StackTraceElement elem : Thread.currentThread().getStackTrace()) {
|
||||||
if ("mapwriter.util.Utils".equals(elem.getClassName()) && "getWorldName".equals(elem.getMethodName())) {
|
if ("mapwriter.util.Utils".equals(elem.getClassName()) && "getWorldName".equals(elem.getMethodName())) {
|
||||||
|
//#if MC>=10809
|
||||||
ci.setReturnValue(new ServerData(null, "replay", false));
|
ci.setReturnValue(new ServerData(null, "replay", false));
|
||||||
|
//#else
|
||||||
|
//$$ ci.setReturnValue(new ServerData(null, "replay"));
|
||||||
|
//#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import net.minecraftforge.fml.common.Loader;
|
|||||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Orange seems to have copied vast parts of the RendererLivingEntity into their ArmorAnimation class which cancels the RenderLivingEvent.Pre and calls its own code instead.
|
* Orange seems to have copied vast parts of the RendererLivingEntity into their ArmorAnimation class which cancels the RenderLivingEvent.Pre and calls its own code instead.
|
||||||
* This breaks our mixin which assures that, even though the camera is in spectator mode, it cannot see invisible entities.
|
* This breaks our mixin which assures that, even though the camera is in spectator mode, it cannot see invisible entities.
|
||||||
@@ -20,7 +22,7 @@ public class HideInvisibleEntities {
|
|||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||||
public void preRenderLiving(RenderLivingEvent.Pre event) {
|
public void preRenderLiving(RenderLivingEvent.Pre event) {
|
||||||
if (modLoaded) {
|
if (modLoaded) {
|
||||||
if (mc.player instanceof CameraEntity && event.getEntity().isInvisible()) {
|
if (player(mc) instanceof CameraEntity && getEntity(event).isInvisible()) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.replaymod.core;
|
|||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.crash.CrashReportCategory;
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
@@ -85,7 +86,7 @@ public class KeyBindingRegistry {
|
|||||||
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Key Binding");
|
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Key Binding");
|
||||||
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
||||||
category.addCrashSection("Key Binding", keyBinding);
|
category.addCrashSection("Key Binding", keyBinding);
|
||||||
category.addDetail("Handler", runnable::toString);
|
MCVer.addDetail(category, "Handler", runnable::toString);
|
||||||
throw new ReportedException(crashReport);
|
throw new ReportedException(crashReport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,7 @@ public class KeyBindingRegistry {
|
|||||||
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Raw Key Binding");
|
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Raw Key Binding");
|
||||||
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
CrashReportCategory category = crashReport.makeCategory("Key Binding");
|
||||||
category.addCrashSection("Key Code", keyCode);
|
category.addCrashSection("Key Code", keyCode);
|
||||||
category.addDetail("Handler", runnable::toString);
|
MCVer.addDetail(category, "Handler", runnable::toString);
|
||||||
throw new ReportedException(crashReport);
|
throw new ReportedException(crashReport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,11 @@ public class LoadingPlugin implements IFMLLoadingPlugin {
|
|||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
// This forces forge to reexamine the jar file for FML mods
|
// This forces forge to reexamine the jar file for FML mods
|
||||||
// Should eventually be handled by Mixin itself, maybe?
|
// Should eventually be handled by Mixin itself, maybe?
|
||||||
|
//#if MC>=10809
|
||||||
CoreModManager.getIgnoredMods().remove(file.getName());
|
CoreModManager.getIgnoredMods().remove(file.getName());
|
||||||
|
//#else
|
||||||
|
//$$ CoreModManager.getLoadedCoremods().remove(file.getName());
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ import com.replaymod.replaystudio.util.I18n;
|
|||||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.resources.FolderResourcePack;
|
||||||
|
import net.minecraft.client.resources.IResourcePack;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.crash.CrashReportCategory;
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.*;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
@@ -29,11 +29,28 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|||||||
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
|
import org.apache.commons.io.Charsets;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.util.text.*;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.util.ChatComponentText;
|
||||||
|
//$$ import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
//$$ import net.minecraft.util.ChatStyle;
|
||||||
|
//$$ import net.minecraft.util.EnumChatFormatting;
|
||||||
|
//$$ import net.minecraft.util.IChatComponent;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.FutureTask;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mod(modid = ReplayMod.MOD_ID,
|
@Mod(modid = ReplayMod.MOD_ID,
|
||||||
useMetadata = true,
|
useMetadata = true,
|
||||||
@@ -108,13 +125,34 @@ public class ReplayMod {
|
|||||||
settingsRegistry.setConfiguration(config);
|
settingsRegistry.setConfiguration(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#ifdef DEV_ENV
|
||||||
|
static { // Note: even preInit is too late and we'd have to issue another resource reload
|
||||||
|
FolderResourcePack jGuiResourcePack = new FolderResourcePack(new File("../jGui/src/main/resources")) {
|
||||||
|
@Override
|
||||||
|
protected InputStream getInputStreamByName(String resourceName) throws IOException {
|
||||||
|
try {
|
||||||
|
return super.getInputStreamByName(resourceName);
|
||||||
|
} catch (IOException e) {
|
||||||
|
if ("pack.mcmeta".equals(resourceName)) {
|
||||||
|
return new ByteArrayInputStream(("{\"pack\": {\"description\": \"dummy pack for jGui resources in dev-env\", \"pack_format\": 1}}").getBytes(Charsets.UTF_8));
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<IResourcePack> defaultResourcePacks = mc.defaultResourcePacks;
|
||||||
|
defaultResourcePacks.add(jGuiResourcePack);
|
||||||
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
getSettingsRegistry().register(Setting.class);
|
getSettingsRegistry().register(Setting.class);
|
||||||
|
|
||||||
new MainMenuHandler().register();
|
new MainMenuHandler().register();
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(keyBindingRegistry);
|
FML_BUS.register(keyBindingRegistry);
|
||||||
|
|
||||||
getKeyBindingRegistry().registerKeyBinding("replaymod.input.settings", 0, () -> {
|
getKeyBindingRegistry().registerKeyBinding("replaymod.input.settings", 0, () -> {
|
||||||
new GuiReplaySettings(null, settingsRegistry).display();
|
new GuiReplaySettings(null, settingsRegistry).display();
|
||||||
@@ -173,7 +211,7 @@ public class ReplayMod {
|
|||||||
|
|
||||||
public void runLater(Runnable runnable) {
|
public void runLater(Runnable runnable) {
|
||||||
if (mc.isCallingFromMinecraftThread() && inRunLater) {
|
if (mc.isCallingFromMinecraftThread() && inRunLater) {
|
||||||
EventBus bus = MinecraftForge.EVENT_BUS;
|
EventBus bus = FORGE_BUS;
|
||||||
bus.register(new Object() {
|
bus.register(new Object() {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRenderTick(TickEvent.RenderTickEvent event) {
|
public void onRenderTick(TickEvent.RenderTickEvent event) {
|
||||||
@@ -185,8 +223,12 @@ public class ReplayMod {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ @SuppressWarnings("unchecked")
|
||||||
|
//#endif
|
||||||
|
Queue<FutureTask<?>> tasks = mc.scheduledTasks;
|
||||||
synchronized (mc.scheduledTasks) {
|
synchronized (mc.scheduledTasks) {
|
||||||
mc.scheduledTasks.add(ListenableFutureTask.create(() -> {
|
tasks.add(ListenableFutureTask.create(() -> {
|
||||||
inRunLater = true;
|
inRunLater = true;
|
||||||
try {
|
try {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
@@ -222,6 +264,7 @@ public class ReplayMod {
|
|||||||
private void printToChat(boolean warning, String message, Object... args) {
|
private void printToChat(boolean warning, String message, Object... args) {
|
||||||
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
|
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
|
||||||
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
||||||
|
//#if MC>=10904
|
||||||
Style coloredDarkGray = new Style().setColor(TextFormatting.DARK_GRAY);
|
Style coloredDarkGray = new Style().setColor(TextFormatting.DARK_GRAY);
|
||||||
Style coloredGold = new Style().setColor(TextFormatting.GOLD);
|
Style coloredGold = new Style().setColor(TextFormatting.GOLD);
|
||||||
ITextComponent text = new TextComponentString("[").setStyle(coloredDarkGray)
|
ITextComponent text = new TextComponentString("[").setStyle(coloredDarkGray)
|
||||||
@@ -229,6 +272,15 @@ public class ReplayMod {
|
|||||||
.appendSibling(new TextComponentString("] "))
|
.appendSibling(new TextComponentString("] "))
|
||||||
.appendSibling(new TextComponentTranslation(message, args).setStyle(new Style()
|
.appendSibling(new TextComponentTranslation(message, args).setStyle(new Style()
|
||||||
.setColor(warning ? TextFormatting.RED : TextFormatting.DARK_GREEN)));
|
.setColor(warning ? TextFormatting.RED : TextFormatting.DARK_GREEN)));
|
||||||
|
//#else
|
||||||
|
//$$ ChatStyle coloredDarkGray = new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
||||||
|
//$$ ChatStyle coloredGold = new ChatStyle().setColor(EnumChatFormatting.GOLD);
|
||||||
|
//$$ IChatComponent text = new ChatComponentText("[").setChatStyle(coloredDarkGray)
|
||||||
|
//$$ .appendSibling(new ChatComponentTranslation("replaymod.title").setChatStyle(coloredGold))
|
||||||
|
//$$ .appendSibling(new ChatComponentText("] "))
|
||||||
|
//$$ .appendSibling(new ChatComponentTranslation(message, args).setChatStyle(new ChatStyle()
|
||||||
|
//$$ .setColor(warning ? EnumChatFormatting.RED : EnumChatFormatting.DARK_GREEN)));
|
||||||
|
//#endif
|
||||||
// Send message to chat GUI
|
// Send message to chat GUI
|
||||||
// The ingame GUI is initialized at startup, therefore this is possible before the client is connected
|
// The ingame GUI is initialized at startup, therefore this is possible before the client is connected
|
||||||
mc.ingameGUI.getChatGUI().printChatMessage(text);
|
mc.ingameGUI.getChatGUI().printChatMessage(text);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.replaymod.core;
|
|||||||
|
|
||||||
import com.replaymod.core.events.SettingsChangedEvent;
|
import com.replaymod.core.events.SettingsChangedEvent;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -10,6 +9,8 @@ import java.lang.reflect.Modifier;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class SettingsRegistry {
|
public class SettingsRegistry {
|
||||||
private static final Object NULL_OBJECT = new Object();
|
private static final Object NULL_OBJECT = new Object();
|
||||||
private Map<SettingKey<?>, Object> settings = new ConcurrentHashMap<>();
|
private Map<SettingKey<?>, Object> settings = new ConcurrentHashMap<>();
|
||||||
@@ -83,7 +84,7 @@ public class SettingsRegistry {
|
|||||||
throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
||||||
}
|
}
|
||||||
settings.put(key, value);
|
settings.put(key, value);
|
||||||
MinecraftForge.EVENT_BUS.post(new SettingsChangedEvent(this, key));
|
FML_BUS.post(new SettingsChangedEvent(this, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class GuiFactory implements IModGuiFactory {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
@Override
|
@Override
|
||||||
public boolean hasConfigGui() {
|
public boolean hasConfigGui() {
|
||||||
return true;
|
return true;
|
||||||
@@ -23,6 +24,30 @@ public class GuiFactory implements IModGuiFactory {
|
|||||||
public GuiScreen createConfigGui(GuiScreen parentScreen) {
|
public GuiScreen createConfigGui(GuiScreen parentScreen) {
|
||||||
return new GuiReplaySettings(parentScreen, ReplayMod.instance.getSettingsRegistry()).toMinecraft();
|
return new GuiReplaySettings(parentScreen, ReplayMod.instance.getSettingsRegistry()).toMinecraft();
|
||||||
}
|
}
|
||||||
|
//#else
|
||||||
|
//$$ @Override
|
||||||
|
//$$ public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||||
|
//$$ return ConfigGuiWrapper.class;
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ @Override
|
||||||
|
//$$ public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||||
|
//$$ return null;
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ public static class ConfigGuiWrapper extends GuiScreen {
|
||||||
|
//$$ private final GuiScreen parent;
|
||||||
|
//$$
|
||||||
|
//$$ public ConfigGuiWrapper(GuiScreen parent) {
|
||||||
|
//$$ this.parent = parent;
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ @Override
|
||||||
|
//$$ public void initGui() {
|
||||||
|
//$$ new GuiReplaySettings(parent, ReplayMod.instance.getSettingsRegistry()).display();
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import org.lwjgl.opengl.GL11;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves certain buttons on the main menu upwards so we can inject our own.
|
* Moves certain buttons on the main menu upwards so we can inject our own.
|
||||||
*/
|
*/
|
||||||
@@ -21,25 +23,30 @@ public class MainMenuHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void onInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
if (event.getGui() instanceof GuiMainMenu) {
|
GuiScreen guiScreen = getGui(event);
|
||||||
GuiMainMenu gui = (GuiMainMenu) event.getGui();
|
if (guiScreen instanceof GuiMainMenu) {
|
||||||
|
GuiMainMenu gui = (GuiMainMenu) guiScreen;
|
||||||
int realmsOffset = 0;
|
int realmsOffset = 0;
|
||||||
for (GuiButton button : event.getButtonList()) {
|
for (GuiButton button : getButtonList(event)) {
|
||||||
// Buttons that aren't in a rectangle directly above our space don't need moving
|
// Buttons that aren't in a rectangle directly above our space don't need moving
|
||||||
if (button.x + button.width < event.getGui().width / 2 - 100
|
if (x(button) + button.width < gui.width / 2 - 100
|
||||||
|| button.x > event.getGui().width / 2 + 100
|
|| x(button) > gui.width / 2 + 100
|
||||||
|| button.y > event.getGui().height / 4 + 10 + 4 * 24) continue;
|
|| y(button) > gui.height / 4 + 10 + 4 * 24) continue;
|
||||||
// Move button up to make space for two rows of buttons
|
// Move button up to make space for two rows of buttons
|
||||||
// and then move back down by 10 to compensate for the space to the exit button that was already there
|
// and then move back down by 10 to compensate for the space to the exit button that was already there
|
||||||
int offset = -2 * 24 + 10;
|
int offset = -2 * 24 + 10;
|
||||||
button.y += offset;
|
y(button, y(button) + offset);
|
||||||
|
//#if MC>=11202
|
||||||
if (button == gui.realmsButton) {
|
if (button == gui.realmsButton) {
|
||||||
realmsOffset = offset;
|
realmsOffset = offset;
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
//#if MC>=11202
|
||||||
if (realmsOffset != 0 && gui.realmsNotification instanceof GuiScreenRealmsProxy) {
|
if (realmsOffset != 0 && gui.realmsNotification instanceof GuiScreenRealmsProxy) {
|
||||||
gui.realmsNotification = new RealmsNotificationProxy((GuiScreenRealmsProxy) gui.realmsNotification, realmsOffset);
|
gui.realmsNotification = new RealmsNotificationProxy((GuiScreenRealmsProxy) gui.realmsNotification, realmsOffset);
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,10 +59,12 @@ public class MainMenuHandler {
|
|||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=11202
|
||||||
@Override
|
@Override
|
||||||
public void setGuiSize(int w, int h) {
|
public void setGuiSize(int w, int h) {
|
||||||
proxy.setGuiSize(w, h);
|
proxy.setGuiSize(w, h);
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
|
|||||||
@@ -4,18 +4,24 @@ import com.replaymod.replaystudio.data.ModInfo;
|
|||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
import net.minecraftforge.fml.common.ModContainer;
|
import net.minecraftforge.fml.common.ModContainer;
|
||||||
|
//#if MC>=11200
|
||||||
import net.minecraftforge.registries.ForgeRegistry;
|
import net.minecraftforge.registries.ForgeRegistry;
|
||||||
import net.minecraftforge.registries.RegistryManager;
|
import net.minecraftforge.registries.RegistryManager;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraftforge.fml.common.registry.GameData;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ModCompat {
|
public class ModCompat {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static Collection<ModInfo> getInstalledNetworkMods() {
|
public static Collection<ModInfo> getInstalledNetworkMods() {
|
||||||
Map<String, ModContainer> ignoreCaseMap = Loader.instance().getModList().stream()
|
Map<String, ModContainer> ignoreCaseMap = Loader.instance().getModList().stream()
|
||||||
.collect(Collectors.toMap(m -> m.getModId().toLowerCase(), Function.identity()));
|
.collect(Collectors.toMap(m -> m.getModId().toLowerCase(), Function.identity()));
|
||||||
|
//#if MC>=11200
|
||||||
return RegistryManager.ACTIVE.takeSnapshot(false).keySet().stream()
|
return RegistryManager.ACTIVE.takeSnapshot(false).keySet().stream()
|
||||||
.map(RegistryManager.ACTIVE::getRegistry)
|
.map(RegistryManager.ACTIVE::getRegistry)
|
||||||
.map(ForgeRegistry::getKeys).flatMap(Set::stream)
|
.map(ForgeRegistry::getKeys).flatMap(Set::stream)
|
||||||
@@ -23,6 +29,15 @@ public class ModCompat {
|
|||||||
.map(String::toLowerCase).map(ignoreCaseMap::get).filter(mod -> mod != null)
|
.map(String::toLowerCase).map(ignoreCaseMap::get).filter(mod -> mod != null)
|
||||||
.map(mod -> new ModInfo(mod.getModId(), mod.getName(), mod.getVersion()))
|
.map(mod -> new ModInfo(mod.getModId(), mod.getName(), mod.getVersion()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
//#else
|
||||||
|
//$$ return Stream.concat(
|
||||||
|
//$$ ((Set<ResourceLocation>) GameData.getBlockRegistry().getKeys()).stream(),
|
||||||
|
//$$ ((Set<ResourceLocation>) GameData.getItemRegistry().getKeys()).stream()
|
||||||
|
//$$ ).map(ResourceLocation::getResourceDomain).filter(s -> !s.equals("minecraft")).distinct()
|
||||||
|
//$$ .map(String::toLowerCase).map(ignoreCaseMap::get).filter(mod -> mod != null)
|
||||||
|
//$$ .map(mod -> new ModInfo(mod.getModId(), mod.getName(), mod.getVersion()))
|
||||||
|
//$$ .collect(Collectors.toList());
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class ModInfoDifference {
|
public static final class ModInfoDifference {
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package com.replaymod.core.utils;
|
package com.replaymod.core.utils;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
@@ -27,24 +23,4 @@ public class OpenGLUtils {
|
|||||||
*/
|
*/
|
||||||
public static void init() {
|
public static void init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawRotatedRectWithCustomSizedTexture(int x, int y, float rotation, float u, float v, int width, int height, float textureWidth, float textureHeight) {
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
|
|
||||||
float f4 = 1.0F / textureWidth;
|
|
||||||
float f5 = 1.0F / textureHeight;
|
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
|
||||||
BufferBuilder vertexBuffer = tessellator.getBuffer();
|
|
||||||
GlStateManager.translate(x+(width/2), y+(width/2), 0);
|
|
||||||
GlStateManager.rotate(rotation, 0, 0, 1);
|
|
||||||
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
|
||||||
vertexBuffer.pos(-width / 2, height / 2, 0.0D).tex((double) (u * f4), (double) ((v + (float) height) * f5)).endVertex();
|
|
||||||
vertexBuffer.pos(width/2, height/2, 0.0D).tex((double)((u + (float)width) * f4), (double)((v + (float)height) * f5)).endVertex();
|
|
||||||
vertexBuffer.pos(width/2, -height/2, 0.0D).tex((double)((u + (float)width) * f4), (double)(v * f5)).endVertex();
|
|
||||||
vertexBuffer.pos(-width/2, -height/2, 0.0D).tex((double)(u * f4), (double)(v * f5)).endVertex();
|
|
||||||
tessellator.draw();
|
|
||||||
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package com.replaymod.core.utils;
|
package com.replaymod.core.utils;
|
||||||
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
//#if MC>=10904
|
||||||
import net.minecraft.network.play.server.SPacketCustomPayload;
|
import net.minecraft.network.play.server.SPacketCustomPayload;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.network.play.server.S3FPacketCustomPayload;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.readString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restrictions set by the server,
|
* Restrictions set by the server,
|
||||||
@@ -14,10 +20,14 @@ public class Restrictions {
|
|||||||
private boolean onlyFirstPerson;
|
private boolean onlyFirstPerson;
|
||||||
private boolean onlyRecordingPlayer;
|
private boolean onlyRecordingPlayer;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
public String handle(SPacketCustomPayload packet) {
|
public String handle(SPacketCustomPayload packet) {
|
||||||
|
//#else
|
||||||
|
//$$ public String handle(S3FPacketCustomPayload packet) {
|
||||||
|
//#endif
|
||||||
PacketBuffer buffer = packet.getBufferData();
|
PacketBuffer buffer = packet.getBufferData();
|
||||||
while (buffer.isReadable()) {
|
while (buffer.isReadable()) {
|
||||||
String name = buffer.readString(64);
|
String name = readString(buffer, 64);
|
||||||
boolean active = buffer.readBoolean();
|
boolean active = buffer.readBoolean();
|
||||||
// if ("no_xray".equals(name)) {
|
// if ("no_xray".equals(name)) {
|
||||||
// noXray = active;
|
// noXray = active;
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import java.util.Date;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.getConnection;
|
||||||
import static net.minecraft.client.Minecraft.getMinecraft;
|
import static net.minecraft.client.Minecraft.getMinecraft;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
@@ -160,7 +161,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceLocation getResourceLocationForPlayerUUID(UUID uuid) {
|
public static ResourceLocation getResourceLocationForPlayerUUID(UUID uuid) {
|
||||||
NetworkPlayerInfo info = getMinecraft().getConnection().getPlayerInfo(uuid);
|
NetworkPlayerInfo info = getConnection(getMinecraft()).getPlayerInfo(uuid);
|
||||||
ResourceLocation skinLocation;
|
ResourceLocation skinLocation;
|
||||||
if (info != null && info.hasLocationSkin()) {
|
if (info != null && info.hasLocationSkin()) {
|
||||||
skinLocation = info.getLocationSkin();
|
skinLocation = info.getLocationSkin();
|
||||||
|
|||||||
@@ -25,6 +25,19 @@ public class WrappedTimer extends Timer {
|
|||||||
to.renderPartialTicks = from.renderPartialTicks;
|
to.renderPartialTicks = from.renderPartialTicks;
|
||||||
to.lastSyncSysClock = from.lastSyncSysClock;
|
to.lastSyncSysClock = from.lastSyncSysClock;
|
||||||
to.elapsedPartialTicks = from.elapsedPartialTicks;
|
to.elapsedPartialTicks = from.elapsedPartialTicks;
|
||||||
|
//#if MC>=11200
|
||||||
to.tickLength = from.tickLength;
|
to.tickLength = from.tickLength;
|
||||||
|
//#else
|
||||||
|
//$$ to.ticksPerSecond = from.ticksPerSecond;
|
||||||
|
//$$ to.lastHRTime = from.lastHRTime;
|
||||||
|
//$$ to.timerSpeed = from.timerSpeed;
|
||||||
|
//$$ to.lastSyncHRClock = from.lastSyncHRClock;
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ to.counter = from.counter;
|
||||||
|
//#else
|
||||||
|
//$$ to.field_74285_i = from.field_74285_i;
|
||||||
|
//#endif
|
||||||
|
//$$ to.timeSyncAdjustment = from.timeSyncAdjustment;
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
407
src/main/java/com/replaymod/core/versions/MCVer.java
Normal file
407
src/main/java/com/replaymod/core/versions/MCVer.java
Normal file
@@ -0,0 +1,407 @@
|
|||||||
|
package com.replaymod.core.versions;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.gui.ScaledResolution;
|
||||||
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
|
import net.minecraft.client.multiplayer.ServerList;
|
||||||
|
import net.minecraft.client.multiplayer.WorldClient;
|
||||||
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.client.resources.ResourcePackRepository;
|
||||||
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.network.Packet;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldType;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
|
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
//#if MC>=11200
|
||||||
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.renderer.VertexBuffer;
|
||||||
|
//#endif
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.renderer.WorldRenderer;
|
||||||
|
//$$ import net.minecraft.util.MathHelper;
|
||||||
|
//#endif
|
||||||
|
//#if MC>=10809
|
||||||
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstraction over things that have changed between different MC versions.
|
||||||
|
*/
|
||||||
|
public class MCVer {
|
||||||
|
public static EventBus FORGE_BUS = MinecraftForge.EVENT_BUS;
|
||||||
|
//#if MC>=10809
|
||||||
|
public static EventBus FML_BUS = FORGE_BUS;
|
||||||
|
//#else
|
||||||
|
//$$ public static EventBus FML_BUS = FMLCommonHandler.instance().bus();
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
public static void addDetail(CrashReportCategory category, String name, Callable<String> callable) {
|
||||||
|
//#if MC>=10904
|
||||||
|
//#if MC>=11200
|
||||||
|
category.addDetail(name, callable::call);
|
||||||
|
//#else
|
||||||
|
//$$ category.setDetail(name, callable::call);
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//$$ category.addCrashSectionCallable(name, callable);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static List<GuiButton> getButtonList(GuiScreenEvent.InitGuiEvent event) {
|
||||||
|
//#if MC>=10904
|
||||||
|
return event.getButtonList();
|
||||||
|
//#else
|
||||||
|
//$$ return event.buttonList;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiButton getButton(GuiScreenEvent.ActionPerformedEvent event) {
|
||||||
|
//#if MC>=10904
|
||||||
|
return event.getButton();
|
||||||
|
//#else
|
||||||
|
//$$ return event.button;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GuiScreen getGui(GuiScreenEvent event) {
|
||||||
|
//#if MC>=10904
|
||||||
|
return event.getGui();
|
||||||
|
//#else
|
||||||
|
//$$ return event.gui;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int x(GuiButton button) {
|
||||||
|
//#if MC>=11200
|
||||||
|
return button.x;
|
||||||
|
//#else
|
||||||
|
//$$ return button.xPosition;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int y(GuiButton button) {
|
||||||
|
//#if MC>=11200
|
||||||
|
return button.y;
|
||||||
|
//#else
|
||||||
|
//$$ return button.yPosition;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void y(GuiButton button, int val) {
|
||||||
|
//#if MC>=11200
|
||||||
|
button.y = val;
|
||||||
|
//#else
|
||||||
|
//$$ button.yPosition = val;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EntityLivingBase getEntity(RenderLivingEvent event) {
|
||||||
|
//#if MC>=10904
|
||||||
|
return event.getEntity();
|
||||||
|
//#else
|
||||||
|
//$$ return event.entity;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NetHandlerPlayClient getConnection(Minecraft mc) {
|
||||||
|
//#if MC>=10904
|
||||||
|
return mc.getConnection();
|
||||||
|
//#else
|
||||||
|
//$$ return mc.getNetHandler();
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String readString(PacketBuffer buffer, int max) {
|
||||||
|
//#if MC>=11102
|
||||||
|
return buffer.readString(max);
|
||||||
|
//#else
|
||||||
|
//$$ return buffer.readStringFromBuffer(max);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int readVarInt(PacketBuffer buffer) {
|
||||||
|
//#if MC>=11102
|
||||||
|
return buffer.readVarInt();
|
||||||
|
//#else
|
||||||
|
//$$ return buffer.readVarIntFromBuffer();
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeVarInt(PacketBuffer buffer, int val) {
|
||||||
|
//#if MC>=11102
|
||||||
|
buffer.writeVarInt(val);
|
||||||
|
//#else
|
||||||
|
//$$ buffer.writeVarIntToBuffer(val);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FontRenderer getFontRenderer(Minecraft mc) {
|
||||||
|
//#if MC>=11200
|
||||||
|
return mc.fontRenderer;
|
||||||
|
//#else
|
||||||
|
//$$ return mc.fontRendererObj;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RenderGameOverlayEvent.ElementType getType(RenderGameOverlayEvent event) {
|
||||||
|
//#if MC>=10904
|
||||||
|
return event.getType();
|
||||||
|
//#else
|
||||||
|
//$$ return event.type;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WorldType WorldType_DEBUG_ALL_BLOCK_STATES
|
||||||
|
//#if MC>=11200
|
||||||
|
= WorldType.DEBUG_ALL_BLOCK_STATES;
|
||||||
|
//#else
|
||||||
|
//$$ = WorldType.DEBUG_WORLD;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
public static EntityPlayerSP player(Minecraft mc) {
|
||||||
|
//#if MC>=11102
|
||||||
|
return mc.player;
|
||||||
|
//#else
|
||||||
|
//$$ return mc.thePlayer;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WorldClient world(Minecraft mc) {
|
||||||
|
//#if MC>=11102
|
||||||
|
return mc.world;
|
||||||
|
//#else
|
||||||
|
//$$ return mc.theWorld;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static World world(Entity entity) {
|
||||||
|
//#if MC>=11102
|
||||||
|
return entity.world;
|
||||||
|
//#else
|
||||||
|
//$$ return entity.worldObj;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void world(Entity entity, World world) {
|
||||||
|
//#if MC>=11102
|
||||||
|
entity.world = world;
|
||||||
|
//#else
|
||||||
|
//$$ entity.worldObj = world;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Entity getRidingEntity(Entity ridden) {
|
||||||
|
//#if MC>=10904
|
||||||
|
return ridden.getRidingEntity();
|
||||||
|
//#else
|
||||||
|
//$$ return ridden.ridingEntity;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static List<Entity> loadedEntityList(World world) {
|
||||||
|
return world.loadedEntityList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static Collection<Entity>[] getEntityLists(Chunk chunk) {
|
||||||
|
return chunk.getEntityLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static List<EntityPlayer> playerEntities(World world) {
|
||||||
|
return world.playerEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GlStateManager.BooleanState fog(GlStateManager.FogState fogState) {
|
||||||
|
//#if MC>=10809
|
||||||
|
return fogState.fog;
|
||||||
|
//#else
|
||||||
|
//$$ return fogState.field_179049_a;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fog(GlStateManager.FogState fogState, GlStateManager.BooleanState fog) {
|
||||||
|
//#if MC>=10809
|
||||||
|
fogState.fog = fog;
|
||||||
|
//#else
|
||||||
|
//$$ fogState.field_179049_a = fog;
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ServerList_saveSingleServer(ServerData serverData) {
|
||||||
|
//#if MC>=10904
|
||||||
|
ServerList.saveSingleServer(serverData);
|
||||||
|
//#else
|
||||||
|
//$$ ServerList.func_147414_b(serverData);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendPacket(NetHandlerPlayClient netHandler, Packet packet) {
|
||||||
|
//#if MC>=10904
|
||||||
|
netHandler.sendPacket(packet);
|
||||||
|
//#else
|
||||||
|
//$$ netHandler.addToSendQueue(packet);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ScaledResolution newScaledResolution(Minecraft mc) {
|
||||||
|
//#if MC>=10809
|
||||||
|
return new ScaledResolution(mc);
|
||||||
|
//#else
|
||||||
|
//$$ return new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ListenableFuture setServerResourcePack(ResourcePackRepository repo, File file) {
|
||||||
|
//#if MC>=10809
|
||||||
|
//#if MC>=11200
|
||||||
|
return repo.setServerResourcePack(file);
|
||||||
|
//#else
|
||||||
|
//$$ return repo.setResourcePackInstance(file);
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//$$ return repo.func_177319_a(file);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BufferBuilder_setTranslation(double x, double y, double z) {
|
||||||
|
//#if MC>=10904
|
||||||
|
Tessellator.getInstance().getBuffer().setTranslation(x, y, z);
|
||||||
|
//#else
|
||||||
|
//$$ Tessellator.getInstance().getWorldRenderer().setTranslation(x, y, z);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BufferBuilder_beginPosCol(int mode) {
|
||||||
|
//#if MC>=10904
|
||||||
|
Tessellator.getInstance().getBuffer().begin(mode, DefaultVertexFormats.POSITION_COLOR);
|
||||||
|
//#else
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ Tessellator.getInstance().getWorldRenderer().begin(mode, DefaultVertexFormats.POSITION_COLOR);
|
||||||
|
//#else
|
||||||
|
//$$ Tessellator.getInstance().getWorldRenderer().startDrawing(mode);
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BufferBuilder_addPosCol(double x, double y, double z, int r, int g, int b, int a) {
|
||||||
|
//#if MC>=10904
|
||||||
|
//#if MC>=11200
|
||||||
|
BufferBuilder worldRenderer = Tessellator.getInstance().getBuffer();
|
||||||
|
//#else
|
||||||
|
//$$ VertexBuffer worldRenderer = Tessellator.getInstance().getBuffer();
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//$$ WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
|
||||||
|
//#endif
|
||||||
|
//#if MC>=10809
|
||||||
|
worldRenderer.pos(x, y, z).color(r, g, b, a).endVertex();
|
||||||
|
//#else
|
||||||
|
//$$ worldRenderer.setColorRGBA(r, g, b, a);
|
||||||
|
//$$ worldRenderer.addVertex(x, y, z);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BufferBuilder_beginPosTex(int mode) {
|
||||||
|
//#if MC>=10904
|
||||||
|
Tessellator.getInstance().getBuffer().begin(mode, DefaultVertexFormats.POSITION_TEX);
|
||||||
|
//#else
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ Tessellator.getInstance().getWorldRenderer().begin(mode, DefaultVertexFormats.POSITION_TEX);
|
||||||
|
//#else
|
||||||
|
//$$ Tessellator.getInstance().getWorldRenderer().startDrawing(mode);
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BufferBuilder_addPosTex(double x, double y, double z, double u, double v) {
|
||||||
|
//#if MC>=10904
|
||||||
|
//#if MC>=11200
|
||||||
|
BufferBuilder worldRenderer = Tessellator.getInstance().getBuffer();
|
||||||
|
//#else
|
||||||
|
//$$ VertexBuffer worldRenderer = Tessellator.getInstance().getBuffer();
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//$$ WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
|
||||||
|
//#endif
|
||||||
|
//#if MC>=10809
|
||||||
|
worldRenderer.pos(x, y, z).tex(u, v).endVertex();
|
||||||
|
//#else
|
||||||
|
//$$ worldRenderer.addVertexWithUV(x, y, z, u, v);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BufferBuilder_beginPosTexCol(int mode) {
|
||||||
|
//#if MC>=10904
|
||||||
|
Tessellator.getInstance().getBuffer().begin(mode, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||||
|
//#else
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ Tessellator.getInstance().getWorldRenderer().begin(mode, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||||
|
//#else
|
||||||
|
//$$ Tessellator.getInstance().getWorldRenderer().startDrawing(mode);
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void BufferBuilder_addPosTexCol(double x, double y, double z, double u, double v, int r, int g, int b, int a) {
|
||||||
|
//#if MC>=10904
|
||||||
|
//#if MC>=11200
|
||||||
|
BufferBuilder worldRenderer = Tessellator.getInstance().getBuffer();
|
||||||
|
//#else
|
||||||
|
//$$ VertexBuffer worldRenderer = Tessellator.getInstance().getBuffer();
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//$$ WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
|
||||||
|
//#endif
|
||||||
|
//#if MC>=10809
|
||||||
|
worldRenderer.pos(x, y, z).tex(u, v).color(r, g, b, a).endVertex();
|
||||||
|
//#else
|
||||||
|
//$$ worldRenderer.setColorRGBA(r, g, b, a);
|
||||||
|
//$$ worldRenderer.addVertexWithUV(x, y, z, u, v);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
public static int floor(double val) {
|
||||||
|
//#if MC>=11102
|
||||||
|
return MathHelper.floor(val);
|
||||||
|
//#else
|
||||||
|
//$$ return MathHelper.floor_double(val);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float cos(float val) {
|
||||||
|
return MathHelper.cos(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float sin(float val) {
|
||||||
|
return MathHelper.sin(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ import net.minecraftforge.client.event.GuiScreenEvent;
|
|||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
private static final int BUTTON_REPLAY_EDITOR = 17890237;
|
private static final int BUTTON_REPLAY_EDITOR = 17890237;
|
||||||
|
|
||||||
@@ -20,28 +22,29 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
|
FORGE_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||||
if (!(event.getGui() instanceof GuiMainMenu)) {
|
if (!(getGui(event) instanceof GuiMainMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_EDITOR, event.getGui().width / 2 + 2,
|
GuiButton button = new GuiButton(BUTTON_REPLAY_EDITOR, getGui(event).width / 2 + 2,
|
||||||
event.getGui().height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayeditor"));
|
getGui(event).height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayeditor"));
|
||||||
button.width = button.width / 2 - 2;
|
button.width = button.width / 2 - 2;
|
||||||
event.getButtonList().add(button);
|
getButtonList(event).add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||||
if(!event.getButton().enabled) return;
|
if(!getButton(event).enabled) return;
|
||||||
|
|
||||||
if (event.getGui() instanceof GuiMainMenu) {
|
if (getGui(event) instanceof GuiMainMenu) {
|
||||||
if (event.getButton().id == BUTTON_REPLAY_EDITOR) {
|
if (getButton(event).id == BUTTON_REPLAY_EDITOR) {
|
||||||
new GuiReplayEditor(GuiScreen.wrap(event.getGui()), mod.getCore()).display();
|
new GuiReplayEditor(GuiScreen.wrap(getGui(event)), mod.getCore()).display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import de.johni0702.minecraft.gui.element.GuiImage;
|
|||||||
import de.johni0702.minecraft.gui.element.IGuiImage;
|
import de.johni0702.minecraft.gui.element.IGuiImage;
|
||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class FullBrightness implements Extra {
|
public class FullBrightness implements Extra {
|
||||||
private ReplayModReplay module;
|
private ReplayModReplay module;
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ public class FullBrightness implements Extra {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import de.johni0702.minecraft.gui.layout.GridLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.LayoutData;
|
import de.johni0702.minecraft.gui.layout.LayoutData;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
@@ -28,6 +27,8 @@ import java.util.Collections;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class HotkeyButtons implements Extra {
|
public class HotkeyButtons implements Extra {
|
||||||
private ReplayMod mod;
|
private ReplayMod mod;
|
||||||
|
|
||||||
@@ -35,7 +36,7 @@ public class HotkeyButtons implements Extra {
|
|||||||
public void register(ReplayMod mod) throws Exception {
|
public void register(ReplayMod mod) throws Exception {
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -5,10 +5,15 @@ import com.replaymod.core.ReplayMod;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.resources.IResourcePack;
|
import net.minecraft.client.resources.IResourcePack;
|
||||||
import net.minecraft.client.resources.data.IMetadataSection;
|
import net.minecraft.client.resources.data.IMetadataSection;
|
||||||
import net.minecraft.client.resources.data.MetadataSerializer;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.client.resources.data.MetadataSerializer;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.resources.data.IMetadataSerializer;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -103,8 +108,13 @@ public class LocalizationExtra implements Extra {
|
|||||||
return ImmutableSet.of("replaymod");
|
return ImmutableSet.of("replaymod");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
@Override
|
@Override
|
||||||
public <T extends IMetadataSection> T getPackMetadata(MetadataSerializer metadataSerializer, String metadataSectionName) throws IOException {
|
public <T extends IMetadataSection> T getPackMetadata(MetadataSerializer metadataSerializer, String metadataSectionName) throws IOException {
|
||||||
|
//#else
|
||||||
|
//$$ @Override
|
||||||
|
//$$ public IMetadataSection getPackMetadata(IMetadataSerializer metadataSerializer, String metadataSectionName) throws IOException {
|
||||||
|
//#endif
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import org.lwjgl.input.Keyboard;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class PlayerOverview implements Extra {
|
public class PlayerOverview implements Extra {
|
||||||
private ReplayModReplay module;
|
private ReplayModReplay module;
|
||||||
|
|
||||||
@@ -34,7 +36,7 @@ public class PlayerOverview implements Extra {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (module.getReplayHandler() != null) {
|
if (module.getReplayHandler() != null) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<EntityPlayer> players = mod.getMinecraft().world.getPlayers(EntityPlayer.class, new Predicate() {
|
List<EntityPlayer> players = world(mod.getMinecraft()).getPlayers(EntityPlayer.class, new Predicate() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Object input) {
|
public boolean apply(Object input) {
|
||||||
return !(input instanceof CameraEntity); // Exclude the camera entity
|
return !(input instanceof CameraEntity); // Exclude the camera entity
|
||||||
@@ -55,7 +57,8 @@ public class PlayerOverview implements Extra {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
|
FORGE_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHidden(UUID uuid) {
|
public boolean isHidden(UUID uuid) {
|
||||||
|
|||||||
@@ -21,12 +21,17 @@ import de.johni0702.minecraft.gui.utils.Colors;
|
|||||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
import net.minecraft.entity.player.EnumPlayerModelParts;
|
||||||
import net.minecraft.init.MobEffects;
|
|
||||||
import net.minecraft.init.SoundEvents;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.init.MobEffects;
|
||||||
|
import net.minecraft.init.SoundEvents;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.potion.Potion;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -47,14 +52,22 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
public final GuiCheckbox checkAll = new GuiCheckbox(contentPanel){
|
public final GuiCheckbox checkAll = new GuiCheckbox(contentPanel){
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
|
//#if MC>=10904
|
||||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
|
//#else
|
||||||
|
//$$ getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(BUTTON_SOUND, 1.0F));
|
||||||
|
//#endif
|
||||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(true);
|
playersScrollable.forEach(IGuiCheckbox.class).setChecked(true);
|
||||||
}
|
}
|
||||||
}.setLabel("").setChecked(true).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.showall"));
|
}.setLabel("").setChecked(true).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.showall"));
|
||||||
public final GuiCheckbox uncheckAll = new GuiCheckbox(contentPanel){
|
public final GuiCheckbox uncheckAll = new GuiCheckbox(contentPanel){
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
|
//#if MC>=10904
|
||||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
|
//#else
|
||||||
|
//$$ getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(BUTTON_SOUND, 1.0F));
|
||||||
|
//#endif
|
||||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(false);
|
playersScrollable.forEach(IGuiCheckbox.class).setChecked(false);
|
||||||
}
|
}
|
||||||
}.setLabel("").setChecked(false).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.hideall"));
|
}.setLabel("").setChecked(false).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.hideall"));
|
||||||
@@ -97,7 +110,11 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
|
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
|
||||||
renderer.bindTexture(texture);
|
renderer.bindTexture(texture);
|
||||||
renderer.drawTexturedRect(0, 0, 8, 8, 16, 16, 8, 8, 64, 64);
|
renderer.drawTexturedRect(0, 0, 8, 8, 16, 16, 8, 8, 64, 64);
|
||||||
|
//#if MC>=10809
|
||||||
if (p.isWearing(EnumPlayerModelParts.HAT)) {
|
if (p.isWearing(EnumPlayerModelParts.HAT)) {
|
||||||
|
//#else
|
||||||
|
//$$ if (p.func_175148_a(EnumPlayerModelParts.HAT)) {
|
||||||
|
//#endif
|
||||||
renderer.drawTexturedRect(0, 0, 40, 8, size.getWidth(), size.getHeight(), 8, 8, 64, 64);
|
renderer.drawTexturedRect(0, 0, 40, 8, size.getWidth(), size.getHeight(), 8, 8, 64, 64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +163,11 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSpectator(EntityPlayer e) {
|
private static boolean isSpectator(EntityPlayer e) {
|
||||||
|
//#if MC>=10904
|
||||||
return e.isInvisible() && e.getActivePotionEffect(MobEffects.INVISIBILITY) == null;
|
return e.isInvisible() && e.getActivePotionEffect(MobEffects.INVISIBILITY) == null;
|
||||||
|
//#else
|
||||||
|
//$$ return e.isInvisible() && e.getActivePotionEffect(Potion.invisibility) == null;
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class PlayerComparator implements Comparator<EntityPlayer> {
|
private static final class PlayerComparator implements Comparator<EntityPlayer> {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import net.minecraftforge.client.event.GuiScreenEvent;
|
|||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class YoutubeUpload implements Extra {
|
public class YoutubeUpload implements Extra {
|
||||||
@Override
|
@Override
|
||||||
public void register(ReplayMod mod) throws Exception {
|
public void register(ReplayMod mod) throws Exception {
|
||||||
@@ -17,8 +19,8 @@ public class YoutubeUpload implements Extra {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onGuiOpen(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void onGuiOpen(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
if (GuiScreen.from(event.getGui()) instanceof GuiRenderingDone) {
|
if (GuiScreen.from(getGui(event)) instanceof GuiRenderingDone) {
|
||||||
GuiRenderingDone gui = (GuiRenderingDone) GuiScreen.from(event.getGui());
|
GuiRenderingDone gui = (GuiRenderingDone) GuiScreen.from(getGui(event));
|
||||||
// Check if there already is a youtube button
|
// Check if there already is a youtube button
|
||||||
if (gui.actionsPanel.getChildren().stream().anyMatch(it -> it instanceof YoutubeButton)) {
|
if (gui.actionsPanel.getChildren().stream().anyMatch(it -> it instanceof YoutubeButton)) {
|
||||||
return; // Button already added
|
return; // Button already added
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
|||||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
@@ -24,6 +23,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
import static net.minecraft.client.Minecraft.getMinecraft;
|
import static net.minecraft.client.Minecraft.getMinecraft;
|
||||||
|
|
||||||
@Mod(modid = ReplayModOnline.MOD_ID,
|
@Mod(modid = ReplayModOnline.MOD_ID,
|
||||||
@@ -76,7 +76,7 @@ public class ReplayModOnline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
new GuiHandler(this).register();
|
new GuiHandler(this).register();
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.replaymod.online.gui;
|
package com.replaymod.online.gui;
|
||||||
|
|
||||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
import com.replaymod.online.api.ApiClient;
|
import com.replaymod.online.api.ApiClient;
|
||||||
import com.replaymod.online.api.ApiException;
|
import com.replaymod.online.api.ApiException;
|
||||||
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
||||||
@@ -16,6 +17,8 @@ import net.minecraft.client.gui.FontRenderer;
|
|||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
import org.lwjgl.util.ReadableColor;
|
import org.lwjgl.util.ReadableColor;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class GuiRegister extends AbstractGuiScreen<GuiRegister> {
|
public class GuiRegister extends AbstractGuiScreen<GuiRegister> {
|
||||||
public static final int MIN_PW_LENGTH = 5;
|
public static final int MIN_PW_LENGTH = 5;
|
||||||
public static final int MAX_PW_LENGTH = 1024;
|
public static final int MAX_PW_LENGTH = 1024;
|
||||||
@@ -55,7 +58,7 @@ public class GuiRegister extends AbstractGuiScreen<GuiRegister> {
|
|||||||
pos(cancelButton, width / 2 + 2, 170);
|
pos(cancelButton, width / 2 + 2, 170);
|
||||||
pos(statusLabel, width / 2 - statusLabel.getMinSize().getWidth() / 2, 152);
|
pos(statusLabel, width / 2 - statusLabel.getMinSize().getWidth() / 2, 152);
|
||||||
|
|
||||||
FontRenderer font = getMinecraft().fontRenderer;
|
FontRenderer font = getFontRenderer(getMinecraft());
|
||||||
int lineCount = font.listFormattedStringToWidth(disclaimerLabel.getText(), width - 10).size();
|
int lineCount = font.listFormattedStringToWidth(disclaimerLabel.getText(), width - 10).size();
|
||||||
Dimension dim = new Dimension(width - 10, font.FONT_HEIGHT * lineCount);
|
Dimension dim = new Dimension(width - 10, font.FONT_HEIGHT * lineCount);
|
||||||
disclaimerLabel.setSize(dim);
|
disclaimerLabel.setSize(dim);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
|||||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
|
|
||||||
@@ -420,7 +420,7 @@ public class GuiReplayCenter extends GuiScreen {
|
|||||||
name.setText(ChatFormatting.UNDERLINE + Utils.fileNameToReplayName(fileInfo.getName()));
|
name.setText(ChatFormatting.UNDERLINE + Utils.fileNameToReplayName(fileInfo.getName()));
|
||||||
author.setI18nText("replaymod.gui.center.author",
|
author.setI18nText("replaymod.gui.center.author",
|
||||||
"" + ChatFormatting.GRAY + ChatFormatting.ITALIC, fileInfo.getOwner());
|
"" + ChatFormatting.GRAY + ChatFormatting.ITALIC, fileInfo.getOwner());
|
||||||
if (Strings.isEmpty(metaData.getServerName())) {
|
if (StringUtils.isEmpty(metaData.getServerName())) {
|
||||||
server.setI18nText("replaymod.gui.iphidden").setColor(Colors.DARK_RED);
|
server.setI18nText("replaymod.gui.iphidden").setColor(Colors.DARK_RED);
|
||||||
} else {
|
} else {
|
||||||
server.setText(metaData.getServerName());
|
server.setText(metaData.getServerName());
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
private static final int BUTTON_REPLAY_CENTER = 17890236;
|
private static final int BUTTON_REPLAY_CENTER = 17890236;
|
||||||
|
|
||||||
@@ -28,23 +30,24 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
|
FORGE_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||||
if (!(event.getGui() instanceof GuiMainMenu)) {
|
if (!(getGui(event) instanceof GuiMainMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, event.getGui().width / 2 - 100,
|
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, getGui(event).width / 2 - 100,
|
||||||
event.getGui().height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
|
getGui(event).height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
|
||||||
event.getButtonList().add(button);
|
getButtonList(event).add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoReplayViewer(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void injectIntoReplayViewer(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
AbstractGuiScreen guiScreen = GuiScreen.from(event.getGui());
|
AbstractGuiScreen guiScreen = GuiScreen.from(getGui(event));
|
||||||
if (!(guiScreen instanceof GuiReplayViewer)) {
|
if (!(guiScreen instanceof GuiReplayViewer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -70,15 +73,15 @@ public class GuiHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||||
if(!event.getButton().enabled) return;
|
if(!getButton(event).enabled) return;
|
||||||
|
|
||||||
if (event.getGui() instanceof GuiMainMenu) {
|
if (getGui(event) instanceof GuiMainMenu) {
|
||||||
if (event.getButton().id == BUTTON_REPLAY_CENTER) {
|
if (getButton(event).id == BUTTON_REPLAY_CENTER) {
|
||||||
GuiReplayCenter replayCenter = new GuiReplayCenter(mod);
|
GuiReplayCenter replayCenter = new GuiReplayCenter(mod);
|
||||||
if (mod.isLoggedIn()) {
|
if (mod.isLoggedIn()) {
|
||||||
replayCenter.display();
|
replayCenter.display();
|
||||||
} else {
|
} else {
|
||||||
new GuiLoginPrompt(mod.getApiClient(), GuiScreen.wrap(event.getGui()), replayCenter, true).display();
|
new GuiLoginPrompt(mod.getApiClient(), GuiScreen.wrap(getGui(event)), replayCenter, true).display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays a timeline.
|
* Plays a timeline.
|
||||||
*/
|
*/
|
||||||
@@ -66,11 +68,16 @@ public abstract class AbstractTimelinePlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replayHandler.getReplaySender().setSyncModeAndWait();
|
replayHandler.getReplaySender().setSyncModeAndWait();
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
mc.timer = new ReplayTimer(mc.timer);
|
mc.timer = new ReplayTimer(mc.timer);
|
||||||
|
//#if MC>=11200
|
||||||
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK;
|
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK;
|
||||||
mc.timer.renderPartialTicks = mc.timer.elapsedTicks = 0;
|
mc.timer.renderPartialTicks = mc.timer.elapsedTicks = 0;
|
||||||
|
//#else
|
||||||
|
//$$ mc.timer.timerSpeed = 1;
|
||||||
|
//$$ mc.timer.elapsedPartialTicks = mc.timer.elapsedTicks = 0;
|
||||||
|
//#endif
|
||||||
return future = settableFuture = SettableFuture.create();
|
return future = settableFuture = SettableFuture.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +95,7 @@ public abstract class AbstractTimelinePlayer {
|
|||||||
mc.timer = ((ReplayTimer) mc.timer).getWrapped();
|
mc.timer = ((ReplayTimer) mc.timer).getWrapped();
|
||||||
replayHandler.getReplaySender().setReplaySpeed(0);
|
replayHandler.getReplaySender().setReplaySpeed(0);
|
||||||
replayHandler.getReplaySender().setAsyncMode(true);
|
replayHandler.getReplaySender().setAsyncMode(true);
|
||||||
MinecraftForge.EVENT_BUS.unregister(this);
|
FML_BUS.unregister(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long time = getTimePassed();
|
long time = getTimePassed();
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package com.replaymod.pathing.player;
|
|||||||
|
|
||||||
import com.replaymod.core.utils.WrappedTimer;
|
import com.replaymod.core.utils.WrappedTimer;
|
||||||
import net.minecraft.util.Timer;
|
import net.minecraft.util.Timer;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper around the current timer that prevents the timer from advancing by itself.
|
* Wrapper around the current timer that prevents the timer from advancing by itself.
|
||||||
*/
|
*/
|
||||||
@@ -20,7 +21,7 @@ public class ReplayTimer extends WrappedTimer {
|
|||||||
copy(this, state); // Save our current state
|
copy(this, state); // Save our current state
|
||||||
super.updateTimer(); // Update current state
|
super.updateTimer(); // Update current state
|
||||||
copy(state, this); // Restore our old state
|
copy(state, this); // Restore our old state
|
||||||
MinecraftForge.EVENT_BUS.post(new UpdatedEvent());
|
FML_BUS.post(new UpdatedEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timer getWrapped() {
|
public Timer getWrapped() {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import com.replaymod.recording.handler.GuiHandler;
|
|||||||
import com.replaymod.recording.packet.PacketListener;
|
import com.replaymod.recording.packet.PacketListener;
|
||||||
import io.netty.channel.ChannelDuplexHandler;
|
import io.netty.channel.ChannelDuplexHandler;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
@@ -17,6 +16,8 @@ import net.minecraftforge.fml.common.network.NetworkRegistry;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mod(modid = ReplayModRecording.MOD_ID,
|
@Mod(modid = ReplayModRecording.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
@@ -56,7 +57,7 @@ public class ReplayModRecording {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
EventBus bus = MinecraftForge.EVENT_BUS;
|
EventBus bus = FML_BUS;
|
||||||
bus.register(connectionEventHandler = new ConnectionEventHandler(logger, core));
|
bus.register(connectionEventHandler = new ConnectionEventHandler(logger, core));
|
||||||
|
|
||||||
new GuiHandler(core).register();
|
new GuiHandler(core).register();
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|||||||
|
|
||||||
import static com.replaymod.core.ReplayMod.TEXTURE;
|
import static com.replaymod.core.ReplayMod.TEXTURE;
|
||||||
import static com.replaymod.core.ReplayMod.TEXTURE_SIZE;
|
import static com.replaymod.core.ReplayMod.TEXTURE_SIZE;
|
||||||
|
import static com.replaymod.core.versions.MCVer.getFontRenderer;
|
||||||
|
import static com.replaymod.core.versions.MCVer.getType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders overlay during recording.
|
* Renders overlay during recording.
|
||||||
@@ -40,9 +42,9 @@ public class GuiRecordingOverlay {
|
|||||||
*/
|
*/
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void renderRecordingIndicator(RenderGameOverlayEvent.Post event) {
|
public void renderRecordingIndicator(RenderGameOverlayEvent.Post event) {
|
||||||
if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) return;
|
if (getType(event) != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||||
if (settingsRegistry.get(Setting.INDICATOR)) {
|
if (settingsRegistry.get(Setting.INDICATOR)) {
|
||||||
FontRenderer fontRenderer = mc.fontRenderer;
|
FontRenderer fontRenderer = getFontRenderer(mc);
|
||||||
fontRenderer.drawString(I18n.format("replaymod.gui.recording").toUpperCase(), 30, 18 - (fontRenderer.FONT_HEIGHT / 2), 0xffffffff);
|
fontRenderer.drawString(I18n.format("replaymod.gui.recording").toUpperCase(), 30, 18 - (fontRenderer.FONT_HEIGHT / 2), 0xffffffff);
|
||||||
mc.renderEngine.bindTexture(TEXTURE);
|
mc.renderEngine.bindTexture(TEXTURE);
|
||||||
GlStateManager.resetColor();
|
GlStateManager.resetColor();
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import com.replaymod.replaystudio.replay.ZipReplayFile;
|
|||||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.world.WorldType;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent;
|
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@@ -21,6 +20,8 @@ import java.io.File;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.WorldType_DEBUG_ALL_BLOCK_STATES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles connection events and initiates recording if enabled.
|
* Handles connection events and initiates recording if enabled.
|
||||||
*/
|
*/
|
||||||
@@ -47,7 +48,7 @@ public class ConnectionEventHandler {
|
|||||||
try {
|
try {
|
||||||
boolean local = networkManager.isLocalChannel();
|
boolean local = networkManager.isLocalChannel();
|
||||||
if (local) {
|
if (local) {
|
||||||
if (mc.getIntegratedServer().getEntityWorld().getWorldType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
|
if (mc.getIntegratedServer().getEntityWorld().getWorldType() == WorldType_DEBUG_ALL_BLOCK_STATES) {
|
||||||
logger.info("Debug World recording is not supported.");
|
logger.info("Debug World recording is not supported.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -67,9 +68,11 @@ public class ConnectionEventHandler {
|
|||||||
worldName = mc.getIntegratedServer().getWorldName();
|
worldName = mc.getIntegratedServer().getWorldName();
|
||||||
} else if (Minecraft.getMinecraft().getCurrentServerData() != null) {
|
} else if (Minecraft.getMinecraft().getCurrentServerData() != null) {
|
||||||
worldName = Minecraft.getMinecraft().getCurrentServerData().serverIP;
|
worldName = Minecraft.getMinecraft().getCurrentServerData().serverIP;
|
||||||
|
//#if MC>=11100
|
||||||
} else if (Minecraft.getMinecraft().isConnectedToRealms()) {
|
} else if (Minecraft.getMinecraft().isConnectedToRealms()) {
|
||||||
// we can't access the server name without tapping too deep in the Realms Library
|
// we can't access the server name without tapping too deep in the Realms Library
|
||||||
worldName = "A Realms Server";
|
worldName = "A Realms Server";
|
||||||
|
//#endif
|
||||||
} else {
|
} else {
|
||||||
logger.info("Recording not started as the world is neither local nor remote (probably a replay).");
|
logger.info("Recording not started as the world is neither local nor remote (probably a replay).");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -8,11 +8,17 @@ import de.johni0702.minecraft.gui.container.VanillaGuiScreen;
|
|||||||
import de.johni0702.minecraft.gui.element.GuiCheckbox;
|
import de.johni0702.minecraft.gui.element.GuiCheckbox;
|
||||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||||
import net.minecraft.client.gui.GuiMultiplayer;
|
import net.minecraft.client.gui.GuiMultiplayer;
|
||||||
|
//#if MC>=10904
|
||||||
import net.minecraft.client.gui.GuiWorldSelection;
|
import net.minecraft.client.gui.GuiWorldSelection;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.gui.GuiSelectWorld;
|
||||||
|
//#endif
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.getGui;
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
|
|
||||||
private final ReplayMod mod;
|
private final ReplayMod mod;
|
||||||
@@ -27,9 +33,14 @@ public class GuiHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
|
//#if MC>=10904
|
||||||
if (event.getGui() instanceof GuiWorldSelection || event.getGui() instanceof GuiMultiplayer) {
|
if (event.getGui() instanceof GuiWorldSelection || event.getGui() instanceof GuiMultiplayer) {
|
||||||
SettingsRegistry settingsRegistry = mod.getSettingsRegistry();
|
|
||||||
boolean sp = event.getGui() instanceof GuiWorldSelection;
|
boolean sp = event.getGui() instanceof GuiWorldSelection;
|
||||||
|
//#else
|
||||||
|
//$$ if (event.gui instanceof GuiSelectWorld || event.gui instanceof GuiMultiplayer) {
|
||||||
|
//$$ boolean sp = event.gui instanceof GuiSelectWorld;
|
||||||
|
//#endif
|
||||||
|
SettingsRegistry settingsRegistry = mod.getSettingsRegistry();
|
||||||
Setting<Boolean> setting = sp ? Setting.RECORD_SINGLEPLAYER : Setting.RECORD_SERVER;
|
Setting<Boolean> setting = sp ? Setting.RECORD_SINGLEPLAYER : Setting.RECORD_SERVER;
|
||||||
|
|
||||||
GuiCheckbox recordingCheckbox = new GuiCheckbox()
|
GuiCheckbox recordingCheckbox = new GuiCheckbox()
|
||||||
@@ -40,7 +51,7 @@ public class GuiHandler {
|
|||||||
settingsRegistry.save();
|
settingsRegistry.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
VanillaGuiScreen.setup(event.getGui()).setLayout(new CustomLayout<GuiScreen>() {
|
VanillaGuiScreen.setup(getGui(event)).setLayout(new CustomLayout<GuiScreen>() {
|
||||||
@Override
|
@Override
|
||||||
protected void layout(GuiScreen container, int width, int height) {
|
protected void layout(GuiScreen container, int width, int height) {
|
||||||
//size(recordingCheckbox, 200, 20);
|
//size(recordingCheckbox, 200, 20);
|
||||||
|
|||||||
@@ -2,18 +2,11 @@ package com.replaymod.recording.handler;
|
|||||||
|
|
||||||
import com.replaymod.recording.packet.PacketListener;
|
import com.replaymod.recording.packet.PacketListener;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.EntityLiving;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.datasync.EntityDataManager;
|
|
||||||
import net.minecraft.network.play.server.*;
|
import net.minecraft.network.play.server.*;
|
||||||
import net.minecraft.server.integrated.IntegratedServer;
|
import net.minecraft.server.integrated.IntegratedServer;
|
||||||
import net.minecraft.util.EnumHand;
|
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.SoundEvent;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
|
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
|
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
|
||||||
@@ -22,8 +15,22 @@ import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
|
|||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
import net.minecraft.network.datasync.EntityDataManager;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvent;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.util.BlockPos;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class RecordingEventHandler {
|
public class RecordingEventHandler {
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = Minecraft.getMinecraft();
|
||||||
@@ -35,20 +42,24 @@ public class RecordingEventHandler {
|
|||||||
private boolean wasSleeping;
|
private boolean wasSleeping;
|
||||||
private int lastRiding = -1;
|
private int lastRiding = -1;
|
||||||
private Integer rotationYawHeadBefore;
|
private Integer rotationYawHeadBefore;
|
||||||
|
//#if MC>=10904
|
||||||
private boolean wasHandActive;
|
private boolean wasHandActive;
|
||||||
private EnumHand lastActiveHand;
|
private EnumHand lastActiveHand;
|
||||||
|
//#endif
|
||||||
|
|
||||||
public RecordingEventHandler(PacketListener packetListener) {
|
public RecordingEventHandler(PacketListener packetListener) {
|
||||||
this.packetListener = packetListener;
|
this.packetListener = packetListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
|
FORGE_BUS.register(this);
|
||||||
((RecordingEventSender) mc.renderGlobal).setRecordingEventHandler(this);
|
((RecordingEventSender) mc.renderGlobal).setRecordingEventHandler(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregister() {
|
public void unregister() {
|
||||||
MinecraftForge.EVENT_BUS.unregister(this);
|
FML_BUS.unregister(this);
|
||||||
|
FORGE_BUS.unregister(this);
|
||||||
RecordingEventSender recordingEventSender = ((RecordingEventSender) mc.renderGlobal);
|
RecordingEventSender recordingEventSender = ((RecordingEventSender) mc.renderGlobal);
|
||||||
if (recordingEventSender.getRecordingEventHandler() == this) {
|
if (recordingEventSender.getRecordingEventHandler() == this) {
|
||||||
recordingEventSender.setRecordingEventHandler(null);
|
recordingEventSender.setRecordingEventHandler(null);
|
||||||
@@ -57,7 +68,11 @@ public class RecordingEventHandler {
|
|||||||
|
|
||||||
public void onPlayerJoin() {
|
public void onPlayerJoin() {
|
||||||
try {
|
try {
|
||||||
packetListener.save(new SPacketSpawnPlayer(mc.player));
|
//#if MC>=10904
|
||||||
|
packetListener.save(new SPacketSpawnPlayer(player(mc)));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new S0CPacketSpawnPlayer(player(mc)));
|
||||||
|
//#endif
|
||||||
} catch(Exception e1) {
|
} catch(Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -65,12 +80,17 @@ public class RecordingEventHandler {
|
|||||||
|
|
||||||
public void onPlayerRespawn() {
|
public void onPlayerRespawn() {
|
||||||
try {
|
try {
|
||||||
packetListener.save(new SPacketSpawnPlayer(mc.player));
|
//#if MC>=10904
|
||||||
|
packetListener.save(new SPacketSpawnPlayer(player(mc)));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new S0CPacketSpawnPlayer(player(mc)));
|
||||||
|
//#endif
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
public void onClientSound(SoundEvent sound, SoundCategory category,
|
public void onClientSound(SoundEvent sound, SoundCategory category,
|
||||||
double x, double y, double z, float volume, float pitch) {
|
double x, double y, double z, float volume, float pitch) {
|
||||||
try {
|
try {
|
||||||
@@ -89,11 +109,12 @@ public class RecordingEventHandler {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerTick(PlayerTickEvent e) {
|
public void onPlayerTick(PlayerTickEvent e) {
|
||||||
try {
|
try {
|
||||||
if(e.player != mc.player) return;
|
if(e.player != player(mc)) return;
|
||||||
|
|
||||||
boolean force = false;
|
boolean force = false;
|
||||||
if(lastX == null || lastY == null || lastZ == null) {
|
if(lastX == null || lastY == null || lastZ == null) {
|
||||||
@@ -119,14 +140,24 @@ public class RecordingEventHandler {
|
|||||||
|
|
||||||
Packet packet;
|
Packet packet;
|
||||||
if (force || Math.abs(dx) > 8.0 || Math.abs(dy) > 8.0 || Math.abs(dz) > 8.0) {
|
if (force || Math.abs(dx) > 8.0 || Math.abs(dy) > 8.0 || Math.abs(dz) > 8.0) {
|
||||||
|
//#if MC>=10904
|
||||||
packet = new SPacketEntityTeleport(e.player);
|
packet = new SPacketEntityTeleport(e.player);
|
||||||
|
//#else
|
||||||
|
//$$ packet = new S18PacketEntityTeleport(e.player);
|
||||||
|
//#endif
|
||||||
} else {
|
} else {
|
||||||
byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
||||||
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
packet = new SPacketEntity.S17PacketEntityLookMove(e.player.getEntityId(),
|
packet = new SPacketEntity.S17PacketEntityLookMove(e.player.getEntityId(),
|
||||||
(short) Math.round(dx * 4096), (short) Math.round(dy * 4096), (short) Math.round(dz * 4096),
|
(short) Math.round(dx * 4096), (short) Math.round(dy * 4096), (short) Math.round(dz * 4096),
|
||||||
newYaw, newPitch, e.player.onGround);
|
newYaw, newPitch, e.player.onGround);
|
||||||
|
//#else
|
||||||
|
//$$ packet = new S14PacketEntity.S17PacketEntityLookMove(e.player.getEntityId(),
|
||||||
|
//$$ (byte) Math.round(dx * 32), (byte) Math.round(dy * 32), (byte) Math.round(dz * 32),
|
||||||
|
//$$ newYaw, newPitch, e.player.onGround);
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
packetListener.save(packet);
|
packetListener.save(packet);
|
||||||
@@ -135,16 +166,28 @@ public class RecordingEventHandler {
|
|||||||
int rotationYawHead = ((int)(e.player.rotationYawHead * 256.0F / 360.0F));
|
int rotationYawHead = ((int)(e.player.rotationYawHead * 256.0F / 360.0F));
|
||||||
|
|
||||||
if(!Objects.equals(rotationYawHead, rotationYawHeadBefore)) {
|
if(!Objects.equals(rotationYawHead, rotationYawHeadBefore)) {
|
||||||
|
//#if MC>=10904
|
||||||
packetListener.save(new SPacketEntityHeadLook(e.player, (byte) rotationYawHead));
|
packetListener.save(new SPacketEntityHeadLook(e.player, (byte) rotationYawHead));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new S19PacketEntityHeadLook(e.player, (byte) rotationYawHead));
|
||||||
|
//#endif
|
||||||
rotationYawHeadBefore = rotationYawHead;
|
rotationYawHeadBefore = rotationYawHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
packetListener.save(new SPacketEntityVelocity(e.player.getEntityId(), e.player.motionX, e.player.motionY, e.player.motionZ));
|
packetListener.save(new SPacketEntityVelocity(e.player.getEntityId(), e.player.motionX, e.player.motionY, e.player.motionZ));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new S12PacketEntityVelocity(e.player.getEntityId(), e.player.motionX, e.player.motionY, e.player.motionZ));
|
||||||
|
//#endif
|
||||||
|
|
||||||
//Animation Packets
|
//Animation Packets
|
||||||
//Swing Animation
|
//Swing Animation
|
||||||
if (e.player.isSwingInProgress && e.player.swingProgressInt == -1) {
|
if (e.player.isSwingInProgress && e.player.swingProgressInt == -1) {
|
||||||
|
//#if MC>=10904
|
||||||
packetListener.save(new SPacketAnimation(e.player, e.player.swingingHand == EnumHand.MAIN_HAND ? 0 : 3));
|
packetListener.save(new SPacketAnimation(e.player, e.player.swingingHand == EnumHand.MAIN_HAND ? 0 : 3));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new S0BPacketAnimation(e.player, 0));
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -168,63 +211,105 @@ public class RecordingEventHandler {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//Inventory Handling
|
//Inventory Handling
|
||||||
if (playerItems[0] != mc.player.getHeldItem(EnumHand.MAIN_HAND)) {
|
//#if MC>=10904
|
||||||
playerItems[0] = mc.player.getHeldItem(EnumHand.MAIN_HAND);
|
if (playerItems[0] != player(mc).getHeldItem(EnumHand.MAIN_HAND)) {
|
||||||
|
playerItems[0] = player(mc).getHeldItem(EnumHand.MAIN_HAND);
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.MAINHAND, playerItems[0]));
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.MAINHAND, playerItems[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerItems[1] != mc.player.getHeldItem(EnumHand.OFF_HAND)) {
|
if (playerItems[1] != player(mc).getHeldItem(EnumHand.OFF_HAND)) {
|
||||||
playerItems[1] = mc.player.getHeldItem(EnumHand.OFF_HAND);
|
playerItems[1] = player(mc).getHeldItem(EnumHand.OFF_HAND);
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.OFFHAND, playerItems[1]));
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.OFFHAND, playerItems[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerItems[2] != mc.player.getItemStackFromSlot(EntityEquipmentSlot.FEET)) {
|
if (playerItems[2] != player(mc).getItemStackFromSlot(EntityEquipmentSlot.FEET)) {
|
||||||
playerItems[2] = mc.player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
playerItems[2] = player(mc).getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.FEET, playerItems[2]));
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.FEET, playerItems[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerItems[3] != mc.player.getItemStackFromSlot(EntityEquipmentSlot.LEGS)) {
|
if (playerItems[3] != player(mc).getItemStackFromSlot(EntityEquipmentSlot.LEGS)) {
|
||||||
playerItems[3] = mc.player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
|
playerItems[3] = player(mc).getItemStackFromSlot(EntityEquipmentSlot.LEGS);
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.LEGS, playerItems[3]));
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.LEGS, playerItems[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerItems[4] != mc.player.getItemStackFromSlot(EntityEquipmentSlot.CHEST)) {
|
if (playerItems[4] != player(mc).getItemStackFromSlot(EntityEquipmentSlot.CHEST)) {
|
||||||
playerItems[4] = mc.player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
playerItems[4] = player(mc).getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.CHEST, playerItems[4]));
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.CHEST, playerItems[4]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerItems[5] != mc.player.getItemStackFromSlot(EntityEquipmentSlot.HEAD)) {
|
if (playerItems[5] != player(mc).getItemStackFromSlot(EntityEquipmentSlot.HEAD)) {
|
||||||
playerItems[5] = mc.player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
playerItems[5] = player(mc).getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
||||||
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.HEAD, playerItems[5]));
|
packetListener.save(new SPacketEntityEquipment(e.player.getEntityId(), EntityEquipmentSlot.HEAD, playerItems[5]));
|
||||||
}
|
}
|
||||||
|
//#else
|
||||||
|
//$$ if(playerItems[0] != mc.thePlayer.getHeldItem()) {
|
||||||
|
//$$ playerItems[0] = mc.thePlayer.getHeldItem();
|
||||||
|
//$$ S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 0, playerItems[0]);
|
||||||
|
//$$ packetListener.save(pee);
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ if(playerItems[1] != mc.thePlayer.inventory.armorInventory[0]) {
|
||||||
|
//$$ playerItems[1] = mc.thePlayer.inventory.armorInventory[0];
|
||||||
|
//$$ S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 1, playerItems[1]);
|
||||||
|
//$$ packetListener.save(pee);
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ if(playerItems[2] != mc.thePlayer.inventory.armorInventory[1]) {
|
||||||
|
//$$ playerItems[2] = mc.thePlayer.inventory.armorInventory[1];
|
||||||
|
//$$ S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 2, playerItems[2]);
|
||||||
|
//$$ packetListener.save(pee);
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ if(playerItems[3] != mc.thePlayer.inventory.armorInventory[2]) {
|
||||||
|
//$$ playerItems[3] = mc.thePlayer.inventory.armorInventory[2];
|
||||||
|
//$$ S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 3, playerItems[3]);
|
||||||
|
//$$ packetListener.save(pee);
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ if(playerItems[4] != mc.thePlayer.inventory.armorInventory[3]) {
|
||||||
|
//$$ playerItems[4] = mc.thePlayer.inventory.armorInventory[3];
|
||||||
|
//$$ S04PacketEntityEquipment pee = new S04PacketEntityEquipment(e.player.getEntityId(), 4, playerItems[4]);
|
||||||
|
//$$ packetListener.save(pee);
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
//Leaving Ride
|
//Leaving Ride
|
||||||
|
|
||||||
if((!mc.player.isRiding() && lastRiding != -1) ||
|
if((!player(mc).isRiding() && lastRiding != -1) ||
|
||||||
(mc.player.isRiding() && lastRiding != mc.player.getRidingEntity().getEntityId())) {
|
(player(mc).isRiding() && lastRiding != getRidingEntity(player(mc)).getEntityId())) {
|
||||||
if(!mc.player.isRiding()) {
|
if(!player(mc).isRiding()) {
|
||||||
lastRiding = -1;
|
lastRiding = -1;
|
||||||
} else {
|
} else {
|
||||||
lastRiding = mc.player.getRidingEntity().getEntityId();
|
lastRiding = getRidingEntity(player(mc)).getEntityId();
|
||||||
}
|
}
|
||||||
packetListener.save(new SPacketEntityAttach(e.player, e.player.getRidingEntity()));
|
//#if MC>=10904
|
||||||
|
packetListener.save(new SPacketEntityAttach(e.player, getRidingEntity(e.player)));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new S1BPacketEntityAttach(0, e.player, getRidingEntity(e.player)));
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sleeping
|
//Sleeping
|
||||||
if(!mc.player.isPlayerSleeping() && wasSleeping) {
|
if(!player(mc).isPlayerSleeping() && wasSleeping) {
|
||||||
|
//#if MC>=10904
|
||||||
packetListener.save(new SPacketAnimation(e.player, 2));
|
packetListener.save(new SPacketAnimation(e.player, 2));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new S0BPacketAnimation(e.player, 2));
|
||||||
|
//#endif
|
||||||
wasSleeping = false;
|
wasSleeping = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
// Active hand (e.g. eating, drinking, blocking)
|
// Active hand (e.g. eating, drinking, blocking)
|
||||||
if (mc.player.isHandActive() ^ wasHandActive || mc.player.getActiveHand() != lastActiveHand) {
|
if (player(mc).isHandActive() ^ wasHandActive || player(mc).getActiveHand() != lastActiveHand) {
|
||||||
wasHandActive = mc.player.isHandActive();
|
wasHandActive = player(mc).isHandActive();
|
||||||
lastActiveHand = mc.player.getActiveHand();
|
lastActiveHand = player(mc).getActiveHand();
|
||||||
EntityDataManager dataManager = new EntityDataManager(null);
|
EntityDataManager dataManager = new EntityDataManager(null);
|
||||||
int state = (wasHandActive ? 1 : 0) | (lastActiveHand == EnumHand.OFF_HAND ? 2 : 0);
|
int state = (wasHandActive ? 1 : 0) | (lastActiveHand == EnumHand.OFF_HAND ? 2 : 0);
|
||||||
dataManager.register(EntityLiving.HAND_STATES, (byte) state);
|
dataManager.register(EntityLiving.HAND_STATES, (byte) state);
|
||||||
packetListener.save(new SPacketEntityMetadata(mc.player.getEntityId(), dataManager, true));
|
packetListener.save(new SPacketEntityMetadata(player(mc).getEntityId(), dataManager, true));
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
} catch(Exception e1) {
|
} catch(Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
@@ -234,8 +319,21 @@ public class RecordingEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPickupItem(ItemPickupEvent event) {
|
public void onPickupItem(ItemPickupEvent event) {
|
||||||
try {
|
try {
|
||||||
|
//#if MC>=11100
|
||||||
|
//#if MC>=11200
|
||||||
packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId(),
|
packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId(),
|
||||||
event.pickedUp.getItem().getMaxStackSize()));
|
event.pickedUp.getItem().getMaxStackSize()));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId(),
|
||||||
|
//$$ event.pickedUp.getEntityItem().getMaxStackSize()));
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//#if MC>=10904
|
||||||
|
//$$ packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId()));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new S0DPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId()));
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -244,11 +342,19 @@ public class RecordingEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onSleep(PlayerSleepInBedEvent event) {
|
public void onSleep(PlayerSleepInBedEvent event) {
|
||||||
try {
|
try {
|
||||||
if (event.getEntityPlayer() != mc.player) {
|
//#if MC>=10904
|
||||||
|
if (event.getEntityPlayer() != player(mc)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packetListener.save(new SPacketUseBed(event.getEntityPlayer(), event.getPos()));
|
packetListener.save(new SPacketUseBed(event.getEntityPlayer(), event.getPos()));
|
||||||
|
//#else
|
||||||
|
//$$ if (event.entityPlayer != player(mc)) {
|
||||||
|
//$$ return;
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ packetListener.save(new S0APacketUseBed(event.entityPlayer, event.pos));
|
||||||
|
//#endif
|
||||||
|
|
||||||
wasSleeping = true;
|
wasSleeping = true;
|
||||||
|
|
||||||
@@ -260,22 +366,36 @@ public class RecordingEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void enterMinecart(MinecartInteractEvent event) {
|
public void enterMinecart(MinecartInteractEvent event) {
|
||||||
try {
|
try {
|
||||||
if(event.getEntity() != mc.player) {
|
//#if MC>=10904
|
||||||
|
if(event.getEntity() != player(mc)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
packetListener.save(new SPacketEntityAttach(event.getPlayer(), event.getMinecart()));
|
packetListener.save(new SPacketEntityAttach(event.getPlayer(), event.getMinecart()));
|
||||||
|
|
||||||
lastRiding = event.getMinecart().getEntityId();
|
lastRiding = event.getMinecart().getEntityId();
|
||||||
|
//#else
|
||||||
|
//$$ if(event.entity != player(mc)) {
|
||||||
|
//$$ return;
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ packetListener.save(new S1BPacketEntityAttach(0, event.player, event.minecart));
|
||||||
|
//$$
|
||||||
|
//$$ lastRiding = event.minecart.getEntityId();
|
||||||
|
//#endif
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBlockBreakAnim(int breakerId, BlockPos pos, int progress) {
|
public void onBlockBreakAnim(int breakerId, BlockPos pos, int progress) {
|
||||||
EntityPlayer thePlayer = mc.player;
|
EntityPlayer thePlayer = player(mc);
|
||||||
if (thePlayer != null && breakerId == thePlayer.getEntityId()) {
|
if (thePlayer != null && breakerId == thePlayer.getEntityId()) {
|
||||||
|
//#if MC>=10904
|
||||||
packetListener.save(new SPacketBlockBreakAnim(breakerId, pos, progress));
|
packetListener.save(new SPacketBlockBreakAnim(breakerId, pos, progress));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new S25PacketBlockBreakAnim(breakerId, pos, progress));
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ public abstract class MixinNetHandlerLoginClient {
|
|||||||
ReplayModRecording.instance.initiateRecording(networkManager);
|
ReplayModRecording.instance.initiateRecording(networkManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
@Inject(method = "handleLoginSuccess", at=@At("RETURN"))
|
@Inject(method = "handleLoginSuccess", at=@At("RETURN"))
|
||||||
public void replayModRecording_raceConditionWorkAround(CallbackInfo cb) {
|
public void replayModRecording_raceConditionWorkAround(CallbackInfo cb) {
|
||||||
networkManager.channel().config().setAutoRead(true);
|
networkManager.channel().config().setAutoRead(true);
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,28 @@ import com.replaymod.recording.handler.RecordingEventHandler;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||||
import net.minecraft.network.play.server.SPacketPlayerListItem;
|
import net.minecraft.network.play.server.*;
|
||||||
import net.minecraft.network.play.server.SPacketRespawn;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.network.play.server.SPacketPlayerListItem.Action;
|
||||||
|
import net.minecraft.network.play.server.SPacketPlayerListItem.AddPlayerData;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.network.play.server.S38PacketPlayerListItem.Action;
|
||||||
|
//$$ import net.minecraft.network.play.server.S38PacketPlayerListItem.AddPlayerData;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mixin(NetHandlerPlayClient.class)
|
@Mixin(NetHandlerPlayClient.class)
|
||||||
public abstract class MixinNetHandlerPlayClient {
|
public abstract class MixinNetHandlerPlayClient {
|
||||||
|
|
||||||
@@ -36,31 +47,59 @@ public abstract class MixinNetHandlerPlayClient {
|
|||||||
* @param ci Callback info
|
* @param ci Callback info
|
||||||
*/
|
*/
|
||||||
@Inject(method = "handlePlayerListItem", at=@At("HEAD"))
|
@Inject(method = "handlePlayerListItem", at=@At("HEAD"))
|
||||||
|
//#if MC>=10809
|
||||||
|
//#if MC>=10904
|
||||||
public void recordOwnJoin(SPacketPlayerListItem packet, CallbackInfo ci) {
|
public void recordOwnJoin(SPacketPlayerListItem packet, CallbackInfo ci) {
|
||||||
if (gameController.player == null) return;
|
//#else
|
||||||
|
//$$ public void recordOwnJoin(S38PacketPlayerListItem packet, CallbackInfo ci) {
|
||||||
|
//#endif
|
||||||
|
if (player(gameController) == null) return;
|
||||||
|
|
||||||
RecordingEventHandler handler = getRecordingEventHandler();
|
RecordingEventHandler handler = getRecordingEventHandler();
|
||||||
if (handler != null && packet.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER) {
|
if (handler != null && packet.getAction() == Action.ADD_PLAYER) {
|
||||||
for (SPacketPlayerListItem.AddPlayerData data : packet.getEntries()) {
|
for (AddPlayerData data : packet.getEntries()) {
|
||||||
if (data.getProfile() == null || data.getProfile().getId() == null) continue;
|
if (data.getProfile() == null || data.getProfile().getId() == null) continue;
|
||||||
// Only add spawn packet for our own player and only if he isn't known yet
|
// Only add spawn packet for our own player and only if he isn't known yet
|
||||||
if (data.getProfile().getId().equals(Minecraft.getMinecraft().player.getGameProfile().getId())
|
if (data.getProfile().getId().equals(player(gameController).getGameProfile().getId())
|
||||||
&& !playerInfoMap.containsKey(data.getProfile().getId())) {
|
&& !playerInfoMap.containsKey(data.getProfile().getId())) {
|
||||||
handler.onPlayerJoin();
|
handler.onPlayerJoin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#else
|
||||||
|
//$$ public void recordOwnJoin(S38PacketPlayerListItem packet, CallbackInfo ci) {
|
||||||
|
//$$ if (gameController.thePlayer == null) return;
|
||||||
|
//$$
|
||||||
|
//$$ RecordingEventHandler handler = getRecordingEventHandler();
|
||||||
|
//$$ if (handler != null && packet.func_179768_b() == S38PacketPlayerListItem.Action.ADD_PLAYER) {
|
||||||
|
//$$ @SuppressWarnings("unchecked")
|
||||||
|
//$$ List<S38PacketPlayerListItem.AddPlayerData> dataList = packet.func_179767_a();
|
||||||
|
//$$ for (S38PacketPlayerListItem.AddPlayerData data : dataList) {
|
||||||
|
//$$ if (data.func_179962_a() == null || data.func_179962_a().getId() == null) continue;
|
||||||
|
//$$ // Only add spawn packet for our own player and only if he isn't known yet
|
||||||
|
//$$ if (data.func_179962_a().getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId())
|
||||||
|
//$$ && !playerInfoMap.containsKey(data.func_179962_a().getId())) {
|
||||||
|
//$$ handler.onPlayerJoin();
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record the own player entity respawning.
|
* Record the own player entity respawning.
|
||||||
* We cannot use the {@link net.minecraftforge.event.entity.EntityJoinWorldEvent} because that would also include
|
* We cannot use the {@link net.minecraftforge.event.entity.EntityJoinWorldEvent} because that would also include
|
||||||
* the first spawn which is already handled by {@link #recordOwnJoin(SPacketPlayerListItem, CallbackInfo)}.
|
* the first spawn which is already handled by the above method.
|
||||||
* @param packet The packet
|
* @param packet The packet
|
||||||
* @param ci Callback info
|
* @param ci Callback info
|
||||||
*/
|
*/
|
||||||
@Inject(method = "handleRespawn", at=@At("RETURN"))
|
@Inject(method = "handleRespawn", at=@At("RETURN"))
|
||||||
|
//#if MC>=10904
|
||||||
public void recordOwnRespawn(SPacketRespawn packet, CallbackInfo ci) {
|
public void recordOwnRespawn(SPacketRespawn packet, CallbackInfo ci) {
|
||||||
|
//#else
|
||||||
|
//$$ public void recordOwnRespawn(S07PacketRespawn packet, CallbackInfo ci) {
|
||||||
|
//#endif
|
||||||
RecordingEventHandler handler = getRecordingEventHandler();
|
RecordingEventHandler handler = getRecordingEventHandler();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
handler.onPlayerRespawn();
|
handler.onPlayerRespawn();
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
package com.replaymod.recording.mixin;
|
package com.replaymod.recording.mixin;
|
||||||
|
|
||||||
import com.replaymod.recording.handler.FMLHandshakeFilter;
|
import com.replaymod.recording.handler.FMLHandshakeFilter;
|
||||||
import io.netty.channel.ChannelConfig;
|
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.embedded.EmbeddedChannel;
|
import io.netty.channel.embedded.EmbeddedChannel;
|
||||||
import net.minecraft.network.EnumConnectionState;
|
|
||||||
import net.minecraft.network.NetworkManager;
|
|
||||||
import net.minecraftforge.fml.common.network.handshake.FMLHandshakeCodec;
|
import net.minecraftforge.fml.common.network.handshake.FMLHandshakeCodec;
|
||||||
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
@@ -13,9 +10,15 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
|
import io.netty.channel.ChannelConfig;
|
||||||
|
import net.minecraft.network.EnumConnectionState;
|
||||||
|
import net.minecraft.network.NetworkManager;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Mixin(value = NetworkDispatcher.class, remap = false)
|
@Mixin(value = NetworkDispatcher.class, remap = false)
|
||||||
public abstract class MixinNetworkDispatcher {
|
public abstract class MixinNetworkDispatcher {
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ public abstract class MixinNetworkDispatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
@Redirect(method = "clientListenForServerHandshake", at = @At(value = "INVOKE", remap = true, target =
|
@Redirect(method = "clientListenForServerHandshake", at = @At(value = "INVOKE", remap = true, target =
|
||||||
"Lnet/minecraft/network/NetworkManager;setConnectionState(Lnet/minecraft/network/EnumConnectionState;)V"))
|
"Lnet/minecraft/network/NetworkManager;setConnectionState(Lnet/minecraft/network/EnumConnectionState;)V"))
|
||||||
public void replayModRecording_raceConditionWorkAround1(NetworkManager self, EnumConnectionState ignored) { }
|
public void replayModRecording_raceConditionWorkAround1(NetworkManager self, EnumConnectionState ignored) { }
|
||||||
@@ -60,4 +64,5 @@ public abstract class MixinNetworkDispatcher {
|
|||||||
}
|
}
|
||||||
return self.setAutoRead(autoRead);
|
return self.setAutoRead(autoRead);
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.replaymod.recording.mixin;
|
package com.replaymod.recording.mixin;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
import com.replaymod.recording.handler.RecordingEventHandler;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||||
@@ -10,6 +11,8 @@ import org.spongepowered.asm.mixin.Shadow;
|
|||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mixin(PlayerControllerMP.class)
|
@Mixin(PlayerControllerMP.class)
|
||||||
public abstract class MixinPlayerControllerMP implements RecordingEventHandler.RecordingEventSender {
|
public abstract class MixinPlayerControllerMP implements RecordingEventHandler.RecordingEventSender {
|
||||||
|
|
||||||
@@ -23,6 +26,7 @@ public abstract class MixinPlayerControllerMP implements RecordingEventHandler.R
|
|||||||
@Redirect(method = "onPlayerDestroyBlock", at = @At(value = "INVOKE",
|
@Redirect(method = "onPlayerDestroyBlock", at = @At(value = "INVOKE",
|
||||||
target = "Lnet/minecraft/world/World;playEvent(ILnet/minecraft/util/math/BlockPos;I)V"))
|
target = "Lnet/minecraft/world/World;playEvent(ILnet/minecraft/util/math/BlockPos;I)V"))
|
||||||
public void replayModRecording_playEvent_fixed(World world, int type, BlockPos pos, int data) {
|
public void replayModRecording_playEvent_fixed(World world, int type, BlockPos pos, int data) {
|
||||||
world.playEvent(mc.player, type, pos, data);
|
world.playEvent(player(mc), type, pos, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|||||||
@@ -2,12 +2,17 @@ package com.replaymod.recording.mixin;
|
|||||||
|
|
||||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
import com.replaymod.recording.handler.RecordingEventHandler;
|
||||||
import net.minecraft.client.renderer.RenderGlobal;
|
import net.minecraft.client.renderer.RenderGlobal;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.util.BlockPos;
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Mixin(RenderGlobal.class)
|
@Mixin(RenderGlobal.class)
|
||||||
public abstract class MixinRenderGlobal implements RecordingEventHandler.RecordingEventSender {
|
public abstract class MixinRenderGlobal implements RecordingEventHandler.RecordingEventSender {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.replaymod.recording.mixin;
|
package com.replaymod.recording.mixin;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
import com.replaymod.recording.handler.RecordingEventHandler;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.multiplayer.WorldClient;
|
||||||
@@ -18,6 +19,8 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mixin(WorldClient.class)
|
@Mixin(WorldClient.class)
|
||||||
public abstract class MixinWorldClient extends World implements RecordingEventHandler.RecordingEventSender {
|
public abstract class MixinWorldClient extends World implements RecordingEventHandler.RecordingEventSender {
|
||||||
@Shadow
|
@Shadow
|
||||||
@@ -39,7 +42,7 @@ public abstract class MixinWorldClient extends World implements RecordingEventHa
|
|||||||
at = @At("HEAD"))
|
at = @At("HEAD"))
|
||||||
public void replayModRecording_recordClientSound(EntityPlayer player, double x, double y, double z, SoundEvent sound, SoundCategory category,
|
public void replayModRecording_recordClientSound(EntityPlayer player, double x, double y, double z, SoundEvent sound, SoundCategory category,
|
||||||
float volume, float pitch, CallbackInfo ci) {
|
float volume, float pitch, CallbackInfo ci) {
|
||||||
if (player == mc.player) {
|
if (player == player(mc)) {
|
||||||
RecordingEventHandler handler = replayModRecording_getRecordingEventHandler();
|
RecordingEventHandler handler = replayModRecording_getRecordingEventHandler();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
handler.onClientSound(sound, category, x, y, z, volume, pitch);
|
handler.onClientSound(sound, category, x, y, z, volume, pitch);
|
||||||
@@ -51,7 +54,7 @@ public abstract class MixinWorldClient extends World implements RecordingEventHa
|
|||||||
// These are handled in the World class, so we override the method in WorldClient and add our special handling.
|
// These are handled in the World class, so we override the method in WorldClient and add our special handling.
|
||||||
@Override
|
@Override
|
||||||
public void playEvent(EntityPlayer player, int type, BlockPos pos, int data) {
|
public void playEvent(EntityPlayer player, int type, BlockPos pos, int data) {
|
||||||
if (player == mc.player) {
|
if (player == player(mc)) {
|
||||||
// We caused this event, the server won't send it to us
|
// We caused this event, the server won't send it to us
|
||||||
RecordingEventHandler handler = replayModRecording_getRecordingEventHandler();
|
RecordingEventHandler handler = replayModRecording_getRecordingEventHandler();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
@@ -61,3 +64,4 @@ public abstract class MixinWorldClient extends World implements RecordingEventHa
|
|||||||
super.playEvent(player, type, pos, data);
|
super.playEvent(player, type, pos, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|||||||
@@ -14,18 +14,21 @@ import net.minecraft.network.EnumConnectionState;
|
|||||||
import net.minecraft.network.EnumPacketDirection;
|
import net.minecraft.network.EnumPacketDirection;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.network.datasync.EntityDataManager;
|
import net.minecraft.network.play.server.*;
|
||||||
import net.minecraft.network.play.server.SPacketCollectItem;
|
|
||||||
import net.minecraft.network.play.server.SPacketCustomPayload;
|
|
||||||
import net.minecraft.network.play.server.SPacketDisconnect;
|
|
||||||
import net.minecraft.network.play.server.SPacketResourcePackSend;
|
|
||||||
import net.minecraft.network.play.server.SPacketSpawnMob;
|
|
||||||
import net.minecraft.network.play.server.SPacketSpawnPlayer;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.network.datasync.EntityDataManager;
|
||||||
|
import net.minecraft.util.text.TextComponentString;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.entity.DataWatcher;
|
||||||
|
//$$ import net.minecraft.util.ChatComponentText;
|
||||||
|
//$$
|
||||||
|
//$$ import java.util.List;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -37,6 +40,8 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class PacketListener extends ChannelInboundHandlerAdapter {
|
public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||||
|
|
||||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||||
@@ -92,13 +97,27 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
public void save(Packet packet) {
|
public void save(Packet packet) {
|
||||||
try {
|
try {
|
||||||
|
//#if MC>=10904
|
||||||
if(packet instanceof SPacketSpawnPlayer) {
|
if(packet instanceof SPacketSpawnPlayer) {
|
||||||
UUID uuid = ((SPacketSpawnPlayer) packet).getUniqueId();
|
UUID uuid = ((SPacketSpawnPlayer) packet).getUniqueId();
|
||||||
|
//#else
|
||||||
|
//$$ if(packet instanceof S0CPacketSpawnPlayer) {
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ UUID uuid = ((S0CPacketSpawnPlayer) packet).getPlayer();
|
||||||
|
//#else
|
||||||
|
//$$ UUID uuid = ((S0CPacketSpawnPlayer) packet).func_179819_c();
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
Set<String> uuids = new HashSet<>(Arrays.asList(metaData.getPlayers()));
|
Set<String> uuids = new HashSet<>(Arrays.asList(metaData.getPlayers()));
|
||||||
uuids.add(uuid.toString());
|
uuids.add(uuid.toString());
|
||||||
metaData.setPlayers(uuids.toArray(new String[uuids.size()]));
|
metaData.setPlayers(uuids.toArray(new String[uuids.size()]));
|
||||||
saveMetaData();
|
saveMetaData();
|
||||||
}
|
}
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ if (packet instanceof S46PacketSetCompressionLevel) {
|
||||||
|
//$$ return; // Replay data is never compressed on the packet level
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
byte[] bytes = getPacketData(packet);
|
byte[] bytes = getPacketData(packet);
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
@@ -159,16 +178,31 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
try {
|
try {
|
||||||
Packet packet = (Packet) msg;
|
Packet packet = (Packet) msg;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if(packet instanceof SPacketCollectItem) {
|
if(packet instanceof SPacketCollectItem) {
|
||||||
if(mc.player != null ||
|
if(player(mc) != null ||
|
||||||
((SPacketCollectItem) packet).getEntityID() == mc.player.getEntityId()) {
|
((SPacketCollectItem) packet).getEntityID() == player(mc).getEntityId()) {
|
||||||
|
//#else
|
||||||
|
//$$ if(packet instanceof S0DPacketCollectItem) {
|
||||||
|
//$$ if(player(mc) != null ||
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ ((S0DPacketCollectItem) packet).getEntityID() == player(mc).getEntityId()) {
|
||||||
|
//#else
|
||||||
|
//$$ ((S0DPacketCollectItem) packet).func_149353_d() == player(mc).getEntityId()) {
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
super.channelRead(ctx, msg);
|
super.channelRead(ctx, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if (packet instanceof SPacketResourcePackSend) {
|
if (packet instanceof SPacketResourcePackSend) {
|
||||||
save(resourcePackRecorder.handleResourcePack((SPacketResourcePackSend) packet));
|
save(resourcePackRecorder.handleResourcePack((SPacketResourcePackSend) packet));
|
||||||
|
//#else
|
||||||
|
//$$ if (packet instanceof S48PacketResourcePackSend) {
|
||||||
|
//$$ save(resourcePackRecorder.handleResourcePack((S48PacketResourcePackSend) packet));
|
||||||
|
//#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,10 +215,17 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
save(packet);
|
save(packet);
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if (packet instanceof SPacketCustomPayload) {
|
if (packet instanceof SPacketCustomPayload) {
|
||||||
SPacketCustomPayload p = (SPacketCustomPayload) packet;
|
SPacketCustomPayload p = (SPacketCustomPayload) packet;
|
||||||
if (Restrictions.PLUGIN_CHANNEL.equals(p.getChannelName())) {
|
if (Restrictions.PLUGIN_CHANNEL.equals(p.getChannelName())) {
|
||||||
packet = new SPacketDisconnect(new TextComponentString("Please update to view this replay."));
|
packet = new SPacketDisconnect(new TextComponentString("Please update to view this replay."));
|
||||||
|
//#else
|
||||||
|
//$$ if (packet instanceof S3FPacketCustomPayload) {
|
||||||
|
//$$ S3FPacketCustomPayload p = (S3FPacketCustomPayload) packet;
|
||||||
|
//$$ if (Restrictions.PLUGIN_CHANNEL.equals(p.getChannelName())) {
|
||||||
|
//$$ packet = new S40PacketDisconnect(new ChatComponentText("Please update to view this replay."));
|
||||||
|
//#endif
|
||||||
save(packet);
|
save(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -197,12 +238,15 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
super.channelRead(ctx, msg);
|
super.channelRead(ctx, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
private <T> void DataManager_set(EntityDataManager dataManager, EntityDataManager.DataEntry<T> entry) {
|
private <T> void DataManager_set(EntityDataManager dataManager, EntityDataManager.DataEntry<T> entry) {
|
||||||
dataManager.register(entry.getKey(), entry.getValue());
|
dataManager.register(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private byte[] getPacketData(Packet packet) throws Exception {
|
private byte[] getPacketData(Packet packet) throws Exception {
|
||||||
|
//#if MC>=10904
|
||||||
if (packet instanceof SPacketSpawnMob) {
|
if (packet instanceof SPacketSpawnMob) {
|
||||||
SPacketSpawnMob p = (SPacketSpawnMob) packet;
|
SPacketSpawnMob p = (SPacketSpawnMob) packet;
|
||||||
if (p.dataManager == null) {
|
if (p.dataManager == null) {
|
||||||
@@ -226,6 +270,39 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#else
|
||||||
|
//$$ if(packet instanceof S0FPacketSpawnMob) {
|
||||||
|
//$$ S0FPacketSpawnMob p = (S0FPacketSpawnMob) packet;
|
||||||
|
//$$ if (p.field_149043_l == null) {
|
||||||
|
//$$ p.field_149043_l = new DataWatcher(null);
|
||||||
|
//$$ if(p.func_149027_c() != null) {
|
||||||
|
//$$ for(DataWatcher.WatchableObject wo : (List<DataWatcher.WatchableObject>) p.func_149027_c()) {
|
||||||
|
//$$ p.field_149043_l.addObject(wo.getDataValueId(), wo.getObject());
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ if(packet instanceof S0CPacketSpawnPlayer) {
|
||||||
|
//$$ S0CPacketSpawnPlayer p = (S0CPacketSpawnPlayer) packet;
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ if (p.watcher == null) {
|
||||||
|
//$$ p.watcher = new DataWatcher(null);
|
||||||
|
//$$ if(p.func_148944_c() != null) {
|
||||||
|
//$$ for(DataWatcher.WatchableObject wo : p.func_148944_c()) {
|
||||||
|
//$$ p.watcher.addObject(wo.getDataValueId(), wo.getObject());
|
||||||
|
//#else
|
||||||
|
//$$ if (p.field_148960_i == null) {
|
||||||
|
//$$ p.field_148960_i = new DataWatcher(null);
|
||||||
|
//$$ if(p.func_148944_c() != null) {
|
||||||
|
//$$ for(DataWatcher.WatchableObject wo : (List<DataWatcher.WatchableObject>) p.func_148944_c()) {
|
||||||
|
//$$ p.field_148960_i.addObject(wo.getDataValueId(), wo.getObject());
|
||||||
|
//#endif
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
Integer packetId = EnumConnectionState.PLAY.getPacketId(EnumPacketDirection.CLIENTBOUND, packet);
|
Integer packetId = EnumConnectionState.PLAY.getPacketId(EnumPacketDirection.CLIENTBOUND, packet);
|
||||||
if (packetId == null) {
|
if (packetId == null) {
|
||||||
@@ -233,7 +310,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
ByteBuf byteBuf = Unpooled.buffer();
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
PacketBuffer packetBuffer = new PacketBuffer(byteBuf);
|
PacketBuffer packetBuffer = new PacketBuffer(byteBuf);
|
||||||
packetBuffer.writeVarInt(packetId);
|
writeVarInt(packetBuffer, packetId);
|
||||||
packet.writePacketData(packetBuffer);
|
packet.writePacketData(packetBuffer);
|
||||||
|
|
||||||
byteBuf.readerIndex(0);
|
byteBuf.readerIndex(0);
|
||||||
|
|||||||
@@ -9,19 +9,27 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiScreenWorking;
|
import net.minecraft.client.gui.GuiScreenWorking;
|
||||||
import net.minecraft.client.gui.GuiYesNo;
|
import net.minecraft.client.gui.GuiYesNo;
|
||||||
|
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||||
import net.minecraft.client.multiplayer.ServerData;
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
import net.minecraft.client.multiplayer.ServerList;
|
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.resources.ResourcePackRepository;
|
import net.minecraft.client.resources.ResourcePackRepository;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.play.client.CPacketResourcePackStatus;
|
|
||||||
import net.minecraft.network.play.server.SPacketResourcePackSend;
|
|
||||||
import net.minecraft.util.HttpUtil;
|
import net.minecraft.util.HttpUtil;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.network.play.client.CPacketResourcePackStatus;
|
||||||
|
import net.minecraft.network.play.client.CPacketResourcePackStatus.Action;
|
||||||
|
import net.minecraft.network.play.server.SPacketResourcePackSend;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.network.play.client.C19PacketResourcePackStatus;
|
||||||
|
//$$ import net.minecraft.network.play.client.C19PacketResourcePackStatus.Action;
|
||||||
|
//$$ import net.minecraft.network.play.server.S48PacketResourcePackSend;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -29,6 +37,8 @@ import java.io.OutputStream;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Records resource packs and handles incoming resource pack packets during recording.
|
* Records resource packs and handles incoming resource pack packets during recording.
|
||||||
*/
|
*/
|
||||||
@@ -74,12 +84,36 @@ public class ResourcePackRecorder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
public CPacketResourcePackStatus makeStatusPacket(String hash, Action action) {
|
||||||
|
//#if MC>=11002
|
||||||
|
return new CPacketResourcePackStatus(action);
|
||||||
|
//#else
|
||||||
|
//$$ return new CPacketResourcePackStatus(hash, action);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
//#else
|
||||||
|
//$$ public C19PacketResourcePackStatus makeStatusPacket(String hash, Action action) {
|
||||||
|
//$$ return new C19PacketResourcePackStatus(hash, action);
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
public synchronized SPacketResourcePackSend handleResourcePack(SPacketResourcePackSend packet) {
|
public synchronized SPacketResourcePackSend handleResourcePack(SPacketResourcePackSend packet) {
|
||||||
|
//#else
|
||||||
|
//$$ public synchronized S48PacketResourcePackSend handleResourcePack(S48PacketResourcePackSend packet) {
|
||||||
|
//#endif
|
||||||
final int requestId = nextRequestId++;
|
final int requestId = nextRequestId++;
|
||||||
final NetHandlerPlayClient netHandler = mc.getConnection();
|
final NetHandlerPlayClient netHandler = getConnection(mc);
|
||||||
final NetworkManager netManager = netHandler.getNetworkManager();
|
final NetworkManager netManager = netHandler.getNetworkManager();
|
||||||
|
//#if MC>=10809
|
||||||
final String url = packet.getURL();
|
final String url = packet.getURL();
|
||||||
final String hash = packet.getHash();
|
final String hash = packet.getHash();
|
||||||
|
//#else
|
||||||
|
//$$ final String url = packet.func_179783_a();
|
||||||
|
//$$ final String hash = packet.func_179784_b();
|
||||||
|
//#endif
|
||||||
|
|
||||||
if (url.startsWith("level://")) {
|
if (url.startsWith("level://")) {
|
||||||
String levelName = url.substring("level://".length());
|
String levelName = url.substring("level://".length());
|
||||||
@@ -87,60 +121,69 @@ public class ResourcePackRecorder {
|
|||||||
final File levelDir = new File(savesDir, levelName);
|
final File levelDir = new File(savesDir, levelName);
|
||||||
|
|
||||||
if (levelDir.isFile()) {
|
if (levelDir.isFile()) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
netManager.sendPacket(makeStatusPacket(hash, Action.ACCEPTED));
|
||||||
Futures.addCallback(mc.getResourcePackRepository().setServerResourcePack(levelDir), new FutureCallback<Object>() {
|
Futures.addCallback(setServerResourcePack(mc.getResourcePackRepository(), levelDir), new FutureCallback<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object result) {
|
public void onSuccess(Object result) {
|
||||||
recordResourcePack(levelDir, requestId);
|
recordResourcePack(levelDir, requestId);
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
netManager.sendPacket(makeStatusPacket(hash, Action.SUCCESSFULLY_LOADED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@Nonnull Throwable throwable) {
|
public void onFailure(@Nonnull Throwable throwable) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
netManager.sendPacket(makeStatusPacket(hash, Action.FAILED_DOWNLOAD));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
netManager.sendPacket(makeStatusPacket(hash, Action.FAILED_DOWNLOAD));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final ServerData serverData = mc.getCurrentServerData();
|
final ServerData serverData = mc.getCurrentServerData();
|
||||||
if (serverData != null && serverData.getResourceMode() == ServerData.ServerResourceMode.ENABLED) {
|
if (serverData != null && serverData.getResourceMode() == ServerData.ServerResourceMode.ENABLED) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
netManager.sendPacket(makeStatusPacket(hash, Action.ACCEPTED));
|
||||||
downloadResourcePackFuture(requestId, url, hash);
|
downloadResourcePackFuture(requestId, url, hash);
|
||||||
} else if (serverData != null && serverData.getResourceMode() != ServerData.ServerResourceMode.PROMPT) {
|
} else if (serverData != null && serverData.getResourceMode() != ServerData.ServerResourceMode.PROMPT) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
|
netManager.sendPacket(makeStatusPacket(hash, Action.DECLINED));
|
||||||
} else {
|
} else {
|
||||||
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiYesNo((result, id) -> {
|
// Lambdas MUST NOT be used with methods that need re-obfuscation in FG prior to 2.2 (will result in AbstractMethodError)
|
||||||
if (serverData != null) {
|
//noinspection Convert2Lambda
|
||||||
serverData.setResourceMode(result ? ServerData.ServerResourceMode.ENABLED : ServerData.ServerResourceMode.DISABLED);
|
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback() {
|
||||||
}
|
@Override
|
||||||
if (result) {
|
public void confirmClicked(boolean result, int id) {
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.ACCEPTED));
|
if (serverData != null) {
|
||||||
downloadResourcePackFuture(requestId, url, hash);
|
serverData.setResourceMode(result ? ServerData.ServerResourceMode.ENABLED : ServerData.ServerResourceMode.DISABLED);
|
||||||
} else {
|
}
|
||||||
netManager.sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.DECLINED));
|
if (result) {
|
||||||
}
|
netManager.sendPacket(makeStatusPacket(hash, Action.ACCEPTED));
|
||||||
|
downloadResourcePackFuture(requestId, url, hash);
|
||||||
|
} else {
|
||||||
|
netManager.sendPacket(makeStatusPacket(hash, Action.DECLINED));
|
||||||
|
}
|
||||||
|
|
||||||
ServerList.saveSingleServer(serverData);
|
ServerList_saveSingleServer(serverData);
|
||||||
mc.displayGuiScreen(null);
|
mc.displayGuiScreen(null);
|
||||||
|
}
|
||||||
}, I18n.format("multiplayer.texturePrompt.line1"), I18n.format("multiplayer.texturePrompt.line2"), 0)));
|
}, I18n.format("multiplayer.texturePrompt.line1"), I18n.format("multiplayer.texturePrompt.line2"), 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
return new SPacketResourcePackSend("replay://" + requestId, "");
|
return new SPacketResourcePackSend("replay://" + requestId, "");
|
||||||
|
//#else
|
||||||
|
//$$ return new S48PacketResourcePackSend("replay://" + requestId, "");
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadResourcePackFuture(int requestId, String url, final String hash) {
|
private void downloadResourcePackFuture(int requestId, String url, final String hash) {
|
||||||
Futures.addCallback(downloadResourcePack(requestId, url, hash), new FutureCallback() {
|
Futures.addCallback(downloadResourcePack(requestId, url, hash), new FutureCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object result) {
|
public void onSuccess(Object result) {
|
||||||
mc.getConnection().sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.SUCCESSFULLY_LOADED));
|
sendPacket(getConnection(mc), makeStatusPacket(hash, Action.SUCCESSFULLY_LOADED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@Nonnull Throwable throwable) {
|
public void onFailure(@Nonnull Throwable throwable) {
|
||||||
mc.getConnection().sendPacket(new CPacketResourcePackStatus(CPacketResourcePackStatus.Action.FAILED_DOWNLOAD));
|
sendPacket(getConnection(mc), makeStatusPacket(hash, Action.FAILED_DOWNLOAD));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -165,16 +208,24 @@ public class ResourcePackRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final File file = new File(repo.dirServerResourcepacks, fileName);
|
final File file = new File(repo.dirServerResourcepacks, fileName);
|
||||||
|
//#if MC>=10809
|
||||||
repo.lock.lock();
|
repo.lock.lock();
|
||||||
|
//#else
|
||||||
|
//$$ repo.field_177321_h.lock();
|
||||||
|
//#endif
|
||||||
try {
|
try {
|
||||||
|
//#if MC>=10809
|
||||||
repo.clearResourcePack();
|
repo.clearResourcePack();
|
||||||
|
//#else
|
||||||
|
//$$ repo.func_148529_f();
|
||||||
|
//#endif
|
||||||
|
|
||||||
if (file.exists() && hash.length() == 40) {
|
if (file.exists() && hash.length() == 40) {
|
||||||
try {
|
try {
|
||||||
String fileHash = Hashing.sha1().hashBytes(Files.toByteArray(file)).toString();
|
String fileHash = Hashing.sha1().hashBytes(Files.toByteArray(file)).toString();
|
||||||
if (fileHash.equals(hash)) {
|
if (fileHash.equals(hash)) {
|
||||||
recordResourcePack(file, requestId);
|
recordResourcePack(file, requestId);
|
||||||
return repo.setServerResourcePack(file);
|
return setServerResourcePack(repo, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.warn("File " + file + " had wrong hash (expected " + hash + ", found " + fileHash + "). Deleting it.");
|
logger.warn("File " + file + " had wrong hash (expected " + hash + ", found " + fileHash + "). Deleting it.");
|
||||||
@@ -190,13 +241,27 @@ public class ResourcePackRecorder {
|
|||||||
|
|
||||||
Futures.getUnchecked(mc.addScheduledTask(() -> mc.displayGuiScreen(guiScreen)));
|
Futures.getUnchecked(mc.addScheduledTask(() -> mc.displayGuiScreen(guiScreen)));
|
||||||
|
|
||||||
|
//#if MC>=10809
|
||||||
|
//#if MC>=11002
|
||||||
|
//#if MC>=11100
|
||||||
Map<String, String> sessionInfo = ResourcePackRepository.getDownloadHeaders();
|
Map<String, String> sessionInfo = ResourcePackRepository.getDownloadHeaders();
|
||||||
|
//#else
|
||||||
|
//$$ Map<String, String> sessionInfo = ResourcePackRepository.func_190115_a();
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//$$ Map<String, String> sessionInfo = Minecraft.getSessionInfo();
|
||||||
|
//#endif
|
||||||
repo.downloadingPacks = HttpUtil.downloadResourcePack(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
repo.downloadingPacks = HttpUtil.downloadResourcePack(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
||||||
Futures.addCallback(repo.downloadingPacks, new FutureCallback<Object>() {
|
Futures.addCallback(repo.downloadingPacks, new FutureCallback<Object>() {
|
||||||
|
//#else
|
||||||
|
//$$ Map sessionInfo = Minecraft.getSessionInfo();
|
||||||
|
//$$ repo.field_177322_i = HttpUtil.func_180192_a(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
||||||
|
//$$ Futures.addCallback(repo.field_177322_i, new FutureCallback() {
|
||||||
|
//#endif
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object value) {
|
public void onSuccess(Object value) {
|
||||||
recordResourcePack(file, requestId);
|
recordResourcePack(file, requestId);
|
||||||
repo.setServerResourcePack(file);
|
setServerResourcePack(repo, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -204,9 +269,17 @@ public class ResourcePackRecorder {
|
|||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
//#if MC>=10809
|
||||||
return repo.downloadingPacks;
|
return repo.downloadingPacks;
|
||||||
|
//#else
|
||||||
|
//$$ return repo.field_177322_i;
|
||||||
|
//#endif
|
||||||
} finally {
|
} finally {
|
||||||
|
//#if MC>=10809
|
||||||
repo.lock.unlock();
|
repo.lock.unlock();
|
||||||
|
//#else
|
||||||
|
//$$ repo.field_177321_h.unlock();
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.replaymod.render.utils.RenderJob;
|
|||||||
import com.replaymod.replay.events.ReplayCloseEvent;
|
import com.replaymod.replay.events.ReplayCloseEvent;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.util.ReportedException;
|
import net.minecraft.util.ReportedException;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
@@ -18,6 +17,8 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mod(modid = ReplayModRender.MOD_ID,
|
@Mod(modid = ReplayModRender.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
@@ -47,7 +48,7 @@ public class ReplayModRender {
|
|||||||
core = ReplayMod.instance;
|
core = ReplayMod.instance;
|
||||||
configuration = new Configuration(event.getSuggestedConfigurationFile());
|
configuration = new Configuration(event.getSuggestedConfigurationFile());
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
|
|
||||||
core.getSettingsRegistry().register(Setting.class);
|
core.getSettingsRegistry().register(Setting.class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.lwjgl.util.ReadableDimension;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.fog;
|
||||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||||
@@ -75,15 +76,15 @@ public class ODSFrameCapturer implements FrameCapturer<ODSOpenGlFrame> {
|
|||||||
linkState(1, "lightMapEnabled");
|
linkState(1, "lightMapEnabled");
|
||||||
linkState(2, "hurtTextureEnabled");
|
linkState(2, "hurtTextureEnabled");
|
||||||
final Program.Uniform uniform = shaderProgram.getUniformVariable("fogEnabled");
|
final Program.Uniform uniform = shaderProgram.getUniformVariable("fogEnabled");
|
||||||
previousFogState = GlStateManager.fogState.fog;
|
previousFogState = fog(GlStateManager.fogState);
|
||||||
uniform.set(previousFogState.currentState);
|
uniform.set(previousFogState.currentState);
|
||||||
GlStateManager.fogState.fog = new BooleanState(previousFogState.capability) {
|
fog(GlStateManager.fogState, new BooleanState(previousFogState.capability) {
|
||||||
@Override
|
@Override
|
||||||
public void setState(boolean state) {
|
public void setState(boolean state) {
|
||||||
super.setState(state);
|
super.setState(state);
|
||||||
uniform.set(state);
|
uniform.set(state);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
shaderProgram.stopUsing();
|
shaderProgram.stopUsing();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ReportedException(CrashReport.makeCrashReport(e, "Creating ODS shaders"));
|
throw new ReportedException(CrashReport.makeCrashReport(e, "Creating ODS shaders"));
|
||||||
@@ -135,7 +136,7 @@ public class ODSFrameCapturer implements FrameCapturer<ODSOpenGlFrame> {
|
|||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
GlStateManager.textureState[i].texture2DState = previousStates[i];
|
GlStateManager.textureState[i].texture2DState = previousStates[i];
|
||||||
}
|
}
|
||||||
GlStateManager.fogState.fog = previousFogState;
|
fog(GlStateManager.fogState, previousFogState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CubicStereoFrameCapturer extends CubicPboOpenGlFrameCapturer {
|
private class CubicStereoFrameCapturer extends CubicPboOpenGlFrameCapturer {
|
||||||
|
|||||||
@@ -10,7 +10,14 @@ import net.minecraft.client.renderer.chunk.RenderChunk;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
|
//#else
|
||||||
|
//$$ import java.util.concurrent.BlockingQueue;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class ChunkLoadingRenderGlobal {
|
public class ChunkLoadingRenderGlobal {
|
||||||
|
|
||||||
@@ -27,10 +34,18 @@ public class ChunkLoadingRenderGlobal {
|
|||||||
this.renderWorker = new CustomChunkRenderWorker(renderDispatcher, new RegionRenderCacheBuilder());
|
this.renderWorker = new CustomChunkRenderWorker(renderDispatcher, new RegionRenderCacheBuilder());
|
||||||
|
|
||||||
int workerThreads = renderDispatcher.listThreadedWorkers.size();
|
int workerThreads = renderDispatcher.listThreadedWorkers.size();
|
||||||
|
//#if MC>=10904
|
||||||
PriorityBlockingQueue<ChunkCompileTaskGenerator> queueChunkUpdates = renderDispatcher.queueChunkUpdates;
|
PriorityBlockingQueue<ChunkCompileTaskGenerator> queueChunkUpdates = renderDispatcher.queueChunkUpdates;
|
||||||
|
//#else
|
||||||
|
//$$ BlockingQueue<ChunkCompileTaskGenerator> queueChunkUpdates = renderDispatcher.queueChunkUpdates;
|
||||||
|
//#endif
|
||||||
workerJailingQueue = new JailingQueue<>(queueChunkUpdates);
|
workerJailingQueue = new JailingQueue<>(queueChunkUpdates);
|
||||||
renderDispatcher.queueChunkUpdates = workerJailingQueue;
|
renderDispatcher.queueChunkUpdates = workerJailingQueue;
|
||||||
|
//#if MC>=10904
|
||||||
ChunkCompileTaskGenerator element = new ChunkCompileTaskGenerator(null, null, 0);
|
ChunkCompileTaskGenerator element = new ChunkCompileTaskGenerator(null, null, 0);
|
||||||
|
//#else
|
||||||
|
//$$ ChunkCompileTaskGenerator element = new ChunkCompileTaskGenerator(null, null);
|
||||||
|
//#endif
|
||||||
element.finish();
|
element.finish();
|
||||||
for (int i = 0; i < workerThreads; i++) {
|
for (int i = 0; i < workerThreads; i++) {
|
||||||
queueChunkUpdates.add(element);
|
queueChunkUpdates.add(element);
|
||||||
@@ -58,17 +73,28 @@ public class ChunkLoadingRenderGlobal {
|
|||||||
|
|
||||||
while (!renderDispatcher.queueChunkUpdates.isEmpty()) {
|
while (!renderDispatcher.queueChunkUpdates.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
renderWorker.processTask(renderDispatcher.queueChunkUpdates.poll());
|
renderWorker.processTask(
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ (ChunkCompileTaskGenerator)
|
||||||
|
//#endif
|
||||||
|
renderDispatcher.queueChunkUpdates.poll());
|
||||||
} catch (InterruptedException ignored) { }
|
} catch (InterruptedException ignored) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ @SuppressWarnings("unchecked")
|
||||||
|
//#endif
|
||||||
Iterator<RenderChunk> iterator = hooked.chunksToUpdate.iterator();
|
Iterator<RenderChunk> iterator = hooked.chunksToUpdate.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
RenderChunk renderchunk = iterator.next();
|
RenderChunk renderchunk = iterator.next();
|
||||||
|
|
||||||
renderDispatcher.updateChunkNow(renderchunk);
|
renderDispatcher.updateChunkNow(renderchunk);
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
renderchunk.clearNeedsUpdate();
|
renderchunk.clearNeedsUpdate();
|
||||||
|
//#else
|
||||||
|
//$$ renderchunk.setNeedsUpdate(false);
|
||||||
|
//#endif
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.replaymod.render.mixin;
|
||||||
|
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ import com.replaymod.render.hooks.EntityRendererHandler;
|
||||||
|
//$$ import net.minecraft.client.Minecraft;
|
||||||
|
//$$ import net.minecraft.client.particle.EffectRenderer;
|
||||||
|
//$$ import net.minecraft.client.particle.EntityFX;
|
||||||
|
//$$ import net.minecraft.client.renderer.WorldRenderer;
|
||||||
|
//$$ import net.minecraft.entity.Entity;
|
||||||
|
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
//$$ import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
//$$ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
//$$
|
||||||
|
//$$ @Mixin(EffectRenderer.class)
|
||||||
|
//$$ public abstract class MixinEffectRenderer {
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ @Redirect(method = "renderParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EntityFX;renderParticle(Lnet/minecraft/client/renderer/WorldRenderer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
|
//#else
|
||||||
|
//$$ @Redirect(method = "renderParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EntityFX;func_180434_a(Lnet/minecraft/client/renderer/WorldRenderer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
|
//#endif
|
||||||
|
//$$ private void renderNormalParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks,
|
||||||
|
//$$ float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
|
//$$ renderParticle(fx, worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ @Redirect(method = "renderLitParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EntityFX;renderParticle(Lnet/minecraft/client/renderer/WorldRenderer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
|
//#else
|
||||||
|
//$$ @Redirect(method = "renderLitParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/EntityFX;func_180434_a(Lnet/minecraft/client/renderer/WorldRenderer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
|
//#endif
|
||||||
|
//$$ private void renderLitParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks,
|
||||||
|
//$$ float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
|
//$$ renderParticle(fx, worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ private void renderParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks,
|
||||||
|
//$$ float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
|
//$$ EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
|
//$$ if (handler != null && handler.omnidirectional) {
|
||||||
|
//$$ // Align all particles towards the camera
|
||||||
|
//$$ double dx = fx.prevPosX + (fx.posX - fx.prevPosX) * partialTicks - view.posX;
|
||||||
|
//$$ double dy = fx.prevPosY + (fx.posY - fx.prevPosY) * partialTicks - view.posY;
|
||||||
|
//$$ double dz = fx.prevPosZ + (fx.posZ - fx.prevPosZ) * partialTicks - view.posZ;
|
||||||
|
//$$ double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
||||||
|
//$$ double yaw = -Math.atan2(dx, dz);
|
||||||
|
//$$
|
||||||
|
//$$ rotX = (float) Math.cos(yaw);
|
||||||
|
//$$ rotZ = (float) Math.sin(yaw);
|
||||||
|
//$$ rotXZ = (float) Math.cos(pitch);
|
||||||
|
//$$
|
||||||
|
//$$ rotYZ = (float) (-rotZ * Math.sin(pitch));
|
||||||
|
//$$ rotXY = (float) (rotX * Math.sin(pitch));
|
||||||
|
//$$ }
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ fx.renderParticle(worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
|
//#else
|
||||||
|
//$$ fx.func_180434_a(worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
|
//#endif
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
@@ -12,7 +12,6 @@ import net.minecraft.client.renderer.RenderGlobal;
|
|||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.util.ReadableColor;
|
import org.lwjgl.util.ReadableColor;
|
||||||
import org.lwjgl.util.glu.Project;
|
import org.lwjgl.util.glu.Project;
|
||||||
@@ -23,6 +22,12 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.util.MovingObjectPosition;
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Mixin(value = EntityRenderer.class)
|
@Mixin(value = EntityRenderer.class)
|
||||||
public abstract class MixinEntityRenderer implements EntityRendererHandler.IEntityRenderer, EntityRendererHandler.GluPerspective {
|
public abstract class MixinEntityRenderer implements EntityRendererHandler.IEntityRenderer, EntityRendererHandler.GluPerspective {
|
||||||
@Shadow
|
@Shadow
|
||||||
@@ -118,8 +123,13 @@ public abstract class MixinEntityRenderer implements EntityRendererHandler.IEnti
|
|||||||
@Shadow
|
@Shadow
|
||||||
public abstract void renderHand(float partialTicks, int renderPass);
|
public abstract void renderHand(float partialTicks, int renderPass);
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
@Redirect(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;drawSelectionBox(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/util/math/RayTraceResult;IF)V"))
|
@Redirect(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;drawSelectionBox(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/util/math/RayTraceResult;IF)V"))
|
||||||
private void replayModRender_drawSelectionBox(RenderGlobal instance, EntityPlayer player, RayTraceResult rtr, int alwaysZero, float partialTicks) {
|
private void replayModRender_drawSelectionBox(RenderGlobal instance, EntityPlayer player, RayTraceResult rtr, int alwaysZero, float partialTicks) {
|
||||||
|
//#else
|
||||||
|
//$$ @Redirect(method = "renderWorldPass", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;drawSelectionBox(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/util/MovingObjectPosition;IF)V"))
|
||||||
|
//$$ private void replayModRender_drawSelectionBox(RenderGlobal instance, EntityPlayer player, MovingObjectPosition rtr, int alwaysZero, float partialTicks) {
|
||||||
|
//#endif
|
||||||
if (replayModRender_handler == null) {
|
if (replayModRender_handler == null) {
|
||||||
instance.drawSelectionBox(player, rtr, alwaysZero, partialTicks);
|
instance.drawSelectionBox(player, rtr, alwaysZero, partialTicks);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,50 @@
|
|||||||
package com.replaymod.render.mixin;
|
package com.replaymod.render.mixin;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
import com.replaymod.render.hooks.EntityRendererHandler;
|
import com.replaymod.render.hooks.EntityRendererHandler;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.particle.Particle;
|
import net.minecraft.client.particle.Particle;
|
||||||
import net.minecraft.client.particle.ParticleManager;
|
import net.minecraft.client.particle.ParticleManager;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.renderer.VertexBuffer;
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Mixin(ParticleManager.class)
|
@Mixin(ParticleManager.class)
|
||||||
public abstract class MixinParticleManager {
|
public abstract class MixinParticleManager {
|
||||||
|
//#if MC>=11200
|
||||||
@Redirect(method = "renderParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/BufferBuilder;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
@Redirect(method = "renderParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/BufferBuilder;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
private void renderNormalParticle(Particle particle, BufferBuilder vertexBuffer, Entity view, float partialTicks,
|
private void renderNormalParticle(Particle particle, BufferBuilder vertexBuffer, Entity view, float partialTicks,
|
||||||
|
//#else
|
||||||
|
//$$ @Redirect(method = "renderParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/VertexBuffer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
|
//$$ private void renderNormalParticle(Particle particle, VertexBuffer vertexBuffer, Entity view, float partialTicks,
|
||||||
|
//#endif
|
||||||
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
renderParticle(particle, vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
renderParticle(particle, vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
@Redirect(method = "renderLitParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/BufferBuilder;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
@Redirect(method = "renderLitParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/BufferBuilder;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
private void renderLitParticle(Particle particle, BufferBuilder vertexBuffer, Entity view, float partialTicks,
|
private void renderLitParticle(Particle particle, BufferBuilder vertexBuffer, Entity view, float partialTicks,
|
||||||
|
//#else
|
||||||
|
//$$ @Redirect(method = "renderLitParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/VertexBuffer;Lnet/minecraft/entity/Entity;FFFFFF)V"))
|
||||||
|
//$$ private void renderLitParticle(Particle particle, VertexBuffer vertexBuffer, Entity view, float partialTicks,
|
||||||
|
//#endif
|
||||||
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
renderParticle(particle, vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
renderParticle(particle, vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
private void renderParticle(Particle particle, BufferBuilder vertexBuffer, Entity view, float partialTicks,
|
private void renderParticle(Particle particle, BufferBuilder vertexBuffer, Entity view, float partialTicks,
|
||||||
|
//#else
|
||||||
|
//$$ private void renderParticle(Particle particle, VertexBuffer vertexBuffer, Entity view, float partialTicks,
|
||||||
|
//#endif
|
||||||
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||||
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
if (handler != null && handler.omnidirectional) {
|
if (handler != null && handler.omnidirectional) {
|
||||||
@@ -45,3 +65,4 @@ public abstract class MixinParticleManager {
|
|||||||
particle.renderParticle(vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
particle.renderParticle(vertexBuffer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||||
|
//$$ import net.minecraft.util.BlockPos;
|
||||||
|
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Mixin(RenderGlobal.class)
|
@Mixin(RenderGlobal.class)
|
||||||
public abstract class MixinRenderGlobal {
|
public abstract class MixinRenderGlobal {
|
||||||
public ChunkLoadingRenderGlobal replayModRender_hook;
|
public ChunkLoadingRenderGlobal replayModRender_hook;
|
||||||
@@ -44,6 +50,15 @@ public abstract class MixinRenderGlobal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ @Inject(method = "isPositionInRenderChunk", at = @At("HEAD"), cancellable = true)
|
||||||
|
//$$ public void replayModRender_isPositionInRenderChunk(BlockPos pos, RenderChunk chunk, CallbackInfoReturnable<Boolean> ci) {
|
||||||
|
//$$ if (replayModRender_hook != null) {
|
||||||
|
//$$ ci.setReturnValue(true);
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Inject(method = "updateChunks", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "updateChunks", at = @At("HEAD"), cancellable = true)
|
||||||
public void replayModRender_updateChunks(long finishTimeNano, CallbackInfo ci) {
|
public void replayModRender_updateChunks(long finishTimeNano, CallbackInfo ci) {
|
||||||
if (replayModRender_hook != null) {
|
if (replayModRender_hook != null) {
|
||||||
|
|||||||
@@ -8,7 +8,12 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
//#else
|
||||||
|
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Mixin(RenderManager.class)
|
@Mixin(RenderManager.class)
|
||||||
public abstract class MixinRenderManager {
|
public abstract class MixinRenderManager {
|
||||||
@@ -19,7 +24,11 @@ public abstract class MixinRenderManager {
|
|||||||
private float playerViewY;
|
private float playerViewY;
|
||||||
|
|
||||||
@Inject(method = "doRenderEntity", at = @At("HEAD"))
|
@Inject(method = "doRenderEntity", at = @At("HEAD"))
|
||||||
|
//#if MC>=10904
|
||||||
private void replayModRender_reorientForCubicRendering(Entity entity, double dx, double dy, double dz, float iDoNotKnow, float partialTicks, boolean iDoNotCare, CallbackInfo ci) {
|
private void replayModRender_reorientForCubicRendering(Entity entity, double dx, double dy, double dz, float iDoNotKnow, float partialTicks, boolean iDoNotCare, CallbackInfo ci) {
|
||||||
|
//#else
|
||||||
|
//$$ private void replayModRender_reorientForCubicRendering(Entity entity, double dx, double dy, double dz, float iDoNotKnow, float partialTicks, boolean iDoNotCare, CallbackInfoReturnable<Boolean> ci) {
|
||||||
|
//#endif
|
||||||
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
if (handler != null && handler.omnidirectional) {
|
if (handler != null && handler.omnidirectional) {
|
||||||
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.replaymod.render.mixin;
|
||||||
|
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ import com.replaymod.render.hooks.EntityRendererHandler;
|
||||||
|
//$$ import net.minecraft.client.Minecraft;
|
||||||
|
//$$ import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||||
|
//$$ import net.minecraft.entity.EntityLivingBase;
|
||||||
|
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
//$$ import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
//$$ import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
//$$
|
||||||
|
//$$ @Mixin(RendererLivingEntity.class)
|
||||||
|
//$$ public abstract class MixinRendererLivingEntity {
|
||||||
|
//$$ @Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
||||||
|
//$$ private void replayModRender_areAllNamesHidden(EntityLivingBase entity, CallbackInfoReturnable<Boolean> ci) {
|
||||||
|
//$$ EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) Minecraft.getMinecraft().entityRenderer).replayModRender_getHandler();
|
||||||
|
//$$ if (handler != null && !handler.getSettings().isRenderNameTags()) {
|
||||||
|
//$$ ci.setReturnValue(false); //this calls the cancel method
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
@@ -23,14 +23,18 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.gui.ScaledResolution;
|
import net.minecraft.client.gui.ScaledResolution;
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.client.shader.Framebuffer;
|
import net.minecraft.client.shader.Framebuffer;
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.Timer;
|
import net.minecraft.util.Timer;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.audio.SoundCategory;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
@@ -40,6 +44,7 @@ import java.util.concurrent.Future;
|
|||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.getLast;
|
import static com.google.common.collect.Iterables.getLast;
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
import static com.replaymod.render.ReplayModRender.LOGGER;
|
import static com.replaymod.render.ReplayModRender.LOGGER;
|
||||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||||
@@ -56,7 +61,11 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
private int fps;
|
private int fps;
|
||||||
private boolean mouseWasGrabbed;
|
private boolean mouseWasGrabbed;
|
||||||
private boolean debugInfoWasShown;
|
private boolean debugInfoWasShown;
|
||||||
|
//#if MC>=10904
|
||||||
private Map<SoundCategory, Float> originalSoundLevels;
|
private Map<SoundCategory, Float> originalSoundLevels;
|
||||||
|
//#else
|
||||||
|
//$$ private Map originalSoundLevels;
|
||||||
|
//#endif
|
||||||
|
|
||||||
private TimelinePlayer timelinePlayer;
|
private TimelinePlayer timelinePlayer;
|
||||||
private Future<Void> timelinePlayerFuture;
|
private Future<Void> timelinePlayerFuture;
|
||||||
@@ -93,7 +102,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
* @return {@code true} if rendering was successful, {@code false} if the user aborted rendering (or the window was closed)
|
* @return {@code true} if rendering was successful, {@code false} if the user aborted rendering (or the window was closed)
|
||||||
*/
|
*/
|
||||||
public boolean renderVideo() throws Throwable {
|
public boolean renderVideo() throws Throwable {
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayRenderEvent.Pre(this));
|
FML_BUS.post(new ReplayRenderEvent.Pre(this));
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
@@ -114,8 +123,13 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
if (videoStart > 1000) {
|
if (videoStart > 1000) {
|
||||||
int replayTime = videoStart - 1000;
|
int replayTime = videoStart - 1000;
|
||||||
|
//#if MC>=11200
|
||||||
timer.renderPartialTicks = 0;
|
timer.renderPartialTicks = 0;
|
||||||
timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK;
|
timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK;
|
||||||
|
//#else
|
||||||
|
//$$ timer.elapsedPartialTicks = timer.renderPartialTicks = 0;
|
||||||
|
//$$ timer.timerSpeed = 1;
|
||||||
|
//#endif
|
||||||
while (replayTime < videoStart) {
|
while (replayTime < videoStart) {
|
||||||
timer.elapsedTicks = 1;
|
timer.elapsedTicks = 1;
|
||||||
replayTime += 50;
|
replayTime += 50;
|
||||||
@@ -139,7 +153,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayRenderEvent.Post(this));
|
FML_BUS.post(new ReplayRenderEvent.Post(this));
|
||||||
|
|
||||||
if (failureCause != null) {
|
if (failureCause != null) {
|
||||||
throw failureCause;
|
throw failureCause;
|
||||||
@@ -203,9 +217,15 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
for (SoundCategory category : SoundCategory.values()) {
|
for (SoundCategory category : SoundCategory.values()) {
|
||||||
mutedSounds.put(category, 0f);
|
mutedSounds.put(category, 0f);
|
||||||
}
|
}
|
||||||
|
//#if MC>=10904
|
||||||
originalSoundLevels = mc.gameSettings.soundLevels;
|
originalSoundLevels = mc.gameSettings.soundLevels;
|
||||||
mutedSounds.put(SoundCategory.MASTER, originalSoundLevels.get(SoundCategory.MASTER));
|
mutedSounds.put(SoundCategory.MASTER, originalSoundLevels.get(SoundCategory.MASTER));
|
||||||
mc.gameSettings.soundLevels = mutedSounds;
|
mc.gameSettings.soundLevels = mutedSounds;
|
||||||
|
//#else
|
||||||
|
//$$ originalSoundLevels = mc.gameSettings.mapSoundLevels;
|
||||||
|
//$$ mutedSounds.put(SoundCategory.MASTER, (Float) originalSoundLevels.get(SoundCategory.MASTER));
|
||||||
|
//$$ mc.gameSettings.mapSoundLevels = mutedSounds;
|
||||||
|
//#endif
|
||||||
|
|
||||||
fps = settings.getFramesPerSecond();
|
fps = settings.getFramesPerSecond();
|
||||||
|
|
||||||
@@ -226,6 +246,11 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
updateDisplaySize();
|
updateDisplaySize();
|
||||||
|
|
||||||
|
//#if MC<=10809
|
||||||
|
//$$ ScaledResolution scaled = newScaledResolution(mc);
|
||||||
|
//$$ gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
|
||||||
|
//#endif
|
||||||
|
|
||||||
chunkLoadingRenderGlobal = new ChunkLoadingRenderGlobal(mc.renderGlobal);
|
chunkLoadingRenderGlobal = new ChunkLoadingRenderGlobal(mc.renderGlobal);
|
||||||
|
|
||||||
// Set up our own framebuffer to render the GUI to
|
// Set up our own framebuffer to render the GUI to
|
||||||
@@ -246,7 +271,11 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
if (mouseWasGrabbed) {
|
if (mouseWasGrabbed) {
|
||||||
mc.mouseHelper.grabMouseCursor();
|
mc.mouseHelper.grabMouseCursor();
|
||||||
}
|
}
|
||||||
|
//#if MC>=10904
|
||||||
mc.gameSettings.soundLevels = originalSoundLevels;
|
mc.gameSettings.soundLevels = originalSoundLevels;
|
||||||
|
//#else
|
||||||
|
//$$ mc.gameSettings.mapSoundLevels = originalSoundLevels;
|
||||||
|
//#endif
|
||||||
mc.displayGuiScreen(null);
|
mc.displayGuiScreen(null);
|
||||||
if (chunkLoadingRenderGlobal != null) {
|
if (chunkLoadingRenderGlobal != null) {
|
||||||
chunkLoadingRenderGlobal.uninstall();
|
chunkLoadingRenderGlobal.uninstall();
|
||||||
@@ -296,7 +325,7 @@ public class VideoRenderer implements RenderInfo {
|
|||||||
|
|
||||||
mc.entityRenderer.setupOverlayRendering();
|
mc.entityRenderer.setupOverlayRendering();
|
||||||
|
|
||||||
ScaledResolution scaled = new ScaledResolution(mc);
|
ScaledResolution scaled = newScaledResolution(mc);
|
||||||
gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
|
gui.toMinecraft().setWorldAndResolution(mc, scaled.getScaledWidth(), scaled.getScaledHeight());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -6,14 +6,34 @@ import java.util.Collection;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class JailingQueue<T> extends PriorityBlockingQueue<T> {
|
//#if MC>=10904
|
||||||
private final PriorityBlockingQueue<T> delegate;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
private final Set<Thread> jailed = new HashSet<Thread>();
|
//#else
|
||||||
|
//$$ import java.util.AbstractQueue;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
public class JailingQueue<T>
|
||||||
|
//#if MC>=10904
|
||||||
|
extends PriorityBlockingQueue<T>
|
||||||
|
//#else
|
||||||
|
//$$ extends AbstractQueue<T> implements BlockingQueue<T>
|
||||||
|
//#endif
|
||||||
|
{
|
||||||
|
//#if MC>=10904
|
||||||
|
private final PriorityBlockingQueue<T> delegate;
|
||||||
|
//#else
|
||||||
|
//$$ private final BlockingQueue<T> delegate;
|
||||||
|
//#endif
|
||||||
|
private final Set<Thread> jailed = new HashSet<>();
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
public JailingQueue(PriorityBlockingQueue<T> delegate) {
|
public JailingQueue(PriorityBlockingQueue<T> delegate) {
|
||||||
|
//#else
|
||||||
|
//$$ public JailingQueue(BlockingQueue<T> delegate) {
|
||||||
|
//#endif
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,13 +82,21 @@ public class JailingQueue<T> extends PriorityBlockingQueue<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(T t) {
|
public void put(T t)
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ throws InterruptedException
|
||||||
|
//#endif
|
||||||
|
{
|
||||||
tryAccess();
|
tryAccess();
|
||||||
delegate.put(t);
|
delegate.put(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean offer(T t, long timeout, TimeUnit unit) {
|
public boolean offer(T t, long timeout, TimeUnit unit)
|
||||||
|
//#if MC<10904
|
||||||
|
//$$ throws InterruptedException
|
||||||
|
//#endif
|
||||||
|
{
|
||||||
tryAccess();
|
tryAccess();
|
||||||
return delegate.offer(t, timeout, unit);
|
return delegate.offer(t, timeout, unit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,11 @@ public class InputReplayTimer extends WrappedTimer {
|
|||||||
// TODO: Translate magic values to Keyboard.KEY_ constants
|
// TODO: Translate magic values to Keyboard.KEY_ constants
|
||||||
|
|
||||||
if (key == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
if (key == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
||||||
|
//#if MC>=11100
|
||||||
mc.ingameGUI.getChatGUI().clearChatMessages(false);
|
mc.ingameGUI.getChatGUI().clearChatMessages(false);
|
||||||
|
//#else
|
||||||
|
//$$ mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == 31 && Keyboard.isKeyDown(61)) {
|
if (key == 31 && Keyboard.isKeyDown(61)) {
|
||||||
|
|||||||
@@ -43,7 +43,11 @@ public class NoGuiScreenshot {
|
|||||||
mc.getFramebuffer().bindFramebuffer(true);
|
mc.getFramebuffer().bindFramebuffer(true);
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
|
|
||||||
|
//#if MC>=10809
|
||||||
mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks, System.nanoTime());
|
mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks, System.nanoTime());
|
||||||
|
//#else
|
||||||
|
//$$ mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks);
|
||||||
|
//#endif
|
||||||
|
|
||||||
mc.getFramebuffer().unbindFramebuffer();
|
mc.getFramebuffer().unbindFramebuffer();
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import org.lwjgl.opengl.Display;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||||
@@ -77,7 +78,7 @@ public class ReplayHandler {
|
|||||||
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
||||||
this.replayFile = replayFile;
|
this.replayFile = replayFile;
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayOpenEvent.Pre(this));
|
FML_BUS.post(new ReplayOpenEvent.Pre(this));
|
||||||
|
|
||||||
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
|
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ public class ReplayHandler {
|
|||||||
overlay = new GuiReplayOverlay(this);
|
overlay = new GuiReplayOverlay(this);
|
||||||
overlay.setVisible(true);
|
overlay.setVisible(true);
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayOpenEvent.Post(this));
|
FML_BUS.post(new ReplayOpenEvent.Post(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void restartedReplay() {
|
void restartedReplay() {
|
||||||
@@ -102,7 +103,7 @@ public class ReplayHandler {
|
|||||||
public void endReplay() throws IOException {
|
public void endReplay() throws IOException {
|
||||||
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayCloseEvent.Pre(this));
|
FML_BUS.post(new ReplayCloseEvent.Pre(this));
|
||||||
|
|
||||||
replaySender.terminateReplay();
|
replaySender.terminateReplay();
|
||||||
|
|
||||||
@@ -111,27 +112,35 @@ public class ReplayHandler {
|
|||||||
|
|
||||||
channel.close().awaitUninterruptibly();
|
channel.close().awaitUninterruptibly();
|
||||||
|
|
||||||
if (mc.player instanceof CameraEntity) {
|
if (player(mc) instanceof CameraEntity) {
|
||||||
mc.player.setDead();
|
player(mc).setDead();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc.world != null) {
|
if (world(mc) != null) {
|
||||||
mc.world.sendQuittingDisconnectingPacket();
|
world(mc).sendQuittingDisconnectingPacket();
|
||||||
mc.loadWorld(null);
|
mc.loadWorld(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK;
|
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK;
|
||||||
|
//#else
|
||||||
|
//$$ mc.timer.timerSpeed = 1;
|
||||||
|
//#endif
|
||||||
overlay.setVisible(false);
|
overlay.setVisible(false);
|
||||||
|
|
||||||
ReplayModReplay.instance.replayHandler = null;
|
ReplayModReplay.instance.replayHandler = null;
|
||||||
|
|
||||||
mc.displayGuiScreen(null);
|
mc.displayGuiScreen(null);
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReplayCloseEvent.Post(this));
|
FML_BUS.post(new ReplayCloseEvent.Post(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
mc.ingameGUI.getChatGUI().clearChatMessages(true);
|
//#if MC>=11100
|
||||||
|
mc.ingameGUI.getChatGUI().clearChatMessages(false);
|
||||||
|
//#else
|
||||||
|
//$$ mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||||
|
//#endif
|
||||||
|
|
||||||
NetworkManager networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND) {
|
NetworkManager networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND) {
|
||||||
@Override
|
@Override
|
||||||
@@ -144,6 +153,7 @@ public class ReplayHandler {
|
|||||||
networkManager.setNetHandler(netHandlerPlayClient);
|
networkManager.setNetHandler(netHandlerPlayClient);
|
||||||
FMLClientHandler.instance().setPlayClient(netHandlerPlayClient);
|
FMLClientHandler.instance().setPlayClient(netHandlerPlayClient);
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
channel = new EmbeddedChannel();
|
channel = new EmbeddedChannel();
|
||||||
NetworkDispatcher networkDispatcher = new NetworkDispatcher(networkManager);
|
NetworkDispatcher networkDispatcher = new NetworkDispatcher(networkManager);
|
||||||
channel.attr(NetworkDispatcher.FML_DISPATCHER).set(networkDispatcher);
|
channel.attr(NetworkDispatcher.FML_DISPATCHER).set(networkDispatcher);
|
||||||
@@ -152,6 +162,15 @@ public class ReplayHandler {
|
|||||||
channel.pipeline().addLast("packet_handler", networkManager);
|
channel.pipeline().addLast("packet_handler", networkManager);
|
||||||
channel.pipeline().fireChannelActive();
|
channel.pipeline().fireChannelActive();
|
||||||
networkDispatcher.clientToServerHandshake();
|
networkDispatcher.clientToServerHandshake();
|
||||||
|
//#else
|
||||||
|
//$$ channel = new EmbeddedChannel(networkManager);
|
||||||
|
//$$ NetworkDispatcher networkDispatcher = new NetworkDispatcher(networkManager);
|
||||||
|
//$$ channel.attr(NetworkDispatcher.FML_DISPATCHER).set(networkDispatcher);
|
||||||
|
//$$
|
||||||
|
//$$ channel.pipeline().addFirst("ReplayModReplay_replaySender", replaySender);
|
||||||
|
//$$ channel.pipeline().addAfter("ReplayModReplay_replaySender", "fml:packet_handler", networkDispatcher);
|
||||||
|
//$$ channel.pipeline().fireChannelActive();
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplayFile getReplayFile() {
|
public ReplayFile getReplayFile() {
|
||||||
@@ -248,7 +267,7 @@ public class ReplayHandler {
|
|||||||
* @return {@code true} if the camera is the view entity, {@code false} otherwise
|
* @return {@code true} if the camera is the view entity, {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isCameraView() {
|
public boolean isCameraView() {
|
||||||
return mc.player instanceof CameraEntity && mc.player == mc.getRenderViewEntity();
|
return player(mc) instanceof CameraEntity && player(mc) == mc.getRenderViewEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -256,7 +275,7 @@ public class ReplayHandler {
|
|||||||
* @return The camera entity or {@code null} if it does not yet exist
|
* @return The camera entity or {@code null} if it does not yet exist
|
||||||
*/
|
*/
|
||||||
public CameraEntity getCameraEntity() {
|
public CameraEntity getCameraEntity() {
|
||||||
return mc.player instanceof CameraEntity ? (CameraEntity) mc.player : null;
|
return player(mc) instanceof CameraEntity ? (CameraEntity) player(mc) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getSpectatedUUID() {
|
public UUID getSpectatedUUID() {
|
||||||
@@ -303,7 +322,7 @@ public class ReplayHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
drawBackground(0);
|
drawBackground(0);
|
||||||
drawCenteredString(fontRenderer, I18n.format("replaymod.gui.pleasewait"),
|
drawCenteredString(getFontRenderer(mc), I18n.format("replaymod.gui.pleasewait"),
|
||||||
width / 2, height / 2, 0xffffffff);
|
width / 2, height / 2, 0xffffffff);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -318,7 +337,7 @@ public class ReplayHandler {
|
|||||||
mc.getFramebuffer().bindFramebuffer(true);
|
mc.getFramebuffer().bindFramebuffer(true);
|
||||||
mc.entityRenderer.setupOverlayRendering();
|
mc.entityRenderer.setupOverlayRendering();
|
||||||
|
|
||||||
ScaledResolution resolution = new ScaledResolution(mc);
|
ScaledResolution resolution = newScaledResolution(mc);
|
||||||
guiScreen.setWorldAndResolution(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
|
guiScreen.setWorldAndResolution(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
|
||||||
guiScreen.drawScreen(0, 0, 0);
|
guiScreen.drawScreen(0, 0, 0);
|
||||||
|
|
||||||
@@ -335,8 +354,8 @@ public class ReplayHandler {
|
|||||||
replaySender.setAsyncMode(true);
|
replaySender.setAsyncMode(true);
|
||||||
replaySender.setReplaySpeed(0);
|
replaySender.setReplaySpeed(0);
|
||||||
|
|
||||||
mc.getConnection().getNetworkManager().processReceivedPackets();
|
getConnection(mc).getNetworkManager().processReceivedPackets();
|
||||||
for (Entity entity : mc.world.loadedEntityList) {
|
for (Entity entity : loadedEntityList(world(mc))) {
|
||||||
if (entity instanceof EntityOtherPlayerMP) {
|
if (entity instanceof EntityOtherPlayerMP) {
|
||||||
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
||||||
e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ);
|
e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.core.utils.Restrictions;
|
import com.replaymod.core.utils.Restrictions;
|
||||||
import com.replaymod.core.utils.WrappedTimer;
|
|
||||||
import com.replaymod.replay.camera.CameraEntity;
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
import com.replaymod.replaystudio.io.ReplayInputStream;
|
import com.replaymod.replaystudio.io.ReplayInputStream;
|
||||||
import com.replaymod.replaystudio.io.ReplayOutputStream;
|
import com.replaymod.replaystudio.io.ReplayOutputStream;
|
||||||
@@ -26,11 +25,7 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.network.*;
|
import net.minecraft.network.*;
|
||||||
import net.minecraft.network.play.server.*;
|
import net.minecraft.network.play.server.*;
|
||||||
import net.minecraft.util.ClassInheritanceMultiMap;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.world.EnumDifficulty;
|
import net.minecraft.world.EnumDifficulty;
|
||||||
import net.minecraft.world.GameType;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldType;
|
import net.minecraft.world.WorldType;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
@@ -41,12 +36,29 @@ import net.minecraftforge.fml.common.gameevent.TickEvent;
|
|||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
|
import com.replaymod.core.utils.WrappedTimer;
|
||||||
|
//#endif
|
||||||
|
//#if MC>=11002
|
||||||
|
import net.minecraft.world.GameType;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.world.WorldSettings.GameType;
|
||||||
|
//#endif
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.util.IChatComponent;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends replay packets to netty channels.
|
* Sends replay packets to netty channels.
|
||||||
* Even though {@link Sharable}, this should never be added to multiple pipes at once, it may however be re-added when
|
* Even though {@link Sharable}, this should never be added to multiple pipes at once, it may however be re-added when
|
||||||
@@ -58,10 +70,13 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
* These packets are ignored completely during replay.
|
* These packets are ignored completely during replay.
|
||||||
*/
|
*/
|
||||||
private static final List<Class> BAD_PACKETS = Arrays.<Class>asList(
|
private static final List<Class> BAD_PACKETS = Arrays.<Class>asList(
|
||||||
// TODO Update possibly more?
|
//#if MC>=11200
|
||||||
SPacketRecipeBook.class,
|
SPacketRecipeBook.class,
|
||||||
SPacketAdvancementInfo.class,
|
SPacketAdvancementInfo.class,
|
||||||
SPacketSelectAdvancementsTab.class,
|
SPacketSelectAdvancementsTab.class,
|
||||||
|
//#endif
|
||||||
|
//#if MC>=10904
|
||||||
|
// TODO Update possibly more?
|
||||||
SPacketUpdateHealth.class,
|
SPacketUpdateHealth.class,
|
||||||
SPacketOpenWindow.class,
|
SPacketOpenWindow.class,
|
||||||
SPacketCloseWindow.class,
|
SPacketCloseWindow.class,
|
||||||
@@ -72,7 +87,21 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
SPacketSetExperience.class,
|
SPacketSetExperience.class,
|
||||||
SPacketCamera.class,
|
SPacketCamera.class,
|
||||||
SPacketPlayerAbilities.class,
|
SPacketPlayerAbilities.class,
|
||||||
SPacketTitle.class);
|
SPacketTitle.class
|
||||||
|
//#else
|
||||||
|
//$$ S06PacketUpdateHealth.class,
|
||||||
|
//$$ S2DPacketOpenWindow.class,
|
||||||
|
//$$ S2EPacketCloseWindow.class,
|
||||||
|
//$$ S2FPacketSetSlot.class,
|
||||||
|
//$$ S30PacketWindowItems.class,
|
||||||
|
//$$ S36PacketSignEditorOpen.class,
|
||||||
|
//$$ S37PacketStatistics.class,
|
||||||
|
//$$ S1FPacketSetExperience.class,
|
||||||
|
//$$ S43PacketCamera.class,
|
||||||
|
//$$ S39PacketPlayerAbilities.class,
|
||||||
|
//$$ S45PacketTitle.class
|
||||||
|
//#endif
|
||||||
|
);
|
||||||
|
|
||||||
private static int TP_DISTANCE_LIMIT = 128;
|
private static int TP_DISTANCE_LIMIT = 128;
|
||||||
|
|
||||||
@@ -271,8 +300,8 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
// Entity#addedToChunk is not set and it is therefore not updated every tick.
|
// Entity#addedToChunk is not set and it is therefore not updated every tick.
|
||||||
// To counteract this, we need to manually update it's position if it hasn't been added
|
// To counteract this, we need to manually update it's position if it hasn't been added
|
||||||
// to any chunk yet.
|
// to any chunk yet.
|
||||||
if (mc.world != null) {
|
if (world(mc) != null) {
|
||||||
for (EntityPlayer playerEntity : mc.world.playerEntities) {
|
for (EntityPlayer playerEntity : playerEntities(world(mc))) {
|
||||||
if (!playerEntity.addedToChunk && playerEntity instanceof EntityOtherPlayerMP) {
|
if (!playerEntity.addedToChunk && playerEntity instanceof EntityOtherPlayerMP) {
|
||||||
playerEntity.onLivingUpdate();
|
playerEntity.onLivingUpdate();
|
||||||
}
|
}
|
||||||
@@ -306,7 +335,8 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
// If we do not give minecraft time to tick, there will be dead entity artifacts left in the world
|
// If we do not give minecraft time to tick, there will be dead entity artifacts left in the world
|
||||||
// Therefore we have to remove all loaded, dead entities manually if we are in sync mode.
|
// Therefore we have to remove all loaded, dead entities manually if we are in sync mode.
|
||||||
// We do this after every SpawnX packet and after the destroy entities packet.
|
// We do this after every SpawnX packet and after the destroy entities packet.
|
||||||
if (!asyncMode && mc.world != null) {
|
if (!asyncMode && world(mc) != null) {
|
||||||
|
//#if MC>=10904
|
||||||
if (p instanceof SPacketSpawnPlayer
|
if (p instanceof SPacketSpawnPlayer
|
||||||
|| p instanceof SPacketSpawnObject
|
|| p instanceof SPacketSpawnObject
|
||||||
|| p instanceof SPacketSpawnMob
|
|| p instanceof SPacketSpawnMob
|
||||||
@@ -314,14 +344,27 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
|| p instanceof SPacketSpawnPainting
|
|| p instanceof SPacketSpawnPainting
|
||||||
|| p instanceof SPacketSpawnExperienceOrb
|
|| p instanceof SPacketSpawnExperienceOrb
|
||||||
|| p instanceof SPacketDestroyEntities) {
|
|| p instanceof SPacketDestroyEntities) {
|
||||||
World world = mc.world;
|
//#else
|
||||||
|
//$$ if (p instanceof S0CPacketSpawnPlayer
|
||||||
|
//$$ || p instanceof S0EPacketSpawnObject
|
||||||
|
//$$ || p instanceof S0FPacketSpawnMob
|
||||||
|
//$$ || p instanceof S2CPacketSpawnGlobalEntity
|
||||||
|
//$$ || p instanceof S10PacketSpawnPainting
|
||||||
|
//$$ || p instanceof S11PacketSpawnExperienceOrb
|
||||||
|
//$$ || p instanceof S13PacketDestroyEntities) {
|
||||||
|
//#endif
|
||||||
|
World world = world(mc);
|
||||||
for (int i = 0; i < world.loadedEntityList.size(); ++i) {
|
for (int i = 0; i < world.loadedEntityList.size(); ++i) {
|
||||||
Entity entity = world.loadedEntityList.get(i);
|
Entity entity = loadedEntityList(world).get(i);
|
||||||
if (entity.isDead) {
|
if (entity.isDead) {
|
||||||
int chunkX = entity.chunkCoordX;
|
int chunkX = entity.chunkCoordX;
|
||||||
int chunkY = entity.chunkCoordZ;
|
int chunkY = entity.chunkCoordZ;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if (entity.addedToChunk && world.getChunkProvider().getLoadedChunk(chunkX, chunkY) != null) {
|
if (entity.addedToChunk && world.getChunkProvider().getLoadedChunk(chunkX, chunkY) != null) {
|
||||||
|
//#else
|
||||||
|
//$$ if (entity.addedToChunk && world.getChunkProvider().chunkExists(chunkX, chunkY)) {
|
||||||
|
//#endif
|
||||||
world.getChunkFromChunkCoords(chunkX, chunkY).removeEntity(entity);
|
world.getChunkFromChunkCoords(chunkX, chunkY).removeEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +388,7 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
|
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
|
||||||
PacketBuffer pb = new PacketBuffer(bb);
|
PacketBuffer pb = new PacketBuffer(bb);
|
||||||
|
|
||||||
int i = pb.readVarInt();
|
int i = readVarInt(pb);
|
||||||
|
|
||||||
Packet p = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
Packet p = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||||
p.readPacketData(pb);
|
p.readPacketData(pb);
|
||||||
@@ -359,8 +402,13 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
* @return The processed packet or {@code null} if no packet shall be sent
|
* @return The processed packet or {@code null} if no packet shall be sent
|
||||||
*/
|
*/
|
||||||
protected Packet processPacket(Packet p) throws Exception {
|
protected Packet processPacket(Packet p) throws Exception {
|
||||||
|
//#if MC>=10904
|
||||||
if (p instanceof SPacketCustomPayload) {
|
if (p instanceof SPacketCustomPayload) {
|
||||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||||
|
//#else
|
||||||
|
//$$ if (p instanceof S3FPacketCustomPayload) {
|
||||||
|
//$$ S3FPacketCustomPayload packet = (S3FPacketCustomPayload) p;
|
||||||
|
//#endif
|
||||||
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannelName())) {
|
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannelName())) {
|
||||||
final String unknown = replayHandler.getRestrictions().handle(packet);
|
final String unknown = replayHandler.getRestrictions().handle(packet);
|
||||||
if (unknown == null) {
|
if (unknown == null) {
|
||||||
@@ -386,8 +434,17 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#if MC>=10904
|
||||||
if (p instanceof SPacketDisconnect) {
|
if (p instanceof SPacketDisconnect) {
|
||||||
ITextComponent reason = ((SPacketDisconnect) p).getReason();
|
ITextComponent reason = ((SPacketDisconnect) p).getReason();
|
||||||
|
//#else
|
||||||
|
//$$ if (p instanceof S40PacketDisconnect) {
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ IChatComponent reason = ((S40PacketDisconnect) p).getReason();
|
||||||
|
//#else
|
||||||
|
//$$ IChatComponent reason = ((S40PacketDisconnect) p).func_149165_c();
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
if ("Please update to view this replay.".equals(reason.getUnformattedText())) {
|
if ("Please update to view this replay.".equals(reason.getUnformattedText())) {
|
||||||
// This version of the mod supports replay restrictions so we are allowed
|
// This version of the mod supports replay restrictions so we are allowed
|
||||||
// to remove this packet.
|
// to remove this packet.
|
||||||
@@ -397,16 +454,31 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
|
|
||||||
if(BAD_PACKETS.contains(p.getClass())) return null;
|
if(BAD_PACKETS.contains(p.getClass())) return null;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if (p instanceof SPacketCustomPayload) {
|
if (p instanceof SPacketCustomPayload) {
|
||||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||||
|
//#else
|
||||||
|
//$$ if (p instanceof S3FPacketCustomPayload) {
|
||||||
|
//$$ S3FPacketCustomPayload packet = (S3FPacketCustomPayload) p;
|
||||||
|
//#endif
|
||||||
if ("MC|BOpen".equals(packet.getChannelName())) {
|
if ("MC|BOpen".equals(packet.getChannelName())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if(p instanceof SPacketResourcePackSend) {
|
if(p instanceof SPacketResourcePackSend) {
|
||||||
SPacketResourcePackSend packet = (SPacketResourcePackSend) p;
|
SPacketResourcePackSend packet = (SPacketResourcePackSend) p;
|
||||||
String url = packet.getURL();
|
String url = packet.getURL();
|
||||||
|
//#else
|
||||||
|
//$$ if(p instanceof S48PacketResourcePackSend) {
|
||||||
|
//$$ S48PacketResourcePackSend packet = (S48PacketResourcePackSend) p;
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ String url = packet.getURL();
|
||||||
|
//#else
|
||||||
|
//$$ String url = packet.func_179783_a();
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
if (url.startsWith("replay://")) {
|
if (url.startsWith("replay://")) {
|
||||||
int id = Integer.parseInt(url.substring("replay://".length()));
|
int id = Integer.parseInt(url.substring("replay://".length()));
|
||||||
Map<Integer, String> index = replayFile.getResourcePackIndex();
|
Map<Integer, String> index = replayFile.getResourcePackIndex();
|
||||||
@@ -417,17 +489,23 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
IOUtils.copy(replayFile.getResourcePack(hash).get(), new FileOutputStream(file));
|
IOUtils.copy(replayFile.getResourcePack(hash).get(), new FileOutputStream(file));
|
||||||
}
|
}
|
||||||
mc.getResourcePackRepository().setServerResourcePack(file);
|
setServerResourcePack(mc.getResourcePackRepository(), file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if(p instanceof SPacketJoinGame) {
|
if(p instanceof SPacketJoinGame) {
|
||||||
SPacketJoinGame packet = (SPacketJoinGame) p;
|
SPacketJoinGame packet = (SPacketJoinGame) p;
|
||||||
allowMovement = true;
|
|
||||||
int entId = packet.getPlayerId();
|
int entId = packet.getPlayerId();
|
||||||
|
//#else
|
||||||
|
//$$ if(p instanceof S01PacketJoinGame) {
|
||||||
|
//$$ S01PacketJoinGame packet = (S01PacketJoinGame) p;
|
||||||
|
//$$ int entId = packet.getEntityId();
|
||||||
|
//#endif
|
||||||
|
allowMovement = true;
|
||||||
actualID = entId;
|
actualID = entId;
|
||||||
entId = -1789435; // Camera entity id should be negative which is an invalid id and can't be used by servers
|
entId = -1789435; // Camera entity id should be negative which is an invalid id and can't be used by servers
|
||||||
int dimension = packet.getDimension();
|
int dimension = packet.getDimension();
|
||||||
@@ -435,21 +513,43 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
int maxPlayers = packet.getMaxPlayers();
|
int maxPlayers = packet.getMaxPlayers();
|
||||||
WorldType worldType = packet.getWorldType();
|
WorldType worldType = packet.getWorldType();
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
p = new SPacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
p = new SPacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||||
difficulty, maxPlayers, worldType, false);
|
difficulty, maxPlayers, worldType, false);
|
||||||
|
//#else
|
||||||
|
//$$ p = new S01PacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||||
|
//$$ difficulty, maxPlayers, worldType, false);
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if(p instanceof SPacketRespawn) {
|
if(p instanceof SPacketRespawn) {
|
||||||
SPacketRespawn respawn = (SPacketRespawn) p;
|
SPacketRespawn respawn = (SPacketRespawn) p;
|
||||||
p = new SPacketRespawn(respawn.getDimensionID(),
|
p = new SPacketRespawn(respawn.getDimensionID(),
|
||||||
respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
||||||
|
//#else
|
||||||
|
//$$ if(p instanceof S07PacketRespawn) {
|
||||||
|
//$$ S07PacketRespawn respawn = (S07PacketRespawn) p;
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ p = new S07PacketRespawn(respawn.getDimensionID(),
|
||||||
|
//$$ respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
||||||
|
//#else
|
||||||
|
//$$ p = new S07PacketRespawn(respawn.func_149082_c(),
|
||||||
|
//$$ respawn.func_149081_d(), respawn.func_149080_f(), GameType.SPECTATOR);
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
|
||||||
allowMovement = true;
|
allowMovement = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if(p instanceof SPacketPlayerPosLook) {
|
if(p instanceof SPacketPlayerPosLook) {
|
||||||
if(!hasWorldLoaded) hasWorldLoaded = true;
|
|
||||||
final SPacketPlayerPosLook ppl = (SPacketPlayerPosLook) p;
|
final SPacketPlayerPosLook ppl = (SPacketPlayerPosLook) p;
|
||||||
|
//#else
|
||||||
|
//$$ if(p instanceof S08PacketPlayerPosLook) {
|
||||||
|
//$$ final S08PacketPlayerPosLook ppl = (S08PacketPlayerPosLook) p;
|
||||||
|
//#endif
|
||||||
|
if(!hasWorldLoaded) hasWorldLoaded = true;
|
||||||
|
|
||||||
if (mc.currentScreen instanceof GuiDownloadTerrain) {
|
if (mc.currentScreen instanceof GuiDownloadTerrain) {
|
||||||
// Close the world loading screen manually in case we swallow the packet
|
// Close the world loading screen manually in case we swallow the packet
|
||||||
@@ -460,17 +560,29 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
|
|
||||||
CameraEntity cent = replayHandler.getCameraEntity();
|
CameraEntity cent = replayHandler.getCameraEntity();
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
for (SPacketPlayerPosLook.EnumFlags relative : ppl.getFlags()) {
|
for (SPacketPlayerPosLook.EnumFlags relative : ppl.getFlags()) {
|
||||||
if (relative == SPacketPlayerPosLook.EnumFlags.X
|
if (relative == SPacketPlayerPosLook.EnumFlags.X
|
||||||
|| relative == SPacketPlayerPosLook.EnumFlags.Y
|
|| relative == SPacketPlayerPosLook.EnumFlags.Y
|
||||||
|| relative == SPacketPlayerPosLook.EnumFlags.Z) {
|
|| relative == SPacketPlayerPosLook.EnumFlags.Z) {
|
||||||
|
//#else
|
||||||
|
//$$ for (Object relative : ppl.func_179834_f()) {
|
||||||
|
//$$ if (relative == S08PacketPlayerPosLook.EnumFlags.X
|
||||||
|
//$$ || relative == S08PacketPlayerPosLook.EnumFlags.Y
|
||||||
|
//$$ || relative == S08PacketPlayerPosLook.EnumFlags.Z) {
|
||||||
|
//#endif
|
||||||
return null; // At least one of the coordinates is relative, so we don't care
|
return null; // At least one of the coordinates is relative, so we don't care
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cent != null) {
|
if(cent != null) {
|
||||||
|
//#if MC>=10809
|
||||||
if(!allowMovement && !((Math.abs(cent.posX - ppl.getX()) > TP_DISTANCE_LIMIT) ||
|
if(!allowMovement && !((Math.abs(cent.posX - ppl.getX()) > TP_DISTANCE_LIMIT) ||
|
||||||
(Math.abs(cent.posZ - ppl.getZ()) > TP_DISTANCE_LIMIT))) {
|
(Math.abs(cent.posZ - ppl.getZ()) > TP_DISTANCE_LIMIT))) {
|
||||||
|
//#else
|
||||||
|
//$$ if(!allowMovement && !((Math.abs(cent.posX - ppl.func_148932_c()) > TP_DISTANCE_LIMIT) ||
|
||||||
|
//$$ (Math.abs(cent.posZ - ppl.func_148933_e()) > TP_DISTANCE_LIMIT))) {
|
||||||
|
//#endif
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
allowMovement = false;
|
allowMovement = false;
|
||||||
@@ -481,20 +593,34 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mc.world == null || !mc.isCallingFromMinecraftThread()) {
|
if (world(mc) == null || !mc.isCallingFromMinecraftThread()) {
|
||||||
ReplayMod.instance.runLater(this);
|
ReplayMod.instance.runLater(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraEntity cent = replayHandler.getCameraEntity();
|
CameraEntity cent = replayHandler.getCameraEntity();
|
||||||
|
//#if MC>=10809
|
||||||
cent.setCameraPosition(ppl.getX(), ppl.getY(), ppl.getZ());
|
cent.setCameraPosition(ppl.getX(), ppl.getY(), ppl.getZ());
|
||||||
|
//#else
|
||||||
|
//$$ cent.setCameraPosition(ppl.func_148932_c(), ppl.func_148928_d(), ppl.func_148933_e());
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if(p instanceof SPacketChangeGameState) {
|
if(p instanceof SPacketChangeGameState) {
|
||||||
SPacketChangeGameState pg = (SPacketChangeGameState)p;
|
SPacketChangeGameState pg = (SPacketChangeGameState)p;
|
||||||
int reason = pg.getGameState();
|
int reason = pg.getGameState();
|
||||||
|
//#else
|
||||||
|
//$$ if(p instanceof S2BPacketChangeGameState) {
|
||||||
|
//$$ S2BPacketChangeGameState pg = (S2BPacketChangeGameState)p;
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ int reason = pg.getGameState();
|
||||||
|
//#else
|
||||||
|
//$$ int reason = pg.func_149138_c();
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
|
||||||
// only allow the following packets:
|
// only allow the following packets:
|
||||||
// 1 - End raining
|
// 1 - End raining
|
||||||
@@ -508,7 +634,11 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
if (p instanceof SPacketChat) {
|
if (p instanceof SPacketChat) {
|
||||||
|
//#else
|
||||||
|
//$$ if (p instanceof S02PacketChat) {
|
||||||
|
//#endif
|
||||||
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -521,7 +651,11 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
//#if MC>=10904
|
||||||
ctx.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).set(EnumConnectionState.PLAY);
|
ctx.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).set(EnumConnectionState.PLAY);
|
||||||
|
//#else
|
||||||
|
//$$ ctx.attr(NetworkManager.attrKeyConnectionState).set(EnumConnectionState.PLAY);
|
||||||
|
//#endif
|
||||||
super.channelActive(ctx);
|
super.channelActive(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,7 +683,11 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
* @return {@code true} if it is paused, {@code false} otherwise
|
* @return {@code true} if it is paused, {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
public boolean paused() {
|
public boolean paused() {
|
||||||
|
//#if MC>=11200
|
||||||
return mc.timer.tickLength == Float.POSITIVE_INFINITY;
|
return mc.timer.tickLength == Float.POSITIVE_INFINITY;
|
||||||
|
//#else
|
||||||
|
//$$ return mc.timer.timerSpeed == 0;
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -569,7 +707,11 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
*/
|
*/
|
||||||
public void setReplaySpeed(final double d) {
|
public void setReplaySpeed(final double d) {
|
||||||
if(d != 0) this.replaySpeed = d;
|
if(d != 0) this.replaySpeed = d;
|
||||||
|
//#if MC>=11200
|
||||||
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK / (float) d;
|
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK / (float) d;
|
||||||
|
//#else
|
||||||
|
//$$ mc.timer.timerSpeed = (float) d;
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
@@ -739,11 +881,23 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
protected Packet processPacketAsync(Packet p) {
|
protected Packet processPacketAsync(Packet p) {
|
||||||
//If hurrying, ignore some packets, except for short durations
|
//If hurrying, ignore some packets, except for short durations
|
||||||
if(desiredTimeStamp - lastTimeStamp > 1000) {
|
if(desiredTimeStamp - lastTimeStamp > 1000) {
|
||||||
|
//#if MC>=10904
|
||||||
if(p instanceof SPacketParticles) return null;
|
if(p instanceof SPacketParticles) return null;
|
||||||
|
|
||||||
if(p instanceof SPacketSpawnObject) {
|
if(p instanceof SPacketSpawnObject) {
|
||||||
SPacketSpawnObject pso = (SPacketSpawnObject)p;
|
SPacketSpawnObject pso = (SPacketSpawnObject)p;
|
||||||
int type = pso.getType();
|
int type = pso.getType();
|
||||||
|
//#else
|
||||||
|
//$$ if(p instanceof S2APacketParticles) return null;
|
||||||
|
//$$
|
||||||
|
//$$ if(p instanceof S0EPacketSpawnObject) {
|
||||||
|
//$$ S0EPacketSpawnObject pso = (S0EPacketSpawnObject)p;
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ int type = pso.getType();
|
||||||
|
//#else
|
||||||
|
//$$ int type = pso.func_148993_l();
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
if(type == 76) { // Firework rocket
|
if(type == 76) { // Firework rocket
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -829,22 +983,38 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Packet processPacketSync(Packet p) {
|
protected Packet processPacketSync(Packet p) {
|
||||||
|
//#if MC>=10904
|
||||||
if (p instanceof SPacketUnloadChunk) {
|
if (p instanceof SPacketUnloadChunk) {
|
||||||
SPacketUnloadChunk packet = (SPacketUnloadChunk) p;
|
SPacketUnloadChunk packet = (SPacketUnloadChunk) p;
|
||||||
|
int x = packet.getX();
|
||||||
|
int z = packet.getZ();
|
||||||
|
//#else
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ if (p instanceof S21PacketChunkData && ((S21PacketChunkData) p).getExtractedSize() == 0) {
|
||||||
|
//$$ S21PacketChunkData packet = (S21PacketChunkData) p;
|
||||||
|
//$$ int x = packet.getChunkX();
|
||||||
|
//$$ int z = packet.getChunkZ();
|
||||||
|
//#else
|
||||||
|
//$$ if (p instanceof S21PacketChunkData && ((S21PacketChunkData) p).func_149276_g() == 0) {
|
||||||
|
//$$ S21PacketChunkData packet = (S21PacketChunkData) p;
|
||||||
|
//$$ int x = packet.func_149273_e();
|
||||||
|
//$$ int z = packet.func_149271_f();
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
// If the chunk is getting unloaded, we will have to forcefully update the position of all entities
|
// If the chunk is getting unloaded, we will have to forcefully update the position of all entities
|
||||||
// within. Otherwise, if there wasn't a game tick recently, there may be entities that have moved
|
// within. Otherwise, if there wasn't a game tick recently, there may be entities that have moved
|
||||||
// out of the chunk by now but are still registered in it. If we do not update those, they will get
|
// out of the chunk by now but are still registered in it. If we do not update those, they will get
|
||||||
// unloaded even though they shouldn't.
|
// unloaded even though they shouldn't.
|
||||||
// To make things worse, it seems like players were never supposed to be unloaded this way because
|
// To make things worse, it seems like players were never supposed to be unloaded this way because
|
||||||
// they will remain glitched in the World#playerEntities list.
|
// they will remain glitched in the World#playerEntities list.
|
||||||
World world = mc.world;
|
World world = world(mc);
|
||||||
IChunkProvider chunkProvider = world.getChunkProvider();
|
IChunkProvider chunkProvider = world.getChunkProvider();
|
||||||
// Get the chunk that will be unloaded
|
// Get the chunk that will be unloaded
|
||||||
Chunk chunk = chunkProvider.provideChunk(packet.getX(), packet.getZ());
|
Chunk chunk = chunkProvider.provideChunk(x, z);
|
||||||
if (!chunk.isEmpty()) {
|
if (!chunk.isEmpty()) {
|
||||||
List<Entity> entitiesInChunk = new ArrayList<>();
|
List<Entity> entitiesInChunk = new ArrayList<>();
|
||||||
// Gather all entities in that chunk
|
// Gather all entities in that chunk
|
||||||
for (ClassInheritanceMultiMap<Entity> entityList : chunk.getEntityLists()) {
|
for (Collection<Entity> entityList : getEntityLists(chunk)) {
|
||||||
entitiesInChunk.addAll(entityList);
|
entitiesInChunk.addAll(entityList);
|
||||||
}
|
}
|
||||||
for (Entity entity : entitiesInChunk) {
|
for (Entity entity : entitiesInChunk) {
|
||||||
@@ -857,12 +1027,17 @@ public class ReplaySender extends ChannelDuplexHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check whether the entity has left the chunk
|
// Check whether the entity has left the chunk
|
||||||
int chunkX = MathHelper.floor(entity.posX / 16);
|
int chunkX = floor(entity.posX / 16);
|
||||||
int chunkZ = MathHelper.floor(entity.posZ / 16);
|
int chunkZ = floor(entity.posZ / 16);
|
||||||
if (entity.chunkCoordX != chunkX || entity.chunkCoordZ != chunkZ) {
|
if (entity.chunkCoordX != chunkX || entity.chunkCoordZ != chunkZ) {
|
||||||
// Entity has left the chunk
|
// Entity has left the chunk
|
||||||
chunk.removeEntityAtIndex(entity, entity.chunkCoordY);
|
chunk.removeEntityAtIndex(entity, entity.chunkCoordY);
|
||||||
|
//#if MC>=10904
|
||||||
Chunk newChunk = chunkProvider.getLoadedChunk(chunkX, chunkZ);
|
Chunk newChunk = chunkProvider.getLoadedChunk(chunkX, chunkZ);
|
||||||
|
//#else
|
||||||
|
//$$ Chunk newChunk = chunkProvider.chunkExists(chunkX, chunkZ)
|
||||||
|
//$$ ? chunkProvider.provideChunk(chunkX, chunkZ) : null;
|
||||||
|
//#endif
|
||||||
if (newChunk != null) {
|
if (newChunk != null) {
|
||||||
newChunk.addEntity(entity);
|
newChunk.addEntity(entity);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -19,14 +19,7 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.item.EntityItemFrame;
|
import net.minecraft.entity.item.EntityItemFrame;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
|
||||||
import net.minecraft.stats.RecipeBook;
|
|
||||||
import net.minecraft.stats.StatisticsManager;
|
|
||||||
import net.minecraft.util.EnumHand;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
@@ -36,13 +29,32 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
|||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
//#if MC>=11200
|
||||||
|
import net.minecraft.stats.RecipeBook;
|
||||||
|
//#endif
|
||||||
|
import net.minecraft.stats.StatisticsManager;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.stats.StatFileWriter;
|
||||||
|
//$$ import net.minecraft.util.AxisAlignedBB;
|
||||||
|
//$$ import net.minecraft.util.IChatComponent;
|
||||||
|
//$$ import net.minecraft.util.MovingObjectPosition;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The camera entity used as the main player entity during replay viewing.
|
* The camera entity used as the main player entity during replay viewing.
|
||||||
* During a replay {@link Minecraft#player} should be an instance of this class.
|
* During a replay the player should be an instance of this class.
|
||||||
* Camera movement is controlled by a separate {@link CameraController}.
|
* Camera movement is controlled by a separate {@link CameraController}.
|
||||||
*/
|
*/
|
||||||
public class CameraEntity extends EntityPlayerSP {
|
public class CameraEntity extends EntityPlayerSP {
|
||||||
@@ -69,9 +81,20 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
*/
|
*/
|
||||||
private final EventHandler eventHandler = new EventHandler();
|
private final EventHandler eventHandler = new EventHandler();
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager, RecipeBook recipeBook) {
|
public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager, RecipeBook recipeBook) {
|
||||||
super(mcIn, worldIn, netHandlerPlayClient, statisticsManager, recipeBook);
|
super(mcIn, worldIn, netHandlerPlayClient, statisticsManager, recipeBook);
|
||||||
MinecraftForge.EVENT_BUS.register(eventHandler);
|
//#else
|
||||||
|
//#if MC>=10904
|
||||||
|
//$$ public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager) {
|
||||||
|
//$$ super(mcIn, worldIn, netHandlerPlayClient, statisticsManager);
|
||||||
|
//#else
|
||||||
|
//$$ public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatFileWriter statFileWriter) {
|
||||||
|
//$$ super(mcIn, worldIn, netHandlerPlayClient, statFileWriter);
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
FORGE_BUS.register(eventHandler);
|
||||||
|
FML_BUS.register(eventHandler);
|
||||||
if (ReplayModReplay.instance.getReplayHandler().getSpectatedUUID() == null) {
|
if (ReplayModReplay.instance.getReplayHandler().getSpectatedUUID() == null) {
|
||||||
cameraController = ReplayModReplay.instance.createCameraController(this);
|
cameraController = ReplayModReplay.instance.createCameraController(this);
|
||||||
} else {
|
} else {
|
||||||
@@ -159,14 +182,14 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
// entity is recreated and we have to spectate a new entity
|
// entity is recreated and we have to spectate a new entity
|
||||||
UUID spectating = ReplayModReplay.instance.getReplayHandler().getSpectatedUUID();
|
UUID spectating = ReplayModReplay.instance.getReplayHandler().getSpectatedUUID();
|
||||||
if (spectating != null && (view.getUniqueID() != spectating
|
if (spectating != null && (view.getUniqueID() != spectating
|
||||||
|| view.world != world)
|
|| world(view) != world(this))
|
||||||
|| world.getEntityByID(view.getEntityId()) != view) {
|
|| world(this).getEntityByID(view.getEntityId()) != view) {
|
||||||
if (spectating == null) {
|
if (spectating == null) {
|
||||||
// Entity (non-player) died, stop spectating
|
// Entity (non-player) died, stop spectating
|
||||||
ReplayModReplay.instance.getReplayHandler().spectateEntity(this);
|
ReplayModReplay.instance.getReplayHandler().spectateEntity(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
view = world.getPlayerEntityByUUID(spectating);
|
view = world(this).getPlayerEntityByUUID(spectating);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
mc.setRenderViewEntity(view);
|
mc.setRenderViewEntity(view);
|
||||||
} else {
|
} else {
|
||||||
@@ -185,8 +208,8 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
@Override
|
@Override
|
||||||
public void preparePlayerToSpawn() {
|
public void preparePlayerToSpawn() {
|
||||||
// Make sure our world is up-to-date in case of world changes
|
// Make sure our world is up-to-date in case of world changes
|
||||||
if (mc.world != null) {
|
if (world(mc) != null) {
|
||||||
world = mc.world;
|
world(this, world(mc));
|
||||||
}
|
}
|
||||||
super.preparePlayerToSpawn();
|
super.preparePlayerToSpawn();
|
||||||
}
|
}
|
||||||
@@ -296,6 +319,7 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
@Override
|
@Override
|
||||||
public float getCooldownPeriod() {
|
public float getCooldownPeriod() {
|
||||||
Entity view = mc.getRenderViewEntity();
|
Entity view = mc.getRenderViewEntity();
|
||||||
@@ -344,6 +368,19 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
//#else
|
||||||
|
//$$ @Override
|
||||||
|
//$$ public MovingObjectPosition rayTrace(double p_174822_1_, float p_174822_3_) {
|
||||||
|
//$$ MovingObjectPosition pos = super.rayTrace(p_174822_1_, 1f);
|
||||||
|
//$$
|
||||||
|
//$$ // Make sure we can never look at blocks (-> no outline)
|
||||||
|
//$$ if(pos != null && pos.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||||
|
//$$ pos.typeOfHit = MovingObjectPosition.MovingObjectType.MISS;
|
||||||
|
//$$ }
|
||||||
|
//$$
|
||||||
|
//$$ return pos;
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openGui(Object mod, int modGuiId, World world, int x, int y, int z) {
|
public void openGui(Object mod, int modGuiId, World world, int x, int y, int z) {
|
||||||
@@ -354,7 +391,8 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
@Override
|
@Override
|
||||||
public void setDead() {
|
public void setDead() {
|
||||||
super.setDead();
|
super.setDead();
|
||||||
MinecraftForge.EVENT_BUS.unregister(eventHandler);
|
FORGE_BUS.unregister(eventHandler);
|
||||||
|
FML_BUS.unregister(eventHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
@@ -392,11 +430,23 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
&& (e instanceof EntityPlayer || e instanceof EntityLiving || e instanceof EntityItemFrame);
|
&& (e instanceof EntityPlayer || e instanceof EntityLiving || e instanceof EntityItemFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=11102
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(ITextComponent message) {
|
public void sendMessage(ITextComponent message) {
|
||||||
if (MinecraftForge.EVENT_BUS.post(new ReplayChatMessageEvent(this))) return;
|
if (MinecraftForge.EVENT_BUS.post(new ReplayChatMessageEvent(this))) return;
|
||||||
super.sendMessage(message);
|
super.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
//#else
|
||||||
|
//$$ @Override
|
||||||
|
//#if MC>=10904
|
||||||
|
//$$ public void addChatMessage(ITextComponent message) {
|
||||||
|
//#else
|
||||||
|
//$$ public void addChatMessage(IChatComponent message) {
|
||||||
|
//#endif
|
||||||
|
//$$ if (MinecraftForge.EVENT_BUS.post(new ReplayChatMessageEvent(this))) return;
|
||||||
|
//$$ super.addChatMessage(message);
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
private class EventHandler {
|
private class EventHandler {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@@ -417,11 +467,11 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
||||||
// The crosshair should only render if targeted entity can actually be spectated
|
// The crosshair should only render if targeted entity can actually be spectated
|
||||||
if (event.getType() == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
if (getType(event) == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||||
event.setCanceled(!canSpectate(mc.pointedEntity));
|
event.setCanceled(!canSpectate(mc.pointedEntity));
|
||||||
}
|
}
|
||||||
// Hotbar should never be rendered
|
// Hotbar should never be rendered
|
||||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) {
|
if (getType(event) == RenderGameOverlayEvent.ElementType.HOTBAR) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -454,16 +504,23 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
if (lastHandRendered != player) {
|
if (lastHandRendered != player) {
|
||||||
lastHandRendered = player;
|
lastHandRendered = player;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
mc.entityRenderer.itemRenderer.prevEquippedProgressMainHand = 1;
|
mc.entityRenderer.itemRenderer.prevEquippedProgressMainHand = 1;
|
||||||
mc.entityRenderer.itemRenderer.prevEquippedProgressOffHand = 1;
|
mc.entityRenderer.itemRenderer.prevEquippedProgressOffHand = 1;
|
||||||
mc.entityRenderer.itemRenderer.equippedProgressMainHand = 1;
|
mc.entityRenderer.itemRenderer.equippedProgressMainHand = 1;
|
||||||
mc.entityRenderer.itemRenderer.equippedProgressOffHand = 1;
|
mc.entityRenderer.itemRenderer.equippedProgressOffHand = 1;
|
||||||
mc.entityRenderer.itemRenderer.itemStackMainHand = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
|
mc.entityRenderer.itemRenderer.itemStackMainHand = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
|
||||||
mc.entityRenderer.itemRenderer.itemStackOffHand = player.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
|
mc.entityRenderer.itemRenderer.itemStackOffHand = player.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
|
||||||
|
//#else
|
||||||
|
//$$ mc.entityRenderer.itemRenderer.prevEquippedProgress = 1;
|
||||||
|
//$$ mc.entityRenderer.itemRenderer.equippedProgress = 1;
|
||||||
|
//$$ mc.entityRenderer.itemRenderer.itemToRender = player.inventory.getCurrentItem();
|
||||||
|
//$$ mc.entityRenderer.itemRenderer.equippedItemSlot = player.inventory.currentItem;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
mc.player.renderArmYaw = mc.player.prevRenderArmYaw = player.rotationYaw;
|
player(mc).renderArmYaw = player(mc).prevRenderArmYaw = player.rotationYaw;
|
||||||
mc.player.renderArmPitch = mc.player.prevRenderArmPitch = player.rotationPitch;
|
player(mc).renderArmPitch = player(mc).prevRenderArmPitch = player.rotationPitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -471,7 +528,11 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
||||||
if (mc.getRenderViewEntity() == CameraEntity.this) {
|
if (mc.getRenderViewEntity() == CameraEntity.this) {
|
||||||
|
//#if MC>=10904
|
||||||
event.setRoll(roll);
|
event.setRoll(roll);
|
||||||
|
//#else
|
||||||
|
//$$ event.roll = roll;
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,7 +540,7 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
|
public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
|
||||||
switch (event.getType()) {
|
switch (getType(event)) {
|
||||||
case ALL:
|
case ALL:
|
||||||
heldItemTooltipsWasTrue = mc.gameSettings.heldItemTooltips;
|
heldItemTooltipsWasTrue = mc.gameSettings.heldItemTooltips;
|
||||||
mc.gameSettings.heldItemTooltips = false;
|
mc.gameSettings.heldItemTooltips = false;
|
||||||
@@ -492,15 +553,19 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
case EXPERIENCE:
|
case EXPERIENCE:
|
||||||
case HEALTHMOUNT:
|
case HEALTHMOUNT:
|
||||||
case JUMPBAR:
|
case JUMPBAR:
|
||||||
|
//#if MC>=10904
|
||||||
case POTION_ICONS:
|
case POTION_ICONS:
|
||||||
|
//#endif
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
break;
|
break;
|
||||||
case HELMET:
|
case HELMET:
|
||||||
case PORTAL:
|
case PORTAL:
|
||||||
case CROSSHAIRS:
|
case CROSSHAIRS:
|
||||||
case BOSSHEALTH:
|
case BOSSHEALTH:
|
||||||
|
//#if MC>=10904
|
||||||
case BOSSINFO:
|
case BOSSINFO:
|
||||||
case SUBTITLES:
|
case SUBTITLES:
|
||||||
|
//#endif
|
||||||
case TEXT:
|
case TEXT:
|
||||||
case CHAT:
|
case CHAT:
|
||||||
case PLAYER_LIST:
|
case PLAYER_LIST:
|
||||||
@@ -511,7 +576,7 @@ public class CameraEntity extends EntityPlayerSP {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void postRenderGameOverlay(RenderGameOverlayEvent.Post event) {
|
public void postRenderGameOverlay(RenderGameOverlayEvent.Post event) {
|
||||||
if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) return;
|
if (getType(event) != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||||
mc.gameSettings.heldItemTooltips = heldItemTooltipsWasTrue;
|
mc.gameSettings.heldItemTooltips = heldItemTooltipsWasTrue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package com.replaymod.replay.camera;
|
|||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
|
import org.lwjgl.util.vector.Vector3f;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
// TODO: Marius is responsible for this. Please, someone clean it up.
|
// TODO: Marius is responsible for this. Please, someone clean it up.
|
||||||
public class ClassicCameraController implements CameraController {
|
public class ClassicCameraController implements CameraController {
|
||||||
@@ -18,8 +19,8 @@ public class ClassicCameraController implements CameraController {
|
|||||||
private double THRESHOLD = MAX_SPEED / 20;
|
private double THRESHOLD = MAX_SPEED / 20;
|
||||||
private double DECAY = MAX_SPEED/3;
|
private double DECAY = MAX_SPEED/3;
|
||||||
|
|
||||||
private Vec3d direction;
|
private Vector3f direction;
|
||||||
private Vec3d dirBefore;
|
private Vector3f dirBefore;
|
||||||
private double motion;
|
private double motion;
|
||||||
private long lastCall = Sys.getTime();
|
private long lastCall = Sys.getTime();
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ public class ClassicCameraController implements CameraController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d movement = direction.normalize();
|
Vector3f movement = direction.normalise(null);
|
||||||
double factor = motion * (frac / 1000D);
|
double factor = motion * (frac / 1000D);
|
||||||
|
|
||||||
camera.moveCamera(movement.x * factor, movement.y * factor, movement.z * factor);
|
camera.moveCamera(movement.x * factor, movement.y * factor, movement.z * factor);
|
||||||
@@ -158,10 +159,10 @@ public class ClassicCameraController implements CameraController {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d dbf = direction;
|
Vector3f dbf = direction;
|
||||||
|
|
||||||
if(dirBefore != null) {
|
if(dirBefore != null) {
|
||||||
direction = dirBefore.normalize().add(direction);
|
direction = Vector3f.add(direction, dirBefore.normalise(null), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
dirBefore = dbf;
|
dirBefore = dbf;
|
||||||
@@ -169,12 +170,12 @@ public class ClassicCameraController implements CameraController {
|
|||||||
updateMovement();
|
updateMovement();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vec3d getVectorForRotation(float pitch, float yaw) {
|
private Vector3f getVectorForRotation(float pitch, float yaw) {
|
||||||
float f2 = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
float f2 = cos(-yaw * 0.017453292F - (float) Math.PI);
|
||||||
float f3 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI);
|
float f3 = sin(-yaw * 0.017453292F - (float)Math.PI);
|
||||||
float f4 = -MathHelper.cos(-pitch * 0.017453292F);
|
float f4 = -cos(-pitch * 0.017453292F);
|
||||||
float f5 = MathHelper.sin(-pitch * 0.017453292F);
|
float f5 = sin(-pitch * 0.017453292F);
|
||||||
return new Vec3d((double)(f3 * f4), (double)f5, (double)(f2 * f4));
|
return new Vector3f(f3 * f4, f5, f2 * f4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MoveDirection {
|
public enum MoveDirection {
|
||||||
|
|||||||
@@ -41,9 +41,14 @@ public class SpectatorCameraController implements CameraController {
|
|||||||
if (view instanceof EntityPlayer) {
|
if (view instanceof EntityPlayer) {
|
||||||
EntityPlayer viewPlayer = (EntityPlayer) view;
|
EntityPlayer viewPlayer = (EntityPlayer) view;
|
||||||
camera.inventory = viewPlayer.inventory;
|
camera.inventory = viewPlayer.inventory;
|
||||||
|
//#if MC>=10904
|
||||||
camera.itemStackMainHand = viewPlayer.itemStackMainHand;
|
camera.itemStackMainHand = viewPlayer.itemStackMainHand;
|
||||||
camera.swingingHand = viewPlayer.swingingHand;
|
camera.swingingHand = viewPlayer.swingingHand;
|
||||||
camera.activeItemStackUseCount = viewPlayer.activeItemStackUseCount;
|
camera.activeItemStackUseCount = viewPlayer.activeItemStackUseCount;
|
||||||
|
//#else
|
||||||
|
//$$ camera.itemInUse = viewPlayer.itemInUse;
|
||||||
|
//$$ camera.itemInUseCount = viewPlayer.itemInUseCount;
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import de.johni0702.minecraft.gui.RenderInfo;
|
|||||||
import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline;
|
import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline;
|
||||||
import de.johni0702.minecraft.gui.function.Draggable;
|
import de.johni0702.minecraft.gui.function.Draggable;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import org.lwjgl.util.Point;
|
import org.lwjgl.util.Point;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
import org.lwjgl.util.ReadableDimension;
|
||||||
import org.lwjgl.util.ReadablePoint;
|
import org.lwjgl.util.ReadablePoint;
|
||||||
|
|
||||||
|
import static de.johni0702.minecraft.gui.utils.Utils.clamp;
|
||||||
|
|
||||||
public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> implements Draggable {
|
public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> implements Draggable {
|
||||||
protected static final int TEXTURE_MARKER_X = 109;
|
protected static final int TEXTURE_MARKER_X = 109;
|
||||||
protected static final int TEXTURE_MARKER_Y = 20;
|
protected static final int TEXTURE_MARKER_Y = 20;
|
||||||
@@ -58,7 +59,7 @@ public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> im
|
|||||||
|
|
||||||
protected void drawMarker(GuiRenderer renderer, ReadableDimension size, Marker marker) {
|
protected void drawMarker(GuiRenderer renderer, ReadableDimension size, Marker marker) {
|
||||||
int visibleLength = (int) (getLength() * getZoom());
|
int visibleLength = (int) (getLength() * getZoom());
|
||||||
int markerPos = MathHelper.clamp(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
int markerPos = clamp(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
||||||
double positionInVisible = markerPos - getOffset();
|
double positionInVisible = markerPos - getOffset();
|
||||||
double fractionOfVisible = positionInVisible / visibleLength;
|
double fractionOfVisible = positionInVisible / visibleLength;
|
||||||
int markerX = (int) (BORDER_LEFT + fractionOfVisible * (size.getWidth() - BORDER_LEFT - BORDER_RIGHT));
|
int markerX = (int) (BORDER_LEFT + fractionOfVisible * (size.getWidth() - BORDER_LEFT - BORDER_RIGHT));
|
||||||
@@ -99,7 +100,7 @@ public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> im
|
|||||||
int visibleLength = (int) (getLength() * getZoom());
|
int visibleLength = (int) (getLength() * getZoom());
|
||||||
int contentWidth = lastSize.getWidth() - BORDER_LEFT - BORDER_RIGHT;
|
int contentWidth = lastSize.getWidth() - BORDER_LEFT - BORDER_RIGHT;
|
||||||
for (Marker marker : replayHandler.getMarkers()) {
|
for (Marker marker : replayHandler.getMarkers()) {
|
||||||
int markerPos = MathHelper.clamp(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
int markerPos = clamp(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
||||||
double positionInVisible = markerPos - getOffset();
|
double positionInVisible = markerPos - getOffset();
|
||||||
double fractionOfVisible = positionInVisible / visibleLength;
|
double fractionOfVisible = positionInVisible / visibleLength;
|
||||||
int markerX = (int) (BORDER_LEFT + fractionOfVisible * contentWidth);
|
int markerX = (int) (BORDER_LEFT + fractionOfVisible * contentWidth);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import de.johni0702.minecraft.gui.layout.CustomLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
@@ -25,6 +24,7 @@ import org.lwjgl.util.ReadablePoint;
|
|||||||
import org.lwjgl.util.WritablePoint;
|
import org.lwjgl.util.WritablePoint;
|
||||||
|
|
||||||
import static com.replaymod.core.ReplayMod.TEXTURE_SIZE;
|
import static com.replaymod.core.ReplayMod.TEXTURE_SIZE;
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
||||||
|
|
||||||
@@ -138,9 +138,9 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
|||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
if (isVisible() != visible) {
|
if (isVisible() != visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
} else {
|
} else {
|
||||||
MinecraftForge.EVENT_BUS.unregister(this);
|
FML_BUS.unregister(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.setVisible(visible);
|
super.setVisible(visible);
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import net.minecraft.util.Util;
|
|||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOCase;
|
import org.apache.commons.io.IOCase;
|
||||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.util.Dimension;
|
import org.lwjgl.util.Dimension;
|
||||||
@@ -321,7 +321,7 @@ public class GuiReplayViewer extends GuiScreen implements Typeable {
|
|||||||
this.file = file;
|
this.file = file;
|
||||||
|
|
||||||
name.setText(ChatFormatting.UNDERLINE + Utils.fileNameToReplayName(file.getName()));
|
name.setText(ChatFormatting.UNDERLINE + Utils.fileNameToReplayName(file.getName()));
|
||||||
if (Strings.isEmpty(metaData.getServerName())
|
if (StringUtils.isEmpty(metaData.getServerName())
|
||||||
|| !ReplayMod.instance.getSettingsRegistry().get(Setting.SHOW_SERVER_IPS)) {
|
|| !ReplayMod.instance.getSettingsRegistry().get(Setting.SHOW_SERVER_IPS)) {
|
||||||
server.setI18nText("replaymod.gui.iphidden").setColor(Colors.DARK_RED);
|
server.setI18nText("replaymod.gui.iphidden").setColor(Colors.DARK_RED);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
@@ -35,12 +36,13 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
|
FORGE_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||||
if (!(event.getGui() instanceof GuiIngameMenu)) {
|
if (!(getGui(event) instanceof GuiIngameMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ public class GuiHandler {
|
|||||||
mod.getReplayHandler().getReplaySender().setReplaySpeed(0);
|
mod.getReplayHandler().getReplaySender().setReplaySpeed(0);
|
||||||
|
|
||||||
GuiButton achievements = null, stats = null, openToLan = null;
|
GuiButton achievements = null, stats = null, openToLan = null;
|
||||||
List<GuiButton> buttonList = event.getButtonList();
|
List<GuiButton> buttonList = getButtonList(event);
|
||||||
for(GuiButton b : new ArrayList<>(buttonList)) {
|
for(GuiButton b : new ArrayList<>(buttonList)) {
|
||||||
switch (b.id) {
|
switch (b.id) {
|
||||||
// Replace "Exit Server" button with "Exit Replay" button
|
// Replace "Exit Server" button with "Exit Replay" button
|
||||||
@@ -70,12 +72,12 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (achievements != null && stats != null) {
|
if (achievements != null && stats != null) {
|
||||||
moveAllButtonsDirectlyBelowUpwards(buttonList, achievements.y,
|
moveAllButtonsDirectlyBelowUpwards(buttonList, y(achievements),
|
||||||
achievements.x, stats.x + stats.width);
|
x(achievements), x(stats) + stats.width);
|
||||||
}
|
}
|
||||||
if (openToLan != null) {
|
if (openToLan != null) {
|
||||||
moveAllButtonsDirectlyBelowUpwards(buttonList, openToLan.y,
|
moveAllButtonsDirectlyBelowUpwards(buttonList, y(openToLan),
|
||||||
openToLan.x, openToLan.x + openToLan.width);
|
x(openToLan), x(openToLan) + openToLan.width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,15 +91,15 @@ public class GuiHandler {
|
|||||||
*/
|
*/
|
||||||
private void moveAllButtonsDirectlyBelowUpwards(List<GuiButton> buttons, int belowY, int xStart, int xEnd) {
|
private void moveAllButtonsDirectlyBelowUpwards(List<GuiButton> buttons, int belowY, int xStart, int xEnd) {
|
||||||
for (GuiButton button : buttons) {
|
for (GuiButton button : buttons) {
|
||||||
if (button.y >= belowY && button.x <= xEnd && button.x + button.width >= xStart) {
|
if (y(button) >= belowY && x(button) <= xEnd && x(button) + button.width >= xStart) {
|
||||||
button.y -= 24;
|
y(button, y(button) - 24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||||
if (!(event.getGui() instanceof GuiMainMenu)) {
|
if (!(getGui(event) instanceof GuiMainMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,25 +117,25 @@ public class GuiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, event.getGui().width / 2 - 100,
|
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, getGui(event).width / 2 - 100,
|
||||||
event.getGui().height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayviewer"));
|
getGui(event).height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayviewer"));
|
||||||
button.width = button.width / 2 - 2;
|
button.width = button.width / 2 - 2;
|
||||||
event.getButtonList().add(button);
|
getButtonList(event).add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||||
if(!event.getButton().enabled) return;
|
if(!getButton(event).enabled) return;
|
||||||
|
|
||||||
if (event.getGui() instanceof GuiMainMenu) {
|
if (getGui(event) instanceof GuiMainMenu) {
|
||||||
if (event.getButton().id == BUTTON_REPLAY_VIEWER) {
|
if (getButton(event).id == BUTTON_REPLAY_VIEWER) {
|
||||||
new GuiReplayViewer(mod).display();
|
new GuiReplayViewer(mod).display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getGui() instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
if (getGui(event) instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
||||||
if (event.getButton().id == BUTTON_EXIT_REPLAY) {
|
if (getButton(event).id == BUTTON_EXIT_REPLAY) {
|
||||||
event.getButton().enabled = false;
|
getButton(event).enabled = false;
|
||||||
mc.displayGuiScreen(new GuiMainMenu());
|
mc.displayGuiScreen(new GuiMainMenu());
|
||||||
try {
|
try {
|
||||||
mod.getReplayHandler().endReplay();
|
mod.getReplayHandler().endReplay();
|
||||||
|
|||||||
@@ -4,20 +4,22 @@ import com.replaymod.replay.camera.CameraEntity;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiSpectator;
|
import net.minecraft.client.gui.GuiSpectator;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mixin(GuiSpectator.class)
|
@Mixin(GuiSpectator.class)
|
||||||
public abstract class MixinGuiSpectator {
|
public abstract class MixinGuiSpectator {
|
||||||
@Shadow
|
//#if MC>=10904
|
||||||
private Minecraft mc;
|
|
||||||
|
|
||||||
@Inject(method = "onHotbarSelected", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "onHotbarSelected", at = @At("HEAD"), cancellable = true)
|
||||||
|
//#else
|
||||||
|
//$$ @Inject(method = "func_175260_a", at = @At("HEAD"), cancellable = true)
|
||||||
|
//#endif
|
||||||
public void isInReplay(int i, CallbackInfo ci) {
|
public void isInReplay(int i, CallbackInfo ci) {
|
||||||
// Prevent spectator gui from opening while in a replay
|
// Prevent spectator gui from opening while in a replay
|
||||||
if (mc.player instanceof CameraEntity) {
|
if (player(Minecraft.getMinecraft()) instanceof CameraEntity) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.replaymod.replay.mixin;
|
package com.replaymod.replay.mixin;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
import net.minecraft.client.particle.Particle;
|
import net.minecraft.client.particle.Particle;
|
||||||
import net.minecraft.client.particle.ParticleManager;
|
import net.minecraft.client.particle.ParticleManager;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -29,3 +30,4 @@ public abstract class MixinParticleManager {
|
|||||||
queueEntityFX.clear();
|
queueEntityFX.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#endif
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||||
import net.minecraft.stats.RecipeBook;
|
|
||||||
import net.minecraft.stats.StatisticsManager;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -15,6 +13,17 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
|
import net.minecraft.stats.RecipeBook;
|
||||||
|
//#endif
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.stats.StatisticsManager;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.stats.StatFileWriter;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mixin(PlayerControllerMP.class)
|
@Mixin(PlayerControllerMP.class)
|
||||||
public abstract class MixinPlayerControllerMP {
|
public abstract class MixinPlayerControllerMP {
|
||||||
|
|
||||||
@@ -22,20 +31,38 @@ public abstract class MixinPlayerControllerMP {
|
|||||||
private Minecraft mc;
|
private Minecraft mc;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
|
//#if MC>=10904
|
||||||
private NetHandlerPlayClient connection;
|
private NetHandlerPlayClient connection;
|
||||||
|
//#else
|
||||||
|
//$$ private NetHandlerPlayClient netClientHandler;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
//#if MC>=11200
|
||||||
@Inject(method = "func_192830_a", at=@At("HEAD"), cancellable = true)
|
@Inject(method = "func_192830_a", at=@At("HEAD"), cancellable = true)
|
||||||
private void replayModReplay_createReplayCamera(World worldIn, StatisticsManager statisticsManager, RecipeBook recipeBook, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
private void replayModReplay_createReplayCamera(World worldIn, StatisticsManager statisticsManager, RecipeBook recipeBook, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
||||||
if (ReplayModReplay.instance.getReplayHandler() != null) {
|
if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||||
ci.setReturnValue(new CameraEntity(mc, worldIn, connection, statisticsManager, recipeBook));
|
ci.setReturnValue(new CameraEntity(mc, worldIn, connection, statisticsManager, recipeBook));
|
||||||
|
//#else
|
||||||
|
//#if MC>=10904
|
||||||
|
//$$ @Inject(method = "createClientPlayer", at=@At("HEAD"), cancellable = true)
|
||||||
|
//$$ private void replayModReplay_createReplayCamera(World worldIn, StatisticsManager statisticsManager, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
||||||
|
//$$ if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||||
|
//$$ ci.setReturnValue(new CameraEntity(mc, worldIn, connection, statisticsManager));
|
||||||
|
//#else
|
||||||
|
//$$ @Inject(method = "func_178892_a", at=@At("HEAD"), cancellable = true)
|
||||||
|
//$$ private void replayModReplay_createReplayCamera(World worldIn, StatFileWriter statFileWriter, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
||||||
|
//$$ if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||||
|
//$$ ci.setReturnValue(new CameraEntity(mc, worldIn, netClientHandler, statFileWriter));
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "isSpectator", at=@At("HEAD"), cancellable = true)
|
@Inject(method = "isSpectator", at=@At("HEAD"), cancellable = true)
|
||||||
private void replayModReplay_isSpectator(CallbackInfoReturnable<Boolean> ci) {
|
private void replayModReplay_isSpectator(CallbackInfoReturnable<Boolean> ci) {
|
||||||
if (mc.player instanceof CameraEntity) { // this check should in theory not be required
|
if (player(mc) instanceof CameraEntity) { // this check should in theory not be required
|
||||||
ci.setReturnValue(mc.player.isSpectator());
|
ci.setReturnValue(player(mc).isSpectator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,16 @@ package com.replaymod.replay.mixin;
|
|||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.RenderItem;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.client.renderer.RenderItem;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Mixin(RenderItem.class)
|
@Mixin(RenderItem.class)
|
||||||
public class MixinRenderItem {
|
public class MixinRenderItem {
|
||||||
@Redirect(method = "renderEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
@Redirect(method = "renderEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.replaymod.replay.mixin;
|
|||||||
|
|
||||||
import com.replaymod.replay.camera.CameraEntity;
|
import com.replaymod.replay.camera.CameraEntity;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -11,11 +10,23 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
|||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
@Mixin(RenderLivingBase.class)
|
@Mixin(RenderLivingBase.class)
|
||||||
|
//#else
|
||||||
|
//$$ @Mixin(RendererLivingEntity.class)
|
||||||
|
//#endif
|
||||||
public abstract class MixinRenderLivingBase {
|
public abstract class MixinRenderLivingBase {
|
||||||
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
||||||
private void replayModReplay_canRenderInvisibleName(EntityLivingBase entity, CallbackInfoReturnable<Boolean> ci) {
|
private void replayModReplay_canRenderInvisibleName(EntityLivingBase entity, CallbackInfoReturnable<Boolean> ci) {
|
||||||
EntityPlayer thePlayer = Minecraft.getMinecraft().player;
|
EntityPlayer thePlayer = player(Minecraft.getMinecraft());
|
||||||
if (thePlayer instanceof CameraEntity && entity.isInvisible()) {
|
if (thePlayer instanceof CameraEntity && entity.isInvisible()) {
|
||||||
ci.setReturnValue(false);
|
ci.setReturnValue(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
|
|
||||||
@Mixin(TileEntityEndPortalRenderer.class)
|
@Mixin(TileEntityEndPortalRenderer.class)
|
||||||
public class MixinTileEntityEndPortalRenderer {
|
public class MixinTileEntityEndPortalRenderer {
|
||||||
|
//#if MC>=10809
|
||||||
@Redirect(method = "renderTileEntityAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
@Redirect(method = "renderTileEntityAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||||
|
//#else
|
||||||
|
//$$ @Redirect(method = "func_180544_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||||
|
//#endif
|
||||||
private long replayModReplay_getEnchantmentTime() {
|
private long replayModReplay_getEnchantmentTime() {
|
||||||
ReplayHandler replayHandler = ReplayModReplay.instance.getReplayHandler();
|
ReplayHandler replayHandler = ReplayModReplay.instance.getReplayHandler();
|
||||||
if (replayHandler != null) {
|
if (replayHandler != null) {
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import net.minecraft.client.renderer.RenderGlobal;
|
|||||||
import net.minecraft.client.renderer.ViewFrustum;
|
import net.minecraft.client.renderer.ViewFrustum;
|
||||||
import net.minecraft.client.renderer.chunk.IRenderChunkFactory;
|
import net.minecraft.client.renderer.chunk.IRenderChunkFactory;
|
||||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -14,6 +12,14 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.util.BlockPos;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mixin(ViewFrustum.class)
|
@Mixin(ViewFrustum.class)
|
||||||
public abstract class MixinViewFrustum {
|
public abstract class MixinViewFrustum {
|
||||||
private IRenderChunkFactory renderChunkFactory;
|
private IRenderChunkFactory renderChunkFactory;
|
||||||
@@ -31,7 +37,7 @@ public abstract class MixinViewFrustum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instead of calling {@link RenderChunk#setPosition(int, int, int)} we recreate the render chunk
|
* Instead of updating its position, we recreate the render chunk
|
||||||
* which seems to solve the problem that chunks are invisible when you leave an area and return
|
* which seems to solve the problem that chunks are invisible when you leave an area and return
|
||||||
* to it.
|
* to it.
|
||||||
* Any better fixes are welcome.
|
* Any better fixes are welcome.
|
||||||
@@ -43,8 +49,8 @@ public abstract class MixinViewFrustum {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = MathHelper.floor(viewEntityX) - 8;
|
int i = floor(viewEntityX) - 8;
|
||||||
int j = MathHelper.floor(viewEntityZ) - 8;
|
int j = floor(viewEntityZ) - 8;
|
||||||
int k = this.countChunksX * 16;
|
int k = this.countChunksX * 16;
|
||||||
|
|
||||||
for (int l = 0; l < this.countChunksX; ++l) {
|
for (int l = 0; l < this.countChunksX; ++l) {
|
||||||
@@ -57,9 +63,18 @@ public abstract class MixinViewFrustum {
|
|||||||
BlockPos blockpos = new BlockPos(i1, i2, k1);
|
BlockPos blockpos = new BlockPos(i1, i2, k1);
|
||||||
if (!blockpos.equals(renderchunk.getPosition())) {
|
if (!blockpos.equals(renderchunk.getPosition())) {
|
||||||
// Recreate render chunk instead of setting its position
|
// Recreate render chunk instead of setting its position
|
||||||
|
//#if MC>=10904
|
||||||
(renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l] =
|
(renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l] =
|
||||||
renderChunkFactory.create(world, renderGlobal, 0)
|
renderChunkFactory.create(world, renderGlobal, 0)
|
||||||
|
//#if MC>= 11100
|
||||||
).setPosition(blockpos.getX(), blockpos.getY(), blockpos.getZ());
|
).setPosition(blockpos.getX(), blockpos.getY(), blockpos.getZ());
|
||||||
|
//#else
|
||||||
|
//$$ ).setOrigin(blockpos.getX(), blockpos.getY(), blockpos.getZ());
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//$$ renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l] =
|
||||||
|
//$$ renderChunkFactory.makeRenderChunk(world, renderGlobal, blockpos, 0);
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,5 +82,12 @@ public abstract class MixinViewFrustum {
|
|||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//#if MC>=10904
|
||||||
@Shadow abstract int getBaseCoordinate(int p_178157_1_, int p_178157_2_, int p_178157_3_);
|
@Shadow abstract int getBaseCoordinate(int p_178157_1_, int p_178157_2_, int p_178157_3_);
|
||||||
|
//#else
|
||||||
|
//$$ private int getBaseCoordinate(int p_178157_1_, int p_178157_2_, int p_178157_3_) {
|
||||||
|
//$$ return func_178157_a(p_178157_1_, p_178157_2_, p_178157_3_);
|
||||||
|
//$$ }
|
||||||
|
//$$ @Shadow abstract int func_178157_a(int p_178157_1_, int p_178157_2_, int p_178157_3_);
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import io.netty.channel.ChannelFutureListener;
|
|||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||||
@@ -27,6 +26,8 @@ import java.io.IOException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mod(modid = ReplayModRestrictions.MOD_ID,
|
@Mod(modid = ReplayModRestrictions.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
@@ -54,7 +55,7 @@ public class ReplayModRestrictions {
|
|||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
EventBus bus = FMLCommonHandler.instance().bus();
|
EventBus bus = FML_BUS;
|
||||||
bus.register(this);
|
bus.register(this);
|
||||||
|
|
||||||
channel = NetworkRegistry.INSTANCE.newChannel(Restrictions.PLUGIN_CHANNEL, new RestrictionsChannelHandler()).get(Side.SERVER);
|
channel = NetworkRegistry.INSTANCE.newChannel(Restrictions.PLUGIN_CHANNEL, new RestrictionsChannelHandler()).get(Side.SERVER);
|
||||||
|
|||||||
@@ -11,13 +11,14 @@ import com.replaymod.simplepathing.SPTimeline.SPPath;
|
|||||||
import com.replaymod.simplepathing.gui.GuiPathing;
|
import com.replaymod.simplepathing.gui.GuiPathing;
|
||||||
import com.replaymod.simplepathing.preview.PathPreview;
|
import com.replaymod.simplepathing.preview.PathPreview;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
@Mod(modid = ReplayModSimplePathing.MOD_ID,
|
@Mod(modid = ReplayModSimplePathing.MOD_ID,
|
||||||
version = "@MOD_VERSION@",
|
version = "@MOD_VERSION@",
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||||
@@ -43,7 +44,7 @@ public class ReplayModSimplePathing {
|
|||||||
|
|
||||||
core.getSettingsRegistry().register(Setting.class);
|
core.getSettingsRegistry().register(Setting.class);
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
|
|
||||||
PathPreview pathPreview = new PathPreview(this);
|
PathPreview pathPreview = new PathPreview(this);
|
||||||
pathPreview.register();
|
pathPreview.register();
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
import static com.replaymod.replaystudio.pathing.change.RemoveKeyframe.create;
|
import static com.replaymod.replaystudio.pathing.change.RemoveKeyframe.create;
|
||||||
import static com.replaymod.simplepathing.ReplayModSimplePathing.LOGGER;
|
import static com.replaymod.simplepathing.ReplayModSimplePathing.LOGGER;
|
||||||
|
|
||||||
@@ -658,7 +659,7 @@ public class SPTimeline implements PathingRegistry {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CrashReport crash = CrashReport.makeCrashReport(e, "Serializing interpolator");
|
CrashReport crash = CrashReport.makeCrashReport(e, "Serializing interpolator");
|
||||||
CrashReportCategory category = crash.makeCategory("Serializing interpolator");
|
CrashReportCategory category = crash.makeCategory("Serializing interpolator");
|
||||||
category.addDetail("Interpolator", interpolator::toString);
|
addDetail(category, "Interpolator", interpolator::toString);
|
||||||
throw new ReportedException(crash);
|
throw new ReportedException(crash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import com.replaymod.replay.events.ReplayCloseEvent;
|
|||||||
import com.replaymod.replay.events.ReplayOpenEvent;
|
import com.replaymod.replay.events.ReplayOpenEvent;
|
||||||
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||||
import com.replaymod.simplepathing.Setting;
|
import com.replaymod.simplepathing.Setting;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class PathPreview {
|
public class PathPreview {
|
||||||
private final ReplayModSimplePathing mod;
|
private final ReplayModSimplePathing mod;
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ public class PathPreview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
FML_BUS.register(this);
|
||||||
|
|
||||||
ReplayMod core = mod.getCore();
|
ReplayMod core = mod.getCore();
|
||||||
mod.getCore().getKeyBindingRegistry().registerKeyBinding("replaymod.input.pathpreview", Keyboard.KEY_H, () -> {
|
mod.getCore().getKeyBindingRegistry().registerKeyBinding("replaymod.input.pathpreview", Keyboard.KEY_H, () -> {
|
||||||
|
|||||||
@@ -15,10 +15,8 @@ import com.replaymod.simplepathing.ReplayModSimplePathing;
|
|||||||
import com.replaymod.simplepathing.SPTimeline;
|
import com.replaymod.simplepathing.SPTimeline;
|
||||||
import com.replaymod.simplepathing.gui.GuiPathing;
|
import com.replaymod.simplepathing.gui.GuiPathing;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
@@ -32,6 +30,7 @@ import java.util.Comparator;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static com.replaymod.core.ReplayMod.TEXTURE;
|
import static com.replaymod.core.ReplayMod.TEXTURE;
|
||||||
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class PathPreviewRenderer {
|
public class PathPreviewRenderer {
|
||||||
private static final ResourceLocation CAMERA_HEAD = new ResourceLocation("replaymod", "camera_head.png");
|
private static final ResourceLocation CAMERA_HEAD = new ResourceLocation("replaymod", "camera_head.png");
|
||||||
@@ -203,36 +202,32 @@ public class PathPreviewRenderer {
|
|||||||
if (distanceSquared(view, pos1) > renderDistanceSquared) return;
|
if (distanceSquared(view, pos1) > renderDistanceSquared) return;
|
||||||
if (distanceSquared(view, pos2) > renderDistanceSquared) return;
|
if (distanceSquared(view, pos2) > renderDistanceSquared) return;
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
BufferBuilder_setTranslation(-view.getLeft(), -view.getMiddle(), -view.getRight());
|
||||||
BufferBuilder vertexBuffer = tessellator.getBuffer();
|
|
||||||
vertexBuffer.setTranslation(-view.getLeft(), -view.getMiddle(), -view.getRight());
|
|
||||||
|
|
||||||
vertexBuffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
|
BufferBuilder_beginPosCol(GL11.GL_LINES);
|
||||||
|
|
||||||
vertexBuffer.pos(pos1.getLeft(), pos1.getMiddle(), pos1.getRight()).color(
|
BufferBuilder_addPosCol(pos1.getLeft(), pos1.getMiddle(), pos1.getRight(),
|
||||||
color >> 16 & 0xff,
|
color >> 16 & 0xff,
|
||||||
color >> 8 & 0xff,
|
color >> 8 & 0xff,
|
||||||
color & 0xff,
|
color & 0xff,
|
||||||
255
|
255
|
||||||
).endVertex();
|
);
|
||||||
vertexBuffer.pos(pos2.getLeft(), pos2.getMiddle(), pos2.getRight()).color(
|
BufferBuilder_addPosCol(pos2.getLeft(), pos2.getMiddle(), pos2.getRight(),
|
||||||
color >> 16 & 0xff,
|
color >> 16 & 0xff,
|
||||||
color >> 8 & 0xff,
|
color >> 8 & 0xff,
|
||||||
color & 0xff,
|
color & 0xff,
|
||||||
255
|
255
|
||||||
).endVertex();
|
);
|
||||||
|
|
||||||
GL11.glLineWidth(3);
|
GL11.glLineWidth(3);
|
||||||
tessellator.draw();
|
Tessellator.getInstance().draw();
|
||||||
vertexBuffer.setTranslation(0, 0, 0);
|
BufferBuilder_setTranslation(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawPoint(Triple<Double, Double, Double> view,
|
private void drawPoint(Triple<Double, Double, Double> view,
|
||||||
Triple<Double, Double, Double> pos,
|
Triple<Double, Double, Double> pos,
|
||||||
Keyframe keyframe) {
|
Keyframe keyframe) {
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
BufferBuilder_setTranslation(0, 0, 0);
|
||||||
BufferBuilder vertexBuffer = tessellator.getBuffer();
|
|
||||||
vertexBuffer.setTranslation(0, 0, 0);
|
|
||||||
|
|
||||||
mc.renderEngine.bindTexture(TEXTURE);
|
mc.renderEngine.bindTexture(TEXTURE);
|
||||||
|
|
||||||
@@ -253,12 +248,12 @@ public class PathPreviewRenderer {
|
|||||||
float maxX = 0.5f;
|
float maxX = 0.5f;
|
||||||
float maxY = 0.5f;
|
float maxY = 0.5f;
|
||||||
|
|
||||||
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
BufferBuilder_beginPosTex(GL11.GL_QUADS);
|
||||||
|
|
||||||
vertexBuffer.pos(minX, minY, 0).tex(posX + size, posY + size).endVertex();
|
BufferBuilder_addPosTex(minX, minY, 0, posX + size, posY + size);
|
||||||
vertexBuffer.pos(minX, maxY, 0).tex(posX + size, posY).endVertex();
|
BufferBuilder_addPosTex(minX, maxY, 0, posX + size, posY);
|
||||||
vertexBuffer.pos(maxX, maxY, 0).tex(posX, posY).endVertex();
|
BufferBuilder_addPosTex(maxX, maxY, 0, posX, posY);
|
||||||
vertexBuffer.pos(maxX, minY, 0).tex(posX, posY + size).endVertex();
|
BufferBuilder_addPosTex(maxX, minY, 0, posX, posY + size);
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
@@ -271,7 +266,7 @@ public class PathPreviewRenderer {
|
|||||||
GL11.glRotatef(-mc.getRenderManager().playerViewY, 0, 1, 0);
|
GL11.glRotatef(-mc.getRenderManager().playerViewY, 0, 1, 0);
|
||||||
GL11.glRotatef(mc.getRenderManager().playerViewX, 1, 0, 0);
|
GL11.glRotatef(mc.getRenderManager().playerViewX, 1, 0, 0);
|
||||||
|
|
||||||
tessellator.draw();
|
Tessellator.getInstance().draw();
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
@@ -280,8 +275,7 @@ public class PathPreviewRenderer {
|
|||||||
Triple<Double, Double, Double> pos,
|
Triple<Double, Double, Double> pos,
|
||||||
Triple<Float, Float, Float> rot) {
|
Triple<Float, Float, Float> rot) {
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder vertexBuffer = tessellator.getBuffer();
|
BufferBuilder_setTranslation(0, 0, 0);
|
||||||
vertexBuffer.setTranslation(0, 0, 0);
|
|
||||||
|
|
||||||
mc.renderEngine.bindTexture(CAMERA_HEAD);
|
mc.renderEngine.bindTexture(CAMERA_HEAD);
|
||||||
|
|
||||||
@@ -299,10 +293,10 @@ public class PathPreviewRenderer {
|
|||||||
|
|
||||||
//draw the position line
|
//draw the position line
|
||||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
vertexBuffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
|
BufferBuilder_beginPosCol(GL11.GL_LINES);
|
||||||
|
|
||||||
vertexBuffer.pos(0, 0, 0).color(0, 255, 0, 170).endVertex();
|
BufferBuilder_addPosCol(0, 0, 0, 0, 255, 0, 170);
|
||||||
vertexBuffer.pos(0, 0, 2).color(0, 255, 0, 170).endVertex();
|
BufferBuilder_addPosCol(0, 0, 2, 0, 255, 0, 170);
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
@@ -313,43 +307,43 @@ public class PathPreviewRenderer {
|
|||||||
|
|
||||||
double r = -cubeSize/2;
|
double r = -cubeSize/2;
|
||||||
|
|
||||||
vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
BufferBuilder_beginPosTexCol(GL11.GL_QUADS);
|
||||||
|
|
||||||
//back
|
//back
|
||||||
vertexBuffer.pos(r, r + cubeSize, r).tex(3 * 8 / 64f, 8 / 64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r + cubeSize, r, 3 * 8 / 64f, 8 / 64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r).tex(4*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r, 4*8/64f, 8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r + cubeSize, r, r).tex(4*8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r, r, 4*8/64f, 2*8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r, r, r).tex(3*8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r, r, 3*8/64f, 2*8/64f, 255, 255, 255, 200);
|
||||||
|
|
||||||
//front
|
//front
|
||||||
vertexBuffer.pos(r + cubeSize, r, r + cubeSize).tex(2 * 8 / 64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r, r + cubeSize, 2 * 8 / 64f, 2*8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r + cubeSize).tex(2 * 8 / 64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r + cubeSize, 2 * 8 / 64f, 8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r, r + cubeSize, r + cubeSize).tex(8 / 64f, 8 / 64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r + cubeSize, r + cubeSize, 8 / 64f, 8 / 64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r, r, r + cubeSize).tex(8 / 64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r, r + cubeSize, 8 / 64f, 2*8/64f, 255, 255, 255, 200);
|
||||||
|
|
||||||
//left
|
//left
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r).tex(0, 8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r, 0, 8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r + cubeSize).tex(8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r + cubeSize, 8/64f, 8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r + cubeSize, r, r + cubeSize).tex(8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r, r + cubeSize, 8/64f, 2*8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r+cubeSize, r, r).tex(0, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r+cubeSize, r, r, 0, 2*8/64f, 255, 255, 255, 200);
|
||||||
|
|
||||||
//right
|
//right
|
||||||
vertexBuffer.pos(r, r + cubeSize, r + cubeSize).tex(2*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r + cubeSize, r + cubeSize, 2*8/64f, 8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r, r + cubeSize, r).tex(3*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r + cubeSize, r, 3*8/64f, 8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r, r, r).tex(3*8/64f, 2*8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r, r, 3*8/64f, 2*8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r, r, r + cubeSize).tex(2 * 8 / 64f, 2 * 8 / 64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r, r + cubeSize, 2 * 8 / 64f, 2 * 8 / 64f, 255, 255, 255, 200);
|
||||||
|
|
||||||
//bottom
|
//bottom
|
||||||
vertexBuffer.pos(r + cubeSize, r, r).tex(3*8/64f, 0).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r, r, 3*8/64f, 0, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r + cubeSize, r, r + cubeSize).tex(3*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r, r + cubeSize, 3*8/64f, 8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r, r, r + cubeSize).tex(2*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r, r + cubeSize, 2*8/64f, 8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r, r, r).tex(2 * 8 / 64f, 0).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r, r, 2 * 8 / 64f, 0, 255, 255, 255, 200);
|
||||||
|
|
||||||
//top
|
//top
|
||||||
vertexBuffer.pos(r, r + cubeSize, r).tex(8/64f, 0).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r + cubeSize, r, 8/64f, 0, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r, r + cubeSize, r + cubeSize).tex(8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r, r + cubeSize, r + cubeSize, 8/64f, 8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r + cubeSize).tex(2*8/64f, 8/64f).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r + cubeSize, 2*8/64f, 8/64f, 255, 255, 255, 200);
|
||||||
vertexBuffer.pos(r + cubeSize, r + cubeSize, r).tex(2 * 8 / 64f, 0).color(255, 255, 255, 200).endVertex();
|
BufferBuilder_addPosTexCol(r + cubeSize, r + cubeSize, r, 2 * 8 / 64f, 0, 255, 255, 255, 200);
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
# To apply changes in this file run: ./gradlew clean setupDecompWorkspace idea
|
# To apply changes in this file run: ./gradlew clean setupDecompWorkspace idea
|
||||||
|
|
||||||
# Minecraft
|
# Minecraft
|
||||||
|
##if MC>=11002
|
||||||
public-f net.minecraft.client.Minecraft field_71428_T # timer
|
public-f net.minecraft.client.Minecraft field_71428_T # timer
|
||||||
|
##else
|
||||||
|
#$$ public net.minecraft.client.Minecraft field_71428_T # timer
|
||||||
|
##endif
|
||||||
public net.minecraft.client.Minecraft field_83002_am # debugCrashKeyPressTime
|
public net.minecraft.client.Minecraft field_83002_am # debugCrashKeyPressTime
|
||||||
public net.minecraft.client.Minecraft field_71467_ac # rightClickDelayTimer
|
public net.minecraft.client.Minecraft field_71467_ac # rightClickDelayTimer
|
||||||
public net.minecraft.client.Minecraft field_71423_H # systemTime
|
public net.minecraft.client.Minecraft field_71423_H # systemTime
|
||||||
@@ -21,30 +25,36 @@ public net.minecraft.client.Minecraft func_147112_ai()V # middleClickMouse
|
|||||||
public net.minecraft.client.Minecraft func_147115_a(Z)V # sendClickBlockToController
|
public net.minecraft.client.Minecraft func_147115_a(Z)V # sendClickBlockToController
|
||||||
|
|
||||||
# Packets
|
# Packets
|
||||||
|
##if MC>=10904
|
||||||
public net.minecraft.network.play.server.SPacketSpawnMob field_149043_l # dataManager
|
public net.minecraft.network.play.server.SPacketSpawnMob field_149043_l # dataManager
|
||||||
public net.minecraft.network.play.server.SPacketSpawnPlayer field_148960_i # watcher
|
public net.minecraft.network.play.server.SPacketSpawnPlayer field_148960_i # watcher
|
||||||
#public net.minecraft.network.play.server.S38PacketPlayerListItem field_179964_d # profile
|
##else
|
||||||
# public net.minecraft.network.play.server.S1DPacketEntityEffect field_149434_a # entityId
|
#$$ public net.minecraft.network.play.server.S0FPacketSpawnMob field_149043_l # dataWatcher
|
||||||
# public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149379_a # entityId
|
#$$ public net.minecraft.network.play.server.S1DPacketEntityEffect field_149434_a # entityId
|
||||||
# public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149378_b # list
|
#$$ public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149379_a # entityId
|
||||||
# public net.minecraft.network.play.server.S0BPacketAnimation field_148981_a # entityId
|
#$$ public net.minecraft.network.play.server.S1CPacketEntityMetadata field_149378_b # list
|
||||||
# public net.minecraft.network.play.server.S02PacketChat field_179842_b # position
|
#$$ public net.minecraft.network.play.server.S0BPacketAnimation field_148981_a # entityId
|
||||||
# public net.minecraft.network.play.server.S19PacketEntityStatus field_149164_a # entityId
|
#$$ public net.minecraft.network.play.server.S02PacketChat field_179842_b # position
|
||||||
# public net.minecraft.network.play.server.S18PacketEntityTeleport *
|
#$$ public net.minecraft.network.play.server.S19PacketEntityStatus field_149164_a # entityId
|
||||||
# public net.minecraft.network.play.server.S14PacketEntity *
|
#$$ public net.minecraft.network.play.server.S0CPacketSpawnPlayer *
|
||||||
# public net.minecraft.network.play.server.S19PacketEntityHeadLook *
|
#$$ public net.minecraft.network.play.server.S18PacketEntityTeleport *
|
||||||
# public net.minecraft.network.play.server.S12PacketEntityVelocity *
|
#$$ public net.minecraft.network.play.server.S14PacketEntity *
|
||||||
# public net.minecraft.network.play.server.S04PacketEntityEquipment *
|
#$$ public net.minecraft.network.play.server.S19PacketEntityHeadLook *
|
||||||
# public net.minecraft.network.play.server.S1BPacketEntityAttach *
|
#$$ public net.minecraft.network.play.server.S12PacketEntityVelocity *
|
||||||
# public net.minecraft.network.play.server.S0DPacketCollectItem *
|
#$$ public net.minecraft.network.play.server.S04PacketEntityEquipment *
|
||||||
# public net.minecraft.network.play.server.S13PacketDestroyEntities *
|
#$$ public net.minecraft.network.play.server.S1BPacketEntityAttach *
|
||||||
|
#$$ public net.minecraft.network.play.server.S0DPacketCollectItem *
|
||||||
|
#$$ public net.minecraft.network.play.server.S13PacketDestroyEntities *
|
||||||
|
##endif
|
||||||
|
|
||||||
# GuiTextField
|
# GuiTextField
|
||||||
public net.minecraft.client.gui.GuiTextField field_146216_j # text
|
public net.minecraft.client.gui.GuiTextField field_146216_j # text
|
||||||
|
|
||||||
# GuiMainMenu
|
# GuiMainMenu
|
||||||
|
##if MC>=11202
|
||||||
public net.minecraft.client.gui.GuiMainMenu field_175372_K # realmsButton
|
public net.minecraft.client.gui.GuiMainMenu field_175372_K # realmsButton
|
||||||
public net.minecraft.client.gui.GuiMainMenu field_183503_M # realmsNotification
|
public net.minecraft.client.gui.GuiMainMenu field_183503_M # realmsNotification
|
||||||
|
##endif
|
||||||
|
|
||||||
# Entity
|
# Entity
|
||||||
public net.minecraft.entity.Entity field_70180_af # dataWatcher
|
public net.minecraft.entity.Entity field_70180_af # dataWatcher
|
||||||
@@ -65,7 +75,9 @@ public net.minecraft.client.renderer.RenderGlobal field_175009_l # chunksToUpdat
|
|||||||
public net.minecraft.client.renderer.RenderGlobal field_72755_R # renderInfos
|
public net.minecraft.client.renderer.RenderGlobal field_72755_R # renderInfos
|
||||||
public net.minecraft.client.renderer.RenderGlobal field_175009_l # chunksToUpdate
|
public net.minecraft.client.renderer.RenderGlobal field_175009_l # chunksToUpdate
|
||||||
public net.minecraft.client.renderer.RenderGlobal field_72740_G # renderEntitiesStartupCounter
|
public net.minecraft.client.renderer.RenderGlobal field_72740_G # renderEntitiesStartupCounter
|
||||||
# public net.minecraft.client.renderer.RenderGlobal func_174983_a(Lnet.minecraft.util.BlockPos;Lnet.minecraft.client.renderer.chunk.RenderChunk;)Z # isPositionInRenderChunk
|
##if MC<10904
|
||||||
|
#$$ public net.minecraft.client.renderer.RenderGlobal func_174983_a(Lnet.minecraft.util.BlockPos;Lnet.minecraft.client.renderer.chunk.RenderChunk;)Z # isPositionInRenderChunk
|
||||||
|
##endif
|
||||||
|
|
||||||
public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation
|
public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation
|
||||||
#public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation field_178553_a # renderChunk
|
#public net.minecraft.client.renderer.RenderGlobal$ContainerLocalRenderInformation field_178553_a # renderChunk
|
||||||
@@ -92,17 +104,31 @@ public net.minecraft.entity.player.EntityPlayer *
|
|||||||
public net.minecraft.client.entity.EntityOtherPlayerMP *
|
public net.minecraft.client.entity.EntityOtherPlayerMP *
|
||||||
|
|
||||||
# EffectRenderer
|
# EffectRenderer
|
||||||
# public net.minecraft.client.particle.EffectRenderer field_110737_b # particleTextures
|
##if MC<10904
|
||||||
# public net.minecraft.client.particle.EffectRenderer field_78876_b # fxLayers
|
#$$ public net.minecraft.client.particle.EffectRenderer field_110737_b # particleTextures
|
||||||
|
#$$ public net.minecraft.client.particle.EffectRenderer field_78876_b # fxLayers
|
||||||
|
##endif
|
||||||
|
|
||||||
# IntegratedServer
|
# IntegratedServer
|
||||||
public net.minecraft.server.integrated.IntegratedServer field_71348_o # isGamePaused
|
public net.minecraft.server.integrated.IntegratedServer field_71348_o # isGamePaused
|
||||||
|
|
||||||
# GameSettings
|
# GameSettings
|
||||||
|
##if MC>=10904
|
||||||
|
##if MC>=11002
|
||||||
public-f net.minecraft.client.settings.GameSettings field_186714_aM # soundLevels
|
public-f net.minecraft.client.settings.GameSettings field_186714_aM # soundLevels
|
||||||
|
##else
|
||||||
|
#$$ public net.minecraft.client.settings.GameSettings field_186714_aM # soundLevels
|
||||||
|
##endif
|
||||||
|
##else
|
||||||
|
#$$ public net.minecraft.client.settings.GameSettings field_151446_aD # mapSoundLevels
|
||||||
|
##endif
|
||||||
|
|
||||||
# Frustum
|
# Frustum
|
||||||
|
##if MC>=11002
|
||||||
public-f net.minecraft.client.renderer.culling.Frustum field_78552_a # clippingHelper
|
public-f net.minecraft.client.renderer.culling.Frustum field_78552_a # clippingHelper
|
||||||
|
##else
|
||||||
|
#$$ public net.minecraft.client.renderer.culling.Frustum field_78552_a # clippingHelper
|
||||||
|
##endif
|
||||||
|
|
||||||
# CrashReportCategory
|
# CrashReportCategory
|
||||||
public net.minecraft.crash.CrashReportCategory field_85077_c # children
|
public net.minecraft.crash.CrashReportCategory field_85077_c # children
|
||||||
@@ -121,12 +147,16 @@ public net.minecraft.client.renderer.GlStateManager$FogState
|
|||||||
public net.minecraft.client.renderer.GlStateManager$BooleanState
|
public net.minecraft.client.renderer.GlStateManager$BooleanState
|
||||||
public net.minecraft.client.renderer.GlStateManager$BooleanState *
|
public net.minecraft.client.renderer.GlStateManager$BooleanState *
|
||||||
|
|
||||||
|
##if MC>=10904
|
||||||
# EntityLivingBase
|
# EntityLivingBase
|
||||||
public net.minecraft.entity.EntityLivingBase field_184621_as # HAND_STATES
|
public net.minecraft.entity.EntityLivingBase field_184621_as # HAND_STATES
|
||||||
public net.minecraft.entity.EntityLivingBase field_184628_bn # activeItemStackUseCount
|
public net.minecraft.entity.EntityLivingBase field_184628_bn # activeItemStackUseCount
|
||||||
|
##endif
|
||||||
|
|
||||||
# EntityLivingBase
|
# Particles
|
||||||
|
##if MC>=10904
|
||||||
public net.minecraft.client.particle.Particle *
|
public net.minecraft.client.particle.Particle *
|
||||||
|
##endif
|
||||||
|
|
||||||
# ScreenShotHelper
|
# ScreenShotHelper
|
||||||
public net.minecraft.util.ScreenShotHelper func_74290_a(Ljava/io/File;)Ljava/io/File; # getTimestampedPNGFileForDirectory
|
public net.minecraft.util.ScreenShotHelper func_74290_a(Ljava/io/File;)Ljava/io/File; # getTimestampedPNGFileForDirectory
|
||||||
|
|||||||
@@ -4,12 +4,14 @@
|
|||||||
"mixins": [],
|
"mixins": [],
|
||||||
"server": [],
|
"server": [],
|
||||||
"client": [
|
"client": [
|
||||||
|
//#if MC>=10904
|
||||||
|
"MixinPlayerControllerMP",
|
||||||
|
"MixinWorldClient",
|
||||||
|
//#endif
|
||||||
"MixinNetHandlerLoginClient",
|
"MixinNetHandlerLoginClient",
|
||||||
"MixinNetHandlerPlayClient",
|
"MixinNetHandlerPlayClient",
|
||||||
"MixinNetworkDispatcher",
|
"MixinNetworkDispatcher",
|
||||||
"MixinPlayerControllerMP",
|
"MixinRenderGlobal"
|
||||||
"MixinRenderGlobal",
|
|
||||||
"MixinWorldClient"
|
|
||||||
],
|
],
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"minVersion": "0.6.11",
|
"minVersion": "0.6.11",
|
||||||
|
|||||||
@@ -4,9 +4,14 @@
|
|||||||
"mixins": [],
|
"mixins": [],
|
||||||
"server": [],
|
"server": [],
|
||||||
"client": [
|
"client": [
|
||||||
|
//#if MC>=10904
|
||||||
|
"MixinParticleManager",
|
||||||
|
//#else
|
||||||
|
//$$ "MixinEffectRenderer",
|
||||||
|
//$$ "MixinRendererLivingEntity",
|
||||||
|
//#endif
|
||||||
"MixinEntityRenderer",
|
"MixinEntityRenderer",
|
||||||
"MixinFrustum",
|
"MixinFrustum",
|
||||||
"MixinParticleManager",
|
|
||||||
"MixinRender",
|
"MixinRender",
|
||||||
"MixinRenderGlobal",
|
"MixinRenderGlobal",
|
||||||
"MixinRenderManager"
|
"MixinRenderManager"
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
"mixins": [],
|
"mixins": [],
|
||||||
"server": [],
|
"server": [],
|
||||||
"client": [
|
"client": [
|
||||||
"MixinGuiSpectator",
|
//#if MC>=10904
|
||||||
"MixinParticleManager",
|
"MixinParticleManager",
|
||||||
|
//#endif
|
||||||
|
"MixinGuiSpectator",
|
||||||
"MixinPlayerControllerMP",
|
"MixinPlayerControllerMP",
|
||||||
"MixinRenderArrow",
|
"MixinRenderArrow",
|
||||||
"MixinRenderItem",
|
"MixinRenderItem",
|
||||||
|
|||||||
17
versions/1.10.2/build.gradle
Normal file
17
versions/1.10.2/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../common.gradle'
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = '1.10.2-12.18.2.2099'
|
||||||
|
mappings = "snapshot_20160518"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shade 'com.github.replaymod:ReplayStudio:7d8c2f7'
|
||||||
|
shade project(':jGui:versions:1.9.4')
|
||||||
|
}
|
||||||
17
versions/1.11.2/build.gradle
Normal file
17
versions/1.11.2/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../common.gradle'
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = '1.11.2-13.20.0.2216'
|
||||||
|
mappings = "snapshot_20161220"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shade 'com.github.replaymod:ReplayStudio:9605121'
|
||||||
|
shade project(':jGui:versions:1.9.4')
|
||||||
|
}
|
||||||
17
versions/1.11/build.gradle
Normal file
17
versions/1.11/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../common.gradle'
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = '1.11-13.19.1.2188'
|
||||||
|
mappings = "snapshot_20161111"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shade 'com.github.ReplayMod:ReplayStudio:2b063ec'
|
||||||
|
shade project(':jGui:versions:1.9.4')
|
||||||
|
}
|
||||||
17
versions/1.12.1/build.gradle
Normal file
17
versions/1.12.1/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../common.gradle'
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = '1.12.1-14.22.0.2444'
|
||||||
|
mappings = "snapshot_20170615"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shade 'com.github.replaymod:ReplayStudio:9ee698e'
|
||||||
|
shade project(':jGui:versions:1.12')
|
||||||
|
}
|
||||||
17
versions/1.12.2/build.gradle
Normal file
17
versions/1.12.2/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../common.gradle'
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = '1.12.2-14.23.0.2486'
|
||||||
|
mappings = "snapshot_20170615"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shade 'com.github.replaymod:ReplayStudio:b040763'
|
||||||
|
shade project(':jGui:versions:1.12')
|
||||||
|
}
|
||||||
17
versions/1.12/build.gradle
Normal file
17
versions/1.12/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../common.gradle'
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = '1.12-14.21.1.2387'
|
||||||
|
mappings = "snapshot_20170615"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shade 'com.github.replaymod:ReplayStudio:9ee698e'
|
||||||
|
shade project(':jGui:versions:1.12')
|
||||||
|
}
|
||||||
17
versions/1.8.9/build.gradle
Normal file
17
versions/1.8.9/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../common.gradle'
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = '1.8.9-11.15.1.1722'
|
||||||
|
mappings = "stable_22"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shade 'com.github.replaymod:ReplayStudio:a2168ca'
|
||||||
|
shade project(':jGui:versions:1.8.9')
|
||||||
|
}
|
||||||
17
versions/1.8/build.gradle
Normal file
17
versions/1.8/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../common.gradle'
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = '1.8-11.14.4.1563'
|
||||||
|
mappings = "snapshot_nodoc_20141130"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shade 'com.github.replaymod:ReplayStudio:a2168ca'
|
||||||
|
shade project(':jGui:versions:1.8')
|
||||||
|
}
|
||||||
17
versions/1.9.4/build.gradle
Normal file
17
versions/1.9.4/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../common.gradle'
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = '1.9.4-12.17.0.1976'
|
||||||
|
mappings = "snapshot_20160518"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shade 'com.github.replaymod:ReplayStudio:14daa88'
|
||||||
|
shade project(':jGui:versions:1.9.4')
|
||||||
|
}
|
||||||
273
versions/common.gradle
Normal file
273
versions/common.gradle
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'org.ow2.asm:asm:6.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||||
|
apply plugin: 'org.spongepowered.mixin'
|
||||||
|
|
||||||
|
sourceCompatibility = 1.8
|
||||||
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
|
version = gitDescribe()
|
||||||
|
group= "com.replaymod"
|
||||||
|
archivesBaseName = "replaymod"
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
coreMod = 'com.replaymod.core.LoadingPlugin'
|
||||||
|
runDir = "../../eclipse"
|
||||||
|
replace '@MOD_VERSION@', project.version
|
||||||
|
}
|
||||||
|
afterEvaluate {
|
||||||
|
// Includes intentional whitespace to stop Forge from declaring the mod to be compatible with
|
||||||
|
// a newer srg-compatible MC version (that may be using a different protocol version)
|
||||||
|
minecraft.replace '@MC_VERSION@', "[ ${project.minecraft.version} ]"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "SpongePowered Repo"
|
||||||
|
url = "http://repo.spongepowered.org/maven/"
|
||||||
|
}
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
shade
|
||||||
|
compile.extendsFrom shade
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile 'org.projectlombok:lombok:1.16.4'
|
||||||
|
|
||||||
|
compile 'org.spongepowered:mixin:0.7.5-SNAPSHOT'
|
||||||
|
shade 'com.googlecode.mp4parser:isoparser:1.1.7'
|
||||||
|
shade 'org.apache.commons:commons-exec:1.3'
|
||||||
|
def withoutGuava = { exclude group: 'com.google.guava', module: 'guava-jdk5' }
|
||||||
|
shade 'com.google.apis:google-api-services-youtube:v3-rev178-1.22.0', withoutGuava
|
||||||
|
shade 'com.google.api-client:google-api-client-gson:1.20.0', withoutGuava
|
||||||
|
shade 'com.google.api-client:google-api-client-java6:1.20.0', withoutGuava
|
||||||
|
shade 'com.google.oauth-client:google-oauth-client-jetty:1.20.0'
|
||||||
|
|
||||||
|
shade 'org.aspectj:aspectjrt:1.8.2'
|
||||||
|
|
||||||
|
testCompile 'junit:junit:4.11'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (project.name != 'core') {
|
||||||
|
apply from: '../preprocessor.gradle'
|
||||||
|
|
||||||
|
def preprocessedSrc = 'build/preprocessed/src'
|
||||||
|
def preprocessedRes = 'build/preprocessed/res'
|
||||||
|
def originalSrc = '../../src/main/java'
|
||||||
|
def originalRes = '../../src/main/resources'
|
||||||
|
def (major, minor, patch) = project.name.tokenize('.')
|
||||||
|
def mcVersion = "${major}${minor.padLeft(2, '0')}${(patch ?: '').padLeft(2, '0')}"
|
||||||
|
def vars = [MC: mcVersion as int]
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDir preprocessedSrc
|
||||||
|
main.resources.srcDir preprocessedRes
|
||||||
|
}
|
||||||
|
|
||||||
|
task preprocessJava {
|
||||||
|
inputs.dir(originalSrc)
|
||||||
|
outputs.dir(preprocessedSrc)
|
||||||
|
doLast {
|
||||||
|
project.convertTree(vars, originalSrc, preprocessedSrc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task preprocessResources {
|
||||||
|
inputs.dir(originalRes)
|
||||||
|
outputs.dir(preprocessedRes)
|
||||||
|
doLast {
|
||||||
|
project.convertTree(vars, originalRes, preprocessedRes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava.dependsOn preprocessJava
|
||||||
|
processResources.dependsOn preprocessResources
|
||||||
|
[deobfMcMCP, deobfMcSRG].each { task ->
|
||||||
|
task.dependsOn preprocessResources
|
||||||
|
}
|
||||||
|
|
||||||
|
minecraft.accessTransformer preprocessedRes + '/META-INF/replaymod_at.cfg'
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
|
||||||
|
dependsOn configurations.compile
|
||||||
|
dependsOn configurations.shade
|
||||||
|
|
||||||
|
def shade = {files(
|
||||||
|
configurations.compile.findAll {it.name.startsWith 'mixin-'}
|
||||||
|
+ configurations.shade
|
||||||
|
)}
|
||||||
|
|
||||||
|
def noticeDir = file("$buildDir/NOTICE")
|
||||||
|
doFirst {
|
||||||
|
noticeDir.deleteDir()
|
||||||
|
noticeDir.mkdirs()
|
||||||
|
shade().collect { it.isDirectory() ? fileTree(it) : zipTree(it) }.each {
|
||||||
|
it.matching { include '**/NOTICE*' }.each {
|
||||||
|
new File(noticeDir, 'NOTICE.txt') << it.getText('UTF-8') + '\n'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
from noticeDir
|
||||||
|
|
||||||
|
from ({shade().collect { it.isDirectory() ? it : zipTree(it) }}) {
|
||||||
|
exclude '**/NOTICE*'
|
||||||
|
eachFile {
|
||||||
|
if (getName() == 'LICENSE.txt') {
|
||||||
|
setName(getFile().getParentFile().getName().split('.jar_')[0] + '-LICENSE.txt')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
||||||
|
'TweakOrder': '0',
|
||||||
|
'FMLCorePluginContainsFMLMod': 'true',
|
||||||
|
'FMLAT': 'replaymod_at.cfg'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def gitDescribe() {
|
||||||
|
try {
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine 'git', 'describe', '--always', '--dirty=*'
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
return stdout.toString().trim()
|
||||||
|
} catch (e) {
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
ext.refMap = "mixins.replaymod.refmap.json"
|
||||||
|
}
|
||||||
|
integrationTest {
|
||||||
|
compileClasspath += main.runtimeClasspath + main.output
|
||||||
|
java {
|
||||||
|
srcDir file('src/integration-test/java')
|
||||||
|
}
|
||||||
|
resources.srcDir file('src/integration-test/resources')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task copySrg(type: Copy, dependsOn: 'genSrgs') {
|
||||||
|
from {project.tasks.genSrgs.mcpToSrg}
|
||||||
|
into 'build'
|
||||||
|
}
|
||||||
|
|
||||||
|
setupDecompWorkspace.dependsOn copySrg
|
||||||
|
setupDevWorkspace.dependsOn copySrg
|
||||||
|
project.tasks.idea.dependsOn copySrg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
|
import java.util.zip.ZipFile
|
||||||
|
import java.util.zip.ZipOutputStream
|
||||||
|
|
||||||
|
import org.objectweb.asm.*
|
||||||
|
|
||||||
|
import static org.objectweb.asm.Opcodes.ASM5
|
||||||
|
|
||||||
|
// MC binaries were complied with a java version that produces invalid class files under certain circumstances
|
||||||
|
// This causes setupCIWorkspace to be insufficient for compiling.
|
||||||
|
// Related JDK bug: https://bugs.openjdk.java.net/browse/JDK-8066725
|
||||||
|
// As a workaround, to use setupCIWorkspace on Drone, we modify the bin jar in-place and remove all parameter annotations.
|
||||||
|
// WARNING: This piece of code ignores any and all gradle conventions and will probably fail horribly when run outside
|
||||||
|
// of a single-use environment (e.g. Drone). Use setupDecompWorkspace for normal use.
|
||||||
|
tasks.deobfMcMCP.doLast {
|
||||||
|
println "Applying RuntimeInvisibleParameterAnnotations workaround..."
|
||||||
|
File jar = getOutJar()
|
||||||
|
File tmp = new File((File) getTemporaryDir(), "workaround.jar")
|
||||||
|
tmp.withOutputStream {
|
||||||
|
new ZipOutputStream(it).withStream { dst ->
|
||||||
|
new ZipFile(jar).withCloseable { src ->
|
||||||
|
src.entries().each {
|
||||||
|
if (it.name.startsWith("net/minecraft/") && it.name.endsWith(".class")) {
|
||||||
|
def cw = new ClassWriter(0)
|
||||||
|
def cv = new ClassVisitor(ASM5, cw) {
|
||||||
|
@Override
|
||||||
|
MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||||
|
return new MethodVisitor(ASM5, cv.visitMethod(access, name, desc, signature, exceptions)) {
|
||||||
|
@Override
|
||||||
|
AnnotationVisitor visitParameterAnnotation(int parameter, String pdesc, boolean visible) {
|
||||||
|
return null // Strip all parameter annotations
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new ClassReader(src.getInputStream(it)).accept(cv, 0)
|
||||||
|
dst.putNextEntry(new ZipEntry(it.name))
|
||||||
|
dst.write(cw.toByteArray())
|
||||||
|
} else {
|
||||||
|
dst.putNextEntry(it)
|
||||||
|
dst.write(src.getInputStream(it).bytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jar.delete()
|
||||||
|
tmp.renameTo(jar)
|
||||||
|
}
|
||||||
|
|
||||||
|
task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
|
||||||
|
main = 'GradleStart'
|
||||||
|
standardOutput = System.out
|
||||||
|
errorOutput = System.err
|
||||||
|
workingDir file(minecraft.runDir)
|
||||||
|
|
||||||
|
def testDir = new File(minecraft.runDir, "integration-test")
|
||||||
|
doFirst {
|
||||||
|
testDir.deleteDir()
|
||||||
|
testDir.mkdirs()
|
||||||
|
}
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
testDir.deleteDir()
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
def runClient = tasks.getByName("runClient")
|
||||||
|
runIntegrationTest.jvmArgs = runClient.jvmArgs + "-Dfml.noGrab=true"
|
||||||
|
runIntegrationTest.args = runClient.args + "--gameDir" + testDir.canonicalPath
|
||||||
|
runIntegrationTest.classpath runClient.classpath + sourceSets.integrationTest.output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultTasks 'build'
|
||||||
108
versions/core/build.gradle
Normal file
108
versions/core/build.gradle
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
//#if MC>=10904
|
||||||
|
//#if MC>=11200
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||||
|
//#else
|
||||||
|
//$$ classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
|
||||||
|
//#else
|
||||||
|
//$$ classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: '../common.gradle'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs = ['../../src/main/java']
|
||||||
|
main.resources.srcDirs = ['../../src/main/resources']
|
||||||
|
}
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
//#if MC>=11202
|
||||||
|
version = '1.12.2-14.23.0.2486'
|
||||||
|
mappings = "snapshot_20170615"
|
||||||
|
//#else
|
||||||
|
//#if MC>=11201
|
||||||
|
//$$ version = '1.12.1-14.22.0.2444'
|
||||||
|
//$$ mappings = "snapshot_20170615"
|
||||||
|
//#else
|
||||||
|
//#if MC>=11200
|
||||||
|
//$$ version = '1.12-14.21.1.2387'
|
||||||
|
//$$ mappings = "snapshot_20170615"
|
||||||
|
//#else
|
||||||
|
//#if MC>=11102
|
||||||
|
//$$ version = '1.11.2-13.20.0.2216'
|
||||||
|
//$$ mappings = "snapshot_20161220"
|
||||||
|
//#else
|
||||||
|
//#if MC>=11100
|
||||||
|
//$$ version = '1.11-13.19.1.2188'
|
||||||
|
//$$ mappings = "snapshot_20161111"
|
||||||
|
//#else
|
||||||
|
//#if MC>=11002
|
||||||
|
//$$ version = '1.10.2-12.18.2.2099'
|
||||||
|
//$$ mappings = "snapshot_20160518"
|
||||||
|
//#else
|
||||||
|
//#if MC>=10904
|
||||||
|
//$$ version = '1.9.4-12.17.0.1976'
|
||||||
|
//$$ mappings = "snapshot_20160518"
|
||||||
|
//#else
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ version = '1.8.9-11.15.1.1722'
|
||||||
|
//$$ mappings = "stable_22"
|
||||||
|
//#else
|
||||||
|
//$$ version = '1.8-11.14.4.1563'
|
||||||
|
//$$ mappings = "snapshot_nodoc_20141130"
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
//#if MC>=11200
|
||||||
|
//#if MC>=11202
|
||||||
|
shade 'com.github.replaymod:ReplayStudio:b040763'
|
||||||
|
//#else
|
||||||
|
//#if MC>=11201
|
||||||
|
//$$ shade 'com.github.replaymod:ReplayStudio:d4b2037'
|
||||||
|
//#else
|
||||||
|
//$$ shade 'com.github.replaymod:ReplayStudio:9ee698e'
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
shade project(':jGui:versions:1.12')
|
||||||
|
//#else
|
||||||
|
//#if MC>=10904
|
||||||
|
//$$ shade project(':jGui:versions:1.9.4')
|
||||||
|
//#if MC>=11002
|
||||||
|
//#if MC>=11100
|
||||||
|
//#if MC>=11102
|
||||||
|
//$$ shade 'com.github.replaymod:ReplayStudio:9605121'
|
||||||
|
//#else
|
||||||
|
//$$ shade 'com.github.ReplayMod:ReplayStudio:2b063ec'
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//$$ shade 'com.github.replaymod:ReplayStudio:7d8c2f7'
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//$$ shade 'com.github.replaymod:ReplayStudio:14daa88'
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
//#if MC>=10809
|
||||||
|
//$$ shade project(':jGui:versions:1.8.9')
|
||||||
|
//#else
|
||||||
|
//$$ shade project(':jGui:versions:1.8')
|
||||||
|
//#endif
|
||||||
|
//$$ shade 'com.github.replaymod:ReplayStudio:a2168ca'
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
151
versions/preprocessor.gradle
Normal file
151
versions/preprocessor.gradle
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
static def evalVar(vars, String var) {
|
||||||
|
if (var.number) {
|
||||||
|
return var as int
|
||||||
|
} else {
|
||||||
|
return vars[var]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
static def evalExpr(vars, String expr) {
|
||||||
|
def matcher = Pattern.compile(/(.+)(<=|>=|<|>)(.+)/).matcher(expr)
|
||||||
|
if (matcher.matches()) {
|
||||||
|
def lhs = evalVar(vars, matcher.group(1))
|
||||||
|
def rhs = evalVar(vars, matcher.group(3))
|
||||||
|
switch (matcher.group(2)) {
|
||||||
|
case '>=': return lhs >= rhs
|
||||||
|
case '<=': return lhs <= rhs
|
||||||
|
case '>': return lhs > rhs
|
||||||
|
case '<': return lhs < rhs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static def getIndent(String str) {
|
||||||
|
return str.takeWhile {it == ' '}.length()
|
||||||
|
}
|
||||||
|
|
||||||
|
class ParserException extends RuntimeException {
|
||||||
|
ParserException(String str) {
|
||||||
|
super(str)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static def convertSource(Map<String, String> kws, Map<String, Integer> vars, List<String> lines, String fileName) {
|
||||||
|
def ifStack = []
|
||||||
|
List<Integer> indentStack = []
|
||||||
|
def active = true
|
||||||
|
def n = 0
|
||||||
|
lines = lines.collect { line ->
|
||||||
|
n++
|
||||||
|
def trimmed = line.trim()
|
||||||
|
if (trimmed.startsWith(kws.if)) {
|
||||||
|
def result = evalExpr(vars, trimmed.substring(kws.if.length()))
|
||||||
|
ifStack.push(result)
|
||||||
|
if (result != null) {
|
||||||
|
indentStack.push(getIndent(line))
|
||||||
|
active &= result
|
||||||
|
}
|
||||||
|
} else if (trimmed.startsWith(kws.else)) {
|
||||||
|
if (ifStack.isEmpty()) {
|
||||||
|
throw new ParserException("Unexpected else in line $n of $fileName")
|
||||||
|
}
|
||||||
|
def head = ifStack.pop()
|
||||||
|
if (head != null) {
|
||||||
|
head = !head
|
||||||
|
indentStack.pop()
|
||||||
|
indentStack.push(getIndent(line))
|
||||||
|
}
|
||||||
|
ifStack.push(head)
|
||||||
|
active = true;
|
||||||
|
ifStack.each {
|
||||||
|
if (it != null) {
|
||||||
|
active &= it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (trimmed.startsWith(kws.ifdef)) {
|
||||||
|
ifStack.push(null)
|
||||||
|
} else if (trimmed.startsWith(kws.endif)) {
|
||||||
|
if (ifStack.isEmpty()) {
|
||||||
|
throw new ParserException("Unexpected endif in line $n of $fileName")
|
||||||
|
}
|
||||||
|
def head = ifStack.pop()
|
||||||
|
if (head != null) {
|
||||||
|
indentStack.pop()
|
||||||
|
active = true;
|
||||||
|
ifStack.each {
|
||||||
|
if (it != null) {
|
||||||
|
active &= it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (active) {
|
||||||
|
if (trimmed.startsWith(kws.eval)) {
|
||||||
|
line = line.replaceFirst(Pattern.quote(kws.eval) + ' ?', '')
|
||||||
|
if (line.trim().isEmpty()) {
|
||||||
|
line = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
def currIndent = indentStack.last()
|
||||||
|
if (trimmed.isEmpty()) {
|
||||||
|
line = ' ' * currIndent + kws.eval
|
||||||
|
} else if (!trimmed.startsWith(kws.eval)) {
|
||||||
|
def actualIndent = getIndent(line)
|
||||||
|
if (currIndent <= actualIndent) {
|
||||||
|
line = ' ' * currIndent + kws.eval + ' ' + line.substring(currIndent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line
|
||||||
|
}
|
||||||
|
if (!ifStack.isEmpty()) {
|
||||||
|
throw new ParserException("Missing endif in $fileName")
|
||||||
|
}
|
||||||
|
return lines
|
||||||
|
}
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
|
static def convertFile(Map<String, String> kws, Map<String, Integer> vars, File inFile, File outFile) {
|
||||||
|
def string = new String(inFile.readBytes(), StandardCharsets.UTF_8)
|
||||||
|
def lines = string.readLines()
|
||||||
|
try {
|
||||||
|
lines = convertSource(kws, vars, lines, inFile.path)
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof ParserException) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Failed to convert file " + inFile, e)
|
||||||
|
}
|
||||||
|
outFile.parentFile.mkdirs()
|
||||||
|
if (string.endsWith('\n')) {
|
||||||
|
outFile.write(lines.collect { it + '\n' }.join(''))
|
||||||
|
} else {
|
||||||
|
outFile.write(lines.join('\n'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.ext.convertTree = { Map<String, Integer> vars, String inName, String outName=inName ->
|
||||||
|
def defaultKws = [if: '//#if ', ifdef: '//#ifdef ', else: '//#else', endif: '//#endif', eval: '//$$']
|
||||||
|
def cfgKws = [if: '##if ', ifdef: '##ifdef ', else: '##else', endif: '##endif', eval: '#$$']
|
||||||
|
def extensions = ['.java': defaultKws, '.gradle': defaultKws, '.json': defaultKws, '.cfg': cfgKws]
|
||||||
|
def inPath = project.file(inName).toPath()
|
||||||
|
def outPath = project.file(outName).toPath()
|
||||||
|
def inPlace = inPath.toAbsolutePath().equals(outPath.toAbsolutePath())
|
||||||
|
project.fileTree(inName).forEach { file ->
|
||||||
|
def outFile = outPath.resolve(inPath.relativize(file.toPath())).toFile()
|
||||||
|
def kws = extensions.find { ext, _ -> file.name.endsWith(ext) }
|
||||||
|
if (kws) {
|
||||||
|
convertFile(kws.value, vars, file, outFile)
|
||||||
|
} else if (!inPlace) {
|
||||||
|
copy {
|
||||||
|
from file
|
||||||
|
into outFile.parentFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user