Update pylons to respect fabulous graphics

This commit is contained in:
Vincent Lee committed 2020-07-04 16:50:05 -05:00
1 parent 3cff9c4036
commit dc74b617e7
3 files changed
+46 -22

No files matched your search

@@ -52,7 +52,7 @@ import java.util.OptionalDouble;
import java.util.Random;
public final class RenderHelper {
private static final RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY;
private static final RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = getTranslucentTransparency();
private static final RenderType STAR;
public static final RenderType RECTANGLE;
public static final RenderType CIRCLE;
@@ -71,16 +71,19 @@ public final class RenderHelper {
public static final RenderType TERRA_PLATE;
public static final RenderType ENCHANTER;
public static final RenderType HALO;
public static final RenderType MANA_PYLON_GLOW;
public static final RenderType NATURA_PYLON_GLOW;
public static final RenderType GAIA_PYLON_GLOW;
public static final RenderType MANA_PYLON_GLOW = getPylonGlow("mana_pylon_glow", RenderTilePylon.MANA_TEXTURE);
public static final RenderType NATURA_PYLON_GLOW = getPylonGlow("natura_pylon_glow", RenderTilePylon.NATURA_TEXTURE);
public static final RenderType GAIA_PYLON_GLOW = getPylonGlow("gaia_pylon_glow", RenderTilePylon.GAIA_TEXTURE);
public static final RenderType MANA_PYLON_GLOW_DIRECT = getPylonGlowDirect("mana_pylon_glow_direct", RenderTilePylon.MANA_TEXTURE);
public static final RenderType NATURA_PYLON_GLOW_DIRECT = getPylonGlowDirect("natura_pylon_glow_direct", RenderTilePylon.NATURA_TEXTURE);
public static final RenderType GAIA_PYLON_GLOW_DIRECT = getPylonGlowDirect("gaia_pylon_glow_direct", RenderTilePylon.GAIA_TEXTURE);
public static final RenderType ASTROLABE_PREVIEW;
public static final RenderType ENTITY_TRANSLUCENT_GOLD;
static {
// todo 1.16 update to match vanilla where necessary (alternate render targets, etc.)
RenderState.TransparencyState lightningTransparency = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228512_d_");
TRANSLUCENT_TRANSPARENCY = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228515_g_");
RenderState.TextureState mipmapBlockAtlasTexture = new RenderState.TextureState(AtlasTexture.LOCATION_BLOCKS_TEXTURE, false, true);
RenderState.CullState disableCull = new RenderState.CullState(false);
RenderState.LayerState viewOffsetZLayering = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_239235_M_");
@@ -153,18 +156,6 @@ public final class RenderHelper {
RenderType halo = RenderType.makeType(LibResources.PREFIX_MOD + "halo", DefaultVertexFormats.POSITION_TEX, GL11.GL_QUADS, 64, glState);
HALO = useShaders ? new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.HALO, null, halo) : halo;
glState = RenderType.State.getBuilder().texture(new RenderState.TextureState(RenderTilePylon.MANA_TEXTURE, false, false)).transparency(TRANSLUCENT_TRANSPARENCY).diffuseLighting(enableDiffuse).alpha(zeroAlpha).cull(disableCull).lightmap(enableLightmap).overlay(enableOverlay).build(true);
RenderType manaPylonGlow = RenderType.makeType(LibResources.PREFIX_MOD + "mana_pylon_glow", DefaultVertexFormats.ENTITY, GL11.GL_QUADS, 128, glState);
MANA_PYLON_GLOW = useShaders ? new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.PYLON_GLOW, null, manaPylonGlow) : manaPylonGlow;
glState = RenderType.State.getBuilder().texture(new RenderState.TextureState(RenderTilePylon.NATURA_TEXTURE, false, false)).transparency(TRANSLUCENT_TRANSPARENCY).diffuseLighting(enableDiffuse).alpha(zeroAlpha).cull(disableCull).lightmap(enableLightmap).overlay(enableOverlay).build(true);
RenderType naturaPylonGlow = RenderType.makeType(LibResources.PREFIX_MOD + "natura_pylon_glow", DefaultVertexFormats.ENTITY, GL11.GL_QUADS, 128, glState);
NATURA_PYLON_GLOW = useShaders ? new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.PYLON_GLOW, null, naturaPylonGlow) : naturaPylonGlow;
glState = RenderType.State.getBuilder().texture(new RenderState.TextureState(RenderTilePylon.GAIA_TEXTURE, false, false)).transparency(TRANSLUCENT_TRANSPARENCY).diffuseLighting(enableDiffuse).alpha(zeroAlpha).cull(disableCull).lightmap(enableLightmap).overlay(enableOverlay).build(true);
RenderType gaiaPylonGlow = RenderType.makeType(LibResources.PREFIX_MOD + "gaia_pylon_glow", DefaultVertexFormats.ENTITY, GL11.GL_QUADS, 128, glState);
GAIA_PYLON_GLOW = useShaders ? new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.PYLON_GLOW, null, gaiaPylonGlow) : gaiaPylonGlow;
// Same as entity_translucent, with no depth test and a shader
glState = RenderType.State.getBuilder().depthTest(new RenderState.DepthTestState("always", GL11.GL_ALWAYS)).texture(new RenderState.TextureState(AtlasTexture.LOCATION_BLOCKS_TEXTURE, false, false)).transparency(TRANSLUCENT_TRANSPARENCY).diffuseLighting(enableDiffuse).alpha(oneTenthAlpha).cull(disableCull).lightmap(enableLightmap).overlay(enableOverlay).build(true);
ShaderCallback cb = shader -> {
@@ -181,6 +172,35 @@ public final class RenderHelper {
ENTITY_TRANSLUCENT_GOLD = useShaders ? new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.GOLD, null, gold) : gold;
}
private static RenderState.TransparencyState getTranslucentTransparency() {
return ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_228515_g_");
}
private static RenderType getPylonGlowDirect(String name, ResourceLocation texture) {
return getPylonGlow(name, texture, true);
}
private static RenderType getPylonGlow(String name, ResourceLocation texture) {
return getPylonGlow(name, texture, false);
}
private static RenderType getPylonGlow(String name, ResourceLocation texture, boolean direct) {
RenderType.State.Builder glState = RenderType.State.getBuilder()
.texture(new RenderState.TextureState(texture, false, false))
.transparency(TRANSLUCENT_TRANSPARENCY)
.diffuseLighting(new RenderState.DiffuseLightingState(true))
.alpha(new RenderState.AlphaState(0))
.cull(new RenderState.CullState(false))
.lightmap(new RenderState.LightmapState(true))
.overlay(new RenderState.OverlayState(true));
if (!direct) {
RenderState.TargetState itemTarget = ObfuscationReflectionHelper.getPrivateValue(RenderState.class, null, "field_241712_U_");
glState = glState.target(itemTarget);
}
RenderType layer = RenderType.makeType(LibResources.PREFIX_MOD + name, DefaultVertexFormats.ENTITY, GL11.GL_QUADS, 128, glState.build(false));
return ShaderHelper.useShaders() ? new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.PYLON_GLOW, null, layer) : layer;
}
public static RenderType getHaloLayer(ResourceLocation texture) {
RenderType.State glState = RenderType.State.getBuilder()
.texture(new RenderState.TextureState(texture, true, false))
@@ -50,6 +50,7 @@ public class RenderTilePylon extends TileEntityRenderer<TilePylon> {
// Overrides for when we call this TESR without an actual pylon
private static BlockPylon.Variant forceVariant = BlockPylon.Variant.MANA;
private static ItemCameraTransforms.TransformType forceTransform = ItemCameraTransforms.TransformType.NONE;
public RenderTilePylon(TileEntityRendererDispatcher manager) {
super(manager);
@@ -65,7 +66,9 @@ public class RenderTilePylon extends TileEntityRenderer<TilePylon> {
}
private void renderPylon(@Nullable TilePylon pylon, float pticks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) {
BlockPylon.Variant type = pylon == null ? forceVariant : ((BlockPylon) pylon.getBlockState().getBlock()).variant;
boolean renderingItem = pylon == null;
boolean direct = renderingItem && (forceTransform == ItemCameraTransforms.TransformType.GUI || forceTransform.func_241716_a_()); // loosely based off ItemRenderer logic
BlockPylon.Variant type = renderingItem ? forceVariant : ((BlockPylon) pylon.getBlockState().getBlock()).variant;
IPylonModel model;
ResourceLocation texture;
RenderType shaderLayer;
@@ -74,19 +77,19 @@ public class RenderTilePylon extends TileEntityRenderer<TilePylon> {
case MANA: {
model = manaModel;
texture = MANA_TEXTURE;
shaderLayer = RenderHelper.MANA_PYLON_GLOW;
shaderLayer = direct ? RenderHelper.MANA_PYLON_GLOW_DIRECT : RenderHelper.MANA_PYLON_GLOW;
break;
}
case NATURA: {
model = naturaModel;
texture = NATURA_TEXTURE;
shaderLayer = RenderHelper.NATURA_PYLON_GLOW;
shaderLayer = direct ? RenderHelper.NATURA_PYLON_GLOW_DIRECT : RenderHelper.NATURA_PYLON_GLOW;
break;
}
case GAIA: {
model = gaiaModel;
texture = GAIA_TEXTURE;
shaderLayer = RenderHelper.GAIA_PYLON_GLOW;
shaderLayer = direct ? RenderHelper.GAIA_PYLON_GLOW_DIRECT : RenderHelper.GAIA_PYLON_GLOW;
break;
}
}
@@ -140,6 +143,7 @@ public class RenderTilePylon extends TileEntityRenderer<TilePylon> {
public void func_239207_a_(ItemStack stack, ItemCameraTransforms.TransformType type, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) {
if (Block.getBlockFromItem(stack.getItem()) instanceof BlockPylon) {
RenderTilePylon.forceVariant = ((BlockPylon) Block.getBlockFromItem(stack.getItem())).variant;
RenderTilePylon.forceTransform = type;
TileEntityRenderer<TilePylon> r = TileEntityRendererDispatcher.instance.getRenderer(DUMMY.getValue());
((RenderTilePylon) r).renderPylon(null, 0, ms, buffers, light, overlay);
}
@@ -39,7 +39,7 @@ public final class ConfigHandler {
public Client(ForgeConfigSpec.Builder builder) {
builder.push("rendering");
useShaders = builder
.comment("Set this to false to disable the use of shaders for some of the mod's renders.")
.comment("Set this to false to disable the use of shaders for some of the mod's renders. (Requires game restart)")
.define("shaders", true);
boundBlockWireframe = builder
.comment("Set this to false to disable the wireframe when looking a block bound to something (spreaders, flowers, etc).")