fix liquid normals
This commit is contained in:
parent
9b0bc17a95
commit
2f010b35c9
3 changed files with 108 additions and 205 deletions
|
@ -3272,31 +3272,6 @@ public class Renderer {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean renderBlock(State state, BlockPos pos, IWorldAccess world, RenderBuffer rb) {
|
||||
Block block = state.getBlock();
|
||||
if(this.gm.xrayActive && !block.isXrayVisible())
|
||||
return false;
|
||||
if(block == Blocks.air)
|
||||
return false;
|
||||
else if(block.getMaterial().isLiquid())
|
||||
return this.renderFluid(world, state, pos, rb);
|
||||
IBakedModel model = this.getBlockModel(state, world, pos);
|
||||
block.setBlockBounds(world, pos);
|
||||
return this.renderModel(world, model, state, pos, rb, !this.gm.xrayActive);
|
||||
}
|
||||
|
||||
public IBakedModel getBlockModel(State state, IWorldAccess world, BlockPos pos) {
|
||||
Block block = state.getBlock();
|
||||
if(!this.gm.debugWorld) {
|
||||
try {
|
||||
state = block.getState(state, world, pos);
|
||||
}
|
||||
catch(Exception e) {
|
||||
}
|
||||
}
|
||||
return this.manager.getModelForState(state);
|
||||
}
|
||||
|
||||
public void renderBlockEntity(State state, float brightness)
|
||||
{
|
||||
if (state.getBlock() != Blocks.air && !state.getBlock().getMaterial().isLiquid())
|
||||
|
@ -3328,6 +3303,46 @@ public class Renderer {
|
|||
Tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean renderBlock(State state, BlockPos pos, IWorldAccess world, RenderBuffer rb) {
|
||||
Block block = state.getBlock();
|
||||
if(this.gm.xrayActive && !block.isXrayVisible())
|
||||
return false;
|
||||
if(block == Blocks.air)
|
||||
return false;
|
||||
else if(block.getMaterial().isLiquid())
|
||||
return this.renderFluid(world, state, pos, rb);
|
||||
State mstate = state;
|
||||
if(!this.gm.debugWorld) {
|
||||
try {
|
||||
mstate = block.getState(state, world, pos);
|
||||
}
|
||||
catch(Exception e) {
|
||||
}
|
||||
}
|
||||
IBakedModel model = this.manager.getModelForState(mstate);
|
||||
block.setBlockBounds(world, pos);
|
||||
boolean checkSides = !this.gm.xrayActive;
|
||||
boolean rendered = false;
|
||||
BitSet bounds = new BitSet(3);
|
||||
for(Facing side : Facing.values()) {
|
||||
List<BakedQuad> list = model.getFace(side);
|
||||
if(!list.isEmpty()) {
|
||||
BlockPos bpos = pos.offset(side);
|
||||
if(!checkSides || block.canRender(world, bpos, side)) {
|
||||
int light = getLightmapValue(world, bpos);
|
||||
this.renderModelStandardQuads(world, block, pos, side, light, false, rb, list, bounds);
|
||||
rendered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<BakedQuad> list = model.getQuads();
|
||||
if(list.size() > 0) {
|
||||
this.renderModelStandardQuads(world, block, pos, null, -1, true, rb, list, bounds);
|
||||
rendered = true;
|
||||
}
|
||||
return rendered;
|
||||
}
|
||||
|
||||
private static final int getLightmapValue(IWorldAccess world, BlockPos pos) {
|
||||
Block block = world.getState(pos).getBlock();
|
||||
|
@ -3350,40 +3365,6 @@ public class Renderer {
|
|||
return (k > l ? k : l) | (i1 > j1 ? i1 : j1) << 16;
|
||||
}
|
||||
|
||||
public boolean renderModel(IWorldAccess blockAccessIn, IBakedModel modelIn, State blockStateIn, BlockPos blockPosIn, RenderBuffer worldRendererIn, boolean checkSides)
|
||||
{
|
||||
Block blockIn = blockStateIn.getBlock();
|
||||
boolean flag = false;
|
||||
BitSet bitset = new BitSet(3);
|
||||
|
||||
for (Facing enumfacing : Facing.values())
|
||||
{
|
||||
List<BakedQuad> list = modelIn.getFace(enumfacing);
|
||||
|
||||
if (!list.isEmpty())
|
||||
{
|
||||
BlockPos blockpos = blockPosIn.offset(enumfacing);
|
||||
|
||||
if (!checkSides || blockIn.canRender(blockAccessIn, blockpos, enumfacing))
|
||||
{
|
||||
int i = getLightmapValue(blockAccessIn, blockpos);
|
||||
this.renderModelStandardQuads(blockAccessIn, blockIn, blockPosIn, enumfacing, i, false, worldRendererIn, list, bitset);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<BakedQuad> list1 = modelIn.getQuads();
|
||||
|
||||
if (list1.size() > 0)
|
||||
{
|
||||
this.renderModelStandardQuads(blockAccessIn, blockIn, blockPosIn, (Facing)null, -1, true, worldRendererIn, list1, bitset);
|
||||
flag = true;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void renderModelStandardQuads(IWorldAccess blockAccessIn, Block blockIn, BlockPos blockPosIn, Facing faceIn, int brightnessIn, boolean ownBrightness, RenderBuffer worldRendererIn, List<BakedQuad> listQuadsIn, BitSet boundsFlags)
|
||||
{
|
||||
double d0 = (double)blockPosIn.getX();
|
||||
|
@ -3483,21 +3464,17 @@ public class Renderer {
|
|||
BlockLiquid blockliquid = (BlockLiquid)blockStateIn.getBlock();
|
||||
blockliquid.setBlockBounds(blockAccess, blockPosIn);
|
||||
Sprite[] atextureatlassprite = this.fluids.get(blockliquid);
|
||||
boolean flag = blockliquid.canRender(blockAccess, blockPosIn.up(), Facing.UP);
|
||||
boolean flag1 = blockliquid.canRender(blockAccess, blockPosIn.down(), Facing.DOWN);
|
||||
boolean up = blockliquid.canRender(blockAccess, blockPosIn.up(), Facing.UP);
|
||||
boolean down = blockliquid.canRender(blockAccess, blockPosIn.down(), Facing.DOWN);
|
||||
boolean[] aboolean = new boolean[] {blockliquid.canRender(blockAccess, blockPosIn.north(), Facing.NORTH), blockliquid.canRender(blockAccess, blockPosIn.south(), Facing.SOUTH), blockliquid.canRender(blockAccess, blockPosIn.west(), Facing.WEST), blockliquid.canRender(blockAccess, blockPosIn.east(), Facing.EAST)};
|
||||
|
||||
if (!flag && !flag1 && !aboolean[0] && !aboolean[1] && !aboolean[2] && !aboolean[3])
|
||||
if (!up && !down && !aboolean[0] && !aboolean[1] && !aboolean[2] && !aboolean[3])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean flag2 = false;
|
||||
float f3 = 0.5F;
|
||||
float f4 = 1.0F;
|
||||
float f5 = 0.8F;
|
||||
float f6 = 0.6F;
|
||||
boolean rendered = false;
|
||||
float f7 = this.getFluidHeight(blockAccess, blockPosIn);
|
||||
float f8 = this.getFluidHeight(blockAccess, blockPosIn.south());
|
||||
float f9 = this.getFluidHeight(blockAccess, blockPosIn.east().south());
|
||||
|
@ -3507,9 +3484,9 @@ public class Renderer {
|
|||
double d2 = (double)blockPosIn.getZ();
|
||||
float f11 = 0.001F;
|
||||
|
||||
if (flag)
|
||||
if (up)
|
||||
{
|
||||
flag2 = true;
|
||||
rendered = true;
|
||||
Sprite textureatlassprite = atextureatlassprite[0];
|
||||
float f12 = (float)BlockLiquid.getFlowDirection(blockAccess, blockPosIn, blockliquid);
|
||||
|
||||
|
@ -3560,24 +3537,21 @@ public class Renderer {
|
|||
int k2 = getLightmapValueLiquid(blockAccess, blockPosIn);
|
||||
int l2 = k2 >> 16 & 65535;
|
||||
int i3 = k2 & 65535;
|
||||
float f24 = f4;
|
||||
float f25 = f4;
|
||||
float f26 = f4;
|
||||
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(f24, f25, f26, 0.5F).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(f24, f25, f26, 0.5F).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(f24, f25, f26, 0.5F).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(f24, f25, f26, 0.5F).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
|
||||
|
||||
if (blockliquid.shouldRenderSides(blockAccess, blockPosIn.up()))
|
||||
{
|
||||
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(f24, f25, f26, 0.5F).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(f24, f25, f26, 0.5F).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(f24, f25, f26, 0.5F).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(f24, f25, f26, 0.5F).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex();
|
||||
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(0.0f, 1.0f, 0.0f, 0.5F).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
if (down)
|
||||
{
|
||||
float f35 = atextureatlassprite[0].getMinU();
|
||||
float f36 = atextureatlassprite[0].getMaxU();
|
||||
|
@ -3586,34 +3560,34 @@ public class Renderer {
|
|||
int l1 = getLightmapValueLiquid(blockAccess, blockPosIn.down());
|
||||
int i2 = l1 >> 16 & 65535;
|
||||
int j2 = l1 & 65535;
|
||||
worldRendererIn.pos(d0, d1, d2 + 1.0D).color(f3, f3, f3, 0.5F).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex();
|
||||
worldRendererIn.pos(d0, d1, d2).color(f3, f3, f3, 0.5F).tex((double)f35, (double)f37).lightmap(i2, j2).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1, d2).color(f3, f3, f3, 0.5F).tex((double)f36, (double)f37).lightmap(i2, j2).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(f3, f3, f3, 0.5F).tex((double)f36, (double)f38).lightmap(i2, j2).endVertex();
|
||||
flag2 = true;
|
||||
worldRendererIn.pos(d0, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, 0.25F).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex();
|
||||
worldRendererIn.pos(d0, d1, d2).color(0.0f, -1.0f, 0.0f, 0.25F).tex((double)f35, (double)f37).lightmap(i2, j2).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1, d2).color(0.0f, -1.0f, 0.0f, 0.25F).tex((double)f36, (double)f37).lightmap(i2, j2).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, 0.25F).tex((double)f36, (double)f38).lightmap(i2, j2).endVertex();
|
||||
rendered = true;
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < 4; ++i1)
|
||||
for (int np = 0; np < 4; ++np)
|
||||
{
|
||||
int j1 = 0;
|
||||
int k1 = 0;
|
||||
|
||||
if (i1 == 0)
|
||||
if (np == 0)
|
||||
{
|
||||
--k1;
|
||||
}
|
||||
|
||||
if (i1 == 1)
|
||||
if (np == 1)
|
||||
{
|
||||
++k1;
|
||||
}
|
||||
|
||||
if (i1 == 2)
|
||||
if (np == 2)
|
||||
{
|
||||
--j1;
|
||||
}
|
||||
|
||||
if (i1 == 3)
|
||||
if (np == 3)
|
||||
{
|
||||
++j1;
|
||||
}
|
||||
|
@ -3621,7 +3595,7 @@ public class Renderer {
|
|||
BlockPos blockpos = blockPosIn.add(j1, 0, k1);
|
||||
Sprite textureatlassprite1 = atextureatlassprite[1];
|
||||
|
||||
if (aboolean[i1])
|
||||
if (aboolean[np])
|
||||
{
|
||||
float f39;
|
||||
float f40;
|
||||
|
@ -3630,7 +3604,7 @@ public class Renderer {
|
|||
double d5;
|
||||
double d6;
|
||||
|
||||
if (i1 == 0)
|
||||
if (np == 0)
|
||||
{
|
||||
f39 = f7;
|
||||
f40 = f10;
|
||||
|
@ -3639,7 +3613,7 @@ public class Renderer {
|
|||
d4 = d2 + (double)f11;
|
||||
d6 = d2 + (double)f11;
|
||||
}
|
||||
else if (i1 == 1)
|
||||
else if (np == 1)
|
||||
{
|
||||
f39 = f9;
|
||||
f40 = f8;
|
||||
|
@ -3648,7 +3622,7 @@ public class Renderer {
|
|||
d4 = d2 + 1.0D - (double)f11;
|
||||
d6 = d2 + 1.0D - (double)f11;
|
||||
}
|
||||
else if (i1 == 2)
|
||||
else if (np == 2)
|
||||
{
|
||||
f39 = f8;
|
||||
f40 = f7;
|
||||
|
@ -3667,7 +3641,7 @@ public class Renderer {
|
|||
d6 = d2 + 1.0D;
|
||||
}
|
||||
|
||||
flag2 = true;
|
||||
rendered = true;
|
||||
float f41 = textureatlassprite1.getInterpolatedU(0.0D);
|
||||
float f27 = textureatlassprite1.getInterpolatedU(8.0D);
|
||||
float f28 = textureatlassprite1.getInterpolatedV((double)((1.0F - f39) * 16.0F * 0.5F));
|
||||
|
@ -3676,22 +3650,21 @@ public class Renderer {
|
|||
int j = getLightmapValueLiquid(blockAccess, blockpos);
|
||||
int k = j >> 16 & 65535;
|
||||
int l = j & 65535;
|
||||
float f31 = i1 < 2 ? f5 : f6;
|
||||
float f32 = f4 * f31;
|
||||
float f33 = f4 * f31;
|
||||
float f34 = f4 * f31;
|
||||
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(f32, f33, f34, 0.5F).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(f32, f33, f34, 0.5F).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(f32, f33, f34, 0.5F).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(f32, f33, f34, 0.5F).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(f32, f33, f34, 0.5F).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(f32, f33, f34, 0.5F).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(f32, f33, f34, 0.5F).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(f32, f33, f34, 0.5F).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
|
||||
float xn = np == 2 ? -1.0f : (np == 3 ? 1.0f : 0.0f);
|
||||
float zn = np == 0 ? -1.0f : (np == 1 ? 1.0f : 0.0f);
|
||||
float br = np < 2 ? 0.4f : 0.3f;
|
||||
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, br).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, br).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
return flag2;
|
||||
return rendered;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,62 +15,21 @@ public class RenderBlockEntity extends Render<Entity>
|
|||
public RenderBlockEntity(RenderManager renderManagerIn, State state)
|
||||
{
|
||||
super(renderManagerIn);
|
||||
// this.shadowSize = 0.5F;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the desired {@code T} type Entity.
|
||||
*/
|
||||
public void doRender(Entity entity, double x, double y, double z, float partialTicks)
|
||||
{
|
||||
// if(entity.isInvisible()) {
|
||||
// return;
|
||||
// }
|
||||
GL46.glPushMatrix();
|
||||
GL46.glTranslatef((float)x, (float)y + 0.5F, (float)z);
|
||||
|
||||
// if ((float)entity.fuse - partialTicks + 1.0F < 10.0F)
|
||||
// {
|
||||
// float f = 1.0F - ((float)entity.fuse - partialTicks + 1.0F) / 10.0F;
|
||||
// f = MathHelper.clamp_float(f, 0.0F, 1.0F);
|
||||
// f = f * f;
|
||||
// f = f * f;
|
||||
// float f1 = 1.0F + f * 0.3F;
|
||||
// GlStateManager.scale(f1, f1, f1);
|
||||
// }
|
||||
|
||||
// float f2 = (1.0F - ((float)entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
|
||||
this.bindEntityTexture(entity);
|
||||
GL46.glTranslatef(-0.5F, -0.5F, 0.5F);
|
||||
Client.CLIENT.renderer.renderBlockEntity(this.state, getBrightness(entity));
|
||||
GL46.glTranslatef(0.0F, 0.0F, 1.0F);
|
||||
|
||||
// if (entity.fuse / 5 % 2 == 0)
|
||||
// {
|
||||
// GlStateManager.disableTexture2D();
|
||||
// GlStateManager.disableLighting();
|
||||
// GlStateManager.enableBlend();
|
||||
// GlStateManager.blendFunc(GL46.GL_SRC_ALPHA, GL46.GL_DST_ALPHA);
|
||||
// GlStateManager.color(1.0F, 1.0F, 1.0F, f2);
|
||||
// GlStateManager.doPolygonOffset(-3.0F, -3.0F);
|
||||
// GlStateManager.enablePolygonOffset();
|
||||
// blockrendererdispatcher.renderBlockBrightness(state, 1.0F);
|
||||
// GlStateManager.doPolygonOffset(0.0F, 0.0F);
|
||||
// GlStateManager.disablePolygonOffset();
|
||||
// GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// GlStateManager.disableBlend();
|
||||
// GlStateManager.enableLighting();
|
||||
// GlStateManager.enableTexture2D();
|
||||
// }
|
||||
|
||||
GL46.glPopMatrix();
|
||||
super.doRender(entity, x, y, z, partialTicks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
|
||||
*/
|
||||
protected String getEntityTexture(Entity entity)
|
||||
{
|
||||
return TextureMap.BLOCKS;
|
||||
|
|
|
@ -3,12 +3,6 @@ package client.renderer.entity;
|
|||
import org.lwjgl.opengl.GL46;
|
||||
|
||||
import client.Client;
|
||||
import client.renderer.DefaultVertexFormats;
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.RenderBuffer;
|
||||
import client.renderer.Renderer;
|
||||
import client.renderer.Tessellator;
|
||||
import client.renderer.blockmodel.IBakedModel;
|
||||
import client.renderer.texture.TextureMap;
|
||||
import common.block.Block;
|
||||
import common.entity.item.EntityFalling;
|
||||
|
@ -17,56 +11,33 @@ import common.util.BlockPos;
|
|||
import common.world.State;
|
||||
import common.world.World;
|
||||
|
||||
public class RenderFallingBlock extends Render<EntityFalling>
|
||||
{
|
||||
public RenderFallingBlock(RenderManager renderManagerIn)
|
||||
{
|
||||
super(renderManagerIn);
|
||||
// this.shadowSize = 0.5F;
|
||||
}
|
||||
public class RenderFallingBlock extends Render<EntityFalling> {
|
||||
public RenderFallingBlock(RenderManager renderManagerIn) {
|
||||
super(renderManagerIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the desired {@code T} type Entity.
|
||||
*/
|
||||
public void doRender(EntityFalling entity, double x, double y, double z, float partialTicks)
|
||||
{
|
||||
if (entity.getBlock() != null)
|
||||
{
|
||||
this.bindTexture(TextureMap.BLOCKS);
|
||||
State state = entity.getBlock();
|
||||
Block block = state.getBlock();
|
||||
BlockPos pos = new BlockPos(entity);
|
||||
World world = entity.getWorldObj();
|
||||
public void doRender(EntityFalling entity, double x, double y, double z, float partialTicks) {
|
||||
if(entity.getBlock() != null) {
|
||||
State state = entity.getBlock();
|
||||
Block block = state.getBlock();
|
||||
BlockPos pos = new BlockPos(entity);
|
||||
World world = entity.getWorldObj();
|
||||
|
||||
if (state != world.getState(pos) && block != Blocks.air && !block.getMaterial().isLiquid())
|
||||
{
|
||||
GL46.glPushMatrix();
|
||||
GL46.glTranslatef((float)x, (float)y, (float)z);
|
||||
GlState.disableLighting();
|
||||
// Tessellator tessellator = Tessellator.getInstance();
|
||||
RenderBuffer rb = Tessellator.getBuffer();
|
||||
rb.begin(GL46.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
int i = pos.getX();
|
||||
int j = pos.getY();
|
||||
int k = pos.getZ();
|
||||
rb.setTranslation((double)((float)(-i) - 0.5F), (double)(-j), (double)((float)(-k) - 0.5F));
|
||||
Renderer renderer = Client.CLIENT.renderer;
|
||||
IBakedModel model = renderer.getBlockModel(state, world, null);
|
||||
renderer.renderModel(world, model, state, pos, rb, false);
|
||||
rb.setTranslation(0.0D, 0.0D, 0.0D);
|
||||
Tessellator.draw();
|
||||
GlState.enableLighting();
|
||||
GL46.glPopMatrix();
|
||||
super.doRender(entity, x, y, z, partialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(state != world.getState(pos) && block != Blocks.air && !block.getMaterial().isLiquid()) {
|
||||
|
||||
/**
|
||||
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
|
||||
*/
|
||||
protected String getEntityTexture(EntityFalling entity)
|
||||
{
|
||||
return TextureMap.BLOCKS;
|
||||
}
|
||||
GL46.glPushMatrix();
|
||||
GL46.glTranslatef((float)x, (float)y + 0.5F, (float)z);
|
||||
this.bindEntityTexture(entity);
|
||||
GL46.glTranslatef(-0.5F, -0.5F, 0.5F);
|
||||
Client.CLIENT.renderer.renderBlockEntity(state, getBrightness(entity));
|
||||
GL46.glTranslatef(0.0F, 0.0F, 1.0F);
|
||||
GL46.glPopMatrix();
|
||||
super.doRender(entity, x, y, z, partialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getEntityTexture(EntityFalling entity) {
|
||||
return TextureMap.BLOCKS;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue