More work, fix gaia head tesrFix gaia head tesr

This commit is contained in:
Vincent Lee committed 2020-01-15 15:58:23 -06:00
1 parent ebee563201
commit cf54cc2b13
11 files changed
+200 -207

No files matched your search

@@ -12,7 +12,7 @@ public final class AccessoryRenderHelper {
* Rotates the render for a bauble correctly if the player is sneaking.
*/
public static void rotateIfSneaking(LivingEntity player) {
if(player.shouldRenderSneaking())
if(player.isCrouching())
applySneakingRotation();
}
@@ -31,90 +31,4 @@ public final class IconHelper {
buffer.vertex(mat, x + width, y, 0).color(1, 1, 1, alpha).texture(icon.getMaxU(), icon.getMinV()).light(fullbright).endVertex();
buffer.vertex(mat, x, y, 0).color(1, 1, 1, alpha).texture(icon.getMinU(), icon.getMinV()).light(fullbright).endVertex();
}
// todo 1.15 remove this and just render real generated models added using addSpecialModel
/**
* Renders a sprite from the spritesheet with depth, like a "builtin/generated" item model.
* Adapted from ItemRenderer.renderItemIn2D, 1.7.10
*/
@Deprecated
public static void renderIconIn3D(Tessellator tess, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int width, int height, float thickness) {
/*
BufferBuilder wr = tess.getBuffer();
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
wr.pos(0.0D, 0.0D, 0.0D).tex(p_78439_1_, p_78439_4_).normal(0, 0, 1).endVertex();
wr.pos(1.0D, 0.0D, 0.0D).tex(p_78439_3_, p_78439_4_).normal(0, 0, 1).endVertex();
wr.pos(1.0D, 1.0D, 0.0D).tex(p_78439_3_, p_78439_2_).normal(0, 0, 1).endVertex();
wr.pos(0.0D, 1.0D, 0.0D).tex(p_78439_1_, p_78439_2_).normal(0, 0, 1).endVertex();
tess.draw();
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
wr.pos(0.0D, 1.0D, 0.0F - thickness).tex(p_78439_1_, p_78439_2_).normal(0, 0, -1).endVertex();
wr.pos(1.0D, 1.0D, 0.0F - thickness).tex(p_78439_3_, p_78439_2_).normal(0, 0, -1).endVertex();
wr.pos(1.0D, 0.0D, 0.0F - thickness).tex(p_78439_3_, p_78439_4_).normal(0, 0, -1).endVertex();
wr.pos(0.0D, 0.0D, 0.0F - thickness).tex(p_78439_1_, p_78439_4_).normal(0, 0, -1).endVertex();
tess.draw();
float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / width;
float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / height;
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
int k;
float f7;
float f8;
for (k = 0; k < width; ++k)
{
f7 = (float)k / (float)width;
f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
wr.pos(f7, 0.0D, 0.0F - thickness).tex(f8, p_78439_4_).normal(-1, 0, 0).endVertex();
wr.pos(f7, 0.0D, 0.0D).tex(f8, p_78439_4_).normal(-1, 0, 0).endVertex();
wr.pos(f7, 1.0D, 0.0D).tex(f8, p_78439_2_).normal(-1, 0, 0).endVertex();
wr.pos(f7, 1.0D, 0.0F - thickness).tex(f8, p_78439_2_).normal(-1, 0, 0).endVertex();
}
tess.draw();
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
float f9;
for (k = 0; k < width; ++k)
{
f7 = (float)k / (float)width;
f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
f9 = f7 + 1.0F / width;
wr.pos(f9, 1.0D, 0.0F - thickness).tex(f8, p_78439_2_).normal(1, 0, 0).endVertex();
wr.pos(f9, 1.0D, 0.0D).tex(f8, p_78439_2_).normal(1, 0, 0).endVertex();
wr.pos(f9, 0.0D, 0.0D).tex(f8, p_78439_4_).normal(1, 0, 0).endVertex();
wr.pos(f9, 0.0D, 0.0F - thickness).tex(f8, p_78439_4_).normal(1, 0, 0).endVertex();
}
tess.draw();
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
for (k = 0; k < height; ++k)
{
f7 = (float)k / (float)height;
f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
f9 = f7 + 1.0F / height;
wr.pos(0.0D, f9, 0.0D).tex(p_78439_1_, f8).normal(0, 1, 0).endVertex();
wr.pos(1.0D, f9, 0.0D).tex(p_78439_3_, f8).normal(0, 1, 0).endVertex();
wr.pos(1.0D, f9, 0.0F - thickness).tex(p_78439_3_, f8).normal(0, 1, 0).endVertex();
wr.pos(0.0D, f9, 0.0F - thickness).tex(p_78439_1_, f8).normal(0, 1, 0).endVertex();
}
tess.draw();
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
for (k = 0; k < height; ++k)
{
f7 = (float)k / (float)height;
f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
wr.pos(1.0D, f7, 0.0D).tex(p_78439_3_, f8).normal(0, -1, 0).endVertex();
wr.pos(0.0D, f7, 0.0D).tex(p_78439_1_, f8).normal(0, -1, 0).endVertex();
wr.pos(0.0D, f7, 0.0F - thickness).tex(p_78439_1_, f8).normal(0, -1, 0).endVertex();
wr.pos(1.0D, f7, 0.0F - thickness).tex(p_78439_3_, f8).normal(0, -1, 0).endVertex();
}
tess.draw();
*/
}
}
@@ -29,6 +29,7 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
import java.util.Arrays;
import java.util.List;
@@ -43,6 +44,7 @@ public final class RenderHelper {
public static final RenderType LINE_4;
public static final RenderType LINE_5;
public static final RenderType LINE_8;
public static final RenderType SPARK;
public static final RenderType LIGHT_RELAY;
public static final RenderType SPINNING_CUBE;
public static final RenderType SPINNING_CUBE_GHOST;
@@ -51,6 +53,7 @@ public final class RenderHelper {
public static final RenderType MANA_POOL_WATER;
public static final RenderType TERRA_PLATE;
public static final RenderType ENCHANTER;
public static final RenderType HALO;
// todo 1.15 AT's for necessary fields
static {
@@ -82,8 +85,9 @@ public final class RenderHelper {
glState = RenderType.State.builder().lineWidth(new RenderState.LineState(OptionalDouble.of(8))).layering(projectionLayering).transparency(translucentTransparency).writeMaskState(colorMask).build(false);
LINE_8 = RenderType.of(LibResources.PREFIX_MOD + "line_8", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 64, glState);
glState = RenderType.State.builder().texture(mipmapBlockAtlasTexture).transparency(translucentTransparency).alpha(new RenderState.AlphaState(0.05F)).build(true);
glState = RenderType.State.builder().texture(mipmapBlockAtlasTexture).transparency(translucentTransparency).alpha(new RenderState.AlphaState(0.05F)).lightmap(enableLightmap).build(true);
// todo 1.15: need normals?
SPARK = RenderType.of(LibResources.PREFIX_MOD + "spark", DefaultVertexFormats.POSITION_COLOR_TEXTURE_LIGHT, GL11.GL_QUADS, 256, glState);
LIGHT_RELAY = new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.HALO, null, RenderType.of(LibResources.PREFIX_MOD + "light_relay", DefaultVertexFormats.POSITION_COLOR_TEXTURE_LIGHT, GL11.GL_QUADS, 64, glState));
glState = RenderType.State.builder().texture(new RenderState.TextureState()).build(false);
@@ -102,6 +106,10 @@ public final class RenderHelper {
MANA_POOL_WATER = new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.MANA_POOL, null, ICON_OVERLAY);
TERRA_PLATE = new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.TERRA_PLATE, null, ICON_OVERLAY);
ENCHANTER = new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.ENCHANTER_RUNE, null, ICON_OVERLAY);
RenderState.TextureState haloTexture = new RenderState.TextureState(ItemFlightTiara.textureHalo, false, true);
glState = RenderType.State.builder().texture(haloTexture).transparency(translucentTransparency).cull(disableCull).shadeModel(smoothShade).build(true);
HALO = new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.HALO, null, RenderType.of(LibResources.PREFIX_MOD + "halo", DefaultVertexFormats.POSITION_TEX, GL11.GL_QUADS, 64, glState));
}
public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
@@ -10,9 +10,12 @@
*/
package vazkii.botania.client.render.entity;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -34,7 +37,7 @@ public class RenderCorporeaSpark extends RenderSparkBase<EntityCorporeaSpark> {
}
@Override
public void renderCallback(EntityCorporeaSpark entity, float pticks) {
public void renderCallback(EntityCorporeaSpark entity, float pticks, MatrixStack ms, IRenderTypeBuffer buffers) {
int time = entity.getItemDisplayTicks();
if(time == 0)
return;
@@ -45,16 +48,13 @@ public class RenderCorporeaSpark extends RenderSparkBase<EntityCorporeaSpark> {
if(stack.isEmpty())
return;
GlStateManager.pushMatrix();
GlStateManager.rotatef(90F, 1F, 0F, 0F);
ms.push();
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90));
float scalef = 1F / 6F;
GlStateManager.scalef(scalef, scalef, scalef);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
ms.scale(scalef, scalef, scalef);
GlStateManager.color4f(1F, 1F, 1F, absTime / 10);
GlStateManager.translatef(0F, 0F, -2F + (time < 0 ? -absTime : absTime) / 6);
ms.translate(0F, 0F, -2F + (time < 0 ? -absTime : absTime) / 6);
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
TextureAtlasSprite icon = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(stack, entity.world, null).getParticleTexture();
if(icon != null) {
@@ -70,20 +70,19 @@ public class RenderCorporeaSpark extends RenderSparkBase<EntityCorporeaSpark> {
int shift = pieces / 2;
float scale = 1F / pieces * 3F;
GlStateManager.scalef(scale, scale, 1F);
ms.scale(scale, scale, 1F);
for(int i = -shift; i < shift; i++) {
GlStateManager.translatef(gap * i, 0F, 0F);
ms.translate(gap * i, 0F, 0F);
for(int j = -shift; j < shift; j++) {
GlStateManager.translatef(0F, gap * j, 0F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), minU + stepU * (i + shift), minV + stepV * (j + shift + 1), minU + stepU * (i + shift + 1), minV + stepV * (j + shift), icon.getWidth() / pieces, icon.getHeight() / pieces, 1F / 8F);
GlStateManager.translatef(0F, -gap * j, 0F);
ms.translate(0F, gap * j, 0F);
// todo 1.15 do this another way IconHelper.renderIconIn3D(Tessellator.getInstance(), minU + stepU * (i + shift), minV + stepV * (j + shift + 1), minU + stepU * (i + shift + 1), minV + stepV * (j + shift), icon.getWidth() / pieces, icon.getHeight() / pieces, 1F / 8F);
ms.translate(0F, -gap * j, 0F);
}
GlStateManager.translatef(-gap * i, 0F, 0F);
ms.translate(-gap * i, 0F, 0F);
}
}
GlStateManager.disableBlend();
GlStateManager.popMatrix();
ms.pop();
}
}
@@ -10,7 +10,11 @@
*/
package vazkii.botania.client.render.entity;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
@@ -20,6 +24,7 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.core.proxy.ClientProxy;
import vazkii.botania.common.entity.EntitySparkBase;
@@ -34,75 +39,55 @@ public abstract class RenderSparkBase<T extends EntitySparkBase> extends EntityR
}
@Override
public void doRender(@Nonnull T tEntity, double par2, double par4, double par6, float par8, float par9) {
public void render(@Nonnull T tEntity, float yaw, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int light) {
TextureAtlasSprite iicon = getBaseIcon(tEntity);
GlStateManager.pushMatrix();
GlStateManager.translated(par2, par4, par6);
GlStateManager.enableRescaleNormal();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.alphaFunc(GL11.GL_GREATER, 0.05F);
double time = ClientTickHandler.ticksInGame + par9;
time += new Random(tEntity.getEntityId()).nextInt();
ms.push();
double time = ClientTickHandler.ticksInGame + partialTicks + new Random(tEntity.getEntityId()).nextInt();
float a = 0.1F + (tEntity.isInvisible() ? 0 : 1) * 0.8F;
GlStateManager.color4f(1F, 1F, 1F, (0.7F + 0.3F * (float) (Math.sin(time / 5.0) + 0.5) * 2) * a);
int alpha = (int) ((0.7F + 0.3F * (float) (Math.sin(time / 5.0) + 0.5) * 2) * a * 255.0F);
int iconColor = 0xFFFFFF | (alpha << 24);
float scale = 0.75F + 0.1F * (float) Math.sin(time / 10);
GlStateManager.scalef(scale, scale, scale);
bindEntityTexture(tEntity);
Tessellator tessellator = Tessellator.getInstance();
ms.scale(scale, scale, scale);
GlStateManager.pushMatrix();
float r = 180.0F - renderManager.playerViewY;
GlStateManager.rotatef(r, 0.0F, 1.0F, 0.0F);
GlStateManager.rotatef(-renderManager.playerViewX, 1F, 0F, 0F);
renderIcon(tessellator, iicon);
IVertexBuilder buffer = buffers.getBuffer(RenderHelper.SPARK);
ms.push();
ms.multiply(renderManager.getRotation());
renderIcon(ms, buffer, iicon, iconColor);
GlStateManager.pushMatrix();
GlStateManager.translatef(-0.02F + (float) Math.sin(time / 20) * 0.2F, 0.24F + (float) Math.cos(time / 20) * 0.2F, 0.005F);
GlStateManager.scalef(0.2F, 0.2F, 0.2F);
colorStar(tEntity, a);
renderIcon(tessellator, MiscellaneousIcons.INSTANCE.corporeaIconStar);
GlStateManager.popMatrix();
ms.push();
ms.translate(-0.02F + (float) Math.sin(time / 20) * 0.2F, 0.24F + (float) Math.cos(time / 20) * 0.2F, 0.005F);
ms.scale(0.2F, 0.2F, 0.2F);
int starColor = tEntity.getNetwork().colorValue | ((int) (a * 255.0F) << 24);
renderIcon(ms, buffer, MiscellaneousIcons.INSTANCE.corporeaIconStar, starColor);
ms.pop();
TextureAtlasSprite spinningIcon = getSpinningIcon(tEntity);
if (spinningIcon != null) {
GlStateManager.translatef(-0.02F + (float) Math.sin(time / 20) * -0.2F, 0.24F + (float) Math.cos(time / 20) * -0.2F, 0.005F);
GlStateManager.scalef(0.2F, 0.2F, 0.2F);
renderIcon(tessellator, spinningIcon);
ms.translate(-0.02F + (float) Math.sin(time / 20) * -0.2F, 0.24F + (float) Math.cos(time / 20) * -0.2F, 0.005F);
ms.scale(0.2F, 0.2F, 0.2F);
renderIcon(ms, buffer, spinningIcon, iconColor);
}
GlStateManager.popMatrix();
GlStateManager.color4f(1F, 1F, 1F, 1F);
renderCallback(tEntity, par9);
ms.pop();
renderCallback(tEntity, partialTicks, ms, buffers);
GlStateManager.disableBlend();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
ms.pop();
}
protected TextureAtlasSprite getBaseIcon(T entity) {
return MiscellaneousIcons.INSTANCE.sparkWorldIcon;
}
private void colorStar(T entity, float a) {
int hex = entity.getNetwork().colorValue;
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
GlStateManager.color4f(r / 255F, g / 255F, b / 255F, a);
}
@Nullable
protected TextureAtlasSprite getSpinningIcon(T entity) {
return null;
}
protected void renderCallback(T entity, float pticks) {}
protected void renderCallback(T entity, float pticks, MatrixStack ms, IRenderTypeBuffer buffers) {}
@Nonnull
@Override
@@ -110,7 +95,7 @@ public abstract class RenderSparkBase<T extends EntitySparkBase> extends EntityR
return AtlasTexture.LOCATION_BLOCKS_TEXTURE;
}
private void renderIcon(Tessellator tess, TextureAtlasSprite icon) {
private void renderIcon(MatrixStack ms, IVertexBuilder buffer, TextureAtlasSprite icon, int color) {
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
@@ -118,13 +103,17 @@ public abstract class RenderSparkBase<T extends EntitySparkBase> extends EntityR
float f4 = 1.0F;
float f5 = 0.5F;
float f6 = 0.25F;
int fullbright = 0xF000F0;
int a = (color >> 24) & 0xFF;
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
tess.getBuffer().begin(GL11.GL_QUADS, ClientProxy.POSITION_TEX_LMAP_NORMAL);
tess.getBuffer().pos(0.0F - f5, 0.0F - f6, 0.0D).tex(f, f3).lightmap(240, 240).normal(0.0F, 1.0F, 0.0F).endVertex();
tess.getBuffer().pos(f4 - f5, 0.0F - f6, 0.0D).tex(f1, f3).lightmap(240, 240).normal(0.0F, 1.0F, 0.0F).endVertex();
tess.getBuffer().pos(f4 - f5, f4 - f6, 0.0D).tex(f1, f2).lightmap(240, 240).normal(0.0F, 1.0F, 0.0F).endVertex();
tess.getBuffer().pos(0.0F - f5, f4 - f6, 0.0D).tex(f, f2).lightmap(240, 240).normal(0.0F, 1.0F, 0.0F).endVertex();
tess.draw();
Matrix4f mat = ms.peek().getModel();
buffer.vertex(mat, 0.0F - f5, 0.0F - f6, 0.0F).color(r, g, b, a).texture(f, f3).light(fullbright).endVertex();
buffer.vertex(mat, f4 - f5, 0.0F - f6, 0.0F).color(r, g, b, a).texture(f1, f3).light(fullbright).endVertex();
buffer.vertex(mat, f4 - f5, f4 - f6, 0.0F).color(r, g, b, a).texture(f1, f2).light(fullbright).endVertex();
buffer.vertex(mat, 0.0F - f5, f4 - f6, 0.0F).color(r, g, b, a).texture(f, f2).light(fullbright).endVertex();
}
}
@@ -11,12 +11,23 @@
package vazkii.botania.client.render.tile;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.block.AbstractSkullBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.SkullBlock;
import net.minecraft.block.WallSkullBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.model.GenericHeadModel;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.boss.WitherEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
@@ -25,37 +36,42 @@ import net.minecraft.entity.monster.SkeletonEntity;
import net.minecraft.entity.monster.WitherSkeletonEntity;
import net.minecraft.entity.monster.ZombieEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.tileentity.SkullTileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.core.helper.ShaderWrappedRenderLayer;
import vazkii.botania.client.render.entity.RenderDoppleganger;
import vazkii.botania.common.block.BlockGaiaHead;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
public class RenderTileGaiaHead extends SkullTileEntityRenderer {
private SkullTileEntityRenderer original = null;
private static final Map<SkullBlock.ISkullType, GenericHeadModel> MODELS = ObfuscationReflectionHelper.getPrivateValue(SkullTileEntityRenderer.class, null, "field_199358_e");
private static final Map<SkullBlock.ISkullType, ResourceLocation> SKINS = ObfuscationReflectionHelper.getPrivateValue(SkullTileEntityRenderer.class, null, "field_199357_d");
public RenderTileGaiaHead(TileEntityRendererDispatcher manager) {
super(manager);
}
@Override
public void render(float x, float y, float z, @Nullable Direction facing, float rotationIn, SkullBlock.ISkullType type, @Nullable GameProfile profile, int destroyStage, float animationProgress) {
// we overwrite the vanilla `instance` singleton in setRendererDispatcher, so call back to the original one if type isn't gaia
if (type != BlockGaiaHead.GAIA_TYPE) {
original.render(x, y, z, facing, rotationIn, type, profile, destroyStage, animationProgress);
return;
}
public void render(@Nullable SkullTileEntity skull, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int light, int overlay) {
// [VanillaCopy] super, but null safe and call our own render method with appropriate overridden type and profile
float f = skull == null ? 0 : skull.getAnimationProgress(partialTicks);
BlockState blockstate = skull == null ? null : skull.getBlockState();
boolean flag = blockstate != null && blockstate.getBlock() instanceof WallSkullBlock;
Direction direction = flag ? blockstate.get(WallSkullBlock.FACING) : null;
float f1 = 22.5F * (float)(flag ? (2 + direction.getHorizontalIndex()) * 4 : blockstate == null ? 0 : blockstate.get(SkullBlock.ROTATION));
Minecraft mc = Minecraft.getInstance();
Entity view = mc.getRenderViewEntity();
Entity view = Minecraft.getInstance().getRenderViewEntity();
SkullBlock.ISkullType type = SkullBlock.Types.PLAYER;
GameProfile profile = null;
profile = null;
type = SkullBlock.Types.PLAYER;
if(view instanceof PlayerEntity) {
profile = ((PlayerEntity) mc.getRenderViewEntity()).getGameProfile();
profile = ((PlayerEntity) view).getGameProfile();
} else if (view instanceof SkeletonEntity)
type = SkullBlock.Types.SKELETON;
else if(view instanceof WitherSkeletonEntity)
@@ -69,8 +85,51 @@ public class RenderTileGaiaHead extends SkullTileEntityRenderer {
else if(view instanceof EnderDragonEntity)
type = SkullBlock.Types.DRAGON;
ShaderHelper.useShader(ShaderHelper.BotaniaShader.DOPPLEGANGER, RenderDoppleganger.defaultCallback);
original.render(x, y, z, facing, rotationIn, type, profile, destroyStage, animationProgress);
ShaderHelper.releaseShader();
gaiaRender(direction, f1, type, profile, f, ms, buffers, light);
}
// [VanillaCopy] super, but calling our own method to get RenderType
private static void gaiaRender(@Nullable Direction facing, float rotation, SkullBlock.ISkullType type, @Nullable GameProfile profile, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int light) {
GenericHeadModel genericheadmodel = MODELS.get(type);
ms.push();
if (facing == null) {
ms.translate(0.5D, 0.0D, 0.5D);
} else {
switch(facing) {
case NORTH:
ms.translate(0.5D, 0.25D, (double)0.74F);
break;
case SOUTH:
ms.translate(0.5D, 0.25D, (double)0.26F);
break;
case WEST:
ms.translate((double)0.74F, 0.25D, 0.5D);
break;
case EAST:
default:
ms.translate((double)0.26F, 0.25D, 0.5D);
}
}
ms.scale(-1.0F, -1.0F, 1.0F);
IVertexBuilder ivertexbuilder = buffers.getBuffer(layerFor(type, profile));
genericheadmodel.render(partialTicks, rotation, 0.0F);
genericheadmodel.render(ms, ivertexbuilder, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
ms.pop();
}
// [VanillaCopy] super but wrapped in a shader
private static RenderType layerFor(SkullBlock.ISkullType type, @Nullable GameProfile profile) {
RenderType base;
ResourceLocation resourcelocation = SKINS.get(type);
if (type == SkullBlock.Types.PLAYER && profile != null) {
Minecraft minecraft = Minecraft.getInstance();
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = minecraft.getSkinManager().loadSkinFromCache(profile);
base = map.containsKey(MinecraftProfileTexture.Type.SKIN) ? RenderType.getEntityTranslucent(minecraft.getSkinManager().loadSkin(map.get(MinecraftProfileTexture.Type.SKIN), MinecraftProfileTexture.Type.SKIN)) : RenderType.getEntityCutoutNoCull(DefaultPlayerSkin.getDefaultSkin(PlayerEntity.getUUID(profile)));
} else {
base = RenderType.getEntityCutoutNoCull(resourcelocation);
}
return new ShaderWrappedRenderLayer(ShaderHelper.BotaniaShader.DOPPLEGANGER, RenderDoppleganger.defaultCallback, base);
}
}
@@ -337,7 +337,7 @@ public class RenderTileTinyPotato extends TileEntityRenderer<TileTinyPotato> {
ms.scale(1.5F, 1.5F, 1.5F);
ms.translate(0F, -0.8F, 0F);
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90));
ItemFlightTiara.renderHalo(null, partialTicks);
ItemFlightTiara.renderHalo(null, ms, buffers, partialTicks);
} else if (name.equals("kingdaddydmac")) {
ms.scale(0.5F, 0.5F, 0.5F);
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180));
@@ -18,6 +18,7 @@ import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.Rarity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
@@ -97,6 +98,7 @@ import vazkii.botania.common.block.tile.string.TileRedStringDispenser;
import vazkii.botania.common.block.tile.string.TileRedStringFertilizer;
import vazkii.botania.common.block.tile.string.TileRedStringInterceptor;
import vazkii.botania.common.block.tile.string.TileRedStringRelay;
import vazkii.botania.common.item.ItemGaiaHead;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.block.ItemBlockDreamwood;
import vazkii.botania.common.item.block.ItemBlockElven;
@@ -819,6 +821,8 @@ public final class ModBlocks {
register(r, new ItemBlockMod(brewery, props), brewery.getRegistryName());
register(r, new ItemBlockMod(corporeaIndex, props), corporeaIndex.getRegistryName());
register(r, new ItemBlockMod(hourglass, props), hourglass.getRegistryName());
Item head = new ItemGaiaHead(gaiaHead, gaiaHeadWall, ModItems.defaultBuilder().rarity(Rarity.UNCOMMON));
register(r, head, gaiaHead.getRegistryName());
return null;
}
@@ -835,6 +839,8 @@ public final class ModBlocks {
register(r, new ItemBlockMod(brewery, ModItems.defaultBuilder().setTEISR(() -> () -> new TEISR(ModBlocks.brewery, TileBrewery.TYPE))), brewery.getRegistryName());
register(r, new ItemBlockMod(corporeaIndex, ModItems.defaultBuilder().setTEISR(() -> () -> new TEISR(ModBlocks.corporeaIndex, TileCorporeaIndex.TYPE))), corporeaIndex.getRegistryName());
register(r, new ItemBlockMod(hourglass, ModItems.defaultBuilder().setTEISR(() -> () -> new TEISR(ModBlocks.hourglass, TileHourglass.TYPE))), hourglass.getRegistryName());
Item head = new ItemGaiaHead(gaiaHead, gaiaHeadWall, ModItems.defaultBuilder().rarity(Rarity.UNCOMMON).setTEISR(() -> () -> new TEISR(ModBlocks.gaiaHead, TileGaiaHead.TYPE)));
register(r, head, gaiaHead.getRegistryName());
return null;
}
@@ -233,8 +233,9 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
if (prop.getName().equals("facing") && prop.getValueClass() == Direction.class) {
IProperty<Direction> facingProp = (IProperty<Direction>) prop;
Direction newDir = old.get(facingProp).rotateAround(axis);
if (facingProp.getAllowedValues().contains(newDir)) {
Direction oldDir = old.get(facingProp);
Direction newDir = rotateAround(oldDir, axis);
if (oldDir != newDir && facingProp.getAllowedValues().contains(newDir)) {
return old.with(facingProp, newDir);
}
}
@@ -243,6 +244,40 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
return old.rotate(Rotation.CLOCKWISE_90);
}
private static Direction rotateAround(Direction old, Direction.Axis axis) {
switch (axis) {
case X: {
switch (old) {
case DOWN: return Direction.SOUTH;
case SOUTH: return Direction.UP;
case UP: return Direction.NORTH;
case NORTH: return Direction.DOWN;
}
break;
}
case Y: {
switch (old) {
case NORTH: return Direction.EAST;
case EAST: return Direction.SOUTH;
case SOUTH: return Direction.WEST;
case WEST: return Direction.NORTH;
}
break;
}
case Z: {
switch (old) {
case DOWN: return Direction.WEST;
case WEST: return Direction.UP;
case UP: return Direction.EAST;
case EAST: return Direction.DOWN;
}
break;
}
}
return old;
}
public static void doParticleBeamWithOffset(World world, BlockPos orig, BlockPos end) {
Vec3d origOffset = world.getBlockState(orig).getOffset(world, orig);
Vector3 vorig = new Vector3(orig.getX() + origOffset.getX() + 0.5, orig.getY() + origOffset.getY() + 0.5, orig.getZ() + origOffset.getZ() + 0.5);
@@ -709,8 +709,6 @@ public final class ModItems {
register(r, new ItemManaweaveArmor(EquipmentSlotType.LEGS, unstackable()), LibItemNames.MANAWEAVE_LEGS);
register(r, new ItemManaweaveArmor(EquipmentSlotType.FEET, unstackable()), LibItemNames.MANAWEAVE_BOOTS);
register(r, new ItemAutocraftingHalo(unstackable()), LibItemNames.AUTOCRAFTING_HALO);
Item head = new ItemGaiaHead(ModBlocks.gaiaHead, ModBlocks.gaiaHeadWall, defaultBuilder().rarity(Rarity.UNCOMMON));
register(r, head, ModBlocks.gaiaHead.getRegistryName());
register(r, new ItemSextant(unstackable()), LibItemNames.SEXTANT);
register(r, new ItemSpeedUpBelt(unstackable()), LibItemNames.SPEED_UP_BELT);
register(r, new ItemBaubleBox(unstackable()), LibItemNames.BAUBLE_BOX);
@@ -18,6 +18,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.renderer.Atlases;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.IBakedModel;
@@ -63,6 +64,7 @@ import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.item.ModItems;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -70,7 +72,7 @@ import java.util.List;
public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
private static final ResourceLocation textureHud = new ResourceLocation(LibResources.GUI_HUD_ICONS);
private static final ResourceLocation textureHalo = new ResourceLocation(LibResources.MISC_HALO);
public static final ResourceLocation textureHalo = new ResourceLocation(LibResources.MISC_HALO);
private static final String TAG_VARIANT = "variant";
private static final String TAG_FLYING = "flying";
@@ -412,44 +414,27 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
ms.pop();
if(meta == 1)
renderHalo(player, partialTicks);
renderHalo(player, ms, buffers, partialTicks);
}
}
@OnlyIn(Dist.CLIENT)
public static void renderHalo(LivingEntity player, float partialTicks) {
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, 240, 240);
GlStateManager.disableLighting();
GlStateManager.disableCull();
GlStateManager.color4f(1F, 1F, 1F, 1F);
Minecraft.getInstance().textureManager.bindTexture(textureHalo);
public static void renderHalo(@Nullable LivingEntity player, MatrixStack ms, IRenderTypeBuffer buffers, float partialTicks) {
if(player != null)
AccessoryRenderHelper.translateToHeadLevel(player, partialTicks);
GlStateManager.translatef(0, 1.5F, 0);
GlStateManager.rotatef(30, 1, 0, -1);
GlStateManager.translatef(-0.1F, -0.5F, -0.1F);
ms.translate(0, 1.5F, 0);
ms.multiply(new Vector3f(1, 0, -1).getDegreesQuaternion(30));
ms.translate(-0.1F, -0.5F, -0.1F);
if(player != null)
GlStateManager.rotatef(player.ticksExisted + partialTicks, 0, 1, 0);
else GlStateManager.rotatef(Botania.proxy.getWorldElapsedTicks(), 0, 1, 0);
Tessellator tes = Tessellator.getInstance();
ShaderHelper.useShader(ShaderHelper.BotaniaShader.HALO);
tes.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
tes.getBuffer().pos(-0.75, 0, -0.75).tex(0, 0).endVertex();
tes.getBuffer().pos(-0.75, 0, 0.75).tex(0, 1).endVertex();
tes.getBuffer().pos(0.75, 0, 0.75).tex(1, 1).endVertex();
tes.getBuffer().pos(0.75, 0, -0.75).tex(1, 0).endVertex();
tes.draw();
ShaderHelper.releaseShader();
GlStateManager.enableLighting();
GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.enableCull();
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(player.ticksExisted + partialTicks));
else ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(Botania.proxy.getWorldElapsedTicks()));
IVertexBuilder buffer = buffers.getBuffer(RenderHelper.HALO);
Matrix4f mat = ms.peek().getModel();
buffer.vertex(mat, -0.75F, 0, -0.75F).texture(0, 0).endVertex();
buffer.vertex(mat, -0.75F, 0, 0.75F).texture(0, 1).endVertex();
buffer.vertex(mat, 0.75F, 0, 0.75F).texture(1, 1).endVertex();
buffer.vertex(mat, 0.75F, 0, -0.75F).texture(1, 0).endVertex();
}
@OnlyIn(Dist.CLIENT)