net.minecraft.client.renderer.GlStateManager.SourceFactor Java Examples

The following examples show how to use net.minecraft.client.renderer.GlStateManager.SourceFactor. 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: ArmorRenderHooks.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void renderArmorLayer(LayerArmorBase<ModelBase> layer, EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, EntityEquipmentSlot slotIn) {
    ItemStack itemStack = entity.getItemStackFromSlot(slotIn);

    if (isArmorItem(itemStack, slotIn)) {
        IArmorItem armorItem = (IArmorItem) itemStack.getItem();
        ModelBase armorModel = layer.getModelFromSlot(slotIn);
        if (armorModel instanceof ModelBiped) {
            armorModel = ForgeHooksClient.getArmorModel(entity, itemStack, slotIn, (ModelBiped) armorModel);
        }
        armorModel.setModelAttributes(layer.renderer.getMainModel());
        armorModel.setLivingAnimations(entity, limbSwing, limbSwingAmount, partialTicks);
        layer.setModelSlotVisible(armorModel, slotIn);

        GlStateManager.enableBlend();
        GlStateManager.blendFunc(SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);

        int layers = armorItem.getArmorLayersAmount(itemStack);
        for (int layerIndex = 0; layerIndex < layers; layerIndex++) {
            int i = armorItem.getArmorLayerColor(itemStack, layerIndex);
            float f = (float) (i >> 16 & 255) / 255.0F;
            float f1 = (float) (i >> 8 & 255) / 255.0F;
            float f2 = (float) (i & 255) / 255.0F;
            GlStateManager.color(f, f1, f2, 1.0f);
            String type = layerIndex == 0 ? null : "layer_" + layerIndex;
            layer.renderer.bindTexture(getArmorTexture(entity, itemStack, slotIn, type));
            armorModel.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
        }
        if (itemStack.hasEffect()) {
            LayerArmorBase.renderEnchantedGlint(layer.renderer, entity, armorModel, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
        }
    }
}
 
Example #2
Source File: GuiElementBase.java    From WearableBackpacks with MIT License 5 votes vote down vote up
public static void enableBlendAlphaStuffs() {
	GlStateManager.enableBlend();
	GlStateManager.tryBlendFuncSeparate(
		SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA,
		SourceFactor.ZERO, DestFactor.ONE);
	GlStateManager.disableTexture2D();
	GlStateManager.shadeModel(GL11.GL_SMOOTH);
}