hopefully last fix for fluid rendering and handling, as well as saving for tank block and fossil cleaner block. need to confirm fabric tho

This commit is contained in:
2026-05-03 12:32:29 -04:00
parent 3a7aba5fb8
commit 2e5d3f9a94
3 changed files with 27 additions and 15 deletions
@@ -154,11 +154,8 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen
tag.putInt("Prog", this.progress);
tag.putInt("MaxProg", this.maxProgress);
tag.put("Energy", energyStorage.saveNBT());
tag.remove("Fluid");
if (!fluidStack.isEmpty()) {
CompoundTag fluidTag = new CompoundTag();
fluidStack.write(registries, fluidTag);
tag.put("Fluid", fluidTag);
tag.put("Fluid", fluidStack.write(registries, new CompoundTag()));
}
}
@@ -270,11 +270,8 @@ public class TankBlockEntity extends BlockEntity implements ExtendedMenuProvider
protected void saveAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) {
super.saveAdditional(pTag, pRegistries);
pTag.put("Inventory", itemHandler.createTag(pRegistries));
pTag.remove("Fluid");
if (!fluidStack.isEmpty()) {
CompoundTag fluidTag = new CompoundTag();
fluidStack.write(pRegistries, fluidTag);
pTag.put("Fluid", fluidTag);
pTag.put("Fluid", fluidStack.write(pRegistries, new CompoundTag()));
}
}
@@ -65,14 +65,14 @@ public class TankBlockEntityRenderer implements BlockEntityRenderer<TankBlockEnt
float yTop = MIN_Y + fluidHeight;
// UV coordinates mapping
float uMin = sprite.getU(MIN_X * 16);
float uMax = sprite.getU(MAX_X * 16);
float vMinZ = sprite.getV(MIN_Z * 16);
float vMaxZ = sprite.getV(MAX_Z * 16);
float uMin = spriteU(sprite, MIN_X);
float uMax = spriteU(sprite, MAX_X);
float vMinZ = spriteV(sprite, MIN_Z);
float vMaxZ = spriteV(sprite, MAX_Z);
// V coords for sides
float vTop = sprite.getV((1 - yTop) * 16);
float vBottom = sprite.getV((1 - MIN_Y) * 16);
float vTop = spriteV(sprite, 1 - yTop);
float vBottom = spriteV(sprite, 1 - MIN_Y);
// Top Face (visible from above)
// Normal +Y
@@ -139,6 +139,24 @@ public class TankBlockEntityRenderer implements BlockEntityRenderer<TankBlockEnt
return sprite == null || sprite.atlasLocation().getPath().contains("missingno");
}
//? if >1.20.1 {
/*private static float spriteU(TextureAtlasSprite sprite, float normalizedU) {
return sprite.getU0() + (sprite.getU1() - sprite.getU0()) * normalizedU;
}
private static float spriteV(TextureAtlasSprite sprite, float normalizedV) {
return sprite.getV0() + (sprite.getV1() - sprite.getV0()) * normalizedV;
}
*///?} else {
private static float spriteU(TextureAtlasSprite sprite, float normalizedU) {
return sprite.getU(normalizedU * 16);
}
private static float spriteV(TextureAtlasSprite sprite, float normalizedV) {
return sprite.getV(normalizedV * 16);
}
//?}
private static void addQuad(VertexConsumer builder, PoseStack poseStack,
float x0, float y0, float z0, float u0, float v0,
float x1, float y1, float z1, float u1, float v1,