net.minecraft.block.Block.canRenderInLayer()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中net.minecraft.block.Block.canRenderInLayer()方法的一些代码示例,展示了Block.canRenderInLayer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.canRenderInLayer()方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:canRenderInLayer

Block.canRenderInLayer介绍

暂无

代码示例

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
  public boolean useAlphaPass( final ItemStack is )
  {
    IBlockState blockState = this.getTextureBlockState( is );

    if( blockState == null )
    {
      return false;
    }

    Block blk = blockState.getBlock();
    return blk.canRenderInLayer( blockState, BlockRenderLayer.TRANSLUCENT );
  }
}

代码示例来源:origin: Vazkii/Botania

return ImmutableList.of();
if(heldState.getBlock().canRenderInLayer(heldState, layer)) {
  IBlockState actual = heldState.getBlock().getActualState(heldState, new FakeBlockAccess(heldWorld), heldPos);

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

if( !blockState.getBlock().canRenderInLayer( blockState, layer ) )
  if( blockState.getBlock().canRenderInLayer( blockState, forcedLayer ) )

代码示例来源:origin: SleepyTrousers/EnderIO

public static boolean canRenderInLayer(@Nullable IBlockState paintSource, @Nonnull BlockRenderLayer blockLayer) {
 if (blockLayer == BREAKING) {
  return true;
 } else if (paintSource != null) {
  return paintSource.getBlock().canRenderInLayer(paintSource, blockLayer);
 } else {
  return blockLayer == BlockRenderLayer.SOLID;
 }
}

代码示例来源:origin: Chisel-Team/Chisel

@Override
@SideOnly(Side.CLIENT)
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
  return super.canRenderInLayer(state, layer);
}

代码示例来源:origin: amadornes/MCMultiPart

@Override
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
  return state.getBlock().canRenderInLayer(state, layer);
}

代码示例来源:origin: amadornes/MCMultiPart

public default boolean canRenderInLayer(IBlockAccess world, BlockPos pos, IPartInfo part, IBlockState state, BlockRenderLayer layer) {
  return state.getBlock().canRenderInLayer(state, layer);
}

代码示例来源:origin: AlgorithmX2/Chisels-and-Bits

@Override
public boolean isVisible(
    final int mySpot,
    final int secondSpot )
{
  final VoxelType myType = BlockBitInfo.getTypeFromStateID( mySpot );
  final VoxelType secondType = BlockBitInfo.getTypeFromStateID( secondSpot );
  final IBlockState state = ModUtil.getStateById( secondSpot );
  final boolean isTranslusent = state.getBlock().canRenderInLayer( state, BlockRenderLayer.TRANSLUCENT ) || state.getBlock().canRenderInLayer( state, BlockRenderLayer.CUTOUT )
      || state.getBlock().canRenderInLayer( state, BlockRenderLayer.CUTOUT_MIPPED );
  return myType != VoxelType.AIR && ( myType != secondType || isTranslusent && mySpot != secondSpot );
}

代码示例来源:origin: CyclopsMC/EvilCraft

@Override
public List<BakedQuad> getGeneralQuads() {
  BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
  List<BakedQuad> quads;
  try {
    if(layer == null || innerBlockState.getBlock().canRenderInLayer(innerBlockState, layer)) {
      // Yes, we do want to run this if layer is null. If we don't, we don't get block breaking textures
      quads = Lists.newArrayList(baseModel.getQuads(innerBlockState, getRenderingSide(), rand));
    } else {
      quads = Lists.newArrayList();
    }
  } catch (Exception e) {
    quads = Lists.newArrayList(); // It's better to render a bit stranger, than to crash all together.
  }
  if((facing == EnumFacing.UP || facing == null) && layer == BlockRenderLayer.CUTOUT_MIPPED) {
    addBakedQuad(quads, 0, 1, 0, 1, 1.01F, overlayIcon, EnumFacing.UP);
  }
  return quads;
}

代码示例来源:origin: McJtyMods/XNet

@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
  IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
  FacadeBlockId facadeId = extendedBlockState.getValue(GenericCableBlock.FACADEID);
  if (facadeId == null) {
    return Collections.emptyList();
  }
  IBlockState facadeState = facadeId.getBlockState();
  BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
  if (layer != null && !facadeState.getBlock().canRenderInLayer(facadeState, layer)) { // always render in the null layer or the block-breaking textures don't show up
    return Collections.emptyList();
  }
  IBakedModel model = getModel(facadeState);
  try {
    return model.getQuads(state, side, rand);
  } catch (Exception e) {
    return Collections.emptyList();
  }
}

代码示例来源:origin: PenguinSquad/Harvest-Festival

protected void addRender(IBlockAccess world, IBlockState state, BlockPos pos, BlockRenderLayer layer, VertexBuffer buffer) {
  if (state.getBlock().canRenderInLayer(state, layer)) {
    Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlock(state, pos, world, buffer);
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
 public void apply(@Nonnull BlockPos pos) {
  IBlockState bs = world.getBlockState(pos);
  Block block = bs.getBlock();
  bs = bs.getActualState(world, pos);
  if (block.canRenderInLayer(bs, layer)) {
   renderBlock(bs, pos, world, Tessellator.getInstance().getBuffer());
  }
 }
});

代码示例来源:origin: thraaawn/CompactMachines

public void renderLayer(BlockRendererDispatcher blockrendererdispatcher, BufferBuilder buffer, BlockRenderLayer renderLayer, List<BlockPos> toRender) {
    for (BlockPos pos : toRender) {
      IBlockState state = recipe.getStateAtBlockPos(pos);
      if (!state.getBlock().canRenderInLayer(state, renderLayer)) {
        continue;
      }

      ForgeHooksClient.setRenderLayer(renderLayer);
      try {
        blockrendererdispatcher.renderBlock(state, pos, blockAccess, buffer);
      } catch (Exception e) {
        e.printStackTrace();
      }
      ForgeHooksClient.setRenderLayer(null);
    }
  }
}

代码示例来源:origin: thraaawn/CompactMachines

public void renderLayer(BlockRendererDispatcher blockrendererdispatcher, BufferBuilder buffer, BlockRenderLayer renderLayer) {
    for (BlockPos pos : toRender) {
      IBlockState state = proxyWorld.getBlockState(pos);
      if (!state.getBlock().canRenderInLayer(state, renderLayer)) {
        continue;
      }
      ForgeHooksClient.setRenderLayer(renderLayer);
      try {
        blockrendererdispatcher.renderBlock(state, pos, blockAccess, buffer);
      } catch (Exception e) {
        e.printStackTrace();
      }
      ForgeHooksClient.setRenderLayer(null);
    }
  }
}

代码示例来源:origin: thraaawn/CompactMachines

public void renderLayer(BlockRendererDispatcher blockrendererdispatcher, BufferBuilder buffer, BlockRenderLayer renderLayer, List<BlockPos> toRender) {
  IBlockAccess blockAccess = ChunkUtils.getBlockAccessFromChunk(GuiMachineData.chunk);
  for (BlockPos pos : toRender) {
    IBlockState state = blockAccess.getBlockState(pos);
    if (!state.getBlock().canRenderInLayer(state, renderLayer)) {
      continue;
    }
    try {
      state = state.getActualState(blockAccess, pos);
    } catch (Exception e) {
      Logz.debug("Could not determine actual state of block: %s", state.getBlock());
    }
    ForgeHooksClient.setRenderLayer(renderLayer);
    try {
      blockrendererdispatcher.renderBlock(state, pos, blockAccess, buffer);
    } catch (Exception e) {
      e.printStackTrace();
    }
    ForgeHooksClient.setRenderLayer(null);
  }
}

代码示例来源:origin: CoFH/ThermalDynamics

@Override
@SideOnly (Side.CLIENT)
public boolean render(IBlockAccess world, BlockRenderLayer layer, CCRenderState ccrs) {
  if (!state.getBlock().canRenderInLayer(state, layer)) {
    return false;
  }
  Attachment attachment = baseTile.getAttachment(side);
  CoverTransformer transformer = null;
  if (attachment != null) {
    transformer = attachment.getHollowMask();
  }
  if (transformer == null) {
    transformer = baseTile.getHollowMask(side);
  }
  return CoverRenderer.renderBlockCover(ccrs, world, baseTile.getPos(), side, state, getCuboid(), transformer);
}

代码示例来源:origin: SleepyTrousers/EnderIO

@SuppressWarnings("null")
public static void renderBlockModel(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, boolean translateToOrigin, boolean relight) {
 BufferBuilder wr = Tessellator.getInstance().getBuffer();
 wr.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
 if (translateToOrigin) {
  wr.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
 }
 BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
 BlockModelShapes modelShapes = blockrendererdispatcher.getBlockModelShapes();
 IBakedModel ibakedmodel = modelShapes.getModelForState(state);
 final IBlockAccess worldWrapper = relight ? new WorldWrapper(world, pos) : world;
 for (BlockRenderLayer layer : BlockRenderLayer.values()) {
  if (state.getBlock().canRenderInLayer(state, layer)) {
   ForgeHooksClient.setRenderLayer(layer);
   blockrendererdispatcher.getBlockModelRenderer().renderModel(worldWrapper, ibakedmodel, state, pos, wr, false);
  }
 }
 ForgeHooksClient.setRenderLayer(null);
 if (translateToOrigin) {
  wr.setTranslation(0, 0, 0);
 }
 Tessellator.getInstance().draw();
}

代码示例来源:origin: OpenMods/OpenModsLib

private void drawBlock() {
  final Tessellator tessellator = Tessellator.getInstance();
  final BufferBuilder wr = tessellator.getBuffer();
  final BlockRendererDispatcher dispatcher = parent.getMinecraft().getBlockRendererDispatcher();
  for (BlockRenderLayer layer : BlockRenderLayer.values()) {
    if (blockState.getBlock().canRenderInLayer(blockState, layer)) {
      net.minecraftforge.client.ForgeHooksClient.setRenderLayer(layer);
      wr.setTranslation(-0.5, -0.5, -0.5);
      wr.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
      dispatcher.renderBlock(blockState, FakeBlockAccess.ORIGIN, access, wr);
      tessellator.draw();
    }
  }
  wr.setTranslation(0.0D, 0.0D, 0.0D);
  net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null);
}

代码示例来源:origin: Vazkii/Patchouli

private void doWorldRenderPass(Multiblock mb, Iterable<? extends BlockPos> blocks, final @Nonnull BlockRenderLayer layer, Vector4f eye) {
  mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  mc.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
  
  ForgeHooksClient.setRenderLayer(layer);
  setGlStateForPass(layer);
  
  BufferBuilder wr = Tessellator.getInstance().getBuffer();
  wr.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
  for (BlockPos pos : blocks) {
    IBlockState bs = mb.getBlockState(pos);
    Block block = bs.getBlock();
    bs = bs.getActualState(mb, pos);
    if (block.canRenderInLayer(bs, layer)) {
      renderBlock(bs, pos, mb, Tessellator.getInstance().getBuffer());
    }
  }
  if (layer == BlockRenderLayer.TRANSLUCENT) {
    wr.sortVertexData(eye.x, eye.y, eye.z);
  }
  Tessellator.getInstance().draw();
}

代码示例来源:origin: RS485/LogisticsPipes

private void doWorldRenderPass(Vector3d trans, List<DoubleCoordinates> blocks, BlockRenderLayer layer) {
  BufferBuilder wr = Tessellator.getInstance().getBuffer();
  wr.begin(7, DefaultVertexFormats.BLOCK);
  Tessellator.getInstance().getBuffer().setTranslation(trans.x, trans.y, trans.z);
  for (DoubleCoordinates bc : blocks) {
    IBlockState bs = world.getBlockState(bc.getBlockPos());
    Block block = bs.getBlock();
    bs = bs.getActualState(world, bc.getBlockPos());
    if (block.canRenderInLayer(bs, layer)) {
      renderBlock(bs, bc.getBlockPos(), world, Tessellator.getInstance().getBuffer());
    }
  }
  Tessellator.getInstance().draw();
  Tessellator.getInstance().getBuffer().setTranslation(0, 0, 0);
}

相关文章

Block类方法