mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-03 19:06:27 +01:00
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.List;
|
||||||
import java.util.Random;
|
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.*;
|
||||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
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,
|
protected static void renderTileEntities(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||||
IRenderTypeBuffer buffer) {
|
IRenderTypeBuffer buffer) {
|
||||||
if (FastRenderDispatcher.available()) {
|
if (FastRenderDispatcher.available()) {
|
||||||
TileEntityRenderHelper.renderTileEntities(world, c.specialRenderedTileEntities, ms, msLocal, buffer);
|
ContraptionRenderDispatcher.renderTileEntities(world, c, ms, msLocal, buffer);
|
||||||
} else {
|
} else {
|
||||||
TileEntityRenderHelper.renderTileEntities(world, c.maybeInstancedTileEntities, ms, msLocal, buffer);
|
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.Contraption;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler;
|
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler;
|
||||||
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
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.FastRenderDispatcher;
|
||||||
import com.simibubi.create.foundation.render.backend.Backend;
|
import com.simibubi.create.foundation.render.backend.Backend;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.Matrix4f;
|
import net.minecraft.client.renderer.Matrix4f;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
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) {
|
private static <C extends AbstractContraptionEntity> void updateTransform(C c, AbstractContraptionEntityRenderer<C> entityRenderer) {
|
||||||
MatrixStack stack = entityRenderer.makeTransformMatrix(c, AnimationTickHolder.getPartialTicks());
|
MatrixStack stack = entityRenderer.makeTransformMatrix(c, AnimationTickHolder.getPartialTicks());
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,7 @@ public class RenderedContraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(ContraptionProgram shader) {
|
void setup(ContraptionProgram shader) {
|
||||||
|
if (model == null) return;
|
||||||
shader.bind(model, lighter.lightVolume.getTextureVolume());
|
shader.bind(model, lighter.lightVolume.getTextureVolume());
|
||||||
lighter.lightVolume.use();
|
lighter.lightVolume.use();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,16 @@ import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
import net.minecraft.client.renderer.Matrix4f;
|
import net.minecraft.client.renderer.*;
|
||||||
import net.minecraft.client.renderer.Vector4f;
|
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.LightType;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
@ -22,6 +22,12 @@ public class TileEntityRenderHelper {
|
||||||
|
|
||||||
public static void renderTileEntities(World world, Iterable<TileEntity> customRenderTEs, MatrixStack ms,
|
public static void renderTileEntities(World world, Iterable<TileEntity> customRenderTEs, MatrixStack ms,
|
||||||
MatrixStack localTransform, IRenderTypeBuffer buffer) {
|
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();
|
float pt = AnimationTickHolder.getPartialTicks();
|
||||||
Matrix4f matrix = localTransform.peek()
|
Matrix4f matrix = localTransform.peek()
|
||||||
.getModel();
|
.getModel();
|
||||||
|
@ -45,8 +51,20 @@ public class TileEntityRenderHelper {
|
||||||
Vector4f vec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1);
|
Vector4f vec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1);
|
||||||
vec.transform(matrix);
|
vec.transform(matrix);
|
||||||
BlockPos lightPos = new BlockPos(vec.getX(), vec.getY(), vec.getZ());
|
BlockPos lightPos = new BlockPos(vec.getX(), vec.getY(), vec.getZ());
|
||||||
renderer.render(tileEntity, pt, ms, buffer, WorldRenderer.getLightmapCoordinates(world, lightPos),
|
int worldLight = WorldRenderer.getLightmapCoordinates(world, lightPos);
|
||||||
OverlayTexture.DEFAULT_UV);
|
|
||||||
|
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();
|
ms.pop();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in a new issue