add non-blocks >:)>>
This commit is contained in:
parent
1bda487487
commit
aabe877c85
2 changed files with 238 additions and 0 deletions
|
@ -35,11 +35,13 @@ import client.renderer.texture.TextureMap;
|
|||
import client.renderer.tileentity.SpecialRenderer;
|
||||
import client.world.ChunkClient;
|
||||
import common.block.Block;
|
||||
import common.block.BlockFalling;
|
||||
import common.block.Material;
|
||||
import common.block.artificial.BlockSlab;
|
||||
import common.block.liquid.BlockDynamicLiquid;
|
||||
import common.block.liquid.BlockLiquid;
|
||||
import common.block.liquid.BlockStaticLiquid;
|
||||
import common.block.tech.BlockAnvil;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.collect.Sets;
|
||||
|
@ -116,6 +118,7 @@ public class Renderer {
|
|||
private final Set<TileEntity> setTileEntities = Sets.<TileEntity>newHashSet();
|
||||
private final Map<BlockPos, Sound> mapSoundPositions = Maps.<BlockPos, Sound>newHashMap();
|
||||
private final Map<BlockLiquid, Sprite[]> fluids = Maps.newHashMap();
|
||||
private final Map<Block, Sprite> dynamic = Maps.newHashMap();
|
||||
|
||||
private float farPlaneDistance;
|
||||
private int rendererUpdateCount;
|
||||
|
@ -1804,6 +1807,12 @@ public class Renderer {
|
|||
this.fluids.put(liquid.second(), sprites);
|
||||
this.fluids.put(liquid.first(), sprites);
|
||||
}
|
||||
for(Block block : BlockRegistry.blocks()) {
|
||||
if(block instanceof BlockFalling && !(block instanceof BlockAnvil)) {
|
||||
String name = BlockRegistry.getName(block);
|
||||
this.dynamic.put(block, texturemap.getAtlasSprite("blocks/" + name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void generateSky2()
|
||||
|
@ -3326,6 +3335,8 @@ public class Renderer {
|
|||
return false;
|
||||
else if(block.getMaterial().isLiquid())
|
||||
return this.renderFluid(world, state, pos, rb);
|
||||
else if(block instanceof BlockFalling && !(block instanceof BlockAnvil))
|
||||
return this.renderDynamic(world, state, pos, rb);
|
||||
State mstate = state;
|
||||
if(!this.gm.debugWorld) {
|
||||
try {
|
||||
|
@ -3725,4 +3736,227 @@ public class Renderer {
|
|||
|
||||
return 1.0F - f / (float)i;
|
||||
}
|
||||
|
||||
private boolean renderDynamic(IWorldAccess blockAccess, State blockStateIn, BlockPos blockPosIn, RenderBuffer worldRendererIn)
|
||||
{
|
||||
Block block = blockStateIn.getBlock();
|
||||
block.setBlockBounds(blockAccess, blockPosIn);
|
||||
Sprite textureatlassprite = this.dynamic.get(block);
|
||||
boolean up = block.canRender(blockAccess, blockPosIn.up(), Facing.UP);
|
||||
boolean down = block.canRender(blockAccess, blockPosIn.down(), Facing.DOWN);
|
||||
boolean[] aboolean = new boolean[] {block.canRender(blockAccess, blockPosIn.north(), Facing.NORTH), block.canRender(blockAccess, blockPosIn.south(), Facing.SOUTH), block.canRender(blockAccess, blockPosIn.west(), Facing.WEST), block.canRender(blockAccess, blockPosIn.east(), Facing.EAST)};
|
||||
float shine = (block.getShinyness() / 32.0f) * 0.5f;
|
||||
|
||||
if (!up && !down && !aboolean[0] && !aboolean[1] && !aboolean[2] && !aboolean[3])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean rendered = false;
|
||||
float f7 = this.getAdjacentHeight(blockAccess, blockPosIn, block);
|
||||
float f8 = this.getAdjacentHeight(blockAccess, blockPosIn.south(), block);
|
||||
float f9 = this.getAdjacentHeight(blockAccess, blockPosIn.east().south(), block);
|
||||
float f10 = this.getAdjacentHeight(blockAccess, blockPosIn.east(), block);
|
||||
double d0 = (double)blockPosIn.getX();
|
||||
double d1 = (double)blockPosIn.getY();
|
||||
double d2 = (double)blockPosIn.getZ();
|
||||
float f11 = 0.001F;
|
||||
|
||||
if (up)
|
||||
{
|
||||
rendered = true;
|
||||
|
||||
f7 -= f11;
|
||||
f8 -= f11;
|
||||
f9 -= f11;
|
||||
f10 -= f11;
|
||||
float f13;
|
||||
float f14;
|
||||
float f15;
|
||||
float f16;
|
||||
float f17;
|
||||
float f18;
|
||||
float f19;
|
||||
float f20;
|
||||
|
||||
f13 = textureatlassprite.getInterpolatedU(0.0D);
|
||||
f17 = textureatlassprite.getInterpolatedV(0.0D);
|
||||
f14 = f13;
|
||||
f18 = textureatlassprite.getInterpolatedV(16.0D);
|
||||
f15 = textureatlassprite.getInterpolatedU(16.0D);
|
||||
f19 = f18;
|
||||
f16 = f15;
|
||||
f20 = f17;
|
||||
|
||||
int k2 = getLightmapValueLiquid(blockAccess, blockPosIn);
|
||||
int l2 = k2 >> 16 & 65535;
|
||||
int i3 = k2 & 65535;
|
||||
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).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, shine).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, shine).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, shine).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
|
||||
//
|
||||
// if (block.shouldRenderSides(blockAccess, blockPosIn.up()))
|
||||
// {
|
||||
// worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(0.0f, 1.0f, 0.0f, shine).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, shine).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, shine).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, shine).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
|
||||
// }
|
||||
}
|
||||
|
||||
if (down)
|
||||
{
|
||||
float f35 = textureatlassprite.getMinU();
|
||||
float f36 = textureatlassprite.getMaxU();
|
||||
float f37 = textureatlassprite.getMinV();
|
||||
float f38 = textureatlassprite.getMaxV();
|
||||
int l1 = getLightmapValueLiquid(blockAccess, blockPosIn.down());
|
||||
int i2 = l1 >> 16 & 65535;
|
||||
int j2 = l1 & 65535;
|
||||
worldRendererIn.pos(d0, d1, d2 + 1.0D).color(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex();
|
||||
worldRendererIn.pos(d0, d1, d2).color(0.0f, -1.0f, 0.0f, shine).tex((double)f35, (double)f37).lightmap(i2, j2).endVertex();
|
||||
worldRendererIn.pos(d0 + 1.0D, d1, d2).color(0.0f, -1.0f, 0.0f, shine).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, shine).tex((double)f36, (double)f38).lightmap(i2, j2).endVertex();
|
||||
rendered = true;
|
||||
}
|
||||
|
||||
for (int np = 0; np < 4; ++np)
|
||||
{
|
||||
int j1 = 0;
|
||||
int k1 = 0;
|
||||
|
||||
if (np == 0)
|
||||
{
|
||||
--k1;
|
||||
}
|
||||
|
||||
if (np == 1)
|
||||
{
|
||||
++k1;
|
||||
}
|
||||
|
||||
if (np == 2)
|
||||
{
|
||||
--j1;
|
||||
}
|
||||
|
||||
if (np == 3)
|
||||
{
|
||||
++j1;
|
||||
}
|
||||
|
||||
BlockPos blockpos = blockPosIn.add(j1, 0, k1);
|
||||
Sprite textureatlassprite1 = textureatlassprite;
|
||||
|
||||
if (aboolean[np])
|
||||
{
|
||||
float f39;
|
||||
float f40;
|
||||
double d3;
|
||||
double d4;
|
||||
double d5;
|
||||
double d6;
|
||||
|
||||
if (np == 0)
|
||||
{
|
||||
f39 = f7;
|
||||
f40 = f10;
|
||||
d3 = d0;
|
||||
d5 = d0 + 1.0D;
|
||||
d4 = d2 + (double)f11;
|
||||
d6 = d2 + (double)f11;
|
||||
}
|
||||
else if (np == 1)
|
||||
{
|
||||
f39 = f9;
|
||||
f40 = f8;
|
||||
d3 = d0 + 1.0D;
|
||||
d5 = d0;
|
||||
d4 = d2 + 1.0D - (double)f11;
|
||||
d6 = d2 + 1.0D - (double)f11;
|
||||
}
|
||||
else if (np == 2)
|
||||
{
|
||||
f39 = f8;
|
||||
f40 = f7;
|
||||
d3 = d0 + (double)f11;
|
||||
d5 = d0 + (double)f11;
|
||||
d4 = d2 + 1.0D;
|
||||
d6 = d2;
|
||||
}
|
||||
else
|
||||
{
|
||||
f39 = f10;
|
||||
f40 = f9;
|
||||
d3 = d0 + 1.0D - (double)f11;
|
||||
d5 = d0 + 1.0D - (double)f11;
|
||||
d4 = d2;
|
||||
d6 = d2 + 1.0D;
|
||||
}
|
||||
|
||||
rendered = true;
|
||||
float f41 = textureatlassprite1.getInterpolatedU(0.0D);
|
||||
float f27 = textureatlassprite1.getInterpolatedU(16.0D);
|
||||
float f28 = textureatlassprite1.getInterpolatedV((double)((1.0F - f39) * 16.0F));
|
||||
float f29 = textureatlassprite1.getInterpolatedV((double)((1.0F - f40) * 16.0F));
|
||||
float f30 = textureatlassprite1.getInterpolatedV(16.0D);
|
||||
int j = getLightmapValueLiquid(blockAccess, blockpos);
|
||||
int k = j >> 16 & 65535;
|
||||
int l = j & 65535;
|
||||
float xn = np == 2 ? -1.0f : (np == 3 ? 1.0f : 0.0f);
|
||||
float zn = np == 0 ? -1.0f : (np == 1 ? 1.0f : 0.0f);
|
||||
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(xn, 0.0f, zn, shine).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
|
||||
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(xn, 0.0f, zn, shine).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
return rendered;
|
||||
}
|
||||
}
|
||||
|
||||
private float getAdjacentHeight(IBlockAccess blockAccess, BlockPos blockPosIn, Block block)
|
||||
{
|
||||
int i = 0;
|
||||
float f = 0.0F;
|
||||
|
||||
for (int j = 0; j < 4; ++j)
|
||||
{
|
||||
BlockPos blockpos = blockPosIn.add(-(j & 1), 0, -(j >> 1 & 1));
|
||||
|
||||
if (blockAccess.getState(blockpos.up()).getBlock() == block)
|
||||
{
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
State iblockstate = blockAccess.getState(blockpos);
|
||||
Block material = iblockstate.getBlock();
|
||||
|
||||
if (material != block)
|
||||
{
|
||||
if (material == Blocks.air)
|
||||
{
|
||||
f += 4;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
f += 1.0F / 9.0f;
|
||||
i += 10;
|
||||
|
||||
// f += 1.0F / 9.0f;
|
||||
// ++i;
|
||||
}
|
||||
}
|
||||
|
||||
return 1.0F - f / (float)i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,4 +69,8 @@ public class BlockFalling extends Block {
|
|||
|
||||
public void onEndFalling(World world, BlockPos pos) {
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue