use of net.minecraft.client.renderer.BlockRendererDispatcher in project BuildCraft by BuildCraft.
the class FakeWorldManager method renderBlock.
private void renderBlock(BlockPos pos, EnumWorldBlockLayer layer, WorldRenderer renderer) {
IBlockState actualState = world.getBlockState(pos);
Block block = actualState.getBlock();
if (block == Blocks.air || block == null) {
return;
}
if (!block.canRenderInLayer(layer)) {
return;
}
actualState = block.getActualState(actualState, world, pos);
BlockRendererDispatcher dispatcher = mc.getBlockRendererDispatcher();
IBakedModel model = dispatcher.getBlockModelShapes().getModelForState(actualState);
if (model == null || model.getParticleTexture() == null || model.getGeneralQuads() == null) {
return;
}
boolean checkSides = pos.getY() > 0;
try {
dispatcher.getBlockModelRenderer().renderModelStandard(world, model, block, pos, renderer, checkSides);
} catch (Throwable t) {
BCLog.logger.warn("The model from the block " + block + " was invalid for layer " + layer, t);
}
}
use of net.minecraft.client.renderer.BlockRendererDispatcher in project HorsePower by GoryMoon.
the class ColorGetter method getTextureAtlasSprite.
@Nullable
private static TextureAtlasSprite getTextureAtlasSprite(IBlockState blockState) {
Minecraft minecraft = Minecraft.getMinecraft();
BlockRendererDispatcher blockRendererDispatcher = minecraft.getBlockRendererDispatcher();
BlockModelShapes blockModelShapes = blockRendererDispatcher.getBlockModelShapes();
TextureAtlasSprite textureAtlasSprite = blockModelShapes.getTexture(blockState);
if (textureAtlasSprite == minecraft.getTextureMapBlocks().getMissingSprite()) {
return null;
}
return textureAtlasSprite;
}
use of net.minecraft.client.renderer.BlockRendererDispatcher in project Adventurers-Toolbox by the-realest-stu.
the class ExtraBlockBreakHandler method drawBlockDamageTexture.
private void drawBlockDamageTexture(Tessellator tessellatorIn, BufferBuilder bufferBuilderIn, Entity entityIn, float partialTicks) {
double d3 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
double d4 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
double d5 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;
if (this.mc.world.getWorldTime() % 20 == 0) {
this.cleanupExtraDamagedBlocks();
}
if (!this.extraDamagedBlocks.isEmpty()) {
this.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
this.preRenderDamagedBlocks();
bufferBuilderIn.begin(7, DefaultVertexFormats.BLOCK);
bufferBuilderIn.setTranslation(-d3, -d4, -d5);
bufferBuilderIn.noColor();
for (Entry<Integer, DestroyExtraBlocksProgress> entry : this.extraDamagedBlocks.entrySet()) {
DestroyExtraBlocksProgress destroyblockprogress = entry.getValue();
BlockPos[] blockpositions = destroyblockprogress.getPositions();
for (int i = 0; i < blockpositions.length; i++) {
BlockPos blockpos = blockpositions[i];
double d6 = (double) blockpos.getX() - d3;
double d7 = (double) blockpos.getY() - d4;
double d8 = (double) blockpos.getZ() - d5;
Block block = this.mc.world.getBlockState(blockpos).getBlock();
TileEntity te = this.mc.world.getTileEntity(blockpos);
boolean hasBreak = block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull;
if (!hasBreak)
hasBreak = te != null && te.canRenderBreaking();
if (!hasBreak) {
if (d6 * d6 + d7 * d7 + d8 * d8 > 16384) {
this.extraDamagedBlocks.remove(entry.getKey());
} else {
IBlockState iblockstate = mc.world.getBlockState(blockpos);
if (iblockstate.getMaterial() != Material.AIR) {
int k1 = destroyblockprogress.getPartialBlockDamage();
TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[k1];
BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, this.mc.world);
}
}
}
}
}
tessellatorIn.draw();
bufferBuilderIn.setTranslation(0.0D, 0.0D, 0.0D);
this.postRenderDamagedBlocks();
}
}
use of net.minecraft.client.renderer.BlockRendererDispatcher in project EnderIO by SleepyTrousers.
the class IoConfigRenderer method renderBlock.
public void renderBlock(@Nonnull IBlockState state, @Nonnull BlockPos pos, @Nonnull IBlockAccess blockAccess, @Nonnull BufferBuilder worldRendererIn) {
try {
BlockRendererDispatcher blockrendererdispatcher = mc.getBlockRendererDispatcher();
EnumBlockRenderType type = state.getRenderType();
if (type != EnumBlockRenderType.MODEL) {
blockrendererdispatcher.renderBlock(state, pos, blockAccess, worldRendererIn);
return;
}
// We only want to change one param here, the check sides
IBakedModel ibakedmodel = blockrendererdispatcher.getModelForState(state);
state = state.getBlock().getExtendedState(state, world, pos);
blockrendererdispatcher.getBlockModelRenderer().renderModel(blockAccess, ibakedmodel, state, pos, worldRendererIn, false);
} catch (Throwable throwable) {
// Just bury a render issue here, it is only the IO screen
}
}
use of net.minecraft.client.renderer.BlockRendererDispatcher in project ForestryMC by ForestryMC.
the class CamouflageHandlerBlock method getModel.
@SideOnly(Side.CLIENT)
@Override
public Pair<IBlockState, IBakedModel> getModel(ItemStack stack) {
Preconditions.checkArgument(!stack.isEmpty(), "Stack cannot be empty");
BlockRendererDispatcher rendererDispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockModelShapes modelShapes = rendererDispatcher.getBlockModelShapes();
Block block = Block.getBlockFromItem(stack.getItem());
Preconditions.checkArgument(block != Blocks.AIR, "Block cannot be AIR");
IBlockState state = block.getStateFromMeta(stack.getItemDamage());
return Pair.of(state, modelShapes.getModelForState(state));
}
Aggregations