Posted July 11, 20205 yr Hello, I tried to port my TileEntityRenderer from 1.12.2 to 1.15.2, i've almost rewrited all. Objectively, I want to render the fluid contained in the TileEntity First, here is the RenderType public static RenderType getPedestalRenderType(ResourceLocation resourceLocation) { RenderType.State state = RenderType.State.getBuilder() .texture(new TextureState(resourceLocation, false, false)) .cull(CULL_DISABLED) .lightmap(LIGHTMAP_DISABLED) .transparency(TRANSLUCENT_TRANSPARENCY) .build(true); return RenderType.makeType(SkillsStones.MOD_ID + ":pedestal_fluid", DefaultVertexFormats.POSITION_COLOR_TEX, GL11.GL_QUADS, 256, true, false, state); } And here is the TileEntityRenderer private static final float MIN_HEIGHT = 0.5625f; private static final float MAX_HEIGHT = 0.78125f; @Override public void render(TileEntityNaturalTotemPedestal tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { Minecraft.getInstance().getProfiler().startSection("pedestalFluidRenderer"); float level = ((float) tileEntityIn.getFluidTank().getFluidAmount()) / (float) tileEntityIn.getFluidTank().getCapacity(); if(!(level > 0)) return; Fluid fluid = tileEntityIn.getFluidTank().getFluid().getFluid(); ResourceLocation resourceLocation; int color; if(fluid.getAttributes().getStillTexture() != null) { resourceLocation = fluid.getAttributes().getStillTexture(); color = getFluidColor(tileEntityIn.getWorld(), tileEntityIn.getPos(), fluid); } else if(fluid.getAttributes().getFlowingTexture() != null) { // In case that Still Texture don't exist resourceLocation = fluid.getAttributes().getFlowingTexture(); color = getFluidColor(tileEntityIn.getWorld(), tileEntityIn.getPos(), fluid); } else { // In case that no texture exist resourceLocation = Fluids.WATER.getAttributes().getStillTexture(); color = getFluidColor(tileEntityIn.getWorld(), tileEntityIn.getPos(), Fluids.WATER); } TextureAtlasSprite textureAtlasSprite = Minecraft.getInstance().getAtlasSpriteGetter(PlayerContainer.LOCATION_BLOCKS_TEXTURE).apply(resourceLocation); float uMin = textureAtlasSprite.getMinU(); float uMax = textureAtlasSprite.getMaxU(); float vMin = textureAtlasSprite.getMinV(); float vMax = textureAtlasSprite.getMaxV(); float a = 1.0F; float r = (color >> 16 & 0xFF) / 255.0F; float g = (color >> 8 & 0xFF) / 255.0F; float b = (color & 0xFF) / 255.0F; Matrix4f matrix4f = matrixStackIn.getLast().getMatrix(); float y = MIN_HEIGHT + (level) * (MAX_HEIGHT - MIN_HEIGHT); matrixStackIn.translate(0, y, 0); IVertexBuilder buffer = bufferIn.getBuffer(SSRenderType.getPedestalRenderType(resourceLocation)); buffer.pos(matrix4f, 0, 0, 0).color(r, g, b, a).tex(uMin, vMin).endVertex(); buffer.pos(matrix4f, 0, 0, 1).color(r, g, b, a).tex(uMin, vMax).endVertex(); buffer.pos(matrix4f, 1, 0, 1).color(r, g, b, a).tex(uMax, vMax).endVertex(); buffer.pos(matrix4f, 1, 0, 0).color(r, g, b, a).tex(uMax, vMin).endVertex(); Minecraft.getInstance().getProfiler().endSection(); } private static int getFluidColor(World world, BlockPos pos, Fluid fluid) { if(fluid.isEquivalentTo(Fluids.WATER)) { return BiomeColors.getWaterColor(world, pos); } return fluid.getAttributes().getColor(); } In this case, i've an error that tell me that texture doesn't exists (with an Java IO FileNotFound Exception) When i hardcode the ResourceLocation value to "minecraft:textures/block/water_still.png" It's working but the texture look weird (also, i've a weird smooth effect) I don't know how I can properly render my fluid. (Sorry for approximative English) Thanks a lot. Edited July 11, 20205 yr by Zeide Solved
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.