Skip to content

Commit f3b1b2d

Browse files
authored
Port726 (#737)
1 parent 692177e commit f3b1b2d

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

src/main/java/com/ldtteam/structurize/client/BlueprintRenderer.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ public void updateBlueprint(final BlueprintPreviewData previewData)
105105
}
106106
}
107107

108-
private void init(final Blueprint blueprint, final Map<Object, Exception> suppressedExceptions, final BlueprintPreviewData previewData)
108+
private void init(final BlueprintPreviewData previewData, final Map<Object, Exception> suppressedExceptions)
109109
{
110+
final Blueprint blueprint = previewData.getBlueprint();
110111
final BlockRenderDispatcher blockRenderer = Minecraft.getInstance().getBlockRenderer();
111112
final RandomSource random = RandomSource.create();
112113

@@ -130,7 +131,7 @@ private void init(final Blueprint blueprint, final Map<Object, Exception> suppre
130131
final BlockPos blockPos = blockInfo.getPos();
131132
BlockState state = blockInfo.getState();
132133
// specially handle blockTagSub here cuz of block entity changes
133-
if (Structurize.getConfig().getClient().renderPlaceholdersNice.get() && state.getBlock() == ModBlocks.blockTagSubstitution.get())
134+
if (previewData.getRenderBlocksNice() && state.getBlock() == ModBlocks.blockTagSubstitution.get())
134135
{
135136
if (tileEntitiesMap.remove(blockPos) instanceof final BlockEntityTagSubstitution tagTE)
136137
{
@@ -150,7 +151,7 @@ private void init(final Blueprint blueprint, final Map<Object, Exception> suppre
150151
}
151152
else
152153
{
153-
state = blockAccess.prepareBlockStateForRendering(state, blockPos);
154+
state = blockAccess.prepareBlockStateForRendering(state, blockPos, previewData);
154155
}
155156

156157
final FluidState fluidState = state.getFluidState();
@@ -309,7 +310,7 @@ public Map<Object, Exception> drawUnsafe(final BlueprintPreviewData previewData,
309310
// init
310311
if (vertexBuffers == null)
311312
{
312-
init(previewData.getBlueprint(), suppressedExceptions, previewData);
313+
init(previewData, suppressedExceptions);
313314
}
314315

315316
profiler.popPush("struct_render_prepare");
@@ -634,11 +635,15 @@ public static void apply(final float overrideValue)
634635
}
635636

636637
float alpha = Structurize.getConfig().getClient().rendererTransparency.get().floatValue();
638+
if (overrideValue != -1)
639+
{
640+
alpha = Mth.clamp(overrideValue, 0, 1);
641+
}
642+
637643
if (alpha < 0 || alpha > THRESHOLD)
638644
{
639645
return;
640646
}
641-
alpha = overrideValue < 0 ? alpha : Mth.clamp(overrideValue, 0, 1);
642647

643648
applied = true;
644649

src/main/java/com/ldtteam/structurize/client/fakelevel/BlueprintBlockAccess.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.ldtteam.structurize.blockentities.BlockEntityTagSubstitution;
88
import com.ldtteam.structurize.blocks.ModBlocks;
99
import com.ldtteam.structurize.blueprints.v1.Blueprint;
10+
import com.ldtteam.structurize.storage.rendering.types.BlueprintPreviewData;
1011
import com.ldtteam.structurize.util.BlockUtils;
1112
import net.minecraft.client.Minecraft;
1213
import net.minecraft.core.BlockPos;
@@ -47,7 +48,12 @@ public BlockState getBlockState(final BlockPos pos)
4748

4849
public BlockState prepareBlockStateForRendering(final BlockState state, final BlockPos pos)
4950
{
50-
if (Structurize.getConfig().getClient().renderPlaceholdersNice.get())
51+
return prepareBlockStateForRendering(state, pos, null);
52+
}
53+
54+
public BlockState prepareBlockStateForRendering(final BlockState state, final BlockPos pos, final BlueprintPreviewData previewData)
55+
{
56+
if (previewData == null ? Structurize.getConfig().getClient().renderPlaceholdersNice.get() : previewData.getRenderBlocksNice())
5157
{
5258
if (state.getBlock() == ModBlocks.blockSolidSubstitution.get())
5359
{

src/main/java/com/ldtteam/structurize/storage/rendering/types/BlueprintPreviewData.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public class BlueprintPreviewData
7676
*/
7777
private BlockState solidSubstitutionOverride = null;
7878

79+
/**
80+
* Setting for whether blocks render nice or not
81+
*/
82+
private boolean renderBlocksNice = Structurize.getConfig().getClient() != null && Structurize.getConfig().getClient().renderPlaceholdersNice.get();
83+
7984
/**
8085
* Default constructor to create a new setup.
8186
*/
@@ -341,6 +346,25 @@ public boolean isServerSyncEnabled()
341346
return serverSyncEnabled;
342347
}
343348

349+
/**
350+
* Sets whether substitution blocks should render nice
351+
*
352+
* @param renderNice
353+
*/
354+
public void setRenderBlocksNice(final boolean renderNice)
355+
{
356+
renderBlocksNice = renderNice;
357+
}
358+
359+
/**
360+
* Whether substitution blocks render nice
361+
* @return
362+
*/
363+
public boolean getRenderBlocksNice()
364+
{
365+
return renderBlocksNice;
366+
}
367+
344368
/**
345369
* Overrides client config for preview transparency if already enabled, else does nothing.
346370
*

0 commit comments

Comments
 (0)