tile entities on contraptions account for self lighting
This commit is contained in:
parent
a8053ce472
commit
d824304f12
4 changed files with 36 additions and 7 deletions
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.*;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
@ -75,7 +76,7 @@ public class ContraptionRenderer {
|
|||
protected static void renderTileEntities(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
if (FastRenderDispatcher.available()) {
|
||||
TileEntityRenderHelper.renderTileEntities(world, c.specialRenderedTileEntities, ms, msLocal, buffer);
|
||||
ContraptionRenderDispatcher.renderTileEntities(world, c, ms, msLocal, buffer);
|
||||
} else {
|
||||
TileEntityRenderHelper.renderTileEntities(world, c.maybeInstancedTileEntities, ms, msLocal, buffer);
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Abs
|
|||
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler;
|
||||
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
||||
import com.simibubi.create.foundation.render.TileEntityRenderHelper;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.Backend;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
|
@ -61,6 +63,13 @@ public class ContraptionRenderDispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
public static void renderTileEntities(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
RenderedContraption renderer = getRenderer(world, c);
|
||||
|
||||
TileEntityRenderHelper.renderTileEntities(world, renderer.renderWorld, c.specialRenderedTileEntities, ms, msLocal, buffer);
|
||||
}
|
||||
|
||||
private static <C extends AbstractContraptionEntity> void updateTransform(C c, AbstractContraptionEntityRenderer<C> entityRenderer) {
|
||||
MatrixStack stack = entityRenderer.makeTransformMatrix(c, AnimationTickHolder.getPartialTicks());
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ public class RenderedContraption {
|
|||
}
|
||||
|
||||
void setup(ContraptionProgram shader) {
|
||||
if (model == null) return;
|
||||
shader.bind(model, lighter.lightVolume.getTextureVolume());
|
||||
lighter.lightVolume.use();
|
||||
}
|
||||
|
|
|
@ -5,16 +5,16 @@ import com.simibubi.create.Create;
|
|||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
|
@ -22,6 +22,12 @@ public class TileEntityRenderHelper {
|
|||
|
||||
public static void renderTileEntities(World world, Iterable<TileEntity> customRenderTEs, MatrixStack ms,
|
||||
MatrixStack localTransform, IRenderTypeBuffer buffer) {
|
||||
|
||||
renderTileEntities(world, null, customRenderTEs, ms, localTransform, buffer);
|
||||
}
|
||||
|
||||
public static void renderTileEntities(World world, PlacementSimulationWorld renderWorld, Iterable<TileEntity> customRenderTEs, MatrixStack ms,
|
||||
MatrixStack localTransform, IRenderTypeBuffer buffer) {
|
||||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
Matrix4f matrix = localTransform.peek()
|
||||
.getModel();
|
||||
|
@ -45,8 +51,20 @@ public class TileEntityRenderHelper {
|
|||
Vector4f vec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1);
|
||||
vec.transform(matrix);
|
||||
BlockPos lightPos = new BlockPos(vec.getX(), vec.getY(), vec.getZ());
|
||||
renderer.render(tileEntity, pt, ms, buffer, WorldRenderer.getLightmapCoordinates(world, lightPos),
|
||||
OverlayTexture.DEFAULT_UV);
|
||||
int worldLight = WorldRenderer.getLightmapCoordinates(world, lightPos);
|
||||
|
||||
if (renderWorld != null) {
|
||||
int contraptionBlockLight = renderWorld.getLightLevel(LightType.BLOCK, pos);
|
||||
|
||||
int worldBlockLight = LightTexture.getBlockLightCoordinates(worldLight);
|
||||
|
||||
if (contraptionBlockLight > worldBlockLight) {
|
||||
worldLight = (worldLight & 0xFFFF0000) | (contraptionBlockLight << 4);
|
||||
}
|
||||
}
|
||||
|
||||
renderer.render(tileEntity, pt, ms, buffer, worldLight,
|
||||
OverlayTexture.DEFAULT_UV);
|
||||
ms.pop();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
Loading…
Reference in a new issue