Add .blend export
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.replaymod.render.blend.mixin;
|
||||
|
||||
import com.replaymod.render.blend.BlendState;
|
||||
import com.replaymod.render.blend.exporters.ChunkExporter;
|
||||
import net.minecraft.client.renderer.chunk.ChunkCompileTaskGenerator;
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderWorker;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(ChunkRenderWorker.class)
|
||||
public abstract class MixinChunkRenderWorker {
|
||||
|
||||
@Inject(method = "processTask", at = @At("RETURN"))
|
||||
public void afterChunkUpdate(ChunkCompileTaskGenerator task, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
if (task.getStatus() == ChunkCompileTaskGenerator.Status.DONE
|
||||
&& task.getType() == ChunkCompileTaskGenerator.Type.REBUILD_CHUNK) {
|
||||
for (EnumWorldBlockLayer layer : EnumWorldBlockLayer.values()) {
|
||||
if (task.getCompiledChunk().isLayerStarted(layer)) {
|
||||
blendState.get(ChunkExporter.class).addChunkUpdate(task.getRenderChunk(), layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.replaymod.render.blend.mixin;
|
||||
|
||||
import com.replaymod.render.blend.BlendState;
|
||||
import com.replaymod.render.blend.exporters.ParticlesExporter;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(EffectRenderer.class)
|
||||
public abstract class MixinEffectRenderer {
|
||||
|
||||
@Inject(method = "renderParticles", at = @At("HEAD"))
|
||||
public void preRender(Entity view, float renderPartialTicks, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ParticlesExporter.class).preParticlesRender(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderParticles", at = @At("RETURN"))
|
||||
public void postRender(Entity view, float renderPartialTicks, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ParticlesExporter.class).postParticlesRender();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderLitParticles", at = @At("HEAD"))
|
||||
public void preLitRender(Entity view, float renderPartialTicks, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ParticlesExporter.class).preParticlesRender(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderLitParticles", at = @At("RETURN"))
|
||||
public void postLitRender(Entity view, float renderPartialTicks, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ParticlesExporter.class).postParticlesRender();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.replaymod.render.blend.mixin;
|
||||
|
||||
import com.replaymod.render.blend.BlendState;
|
||||
import com.replaymod.render.blend.exporters.ModelRendererExporter;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(ModelRenderer.class)
|
||||
public abstract class MixinModelRenderer {
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
public void preRender(float scale, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ModelRendererExporter.class).preRenderModel((ModelRenderer)(Object)this, scale);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderWithRotation", at = @At("HEAD"))
|
||||
public void preRenderWithRotation(float scale, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ModelRendererExporter.class).preRenderModel((ModelRenderer)(Object)this, scale);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"))
|
||||
public void postRender(float scale, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ModelRendererExporter.class).postRenderModel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderWithRotation", at = @At("RETURN"))
|
||||
public void postRenderWithRotation(float scale, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ModelRendererExporter.class).postRenderModel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "render",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/GlStateManager;callList(I)V"),
|
||||
expect = 3)
|
||||
public void onRender(float scale, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ModelRendererExporter.class).onRenderModel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderWithRotation",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/GlStateManager;callList(I)V"))
|
||||
public void onRenderWithRotation(float scale, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ModelRendererExporter.class).onRenderModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.replaymod.render.blend.mixin;
|
||||
|
||||
import com.replaymod.render.blend.BlendState;
|
||||
import com.replaymod.render.blend.exporters.EntityExporter;
|
||||
import com.replaymod.render.blend.exporters.TileEntityExporter;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.culling.ICamera;
|
||||
import net.minecraft.entity.Entity;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(RenderGlobal.class)
|
||||
public abstract class MixinRenderGlobal {
|
||||
|
||||
// FIXME wither skull ._. mojang pls
|
||||
|
||||
@Inject(method = "renderEntities",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/entity/RenderManager;renderEntitySimple(Lnet/minecraft/entity/Entity;F)V"))
|
||||
public void preEntityRender(Entity view, ICamera camera, float renderPartialTicks, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(EntityExporter.class).preEntitiesRender();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderEntities",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/entity/RenderManager;renderEntitySimple(Lnet/minecraft/entity/Entity;F)V",
|
||||
shift = At.Shift.AFTER))
|
||||
public void postEntityRender(Entity view, ICamera camera, float renderPartialTicks, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(EntityExporter.class).postEntitiesRender();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderEntities",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher;renderTileEntity(Lnet/minecraft/tileentity/TileEntity;FI)V"))
|
||||
public void preTileEntityRender(Entity view, ICamera camera, float renderPartialTicks, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(TileEntityExporter.class).preTileEntitiesRender();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderEntities",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher;renderTileEntity(Lnet/minecraft/tileentity/TileEntity;FI)V",
|
||||
shift = At.Shift.AFTER))
|
||||
public void postTileEntityRender(Entity view, ICamera camera, float renderPartialTicks, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(TileEntityExporter.class).postTileEntitiesRender();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.replaymod.render.blend.mixin;
|
||||
|
||||
import com.replaymod.render.blend.BlendState;
|
||||
import com.replaymod.render.blend.exporters.ItemExporter;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(RenderItem.class)
|
||||
public abstract class MixinRenderItem {
|
||||
@Inject(method = "renderModel(Lnet/minecraft/client/resources/model/IBakedModel;Lnet/minecraft/item/ItemStack;)V",
|
||||
at = @At("HEAD"))
|
||||
private void onRenderModel(IBakedModel model, ItemStack stack, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(ItemExporter.class).onRender(model, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.replaymod.render.blend.mixin;
|
||||
|
||||
import com.replaymod.render.blend.BlendState;
|
||||
import com.replaymod.render.blend.exporters.EntityExporter;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
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(RenderManager.class)
|
||||
public abstract class MixinRenderManager {
|
||||
|
||||
@Inject(method = "doRenderEntity",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/entity/Render;doRender(Lnet/minecraft/entity/Entity;DDDFFZ)V"))
|
||||
public void preRender(Entity entity, double x, double y, double z, float yaw, float renderPartialTicks, boolean box, CallbackInfoReturnable<Boolean> ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(EntityExporter.class).preRender(entity, x, y, z, yaw, renderPartialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "doRenderEntity",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/entity/Render;doRender(Lnet/minecraft/entity/Entity;DDDFFZ)V",
|
||||
shift = At.Shift.AFTER))
|
||||
public void postRender(Entity entity, double x, double y, double z, float yaw, float renderPartialTicks, boolean box, CallbackInfoReturnable<Boolean> ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(EntityExporter.class).postRender(entity, x, y, z, yaw, renderPartialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.replaymod.render.blend.mixin;
|
||||
|
||||
import com.replaymod.render.blend.BlendState;
|
||||
import com.replaymod.render.blend.exporters.TileEntityExporter;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(TileEntityRendererDispatcher.class)
|
||||
public abstract class MixinTileEntityRendererDispatcher {
|
||||
|
||||
@Inject(method = "renderTileEntityAt(Lnet/minecraft/tileentity/TileEntity;DDDFI)V",
|
||||
at = @At("HEAD"))
|
||||
public void preRender(TileEntity tileEntity, double x, double y, double z, float renderPartialTicks, int destroyStage, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(TileEntityExporter.class).preRender(tileEntity, x, y, z, renderPartialTicks, destroyStage);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderTileEntityAt(Lnet/minecraft/tileentity/TileEntity;DDDFI)V",
|
||||
at = @At("RETURN"))
|
||||
public void postRender(TileEntity tileEntity, double x, double y, double z, float renderPartialTicks, int destroyStage, CallbackInfo ci) {
|
||||
BlendState blendState = BlendState.getState();
|
||||
if (blendState != null) {
|
||||
blendState.get(TileEntityExporter.class).postRender();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user