use of net.minecraftforge.client.model.data.IModelData in project Bookshelf by Darkhax-Minecraft.
the class RenderUtils method renderModel.
/**
* Renders a block model. Allows the sites rendered to be specifically controlled by the
* caller.
*
* @param renderer The block model renderer instance.
* @param world The world instance.
* @param model The model to render.
* @param state The state of the block.
* @param pos The position of the block.
* @param matrix The render matrix.
* @param buffer The render buffer.
* @param sides The sides of the model to render.
*/
public static void renderModel(BlockModelRenderer renderer, IBlockDisplayReader world, IBakedModel model, BlockState state, BlockPos pos, MatrixStack matrix, IVertexBuilder buffer, Direction[] sides) {
final IModelData modelData = model.getModelData(world, pos, state, EmptyModelData.INSTANCE);
// Renders only the sided model quads.
for (final Direction side : sides) {
RANDOM.setSeed(0L);
final List<BakedQuad> sidedQuads = model.getQuads(state, side, RANDOM, modelData);
if (!sidedQuads.isEmpty()) {
final int lightForSide = WorldRenderer.getLightColor(world, state, pos.relative(side));
renderer.renderModelFaceFlat(world, state, pos, lightForSide, OverlayTexture.NO_OVERLAY, false, matrix, buffer, sidedQuads, BITS);
}
}
// Renders the non-sided model quads.
RANDOM.setSeed(0L);
final List<BakedQuad> unsidedQuads = model.getQuads(state, null, RANDOM, modelData);
if (!unsidedQuads.isEmpty()) {
renderer.renderModelFaceFlat(world, state, pos, -1, OverlayTexture.NO_OVERLAY, true, matrix, buffer, unsidedQuads, BITS);
}
}
use of net.minecraftforge.client.model.data.IModelData in project BluePower by Qmunity.
the class BPMultipartModel method getQuads.
@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
BlockRendererDispatcher brd = Minecraft.getInstance().getBlockRenderer();
Map<BlockState, IModelData> stateInfo = extraData.getData(TileBPMultipart.STATE_INFO);
if (stateInfo != null) {
return stateInfo.keySet().stream().flatMap(i -> brd.getBlockModel(i).getQuads(i, side, rand, stateInfo.get(i)).stream().map(q -> stateInfo.get(i).hasProperty(TileWire.COLOR_INFO) ? transform(q, stateInfo.get(i).getData(TileWire.COLOR_INFO), stateInfo.get(i).hasProperty(TileWire.LIGHT_INFO) ? stateInfo.get(i).getData(TileWire.LIGHT_INFO) : false) : q)).collect(Collectors.toList());
} else {
return Collections.emptyList();
}
}
use of net.minecraftforge.client.model.data.IModelData in project MinecraftForge by MinecraftForge.
the class ModelDataManager method refreshModelData.
private static void refreshModelData(Level world, ChunkPos chunk) {
cleanCaches(world);
Set<BlockPos> needUpdate = needModelDataRefresh.remove(chunk);
if (needUpdate != null) {
Map<BlockPos, IModelData> data = modelDataCache.computeIfAbsent(chunk, $ -> new ConcurrentHashMap<>());
for (BlockPos pos : needUpdate) {
BlockEntity toUpdate = world.getBlockEntity(pos);
if (toUpdate != null && !toUpdate.isRemoved()) {
data.put(pos, toUpdate.getModelData());
} else {
data.remove(pos);
}
}
}
}
Aggregations