Java Code Examples for net.minecraft.world.IBlockAccess#getBlockState()

The following examples show how to use net.minecraft.world.IBlockAccess#getBlockState() . 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: BlockTofuFarmLand.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
{
    switch (side)
    {
        case UP:
            return true;
        case NORTH:
        case SOUTH:
        case WEST:
        case EAST:
            IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
            Block block = iblockstate.getBlock();
            return !iblockstate.isOpaqueCube() && block != Blocks.FARMLAND && block != Blocks.GRASS_PATH;
        default:
            return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
    }
}
 
Example 2
Source File: BlockSlab.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Deprecated
@SideOnly(Side.CLIENT)
public int getPackedLightmapCoords(IBlockState state, IBlockAccess source, BlockPos pos)
{
    int i = source.getCombinedLight(pos, state.getLightValue(source, pos));

    if (i == 0 && (state.getBlock() instanceof net.minecraft.block.BlockSlab || state.getBlock() instanceof BlockSlab))
    {
        pos = pos.down();
        state = source.getBlockState(pos);
        return source.getCombinedLight(pos, state.getLightValue(source, pos));
    } else
    {
        return i;
    }
}
 
Example 3
Source File: BlockRelay.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
	IBlockState actualState = state;
	for (EnumFacing facing : EnumFacing.values()) {
		IBlockState offsetState = worldIn.getBlockState(pos.offset(facing));
		Block offsetBlock = offsetState.getBlock();
		if (offsetBlock instanceof IProtocolProvider && ((IProtocolProvider) offsetBlock).getProtocol() == protocol) {
			if (offsetBlock instanceof BlockRoutiduct && offsetState.getValue(BlockRoutiduct.AXIS) == AxisUtils.getAxis(facing) ||
				offsetBlock instanceof BlockRelay ||
				offsetBlock instanceof BlockPackager && offsetState.getValue(BlockPackager.FACING) == facing.getOpposite() ||
				offsetBlock instanceof BlockUnpackager && offsetState.getValue(BlockUnpackager.FACING) == facing.getOpposite()
				)
				actualState = actualState.withProperty(getProperty(facing), true);
		}
	}
	return actualState;
}
 
Example 4
Source File: ClearPlasticBlock.java    From EmergingTechnology with MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
  public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
  {
      IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
      Block block = iblockstate.getBlock();

      if (this == ModBlocks.clearplasticblock)
      {

          if (block == this || block == ModBlocks.solarglass || block == ModBlocks.aquaponicglass)
          {
              return false;
          }
      }

      return block == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side);
  }
 
Example 5
Source File: BlockSaltPan.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public Stat getStat(IBlockAccess world, BlockPos pos)
{
    if (world.getBlockState(pos).getBlock() == this)
    {
        IBlockState meta = world.getBlockState(pos);
        return this.getStat(meta);
    }
    else
    {
        return Stat.NA;
    }
}
 
Example 6
Source File: BlockStoneStalag.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public int getSize(IBlockState state, IBlockAccess world, BlockPos pos)
{
	int size = 0;
	for (int i = 1; i < 4; i++)
	{
		IBlockState otherState = world.getBlockState(pos.up(i));
		if(otherState.getBlock() == TFCBlocks.Stone)
		{
			size = i-1;
			break;
		}
	}

	return size;
}
 
Example 7
Source File: BlockCrystal.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState,
		IBlockAccess world, BlockPos pos, EnumFacing side) {
      
       EnumFacing dir = side;//side.getOpposite();
       IBlockState blockState2 = world.getBlockState(pos.offset(dir));
      
       return  blockState.equals(blockState2) ? false : super.shouldSideBeRendered(blockState, world, pos, side);
  
}
 
Example 8
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
private static BlockStairs.EnumShape func_185706_d(IBlockState p_185706_0_, IBlockAccess p_185706_1_, BlockPos p_185706_2_)
{
	EnumFacing enumfacing = (EnumFacing)p_185706_0_.getValue(BlockStairs.FACING);
	IBlockState iblockstate = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing));

	if (isBlockStairs(iblockstate) && p_185706_0_.getValue(BlockStairs.HALF) == iblockstate.getValue(BlockStairs.HALF))
	{
		EnumFacing enumfacing1 = (EnumFacing)iblockstate.getValue(BlockStairs.FACING);

		if (enumfacing1.getAxis() != ((EnumFacing)p_185706_0_.getValue(BlockStairs.FACING)).getAxis() && isDifferentStairs(p_185706_0_, p_185706_1_, p_185706_2_, enumfacing1.getOpposite()))
		{
			if (enumfacing1 == enumfacing.rotateYCCW())
			{
				return BlockStairs.EnumShape.OUTER_LEFT;
			}

			return BlockStairs.EnumShape.OUTER_RIGHT;
		}
	}

	IBlockState iblockstate1 = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing.getOpposite()));

	if (isBlockStairs(iblockstate1) && p_185706_0_.getValue(BlockStairs.HALF) == iblockstate1.getValue(BlockStairs.HALF))
	{
		EnumFacing enumfacing2 = (EnumFacing)iblockstate1.getValue(BlockStairs.FACING);

		if (enumfacing2.getAxis() != ((EnumFacing)p_185706_0_.getValue(BlockStairs.FACING)).getAxis() && isDifferentStairs(p_185706_0_, p_185706_1_, p_185706_2_, enumfacing2))
		{
			if (enumfacing2 == enumfacing.rotateYCCW())
			{
				return BlockStairs.EnumShape.INNER_LEFT;
			}

			return BlockStairs.EnumShape.INNER_RIGHT;
		}
	}

	return BlockStairs.EnumShape.STRAIGHT;
}
 
Example 9
Source File: BlockWall.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
private boolean canConnectTo(IBlockAccess worldIn, BlockPos pos, EnumFacing p_176253_3_)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();
    BlockFaceShape blockfaceshape = iblockstate.getBlockFaceShape(worldIn, pos, p_176253_3_);
    boolean flag = blockfaceshape == BlockFaceShape.MIDDLE_POLE_THICK || blockfaceshape == BlockFaceShape.MIDDLE_POLE && block instanceof net.minecraft.block.BlockFenceGate;
    return !isExcepBlockForAttachWithPiston(block) && blockfaceshape == BlockFaceShape.SOLID || flag;
}
 
Example 10
Source File: BlockVegDesert.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IBlockState getPlant(IBlockAccess world, BlockPos pos) 
{
	IBlockState state = world.getBlockState(pos);
	if (state.getBlock() != this) 
		return getDefaultState();
	return state;
}
 
Example 11
Source File: BlockMachine.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Nonnull
@Override
public IBlockState getFacade(@Nonnull IBlockAccess world, @Nonnull BlockPos pos, @Nullable EnumFacing side, BlockPos otherPos) {
    MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos);
    if (metaTileEntity != null && side != null) {
        CoverBehavior coverBehavior = metaTileEntity.getCoverAtSide(side);
        if (coverBehavior instanceof IFacadeCover) {
            return ((IFacadeCover) coverBehavior).getVisualState();
        }
    }
    return world.getBlockState(pos);
}
 
Example 12
Source File: BlockWaterPad.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    AgriSideMetaMatrix connection = new AgriSideMetaMatrix();
    for (EnumFacing facing : EnumFacing.HORIZONTALS) {
        final IBlockState stateAt = world.getBlockState(pos.offset(facing));
        final byte value = (byte)(stateAt.getBlock() == state.getBlock() ? 1 : 0);
        connection.set(facing, value);
    }
    return connection.writeToBlockState(state);
}
 
Example 13
Source File: SolarGlass.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos,
        EnumFacing side) {
    IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
    Block block = iblockstate.getBlock();

    if (block == this || block == ModBlocks.clearplasticblock) {
        return false;
    }

    return block == this ? false : super.shouldSideBeRendered(blockState, blockAccess, pos, side);
}
 
Example 14
Source File: BlockFuton.java    From Sakura_mod with MIT License 5 votes vote down vote up
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
	if (state.getValue(PART) == EnumPartType.FOOT) {
		IBlockState iblockstate = worldIn.getBlockState(pos.offset(state.getValue(FACING)));

		if (iblockstate.getBlock() == this) {
			state = state.withProperty(OCCUPIED, iblockstate.getValue(OCCUPIED));
		}
	}

	return state;
}
 
Example 15
Source File: BlockKawara.java    From Sakura_mod with MIT License 5 votes vote down vote up
private static EnumShape getStairsShape(IBlockState p_185706_0_, IBlockAccess p_185706_1_, BlockPos p_185706_2_)
{
  EnumFacing enumfacing = p_185706_0_.getValue(FACING);
  IBlockState iblockstate = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing.getOpposite()));
  if (isBlockStairs(iblockstate))
  {
    EnumFacing enumfacing1 = iblockstate.getValue(FACING);
    if (enumfacing1.getAxis() != p_185706_0_.getValue(FACING).getAxis())
    {
      if (enumfacing1 == enumfacing.rotateYCCW()) {
        return EnumShape.OUTER_LEFT;
      }
      return EnumShape.OUTER_RIGHT;
    }
  }
  IBlockState iblockstate1 = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing));
  if (isBlockStairs(iblockstate1))
  {
    EnumFacing enumfacing2 = iblockstate1.getValue(FACING);
    if (enumfacing2.getAxis() != p_185706_0_.getValue(FACING).getAxis())
    {
      if (enumfacing2 == enumfacing.rotateYCCW()) {
        return EnumShape.INNER_LEFT;
      }
      return EnumShape.INNER_RIGHT;
    }
  }
  return EnumShape.STRAIGHT;
}
 
Example 16
Source File: OpenBlock.java    From OpenModsLib with MIT License 4 votes vote down vote up
public final static boolean isNeighborBlockSolid(IBlockAccess world, BlockPos blockPos, EnumFacing side) {
	final BlockPos pos = blockPos.offset(side);
	final IBlockState state = world.getBlockState(pos);
	return isExceptionBlockForAttaching(state.getBlock()) ||
			state.getBlockFaceShape(world, pos, side.getOpposite()) == BlockFaceShape.SOLID;
}
 
Example 17
Source File: BlockCloud.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) {
	IBlockState iblockstate = world.getBlockState(pos.offset(side));
	return state != iblockstate;
}
 
Example 18
Source File: BlockBeaconPost.java    From Cyberware with MIT License 4 votes vote down vote up
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos)
{
	IBlockState iblockstate = worldIn.getBlockState(pos);
	Block block = iblockstate.getBlock();
	return block == Blocks.BARRIER ? false : ((!(block instanceof BlockBeaconPost) || block.getMaterial(iblockstate) != this.blockMaterial) && !(block instanceof BlockFenceGate) ? (block.getMaterial(iblockstate).isOpaque() && iblockstate.isFullCube() ? block.getMaterial(iblockstate) != Material.GOURD : false) : true);
}
 
Example 19
Source File: BlockCrop.java    From AgriCraft with MIT License 4 votes vote down vote up
@Override
public IBlockState getPlant(IBlockAccess world, BlockPos pos) {
    // TODO: Fix propertycropplant
    // TileEntity tile = world.getTileEntity(pos);
    return world.getBlockState(pos);
}
 
Example 20
Source File: BlockMixin.java    From customstuff4 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isBeaconBase(IBlockAccess world, BlockPos pos, BlockPos beacon)
{
    IBlockState state = world.getBlockState(pos);
    return getContent().isBeaconBase.get(getSubtype(state)).orElse(false);
}