Search in sources :

Example 1 with SidedConnection

use of com.infinityraider.infinitylib.block.blockstate.SidedConnection in project AgriCraft by AgriCraft.

the class BlockWaterPad method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    SidedConnection connection = new SidedConnection();
    for (EnumFacing facing : EnumFacing.HORIZONTALS) {
        IBlockState stateAt = world.getBlockState(pos.offset(facing));
        connection.setConnected(facing, stateAt.getBlock() == state.getBlock());
    }
    return ((IExtendedBlockState) state).withProperty(AgriProperties.CONNECTIONS, connection);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) SidedConnection(com.infinityraider.infinitylib.block.blockstate.SidedConnection) EnumFacing(net.minecraft.util.EnumFacing)

Example 2 with SidedConnection

use of com.infinityraider.infinitylib.block.blockstate.SidedConnection in project AgriCraft by AgriCraft.

the class RenderWaterPad method renderWorldBlockStatic.

@Override
public void renderWorldBlockStatic(ITessellator tessellator, IBlockState state, BlockWaterPad block, EnumFacing side) {
    // Icon
    final TextureAtlasSprite matIcon = BaseIcons.DIRT.getIcon();
    final TextureAtlasSprite waterIcon = BaseIcons.WATER_STILL.getIcon();
    // Check Full
    SidedConnection connection = state instanceof IExtendedBlockState ? ((IExtendedBlockState) state).getValue(AgriProperties.CONNECTIONS) : DEFAULT;
    // Draw Base
    renderBase(tessellator, matIcon);
    // Render Sides
    for (EnumFacing dir : EnumFacing.HORIZONTALS) {
        if (!connection.isConnected(dir)) {
            renderSide(tessellator, dir, matIcon);
        }
    }
    // Render Water
    if (AgriProperties.POWERED.getValue(state)) {
        renderWater(tessellator, waterIcon);
    }
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) SidedConnection(com.infinityraider.infinitylib.block.blockstate.SidedConnection) EnumFacing(net.minecraft.util.EnumFacing)

Aggregations

SidedConnection (com.infinityraider.infinitylib.block.blockstate.SidedConnection)2 EnumFacing (net.minecraft.util.EnumFacing)2 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)2 IBlockState (net.minecraft.block.state.IBlockState)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1