From b5c0684dd60410fcb60bf97baa5a9cc83c11f99d Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 3 Jul 2021 01:03:37 -0700 Subject: [PATCH] Rendering refactors - Fix fluid rendering in JEI scenes - Add more separate options to SuperByteBuffer - Fix copper backtank diffuse when worn - Fix enchantment glint on custom rendered items; Closes #1846 --- .../armor/CopperBacktankArmorLayer.java | 14 +- .../curiosities/tools/BlueprintRenderer.java | 16 +- .../foundation/fluid/FluidRenderer.java | 68 +++---- .../create/foundation/gui/GuiGameElement.java | 14 +- .../item/render/PartialItemModelRenderer.java | 2 +- .../foundation/render/SuperByteBuffer.java | 170 ++++++++++++++---- .../foundation/renderState/RenderTypes.java | 62 +++---- 7 files changed, 204 insertions(+), 142 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java index f5512c873..2d97378b4 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java @@ -15,6 +15,7 @@ import net.minecraft.block.BlockState; import net.minecraft.client.MainWindow; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; +import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer.Impl; import net.minecraft.client.renderer.RenderType; @@ -60,7 +61,7 @@ public class CopperBacktankArmorLayer model = (BipedModel) entityModel; BlockState renderedState = AllBlocks.COPPER_BACKTANK.getDefaultState() .with(CopperBacktankBlock.HORIZONTAL_FACING, Direction.SOUTH); - RenderType renderType = RenderType.getCutout(); + RenderType renderType = Atlases.getEntityCutout(); SuperByteBuffer backtank = CreateClient.BUFFER_CACHE.renderBlock(renderedState); SuperByteBuffer cogs = @@ -69,8 +70,9 @@ public class CopperBacktankArmorLayer { - public BlueprintRenderer(EntityRendererManager p_i46179_1_) { - super(p_i46179_1_); + public BlueprintRenderer(EntityRendererManager manager) { + super(manager); } @Override public void render(BlueprintEntity entity, float yaw, float pt, MatrixStack ms, IRenderTypeBuffer buffer, - int overlay) { + int light) { PartialModel partialModel = entity.size == 3 ? AllBlockPartials.CRAFTING_BLUEPRINT_3x3 : entity.size == 2 ? AllBlockPartials.CRAFTING_BLUEPRINT_2x2 : AllBlockPartials.CRAFTING_BLUEPRINT_1x1; SuperByteBuffer sbb = PartialBufferer.get(partialModel, Blocks.AIR.getDefaultState()); - int light = WorldRenderer.getLightmapCoordinates(entity.world, entity.getBlockPos()); sbb.matrixStacker() .rotateY(-yaw) .rotateX(90.0F + entity.rotationPitch) @@ -44,10 +41,9 @@ public class BlueprintRenderer extends EntityRenderer { if (entity.size == 2) sbb.translate(.5, 0, -.5); - RenderType entitySolid = RenderType.getEntitySolid(PlayerContainer.BLOCK_ATLAS_TEXTURE); - sbb.asEntityModel() + sbb.forEntityRender() .light(light) - .renderInto(ms, buffer.getBuffer(entitySolid)); + .renderInto(ms, buffer.getBuffer(Atlases.getEntitySolid())); super.render(entity, yaw, pt, ms, buffer, light); ms.push(); diff --git a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java index 2a82e5a30..a87676674 100644 --- a/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/fluid/FluidRenderer.java @@ -2,20 +2,18 @@ package com.simibubi.create.foundation.fluid; import java.util.function.Function; -import com.jozufozu.flywheel.event.RenderLayerEvent; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack.Entry; import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.renderState.RenderTypes; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.MatrixStacker; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.RenderType; +import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.fluid.Fluid; import net.minecraft.inventory.container.PlayerContainer; @@ -28,42 +26,23 @@ import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3i; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.common.Mod; @OnlyIn(Dist.CLIENT) -@Mod.EventBusSubscriber(Dist.CLIENT) public class FluidRenderer { - // If we draw to BufferBuilder that minecraft provides for RenderType.getTranslucent(), minecraft draws the contents - // to the wrong framebuffer. If we tried to inject a custom RenderType into RenderTypeBuffers, we'd have the same - // issue. This is because minecraft calls IRenderTypeBuffer.Impl::draw just before clearing the transparency - // framebuffer, so anything we put into the normal RenderTypeBuffers will never be seen. By using our own - // BufferBuilder, we can avoid getting our contents wiped. Then, using Flywheel's renderLayer hook, we can draw our - // buffer at the same time the transparent world layer is drawn. - private static final BufferBuilder _builder = new BufferBuilder(RenderType.getTranslucent().getExpectedBufferSize()); - - private static BufferBuilder getBuilder() { - if (!_builder.isBuilding()) { - RenderType type = RenderType.getTranslucent(); - - _builder.begin(type.getDrawMode(), type.getVertexFormat()); - } - - return _builder; - } - - @SubscribeEvent - public static void renderLayer(RenderLayerEvent event) { - if (event.type == RenderType.getTranslucent()) { - event.type.draw(_builder, 0, 0, 0); - } + public static IVertexBuilder getFluidBuilder(IRenderTypeBuffer buffer) { + return buffer.getBuffer(RenderTypes.getFluid()); } public static void renderFluidStream(FluidStack fluidStack, Direction direction, float radius, float progress, boolean inbound, IRenderTypeBuffer buffer, MatrixStack ms, int light) { + renderFluidStream(fluidStack, direction, radius, progress, inbound, getFluidBuilder(buffer), ms, light); + } + + public static void renderFluidStream(FluidStack fluidStack, Direction direction, float radius, float progress, + boolean inbound, IVertexBuilder builder, MatrixStack ms, int light) { Fluid fluid = fluidStack.getFluid(); FluidAttributes fluidAttributes = fluid.getAttributes(); Function spriteAtlas = Minecraft.getInstance() @@ -72,18 +51,14 @@ public class FluidRenderer { TextureAtlasSprite stillTexture = spriteAtlas.apply(fluidAttributes.getStillTexture(fluidStack)); int color = fluidAttributes.getColor(fluidStack); - IVertexBuilder builder = getBuilder(); - if (buffer instanceof SuperRenderTypeBuffer) - builder = ((SuperRenderTypeBuffer) buffer).getLateBuffer(RenderType.getTranslucent()); - - MatrixStacker msr = MatrixStacker.of(ms); - int blockLightIn = (light >> 4) & 0xf; + int blockLightIn = (light >> 4) & 0xF; int luminosity = Math.max(blockLightIn, fluidAttributes.getLuminosity(fluidStack)); - light = (light & 0xf00000) | luminosity << 4; + light = (light & 0xF00000) | luminosity << 4; if (inbound) direction = direction.getOpposite(); + MatrixStacker msr = MatrixStacker.of(ms); ms.push(); msr.centre() .rotateY(AngleHelper.horizontalAngle(direction)) @@ -111,11 +86,15 @@ public class FluidRenderer { stillTexture); ms.pop(); - } public static void renderTiledFluidBB(FluidStack fluidStack, float xMin, float yMin, float zMin, float xMax, float yMax, float zMax, IRenderTypeBuffer buffer, MatrixStack ms, int light, boolean renderBottom) { + renderTiledFluidBB(fluidStack, xMin, yMin, zMin, xMax, yMax, zMax, getFluidBuilder(buffer), ms, light, renderBottom); + } + + public static void renderTiledFluidBB(FluidStack fluidStack, float xMin, float yMin, float zMin, float xMax, + float yMax, float zMax, IVertexBuilder builder, MatrixStack ms, int light, boolean renderBottom) { Fluid fluid = fluidStack.getFluid(); FluidAttributes fluidAttributes = fluid.getAttributes(); TextureAtlasSprite fluidTexture = Minecraft.getInstance() @@ -123,16 +102,12 @@ public class FluidRenderer { .apply(fluidAttributes.getStillTexture(fluidStack)); int color = fluidAttributes.getColor(fluidStack); - IVertexBuilder builder = getBuilder(); - if (buffer instanceof SuperRenderTypeBuffer) - builder = ((SuperRenderTypeBuffer) buffer).getLateBuffer(RenderType.getTranslucent()); - MatrixStacker msr = MatrixStacker.of(ms); - Vector3d center = new Vector3d(xMin + (xMax - xMin) / 2, yMin + (yMax - yMin) / 2, zMin + (zMax - zMin) / 2); - - int blockLightIn = (light >> 4) & 0xf; + int blockLightIn = (light >> 4) & 0xF; int luminosity = Math.max(blockLightIn, fluidAttributes.getLuminosity(fluidStack)); - light = (light & 0xf00000) | luminosity << 4; + light = (light & 0xF00000) | luminosity << 4; + Vector3d center = new Vector3d(xMin + (xMax - xMin) / 2, yMin + (yMax - yMin) / 2, zMin + (zMax - zMin) / 2); + MatrixStacker msr = MatrixStacker.of(ms); ms.push(); if (fluidStack.getFluid() .getAttributes() @@ -245,6 +220,7 @@ public class FluidRenderer { builder.vertex(peek.getModel(), x, y, z) .color(r, g, b, a) .texture(u, v) + .overlay(OverlayTexture.DEFAULT_UV) .light(light) .normal(n.getX(), n.getY(), n.getZ()) .endVertex(); diff --git a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java index a7f88729c..b2f1bd5f4 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java @@ -158,12 +158,12 @@ public class GuiGameElement { private static class GuiBlockModelRenderBuilder extends GuiRenderBuilder { - protected IBakedModel blockmodel; + protected IBakedModel blockModel; protected BlockState blockState; public GuiBlockModelRenderBuilder(IBakedModel blockmodel, @Nullable BlockState blockState) { this.blockState = blockState == null ? Blocks.AIR.getDefaultState() : blockState; - this.blockmodel = blockmodel; + this.blockModel = blockmodel; } @Override @@ -194,7 +194,7 @@ public class GuiGameElement { .getColor(blockState, null, null, 0); Vector3d rgb = ColorHelper.getRGB(color == -1 ? this.color : color); blockRenderer.getBlockModelRenderer() - .renderModel(ms.peek(), vb, blockState, blockmodel, (float) rgb.x, (float) rgb.y, (float) rgb.z, + .renderModel(ms.peek(), vb, blockState, blockModel, (float) rgb.x, (float) rgb.y, (float) rgb.z, 0xF000F0, OverlayTexture.DEFAULT_UV, VirtualEmptyModelData.INSTANCE); buffer.draw(); } @@ -227,13 +227,9 @@ public class GuiGameElement { .isEmpty()) return; - ms.push(); - RenderHelper.disableStandardItemLighting(); FluidRenderer.renderTiledFluidBB(new FluidStack(blockState.getFluidState() - .getFluid(), 1000), 0, 0, 0, 1.0001f, 1.0001f, 1.0001f, buffer, ms, 0xF000F0, true); - buffer.draw(RenderType.getTranslucent()); - RenderHelper.enable(); - ms.pop(); + .getFluid(), 1000), 0, 0, 0, 1.0001f, 1.0001f, 1.0001f, buffer, ms, 0xF000F0, false); + buffer.draw(); } } diff --git a/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java b/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java index 898727b8d..434fa0181 100644 --- a/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/item/render/PartialItemModelRenderer.java @@ -70,7 +70,7 @@ public class PartialItemModelRenderer { if (!model.isBuiltInRenderer()) renderBakedItemModel(model, light, ms, - ItemRenderer.getArmorVertexConsumer(buffer, type, true, stack.hasEffect())); + ItemRenderer.getDirectGlintVertexConsumer(buffer, type, true, stack.hasEffect())); else stack.getItem() .getItemStackTileEntityRenderer() diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index c3db4fc51..acca05bf6 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -16,6 +16,7 @@ import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Matrix3f; import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.math.vector.Quaternion; @@ -32,13 +33,18 @@ public class SuperByteBuffer { // Vertex Position private MatrixStack transforms; - // Vertex Texture Coords - private SpriteShiftFunc spriteShiftFunc; - private boolean isEntityModel; - // Vertex Coloring private boolean shouldColor; private int r, g, b, a; + private boolean disableDiffuseDiv; + private boolean disableDiffuseMult; + + // Vertex Texture Coords + private SpriteShiftFunc spriteShiftFunc; + + // Vertex Overlay Color + private boolean hasOverlay; + private int overlay = OverlayTexture.DEFAULT_UV;; // Vertex Lighting private boolean useWorldLight; @@ -46,6 +52,15 @@ public class SuperByteBuffer { private int packedLightCoords; private Matrix4f lightTransform; + // Vertex Normals + private boolean fullNormalTransform; + + // Temporary + private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap(); + private final Vector4f pos = new Vector4f(); + private final Vector3f normal = new Vector3f(); + private final Vector4f lightPos = new Vector4f(); + public SuperByteBuffer(BufferBuilder buf) { template = new BufferBuilderReader(buf); transforms = new MatrixStack(); @@ -61,27 +76,26 @@ public class SuperByteBuffer { return (v - sprite.getMinV()) / f * 16.0F; } - private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap(); - Vector4f pos = new Vector4f(); - Vector3f normal = new Vector3f(); - Vector4f lightPos = new Vector4f(); - public void renderInto(MatrixStack input, IVertexBuilder builder) { if (isEmpty()) return; - Matrix3f normalMat = transforms.peek() - .getNormal() - .copy(); - Matrix4f modelMat = input.peek() .getModel() .copy(); - Matrix4f localTransforms = transforms.peek() .getModel(); modelMat.multiply(localTransforms); + Matrix3f normalMat; + if (fullNormalTransform) { + normalMat = input.peek().getNormal().copy(); + Matrix3f localNormalTransforms = transforms.peek().getNormal(); + normalMat.multiply(localNormalTransforms); + } else { + normalMat = transforms.peek().getNormal().copy(); + } + if (useWorldLight) { WORLD_LIGHT_CACHE.clear(); } @@ -101,43 +115,58 @@ public class SuperByteBuffer { float normalY = template.getNY(i) / 127f; float normalZ = template.getNZ(i) / 127f; - float staticDiffuse = LightUtil.diffuseLight(normalX, normalY, normalZ); normal.set(normalX, normalY, normalZ); normal.transform(normalMat); float nx = normal.getX(); float ny = normal.getY(); float nz = normal.getZ(); + + float staticDiffuse = LightUtil.diffuseLight(normalX, normalY, normalZ); float instanceDiffuse = LightUtil.diffuseLight(nx, ny, nz); pos.set(x, y, z, 1F); pos.transform(modelMat); builder.vertex(pos.getX(), pos.getY(), pos.getZ()); - if (isEntityModel) { - builder.color(255, 255, 255, 255); - } else if (shouldColor) { - int colorR = Math.min(255, (int) (((float) this.r) * instanceDiffuse)); - int colorG = Math.min(255, (int) (((float) this.g) * instanceDiffuse)); - int colorB = Math.min(255, (int) (((float) this.b) * instanceDiffuse)); - builder.color(colorR, colorG, colorB, this.a); + if (shouldColor) { + if (disableDiffuseMult) { + builder.color(this.r, this.g, this.b, this.a); + } else { + int colorR = transformColor(this.r, instanceDiffuse); + int colorG = transformColor(this.g, instanceDiffuse); + int colorB = transformColor(this.b, instanceDiffuse); + builder.color(colorR, colorG, colorB, this.a); + } } else { - float diffuseMult = instanceDiffuse / staticDiffuse; - int colorR = Math.min(255, (int) (((float) Byte.toUnsignedInt(r)) * diffuseMult)); - int colorG = Math.min(255, (int) (((float) Byte.toUnsignedInt(g)) * diffuseMult)); - int colorB = Math.min(255, (int) (((float) Byte.toUnsignedInt(b)) * diffuseMult)); - builder.color(colorR, colorG, colorB, a); + if (disableDiffuseDiv && disableDiffuseMult) { + builder.color(r, g, b, a); + } else { + float diffuseMult; + if (disableDiffuseDiv) { + diffuseMult = instanceDiffuse; + } else if (disableDiffuseMult) { + diffuseMult = 1 / staticDiffuse; + } else { + diffuseMult = instanceDiffuse / staticDiffuse; + } + int colorR = transformColor(r, diffuseMult); + int colorG = transformColor(g, diffuseMult); + int colorB = transformColor(b, diffuseMult); + builder.color(colorR, colorG, colorB, a); + } } float u = template.getU(i); float v = template.getV(i); - if (spriteShiftFunc != null) { spriteShiftFunc.shift(builder, u, v); - } else + } else { builder.texture(u, v); + } - if (isEntityModel) - builder.overlay(OverlayTexture.DEFAULT_UV); + if (hasOverlay) { + builder.overlay(overlay); + } int light; if (useWorldLight) { @@ -163,10 +192,8 @@ public class SuperByteBuffer { builder.light(light); } - if (isEntityModel) - builder.normal(input.peek().getNormal(), nx, ny, nz); - else - builder.normal(nx, ny, nz); + builder.normal(nx, ny, nz); + builder.endVertex(); } @@ -175,17 +202,21 @@ public class SuperByteBuffer { public SuperByteBuffer reset() { transforms = new MatrixStack(); - spriteShiftFunc = null; shouldColor = false; - isEntityModel = false; r = 0; g = 0; b = 0; a = 0; + disableDiffuseDiv = false; + disableDiffuseMult = false; + spriteShiftFunc = null; + hasOverlay = false; + overlay = OverlayTexture.DEFAULT_UV; useWorldLight = false; hybridLight = false; packedLightCoords = 0; lightTransform = null; + fullNormalTransform = false; return this; } @@ -241,6 +272,15 @@ public class SuperByteBuffer { .translate(-.5f, -.5f, -.5f); } + public SuperByteBuffer color(int r, int g, int b, int a) { + shouldColor = true; + this.r = r; + this.g = g; + this.b = b; + this.a = a; + return this; + } + public SuperByteBuffer color(int color) { shouldColor = true; r = ((color >> 16) & 0xFF); @@ -250,6 +290,25 @@ public class SuperByteBuffer { return this; } + /** + * Prevents vertex colors from being divided by the diffuse value calculated from the raw untransformed normal vector. + * Useful when passed vertex colors do not have diffuse baked in. + * Disabled when custom color is used. + */ + public SuperByteBuffer disableDiffuseDiv() { + disableDiffuseDiv = true; + return this; + } + + /** + * Prevents vertex colors from being multiplied by the diffuse value calculated from the final transformed normal vector. + * Useful for entity rendering, when diffuse is applied automatically later. + */ + public SuperByteBuffer disableDiffuseMult() { + disableDiffuseMult = true; + return this; + } + public SuperByteBuffer shiftUV(SpriteShiftEntry entry) { this.spriteShiftFunc = (builder, u, v) -> { float targetU = entry.getTarget() @@ -286,6 +345,17 @@ public class SuperByteBuffer { return this; } + public SuperByteBuffer overlay() { + hasOverlay = true; + return this; + } + + public SuperByteBuffer overlay(int overlay) { + hasOverlay = true; + this.overlay = overlay; + return this; + } + public SuperByteBuffer light() { useWorldLight = true; return this; @@ -309,16 +379,38 @@ public class SuperByteBuffer { return this; } + /** + * Uses max light from calculated light (world light or custom light) and vertex light for the final light value. + * Ineffective if any other light method was not called. + */ public SuperByteBuffer hybridLight() { hybridLight = true; return this; } - public SuperByteBuffer asEntityModel() { - isEntityModel = true; + /** + * Transforms normals not only by the local matrix stack, but also by the passed matrix stack. + */ + public SuperByteBuffer fullNormalTransform() { + fullNormalTransform = true; return this; } + public SuperByteBuffer forEntityRender() { + disableDiffuseMult(); + overlay(); + fullNormalTransform(); + return this; + } + + public static int transformColor(byte component, float scale) { + return MathHelper.clamp((int) (Byte.toUnsignedInt(component) * scale), 0, 255); + } + + public static int transformColor(int component, float scale) { + return MathHelper.clamp((int) (component * scale), 0, 255); + } + public static int maxLight(int packedLight1, int packedLight2) { int blockLight1 = LightTexture.getBlockLightCoordinates(packedLight1); int skyLight1 = LightTexture.getSkyLightCoordinates(packedLight1); diff --git a/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java b/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java index 41cc284bd..4250dd03c 100644 --- a/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java +++ b/src/main/java/com/simibubi/create/foundation/renderState/RenderTypes.java @@ -1,7 +1,9 @@ package com.simibubi.create.foundation.renderState; -import com.mojang.blaze3d.systems.RenderSystem; +import org.lwjgl.opengl.GL11; + import com.simibubi.create.AllSpecialTextures; +import com.simibubi.create.Create; import net.minecraft.client.renderer.RenderState; import net.minecraft.client.renderer.RenderType; @@ -11,8 +13,6 @@ import net.minecraft.util.ResourceLocation; public class RenderTypes extends RenderState { - protected static final RenderState.CullState DISABLE_CULLING = new NoCullState(); - public static RenderType getOutlineTranslucent(ResourceLocation texture, boolean cull) { RenderType.State rendertype$state = RenderType.State.builder() .texture(new RenderState.TextureState(texture, false, false)) @@ -23,15 +23,14 @@ public class RenderTypes extends RenderState { .lightmap(ENABLE_LIGHTMAP) .overlay(ENABLE_OVERLAY_COLOR) .build(true); - return RenderType.of("outline_translucent" + (cull ? "_cull" : ""), - DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, 256, true, true, rendertype$state); + return RenderType.of(createLayerName("outline_translucent" + (cull ? "_cull" : "")), + DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, true, rendertype$state); } private static final RenderType OUTLINE_SOLID = - RenderType.of("outline_solid", DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, 256, true, + RenderType.of(createLayerName("outline_solid"), DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, false, RenderType.State.builder() .texture(new RenderState.TextureState(AllSpecialTextures.BLANK.getLocation(), false, false)) - .transparency(NO_TRANSPARENCY) .diffuseLighting(ENABLE_DIFFUSE_LIGHTING) .lightmap(ENABLE_LIGHTMAP) .overlay(ENABLE_OVERLAY_COLOR) @@ -40,12 +39,10 @@ public class RenderTypes extends RenderState { public static RenderType getGlowingSolid(ResourceLocation texture) { RenderType.State rendertype$state = RenderType.State.builder() .texture(new RenderState.TextureState(texture, false, false)) - .transparency(NO_TRANSPARENCY) - .diffuseLighting(DISABLE_DIFFUSE_LIGHTING) .lightmap(ENABLE_LIGHTMAP) .overlay(ENABLE_OVERLAY_COLOR) .build(true); - return RenderType.of("glowing_solid", DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, 256, + return RenderType.of(createLayerName("glowing_solid"), DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, false, rendertype$state); } @@ -53,41 +50,52 @@ public class RenderTypes extends RenderState { RenderType.State rendertype$state = RenderType.State.builder() .texture(new RenderState.TextureState(texture, false, false)) .transparency(TRANSLUCENT_TRANSPARENCY) - .diffuseLighting(DISABLE_DIFFUSE_LIGHTING) .alpha(ONE_TENTH_ALPHA) .cull(DISABLE_CULLING) .lightmap(ENABLE_LIGHTMAP) .overlay(ENABLE_OVERLAY_COLOR) .build(true); - return RenderType.of("glowing_translucent", DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, + return RenderType.of(createLayerName("glowing_translucent"), DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, true, rendertype$state); } - private static final RenderType GLOWING_SOLID = RenderTypes.getGlowingSolid(PlayerContainer.BLOCK_ATLAS_TEXTURE); - private static final RenderType GLOWING_TRANSLUCENT = - RenderTypes.getGlowingTranslucent(PlayerContainer.BLOCK_ATLAS_TEXTURE); + private static final RenderType GLOWING_SOLID = getGlowingSolid(PlayerContainer.BLOCK_ATLAS_TEXTURE); + private static final RenderType GLOWING_TRANSLUCENT = getGlowingTranslucent(PlayerContainer.BLOCK_ATLAS_TEXTURE); private static final RenderType ITEM_PARTIAL_SOLID = - RenderType.of("item_solid", DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, 256, true, + RenderType.of(createLayerName("item_solid"), DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, false, RenderType.State.builder() - .texture(new RenderState.TextureState(PlayerContainer.BLOCK_ATLAS_TEXTURE, false, false)) + .texture(BLOCK_ATLAS_TEXTURE) .transparency(NO_TRANSPARENCY) .diffuseLighting(ENABLE_DIFFUSE_LIGHTING) .lightmap(ENABLE_LIGHTMAP) .overlay(ENABLE_OVERLAY_COLOR) .build(true)); - private static final RenderType ITEM_PARTIAL_TRANSLUCENT = RenderType.of("entity_translucent", - DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, 256, true, true, RenderType.State.builder() - .texture(new RenderState.TextureState(PlayerContainer.BLOCK_ATLAS_TEXTURE, false, false)) + private static final RenderType ITEM_PARTIAL_TRANSLUCENT = RenderType.of(createLayerName("item_translucent"), + DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, true, RenderType.State.builder() + .texture(BLOCK_ATLAS_TEXTURE) .transparency(TRANSLUCENT_TRANSPARENCY) .diffuseLighting(ENABLE_DIFFUSE_LIGHTING) .alpha(ONE_TENTH_ALPHA) - .cull(ENABLE_CULLING) .lightmap(ENABLE_LIGHTMAP) .overlay(ENABLE_OVERLAY_COLOR) .build(true)); + private static final RenderType FLUID = RenderType.of(createLayerName("fluid"), + DefaultVertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, GL11.GL_QUADS, 256, true, true, RenderType.State.builder() + .texture(MIPMAP_BLOCK_ATLAS_TEXTURE) + .transparency(TRANSLUCENT_TRANSPARENCY) + .shadeModel(SMOOTH_SHADE_MODEL) + .alpha(ONE_TENTH_ALPHA) + .lightmap(ENABLE_LIGHTMAP) + .overlay(ENABLE_OVERLAY_COLOR) + .build(true)); + + private static String createLayerName(String name) { + return Create.ID + ":" + name; + } + public static RenderType getItemPartialSolid() { return ITEM_PARTIAL_SOLID; } @@ -108,19 +116,13 @@ public class RenderTypes extends RenderState { return GLOWING_TRANSLUCENT; } - protected static class NoCullState extends RenderState.CullState { - public NoCullState() { - super(false); - } - - @Override - public void startDrawing() { - RenderSystem.disableCull(); - } + public static RenderType getFluid() { + return FLUID; } // Mmm gimme those protected fields public RenderTypes() { super(null, null, null); } + }