block base class cleanup
This commit is contained in:
parent
346937ba4a
commit
828d215048
161 changed files with 1832 additions and 2044 deletions
|
@ -1809,7 +1809,7 @@ public class Client implements IThreadListener {
|
|||
State block = this.world.getState(pos);
|
||||
|
||||
if(!this.debugWorld) {
|
||||
block = block.getBlock().getActualState(block, this.world, pos);
|
||||
block = block.getBlock().getState(block, this.world, pos);
|
||||
}
|
||||
|
||||
StringBuilder str = new StringBuilder(
|
||||
|
|
|
@ -13,7 +13,6 @@ import client.renderer.blockmodel.IBakedModel;
|
|||
import client.renderer.blockmodel.ModelManager;
|
||||
import client.renderer.texture.TextureAtlasSprite;
|
||||
import client.renderer.texture.TextureMap;
|
||||
import client.renderer.tileentity.TileEntityItemStackRenderer;
|
||||
import common.block.Block;
|
||||
import common.block.Material;
|
||||
import common.block.liquid.BlockDynamicLiquid;
|
||||
|
@ -21,7 +20,6 @@ import common.block.liquid.BlockLiquid;
|
|||
import common.block.liquid.BlockStaticLiquid;
|
||||
import common.collect.Maps;
|
||||
import common.init.BlockRegistry;
|
||||
import common.item.ItemStack;
|
||||
import common.util.BlockPos;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Facing;
|
||||
|
@ -52,11 +50,9 @@ public class BlockRenderer
|
|||
public void renderBlockDamage(State state, BlockPos pos, TextureAtlasSprite texture, IWorldAccess blockAccess)
|
||||
{
|
||||
Block block = state.getBlock();
|
||||
int i = block.getRenderType();
|
||||
|
||||
if (i == 3)
|
||||
if (block.getRenderType() == 3)
|
||||
{
|
||||
state = block.getActualState(state, blockAccess, pos);
|
||||
state = block.getState(state, blockAccess, pos);
|
||||
IBakedModel ibakedmodel = this.manager.getModelForState(state);
|
||||
IBakedModel ibakedmodel1 = (new BakedModel.Builder(ibakedmodel, texture)).makeBakedModel();
|
||||
// Tessellator.getInstance();
|
||||
|
@ -81,9 +77,6 @@ public class BlockRenderer
|
|||
case 1:
|
||||
return this.renderFluid(blockAccess, state, pos, worldRendererIn);
|
||||
|
||||
case 2:
|
||||
return false;
|
||||
|
||||
case 3:
|
||||
IBakedModel ibakedmodel = this.getModelFromBlockState(state, blockAccess, pos);
|
||||
return this.renderBase(blockAccess, ibakedmodel, state, pos, worldRendererIn, !this.gm.xrayActive);
|
||||
|
@ -102,7 +95,7 @@ public class BlockRenderer
|
|||
{
|
||||
try
|
||||
{
|
||||
state = block.getActualState(state, worldIn, pos);
|
||||
state = block.getState(state, worldIn, pos);
|
||||
}
|
||||
catch (Exception var6)
|
||||
{
|
||||
|
@ -120,29 +113,12 @@ public class BlockRenderer
|
|||
// return ibakedmodel;
|
||||
}
|
||||
|
||||
public void renderBlockBrightness(State state, float brightness)
|
||||
public void renderBlockEntity(State state, float brightness)
|
||||
{
|
||||
int i = state.getBlock().getRenderType();
|
||||
|
||||
if (i != -1)
|
||||
if (state.getBlock().getRenderType() == 3)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 1:
|
||||
default:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// this.chestRenderer.renderChestBrightness(state.getBlock(), brightness);
|
||||
GlState.color(brightness, brightness, brightness, 1.0F);
|
||||
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
TileEntityItemStackRenderer.instance.renderByItem(new ItemStack(state.getBlock().getItem()));
|
||||
break;
|
||||
|
||||
case 3:
|
||||
IBakedModel ibakedmodel = this.manager.getModelForState(state);
|
||||
this.renderModelBrightness(ibakedmodel, state, brightness, true);
|
||||
}
|
||||
IBakedModel model = this.manager.getModelForState(state);
|
||||
this.renderModelBrightness(model, state, brightness, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,14 +143,14 @@ public class BlockRenderer
|
|||
private boolean renderBase(IWorldAccess blockAccessIn, IBakedModel modelIn, State blockStateIn, BlockPos blockPosIn, RenderBuffer worldRendererIn, boolean checkSides)
|
||||
{
|
||||
Block block = blockStateIn.getBlock();
|
||||
block.setBlockBoundsBasedOnState(blockAccessIn, blockPosIn);
|
||||
block.setBlockBounds(blockAccessIn, blockPosIn);
|
||||
return this.renderModel(blockAccessIn, modelIn, blockStateIn, blockPosIn, worldRendererIn, checkSides);
|
||||
}
|
||||
|
||||
private boolean renderModel(IWorldAccess blockAccessIn, IBakedModel modelIn, State blockStateIn, BlockPos blockPosIn, RenderBuffer worldRendererIn)
|
||||
{
|
||||
Block block = blockStateIn.getBlock();
|
||||
block.setBlockBoundsBasedOnState(blockAccessIn, blockPosIn);
|
||||
block.setBlockBounds(blockAccessIn, blockPosIn);
|
||||
return this.renderModel(blockAccessIn, modelIn, blockStateIn, blockPosIn, worldRendererIn, true);
|
||||
}
|
||||
|
||||
|
@ -197,9 +173,9 @@ public class BlockRenderer
|
|||
{
|
||||
BlockPos blockpos = blockPosIn.offset(enumfacing);
|
||||
|
||||
if (!checkSides || blockIn.shouldSideBeRendered(blockAccessIn, blockpos, enumfacing))
|
||||
if (!checkSides || blockIn.canRender(blockAccessIn, blockpos, enumfacing))
|
||||
{
|
||||
int i = blockIn.getMixedBrightnessForBlock(blockAccessIn, blockpos);
|
||||
int i = blockIn.getLightmapValue(blockAccessIn, blockpos);
|
||||
this.renderModelStandardQuads(blockAccessIn, blockIn, blockPosIn, enumfacing, i, false, worldRendererIn, list, bitset);
|
||||
flag = true;
|
||||
}
|
||||
|
@ -318,7 +294,7 @@ public class BlockRenderer
|
|||
if (ownBrightness)
|
||||
{
|
||||
this.fillQuadBounds(blockIn, bakedquad.getVertexData(), bakedquad.getFace(), (float[])null, boundsFlags);
|
||||
brightnessIn = boundsFlags.get(0) ? blockIn.getMixedBrightnessForBlock(blockAccessIn, blockPosIn.offset(bakedquad.getFace())) : blockIn.getMixedBrightnessForBlock(blockAccessIn, blockPosIn);
|
||||
brightnessIn = boundsFlags.get(0) ? blockIn.getLightmapValue(blockAccessIn, blockPosIn.offset(bakedquad.getFace())) : blockIn.getLightmapValue(blockAccessIn, blockPosIn);
|
||||
}
|
||||
|
||||
worldRendererIn.addVertexData(bakedquad.getVertexData());
|
||||
|
@ -359,9 +335,9 @@ public class BlockRenderer
|
|||
private void renderModelBrightness(IBakedModel model, State p_178266_2_, float brightness, boolean p_178266_4_)
|
||||
{
|
||||
Block block = p_178266_2_.getBlock();
|
||||
block.setBlockBoundsForItemRender();
|
||||
block.setItemBounds();
|
||||
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
int i = block.getRenderColor(block.getStateForEntityRender(p_178266_2_));
|
||||
int i = block.getRenderColor(block.getEntityState(p_178266_2_));
|
||||
|
||||
// if (EntityRenderer.anaglyphEnable)
|
||||
// {
|
||||
|
@ -419,15 +395,15 @@ public class BlockRenderer
|
|||
private boolean renderFluid(IWorldAccess blockAccess, State blockStateIn, BlockPos blockPosIn, RenderBuffer worldRendererIn)
|
||||
{
|
||||
BlockLiquid blockliquid = (BlockLiquid)blockStateIn.getBlock();
|
||||
blockliquid.setBlockBoundsBasedOnState(blockAccess, blockPosIn);
|
||||
blockliquid.setBlockBounds(blockAccess, blockPosIn);
|
||||
TextureAtlasSprite[] atextureatlassprite = this.fluids.get(blockliquid);
|
||||
int i = blockliquid.colorMultiplier(blockAccess, blockPosIn);
|
||||
int i = blockliquid.colorMultiplier(blockAccess, blockPosIn, 0);
|
||||
float f = (float)(i >> 16 & 255) / 255.0F;
|
||||
float f1 = (float)(i >> 8 & 255) / 255.0F;
|
||||
float f2 = (float)(i & 255) / 255.0F;
|
||||
boolean flag = blockliquid.shouldSideBeRendered(blockAccess, blockPosIn.up(), Facing.UP);
|
||||
boolean flag1 = blockliquid.shouldSideBeRendered(blockAccess, blockPosIn.down(), Facing.DOWN);
|
||||
boolean[] aboolean = new boolean[] {blockliquid.shouldSideBeRendered(blockAccess, blockPosIn.north(), Facing.NORTH), blockliquid.shouldSideBeRendered(blockAccess, blockPosIn.south(), Facing.SOUTH), blockliquid.shouldSideBeRendered(blockAccess, blockPosIn.west(), Facing.WEST), blockliquid.shouldSideBeRendered(blockAccess, blockPosIn.east(), Facing.EAST)};
|
||||
boolean flag = blockliquid.canRender(blockAccess, blockPosIn.up(), Facing.UP);
|
||||
boolean flag1 = 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])
|
||||
{
|
||||
|
@ -500,7 +476,7 @@ public class BlockRenderer
|
|||
f20 = textureatlassprite.getInterpolatedV((double)(8.0F + (-f22 - f21) * 16.0F));
|
||||
}
|
||||
|
||||
int k2 = blockliquid.getMixedBrightnessForBlock(blockAccess, blockPosIn);
|
||||
int k2 = blockliquid.getLightmapValue(blockAccess, blockPosIn);
|
||||
int l2 = k2 >> 16 & 65535;
|
||||
int i3 = k2 & 65535;
|
||||
float f24 = f4 * f;
|
||||
|
@ -526,7 +502,7 @@ public class BlockRenderer
|
|||
float f36 = atextureatlassprite[0].getMaxU();
|
||||
float f37 = atextureatlassprite[0].getMinV();
|
||||
float f38 = atextureatlassprite[0].getMaxV();
|
||||
int l1 = blockliquid.getMixedBrightnessForBlock(blockAccess, blockPosIn.down());
|
||||
int l1 = blockliquid.getLightmapValue(blockAccess, blockPosIn.down());
|
||||
int i2 = l1 >> 16 & 65535;
|
||||
int j2 = l1 & 65535;
|
||||
worldRendererIn.pos(d0, d1, d2 + 1.0D).color(f3, f3, f3, 1.0F).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex();
|
||||
|
@ -616,7 +592,7 @@ public class BlockRenderer
|
|||
float f28 = textureatlassprite1.getInterpolatedV((double)((1.0F - f39) * 16.0F * 0.5F));
|
||||
float f29 = textureatlassprite1.getInterpolatedV((double)((1.0F - f40) * 16.0F * 0.5F));
|
||||
float f30 = textureatlassprite1.getInterpolatedV(8.0D);
|
||||
int j = blockliquid.getMixedBrightnessForBlock(blockAccess, blockpos);
|
||||
int j = blockliquid.getLightmapValue(blockAccess, blockpos);
|
||||
int k = j >> 16 & 65535;
|
||||
int l = j & 65535;
|
||||
float f31 = i1 < 2 ? f5 : f6;
|
||||
|
|
|
@ -255,7 +255,7 @@ public class EffectRenderer {
|
|||
BlockPos blockpos = new BlockPos(this.posX, this.posY, this.posZ);
|
||||
State iblockstate = world.getState(blockpos);
|
||||
Block block = iblockstate.getBlock();
|
||||
block.setBlockBoundsBasedOnState(world, blockpos);
|
||||
block.setBlockBounds(world, blockpos);
|
||||
Material material = iblockstate.getBlock().getMaterial();
|
||||
|
||||
if(material.isLiquid() || material.isSolid()) {
|
||||
|
@ -720,7 +720,7 @@ public class EffectRenderer {
|
|||
Block block = state.getBlock();
|
||||
if(block == Blocks.grass)
|
||||
return;
|
||||
int color = pos == null ? block.getRenderColor(state) : block.colorMultiplier(world, pos);
|
||||
int color = pos == null ? block.getRenderColor(state) : block.colorMultiplier(world, pos, 0);
|
||||
this.red *= (float)(color >> 16 & 255) / 255.0F;
|
||||
this.green *= (float)(color >> 8 & 255) / 255.0F;
|
||||
this.blue *= (float)(color & 255) / 255.0F;
|
||||
|
@ -1080,7 +1080,7 @@ public class EffectRenderer {
|
|||
|
||||
public void destroyBlock(BlockPos pos, State state) {
|
||||
if(state.getBlock() != Blocks.air) {
|
||||
state = state.getBlock().getActualState(state, this.world, pos);
|
||||
state = state.getBlock().getState(state, this.world, pos);
|
||||
int i = 4;
|
||||
|
||||
for(int j = 0; j < i; ++j) {
|
||||
|
|
|
@ -1166,7 +1166,7 @@ public class EntityRenderer {
|
|||
}
|
||||
else if (block != Blocks.air)
|
||||
{
|
||||
block.setBlockBoundsBasedOnState(world, blockpos2);
|
||||
block.setBlockBounds(world, blockpos2);
|
||||
++j;
|
||||
|
||||
if (this.random.zrange(j) == 0)
|
||||
|
|
|
@ -495,7 +495,7 @@ public class RenderGlobal
|
|||
double d0 = renderViewEntity.prevX + (renderViewEntity.posX - renderViewEntity.prevX) * (double)partialTicks;
|
||||
double d1 = renderViewEntity.prevY + (renderViewEntity.posY - renderViewEntity.prevY) * (double)partialTicks;
|
||||
double d2 = renderViewEntity.prevZ + (renderViewEntity.posZ - renderViewEntity.prevZ) * (double)partialTicks;
|
||||
TileEntityRendererDispatcher.instance.cacheActiveRenderInfo(this.theWorld, this.gm.getTextureManager(), this.gm.getRenderViewEntity(), partialTicks);
|
||||
TileEntityRendererDispatcher.instance.setPosition(this.theWorld, this.gm.getTextureManager(), this.gm.getRenderViewEntity(), partialTicks);
|
||||
this.renderManager.cacheActiveRenderInfo(this.theWorld, this.gm.getRenderViewEntity(), this.gm.getPointedEntity(), this.gm, partialTicks);
|
||||
this.countEntitiesTotal = 0;
|
||||
this.countEntitiesRendered = 0;
|
||||
|
@ -504,9 +504,9 @@ public class RenderGlobal
|
|||
double d3 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
|
||||
double d4 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
|
||||
double d5 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
|
||||
TileEntityRendererDispatcher.staticPlayerX = d3;
|
||||
TileEntityRendererDispatcher.staticPlayerY = d4;
|
||||
TileEntityRendererDispatcher.staticPlayerZ = d5;
|
||||
TileEntityRendererDispatcher.entityX = d3;
|
||||
TileEntityRendererDispatcher.entityY = d4;
|
||||
TileEntityRendererDispatcher.entityZ = d5;
|
||||
this.renderManager.setRenderPosition(d3, d4, d5);
|
||||
this.gm.entityRenderer.enableLightmap();
|
||||
List<Entity> list = this.theWorld.getLoadedEntityList();
|
||||
|
@ -661,7 +661,7 @@ public class RenderGlobal
|
|||
{
|
||||
for (TileEntity tileentity2 : list1)
|
||||
{
|
||||
TileEntityRendererDispatcher.instance.renderTileEntity(tileentity2, partialTicks, -1);
|
||||
TileEntityRendererDispatcher.instance.renderTile(tileentity2, partialTicks, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ public class RenderGlobal
|
|||
{
|
||||
for (TileEntity tileentity : this.setTileEntities)
|
||||
{
|
||||
TileEntityRendererDispatcher.instance.renderTileEntity(tileentity, partialTicks, -1);
|
||||
TileEntityRendererDispatcher.instance.renderTile(tileentity, partialTicks, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -684,7 +684,7 @@ public class RenderGlobal
|
|||
|
||||
if (tileentity1 != null && (block instanceof BlockChest || block instanceof BlockSign))
|
||||
{
|
||||
TileEntityRendererDispatcher.instance.renderTileEntity(tileentity1, partialTicks, destroyblockprogress.getPartialBlockDamage());
|
||||
TileEntityRendererDispatcher.instance.renderTile(tileentity1, partialTicks, destroyblockprogress.getPartialBlockDamage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1613,11 +1613,11 @@ public class RenderGlobal
|
|||
|
||||
if (block != Blocks.air) // && this.theWorld.getWorldBorder().contains(blockpos))
|
||||
{
|
||||
block.setBlockBoundsBasedOnState(this.theWorld, blockpos);
|
||||
block.setBlockBounds(this.theWorld, blockpos);
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
|
||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
|
||||
drawSelectionBoundingBox(block.getSelectedBoundingBox(this.theWorld, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2));
|
||||
drawSelectionBoundingBox(block.getSelectionBox(this.theWorld, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2));
|
||||
}
|
||||
|
||||
GlState.depthMask(true);
|
||||
|
|
|
@ -219,7 +219,7 @@ public abstract class ModelBakery
|
|||
return new ModelBlock(MODEL_ENTITY, Transform.IDENTITY);
|
||||
State state = block == null ? null : block.getItemState();
|
||||
if(state != null)
|
||||
return state.getBlock().hasBlockFlatTexture() ? new ModelBlock(state.getBlock().getTransform(), "blocks/" + name) : new ModelBlock((ModelBlock)state.getBlock().getModel(provider, BlockRegistry.getName(state.getBlock()), state), state.getBlock().getTransform());
|
||||
return new ModelBlock((ModelBlock)state.getBlock().getModel(provider, BlockRegistry.getName(state.getBlock()), state), state.getBlock().getTransform());
|
||||
return new ModelBlock(Transform.IDENTITY, item.getTextures(name));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import client.renderer.RenderBuffer;
|
|||
import client.renderer.RenderGlobal;
|
||||
import client.renderer.VertexBuffer;
|
||||
import client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import client.renderer.tileentity.TileRenderer;
|
||||
import client.world.WorldClient;
|
||||
import common.block.Block;
|
||||
import common.block.ITileEntityProvider;
|
||||
|
@ -136,7 +136,7 @@ public class RenderChunk
|
|||
}
|
||||
|
||||
VisGraph lvt_10_1_ = new VisGraph();
|
||||
HashSet lvt_11_1_ = Sets.newHashSet();
|
||||
HashSet forced = Sets.newHashSet();
|
||||
|
||||
if (!iblockaccess.isEmpty())
|
||||
{
|
||||
|
@ -157,15 +157,15 @@ public class RenderChunk
|
|||
if (block instanceof ITileEntityProvider)
|
||||
{
|
||||
TileEntity tileentity = iblockaccess.getTileEntity(new BlockPos(blockpos$mutableblockpos));
|
||||
TileEntitySpecialRenderer<TileEntity> tileentityspecialrenderer = TileEntityRendererDispatcher.instance.<TileEntity>getSpecialRenderer(tileentity);
|
||||
TileRenderer<TileEntity> tileentityspecialrenderer = TileEntityRendererDispatcher.instance.<TileEntity>getRenderer(tileentity);
|
||||
|
||||
if (tileentity != null && tileentityspecialrenderer != null)
|
||||
{
|
||||
compiledchunk.addTileEntity(tileentity);
|
||||
|
||||
if (tileentityspecialrenderer.forceTileEntityRender())
|
||||
if (tileentityspecialrenderer.isAlwaysRendered())
|
||||
{
|
||||
lvt_11_1_.add(tileentity);
|
||||
forced.add(tileentity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,12 +206,12 @@ public class RenderChunk
|
|||
|
||||
try
|
||||
{
|
||||
Set<TileEntity> set = Sets.newHashSet(lvt_11_1_);
|
||||
Set<TileEntity> set = Sets.newHashSet(forced);
|
||||
Set<TileEntity> set1 = Sets.newHashSet(this.setTileEntities);
|
||||
set.removeAll(this.setTileEntities);
|
||||
set1.removeAll(lvt_11_1_);
|
||||
set1.removeAll(forced);
|
||||
this.setTileEntities.clear();
|
||||
this.setTileEntities.addAll(lvt_11_1_);
|
||||
this.setTileEntities.addAll(forced);
|
||||
this.renderGlobal.updateTileEntities(set1, set);
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -45,7 +45,7 @@ public class RenderBlockEntity extends Render<Entity>
|
|||
// float f2 = (1.0F - ((float)entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
|
||||
this.bindEntityTexture(entity);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, 0.5F);
|
||||
blockrendererdispatcher.renderBlockBrightness(state, entity.getBrightness(partialTicks));
|
||||
blockrendererdispatcher.renderBlockEntity(state, entity.getBrightness(partialTicks));
|
||||
GL11.glTranslatef(0.0F, 0.0F, 1.0F);
|
||||
|
||||
// if (entity.fuse / 5 % 2 == 0)
|
||||
|
|
|
@ -37,29 +37,26 @@ public class RenderFallingBlock extends Render<EntityFalling>
|
|||
BlockPos blockpos = new BlockPos(entity);
|
||||
World world = entity.getWorldObj();
|
||||
|
||||
if (iblockstate != world.getState(blockpos) && block.getRenderType() != -1)
|
||||
if (iblockstate != world.getState(blockpos) && block.getRenderType() == 3)
|
||||
{
|
||||
if (block.getRenderType() == 3)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||
GlState.disableLighting();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||
GlState.disableLighting();
|
||||
// Tessellator tessellator = Tessellator.getInstance();
|
||||
RenderBuffer worldrenderer = Tessellator.getBuffer();
|
||||
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
int i = blockpos.getX();
|
||||
int j = blockpos.getY();
|
||||
int k = blockpos.getZ();
|
||||
worldrenderer.setTranslation((double)((float)(-i) - 0.5F), (double)(-j), (double)((float)(-k) - 0.5F));
|
||||
BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher();
|
||||
IBakedModel ibakedmodel = blockrendererdispatcher.getModelFromBlockState(iblockstate, world, (BlockPos)null);
|
||||
blockrendererdispatcher.renderModel(world, ibakedmodel, iblockstate, blockpos, worldrenderer, false);
|
||||
worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
|
||||
Tessellator.draw();
|
||||
GlState.enableLighting();
|
||||
GL11.glPopMatrix();
|
||||
super.doRender(entity, x, y, z, partialTicks);
|
||||
}
|
||||
RenderBuffer worldrenderer = Tessellator.getBuffer();
|
||||
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
int i = blockpos.getX();
|
||||
int j = blockpos.getY();
|
||||
int k = blockpos.getZ();
|
||||
worldrenderer.setTranslation((double)((float)(-i) - 0.5F), (double)(-j), (double)((float)(-k) - 0.5F));
|
||||
BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher();
|
||||
IBakedModel ibakedmodel = blockrendererdispatcher.getModelFromBlockState(iblockstate, world, (BlockPos)null);
|
||||
blockrendererdispatcher.renderModel(world, ibakedmodel, iblockstate, blockpos, worldrenderer, false);
|
||||
worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
|
||||
Tessellator.draw();
|
||||
GlState.enableLighting();
|
||||
GL11.glPopMatrix();
|
||||
super.doRender(entity, x, y, z, partialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import client.Client;
|
||||
import client.renderer.DefaultVertexFormats;
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.ItemModelMesher;
|
||||
|
@ -12,17 +13,26 @@ import client.renderer.Tessellator;
|
|||
import client.renderer.blockmodel.BakedQuad;
|
||||
import client.renderer.blockmodel.IBakedModel;
|
||||
import client.renderer.blockmodel.ModelManager;
|
||||
import client.renderer.layers.LayerArmor;
|
||||
import client.renderer.model.ModelHorse;
|
||||
import client.renderer.texture.TextureManager;
|
||||
import client.renderer.texture.TextureMap;
|
||||
import client.renderer.tileentity.TileEntityItemStackRenderer;
|
||||
import client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import common.block.tech.BlockChest;
|
||||
import common.block.tile.BlockStandingSign;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.item.WieldType;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.item.material.ItemHorseArmor;
|
||||
import common.model.Transform;
|
||||
import common.tileentity.TileEntityChest;
|
||||
import common.tileentity.TileEntitySign;
|
||||
import common.util.Facing;
|
||||
import common.util.Vec3i;
|
||||
import common.world.State;
|
||||
|
||||
public class RenderItem
|
||||
{
|
||||
|
@ -30,7 +40,34 @@ public class RenderItem
|
|||
|
||||
private final ItemModelMesher mesher;
|
||||
private final TextureManager manager;
|
||||
private final TileEntityChest chest = new TileEntityChest(0) {
|
||||
public boolean hasWorldObj() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public State getBlockState() {
|
||||
return RenderItem.this.state;
|
||||
}
|
||||
};
|
||||
|
||||
private final TileEntitySign sign = new TileEntitySign() {
|
||||
public boolean hasWorldObj() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public State getBlockState() {
|
||||
return RenderItem.this.state;
|
||||
}
|
||||
};
|
||||
private final LayerArmor armor = new LayerArmor(null, 12, 12) {
|
||||
public ItemStack getCurrentArmor(EntityLiving entitylivingbaseIn, int armorSlot) {
|
||||
return ((ItemArmor)RenderItem.this.stack.getItem()).armorType.getIndex() == armorSlot ? RenderItem.this.stack : null;
|
||||
}
|
||||
};
|
||||
private final ModelHorse horse = new ModelHorse();
|
||||
|
||||
private State state;
|
||||
private ItemStack stack;
|
||||
public float zLevel;
|
||||
|
||||
public RenderItem(TextureManager textureManager, ModelManager modelManager)
|
||||
|
@ -81,7 +118,7 @@ public class RenderItem
|
|||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlState.enableRescaleNormal();
|
||||
TileEntityItemStackRenderer.instance.renderByItem(stack);
|
||||
this.renderBuiltin(stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -98,6 +135,63 @@ public class RenderItem
|
|||
}
|
||||
}
|
||||
|
||||
private void renderBuiltin(ItemStack stack) {
|
||||
if(stack.getItem().getBlock() instanceof BlockChest chest) {
|
||||
this.state = chest.getState().withProperty(BlockChest.FACING, Facing.SOUTH);
|
||||
TileEntityRendererDispatcher.instance.renderItem(this.chest, 0.0D, 0.0D, 0.0D, 0.0F);
|
||||
this.state = null;
|
||||
}
|
||||
else if(stack.getItem().getBlock() instanceof BlockStandingSign sign) {
|
||||
this.state = sign.getState().withProperty(BlockStandingSign.ROTATION, 8);
|
||||
TileEntityRendererDispatcher.instance.renderItem(this.sign, 0.0D, 0.0D, 0.0D, 0.0F);
|
||||
this.state = null;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemArmor armor) {
|
||||
this.stack = stack;
|
||||
GL11.glPushMatrix();
|
||||
float offset = 0.0f;
|
||||
switch(armor.armorType) {
|
||||
case HEAD:
|
||||
offset = -0.15f;
|
||||
break;
|
||||
case BODY:
|
||||
offset = 0.45f;
|
||||
break;
|
||||
case LEGS:
|
||||
offset = 1.35f;
|
||||
break;
|
||||
case FEET:
|
||||
offset = 1.7f;
|
||||
break;
|
||||
}
|
||||
GL11.glTranslatef(1.0f, offset, 0.0f);
|
||||
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
|
||||
GL11.glScalef(1.4f, -1.4f, 1.4f);
|
||||
boolean cull = GlState.isCullEnabled();
|
||||
if(cull)
|
||||
GlState.disableCull();
|
||||
this.armor.doRenderLayer(null, 0.0f, 0.0f, 0.0f, 0, 0, 0.0f, 0.0625F);
|
||||
if(cull)
|
||||
GlState.enableCull();
|
||||
GL11.glPopMatrix();
|
||||
this.stack = null;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemHorseArmor horseArmor) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.9f, 0.5f, 0.0f);
|
||||
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
|
||||
GL11.glScalef(0.85f, -0.85f, 0.85f);
|
||||
boolean cull = GlState.isCullEnabled();
|
||||
if(cull)
|
||||
GlState.disableCull();
|
||||
this.manager.bindTexture("textures/armor/" + horseArmor.getArmorTexture() + "_horse.png");
|
||||
this.horse.render(null, 0, 0, 0, 0, 0, 0.0625F);
|
||||
if(cull)
|
||||
GlState.enableCull();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private void renderEffect(IBakedModel model)
|
||||
{
|
||||
GlState.depthMask(false);
|
||||
|
@ -213,7 +307,7 @@ public class RenderItem
|
|||
}
|
||||
}
|
||||
|
||||
protected void renderItemModelTransform(ItemStack stack, IBakedModel model, boolean transform, boolean third)
|
||||
private void renderItemModelTransform(ItemStack stack, IBakedModel model, boolean transform, boolean third)
|
||||
{
|
||||
this.manager.bindTexture(TextureMap.BLOCKS);
|
||||
this.preTransform(stack);
|
||||
|
|
|
@ -123,7 +123,7 @@ public class RenderMinecart<T extends EntityCart> extends Render<T>
|
|||
protected void func_180560_a(T minecart, float partialTicks, State state)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
Client.CLIENT.getBlockRendererDispatcher().renderBlockBrightness(state, minecart.getBrightness(partialTicks));
|
||||
Client.CLIENT.getBlockRendererDispatcher().renderBlockEntity(state, minecart.getBrightness(partialTicks));
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class RenderTntMinecart extends RenderMinecart<EntityTntCart>
|
|||
GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
|
||||
GlState.color(1.0F, 1.0F, 1.0F, (1.0F - ((float)i - partialTicks + 1.0F) / 100.0F) * 0.8F);
|
||||
GL11.glPushMatrix();
|
||||
blockrendererdispatcher.renderBlockBrightness(Blocks.tnt.getState(), 1.0F);
|
||||
blockrendererdispatcher.renderBlockEntity(Blocks.tnt.getState(), 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlState.disableBlend();
|
||||
|
|
|
@ -39,7 +39,7 @@ public class RenderTntPrimed extends Render<EntityTnt>
|
|||
this.bindEntityTexture(entity);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, 0.5F);
|
||||
Block tnt = BlockRegistry.byName("tnt" + (entity.explosionSize <= 0 || entity.explosionSize >= 8 ? "" : "_" + entity.explosionSize));
|
||||
blockrendererdispatcher.renderBlockBrightness(tnt.getState(), entity.getBrightness(partialTicks));
|
||||
blockrendererdispatcher.renderBlockEntity(tnt.getState(), entity.getBrightness(partialTicks));
|
||||
GL11.glTranslatef(0.0F, 0.0F, 1.0F);
|
||||
|
||||
if (entity.fuse / 5 % 2 == 0)
|
||||
|
@ -51,7 +51,7 @@ public class RenderTntPrimed extends Render<EntityTnt>
|
|||
GlState.color(1.0F, 1.0F, 1.0F, f2);
|
||||
GlState.doPolygonOffset(-3.0F, -3.0F);
|
||||
GlState.enablePolygonOffset();
|
||||
blockrendererdispatcher.renderBlockBrightness(tnt.getState(), 1.0F);
|
||||
blockrendererdispatcher.renderBlockEntity(tnt.getState(), 1.0F);
|
||||
GlState.doPolygonOffset(0.0F, 0.0F);
|
||||
GlState.disablePolygonOffset();
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
|
|
@ -54,15 +54,6 @@ public class LayerHeldItem implements LayerRenderer<EntityLiving>
|
|||
Item item = itemstack.getItem();
|
||||
Client gm = Client.CLIENT;
|
||||
|
||||
if (item.getBlock() != null && item.getBlock().getRenderType() == 2)
|
||||
{
|
||||
GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
|
||||
GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
float f1 = 0.375F;
|
||||
GL11.glScalef(-f1, -f1, f1);
|
||||
}
|
||||
|
||||
if (entitylivingbaseIn.isSneakingVisually())
|
||||
{
|
||||
GL11.glTranslatef(0.0F, 0.203125F, 0.0F);
|
||||
|
|
|
@ -11,9 +11,13 @@ import common.tileentity.TileEntityChest;
|
|||
import common.world.State;
|
||||
|
||||
|
||||
public class TileEntityChestRenderer extends TileEntitySpecialRenderer<TileEntityChest>
|
||||
public class ChestRenderer extends TileRenderer<TileEntityChest>
|
||||
{
|
||||
private final ModelChest model = new ModelChest();
|
||||
private final ModelChest model = new ModelChest();
|
||||
|
||||
public ChestRenderer(TileEntityRendererDispatcher renderer) {
|
||||
super(renderer);
|
||||
}
|
||||
|
||||
public void renderTileEntityAt(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage)
|
||||
{
|
|
@ -17,7 +17,7 @@ import common.util.BlockPos;
|
|||
import common.util.Facing;
|
||||
import common.world.State;
|
||||
|
||||
public class TileEntityDisplayRenderer extends TileEntitySpecialRenderer<TileEntityDisplay> {
|
||||
public class DisplayRenderer extends TileRenderer<TileEntityDisplay> {
|
||||
private static class TimedTexture {
|
||||
public long time;
|
||||
public long updated;
|
||||
|
@ -78,6 +78,10 @@ public class TileEntityDisplayRenderer extends TileEntitySpecialRenderer<TileEnt
|
|||
tex.time = System.currentTimeMillis();
|
||||
return tex.texture;
|
||||
}
|
||||
|
||||
public DisplayRenderer(TileEntityRendererDispatcher renderer) {
|
||||
super(renderer);
|
||||
}
|
||||
|
||||
public void renderTileEntityAt(TileEntityDisplay te, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||
Block block = te.getBlockType();
|
|
@ -12,12 +12,15 @@ import common.tileentity.TileEntitySign;
|
|||
import common.world.State;
|
||||
|
||||
|
||||
public class TileEntitySignRenderer extends TileEntitySpecialRenderer<TileEntitySign>
|
||||
public class SignRenderer extends TileRenderer<TileEntitySign>
|
||||
{
|
||||
private static final String SIGN_TEXTURE = "textures/blocks/sign.png";
|
||||
|
||||
/** The ModelSign instance for use in this renderer */
|
||||
private final ModelSign model = new ModelSign();
|
||||
|
||||
public SignRenderer(TileEntityRendererDispatcher renderer) {
|
||||
super(renderer);
|
||||
}
|
||||
|
||||
public void renderTileEntityAt(TileEntitySign te, double x, double y, double z, float partialTicks, int destroyStage)
|
||||
{
|
||||
|
@ -122,13 +125,4 @@ public class TileEntitySignRenderer extends TileEntitySpecialRenderer<TileEntity
|
|||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// private void drawdString(String text, int x, int y) {
|
||||
// Drawing.drawText(text, x, y, 0xff000000, false);
|
||||
// }
|
||||
// private int getdStringWidth(String text) {
|
||||
// Vec2i size = Drawing.getTextSize(text);
|
||||
// return size.xpos;
|
||||
// }
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
package client.renderer.tileentity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import client.Client;
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.layers.LayerArmor;
|
||||
import client.renderer.model.ModelHorse;
|
||||
import common.block.tech.BlockChest;
|
||||
import common.block.tile.BlockStandingSign;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.item.material.ItemHorseArmor;
|
||||
import common.tileentity.TileEntityChest;
|
||||
import common.tileentity.TileEntitySign;
|
||||
import common.util.Facing;
|
||||
import common.world.State;
|
||||
|
||||
public class TileEntityItemStackRenderer {
|
||||
public static TileEntityItemStackRenderer instance = new TileEntityItemStackRenderer();
|
||||
|
||||
private State state;
|
||||
private ItemStack stack;
|
||||
|
||||
private final TileEntityChest chest = new TileEntityChest(0) {
|
||||
public boolean hasWorldObj() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public State getBlockState() {
|
||||
return TileEntityItemStackRenderer.this.state;
|
||||
}
|
||||
};
|
||||
|
||||
private final TileEntitySign sign = new TileEntitySign() {
|
||||
public boolean hasWorldObj() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public State getBlockState() {
|
||||
return TileEntityItemStackRenderer.this.state;
|
||||
}
|
||||
};
|
||||
private final LayerArmor armor = new LayerArmor(null, 12, 12) {
|
||||
public ItemStack getCurrentArmor(EntityLiving entitylivingbaseIn, int armorSlot) {
|
||||
return ((ItemArmor)TileEntityItemStackRenderer.this.stack.getItem()).armorType.getIndex() == armorSlot ? TileEntityItemStackRenderer.this.stack : null;
|
||||
}
|
||||
};
|
||||
private final ModelHorse horse = new ModelHorse();
|
||||
|
||||
public void renderByItem(ItemStack stack) {
|
||||
if(stack.getItem().getBlock() instanceof BlockChest chest) {
|
||||
this.state = chest.getState().withProperty(BlockChest.FACING, Facing.SOUTH);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chest, 0.0D, 0.0D, 0.0D, 0.0F);
|
||||
this.state = null;
|
||||
}
|
||||
else if(stack.getItem().getBlock() instanceof BlockStandingSign sign) {
|
||||
this.state = sign.getState().withProperty(BlockStandingSign.ROTATION, 8);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.sign, 0.0D, 0.0D, 0.0D, 0.0F);
|
||||
this.state = null;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemArmor armor) {
|
||||
this.stack = stack;
|
||||
GL11.glPushMatrix();
|
||||
float offset = 0.0f;
|
||||
switch(armor.armorType) {
|
||||
case HEAD:
|
||||
offset = -0.15f;
|
||||
break;
|
||||
case BODY:
|
||||
offset = 0.45f;
|
||||
break;
|
||||
case LEGS:
|
||||
offset = 1.35f;
|
||||
break;
|
||||
case FEET:
|
||||
offset = 1.7f;
|
||||
break;
|
||||
}
|
||||
GL11.glTranslatef(1.0f, offset, 0.0f);
|
||||
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
|
||||
GL11.glScalef(1.4f, -1.4f, 1.4f);
|
||||
boolean cull = GlState.isCullEnabled();
|
||||
if(cull)
|
||||
GlState.disableCull();
|
||||
this.armor.doRenderLayer(null, 0.0f, 0.0f, 0.0f, 0, 0, 0.0f, 0.0625F);
|
||||
if(cull)
|
||||
GlState.enableCull();
|
||||
GL11.glPopMatrix();
|
||||
this.stack = null;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemHorseArmor horseArmor) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.9f, 0.5f, 0.0f);
|
||||
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
|
||||
GL11.glScalef(0.85f, -0.85f, 0.85f);
|
||||
boolean cull = GlState.isCullEnabled();
|
||||
if(cull)
|
||||
GlState.disableCull();
|
||||
Client.CLIENT.getTextureManager().bindTexture("textures/armor/" + horseArmor.getArmorTexture() + "_horse.png");
|
||||
this.horse.render(null, 0, 0, 0, 0, 0, 0.0625F);
|
||||
if(cull)
|
||||
GlState.enableCull();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import org.lwjgl.opengl.GL13;
|
|||
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.texture.TextureManager;
|
||||
import client.world.WorldClient;
|
||||
import common.collect.Maps;
|
||||
import common.entity.Entity;
|
||||
import common.tileentity.TileEntity;
|
||||
|
@ -13,121 +14,67 @@ import common.tileentity.TileEntityChest;
|
|||
import common.tileentity.TileEntityDisplay;
|
||||
import common.tileentity.TileEntitySign;
|
||||
import common.util.BlockPos;
|
||||
import common.world.World;
|
||||
|
||||
public class TileEntityRendererDispatcher
|
||||
{
|
||||
private Map < Class <? extends TileEntity > , TileEntitySpecialRenderer <? extends TileEntity >> mapSpecialRenderers = Maps. < Class <? extends TileEntity > , TileEntitySpecialRenderer <? extends TileEntity >> newHashMap();
|
||||
public static TileEntityRendererDispatcher instance = new TileEntityRendererDispatcher();
|
||||
// private FontRenderer fontRenderer;
|
||||
public class TileEntityRendererDispatcher {
|
||||
public static TileEntityRendererDispatcher instance = new TileEntityRendererDispatcher();
|
||||
public static double entityX; // TODO: useless, duplicate render view entity position?
|
||||
public static double entityY;
|
||||
public static double entityZ;
|
||||
|
||||
/** The player's current X position (same as playerX) */
|
||||
public static double staticPlayerX;
|
||||
private final Map<Class<? extends TileEntity>, TileRenderer<? extends TileEntity>> renderers = Maps.<Class<? extends TileEntity>, TileRenderer<? extends TileEntity>>newHashMap();
|
||||
|
||||
/** The player's current Y position (same as playerY) */
|
||||
public static double staticPlayerY;
|
||||
public TextureManager manager;
|
||||
private WorldClient world;
|
||||
private double posX;
|
||||
private double posY;
|
||||
private double posZ;
|
||||
|
||||
/** The player's current Z position (same as playerZ) */
|
||||
public static double staticPlayerZ;
|
||||
public TextureManager renderEngine;
|
||||
public World worldObj;
|
||||
public Entity entity;
|
||||
public float entityYaw;
|
||||
public float entityPitch;
|
||||
public double entityX;
|
||||
public double entityY;
|
||||
public double entityZ;
|
||||
|
||||
// public static void setChristmas(boolean xmas) {
|
||||
// ((TileEntityChestRenderer)instance.mapSpecialRenderers.get(TileEntityChest.class)).setChristmas(xmas);
|
||||
// }
|
||||
private TileEntityRendererDispatcher() {
|
||||
this.renderers.put(TileEntitySign.class, new SignRenderer(this));
|
||||
this.renderers.put(TileEntityDisplay.class, new DisplayRenderer(this));
|
||||
this.renderers.put(TileEntityChest.class, new ChestRenderer(this));
|
||||
}
|
||||
|
||||
private TileEntityRendererDispatcher()
|
||||
{
|
||||
this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntityDisplay.class, new TileEntityDisplayRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
|
||||
private <T extends TileEntity> TileRenderer<T> getRenderer(Class<? extends TileEntity> clazz) {
|
||||
TileRenderer<? extends TileEntity> renderer = (TileRenderer)this.renderers.get(clazz);
|
||||
if(renderer == null && clazz != TileEntity.class) {
|
||||
renderer = this.<TileEntity>getRenderer((Class<? extends TileEntity>)clazz.getSuperclass());
|
||||
this.renderers.put(clazz, renderer);
|
||||
}
|
||||
return (TileRenderer<T>)renderer;
|
||||
}
|
||||
|
||||
for (TileEntitySpecialRenderer<?> tileentityspecialrenderer : this.mapSpecialRenderers.values())
|
||||
{
|
||||
tileentityspecialrenderer.setRendererDispatcher(this);
|
||||
}
|
||||
}
|
||||
public <T extends TileEntity> TileRenderer<T> getRenderer(TileEntity tile) {
|
||||
return (TileRenderer<T>)(tile == null ? null : this.getRenderer(tile.getClass()));
|
||||
}
|
||||
|
||||
public <T extends TileEntity> TileEntitySpecialRenderer<T> getSpecialRendererByClass(Class <? extends TileEntity > teClass)
|
||||
{
|
||||
TileEntitySpecialRenderer <? extends TileEntity > tileentityspecialrenderer = (TileEntitySpecialRenderer)this.mapSpecialRenderers.get(teClass);
|
||||
public void setPosition(WorldClient world, TextureManager manager, Entity entity, float partial) {
|
||||
this.world = world;
|
||||
this.manager = manager;
|
||||
this.posX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partial;
|
||||
this.posY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partial;
|
||||
this.posZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partial;
|
||||
}
|
||||
|
||||
if (tileentityspecialrenderer == null && teClass != TileEntity.class)
|
||||
{
|
||||
tileentityspecialrenderer = this.<TileEntity>getSpecialRendererByClass((Class <? extends TileEntity >)teClass.getSuperclass());
|
||||
this.mapSpecialRenderers.put(teClass, tileentityspecialrenderer);
|
||||
}
|
||||
public void renderTile(TileEntity tile, float partial, int destroy) {
|
||||
if(tile.getDistanceSq(this.posX, this.posY, this.posZ) < tile.getMaxRenderDistanceSquared()) {
|
||||
int light = this.world.getCombinedLight(tile.getPos(), 0);
|
||||
int block = light % 65536;
|
||||
int sky = light / 65536;
|
||||
GL13.glMultiTexCoord2f(GL13.GL_TEXTURE1, (float)block / 1.0F, (float)sky / 1.0F);
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
BlockPos pos = tile.getPos();
|
||||
this.render(tile, (double)pos.getX() - entityX, (double)pos.getY() - entityY, (double)pos.getZ() - entityZ, partial, destroy);
|
||||
}
|
||||
}
|
||||
|
||||
return (TileEntitySpecialRenderer<T>)tileentityspecialrenderer;
|
||||
}
|
||||
public void renderItem(TileEntity tile, double x, double y, double z, float partial) {
|
||||
this.render(tile, x, y, z, partial, -1);
|
||||
}
|
||||
|
||||
public <T extends TileEntity> TileEntitySpecialRenderer<T> getSpecialRenderer(TileEntity tileEntityIn)
|
||||
{
|
||||
return (TileEntitySpecialRenderer<T>)(tileEntityIn == null ? null : this.getSpecialRendererByClass(tileEntityIn.getClass()));
|
||||
}
|
||||
|
||||
public void cacheActiveRenderInfo(World worldIn, TextureManager textureManagerIn, Entity entityIn, float partialTicks)
|
||||
{
|
||||
if (this.worldObj != worldIn)
|
||||
{
|
||||
this.setWorld(worldIn);
|
||||
}
|
||||
|
||||
this.renderEngine = textureManagerIn;
|
||||
this.entity = entityIn;
|
||||
// this.fontRenderer = fontrendererIn;
|
||||
this.entityYaw = entityIn.prevYaw + (entityIn.rotYaw - entityIn.prevYaw) * partialTicks;
|
||||
this.entityPitch = entityIn.prevPitch + (entityIn.rotPitch - entityIn.prevPitch) * partialTicks;
|
||||
this.entityX = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks;
|
||||
this.entityY = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks;
|
||||
this.entityZ = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks;
|
||||
}
|
||||
|
||||
public void renderTileEntity(TileEntity tileentityIn, float partialTicks, int destroyStage)
|
||||
{
|
||||
if (tileentityIn.getDistanceSq(this.entityX, this.entityY, this.entityZ) < tileentityIn.getMaxRenderDistanceSquared())
|
||||
{
|
||||
int i = this.worldObj.getCombinedLight(tileentityIn.getPos(), 0);
|
||||
int j = i % 65536;
|
||||
int k = i / 65536;
|
||||
GL13.glMultiTexCoord2f(GL13.GL_TEXTURE1, (float)j / 1.0F, (float)k / 1.0F);
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
BlockPos blockpos = tileentityIn.getPos();
|
||||
this.renderTileEntityAt(tileentityIn, (double)blockpos.getX() - staticPlayerX, (double)blockpos.getY() - staticPlayerY, (double)blockpos.getZ() - staticPlayerZ, partialTicks, destroyStage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render this TileEntity at a given set of coordinates
|
||||
*/
|
||||
public void renderTileEntityAt(TileEntity tileEntityIn, double x, double y, double z, float partialTicks)
|
||||
{
|
||||
this.renderTileEntityAt(tileEntityIn, x, y, z, partialTicks, -1);
|
||||
}
|
||||
|
||||
public void renderTileEntityAt(TileEntity tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage)
|
||||
{
|
||||
TileEntitySpecialRenderer<TileEntity> tileentityspecialrenderer = this.<TileEntity>getSpecialRenderer(tileEntityIn);
|
||||
|
||||
if (tileentityspecialrenderer != null)
|
||||
{
|
||||
tileentityspecialrenderer.renderTileEntityAt(tileEntityIn, x, y, z, partialTicks, destroyStage);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWorld(World worldIn)
|
||||
{
|
||||
this.worldObj = worldIn;
|
||||
}
|
||||
|
||||
// public FontRenderer getFontRenderer()
|
||||
// {
|
||||
// return this.fontRenderer;
|
||||
// }
|
||||
private void render(TileEntity tile, double x, double y, double z, float partial, int destroy) {
|
||||
TileRenderer<TileEntity> renderer = this.<TileEntity>getRenderer(tile);
|
||||
if(renderer != null)
|
||||
renderer.renderTileEntityAt(tile, x, y, z, partial, destroy);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
package client.renderer.tileentity;
|
||||
|
||||
import client.renderer.texture.TextureManager;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.world.World;
|
||||
|
||||
public abstract class TileEntitySpecialRenderer<T extends TileEntity>
|
||||
{
|
||||
protected static final String[] DESTROY_STAGES = new String[] {
|
||||
"textures/blocks/destroy_stage_0.png",
|
||||
"textures/blocks/destroy_stage_1.png",
|
||||
"textures/blocks/destroy_stage_2.png",
|
||||
"textures/blocks/destroy_stage_3.png",
|
||||
"textures/blocks/destroy_stage_4.png",
|
||||
"textures/blocks/destroy_stage_5.png",
|
||||
"textures/blocks/destroy_stage_6.png",
|
||||
"textures/blocks/destroy_stage_7.png",
|
||||
"textures/blocks/destroy_stage_8.png",
|
||||
"textures/blocks/destroy_stage_9.png"
|
||||
};
|
||||
|
||||
protected TileEntityRendererDispatcher rendererDispatcher;
|
||||
|
||||
public abstract void renderTileEntityAt(T te, double x, double y, double z, float partialTicks, int destroyStage);
|
||||
|
||||
protected void bindTexture(String location)
|
||||
{
|
||||
TextureManager texturemanager = this.rendererDispatcher.renderEngine;
|
||||
|
||||
if (texturemanager != null)
|
||||
{
|
||||
texturemanager.bindTexture(location);
|
||||
}
|
||||
}
|
||||
|
||||
protected World getWorld()
|
||||
{
|
||||
return this.rendererDispatcher.worldObj;
|
||||
}
|
||||
|
||||
public void setRendererDispatcher(TileEntityRendererDispatcher rendererDispatcherIn)
|
||||
{
|
||||
this.rendererDispatcher = rendererDispatcherIn;
|
||||
}
|
||||
|
||||
// public FontRenderer getFontRenderer()
|
||||
// {
|
||||
// return this.rendererDispatcher.getFontRenderer();
|
||||
// }
|
||||
|
||||
/**
|
||||
* If true the {@link TileEntitySpecialRenderer} will always be rendered while the player is in the render bounding
|
||||
* box {@link TileEntity#getRenderBoundingBox()} and his squared distance with the {@link TileEntity} is smaller
|
||||
* than {@link TileEntity#getMaxRenderDistanceSquared()}.
|
||||
*/
|
||||
public boolean forceTileEntityRender()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
30
client/src/main/java/client/renderer/tileentity/TileRenderer.java
Executable file
30
client/src/main/java/client/renderer/tileentity/TileRenderer.java
Executable file
|
@ -0,0 +1,30 @@
|
|||
package client.renderer.tileentity;
|
||||
|
||||
import client.renderer.texture.TextureManager;
|
||||
import common.tileentity.TileEntity;
|
||||
|
||||
public abstract class TileRenderer<T extends TileEntity> {
|
||||
protected static final String[] DESTROY_STAGES = new String[] {
|
||||
"textures/blocks/destroy_stage_0.png", "textures/blocks/destroy_stage_1.png", "textures/blocks/destroy_stage_2.png", "textures/blocks/destroy_stage_3.png",
|
||||
"textures/blocks/destroy_stage_4.png", "textures/blocks/destroy_stage_5.png", "textures/blocks/destroy_stage_6.png", "textures/blocks/destroy_stage_7.png",
|
||||
"textures/blocks/destroy_stage_8.png", "textures/blocks/destroy_stage_9.png"
|
||||
};
|
||||
|
||||
private final TileEntityRendererDispatcher renderer;
|
||||
|
||||
public TileRenderer(TileEntityRendererDispatcher renderer) {
|
||||
this.renderer = renderer;
|
||||
}
|
||||
|
||||
public abstract void renderTileEntityAt(T te, double x, double y, double z, float partialTicks, int destroyStage);
|
||||
|
||||
protected final void bindTexture(String location) {
|
||||
TextureManager manager = this.renderer.manager;
|
||||
if(manager != null)
|
||||
manager.bindTexture(location);
|
||||
}
|
||||
|
||||
public boolean isAlwaysRendered() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ public class PlayerController {
|
|||
boolean flag = world.setBlockToAir(pos);
|
||||
|
||||
if(flag) {
|
||||
block.onBlockDestroyedByPlayer(world, pos, state);
|
||||
block.onBroken(world, pos, state);
|
||||
}
|
||||
|
||||
this.position = new BlockPos(this.position.getX(), -1, this.position.getZ());
|
||||
|
@ -101,10 +101,10 @@ public class PlayerController {
|
|||
boolean flag = block != Blocks.air;
|
||||
|
||||
if(flag && this.damage == 0.0F) {
|
||||
block.onBlockClicked(this.gm.world, pos, this.gm.player);
|
||||
block.onStartBreak(this.gm.world, pos, this.gm.player);
|
||||
}
|
||||
|
||||
if(flag && block.getPlayerRelativeBlockHardness(this.gm.player, this.gm.player.worldObj, pos) >= 1.0F) {
|
||||
if(flag && block.getHardness(this.gm.player, this.gm.player.worldObj, pos) >= 1.0F) {
|
||||
this.destroyBlock(pos, face);
|
||||
this.delay = 3;
|
||||
}
|
||||
|
@ -152,10 +152,10 @@ public class PlayerController {
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
this.damage += block.getPlayerRelativeBlockHardness(this.gm.player, this.gm.player.worldObj, pos);
|
||||
this.damage += block.getHardness(this.gm.player, this.gm.player.worldObj, pos);
|
||||
|
||||
if(this.stepCounter % 4.0F == 0.0F && block.sound.getStepSound() != null) {
|
||||
this.gm.getSoundManager().playSound(new PositionedSound(block.sound.getStepSound(), 0.25F,
|
||||
if(this.stepCounter % 4.0F == 0.0F && block.getSound().getStepSound() != null) {
|
||||
this.gm.getSoundManager().playSound(new PositionedSound(block.getSound().getStepSound(), 0.25F,
|
||||
(float)pos.getX() + 0.5F, (float)pos.getY() + 0.5F, (float)pos.getZ() + 0.5F));
|
||||
}
|
||||
|
||||
|
@ -228,11 +228,11 @@ public class PlayerController {
|
|||
State iblockstate = world.getState(pos);
|
||||
|
||||
if((!player.isSneaking() || player.getHeldItem() == null)
|
||||
&& iblockstate.getBlock().onBlockActivated(world, pos, iblockstate, player, side, f, f1, f2)) {
|
||||
&& iblockstate.getBlock().onUse(world, pos, iblockstate, player, side, f, f1, f2)) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if(!flag && stack != null && stack.getItem().getBlock() != null && !stack.getItem().getBlock().canPlace(world, pos, side, player, stack))
|
||||
if(!flag && stack != null && stack.getItem().getBlock() != null && !stack.getItem().getBlock().checkPlace(world, pos, side, player, stack))
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -312,7 +312,7 @@ public class WorldClient extends AWorldClient
|
|||
int z = posZ + rand.zrange(DISPLAY_RANGE) - rand.zrange(DISPLAY_RANGE);
|
||||
pos.set(x, y, z);
|
||||
State state = this.getState(pos);
|
||||
state.getBlock().randomDisplayTick(this, pos, state, rand);
|
||||
state.getBlock().displayTick(this, pos, state, rand);
|
||||
}
|
||||
if(this.dimension.hasVoidFog() && this.gm.voidParticles && posY < 32) {
|
||||
for(int n = 0; n < 1000; n++) {
|
||||
|
@ -634,7 +634,7 @@ public class WorldClient extends AWorldClient
|
|||
|
||||
if (state != null && state.getBlock() != Blocks.air)
|
||||
{
|
||||
this.gm.getSoundManager().playSound(new PositionedSound(state.getBlock().sound.getBreakSound(), 1.0F, /* block.sound.getFrequency() * 0.8F, */ (float)blockPosIn.getX() + 0.5F, (float)blockPosIn.getY() + 0.5F, (float)blockPosIn.getZ() + 0.5F));
|
||||
this.gm.getSoundManager().playSound(new PositionedSound(state.getBlock().getSound().getBreakSound(), 1.0F, /* block.sound.getFrequency() * 0.8F, */ (float)blockPosIn.getX() + 0.5F, (float)blockPosIn.getY() + 0.5F, (float)blockPosIn.getZ() + 0.5F));
|
||||
}
|
||||
if(state != null)
|
||||
this.gm.effectRenderer.destroyBlock(blockPosIn, state);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue