mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-02-27 20:34:43 +01:00
Relit
- Actually use light volume api stuffs - Bit of a pain to try to iterate over sections based on an AABB - Still need to handle when contraptions move - Bump flywheel version
This commit is contained in:
parent
7df37f7bff
commit
a38f01fae2
3 changed files with 48 additions and 6 deletions
|
@ -23,7 +23,7 @@ use_parchment = true
|
||||||
# dependency versions
|
# dependency versions
|
||||||
registrate_version = MC1.20-1.3.3
|
registrate_version = MC1.20-1.3.3
|
||||||
flywheel_minecraft_version = 1.20.1
|
flywheel_minecraft_version = 1.20.1
|
||||||
flywheel_version = 1.0.0-alpha-59
|
flywheel_version = 1.0.0-alpha-66
|
||||||
jei_minecraft_version = 1.20.1
|
jei_minecraft_version = 1.20.1
|
||||||
jei_version = 15.2.0.22
|
jei_version = 15.2.0.22
|
||||||
curios_minecraft_version = 1.20.1
|
curios_minecraft_version = 1.20.1
|
||||||
|
|
|
@ -37,6 +37,7 @@ import com.simibubi.create.foundation.utility.worldWrappers.WrappedBlockAndTintG
|
||||||
import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld;
|
import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.SectionPos;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.level.BlockAndTintGetter;
|
import net.minecraft.world.level.BlockAndTintGetter;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
@ -65,7 +66,9 @@ public class ContraptionVisual<E extends AbstractContraptionEntity> extends Abst
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(float partialTick) {
|
public void init(float partialTick) {
|
||||||
Contraption contraption = entity.getContraption();
|
setEmbeddingMatrices(partialTick);
|
||||||
|
|
||||||
|
Contraption contraption = entity.getContraption();
|
||||||
virtualRenderWorld = ContraptionRenderDispatcher.setupRenderWorld(level, contraption);
|
virtualRenderWorld = ContraptionRenderDispatcher.setupRenderWorld(level, contraption);
|
||||||
|
|
||||||
RenderedBlocks blocks = contraption.getRenderedBlocks();
|
RenderedBlocks blocks = contraption.getRenderedBlocks();
|
||||||
|
@ -91,6 +94,8 @@ public class ContraptionVisual<E extends AbstractContraptionEntity> extends Abst
|
||||||
for (var actor : contraption.getActors()) {
|
for (var actor : contraption.getActors()) {
|
||||||
setupActor(actor, partialTick);
|
setupActor(actor, partialTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateLight();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupActor(MutablePair<StructureTemplate.StructureBlockInfo, MovementContext> actor, float partialTick) {
|
private void setupActor(MutablePair<StructureTemplate.StructureBlockInfo, MovementContext> actor, float partialTick) {
|
||||||
|
@ -163,25 +168,60 @@ public class ContraptionVisual<E extends AbstractContraptionEntity> extends Abst
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void beginFrame(VisualFrameContext context) {
|
protected void beginFrame(VisualFrameContext context) {
|
||||||
double x = Mth.lerp(context.partialTick(), entity.xOld, entity.getX());
|
var partialTick = context.partialTick();
|
||||||
double y = Mth.lerp(context.partialTick(), entity.yOld, entity.getY());
|
setEmbeddingMatrices(partialTick);
|
||||||
double z = Mth.lerp(context.partialTick(), entity.zOld, entity.getZ());
|
|
||||||
|
// TODO: re-collect light if needed
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEmbeddingMatrices(float partialTick) {
|
||||||
|
double x = Mth.lerp(partialTick, entity.xOld, entity.getX());
|
||||||
|
double y = Mth.lerp(partialTick, entity.yOld, entity.getY());
|
||||||
|
double z = Mth.lerp(partialTick, entity.zOld, entity.getZ());
|
||||||
|
|
||||||
contraptionMatrix.setIdentity();
|
contraptionMatrix.setIdentity();
|
||||||
contraptionMatrix.translate(x, y, z);
|
contraptionMatrix.translate(x, y, z);
|
||||||
entity.applyLocalTransforms(contraptionMatrix, context.partialTick());
|
entity.applyLocalTransforms(contraptionMatrix, partialTick);
|
||||||
|
|
||||||
embedding.transforms(contraptionMatrix.last().pose(), contraptionMatrix.last().normal());
|
embedding.transforms(contraptionMatrix.last().pose(), contraptionMatrix.last().normal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateLight() {
|
public void updateLight() {
|
||||||
|
// FIXME: Some blocks (e.g. large waterwheels) extend well beyond their actual block
|
||||||
|
// and might have lighting issues here
|
||||||
|
var boundingBox = entity.getBoundingBox();
|
||||||
|
|
||||||
|
int minX = Mth.floor(boundingBox.minX) - 1;
|
||||||
|
int minY = Mth.floor(boundingBox.minY) - 1;
|
||||||
|
int minZ = Mth.floor(boundingBox.minZ) - 1;
|
||||||
|
int sizeX = Mth.ceil(boundingBox.maxX) - minX + 2;
|
||||||
|
int sizeY = Mth.ceil(boundingBox.maxY) - minY + 2;
|
||||||
|
int sizeZ = Mth.ceil(boundingBox.maxZ) - minZ + 2;
|
||||||
|
|
||||||
|
embedding.collectLight(level, minX, minY, minZ, sizeX, sizeY, sizeZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collectLightSections(LongConsumer consumer) {
|
public void collectLightSections(LongConsumer consumer) {
|
||||||
var boundingBox = entity.getBoundingBox();
|
var boundingBox = entity.getBoundingBox();
|
||||||
|
|
||||||
|
int minX = Mth.floor(boundingBox.minX) - 1;
|
||||||
|
int minY = Mth.floor(boundingBox.minY) - 1;
|
||||||
|
int minZ = Mth.floor(boundingBox.minZ) - 1;
|
||||||
|
int sizeXChunks = SectionPos.blockToSectionCoord(Mth.ceil(boundingBox.maxX) - minX + 2) + 1;
|
||||||
|
int sizeYChunks = SectionPos.blockToSectionCoord(Mth.ceil(boundingBox.maxY) - minY + 2) + 1;
|
||||||
|
int sizeZChunks = SectionPos.blockToSectionCoord(Mth.ceil(boundingBox.maxZ) - minZ + 2) + 1;
|
||||||
|
|
||||||
|
var base = SectionPos.asLong(SectionPos.blockToSectionCoord(minX), SectionPos.blockToSectionCoord(minY), SectionPos.blockToSectionCoord(minZ));
|
||||||
|
|
||||||
|
for (int x = 0; x < sizeXChunks; x++) {
|
||||||
|
for (int y = 0; y < sizeYChunks; y++) {
|
||||||
|
for (int z = 0; z < sizeZChunks; z++) {
|
||||||
|
consumer.accept(SectionPos.offset(base, x, y, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -88,6 +88,8 @@ public class CarriageContraptionVisual extends ContraptionVisual<CarriageContrap
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLight() {
|
public void updateLight() {
|
||||||
|
super.updateLight();
|
||||||
|
|
||||||
if (bogeys == null)
|
if (bogeys == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue