From 4d5a6ce301c8becebb45ebad9b695ebe9e44c9e1 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 4 May 2014 15:46:38 -0500 Subject: [PATCH] Add Stained Glass facades. The Item Bus Renderer can now deal with Alpha Pass. --- client/render/BusRenderer.java | 21 ++++++++++++++++++--- core/features/AEFeature.java | 4 +++- items/parts/ItemFacade.java | 16 ++++++++++++++-- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/client/render/BusRenderer.java b/client/render/BusRenderer.java index 63a21117..358c3569 100644 --- a/client/render/BusRenderer.java +++ b/client/render/BusRenderer.java @@ -10,10 +10,13 @@ import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; +import appeng.api.parts.IAlphaPassItem; import appeng.api.parts.IFacadePart; import appeng.api.parts.IPart; import appeng.api.parts.IPartItem; import appeng.client.ClientHelper; +import appeng.core.AEConfig; +import appeng.core.features.AEFeature; import appeng.facade.IFacadeItem; import appeng.util.Platform; import cpw.mods.fml.relauncher.Side; @@ -63,11 +66,24 @@ public class BusRenderer implements IItemRenderer GL11.glPushMatrix(); GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); - GL11.glEnable( GL11.GL_ALPHA_TEST ); GL11.glEnable( GL11.GL_DEPTH_TEST ); GL11.glEnable( GL11.GL_TEXTURE_2D ); GL11.glEnable( GL11.GL_LIGHTING ); - GL11.glDisable( GL11.GL_BLEND ); + + if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) && item.getItem() instanceof IAlphaPassItem + && ((IAlphaPassItem) item.getItem()).useAlphaPass( item ) ) + { + GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA ); + GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); + GL11.glDisable( GL11.GL_ALPHA_TEST ); + GL11.glEnable( GL11.GL_BLEND ); + } + else + { + GL11.glAlphaFunc( GL11.GL_GREATER, 0.4f ); + GL11.glEnable( GL11.GL_ALPHA_TEST ); + GL11.glDisable( GL11.GL_BLEND ); + } if ( type == ItemRenderType.EQUIPPED_FIRST_PERSON ) { @@ -79,7 +95,6 @@ public class BusRenderer implements IItemRenderer GL11.glRotatef( 90.0f, 0.0f, 1.0f, 0.0f ); GL11.glScalef( 0.8f, 0.8f, 0.8f ); GL11.glTranslatef( -0.8f, -0.87f, -0.7f ); - } if ( type == ItemRenderType.INVENTORY ) diff --git a/core/features/AEFeature.java b/core/features/AEFeature.java index 7ce99846..74529d93 100644 --- a/core/features/AEFeature.java +++ b/core/features/AEFeature.java @@ -50,7 +50,9 @@ public enum AEFeature Logging("Misc"), IntegrationLogging("Misc", false), CustomRecipes("Crafting", false), WebsiteRecipes("Misc", false), - enableFacadeCrafting("Crafting"), inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting"), UpdateLogging("Misc", false); + enableFacadeCrafting("Crafting"), inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting"), UpdateLogging("Misc", false), + + AlphaPass("Rendering"); String Category; boolean visible = true; diff --git a/items/parts/ItemFacade.java b/items/parts/ItemFacade.java index 97c51824..7ce29ec0 100644 --- a/items/parts/ItemFacade.java +++ b/items/parts/ItemFacade.java @@ -6,6 +6,7 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockGlass; +import net.minecraft.block.BlockStainedGlass; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -17,6 +18,7 @@ import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.util.ForgeDirection; import appeng.api.AEApi; +import appeng.api.parts.IAlphaPassItem; import appeng.block.solids.OreQuartz; import appeng.client.render.BusRenderer; import appeng.core.FacadeConfig; @@ -28,7 +30,7 @@ import appeng.util.Platform; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class ItemFacade extends AEBaseItem implements IFacadeItem +public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassItem { public ItemFacade() { @@ -141,7 +143,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem int metadata = l.getItem().getMetadata( l.getItemDamage() ); boolean hasTile = b.hasTileEntity( metadata ); - boolean enableGlass = b instanceof BlockGlass; + boolean enableGlass = b instanceof BlockGlass || b instanceof BlockStainedGlass; boolean disableOre = b instanceof OreQuartz; boolean defaultValue = (b.isOpaqueCube() && !b.getTickRandomly() && !hasTile && !disableOre) || enableGlass; @@ -207,4 +209,14 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem return super.getItemStackDisplayName( is ); } + @Override + public boolean useAlphaPass(ItemStack is) + { + ItemStack out = getTextureItem( is ); + Block blk = Block.getBlockFromItem( out.getItem() ); + if ( blk != null && blk.canRenderInPass( 1 ) ) + return true; + return false; + } + }