mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Use existing model data map when buffering contraption structure
This commit is contained in:
parent
653d17e09c
commit
4cfffe3bde
1 changed files with 4 additions and 17 deletions
|
@ -1,7 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.render;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.content.contraptions.Contraption;
|
||||
|
@ -23,11 +22,10 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
|
||||
import net.neoforged.neoforge.client.model.data.ModelData;
|
||||
import net.neoforged.neoforge.client.model.data.ModelDataManager;
|
||||
|
||||
public class ContraptionRenderInfo {
|
||||
public static final SuperByteBufferCache.Compartment<Pair<Contraption, RenderType>> CONTRAPTION = new SuperByteBufferCache.Compartment<>();
|
||||
|
@ -89,7 +87,6 @@ public class ContraptionRenderInfo {
|
|||
int minBuildHeight = contraptionWorld.getMinBuildHeight();
|
||||
int height = contraptionWorld.getHeight();
|
||||
VirtualRenderWorld renderWorld = new VirtualRenderWorld(level, minBuildHeight, height, origin) {
|
||||
|
||||
@Override
|
||||
public boolean supportsVisualization() {
|
||||
return VisualizationManager.supportsVisualization(level);
|
||||
|
@ -97,17 +94,8 @@ public class ContraptionRenderInfo {
|
|||
|
||||
@Override
|
||||
public ModelData getModelData(BlockPos pos) {
|
||||
BlockEntity blockEntity = getBlockEntity(pos);
|
||||
if (blockEntity == null)
|
||||
return super.getModelData(pos);
|
||||
return blockEntity.getModelData();
|
||||
return c.modelData.getOrDefault(pos, ModelData.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ModelDataManager getModelDataManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
renderWorld.setBlockEntities(c.presentBlockEntities.values());
|
||||
|
@ -136,8 +124,7 @@ public class ContraptionRenderInfo {
|
|||
BlockState state = blocks.lookup().apply(pos);
|
||||
if (state.getRenderShape() == RenderShape.MODEL) {
|
||||
BakedModel model = dispatcher.getBlockModel(state);
|
||||
ModelData modelData = contraption.modelData.getOrDefault(pos, ModelData.EMPTY);
|
||||
modelData = model.getModelData(renderWorld, pos, state, modelData);
|
||||
ModelData modelData = model.getModelData(renderWorld, pos, state, renderWorld.getModelData(pos));
|
||||
long randomSeed = state.getSeed(pos);
|
||||
random.setSeed(randomSeed);
|
||||
if (model.getRenderTypes(state, random, modelData).contains(layer)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue