net.minecraft.client.renderer.BlockModelRenderer Java Examples

The following examples show how to use net.minecraft.client.renderer.BlockModelRenderer. 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: RendererBackpack.java    From WearableBackpacks with MIT License 5 votes vote down vote up
private static void renderBackpack(IBackpack backpack, float ticks, boolean renderStraps) {
	ItemStack stack = backpack.getStack();
	int color = ProxyClient.ITEM_COLOR.colorMultiplier(stack, 0);
	
	BlockModelRenderer renderer = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer();
	Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
	
	float r = (color >> 16 & 0xFF) / 255.0F;
	float g = (color >> 8 & 0xFF) / 255.0F;
	float b = (color & 0xFF) / 255.0F;
	renderModel(backpack, renderer, ticks, renderStraps, r, g, b, false);
	
	if (stack.isItemEnchanted())
		renderEnchanted(backpack, renderer, ticks, renderStraps);
}
 
Example #2
Source File: RendererBackpack.java    From WearableBackpacks with MIT License 5 votes vote down vote up
private static void renderModel(IBackpack backpack, BlockModelRenderer renderer,
                                float ticks, boolean renderStraps,
                                float r, float g, float b, boolean useEnch) {
	
	IBakedModel baseModel = (useEnch ? ProxyClient.MODEL_BACKPACK_ENCH : ProxyClient.MODEL_BACKPACK);
	renderer.renderModelBrightnessColor(baseModel, 1.0F, r, g, b);
	if (renderStraps)
		renderer.renderModelBrightnessColor(ProxyClient.MODEL_BACKPACK_STRAPS, 1.0F, r, g, b);
	
	float lidAngle = 0.0F;
	IBackpackType type = backpack.getType();
	if (type != null) {
		int lidTicks = backpack.getLidTicks();
		int prevLidTicks = backpack.getPrevLidTicks();
		lidAngle = type.getLidAngle(lidTicks, prevLidTicks, ticks % 1);
	}
	
	// FIXME: Allow for custom, adjustable lid position.
	float lidYOffset = 9 / 16.0F;
	float lidZOffset = 5 / 16.0F;

	GlStateManager.pushMatrix();
	GlStateManager.translate(0.0F, lidYOffset, lidZOffset);
	GlStateManager.rotate(lidAngle, -1.0F, 0.0F, 0.0F);
	GlStateManager.translate(0.0F, -lidYOffset, -lidZOffset);
	IBakedModel topModel = (useEnch ? ProxyClient.MODEL_BACKPACK_ENCH_TOP : ProxyClient.MODEL_BACKPACK_TOP);
	renderer.renderModelBrightnessColor(topModel, 1.0F, r, g, b);
	GlStateManager.popMatrix();
	
}
 
Example #3
Source File: MixinBlockModelRenderer.java    From VanillaFix with MIT License 4 votes vote down vote up
/**
 * @reason Adds the textures used to render this block to the set of textures in
 * the CompiledChunk.
 */
@Inject(method = "renderQuadsSmooth", at = @At("HEAD"))
private void onRenderQuadsSmooth(IBlockAccess blockAccess, IBlockState state, BlockPos pos, BufferBuilder buffer, List<BakedQuad> quads, float[] quadBounds, BitSet bitSet, BlockModelRenderer.AmbientOcclusionFace aoFace, CallbackInfo ci) {
    markQuads(quads);
}
 
Example #4
Source File: RendererBackpack.java    From WearableBackpacks with MIT License 4 votes vote down vote up
private static void renderEnchanted(IBackpack backpack, BlockModelRenderer renderer,
                                    float ticks, boolean renderStraps) {
	
	Minecraft mc = Minecraft.getMinecraft();
	float glintStrength = WearableBackpacks.CONFIG.cosmetic.enchantEffectOpacity.get().floatValue();
	if (glintStrength <= 0) return;
	float glintScale   = 1.5F;
	float animProgress = ticks / 10;
	
	int color = IntermodUtils.getRuneColor(backpack.getStack());
	float r = (color >> 16 & 0xFF) / 255.0F * glintStrength;
	float g = (color >>  8 & 0xFF) / 255.0F * glintStrength;
	float b = (color       & 0xFF) / 255.0F * glintStrength;
	
	mc.getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT);
	mc.entityRenderer.setupFogColor(true);
	
	GlStateManager.disableLighting();
	GlStateManager.depthMask(false);
	GlStateManager.depthFunc(GL11.GL_EQUAL);
	GlStateManager.enableBlend();
	GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE);
	
	for (int i = 0; i < 2; ++i) {
		GlStateManager.matrixMode(GL11.GL_TEXTURE);
		GlStateManager.loadIdentity();
		GlStateManager.scale(glintScale, glintScale, glintScale);
		GlStateManager.rotate(30.0F - i * 60.0F, 0.0F, 0.0F, 1.0F);
		GlStateManager.translate(0.0F, animProgress * (0.001F + i * 0.003F) * 20.0F, 0.0F);
		GlStateManager.matrixMode(GL11.GL_MODELVIEW);
		renderModel(backpack, renderer, ticks, renderStraps, r, g, b, true);
	}
	
	GlStateManager.matrixMode(GL11.GL_TEXTURE);
	GlStateManager.loadIdentity();
	GlStateManager.matrixMode(GL11.GL_MODELVIEW);
	
	GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
	GlStateManager.disableBlend();
	GlStateManager.depthFunc(GL11.GL_LEQUAL);
	GlStateManager.depthMask(true);
	GlStateManager.enableLighting();
	
	mc.entityRenderer.setupFogColor(false);
	
}