Replace reflection in ChunkLoadingRenderGlobal with mixin
This commit is contained in:
@@ -3,8 +3,6 @@ package com.replaymod.render.hooks;
|
||||
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
//#if MC>=11500
|
||||
//#else
|
||||
//$$ import com.replaymod.render.mixin.ChunkRenderDispatcherAccessor;
|
||||
@@ -45,20 +43,10 @@ public class ChunkLoadingRenderGlobal {
|
||||
this.hooked = renderGlobal;
|
||||
|
||||
//#if MC>=11500
|
||||
install();
|
||||
//#else
|
||||
//$$ setup(((WorldRendererAccessor) renderGlobal).getRenderDispatcher());
|
||||
//$$ install();
|
||||
//#endif
|
||||
}
|
||||
|
||||
private void install() {
|
||||
try {
|
||||
Field hookField = WorldRenderer.class.getField("replayModRender_hook");
|
||||
hookField.set(hooked, this);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
IForceChunkLoading.from(renderGlobal).replayModRender_setHook(this);
|
||||
}
|
||||
|
||||
//#if MC>=11500
|
||||
@@ -153,12 +141,7 @@ public class ChunkLoadingRenderGlobal {
|
||||
//$$ workerJailingQueue.freeAll();
|
||||
//#endif
|
||||
|
||||
try {
|
||||
Field hookField = WorldRenderer.class.getField("replayModRender_hook");
|
||||
hookField.set(hooked, null);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
IForceChunkLoading.from(hooked).replayModRender_setHook(null);
|
||||
}
|
||||
|
||||
//#if MC>=11500
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//#if MC>=10800
|
||||
package com.replaymod.render.hooks;
|
||||
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
|
||||
public interface IForceChunkLoading {
|
||||
void replayModRender_setHook(ChunkLoadingRenderGlobal hook);
|
||||
|
||||
static IForceChunkLoading from(WorldRenderer worldRenderer) {
|
||||
return (IForceChunkLoading) worldRenderer;
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
@@ -3,6 +3,7 @@ package com.replaymod.render.mixin;
|
||||
//#if MC>=10800
|
||||
import com.replaymod.compat.shaders.ShaderReflection;
|
||||
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
||||
import com.replaymod.render.hooks.IForceChunkLoading;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.Frustum;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
@@ -31,8 +32,13 @@ import java.util.Set;
|
||||
//#endif
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
public abstract class Mixin_ForceChunkLoading {
|
||||
public ChunkLoadingRenderGlobal replayModRender_hook;
|
||||
public abstract class Mixin_ForceChunkLoading implements IForceChunkLoading {
|
||||
private ChunkLoadingRenderGlobal replayModRender_hook;
|
||||
|
||||
@Override
|
||||
public void replayModRender_setHook(ChunkLoadingRenderGlobal hook) {
|
||||
this.replayModRender_hook = hook;
|
||||
}
|
||||
|
||||
//#if MC>=11500
|
||||
@Shadow private Set<ChunkBuilder.BuiltChunk> chunksToRebuild;
|
||||
|
||||
Reference in New Issue
Block a user