Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3640e52
Implemented CentrifugalConcentrator FluidRendering
BastianBoB Aug 14, 2025
c79a2ad
Implemented CentrifugalConcentrator FluidRendering
BastianBoB Aug 14, 2025
6d11ea1
CentrifugalConcentrator FluidRendering
BastianBoB Aug 14, 2025
7ada8e6
Merge remote-tracking branch 'origin/main' into main
BastianBoB Aug 14, 2025
79599d5
Merge branch 'main' into main
DaRealTurtyWurty Aug 14, 2025
34d52a8
Implemented RotaryKiln Animation
BastianBoB Aug 15, 2025
9915cc2
Merge remote-tracking branch 'origin/main' into main
BastianBoB Aug 15, 2025
e3e7c88
Merge fix idfk
BastianBoB Aug 15, 2025
14a6c4d
Removed BastiUtil
BastianBoB Aug 15, 2025
a4fe05d
Apply suggestion from @Copilot
DaRealTurtyWurty Aug 15, 2025
4a2cd4d
Update build.gradle
DaRealTurtyWurty Aug 15, 2025
5341465
Update src/client/java/dev/turtywurty/industria/renderer/block/Indust…
DaRealTurtyWurty Aug 15, 2025
9e06aa6
Removed unused import
DaRealTurtyWurty Aug 15, 2025
b8a512f
Fix possible IllegalArgumentException
DaRealTurtyWurty Aug 15, 2025
a1c22b2
Fix copilot error and clean-up whitespace
DaRealTurtyWurty Aug 15, 2025
96f57b5
Add some constants
DaRealTurtyWurty Aug 15, 2025
5c37d89
Update src/client/java/dev/turtywurty/industria/renderer/block/Rotary…
DaRealTurtyWurty Aug 15, 2025
d8e4f3b
Update src/client/java/dev/turtywurty/industria/renderer/block/Rotary…
DaRealTurtyWurty Aug 15, 2025
fad9acc
ShakingTable fixed water volume
BastianBoB Aug 16, 2025
e205915
Merge remote-tracking branch 'origin/main' into main
BastianBoB Aug 16, 2025
c8b3d7b
Merge branch 'main' into main
DaRealTurtyWurty Aug 17, 2025
8eded9c
Merge remote-tracking branch 'upstream/main' into main
BastianBoB Aug 17, 2025
a1061f6
Merge remote-tracking branch 'origin/main' into main
BastianBoB Aug 17, 2025
67d07e8
Merge remote-tracking branch 'upstream/main' into main
BastianBoB Aug 17, 2025
5fd6166
Added particles to RotaryKiln
BastianBoB Aug 17, 2025
d3fc8c0
removed debug println
BastianBoB Aug 17, 2025
35c0a6e
Reworked Fluid rendering to use 1 function for all directions
BastianBoB Aug 18, 2025
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 @@ -10,6 +10,11 @@ public ArcFurnaceBlockEntityRenderer(BlockEntityRendererFactory.Context context)
super(context);
}

@Override
protected void renderModel(ArcFurnaceBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {

}
Comment on lines +13 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Empty renderModel causes the Arc Furnace to render nothing.

With the base class now rendering via renderModel(...), leaving this method empty results in no visual output for the block entity (and likely its item form, once renderForItem is fixed).

Port the previous model draw into renderModel(...). If you need a temporary stopgap while migrating, delegate to onRender(...) (assuming it still contains the prior rendering code), e.g.:

 @Override
 protected void renderModel(ArcFurnaceBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
- 
+    // TEMP: delegate to onRender until the model is fully migrated here
+    onRender(entity, tickDelta, matrices, vertexConsumers, light, overlay);
 }

However, since onRender(...) is also empty here, the real fix is to move the actual model rendering code into this method (similar to Electrolyzer/Digester).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Override
protected void renderModel(ArcFurnaceBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
}
@Override
protected void renderModel(ArcFurnaceBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
// TEMP: delegate to onRender until the model is fully migrated here
onRender(entity, tickDelta, matrices, vertexConsumers, light, overlay);
}
🤖 Prompt for AI Agents
In
src/client/java/dev/turtywurty/industria/renderer/block/ArcFurnaceBlockEntityRenderer.java
around lines 13–16, renderModel(...) is empty which prevents the Arc Furnace
from being drawn; port the previous model-draw code into this method (or, as a
temporary measure, call the old onRender(...) implementation if it still
contains the drawing logic) making sure to perform the same matrix push/pop,
translations/rotations, and use the provided VertexConsumerProvider, light and
overlay parameters so the model renders correctly for both block entity and item
contexts.


@Override
protected void onRender(ArcFurnaceBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package dev.turtywurty.industria.renderer.block;

import com.mojang.blaze3d.vertex.VertexFormat;
import dev.turtywurty.industria.blockentity.CentrifugalConcentratorBlockEntity;
import dev.turtywurty.industria.blockentity.util.fluid.SyncingFluidStorage;
import dev.turtywurty.industria.model.CentrifugalConcentratorModel;
import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.*;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.texture.Sprite;
Expand All @@ -17,16 +13,9 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.TriState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.util.math.Vec3d;
import org.jbox2d.common.Vec3;
import org.joml.Matrix4f;
import org.joml.Vector3d;
import org.joml.Vector3f;
import org.joml.Vector4f;

// TODO: Finish OBJLoader and use that for rendering
public class CentrifugalConcentratorBlockEntityRenderer extends IndustriaBlockEntityRenderer<CentrifugalConcentratorBlockEntity> {
Expand All @@ -40,7 +29,7 @@ public CentrifugalConcentratorBlockEntityRenderer(BlockEntityRendererFactory.Con
}

@Override
protected void onRender(CentrifugalConcentratorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
protected void renderModel(CentrifugalConcentratorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
this.model.getCylinderTop().hidden = true;

int rpm = entity.getRecipeRPM();
Expand All @@ -57,85 +46,86 @@ protected void onRender(CentrifugalConcentratorBlockEntity entity, float tickDel
this.model.getBowl().yaw = prevBowlYRot;

this.model.getCylinderTop().hidden = false;
}

@Override
protected void onRender(CentrifugalConcentratorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {

float fluidYOffset = renderInputFluid(entity, tickDelta, matrices, vertexConsumers, light, overlay);

renderInputFluid(entity, tickDelta, matrices, vertexConsumers, light, overlay);
matrices.push();
matrices.translate(0, fluidYOffset, 0);
renderInputItems(entity, tickDelta, matrices, vertexConsumers, light, overlay);
matrices.pop();
}

private void renderInputFluid(CentrifugalConcentratorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
SyncingFluidStorage fluidTank = entity.getInputFluidTank();
if (fluidTank.isResourceBlank() || fluidTank.amount <= 0) return;
private void renderInputItems(CentrifugalConcentratorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
ItemStack stackInSlot = Items.DIAMOND.getDefaultStack(); //entity.getInputInventory().getStackInSlot(0);
if(stackInSlot.isEmpty()) return;

float radius = 1.1f;

for (int i = 0; i < NUM_SPINNING_ITEMS; i++) {
float angle = -entity.bowlRotation + (float) Math.TAU / NUM_SPINNING_ITEMS * i;

float x = (float) Math.cos(angle) * radius;
float y = (float) Math.sin(angle * 3) * 0.02f - 0.2f;
float z = (float) Math.sin(angle) * radius;

matrices.push();
matrices.translate(x, y, z);
matrices.multiply(RotationAxis.POSITIVE_Y.rotation(angle + (float) Math.PI / 2f));
matrices.scale(0.5f, 0.5f, 0.5f);
this.context.getItemRenderer().renderItem(stackInSlot, ItemDisplayContext.NONE, light, overlay, matrices, vertexConsumers, entity.getWorld(), 0);

Vector3f pos = matrixStackToWorldPosition(matrices);
entity.getWorld().addParticleClient(ParticleTypes.BUBBLE, pos.x, pos.y + 0.3f, pos.z, 0, 0, 0);

matrices.pop();
}
}
Comment on lines +62 to +86
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Remove debug item and throttle particles to avoid permanent diamonds and heavy client load.

  • Items.DIAMOND.getDefaultStack() forces diamonds to render always; use the actual inventory stack.
  • Spawning bubbles every frame per item is expensive. Add a light throttle.
  • Guard against null world.
-        ItemStack stackInSlot = Items.DIAMOND.getDefaultStack(); //entity.getInputInventory().getStackInSlot(0);
+        if (entity.getWorld() == null) return;
+        ItemStack stackInSlot = entity.getInputInventory().getStackInSlot(0);
         if(stackInSlot.isEmpty()) return;
@@
-            Vector3f pos = matrixStackToWorldPosition(matrices);
-            entity.getWorld().addParticleClient(ParticleTypes.BUBBLE, pos.x, pos.y + 0.3f, pos.z, 0, 0, 0);
+            // Light throttle: 1 particle per item every 4 ticks, staggered by index
+            long time = entity.getWorld().getTime();
+            if (((time + i) & 3) == 0) {
+                Vector3f pos = matrixStackToWorldPosition(matrices);
+                entity.getWorld().addParticleClient(ParticleTypes.BUBBLE, pos.x, pos.y + 0.3f, pos.z, 0, 0, 0);
+            }

🏁 Script executed:

#!/bin/bash
# Verify the availability of getInputInventory and inputInventory fields/methods in the codebase
rg -n "getInputInventory" -C3
rg -n "inputInventory" -C3

Length of output: 44259


Remove debug diamond, use real input stack, throttle particles, and guard null world

Please update src/client/java/dev/turtywurty/industria/renderer/block/CentrifugalConcentratorBlockEntityRenderer.java as follows:

• At the top of renderInputItems(...), bail out if entity.getWorld() is null and grab the real stack:

-   ItemStack stackInSlot = Items.DIAMOND.getDefaultStack(); //entity.getInputInventory().getStackInSlot(0);
+   if (entity.getWorld() == null) return;
+   ItemStack stackInSlot = entity.getInputInventory().getStackInSlot(0);
    if (stackInSlot.isEmpty()) return;

• Around the bubble spawn, throttle to once per item every 4 ticks:

-           Vector3f pos = matrixStackToWorldPosition(matrices);
-           entity.getWorld().addParticleClient(ParticleTypes.BUBBLE,
-               pos.x, pos.y + 0.3f, pos.z,
-               0, 0, 0);
+           long time = entity.getWorld().getTime();
+           if (((time + i) & 3) == 0) {  // ¼ frequency, staggered by index
+               Vector3f pos = matrixStackToWorldPosition(matrices);
+               entity.getWorld().addParticleClient(ParticleTypes.BUBBLE,
+                   pos.x, pos.y + 0.3f, pos.z,
+                   0, 0, 0);
+           }

– Lines to update:
• 63–65: Replace debug DIAMOND stack & add null‐world guard
• 74–80: Wrap addParticleClient in time‐based throttle

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private void renderInputItems(CentrifugalConcentratorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
ItemStack stackInSlot = Items.DIAMOND.getDefaultStack(); //entity.getInputInventory().getStackInSlot(0);
if(stackInSlot.isEmpty()) return;
float radius = 1.1f;
for (int i = 0; i < NUM_SPINNING_ITEMS; i++) {
float angle = -entity.bowlRotation + (float) Math.TAU / NUM_SPINNING_ITEMS * i;
float x = (float) Math.cos(angle) * radius;
float y = (float) Math.sin(angle * 3) * 0.02f - 0.2f;
float z = (float) Math.sin(angle) * radius;
matrices.push();
matrices.translate(x, y, z);
matrices.multiply(RotationAxis.POSITIVE_Y.rotation(angle + (float) Math.PI / 2f));
matrices.scale(0.5f, 0.5f, 0.5f);
this.context.getItemRenderer().renderItem(stackInSlot, ItemDisplayContext.NONE, light, overlay, matrices, vertexConsumers, entity.getWorld(), 0);
Vector3f pos = matrixStackToWorldPosition(matrices);
entity.getWorld().addParticleClient(ParticleTypes.BUBBLE, pos.x, pos.y + 0.3f, pos.z, 0, 0, 0);
matrices.pop();
}
}
private void renderInputItems(CentrifugalConcentratorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
if (entity.getWorld() == null) return;
ItemStack stackInSlot = entity.getInputInventory().getStackInSlot(0);
if (stackInSlot.isEmpty()) return;
float radius = 1.1f;
for (int i = 0; i < NUM_SPINNING_ITEMS; i++) {
float angle = -entity.bowlRotation + (float) Math.TAU / NUM_SPINNING_ITEMS * i;
float x = (float) Math.cos(angle) * radius;
float y = (float) Math.sin(angle * 3) * 0.02f - 0.2f;
float z = (float) Math.sin(angle) * radius;
matrices.push();
matrices.translate(x, y, z);
matrices.multiply(RotationAxis.POSITIVE_Y.rotation(angle + (float) Math.PI / 2f));
matrices.scale(0.5f, 0.5f, 0.5f);
this.context.getItemRenderer().renderItem(stackInSlot, ItemDisplayContext.NONE, light, overlay, matrices, vertexConsumers, entity.getWorld(), 0);
long time = entity.getWorld().getTime();
if (((time + i) & 3) == 0) { // ¼ frequency, staggered by index
Vector3f pos = matrixStackToWorldPosition(matrices);
entity.getWorld().addParticleClient(ParticleTypes.BUBBLE,
pos.x, pos.y + 0.3f, pos.z,
0, 0, 0);
}
matrices.pop();
}
}



private float renderInputFluid(CentrifugalConcentratorBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
SyncingFluidStorage fluidTank = entity.getInputFluidTank();
if (fluidTank.isResourceBlank() || fluidTank.amount <= 0) return 0;

FluidVariant fluidVariant = fluidTank.variant;
Sprite fluidSprite = FluidVariantRendering.getSprite(fluidVariant);
if (fluidSprite == null)
return;
if (fluidSprite == null) return 0;

RenderLayer renderLayer = RenderLayer.getItemEntityTranslucentCull(fluidSprite.getAtlasId());
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(renderLayer);

int sides = 16;
float outerRadius = 19 / 16f;
float innerRadius = 4 / 16f;
int fluidColor = FluidVariantRendering.getColor(fluidVariant, entity.getWorld(), entity.getPos());

float fillPercent = fluidTank.amount / (float) fluidTank.getCapacity();

// fillPercent = (float) (Math.sin(entity.getWorld().getTime() / entity.getWorld().getTickManager().getTickRate()) * 0.5f + 0.5f);
int sides = 16;
float outerRadius = 19 / 16f;
float innerRadius = fillPercent <= 7 / 16f ? 0 : 4 / 16f;

if (fillPercent <= 7 / 16f) {
innerRadius = 0;
}
int fluidColor = FluidVariantRendering.getColor(fluidVariant, entity.getWorld(), entity.getPos());

float yMin = 1 / 16f;
float yMax = 18 / 16f;
float yOffset = MathHelper.lerp(fillPercent, yMin, yMax);

matrices.push();
matrices.translate(0, -yOffset, 0);
matrices.translate(0, yOffset, 0);

float angleOffset = (float) Math.PI / sides;
for (int i = 0; i < sides; i += 1) {
float angle0 = angleOffset + (float) (2.0 * Math.PI * i / sides);
float angle1 = angleOffset + (float) (2.0 * Math.PI * (i + 1) / sides);
float angle0 = angleOffset - (float) (2.0 * Math.PI * i / sides);
float angle1 = angleOffset - (float) (2.0 * Math.PI * (i + 1) / sides);

angledFluidVertex(vertexConsumer, matrices, fluidSprite, fluidColor, angle0, innerRadius, outerRadius, light, overlay);
angledFluidVertex(vertexConsumer, matrices, fluidSprite, fluidColor, angle0, outerRadius, outerRadius, light, overlay);
angledFluidVertex(vertexConsumer, matrices, fluidSprite, fluidColor, angle1, outerRadius, outerRadius, light, overlay);
angledFluidVertex(vertexConsumer, matrices, fluidSprite, fluidColor, angle1, innerRadius, outerRadius, light, overlay);
}

ItemStack stackInSlot = Items.DIAMOND.getDefaultStack(); //entity.getInputInventory().getStackInSlot(0);
float radius = 1.1f;

for (int i = 0; i < NUM_SPINNING_ITEMS; i++) {
float angle = -entity.bowlRotation + (float) Math.TAU / NUM_SPINNING_ITEMS * i;

float x = (float) Math.cos(angle) * radius;
float y = (float) Math.sin(angle * 3) * 0.02f + 0.225f;
float z = (float) Math.sin(angle) * radius;

matrices.push();
matrices.translate(x, y, z);
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180));
matrices.multiply(RotationAxis.POSITIVE_Y.rotation(angle + (float) Math.PI / 2f));
matrices.scale(0.5f, 0.5f, 0.5f);
this.context.getItemRenderer().renderItem(stackInSlot, ItemDisplayContext.NONE, light, overlay, matrices, vertexConsumers, entity.getWorld(), 0);


Vector3f pos = localToWorldPosition(matrices);
entity.getWorld().addParticleClient(ParticleTypes.BUBBLE, pos.x, pos.y + 0.25, pos.z, 0, 0, 0);

matrices.pop();
}

matrices.pop();
}

private Vector3f localToWorldPosition(MatrixStack matrices) {
Vector3f pos = matrices.peek().getPositionMatrix().transformPosition(0, 0, 0, new Vector3f());
Vec3d cameraPos = MinecraftClient.getInstance().gameRenderer.getCamera().getPos();

return new Vector3f((float) (pos.x() + cameraPos.x), (float) (pos.y() + cameraPos.y), (float) (pos.z() + cameraPos.z));
return yOffset;
}

private void angledFluidVertex(VertexConsumer vc, MatrixStack matrixStack, Sprite sprite, int fluidColor, float angle, float radius, float uvSize, int light, int overlay) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemDisplayContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.util.math.Vec3d;

public class ClarifierBlockEntityRenderer extends IndustriaBlockEntityRenderer<ClarifierBlockEntity> {

private final ClarifierModel model;
private final InWorldFluidRenderingComponent fluidRenderer = new InWorldFluidRenderingComponent();

Expand Down Expand Up @@ -50,11 +53,13 @@ public ClarifierBlockEntityRenderer(BlockEntityRendererFactory.Context context)
}

@Override
protected void onRender(ClarifierBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
protected void renderModel(ClarifierBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
this.model.getRootPart().render(matrices, vertexConsumers.getBuffer(this.model.getLayer(ClarifierModel.TEXTURE_LOCATION)), light, overlay);
}

if (entity.getWorld() == null)
return;
@Override
protected void onRender(ClarifierBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
if (entity.getWorld() == null) return;

renderInputFluid(entity, matrices, vertexConsumers, light, overlay);
renderOutputFluid(entity, matrices, vertexConsumers, light, overlay);
Expand All @@ -64,20 +69,21 @@ protected void onRender(ClarifierBlockEntity entity, float tickDelta, MatrixStac
}

private void renderOutputStack(ClarifierBlockEntity entity, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
ItemStack outputStack = entity.getOutputInventory().getStack(0);
ItemStack outputStack = new ItemStack(Items.DIAMOND_BLOCK, 64); // Items.DIAMOND.getDefaultStack(); //entity.getOutputInventory().getStack(0);
if (outputStack.isEmpty())
return;

float scale = 0.05f;
float zOffset = 11f / 16f + 10f / 16f + 2f / 16f;
float startY = 0.75f - scale / 2 + 9f / 16f;
float zOffset = -(11f / 16f + 10f / 16f + 2f / 16f);
float startY = -1.1f + scale / 2;

for (int i = 0; i < MathHelper.clamp(outputStack.getCount(), 1, 64); i++) {
matrices.push();

GridPosition position = OUTPUT_ITEM_POSITIONS[i];
float xOff = position.x * (scale + (0.0625f * scale)) - 0.345f;
float yOff = position.y * (scale + (0.0625f * scale));

matrices.translate(xOff, startY - yOff, zOffset);
matrices.scale(scale, scale, scale);
this.context.getItemRenderer().renderItem(outputStack, ItemDisplayContext.NONE, light, overlay, matrices, vertexConsumers, entity.getWorld(), 0);
Expand All @@ -87,12 +93,12 @@ private void renderOutputStack(ClarifierBlockEntity entity, MatrixStack matrices

// Thanks to Basti for the item rendering math
private void renderCurrentOutputItem(ClarifierBlockEntity blockEntity, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
ItemStack nextOutput = blockEntity.getNextOutputItemStack();
ItemStack nextOutput = Items.DIAMOND_BLOCK.getDefaultStack(); //blockEntity.getNextOutputItemStack();

if (nextOutput.isEmpty())
return;

float itemProgress = (float) blockEntity.getProgress() / blockEntity.getMaxProgress();
float itemProgress = (blockEntity.getWorld().getTime() / 100f) % 1; // (float) blockEntity.getProgress() / blockEntity.getMaxProgress();

float scale = 0.15f;
float firstStretch = 11f / 16f;
Expand Down Expand Up @@ -123,66 +129,68 @@ private void renderCurrentOutputItem(ClarifierBlockEntity blockEntity, MatrixSta
}

matrices.push();
matrices.translate(0, 0.75 - scale / 2 - dy, 0 + dz);
matrices.translate(0, -0.75 + scale / 2 + dy, -dz);
matrices.scale(scale, scale, scale);
matrices.multiply(RotationAxis.POSITIVE_X.rotation(rotation));
this.context.getItemRenderer().renderItem(nextOutput, ItemDisplayContext.NONE, light, overlay, matrices, vertexConsumers, blockEntity.getWorld(), 0);
matrices.pop();
}

private void renderInputFluid(ClarifierBlockEntity entity, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
SyncingFluidStorage fluidStorage = entity.getInputFluidTank();
if (fluidStorage == null || fluidStorage.isResourceBlank() || fluidStorage.amount <= 0)
return;
// SyncingFluidStorage fluidStorage = entity.getInputFluidTank();
// if (fluidStorage == null || fluidStorage.isResourceBlank() || fluidStorage.amount <= 0)
// return;

FluidVariant fluidVariant = fluidStorage.getResource();
FluidVariant fluidVariant = FluidVariant.of(Fluids.WATER); // fluidStorage.getResource();

long amount = fluidStorage.amount;
long amount = 10000; //fluidStorage.amount;
float fluidProgress = (float) amount / (FluidConstants.BUCKET * 5);
// fluidProgress = (float) (Math.sin(entity.getWorld().getTime() / 64.0) * 0.5 + 0.5);
float fluidHeight = -0.625f + (fluidProgress * 1 + 1.999f/16f);
fluidProgress = (float) (Math.sin(entity.getWorld().getTime() / 64.0) * 0.5 + 0.5);

float fluidHeight = 0.625f - (fluidProgress * 1 + 1.999f / 16f);

float size = 1.25f;
if (fluidHeight < 0f)
if (fluidHeight > 0f)
size = 0.5f;

this.fluidRenderer.renderTopFaceOnly(fluidVariant,
vertexConsumers, matrices,
light, overlay,
entity.getWorld(), entity.getPos(),
-size, fluidHeight, -size,
size, size);
// this.fluidRenderer.renderTopFaceOnly(fluidVariant,
// vertexConsumers, matrices,
// light, overlay,
// entity.getWorld(), entity.getPos(),
// -size, fluidHeight, -size,
// size, size);
}

private void renderOutputFluid(ClarifierBlockEntity entity, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
SyncingFluidStorage fluidStorage = entity.getOutputFluidTank();
if (fluidStorage == null || fluidStorage.isResourceBlank() || fluidStorage.amount <= 0)
return;

FluidVariant fluidVariant = fluidStorage.getResource();

long amount = fluidStorage.amount;
float fluidProgress = (float) amount / (FluidConstants.BUCKET * 5);
// fluidProgress = (float) (Math.sin(entity.getWorld().getTime() / 64.0) * 0.5 + 0.5);
float fluidHeight = -1.375f + (fluidProgress * 0.5f);
// SyncingFluidStorage fluidStorage = entity.getOutputFluidTank();
// if (fluidStorage == null || fluidStorage.isResourceBlank() || fluidStorage.amount <= 0)
// return;
//
// FluidVariant fluidVariant = fluidStorage.getResource();
//
// long amount = fluidStorage.amount;

this.fluidRenderer.renderTopFaceOnly(fluidVariant,
vertexConsumers, matrices,
light, overlay,
entity.getWorld(), entity.getPos(),
-0.375f, fluidHeight, -0.5f,
0.375f, 1.4375f);

matrices.push();
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180));
this.fluidRenderer.drawTiledXYQuadOnly(fluidVariant,
vertexConsumers, matrices,
light, overlay,
entity.getWorld(), entity.getPos(),
-0.375f, -1.375f, -1.4375f,
0.375f, fluidHeight, -1.4375f);
FluidVariant fluidVariant = FluidVariant.of(Fluids.WATER);
long amount = 10000;

matrices.pop();
float fluidProgress = (float) amount / (FluidConstants.BUCKET * 5);
fluidProgress = (float) (Math.sin(entity.getWorld().getTime() / 64.0) * 0.5 + 0.5);
float fluidHeight = 1.375f - (fluidProgress * 0.5f);

// this.fluidRenderer.renderTopFaceOnly(fluidVariant,
// vertexConsumers, matrices,
// light, overlay,
// entity.getWorld(), entity.getPos(),
// 0.375f, fluidHeight, 0.5f,
// -0.375f, -1.4375f);
//
// this.fluidRenderer.drawTiledXYQuadOnly(fluidVariant,
// vertexConsumers, matrices,
// light, overlay,
// entity.getWorld(), entity.getPos(),
// -0.375f, 1.375f, -1.4375f,
// 0.375f, fluidHeight, -1.4375f);
}

private record GridPosition(int x, int y) {
Expand Down
Loading