use of net.minecraft.client.renderer.model.BakedQuad 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.minecraft.client.renderer.model.BakedQuad in project AgriCraft by AgriCraft.
the class MysticalAgricultureCompatClient method bakeQuadsForMystical.
@Nonnull
private static List<BakedQuad> bakeQuadsForMystical(IAgriGrowable growable, IAgriGrowthStage stage, @Nullable Direction face, IntFunction<TextureAtlasSprite> spriteFunc) {
if (face != null) {
return ImmutableList.of();
}
ITessellator tessellator = AgriPlantQuadGenerator.getInstance().getTessellator();
TextureAtlasSprite sprite = spriteFunc.apply(0);
tessellator.startDrawingQuads();
tessellator.setFace((Direction) null);
tessellator.pushMatrix();
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, sprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, sprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, sprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, sprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, sprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, sprite, 11.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, sprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, sprite, 11.999F, 0, 0, 16, 16);
if (stage.isFinal()) {
IAgriPlant plant = ((IAgriPlant) growable);
int flowerColor = MysticalAgricultureCompatClient.colorForFlower(plant.getId());
TextureAtlasSprite flowerSprite = spriteFunc.apply(1);
if (flowerColor != -1) {
tessellator.setColorRGB(((flowerColor >> 16) & 0xFF) / 255.0F, ((flowerColor >> 8) & 0xFF) / 255.0F, ((flowerColor) & 0xFF) / 255.0F);
}
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, flowerSprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, flowerSprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, flowerSprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, flowerSprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, flowerSprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, flowerSprite, 11.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, flowerSprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, flowerSprite, 11.999F, 0, 0, 16, 16);
}
tessellator.translate(0, 12.0F / 16.0F, 0);
tessellator.popMatrix();
List<BakedQuad> quads = tessellator.getQuads();
tessellator.draw();
return quads;
}
use of net.minecraft.client.renderer.model.BakedQuad in project AgriCraft by AgriCraft.
the class BotanyPotsPlantRenderer method fetchQuads.
protected List<BakedQuad> fetchQuads(IAgriWeed weed, IAgriGrowthStage stage, Direction... sides) {
List<BakedQuad> quads = Lists.newArrayList();
for (Direction dir : sides) {
quads.addAll(AgriPlantModelBridge.getOrBakeQuads(weed, stage, dir));
}
quads.addAll(AgriPlantModelBridge.getOrBakeQuads(weed, stage, null));
return quads;
}
use of net.minecraft.client.renderer.model.BakedQuad 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.minecraft.client.renderer.model.BakedQuad in project BluePower by Qmunity.
the class BPMultipartModel method transform.
private static BakedQuad transform(BakedQuad quad, Pair<Integer, Integer> colorPair, Boolean fullBright) {
BakedQuadBuilder builder = new BakedQuadBuilder();
final IVertexConsumer consumer = new VertexTransformer(builder) {
@Override
public void put(int element, float... data) {
VertexFormatElement e = this.getVertexFormat().getElements().get(element);
if (e.getUsage() == VertexFormatElement.Usage.COLOR) {
int color = quad.getTintIndex() == 2 ? colorPair.getSecond() : colorPair.getFirst();
int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
int r = (color & redMask) >> 16;
int g = (color & greenMask) >> 8;
int b = (color & blueMask);
parent.put(element, r / 255F, g / 255F, b / 255F, 1);
} else {
parent.put(element, data);
}
}
};
LightUtil.putBakedQuad(consumer, quad);
BakedQuad finalQuad = builder.build();
if (fullBright)
LightUtil.setLightData(finalQuad, 240);
return finalQuad;
}
Aggregations