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