steps towards fixing fluid rendering and handling on 1.21.1
This commit is contained in:
+13
-1
@@ -154,10 +154,13 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
@@ -166,7 +169,16 @@ public class FossilCleanerBlockEntity extends BlockEntity implements ExtendedMen
|
||||
progress = tag.getInt("Prog");
|
||||
maxProgress = tag.getInt("MaxProg");
|
||||
if (tag.contains("Energy")) energyStorage.loadNBT(tag.getCompound("Energy"));
|
||||
if (tag.contains("Fluid")) fluidStack = FluidStack.read(registries, tag.getCompound("Fluid")).orElse(FluidStack.empty());
|
||||
if (tag.contains("Fluid", 10)) {
|
||||
CompoundTag fluidTag = tag.getCompound("Fluid");
|
||||
if (fluidTag.contains("id") && fluidTag.contains("amount")) {
|
||||
fluidStack = FluidStack.read(registries, fluidTag).orElse(FluidStack.empty());
|
||||
} else {
|
||||
fluidStack = FluidStack.empty();
|
||||
}
|
||||
} else {
|
||||
fluidStack = FluidStack.empty();
|
||||
}
|
||||
}
|
||||
*///?} else {
|
||||
@Override
|
||||
|
||||
+11
-3
@@ -270,17 +270,25 @@ 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(fluidTag, pRegistries);
|
||||
fluidStack.write(pRegistries, fluidTag);
|
||||
pTag.put("Fluid", fluidTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) {
|
||||
super.loadAdditional(pTag, pRegistries);
|
||||
itemHandler.fromTag(pTag.getList("Inventory", 10), pRegistries);
|
||||
if (pTag.contains("Fluid")) {
|
||||
this.fluidStack = FluidStack.read(pTag.getCompound("Fluid"), pRegistries);
|
||||
if (pTag.contains("Fluid", 10)) {
|
||||
CompoundTag fluidTag = pTag.getCompound("Fluid");
|
||||
if (fluidTag.contains("id") && fluidTag.contains("amount")) {
|
||||
this.fluidStack = FluidStack.read(pRegistries, fluidTag).orElse(FluidStack.empty());
|
||||
} else {
|
||||
this.fluidStack = FluidStack.empty();
|
||||
}
|
||||
} else {
|
||||
this.fluidStack = FluidStack.empty();
|
||||
}
|
||||
|
||||
+10
-1
@@ -153,8 +153,17 @@ public class TankBlockEntityRenderer implements BlockEntityRenderer<TankBlockEnt
|
||||
|
||||
//? if >1.20.1 {
|
||||
/*private static void drawVertex(VertexConsumer builder, PoseStack poseStack, float x, float y, float z, float u, float v, int packedLight, int color) {
|
||||
int a = (color >> 24) & 0xFF;
|
||||
int r = (color >> 16) & 0xFF;
|
||||
int g = (color >> 8) & 0xFF;
|
||||
int b = color & 0xFF;
|
||||
|
||||
if (a == 0) {
|
||||
a = 255;
|
||||
}
|
||||
|
||||
builder.addVertex(poseStack.last().pose(), x, y, z)
|
||||
.setColor(color)
|
||||
.setColor(r, g, b, a)
|
||||
.setUv(u, v)
|
||||
.setLight(packedLight)
|
||||
.setNormal(1, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user