Search in sources :

Example 21 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.

the class ModelConfigurableSides method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    TextureAtlasSprite[] tex = new TextureAtlasSprite[6];
    for (int i = 0; i < tex.length; i++) tex[i] = this.textures[i][0];
    char[] keyArray = "000000".toCharArray();
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState extended = (IExtendedBlockState) state;
        for (int i = 0; i < IEProperties.SIDECONFIG.length; i++) if (extended.getUnlistedNames().contains(IEProperties.SIDECONFIG[i])) {
            IEEnums.SideConfig config = extended.getValue(IEProperties.SIDECONFIG[i]);
            if (config != null) {
                int c = config.ordinal();
                tex[i] = this.textures[i][c];
                keyArray[i] = Character.forDigit(c, 10);
            }
        }
    }
    String key = name + String.copyValueOf(keyArray);
    if (!modelCache.containsKey(key))
        modelCache.put(key, bakeQuads(tex));
    return modelCache.get(key);
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) SideConfig(blusunrize.immersiveengineering.api.IEEnums.SideConfig)

Example 22 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.

the class TileRenderTurret method renderModelPart.

public static void renderModelPart(final BlockRendererDispatcher blockRenderer, Tessellator tessellator, VertexBuffer worldRenderer, World world, IBlockState state, IBakedModel model, BlockPos pos, String... parts) {
    if (state instanceof IExtendedBlockState)
        state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList(parts), true));
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(7425);
    else
        GlStateManager.shadeModel(7424);
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    worldRenderer.setTranslation(-.5 - pos.getX(), -.5 - pos.getY(), -.5 - pos.getZ());
    worldRenderer.color(255, 255, 255, 255);
    blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, worldRenderer, true);
    worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState)

Example 23 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.

the class TileRenderAutoWorkbench method renderModelPart.

public static void renderModelPart(final BlockRendererDispatcher blockRenderer, Tessellator tessellator, VertexBuffer worldRenderer, World world, IBlockState state, IBakedModel model, BlockPos pos, String... parts) {
    if (state instanceof IExtendedBlockState)
        state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList(parts), true));
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(7425);
    else
        GlStateManager.shadeModel(7424);
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    worldRenderer.setTranslation(-.5 - pos.getX(), -.5 - pos.getY(), -.5 - pos.getZ());
    worldRenderer.color(255, 255, 255, 255);
    blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, worldRenderer, true);
    worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState)

Example 24 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.

the class BlockIETileProvider method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    state = super.getExtendedState(state, world, pos);
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState extended = (IExtendedBlockState) state;
        TileEntity te = world.getTileEntity(pos);
        if (te != null) {
            if (te instanceof IConfigurableSides)
                for (int i = 0; i < 6; i++) if (extended.getUnlistedNames().contains(IEProperties.SIDECONFIG[i]))
                    extended = extended.withProperty(IEProperties.SIDECONFIG[i], ((IConfigurableSides) te).getSideConfig(i));
            if (te instanceof IAdvancedHasObjProperty)
                extended = extended.withProperty(Properties.AnimationProperty, ((IAdvancedHasObjProperty) te).getOBJState());
            else if (te instanceof IHasObjProperty)
                extended = extended.withProperty(Properties.AnimationProperty, new OBJState(((IHasObjProperty) te).compileDisplayList(), true));
            if (te instanceof IDynamicTexture)
                extended = extended.withProperty(IEProperties.OBJ_TEXTURE_REMAP, ((IDynamicTexture) te).getTextureReplacements());
            if (te instanceof IOBJModelCallback)
                extended = extended.withProperty(IOBJModelCallback.PROPERTY, (IOBJModelCallback) te);
            if (te.hasCapability(CapabilityShader.SHADER_CAPABILITY, null))
                extended = extended.withProperty(CapabilityShader.BLOCKSTATE_PROPERTY, te.getCapability(CapabilityShader.SHADER_CAPABILITY, null));
            if (te instanceof IPropertyPassthrough && ((IExtendedBlockState) state).getUnlistedNames().contains(IEProperties.TILEENTITY_PASSTHROUGH))
                extended = extended.withProperty(IEProperties.TILEENTITY_PASSTHROUGH, te);
            if (te instanceof TileEntityImmersiveConnectable && ((IExtendedBlockState) state).getUnlistedNames().contains(IEProperties.CONNECTIONS))
                extended = extended.withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable) te).genConnBlockstate());
        }
        state = extended;
    }
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityImmersiveConnectable(blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable) IOBJModelCallback(blusunrize.immersiveengineering.client.models.IOBJModelCallback) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) OBJState(net.minecraftforge.client.model.obj.OBJModel.OBJState)

Example 25 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project ImmersiveEngineering by BluSunrize.

the class BlockConnector method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    state = super.getExtendedState(state, world, pos);
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState ext = (IExtendedBlockState) state;
        TileEntity te = world.getTileEntity(pos);
        if (!(te instanceof TileEntityImmersiveConnectable))
            return state;
        state = ext.withProperty(IEProperties.CONNECTIONS, ((TileEntityImmersiveConnectable) te).genConnBlockstate());
    }
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityImmersiveConnectable(blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Aggregations

IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)29 IBlockState (net.minecraft.block.state.IBlockState)8 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)8 OBJState (net.minecraftforge.client.model.obj.OBJModel.OBJState)8 TileEntity (net.minecraft.tileentity.TileEntity)6 EnumFacing (net.minecraft.util.EnumFacing)6 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)5 BlockPos (net.minecraft.util.math.BlockPos)5 TileEntityImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable)4 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)4 CustomWoodType (com.infinityraider.agricraft.utility.CustomWoodType)2 SidedConnection (com.infinityraider.infinitylib.block.blockstate.SidedConnection)2 UnpackedBakedQuad (net.minecraftforge.client.model.pipeline.UnpackedBakedQuad)2 IModelState (net.minecraftforge.common.model.IModelState)2 ComparableItemStack (blusunrize.immersiveengineering.api.ComparableItemStack)1 SideConfig (blusunrize.immersiveengineering.api.IEEnums.SideConfig)1 Connection (blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection)1 ShaderWrapper (blusunrize.immersiveengineering.api.shader.CapabilityShader.ShaderWrapper)1 IShaderItem (blusunrize.immersiveengineering.api.shader.IShaderItem)1 ShaderCase (blusunrize.immersiveengineering.api.shader.ShaderCase)1