Java Code Examples for net.minecraft.client.renderer.vertex.DefaultVertexFormats#ITEM

The following examples show how to use net.minecraft.client.renderer.vertex.DefaultVertexFormats#ITEM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderUtils.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Reimplement vanilla item so we can draw pearl stacks with opacity support.
 */
private static void renderLitItem(RenderItem ri, IBakedModel model, int color, ItemStack stack) {
	List<BakedQuad> allquads = new ArrayList<>();

	for (EnumFacing enumfacing : EnumFacing.VALUES) {
		allquads.addAll(model.getQuads(null, enumfacing, 0));
	}

	allquads.addAll(model.getQuads(null, null, 0));

	if (allquads.isEmpty()) return;

	// Current list of consecutive quads with the same lighting
	List<BakedQuad> segment = new ArrayList<>();

	// Lighting of the current segment
	int segmentBlockLight = -1;
	int segmentSkyLight = -1;
	// Coloring of the current segment
	int segmentColorMultiplier = color;
	// If the current segment contains lighting data
	boolean hasLighting = false;

	// Tint index cache to avoid unnecessary IItemColor lookups
	int prevTintIndex = -1;

	for (int i = 0; i < allquads.size(); i++) {
		BakedQuad q = allquads.get(i);

		// Lighting of the current quad
		int bl = 0;
		int sl = 0;

		// Fail-fast on ITEM, as it cannot have light data
		if (q.getFormat() != DefaultVertexFormats.ITEM && q.getFormat().hasUvOffset(1)) {
			q.pipe(lightGatherer);
			if (lightGatherer.hasLighting()) {
				bl = lightGatherer.blockLight;
				sl = lightGatherer.skyLight;
			}
		}

		int colorMultiplier = segmentColorMultiplier;

		// If there is no color override, and this quad is tinted, we need to apply IItemColor
		if (color == 0xFFFFFFFF && q.hasTintIndex()) {
			int tintIndex = q.getTintIndex();

			if (prevTintIndex != tintIndex) {
				colorMultiplier = getColorMultiplier(stack, tintIndex);
			}
			prevTintIndex = tintIndex;
		} else {
			colorMultiplier = color;
			prevTintIndex = -1;
		}

		boolean lightingDirty = segmentBlockLight != bl || segmentSkyLight != sl;
		boolean colorDirty = hasLighting && segmentColorMultiplier != colorMultiplier;

		// If lighting or color data has changed, draw the segment and flush it
		if (lightingDirty || colorDirty) {
			if (i > 0) // Make sure this isn't the first quad being processed
			{
				drawSegment(color, stack, segment, segmentBlockLight, segmentSkyLight, segmentColorMultiplier, lightingDirty && (hasLighting || segment.size() < i), colorDirty);
			}
			segmentBlockLight = bl;
			segmentSkyLight = sl;
			segmentColorMultiplier = colorMultiplier;
			hasLighting = segmentBlockLight > 0 || segmentSkyLight > 0;
		}

		segment.add(q);
	}

	drawSegment(color, stack, segment, segmentBlockLight, segmentSkyLight, segmentColorMultiplier, hasLighting || segment.size() < allquads.size(), false);

	// Clean up render state if necessary
	if (hasLighting) {
		OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, OpenGlHelper.lastBrightnessX, OpenGlHelper.lastBrightnessY);
		GL11.glMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_EMISSION, RenderHelper.setColorBuffer(0, 0, 0, 1));
	}
}
 
Example 2
Source File: BWBakedModel.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public BWBakedModel(IBakedModel wrapped) {
	this(wrapped, DefaultVertexFormats.ITEM);
}
 
Example 3
Source File: BWBakedModel.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public BWBakedModel(@SuppressWarnings("deprecation") net.minecraft.client.resources.model.IBakedModel wrapped) {
	this(wrapped, DefaultVertexFormats.ITEM);
}