Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ private void init(final BlueprintPreviewData previewData, final Map<Object, Exce

blockAccess.setBlockEntities(tileEntitiesMap);
blockAccess.setEntities(entities);
blockAccess.setSolidSubstitutionOverride(previewData.getSolidSubstitutionOverride());

final PoseStack matrixStack = new PoseStack();
matrixStack.translate(0.01, 0.01, 0.01);
Expand Down Expand Up @@ -197,6 +198,8 @@ private void init(final BlueprintPreviewData previewData, final Map<Object, Exce
}
}

blockAccess.setSolidSubstitutionOverride(null);

vertexBuffers = blockVertexBuffersFactory.get();
for (final RenderType renderType : blockRenderTypes)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public class BlueprintBlockAccess extends FakeLevel
public static final IFakeLevelLightProvider LIGHT_PROVIDER = new ConfigBasedLightProvider(Structurize.getConfig().getClient().rendererLightLevel);
private static final Scoreboard SCOREBOARD = new Scoreboard();

/**
* Override blockstate for solid placeholders
*/
private BlockState solidSubstitutionOverride = null;

public BlueprintBlockAccess(final Blueprint blueprint)
{
super(blueprint, LIGHT_PROVIDER, SCOREBOARD, true);
Expand Down Expand Up @@ -50,6 +55,10 @@ public BlockState prepareBlockStateForRendering(final BlockState state, final Bl
{
if (state.getBlock() == ModBlocks.blockSolidSubstitution.get())
{
if (solidSubstitutionOverride != null)
{
return solidSubstitutionOverride;
}
return BlockUtils.getSubstitutionBlockAtWorld(anyLevel(), worldPos.offset(pos), levelSource.getRawBlockStateFunction().compose(b -> b.subtract(worldPos)));
}
else if (state.getBlock() == ModBlocks.blockFluidSubstitution.get())
Expand All @@ -72,4 +81,14 @@ else if (state.getBlock() == ModBlocks.blockTagSubstitution.get())

return state;
}

/**
* Set the solid placeholder blockstate override, only updates when the renderer is recalculated
*
* @return
*/
public void setSolidSubstitutionOverride(final BlockState solidSubstitutionOverride)
{
this.solidSubstitutionOverride = solidSubstitutionOverride;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.util.Mth;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -77,6 +78,11 @@ public class BlueprintPreviewData
*/
private boolean renderBlocksNice = Structurize.getConfig().getClient() != null && Structurize.getConfig().getClient().renderPlaceholdersNice.get();

/**
* Override blockstate for solid placeholders
*/
private BlockState solidSubstitutionOverride = null;

/**
* Default constructor to create a new setup.
*/
Expand Down Expand Up @@ -429,4 +435,24 @@ public float getOverridePreviewTransparency()
{
return overridePreviewTransparency;
}

/**
* Get the solid placeholder blockstate override
*
* @return
*/
public BlockState getSolidSubstitutionOverride()
{
return solidSubstitutionOverride;
}

/**
* Set the solid placeholder blockstate override, only updates when the renderer is recalculated
*
* @return
*/
public void setSolidSubstitutionOverride(final BlockState solidSubstitutionOverride)
{
this.solidSubstitutionOverride = solidSubstitutionOverride;
}
}