Move 1.7.10 code from MixinEntityRenderer to Mixin_ForceChunkLoading

This commit is contained in:
Jonas Herzig
2021-02-27 19:45:00 +01:00
parent e7a1fafdf9
commit fad89626e5
4 changed files with 34 additions and 12 deletions

View File

@@ -3,9 +3,15 @@ package com.replaymod.render.hooks;
import net.minecraft.client.renderer.RenderGlobal;
public class ForceChunkLoadingHook {
private final RenderGlobal hooked;
public ForceChunkLoadingHook(RenderGlobal renderGlobal) {
this.hooked = renderGlobal;
IForceChunkLoading.from(renderGlobal).replayModRender_setHook(this);
}
public void uninstall() {
IForceChunkLoading.from(hooked).replayModRender_setHook(null);
}
}

View File

@@ -0,0 +1,27 @@
package com.replaymod.render.mixin;
import com.replaymod.render.hooks.ForceChunkLoadingHook;
import com.replaymod.render.hooks.IForceChunkLoading;
import net.minecraft.client.renderer.RenderGlobal;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(RenderGlobal.class)
public abstract class Mixin_ForceChunkLoading implements IForceChunkLoading {
private ForceChunkLoadingHook replayModRender_hook;
@Override
public void replayModRender_setHook(ForceChunkLoadingHook hook) {
this.replayModRender_hook = hook;
}
@ModifyVariable(method = "updateRenderers", at = @At("HEAD"), argsOnly = true)
private boolean replayModRender_updateAllChunks(boolean renderAllChunks) {
if (replayModRender_hook != null) {
renderAllChunks = true;
}
return renderAllChunks;
}
}