Search in sources :

Example 71 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project XNet by McJty.

the class FacadeBakedModel method getQuads.

@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    IExtendedBlockState extendedBlockState = (IExtendedBlockState) state;
    FacadeBlockId facadeId = extendedBlockState.getValue(GenericCableBlock.FACADEID);
    if (facadeId == null) {
        return Collections.emptyList();
    }
    IBlockState facadeState = facadeId.getBlockState();
    if (!facadeState.getBlock().canRenderInLayer(facadeState, MinecraftForgeClient.getRenderLayer())) {
        return Collections.emptyList();
    }
    IBakedModel model = getModel(facadeState);
    try {
        return model.getQuads(state, side, rand);
    } catch (Exception e) {
        return Collections.emptyList();
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Example 72 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project Random-Things by lumien231.

the class BlockFluidDisplay method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    TileEntityFluidDisplay te = (TileEntityFluidDisplay) worldIn.getTileEntity(pos);
    IExtendedBlockState actualState = (IExtendedBlockState) state;
    if (te == null) {
        return actualState.withProperty(FLUID, null).withProperty(FLOWING, false);
    }
    return actualState.withProperty(FLUID, te.getFluidStack()).withProperty(FLOWING, te.flowing()).withProperty(ROTATION, te.getRotation());
}
Also used : IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) TileEntityFluidDisplay(lumien.randomthings.tileentity.TileEntityFluidDisplay)

Example 73 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project Random-Things by lumien231.

the class BlockCustomWorkbench method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    TileEntityCustomWorkbench te = (TileEntityCustomWorkbench) worldIn.getTileEntity(pos);
    IExtendedBlockState actualState = (IExtendedBlockState) state;
    if (te != null && te.getWoodState() != null) {
        return actualState.withProperty(WOOD_STATE, te.getWoodState());
    } else {
        return actualState.withProperty(WOOD_STATE, Blocks.PLANKS.getDefaultState());
    }
}
Also used : TileEntityCustomWorkbench(lumien.randomthings.tileentity.TileEntityCustomWorkbench) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Example 74 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project Random-Things by lumien231.

the class BlockRuneBase method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    TileEntityRuneBase te = (TileEntityRuneBase) worldIn.getTileEntity(pos);
    IExtendedBlockState actualState = (IExtendedBlockState) state;
    if (te != null) {
        boolean[] connectionData = new boolean[16];
        int[][] runeData = te.getRuneData();
        for (EnumFacing facing : EnumFacing.HORIZONTALS) {
            BlockPos mod = pos.offset(facing);
            TileEntity otherTE = worldIn.getTileEntity(mod);
            if (otherTE instanceof TileEntityRuneBase) {
                TileEntityRuneBase otherRune = (TileEntityRuneBase) otherTE;
                int[][] otherRuneData = otherRune.getRuneData();
                for (int i = 0; i < 4; i++) {
                    if (facing == EnumFacing.NORTH) {
                        connectionData[i] = runeData[i][0] == otherRuneData[i][3];
                    } else if (facing == EnumFacing.EAST) {
                        connectionData[i + 4] = runeData[3][i] == otherRuneData[0][i];
                    } else if (facing == EnumFacing.SOUTH) {
                        connectionData[i + 8] = runeData[i][3] == otherRuneData[i][0];
                    } else if (facing == EnumFacing.WEST) {
                        connectionData[i + 12] = runeData[0][i] == otherRuneData[3][i];
                    }
                }
            }
        }
        return actualState.withProperty(RUNE_DATA, runeData).withProperty(CONNECTION_DATA, connectionData);
    } else {
        return actualState.withProperty(RUNE_DATA, new int[4][4]);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) TileEntityRuneBase(lumien.randomthings.tileentity.TileEntityRuneBase)

Example 75 with IExtendedBlockState

use of net.minecraftforge.common.property.IExtendedBlockState in project Random-Things by lumien231.

the class BlockInventoryRerouter method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    TileEntity te = worldIn.getTileEntity(pos);
    IExtendedBlockState extendedState = (IExtendedBlockState) state;
    if (te instanceof TileEntityInventoryRerouter) {
        TileEntityInventoryRerouter rerouter = (TileEntityInventoryRerouter) te;
        Map<EnumFacing, EnumFacing> facingMap = rerouter.getFacingMap();
        return extendedState.withProperty(OVERRIDE_DATA, new HashMap<>(facingMap));
    }
    return super.getActualState(state, worldIn, pos);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) EnumFacing(net.minecraft.util.EnumFacing) TileEntityInventoryRerouter(lumien.randomthings.tileentity.TileEntityInventoryRerouter)

Aggregations

IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)96 IBlockState (net.minecraft.block.state.IBlockState)27 BlockPos (net.minecraft.util.math.BlockPos)24 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)17 EnumFacing (net.minecraft.util.EnumFacing)17 OBJState (net.minecraftforge.client.model.obj.OBJModel.OBJState)17 TileEntity (net.minecraft.tileentity.TileEntity)16 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)14 ArrayList (java.util.ArrayList)13 IBlockAccess (net.minecraft.world.IBlockAccess)13 UnlistedBlockPos (forestry.core.blocks.properties.UnlistedBlockPos)10 TileEntityImmersiveConnectable (blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable)7 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)7 Block (net.minecraft.block.Block)6 ItemStack (net.minecraft.item.ItemStack)6 Nonnull (javax.annotation.Nonnull)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 Minecraft (net.minecraft.client.Minecraft)3 Vec3d (net.minecraft.util.math.Vec3d)3