net.minecraft.util.math.BlockPos.offset()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(84)

本文整理了Java中net.minecraft.util.math.BlockPos.offset()方法的一些代码示例,展示了BlockPos.offset()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlockPos.offset()方法的具体详情如下:
包路径:net.minecraft.util.math.BlockPos
类名称:BlockPos
方法名:offset

BlockPos.offset介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

public List<ItemStack> getFilter() {
  List<ItemStack> filter = new ArrayList<>();
  for(EnumFacing dir : EnumFacing.HORIZONTALS) {
    List<EntityItemFrame> frames = world.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1)));
    for(EntityItemFrame frame : frames) {
      EnumFacing orientation = frame.facingDirection;
      if(orientation == dir)
        filter.add(frame.getDisplayedItem());
    }
  }
  return filter;
}

代码示例来源:origin: Vazkii/Botania

@Override
public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) {
  if (world.getBlockState(pos.offset(side)).getBlock() == this) {
    return false;
  }
  return super.shouldSideBeRendered(state, world, pos, side);
}

代码示例来源:origin: Vazkii/Botania

@Override
public void onPlayerDestroy(World world, BlockPos pos, IBlockState state) {
  // TE is already gone so best we can do is just notify everyone
  for(EnumFacing side : EnumFacing.VALUES) {
    world.notifyNeighborsOfStateChange(pos.offset(side), this, false);
  }
  super.onPlayerDestroy(world, pos, state);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private boolean isConnected( IBlockAccess world, BlockPos pos, EnumFacing side )
{
  BlockPos adjacentPos = pos.offset( side );
  return world.getBlockState( adjacentPos ).getBlock() instanceof BlockCraftingUnit;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private boolean canPlaceAt( final World w, final BlockPos pos, final EnumFacing dir )
{
  final BlockPos test = pos.offset( dir );
  return w.isSideSolid( test, dir.getOpposite(), false );
}

代码示例来源:origin: Vazkii/Botania

@SideOnly(Side.CLIENT)
@Override
public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) {
  Block block = world.getBlockState(pos.offset(side)).getBlock();
  return block == this ? false : super.shouldSideBeRendered(state, world, pos, side);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private boolean isCrankable( final World world, final BlockPos pos, final EnumFacing offset )
{
  final BlockPos o = pos.offset( offset );
  final TileEntity te = world.getTileEntity( o );
  return te instanceof ICrankable && ( (ICrankable) te ).canCrankAttach( offset.getOpposite() );
}

代码示例来源:origin: Vazkii/Botania

void swapSurroudings(TilePlatform tile, boolean empty) {
  for(EnumFacing dir : EnumFacing.VALUES) {
    BlockPos pos = tile.getPos().offset(dir);
    TileEntity tileAt = world.getTileEntity(pos);
    if(tileAt != null && tileAt instanceof TilePlatform) {
      TilePlatform platform = (TilePlatform) tileAt;
      if(empty ? platform.camoState != null : platform.camoState == null)
        swapSelfAndPass(platform, empty);
    }
  }
}

代码示例来源:origin: Vazkii/Botania

public void onPlace(EntityLivingBase entity) {
  if(entity != null) {
    side = Arrays.asList(SIDES).indexOf(entity.getHorizontalFacing().getOpposite());
  }
  world.notifyNeighborsOfStateChange(getPos().offset(SIDES[side].getOpposite()), getBlockType(), false);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
{
  if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
  {
    this.refresh();
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
{
  if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
  {
    this.opacity = -1;
    this.getHost().markForUpdate();
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public boolean isSideValid( final EnumFacing side )
{
  final BlockPos p = this.pos.offset( side );
  final IBlockState blk = this.world.getBlockState( p );
  return blk.getBlock().isSideSolid( this.world.getBlockState( p ), this.world, p, side.getOpposite() );
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
{
  if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
  {
    final TileEntity te = this.getHost().getTile();
    final AEPartLocation side = this.getSide();
    final BlockPos tePos = te.getPos().offset( side.getFacing() );
    this.blocked = !w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos );
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private int blockLight( final int emit )
{
  if( this.opacity < 0 )
  {
    final TileEntity te = this.getTile();
    this.opacity = 255 - te.getWorld().getBlockLightOpacity( te.getPos().offset( this.getSide().getFacing() ) );
  }
  return (int) ( emit * ( this.opacity / 255.0f ) );
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

protected TileEntity getConnectedTE()
{
  TileEntity self = this.getHost().getTile();
  return this.getTileEntity( self, self.getPos().offset( this.getSide().getFacing() ) );
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private void notifyNeighbors()
{
  final World world = this.getTile().getWorld();
  Platform.notifyBlocksOfNeighbors( world, this.getTile().getPos() );
  // and this cause sometimes it can go thought walls.
  for( final EnumFacing face : EnumFacing.VALUES )
  {
    Platform.notifyBlocksOfNeighbors( world, this.getTile().getPos().offset( face ) );
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private boolean isDense( final AEPartLocation of )
{
  final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( of.getFacing() ) );
  if( te instanceof IGridHost )
  {
    final AECableType t = ( (IGridHost) te ).getCableConnectionType( of.getOpposite() );
    return t.isDense();
  }
  return false;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

protected InventoryAdaptor getHandler()
{
  final TileEntity self = this.getHost().getTile();
  final TileEntity target = this.getTileEntity( self, self.getPos().offset( this.getSide().getFacing() ) );
  return InventoryAdaptor.getAdaptor( target, this.getSide().getFacing().getOpposite() );
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private void updateState()
{
  final boolean isOn = this.isLevelEmitterOn();
  if( this.prevState != isOn )
  {
    this.getHost().markForUpdate();
    final TileEntity te = this.getHost().getTile();
    this.prevState = isOn;
    Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos() );
    Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos().offset( this.getSide().getFacing() ) );
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private void updateState()
{
  final boolean isOn = this.isLevelEmitterOn();
  if( this.prevState != isOn )
  {
    this.getHost().markForUpdate();
    final TileEntity te = this.getHost().getTile();
    this.prevState = isOn;
    Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos() );
    Platform.notifyBlocksOfNeighbors( te.getWorld(), te.getPos().offset( this.getSide().getFacing() ) );
  }
}

相关文章