Convert to threadsafe molten metal list (#120)

* Convert to threadsafe molten metal list

* back to foreach

* wrap in sync bloc
This commit is contained in:
Caedis authored and GitHub committed 2024-07-10 14:06:07 -05:00
1 parent 4f9ba9d0b7
commit c2c2f14596
4 files changed
+47 -43

No files matched your search

@@ -59,50 +59,53 @@ public class SmelteryRender implements ISimpleBlockRenderingHandler {
float base = 0F;
int yBase = 0;
int liquidBase = 0;
for (FluidStack liquid : logic.moltenMetal) {
int liquidSize = liquid.amount;
while (liquidSize > 0) {
int cap = logic.getCapacityPerLayer();
int room = cap - liquidBase;
int countSize = Math.min(liquidSize, room);
liquidSize -= countSize;
float height = countSize > cap ? 1.0F : (float) countSize / (float) cap;
float renderBase = base;
float renderHeight = height + base;
base += height;
liquidBase += countSize;
synchronized (logic.moltenMetal) {
for (FluidStack liquid : logic.moltenMetal) {
int liquidSize = liquid.amount;
while (liquidSize > 0) {
int cap = logic.getCapacityPerLayer();
int room = cap - liquidBase;
int countSize = Math.min(liquidSize, room);
liquidSize -= countSize;
if (renderHeight < 0.01) renderHeight = 0.01f;
float height = countSize > cap ? 1.0F : (float) countSize / (float) cap;
float renderBase = base;
float renderHeight = height + base;
base += height;
liquidBase += countSize;
renderer.setRenderBounds(0, renderBase, 0, 1, renderHeight, 1);
Fluid fluid = liquid.getFluid();
for (int xi = from.x; xi <= to.x; xi++) for (int zi = from.z; zi <= to.z; zi++) {
float minX = xi == from.x ? -0.001F : 0F;
float minZ = zi == from.z ? -0.001F : 0F;
float maxX = xi == to.x ? 1.001F : 1F;
float maxZ = zi == to.z ? 1.001F : 1F;
renderer.setRenderBounds(minX, renderBase, minZ, maxX, renderHeight, maxZ);
if (fluid.canBePlacedInWorld()) BlockSkinRenderHelper
.renderMetadataBlock(fluid.getBlock(), 0, xi, from.y + yBase, zi, renderer, world);
else BlockSkinRenderHelper.renderLiquidBlock(
fluid.getStillIcon(),
fluid.getFlowingIcon(),
xi,
from.y + yBase,
zi,
renderer,
world,
false,
fluid.getColor(liquid));
if (renderHeight < 0.01) renderHeight = 0.01f;
renderer.setRenderBounds(0, renderBase, 0, 1, renderHeight, 1);
Fluid fluid = liquid.getFluid();
for (int xi = from.x; xi <= to.x; xi++) for (int zi = from.z; zi <= to.z; zi++) {
float minX = xi == from.x ? -0.001F : 0F;
float minZ = zi == from.z ? -0.001F : 0F;
float maxX = xi == to.x ? 1.001F : 1F;
float maxZ = zi == to.z ? 1.001F : 1F;
renderer.setRenderBounds(minX, renderBase, minZ, maxX, renderHeight, maxZ);
if (fluid.canBePlacedInWorld()) BlockSkinRenderHelper
.renderMetadataBlock(fluid.getBlock(), 0, xi, from.y + yBase, zi, renderer, world);
else BlockSkinRenderHelper.renderLiquidBlock(
fluid.getStillIcon(),
fluid.getFlowingIcon(),
xi,
from.y + yBase,
zi,
renderer,
world,
false,
fluid.getColor(liquid));
}
if (countSize == room) {
base = 0F;
yBase++;
liquidBase = 0;
}
ret = true;
}
if (countSize == room) {
base = 0F;
yBase++;
liquidBase = 0;
}
ret = true;
}
}
}