diff --git a/src/main/java/thedarkcolour/exdeorum/blockentity/AbstractCrucibleBlockEntity.java b/src/main/java/thedarkcolour/exdeorum/blockentity/AbstractCrucibleBlockEntity.java index 514cb4a5..666bbe63 100644 --- a/src/main/java/thedarkcolour/exdeorum/blockentity/AbstractCrucibleBlockEntity.java +++ b/src/main/java/thedarkcolour/exdeorum/blockentity/AbstractCrucibleBlockEntity.java @@ -54,6 +54,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import thedarkcolour.exdeorum.blockentity.helper.FluidHelper; import thedarkcolour.exdeorum.config.EConfig; +import thedarkcolour.exdeorum.material.AbstractCrucibleMaterial; import thedarkcolour.exdeorum.recipe.crucible.CrucibleRecipe; import thedarkcolour.exdeorum.registry.EBlockEntities; import thedarkcolour.exdeorum.registry.EItems; @@ -83,9 +84,12 @@ public abstract class AbstractCrucibleBlockEntity extends EBlockEntity { private Fluid fluid = null; private short solids; private boolean needsLightUpdate; + public final boolean transparent; public AbstractCrucibleBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); + + this.transparent = AbstractCrucibleMaterial.TRANSPARENT_CRUCIBLES.contains(state.getBlock()); } @NotNull diff --git a/src/main/java/thedarkcolour/exdeorum/client/RenderUtil.java b/src/main/java/thedarkcolour/exdeorum/client/RenderUtil.java index c134dff9..c5386a97 100644 --- a/src/main/java/thedarkcolour/exdeorum/client/RenderUtil.java +++ b/src/main/java/thedarkcolour/exdeorum/client/RenderUtil.java @@ -49,7 +49,6 @@ import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions; import net.minecraftforge.client.model.CompositeModel; import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.registries.ForgeRegistries; -import org.joml.Matrix4f; import org.joml.Vector3f; import thedarkcolour.exdeorum.ExDeorum; import thedarkcolour.exdeorum.client.ter.SieveRenderer; @@ -173,7 +172,7 @@ public class RenderUtil { } @SuppressWarnings("DuplicatedCode") - public static void renderFluidCube(MultiBufferSource buffers, PoseStack stack, Level level, BlockPos pos, float minY, float maxY, float edge, int light, int r, int g, int b, Fluid fluid) { + public static void renderFluidCuboid(MultiBufferSource buffers, PoseStack stack, Level level, BlockPos pos, float minY, float maxY, float edge, int light, int r, int g, int b, Fluid fluid) { var extensions = IClientFluidTypeExtensions.of(fluid); var state = fluid.defaultFluidState(); var builder = buffers.getBuffer(Sheets.translucentCullBlockSheet()); diff --git a/src/main/java/thedarkcolour/exdeorum/client/ter/BarrelRenderer.java b/src/main/java/thedarkcolour/exdeorum/client/ter/BarrelRenderer.java index 523a087c..007ca501 100644 --- a/src/main/java/thedarkcolour/exdeorum/client/ter/BarrelRenderer.java +++ b/src/main/java/thedarkcolour/exdeorum/client/ter/BarrelRenderer.java @@ -33,7 +33,6 @@ import net.minecraft.util.Mth; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemDisplayContext; -import net.minecraft.world.level.material.Fluid; import net.minecraftforge.client.model.data.ModelData; import net.minecraftforge.common.capabilities.ForgeCapabilities; import thedarkcolour.exdeorum.ExDeorum; @@ -99,7 +98,7 @@ public class BarrelRenderer implements BlockEntityRenderer { } if (barrel.transparent) { - RenderUtil.renderFluidCube(buffers, stack, level, pos, 1 / 16f, y, 2.0f, light, r, g, b, fluid); + RenderUtil.renderFluidCuboid(buffers, stack, level, pos, 1 / 16f, y, 2.0f, light, r, g, b, fluid); } else { RenderUtil.renderFlatFluidSprite(buffers, stack, level, pos, y, 2.0f, light, r, g, b, fluid); } diff --git a/src/main/java/thedarkcolour/exdeorum/client/ter/CrucibleRenderer.java b/src/main/java/thedarkcolour/exdeorum/client/ter/CrucibleRenderer.java index ca5f8053..485f7a7a 100644 --- a/src/main/java/thedarkcolour/exdeorum/client/ter/CrucibleRenderer.java +++ b/src/main/java/thedarkcolour/exdeorum/client/ter/CrucibleRenderer.java @@ -23,7 +23,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.util.Mth; -import net.minecraft.world.level.block.Block; import net.minecraftforge.common.capabilities.ForgeCapabilities; import thedarkcolour.exdeorum.blockentity.AbstractCrucibleBlockEntity; import thedarkcolour.exdeorum.client.RenderUtil; @@ -49,7 +48,15 @@ public class CrucibleRenderer implements BlockEntityRenderer> 16) & 0xff, (color >> 8) & 0xff, color & 0xff, fluid); + int r = (color >> 16) & 0xff; + int g = (color >> 8) & 0xff; + int b = color & 0xff; + + if (crucible.transparent) { + RenderUtil.renderFluidCuboid(buffers, stack, level, pos, 4 / 16f, y, 2.0f, light, r, g, b, fluid); + } else { + RenderUtil.renderFlatFluidSprite(buffers, stack, level, pos, y, 2.0f, light, r, g, b, fluid); + } } if (solids != 0) { // eating my words rn :( @@ -64,8 +71,8 @@ public class CrucibleRenderer implements BlockEntityRenderer> 16) & 0xff, (color >> 8) & 0xff, color & 0xff, light, 2.0f, 4.0f, 14.0f); - } } }); diff --git a/src/main/java/thedarkcolour/exdeorum/material/AbstractCrucibleMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/AbstractCrucibleMaterial.java index 4636bce1..3d5ffd5d 100644 --- a/src/main/java/thedarkcolour/exdeorum/material/AbstractCrucibleMaterial.java +++ b/src/main/java/thedarkcolour/exdeorum/material/AbstractCrucibleMaterial.java @@ -18,12 +18,23 @@ package thedarkcolour.exdeorum.material; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import org.jetbrains.annotations.Nullable; +import java.util.HashSet; +import java.util.Set; + public abstract class AbstractCrucibleMaterial extends AbstractMaterial { - public AbstractCrucibleMaterial(SoundType soundType, float strength, boolean needsCorrectTool, int mapColor, String requiredModId) { + public static final Set TRANSPARENT_CRUCIBLES = new HashSet<>(); + + // Whether fluids and solids should be rendered with sides instead of just the top + public final boolean transparent; + + public AbstractCrucibleMaterial(SoundType soundType, float strength, boolean needsCorrectTool, int mapColor, String requiredModId, boolean transparent) { super(soundType, strength, needsCorrectTool, mapColor, requiredModId); + + this.transparent = transparent; } @Nullable @@ -33,15 +44,16 @@ public abstract class AbstractCrucibleMaterial extends AbstractMaterial { boolean needsCorrectTool = parser.getOptionalBoolean("needs_correct_tool"); int mapColor = parser.getMapColor(); String requiredModId = parser.getRequiredModId(); + boolean transparent = parser.getOptionalBoolean("transparent"); if (parser.error) { return null; } else { - return factory.create(soundType, strength, needsCorrectTool, mapColor, requiredModId); + return factory.create(soundType, strength, needsCorrectTool, mapColor, requiredModId, transparent); } } public interface Factory { - T create(SoundType soundType, float strength, boolean needsCorrectTool, int mapColor, String requiredModId); + T create(SoundType soundType, float strength, boolean needsCorrectTool, int mapColor, String requiredModId, boolean transparent); } } diff --git a/src/main/java/thedarkcolour/exdeorum/material/DefaultMaterials.java b/src/main/java/thedarkcolour/exdeorum/material/DefaultMaterials.java index 3b0c4649..356c77ff 100644 --- a/src/main/java/thedarkcolour/exdeorum/material/DefaultMaterials.java +++ b/src/main/java/thedarkcolour/exdeorum/material/DefaultMaterials.java @@ -106,13 +106,13 @@ public class DefaultMaterials { public static final SieveMaterial CRYSTALLIZED_SIEVE = addDefaultSieve("crystallized", SoundType.GLASS, true, ModIds.BLUE_SKIES); // Ex Deorum - public static final LavaCrucibleMaterial PORCELAIN_CRUCIBLE = addDefaultLavaCrucible("porcelain", SoundType.STONE, 2.0f, false, MapColor.TERRACOTTA_WHITE, ExDeorum.ID); - public static final LavaCrucibleMaterial WARPED_CRUCIBLE = addDefaultLavaCrucible("warped", SoundType.STEM, 1.5f, false, MapColor.CRIMSON_STEM, ExDeorum.ID); - public static final LavaCrucibleMaterial CRIMSON_CRUCIBLE = addDefaultLavaCrucible("crimson", SoundType.STEM, 1.5f, false, MapColor.WARPED_STEM, ExDeorum.ID); + public static final LavaCrucibleMaterial PORCELAIN_CRUCIBLE = addDefaultLavaCrucible("porcelain", SoundType.STONE, 2.0f, false, MapColor.TERRACOTTA_WHITE, ExDeorum.ID, false); + public static final LavaCrucibleMaterial WARPED_CRUCIBLE = addDefaultLavaCrucible("warped", SoundType.STEM, 1.5f, false, MapColor.CRIMSON_STEM, ExDeorum.ID, false); + public static final LavaCrucibleMaterial CRIMSON_CRUCIBLE = addDefaultLavaCrucible("crimson", SoundType.STEM, 1.5f, false, MapColor.WARPED_STEM, ExDeorum.ID, false); // Biomes O' Plenty - public static final LavaCrucibleMaterial HELLBARK_CRUCIBLE = addDefaultLavaCrucible("hellbark", SoundType.WOOD, 1.5f, false, MapColor.COLOR_LIGHT_GRAY, ModIds.BIOMES_O_PLENTY); + public static final LavaCrucibleMaterial HELLBARK_CRUCIBLE = addDefaultLavaCrucible("hellbark", SoundType.WOOD, 1.5f, false, MapColor.COLOR_LIGHT_GRAY, ModIds.BIOMES_O_PLENTY, false); // Blue Skies - public static final LavaCrucibleMaterial CRYSTALLIZED_CRUCIBLE = addDefaultLavaCrucible("crystallized", SoundType.GLASS, 2.0f, true, MapColor.TERRACOTTA_WHITE, ModIds.BLUE_SKIES); + public static final LavaCrucibleMaterial CRYSTALLIZED_CRUCIBLE = addDefaultLavaCrucible("crystallized", SoundType.GLASS, 2.0f, true, MapColor.TERRACOTTA_WHITE, ModIds.BLUE_SKIES, true); // Ex Deorum public static final WaterCrucibleMaterial OAK_CRUCIBLE = addDefaultWaterCrucible("oak", SoundType.WOOD, MapColor.WOOD, ExDeorum.ID); @@ -171,14 +171,14 @@ public class DefaultMaterials { return material; } - private static LavaCrucibleMaterial addDefaultLavaCrucible(String name, SoundType soundType, float strength, boolean needsCorrectTool, MapColor color, String requiredModId) { - var material = new LavaCrucibleMaterial(soundType, strength, needsCorrectTool, color.id, requiredModId); + private static LavaCrucibleMaterial addDefaultLavaCrucible(String name, SoundType soundType, float strength, boolean needsCorrectTool, MapColor color, String requiredModId, boolean transparent) { + var material = new LavaCrucibleMaterial(soundType, strength, needsCorrectTool, color.id, requiredModId, transparent); LAVA_CRUCIBLES.register(name, material); return material; } private static WaterCrucibleMaterial addDefaultWaterCrucible(String name, SoundType soundType, MapColor color, String requiredModId) { - var material = new WaterCrucibleMaterial(soundType, 1.5f, false, color.id, requiredModId); + var material = new WaterCrucibleMaterial(soundType, 1.5f, false, color.id, requiredModId, false); WATER_CRUCIBLES.register(name, material); return material; } diff --git a/src/main/java/thedarkcolour/exdeorum/material/LavaCrucibleMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/LavaCrucibleMaterial.java index a6d6a117..067f8c91 100644 --- a/src/main/java/thedarkcolour/exdeorum/material/LavaCrucibleMaterial.java +++ b/src/main/java/thedarkcolour/exdeorum/material/LavaCrucibleMaterial.java @@ -23,8 +23,8 @@ import net.minecraft.world.level.block.SoundType; import thedarkcolour.exdeorum.block.LavaCrucibleBlock; public class LavaCrucibleMaterial extends AbstractCrucibleMaterial { - protected LavaCrucibleMaterial(SoundType soundType, float strength, boolean needsCorrectTool, int mapColor, String requiredModId) { - super(soundType, strength, needsCorrectTool, mapColor, requiredModId); + protected LavaCrucibleMaterial(SoundType soundType, float strength, boolean needsCorrectTool, int mapColor, String requiredModId, boolean transparent) { + super(soundType, strength, needsCorrectTool, mapColor, requiredModId, transparent); } @Override diff --git a/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java b/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java index 9261d5e3..83549030 100644 --- a/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java +++ b/src/main/java/thedarkcolour/exdeorum/material/WaterCrucibleMaterial.java @@ -23,8 +23,8 @@ import net.minecraft.world.level.block.SoundType; import thedarkcolour.exdeorum.block.WaterCrucibleBlock; public class WaterCrucibleMaterial extends AbstractCrucibleMaterial { - protected WaterCrucibleMaterial(SoundType soundType, float strength, boolean needsCorrectTool, int mapColor, String requiredModId) { - super(soundType, strength, needsCorrectTool, mapColor, requiredModId); + protected WaterCrucibleMaterial(SoundType soundType, float strength, boolean needsCorrectTool, int mapColor, String requiredModId, boolean transparent) { + super(soundType, strength, needsCorrectTool, mapColor, requiredModId, transparent); } @Override